From: SONOLET Aymeric Date: Thu, 4 Apr 2024 14:36:51 +0000 (+0200) Subject: refactor: add missing includes and remove unused X-Git-Tag: V9_14_0a1~17 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5972d7ba5e003a70bee90674cb1775b122caa03b;p=tools%2Fmedcoupling.git refactor: add missing includes and remove unused --- diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 000000000..a42aee021 --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,32 @@ +--- +Checks: -*,clang-diagnostic-*,-clang-diagnostic-sign-conversion,clang-analyzer-*,modernize-use-override,modernize-use-nullptr,modernize-use-default-member-init,modernize-loop-convert,modernize-use-auto,modernize-redundant-void-arg,modernize-type-traits,modernize-use-bool-literals,modernize-use-equals-default,modernize-use-equals-delete,misc-const-correctness,misc-unused-parameters,misc-definitions-in-headers,misc-header-include-cycle,misc-redundant-expression,misc-static-assert +WarningsAsErrors: '' +HeaderFileExtensions: + - '' + - h + - hh + - hpp + - hxx + - txx +ImplementationFileExtensions: + - c + - cc + - cpp + - cxx +HeaderFilterRegex: '' +FormatStyle: none +CheckOptions: + cert-dcl16-c.NewSuffixes: L;LL;LU;LLU + cert-err33-c.AllowCastToVoid: 'true' + cert-err33-c.CheckedFunctions: ::aligned_alloc;::asctime_s;::at_quick_exit;::atexit;::bsearch;::bsearch_s;::btowc;::c16rtomb;::c32rtomb;::calloc;::clock;::cnd_broadcast;::cnd_init;::cnd_signal;::cnd_timedwait;::cnd_wait;::ctime_s;::fclose;::fflush;::fgetc;::fgetpos;::fgets;::fgetwc;::fopen;::fopen_s;::fprintf;::fprintf_s;::fputc;::fputs;::fputwc;::fputws;::fread;::freopen;::freopen_s;::fscanf;::fscanf_s;::fseek;::fsetpos;::ftell;::fwprintf;::fwprintf_s;::fwrite;::fwscanf;::fwscanf_s;::getc;::getchar;::getenv;::getenv_s;::gets_s;::getwc;::getwchar;::gmtime;::gmtime_s;::localtime;::localtime_s;::malloc;::mbrtoc16;::mbrtoc32;::mbsrtowcs;::mbsrtowcs_s;::mbstowcs;::mbstowcs_s;::memchr;::mktime;::mtx_init;::mtx_lock;::mtx_timedlock;::mtx_trylock;::mtx_unlock;::printf_s;::putc;::putwc;::raise;::realloc;::remove;::rename;::scanf;::scanf_s;::setlocale;::setvbuf;::signal;::snprintf;::snprintf_s;::sprintf;::sprintf_s;::sscanf;::sscanf_s;::strchr;::strerror_s;::strftime;::strpbrk;::strrchr;::strstr;::strtod;::strtof;::strtoimax;::strtok;::strtok_s;::strtol;::strtold;::strtoll;::strtoul;::strtoull;::strtoumax;::strxfrm;::swprintf;::swprintf_s;::swscanf;::swscanf_s;::thrd_create;::thrd_detach;::thrd_join;::thrd_sleep;::time;::timespec_get;::tmpfile;::tmpfile_s;::tmpnam;::tmpnam_s;::tss_create;::tss_get;::tss_set;::ungetc;::ungetwc;::vfprintf;::vfprintf_s;::vfscanf;::vfscanf_s;::vfwprintf;::vfwprintf_s;::vfwscanf;::vfwscanf_s;::vprintf_s;::vscanf;::vscanf_s;::vsnprintf;::vsnprintf_s;::vsprintf;::vsprintf_s;::vsscanf;::vsscanf_s;::vswprintf;::vswprintf_s;::vswscanf;::vswscanf_s;::vwprintf_s;::vwscanf;::vwscanf_s;::wcrtomb;::wcschr;::wcsftime;::wcspbrk;::wcsrchr;::wcsrtombs;::wcsrtombs_s;::wcsstr;::wcstod;::wcstof;::wcstoimax;::wcstok;::wcstok_s;::wcstol;::wcstold;::wcstoll;::wcstombs;::wcstombs_s;::wcstoul;::wcstoull;::wcstoumax;::wcsxfrm;::wctob;::wctrans;::wctype;::wmemchr;::wprintf_s;::wscanf;::wscanf_s; + cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField: 'false' + cert-str34-c.DiagnoseSignedUnsignedCharComparisons: 'false' + cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic: 'true' + google-readability-braces-around-statements.ShortStatementLines: '1' + google-readability-function-size.StatementThreshold: '800' + google-readability-namespace-comments.ShortNamespaceLines: '10' + google-readability-namespace-comments.SpacesBeforeComments: '2' + llvm-else-after-return.WarnOnConditionVariables: 'false' + llvm-else-after-return.WarnOnUnfixable: 'false' + llvm-qualified-auto.AddConstToQualified: 'false' +SystemHeaders: false diff --git a/src/ICoCo/ICoCoMEDDoubleField.cxx b/src/ICoCo/ICoCoMEDDoubleField.cxx index d408e30bb..913240c5f 100644 --- a/src/ICoCo/ICoCoMEDDoubleField.cxx +++ b/src/ICoCo/ICoCoMEDDoubleField.cxx @@ -22,7 +22,7 @@ namespace ICoCo { - MEDDoubleField::MEDDoubleField() : _field(0) {} + MEDDoubleField::MEDDoubleField() : _field(nullptr) {} MEDDoubleField::MEDDoubleField(MEDCoupling::MEDCouplingFieldDouble *field):_field(field) { diff --git a/src/ICoCo/ICoCoMEDDoubleField.hxx b/src/ICoCo/ICoCoMEDDoubleField.hxx index d316e9dfe..ee0e3d19b 100644 --- a/src/ICoCo/ICoCoMEDDoubleField.hxx +++ b/src/ICoCo/ICoCoMEDDoubleField.hxx @@ -26,6 +26,7 @@ #define ICoCoMEDDoubleField_included #include "ICoCoField.hxx" +#include "ICoCo_DeclSpec.hxx" namespace MEDCoupling { @@ -72,7 +73,7 @@ namespace ICoCo /*! @brief Destructor. */ - virtual ~MEDDoubleField(); + ~MEDDoubleField() override; /*! @brief Get the internal MEDCoupling field object. * @return a pointer to the MEDCouplingField object detained by this instance. Note that the corresponding diff --git a/src/ICoCo/ICoCoMEDIntField.cxx b/src/ICoCo/ICoCoMEDIntField.cxx index 32dfc2d47..472b23e27 100644 --- a/src/ICoCo/ICoCoMEDIntField.cxx +++ b/src/ICoCo/ICoCoMEDIntField.cxx @@ -18,12 +18,13 @@ // #include "ICoCoMEDIntField.h" +#include "ICoCoMEDIntField.hxx" #include "MEDCouplingFieldInt32.hxx" namespace ICoCo { - MEDIntField::MEDIntField() : _field(0) {} + MEDIntField::MEDIntField() : _field(nullptr) {} /*! Constructor directly attaching a MEDCouplingFieldInt the object does not take the control the objects pointed by diff --git a/src/ICoCo/ICoCoMEDIntField.hxx b/src/ICoCo/ICoCoMEDIntField.hxx index d0ab9f8c4..ff76d3293 100644 --- a/src/ICoCo/ICoCoMEDIntField.hxx +++ b/src/ICoCo/ICoCoMEDIntField.hxx @@ -26,6 +26,7 @@ #define ICoCoMEDIntField_included #include "ICoCoField.hxx" +#include "ICoCo_DeclSpec.hxx" namespace MEDCoupling { @@ -72,7 +73,7 @@ namespace ICoCo /*! @brief Destructor. */ - virtual ~MEDIntField(); + ~MEDIntField() override; /*! @brief Get the internal MEDCoupling field object. * @return a pointer to the MEDCouplingField object detained by this instance. Note that the corresponding diff --git a/src/INTERP_KERNEL/BBTree.txx b/src/INTERP_KERNEL/BBTree.txx index f837e2a48..27163c7c8 100644 --- a/src/INTERP_KERNEL/BBTree.txx +++ b/src/INTERP_KERNEL/BBTree.txx @@ -22,7 +22,6 @@ #include #include -#include #include #include #include diff --git a/src/INTERP_KERNEL/BBTreeDst.txx b/src/INTERP_KERNEL/BBTreeDst.txx old mode 100755 new mode 100644 index c09cdf9c2..0e656d4bb --- a/src/INTERP_KERNEL/BBTreeDst.txx +++ b/src/INTERP_KERNEL/BBTreeDst.txx @@ -21,13 +21,14 @@ #ifndef __BBTREEDST_TXX__ #define __BBTREEDST_TXX__ -#include #include +#include -#include #include #include +#include "MCIdType.hxx" + template class BBTreeDst { @@ -39,14 +40,14 @@ private: double _min_right; const double *_bb; std::vector _elems; - double *_terminal; + double *_terminal{nullptr}; mcIdType _nbelems; static const int MIN_NB_ELEMS=15; static const int MAX_LEVEL=20; public: BBTreeDst(const double* bbs, mcIdType* elems, int level, mcIdType nbelems): - _left(0),_right(0),_level(level),_bb(bbs),_terminal(0),_nbelems(nbelems) + _left(0),_right(0),_level(level),_bb(bbs),_nbelems(nbelems) { if((nbelems < MIN_NB_ELEMS || level> MAX_LEVEL)) _terminal=new double[2*dim]; @@ -58,11 +59,11 @@ public: fillBBoxTerminal(bbs); return ; } - double *nodes=new double[nbelems]; + auto *nodes=new double[nbelems]; for (mcIdType i=0; i(nodes, nodes+nbelems/2, nodes+nbelems); - double median = *(nodes+nbelems/2); + double const median = *(nodes+nbelems/2); delete [] nodes; std::vector new_elems_left; std::vector new_elems_right; @@ -74,7 +75,7 @@ public: for(mcIdType i=0; iminOfMaxDsts) { _left->getElemsWhoseMinDistanceToPtSmallerThan(pt,minOfMaxDstsSq,elems); return ; } if(pt[_level%dim]-_max_left>minOfMaxDsts) @@ -151,7 +152,7 @@ public: } else { - double minOfMaxDsts=sqrt(minOfMaxDstsSq); + double const minOfMaxDsts=sqrt(minOfMaxDstsSq); if(_min_right-pt[_level%dim]>minOfMaxDsts) { _left->getMinDistanceOfMax(pt,minOfMaxDstsSq); return ; } if(pt[_level%dim]-_max_left>minOfMaxDsts) @@ -186,7 +187,7 @@ public: for (int idim=0; idim((( (0.((( (0. #include -#include #include #include @@ -66,7 +65,7 @@ public: BBTreePts(const double *pts, const ConnType *elems, int level, ConnType nbelems, double epsilon=1e-12): _left(0),_right(0),_level(level),_pts(pts),_terminal(nbelems < MIN_NB_ELEMS || level> MAX_LEVEL),_nbelems(nbelems),_epsilon(std::abs(epsilon)) { - double *nodes=new double[nbelems]; + auto *nodes=new double[nbelems]; _elems.resize(nbelems); for (ConnType i=0;i +#include +#include /*! * Wrapper over BBTree to deal with ownership of bbox double array. diff --git a/src/INTERP_KERNEL/Barycentric3DIntersectorP1P1.hxx b/src/INTERP_KERNEL/Barycentric3DIntersectorP1P1.hxx index 93dc670b4..e945ffb3d 100644 --- a/src/INTERP_KERNEL/Barycentric3DIntersectorP1P1.hxx +++ b/src/INTERP_KERNEL/Barycentric3DIntersectorP1P1.hxx @@ -23,6 +23,7 @@ #include "Intersector3DP1P1.hxx" #include "NormalizedUnstructuredMesh.hxx" +#include namespace INTERP_KERNEL { @@ -32,7 +33,7 @@ namespace INTERP_KERNEL public: static const int SPACEDIM=MyMeshType::MY_SPACEDIM; static const int MESHDIM=MyMeshType::MY_MESHDIM; - typedef typename MyMeshType::MyConnType ConnType; + using ConnType = typename MyMeshType::MyConnType; static const NumberingPolicy numPol=MyMeshType::My_numPol; public: Barycentric3DIntersectorP1P1(const MyMeshType& targetMesh, const MyMeshType& srcMesh, double precision); diff --git a/src/INTERP_KERNEL/Barycentric3DIntersectorP1P1.txx b/src/INTERP_KERNEL/Barycentric3DIntersectorP1P1.txx index b58a279ae..4019faeff 100644 --- a/src/INTERP_KERNEL/Barycentric3DIntersectorP1P1.txx +++ b/src/INTERP_KERNEL/Barycentric3DIntersectorP1P1.txx @@ -23,7 +23,14 @@ #include "Barycentric3DIntersectorP1P1.hxx" #include "Intersector3DP1P1.txx" -#include "MeshUtils.hxx" +#include "InterpolationUtils.hxx" +#include "InterpKernelUtilities.hxx" +#include +#include +#include "NormalizedGeometricTypes" +#include +#include "CellModel.hxx" +#include "PointLocatorAlgos.txx" namespace INTERP_KERNEL { @@ -42,8 +49,7 @@ namespace INTERP_KERNEL template Barycentric3DIntersectorP1P1::~Barycentric3DIntersectorP1P1() - { - } + = default; /** * @param targetCell in C mode. diff --git a/src/INTERP_KERNEL/Bases/InterpKernelAssert.hxx b/src/INTERP_KERNEL/Bases/InterpKernelAssert.hxx index e59519ce7..a3b31d42b 100644 --- a/src/INTERP_KERNEL/Bases/InterpKernelAssert.hxx +++ b/src/INTERP_KERNEL/Bases/InterpKernelAssert.hxx @@ -21,9 +21,7 @@ #ifndef __INTERPKERNELASSERT_HXX__ #define __INTERPKERNELASSERT_HXX__ -#include "InterpKernelException.hxx" -#include #define IKAssert(a) { bool verdict(a); \ if(!verdict) { std::ostringstream osszz; osszz << "Assertion \"" << #a << "\" failed into " << __FILE__ << " at line " << __LINE__ << " !"; throw INTERP_KERNEL::Exception(osszz.str()); } } diff --git a/src/INTERP_KERNEL/Bases/InterpKernelException.cxx b/src/INTERP_KERNEL/Bases/InterpKernelException.cxx index 0d6d7adca..836190715 100644 --- a/src/INTERP_KERNEL/Bases/InterpKernelException.cxx +++ b/src/INTERP_KERNEL/Bases/InterpKernelException.cxx @@ -28,13 +28,12 @@ INTERP_KERNEL::Exception::Exception(const std::string& reason):_reason(reason) { } -INTERP_KERNEL::Exception::Exception(const char *reason, const char *file, int line):_reason(reason) +INTERP_KERNEL::Exception::Exception(const char *reason, const char * /*file*/, int /*line*/):_reason(reason) { } INTERP_KERNEL::Exception::~Exception() noexcept(true) -{ -} += default; const char *INTERP_KERNEL::Exception::what() const noexcept(true) { diff --git a/src/INTERP_KERNEL/Bases/InterpKernelException.hxx b/src/INTERP_KERNEL/Bases/InterpKernelException.hxx index 1d6ce7d7c..3eeab812d 100644 --- a/src/INTERP_KERNEL/Bases/InterpKernelException.hxx +++ b/src/INTERP_KERNEL/Bases/InterpKernelException.hxx @@ -35,8 +35,8 @@ namespace INTERP_KERNEL INTERPKERNEL_EXPORT Exception(const char *reason); INTERPKERNEL_EXPORT Exception(const std::string& reason); INTERPKERNEL_EXPORT Exception(const char *reason, const char *file, int line); - INTERPKERNEL_EXPORT ~Exception() noexcept(true); - INTERPKERNEL_EXPORT const char *what() const noexcept(true); + INTERPKERNEL_EXPORT ~Exception() noexcept(true) override; + INTERPKERNEL_EXPORT const char *what() const noexcept(true) override; protected: std::string _reason; }; diff --git a/src/INTERP_KERNEL/Bases/InterpKernelHashMap.hxx b/src/INTERP_KERNEL/Bases/InterpKernelHashMap.hxx index e4fc93c81..212e701a1 100644 --- a/src/INTERP_KERNEL/Bases/InterpKernelHashMap.hxx +++ b/src/INTERP_KERNEL/Bases/InterpKernelHashMap.hxx @@ -48,8 +48,13 @@ #ifndef __INTERPKERNELHASHMAP__ #define __INTERPKERNELHASHMAP__ +#include "InterpKernelHashFun.hxx" #include "InterpKernelStlExt.hxx" #include "InterpKernelHashTable.hxx" +#include +#include +#include +#include namespace INTERP_KERNEL { @@ -58,31 +63,29 @@ namespace INTERP_KERNEL class HashMap { private: - typedef hashtable,_Key, _HashFn, - STLEXT::Select1st >, - _EqualKey, _Alloc> _Ht; + using _Ht = hashtable, _Key, _HashFn, STLEXT::Select1st>, _EqualKey, _Alloc>; _Ht _M_ht; public: - typedef typename _Ht::key_type key_type; - typedef _Tp data_type; - typedef _Tp mapped_type; - typedef typename _Ht::value_type value_type; - typedef typename _Ht::hasher hasher; - typedef typename _Ht::key_equal key_equal; - - typedef typename _Ht::size_type size_type; - typedef typename _Ht::difference_type difference_type; - typedef typename _Ht::pointer pointer; - typedef typename _Ht::const_pointer const_pointer; - typedef typename _Ht::reference reference; - typedef typename _Ht::const_reference const_reference; - - typedef typename _Ht::iterator iterator; - typedef typename _Ht::const_iterator const_iterator; - - typedef typename _Ht::allocator_type allocator_type; + using key_type = typename _Ht::key_type; + using data_type = _Tp; + using mapped_type = _Tp; + using value_type = typename _Ht::value_type; + using hasher = typename _Ht::hasher; + using key_equal = typename _Ht::key_equal; + + using size_type = typename _Ht::size_type; + using difference_type = typename _Ht::difference_type; + using pointer = typename _Ht::pointer; + using const_pointer = typename _Ht::const_pointer; + using reference = typename _Ht::reference; + using const_reference = typename _Ht::const_reference; + + using iterator = typename _Ht::iterator; + using const_iterator = typename _Ht::const_iterator; + + using allocator_type = typename _Ht::allocator_type; hasher hash_funct() const { return _M_ht.hash_funct(); } @@ -197,29 +200,27 @@ namespace INTERP_KERNEL class HashMultiMap { private: - typedef hashtable, _Key, _HashFn, - STLEXT::Select1st >, _EqualKey, _Alloc> - _Ht; + using _Ht = hashtable, _Key, _HashFn, STLEXT::Select1st>, _EqualKey, _Alloc>; _Ht _M_ht; public: - typedef typename _Ht::key_type key_type; - typedef _Tp data_type; - typedef _Tp mapped_type; - typedef typename _Ht::value_type value_type; - typedef typename _Ht::hasher hasher; - typedef typename _Ht::key_equal key_equal; - - typedef typename _Ht::size_type size_type; - typedef typename _Ht::difference_type difference_type; - typedef typename _Ht::pointer pointer; - typedef typename _Ht::const_pointer const_pointer; - typedef typename _Ht::reference reference; - typedef typename _Ht::const_reference const_reference; - - typedef typename _Ht::iterator iterator; - typedef typename _Ht::const_iterator const_iterator; - - typedef typename _Ht::allocator_type allocator_type; + using key_type = typename _Ht::key_type; + using data_type = _Tp; + using mapped_type = _Tp; + using value_type = typename _Ht::value_type; + using hasher = typename _Ht::hasher; + using key_equal = typename _Ht::key_equal; + + using size_type = typename _Ht::size_type; + using difference_type = typename _Ht::difference_type; + using pointer = typename _Ht::pointer; + using const_pointer = typename _Ht::const_pointer; + using reference = typename _Ht::reference; + using const_reference = typename _Ht::const_reference; + + using iterator = typename _Ht::iterator; + using const_iterator = typename _Ht::const_iterator; + + using allocator_type = typename _Ht::allocator_type; hasher hash_funct() const { return _M_ht.hash_funct(); } @@ -336,16 +337,15 @@ namespace std _EqKey, _Alloc> > { protected: - typedef INTERP_KERNEL::HashMap<_Key, _Tp, _HashFn, _EqKey, _Alloc> - _Container; + using _Container = INTERP_KERNEL::HashMap<_Key, _Tp, _HashFn, _EqKey, _Alloc>; _Container* container; public: - typedef _Container container_type; - typedef output_iterator_tag iterator_category; - typedef void value_type; - typedef void difference_type; - typedef void pointer; - typedef void reference; + using container_type = _Container; + using iterator_category = output_iterator_tag; + using value_type = void; + using difference_type = void; + using pointer = void; + using reference = void; insert_iterator(_Container& __x) : container(&__x) {} @@ -369,18 +369,17 @@ namespace std _EqKey, _Alloc> > { protected: - typedef INTERP_KERNEL::HashMultiMap<_Key, _Tp, _HashFn, _EqKey, _Alloc> - _Container; + using _Container = INTERP_KERNEL::HashMultiMap<_Key, _Tp, _HashFn, _EqKey, _Alloc>; _Container* container; typename _Container::iterator iter; public: - typedef _Container container_type; - typedef output_iterator_tag iterator_category; - typedef void value_type; - typedef void difference_type; - typedef void pointer; - typedef void reference; + using container_type = _Container; + using iterator_category = output_iterator_tag; + using value_type = void; + using difference_type = void; + using pointer = void; + using reference = void; insert_iterator(_Container& __x) : container(&__x) {} diff --git a/src/INTERP_KERNEL/Bases/InterpKernelHashTable.hxx b/src/INTERP_KERNEL/Bases/InterpKernelHashTable.hxx index 5659e8e7c..2238fd98d 100644 --- a/src/INTERP_KERNEL/Bases/InterpKernelHashTable.hxx +++ b/src/INTERP_KERNEL/Bases/InterpKernelHashTable.hxx @@ -49,13 +49,13 @@ #ifndef __INTERPKERNELHASHTABLE_HXX__ #define __INTERPKERNELHASHTABLE_HXX__ -#include "InterpKernelStlExt.hxx" -#include "InterpKernelHashFun.hxx" +#include +#include +#include #include #include #include -#include namespace INTERP_KERNEL { @@ -82,21 +82,16 @@ namespace INTERP_KERNEL class _ExtractKey, class _EqualKey, class _Alloc> struct _Hashtable_iterator { - typedef hashtable<_Val, _Key, _HashFcn, _ExtractKey, _EqualKey, _Alloc> - _Hashtable; - typedef _Hashtable_iterator<_Val, _Key, _HashFcn, - _ExtractKey, _EqualKey, _Alloc> - iterator; - typedef _Hashtable_const_iterator<_Val, _Key, _HashFcn, - _ExtractKey, _EqualKey, _Alloc> - const_iterator; - typedef _Hashtable_node<_Val> _Node; - typedef std::forward_iterator_tag iterator_category; - typedef _Val value_type; - typedef std::ptrdiff_t difference_type; - typedef std::size_t size_type; - typedef _Val& reference; - typedef _Val* pointer; + using _Hashtable = hashtable<_Val, _Key, _HashFcn, _ExtractKey, _EqualKey, _Alloc>; + using iterator = _Hashtable_iterator<_Val, _Key, _HashFcn, _ExtractKey, _EqualKey, _Alloc>; + using const_iterator = _Hashtable_const_iterator<_Val, _Key, _HashFcn, _ExtractKey, _EqualKey, _Alloc>; + using _Node = _Hashtable_node<_Val>; + using iterator_category = std::forward_iterator_tag; + using value_type = _Val; + using difference_type = std::ptrdiff_t; + using size_type = std::size_t; + using reference = _Val &; + using pointer = _Val *; _Node* _M_cur; _Hashtable* _M_ht; @@ -104,7 +99,7 @@ namespace INTERP_KERNEL _Hashtable_iterator(_Node* __n, _Hashtable* __tab) : _M_cur(__n), _M_ht(__tab) { } - _Hashtable_iterator() { } + _Hashtable_iterator() = default; reference operator*() const @@ -133,22 +128,17 @@ namespace INTERP_KERNEL class _ExtractKey, class _EqualKey, class _Alloc> struct _Hashtable_const_iterator { - typedef hashtable<_Val, _Key, _HashFcn, _ExtractKey, _EqualKey, _Alloc> - _Hashtable; - typedef _Hashtable_iterator<_Val,_Key,_HashFcn, - _ExtractKey,_EqualKey,_Alloc> - iterator; - typedef _Hashtable_const_iterator<_Val, _Key, _HashFcn, - _ExtractKey, _EqualKey, _Alloc> - const_iterator; - typedef _Hashtable_node<_Val> _Node; - - typedef std::forward_iterator_tag iterator_category; - typedef _Val value_type; - typedef std::ptrdiff_t difference_type; - typedef std::size_t size_type; - typedef const _Val& reference; - typedef const _Val* pointer; + using _Hashtable = hashtable<_Val, _Key, _HashFcn, _ExtractKey, _EqualKey, _Alloc>; + using iterator = _Hashtable_iterator<_Val, _Key, _HashFcn, _ExtractKey, _EqualKey, _Alloc>; + using const_iterator = _Hashtable_const_iterator<_Val, _Key, _HashFcn, _ExtractKey, _EqualKey, _Alloc>; + using _Node = _Hashtable_node<_Val>; + + using iterator_category = std::forward_iterator_tag; + using value_type = _Val; + using difference_type = std::ptrdiff_t; + using size_type = std::size_t; + using reference = const _Val &; + using pointer = const _Val *; const _Node* _M_cur; const _Hashtable* _M_ht; @@ -156,7 +146,7 @@ namespace INTERP_KERNEL _Hashtable_const_iterator(const _Node* __n, const _Hashtable* __tab) : _M_cur(__n), _M_ht(__tab) { } - _Hashtable_const_iterator() { } + _Hashtable_const_iterator() = default; _Hashtable_const_iterator(const iterator& __it) : _M_cur(__it._M_cur), _M_ht(__it._M_ht) { } @@ -219,33 +209,33 @@ namespace INTERP_KERNEL class hashtable { public: - typedef _Key key_type; - typedef _Val value_type; - typedef _HashFcn hasher; - typedef _EqualKey key_equal; - - typedef std::size_t size_type; - typedef std::ptrdiff_t difference_type; - typedef value_type* pointer; - typedef const value_type* const_pointer; - typedef value_type& reference; - typedef const value_type& const_reference; + using key_type = _Key; + using value_type = _Val; + using hasher = _HashFcn; + using key_equal = _EqualKey; + + using size_type = std::size_t; + using difference_type = std::ptrdiff_t; + using pointer = value_type *; + using const_pointer = const value_type *; + using reference = value_type &; + using const_reference = const value_type &; hasher hash_funct() const { return _M_hash; } key_equal key_eq() const { return _M_equals; } private: - typedef _Hashtable_node<_Val> _Node; + using _Node = _Hashtable_node<_Val>; public: - typedef typename _Alloc::template rebind::other allocator_type; + using allocator_type = typename _Alloc::template rebind::other; allocator_type get_allocator() const { return _M_node_allocator; } private: - typedef typename _Alloc::template rebind<_Node>::other _Node_Alloc; - typedef typename _Alloc::template rebind<_Node*>::other _Nodeptr_Alloc; - typedef std::vector<_Node*, _Nodeptr_Alloc> _Vector_type; + using _Node_Alloc = typename _Alloc::template rebind<_Node>::other; + using _Nodeptr_Alloc = typename _Alloc::template rebind<_Node *>::other; + using _Vector_type = std::vector<_Node *, _Nodeptr_Alloc>; _Node_Alloc _M_node_allocator; @@ -261,12 +251,8 @@ namespace INTERP_KERNEL size_type _M_num_elements; public: - typedef _Hashtable_iterator<_Val, _Key, _HashFcn, _ExtractKey, - _EqualKey, _Alloc> - iterator; - typedef _Hashtable_const_iterator<_Val, _Key, _HashFcn, _ExtractKey, - _EqualKey, _Alloc> - const_iterator; + using iterator = _Hashtable_iterator<_Val, _Key, _HashFcn, _ExtractKey, _EqualKey, _Alloc>; + using const_iterator = _Hashtable_const_iterator<_Val, _Key, _HashFcn, _ExtractKey, _EqualKey, _Alloc>; friend struct _Hashtable_iterator<_Val, _Key, _HashFcn, _ExtractKey, _EqualKey, _Alloc>; diff --git a/src/INTERP_KERNEL/Bases/InterpKernelStlExt.hxx b/src/INTERP_KERNEL/Bases/InterpKernelStlExt.hxx index cf4d3b019..b790907cf 100644 --- a/src/INTERP_KERNEL/Bases/InterpKernelStlExt.hxx +++ b/src/INTERP_KERNEL/Bases/InterpKernelStlExt.hxx @@ -20,7 +20,6 @@ #ifndef __INTERPKERNELSTLEXT_HXX__ #define __INTERPKERNELSTLEXT_HXX__ -#include namespace INTERP_KERNEL { diff --git a/src/INTERP_KERNEL/Bases/NormalizedUnstructuredMesh.hxx b/src/INTERP_KERNEL/Bases/NormalizedUnstructuredMesh.hxx index 91bee1d18..0ee8dcc02 100644 --- a/src/INTERP_KERNEL/Bases/NormalizedUnstructuredMesh.hxx +++ b/src/INTERP_KERNEL/Bases/NormalizedUnstructuredMesh.hxx @@ -21,7 +21,6 @@ #ifndef __NORMALIZEDUNSTRUCTUREDMESH_HXX__ #define __NORMALIZEDUNSTRUCTUREDMESH_HXX__ -#include "NormalizedGeometricTypes" namespace INTERP_KERNEL { diff --git a/src/INTERP_KERNEL/BoundingBox.hxx b/src/INTERP_KERNEL/BoundingBox.hxx index b3c9f0d9f..63685fe9b 100644 --- a/src/INTERP_KERNEL/BoundingBox.hxx +++ b/src/INTERP_KERNEL/BoundingBox.hxx @@ -36,13 +36,13 @@ namespace INTERP_KERNEL /// Enumeration representing the six coordinates that define the bounding box enum BoxCoord { XMIN = 0, YMIN = 1, ZMIN = 2, XMAX = 3, YMAX = 4, ZMAX = 5 }; - BoundingBox() { } + BoundingBox() = default; BoundingBox(const double** pts, const unsigned numPts); BoundingBox(const BoundingBox& box1, const BoundingBox& box2); - ~BoundingBox() { } + ~BoundingBox() = default; void fillInXMinXmaxYminYmaxZminZmaxFormat(double data[6]) const; diff --git a/src/INTERP_KERNEL/BoxSplittingOptions.cxx b/src/INTERP_KERNEL/BoxSplittingOptions.cxx index e3337f4a1..e5929de94 100644 --- a/src/INTERP_KERNEL/BoxSplittingOptions.cxx +++ b/src/INTERP_KERNEL/BoxSplittingOptions.cxx @@ -20,7 +20,9 @@ #include "BoxSplittingOptions.hxx" +#include #include +#include const double INTERP_KERNEL::BoxSplittingOptions::DFT_EFFICIENCY_GOAL=0.5; diff --git a/src/INTERP_KERNEL/CellModel.cxx b/src/INTERP_KERNEL/CellModel.cxx index 6fb951a09..cdd0708ef 100644 --- a/src/INTERP_KERNEL/CellModel.cxx +++ b/src/INTERP_KERNEL/CellModel.cxx @@ -22,10 +22,16 @@ #include "InterpKernelException.hxx" #include "DiameterCalculator.hxx" +#include "NormalizedGeometricTypes" +#include "MCIdType.hxx" #include "OrientationInverter.hxx" #include +#include +#include +#include #include +#include #include #include @@ -486,7 +492,7 @@ namespace INTERP_KERNEL */ unsigned CellModel::getNumberOfMicroEdges() const { - unsigned mul(isQuadratic()?2:1); + unsigned const mul(isQuadratic()?2:1); if(!isDynamic()) { switch(getDimension()) @@ -558,7 +564,7 @@ namespace INTERP_KERNEL */ unsigned CellModel::fillSonCellNodalConnectivity(int sonId, const mcIdType *nodalConn, mcIdType *sonNodalConn) const { - unsigned nbOfTurnLoop=_nb_of_sons_con[sonId]; + unsigned const nbOfTurnLoop=_nb_of_sons_con[sonId]; const unsigned *sonConn=_sons_con[sonId]; for(unsigned i=0;i tmp0(sz2-1),tmp1(sz2); std::copy(nodalConn+1,nodalConn+sz2,tmp0.rbegin()); std::copy(nodalConn+sz2,nodalConn+sz,tmp1.rbegin()); @@ -779,14 +785,14 @@ namespace INTERP_KERNEL if(!_quadratic) { std::vector tmp(2*lgth); - std::vector::iterator it=std::copy(conn1,conn1+lgth,tmp.begin()); + auto it=std::copy(conn1,conn1+lgth,tmp.begin()); std::copy(conn1,conn1+lgth,it); it=std::search(tmp.begin(),tmp.end(),conn2,conn2+lgth); if(it==tmp.begin()) return true; if(it!=tmp.end()) return _dim!=1; - std::vector::reverse_iterator it2=std::search(tmp.rbegin(),tmp.rend(),conn2,conn2+lgth); + auto const it2=std::search(tmp.rbegin(),tmp.rend(),conn2,conn2+lgth); if(it2!=tmp.rend()) return false; throw INTERP_KERNEL::Exception("CellModel::getOrientationStatus : Request of orientation status of non equal connectively cells !"); @@ -796,10 +802,10 @@ namespace INTERP_KERNEL if(_dim!=1) { std::vector tmp(lgth); - std::vector::iterator it=std::copy(conn1,conn1+lgth/2,tmp.begin()); + auto it=std::copy(conn1,conn1+lgth/2,tmp.begin()); std::copy(conn1,conn1+lgth/2,it); it=std::search(tmp.begin(),tmp.end(),conn2,conn2+lgth/2); - std::size_t d=std::distance(tmp.begin(),it); + std::size_t const d=std::distance(tmp.begin(),it); if(it==tmp.end()) return false; it=std::copy(conn1+lgth/2,conn1+lgth,tmp.begin()); @@ -807,17 +813,17 @@ namespace INTERP_KERNEL it=std::search(tmp.begin(),tmp.end(),conn2,conn2+lgth); if(it==tmp.end()) return false; - std::size_t d2=std::distance(tmp.begin(),it); + std::size_t const d2=std::distance(tmp.begin(),it); return d==d2; } else { - mcIdType p=(lgth+1)/2; + mcIdType const p=(lgth+1)/2; std::vector tmp(2*p); - std::vector::iterator it=std::copy(conn1,conn1+p,tmp.begin()); + auto it=std::copy(conn1,conn1+p,tmp.begin()); std::copy(conn1,conn1+p,it); it=std::search(tmp.begin(),tmp.end(),conn2,conn2+p); - std::size_t d=std::distance(tmp.begin(),it); + std::size_t const d=std::distance(tmp.begin(),it); if(it==tmp.end()) return false; tmp.resize(2*p-2); @@ -826,7 +832,7 @@ namespace INTERP_KERNEL it=std::search(tmp.begin(),tmp.end(),conn2+p,conn2+lgth); if(it==tmp.end()) return false; - std::size_t d2=std::distance(tmp.begin(),it); + std::size_t const d2=std::distance(tmp.begin(),it); return d==d2; } } diff --git a/src/INTERP_KERNEL/CellModel.hxx b/src/INTERP_KERNEL/CellModel.hxx index 584783cc2..6d54e575f 100644 --- a/src/INTERP_KERNEL/CellModel.hxx +++ b/src/INTERP_KERNEL/CellModel.hxx @@ -23,7 +23,7 @@ #include "INTERPKERNELDefines.hxx" -#include "NormalizedUnstructuredMesh.hxx" +#include "NormalizedGeometricTypes" #include "MCIdType.hxx" #include diff --git a/src/INTERP_KERNEL/ConvexIntersector.hxx b/src/INTERP_KERNEL/ConvexIntersector.hxx index 18459c5f2..1e1b230f7 100644 --- a/src/INTERP_KERNEL/ConvexIntersector.hxx +++ b/src/INTERP_KERNEL/ConvexIntersector.hxx @@ -21,12 +21,8 @@ #ifndef __CONVEXINTERSECTOR_HXX__ #define __CONVEXINTERSECTOR_HXX__ -#include "PlanarIntersectorP0P0.hxx" -#include "PlanarIntersectorP0P1.hxx" -#include "PlanarIntersectorP1P0.hxx" -#include "PlanarIntersectorP1P1.hxx" -#include "PlanarIntersectorP1P0Bary.hxx" -#include "PlanarIntersectorP0P1Bary.hxx" +#include "NormalizedUnstructuredMesh.hxx" +#include namespace INTERP_KERNEL { @@ -36,7 +32,7 @@ namespace INTERP_KERNEL public: static const int SPACEDIM=MyMeshType::MY_SPACEDIM; static const int MESHDIM=MyMeshType::MY_MESHDIM; - typedef typename MyMeshType::MyConnType ConnType; + using ConnType = typename MyMeshType::MyConnType; static const NumberingPolicy numPol=MyMeshType::My_numPol; public: ConvexIntersector(const MyMeshType& meshT, const MyMeshType& meshS, diff --git a/src/INTERP_KERNEL/ConvexIntersector.txx b/src/INTERP_KERNEL/ConvexIntersector.txx index 46031c4f3..fdc98317a 100644 --- a/src/INTERP_KERNEL/ConvexIntersector.txx +++ b/src/INTERP_KERNEL/ConvexIntersector.txx @@ -21,6 +21,7 @@ #define __CONVEXINTERSECTOR_TXX__ #include "ConvexIntersector.hxx" +#include "PlanarIntersector.txx" #include "PlanarIntersectorP0P0.txx" #include "PlanarIntersectorP0P1.txx" #include "PlanarIntersectorP1P0.txx" @@ -29,8 +30,12 @@ #include "PlanarIntersectorP0P1Bary.txx" #include "PolygonAlgorithms.txx" +#include "InterpolationUtils.hxx" +#include #include +#include +#include #define CONVINTERSECTOR_TEMPLATE template class InterpType> #define CONVEX_INTERSECTOR_ ConvexIntersector @@ -92,7 +97,7 @@ namespace INTERP_KERNEL CONVINTERSECTOR_TEMPLATE double CONVEX_INTERSECTOR_::intersectGeometryWithQuadrangle(const double * quadrangle, const std::vector& sourceCoords, - bool isSourceQuad) + bool /*isSourceQuad*/) { double result = 0; int nbOfNodesS=int(sourceCoords.size())/SPACEDIM; @@ -154,7 +159,7 @@ namespace INTERP_KERNEL CONVINTERSECTOR_TEMPLATE double CONVEX_INTERSECTOR_::intersectGeoBary(const std::vector& targetCell, - bool targetCellQuadratic, + bool /*targetCellQuadratic*/, const double * sourceTria, std::vector& res) { diff --git a/src/INTERP_KERNEL/CurveIntersector.hxx b/src/INTERP_KERNEL/CurveIntersector.hxx index 83cf97a1d..ff81860d6 100644 --- a/src/INTERP_KERNEL/CurveIntersector.hxx +++ b/src/INTERP_KERNEL/CurveIntersector.hxx @@ -23,6 +23,7 @@ #include "TargetIntersector.txx" #include "NormalizedUnstructuredMesh.hxx" +#include namespace INTERP_KERNEL { diff --git a/src/INTERP_KERNEL/CurveIntersector.txx b/src/INTERP_KERNEL/CurveIntersector.txx index 2864e7f8f..a2965ffff 100644 --- a/src/INTERP_KERNEL/CurveIntersector.txx +++ b/src/INTERP_KERNEL/CurveIntersector.txx @@ -22,9 +22,16 @@ #include "CurveIntersector.hxx" #include "InterpolationUtils.hxx" +#include "MCIdType.hxx" +#include "NormalizedUnstructuredMesh.hxx" +#include "NormalizedGeometricTypes" #include "PointLocatorAlgos.txx" +#include +#include #include +#include +#include namespace INTERP_KERNEL { @@ -54,8 +61,7 @@ namespace INTERP_KERNEL template CurveIntersector::~CurveIntersector() - { - } + = default; //================================================================================ /*! @@ -93,7 +99,7 @@ namespace INTERP_KERNEL ::coo2C(conn[OTT::conn2C(conn_index[icell]+j)]); for(int idim=0; idim::coo2C(conn[OTT::conn2C(conn_index[OTT::ind2C(iP)]+i)])); for(int idim=0; idimbb[2*idim+1]) ? x : bb[2*idim+1]; } @@ -145,7 +151,7 @@ namespace INTERP_KERNEL template void CurveIntersector::ComputeBaryCoordsOf(double startOfSeg, double endOfSeg, double pt, double& startPos, double& endPos) { - double deno(endOfSeg-startOfSeg); + double const deno(endOfSeg-startOfSeg); startPos = (endOfSeg-pt)/deno; startPos = std::max(startPos,0.); startPos = std::min(startPos,1.); endPos=1.-startPos; @@ -356,8 +362,8 @@ namespace INTERP_KERNEL double t0s1[2] = { s1[X]-t0[X], s1[Y]-t0[Y] }; double nt01_x_t0s0 = t0s0[X] * t01[Y] - t0s0[Y] * t01[X]; // t0s0 dot norm of t01 double nt01_x_t0s1 = t0s1[X] * t01[Y] - t0s1[Y] * t01[X]; // t0s1 dot norm of t01 - double dist_ts0 = fabs( nt01_x_t0s0 ); // dist from tgt seg to s0 - double dist_ts1 = fabs( nt01_x_t0s1 ); // dist from tgt seg to s1 + double const dist_ts0 = fabs( nt01_x_t0s0 ); // dist from tgt seg to s0 + double const dist_ts1 = fabs( nt01_x_t0s1 ); // dist from tgt seg to s1 bool s0_out_of_tol = ( dist_ts0 > _tolerance ); bool s1_out_of_tol = ( dist_ts1 > _tolerance ); if ( nt01_x_t0s0 * nt01_x_t0s1 > 0 && ( s0_out_of_tol || s1_out_of_tol )) @@ -423,8 +429,8 @@ namespace INTERP_KERNEL if ( xt0 > xt1 ) std::swap( xt0, xt1 ); if ( xs0 > xs1 ) std::swap( xs0, xs1 ); - double x0 = std::max( xt0, xs0 ); - double x1 = std::min( xt1, xs1 ); + double const x0 = std::max( xt0, xs0 ); + double const x1 = std::min( xt1, xs1 ); return ( x0 < x1 ) ? ( x1 - x0 ) : 0.; } @@ -434,7 +440,7 @@ namespace INTERP_KERNEL public: static const int MY_SPACEDIM=1; static const int MY_MESHDIM=8; - typedef mcIdType MyConnType; + using MyConnType = mcIdType; static const INTERP_KERNEL::NumberingPolicy My_numPol=MyMeshType::My_numPol; // begin // useless, but for windows compilation ... diff --git a/src/INTERP_KERNEL/CurveIntersectorP0P0.hxx b/src/INTERP_KERNEL/CurveIntersectorP0P0.hxx index 6d02dfea7..052d2af34 100644 --- a/src/INTERP_KERNEL/CurveIntersectorP0P0.hxx +++ b/src/INTERP_KERNEL/CurveIntersectorP0P0.hxx @@ -22,6 +22,8 @@ #define __CURVEINTERSECTORP0P0_HXX__ #include "CurveIntersector.hxx" +#include "NormalizedUnstructuredMesh.hxx" +#include namespace INTERP_KERNEL { @@ -31,7 +33,7 @@ namespace INTERP_KERNEL public: static const int SPACEDIM=MyMeshType::MY_SPACEDIM; static const int MESHDIM=MyMeshType::MY_MESHDIM; - typedef typename MyMeshType::MyConnType ConnType; + using ConnType = typename MyMeshType::MyConnType; static const NumberingPolicy numPol=MyMeshType::My_numPol; CurveIntersectorP0P0(const MyMeshType& meshT, const MyMeshType& meshS, diff --git a/src/INTERP_KERNEL/CurveIntersectorP0P0.txx b/src/INTERP_KERNEL/CurveIntersectorP0P0.txx index e29648f5a..3475f7b8f 100644 --- a/src/INTERP_KERNEL/CurveIntersectorP0P0.txx +++ b/src/INTERP_KERNEL/CurveIntersectorP0P0.txx @@ -20,8 +20,10 @@ #ifndef __CURVEINTERSECTORP0P0_TXX__ #define __CURVEINTERSECTORP0P0_TXX__ +#include "CurveIntersector.hxx" #include "CurveIntersectorP0P0.hxx" -#include "CurveIntersector.txx" +#include +#include "InterpolationUtils.hxx" #define BASE_INTERSECTOR CurveIntersector diff --git a/src/INTERP_KERNEL/CurveIntersectorP0P1.hxx b/src/INTERP_KERNEL/CurveIntersectorP0P1.hxx index 01f895550..eb0244220 100644 --- a/src/INTERP_KERNEL/CurveIntersectorP0P1.hxx +++ b/src/INTERP_KERNEL/CurveIntersectorP0P1.hxx @@ -22,6 +22,8 @@ #define __CURVEINTERSECTORP0P1_HXX__ #include "CurveIntersector.hxx" +#include "NormalizedUnstructuredMesh.hxx" +#include namespace INTERP_KERNEL { @@ -31,7 +33,7 @@ namespace INTERP_KERNEL public: static const int SPACEDIM=MyMeshType::MY_SPACEDIM; static const int MESHDIM=MyMeshType::MY_MESHDIM; - typedef typename MyMeshType::MyConnType ConnType; + using ConnType = typename MyMeshType::MyConnType; static const NumberingPolicy numPol=MyMeshType::My_numPol; CurveIntersectorP0P1(const MyMeshType& meshT, const MyMeshType& meshS, diff --git a/src/INTERP_KERNEL/CurveIntersectorP0P1.txx b/src/INTERP_KERNEL/CurveIntersectorP0P1.txx index 474a8c2c1..3aac3c26e 100644 --- a/src/INTERP_KERNEL/CurveIntersectorP0P1.txx +++ b/src/INTERP_KERNEL/CurveIntersectorP0P1.txx @@ -20,8 +20,10 @@ #ifndef __CurveIntersectorP0P1_TXX__ #define __CurveIntersectorP0P1_TXX__ +#include "CurveIntersector.hxx" #include "CurveIntersectorP0P1.hxx" -#include "CurveIntersector.txx" +#include +#include "InterpolationUtils.hxx" #define BASE_INTERSECTOR CurveIntersector diff --git a/src/INTERP_KERNEL/CurveIntersectorP1P0.hxx b/src/INTERP_KERNEL/CurveIntersectorP1P0.hxx index 824ca46cc..00c02bfdc 100644 --- a/src/INTERP_KERNEL/CurveIntersectorP1P0.hxx +++ b/src/INTERP_KERNEL/CurveIntersectorP1P0.hxx @@ -22,6 +22,8 @@ #define __CURVEINTERSECTORP1P0_HXX__ #include "CurveIntersector.hxx" +#include "NormalizedUnstructuredMesh.hxx" +#include namespace INTERP_KERNEL { @@ -31,7 +33,7 @@ namespace INTERP_KERNEL public: static const int SPACEDIM=MyMeshType::MY_SPACEDIM; static const int MESHDIM=MyMeshType::MY_MESHDIM; - typedef typename MyMeshType::MyConnType ConnType; + using ConnType = typename MyMeshType::MyConnType; static const NumberingPolicy numPol=MyMeshType::My_numPol; CurveIntersectorP1P0(const MyMeshType& meshT, const MyMeshType& meshS, diff --git a/src/INTERP_KERNEL/CurveIntersectorP1P0.txx b/src/INTERP_KERNEL/CurveIntersectorP1P0.txx index acfa0330d..149c84c2e 100644 --- a/src/INTERP_KERNEL/CurveIntersectorP1P0.txx +++ b/src/INTERP_KERNEL/CurveIntersectorP1P0.txx @@ -20,8 +20,10 @@ #ifndef __CurveIntersectorP1P0_TXX__ #define __CurveIntersectorP1P0_TXX__ +#include "CurveIntersector.hxx" #include "CurveIntersectorP1P0.hxx" -#include "CurveIntersector.txx" +#include +#include "InterpolationUtils.hxx" #define BASE_INTERSECTOR CurveIntersector diff --git a/src/INTERP_KERNEL/CurveIntersectorP1P1.hxx b/src/INTERP_KERNEL/CurveIntersectorP1P1.hxx index 3052d263d..a0c35d6b5 100644 --- a/src/INTERP_KERNEL/CurveIntersectorP1P1.hxx +++ b/src/INTERP_KERNEL/CurveIntersectorP1P1.hxx @@ -22,6 +22,8 @@ #define __CURVEINTERSECTORP1P1_HXX__ #include "CurveIntersector.hxx" +#include "NormalizedUnstructuredMesh.hxx" +#include namespace INTERP_KERNEL { @@ -31,7 +33,7 @@ namespace INTERP_KERNEL public: static const int SPACEDIM=MyMeshType::MY_SPACEDIM; static const int MESHDIM=MyMeshType::MY_MESHDIM; - typedef typename MyMeshType::MyConnType ConnType; + using ConnType = typename MyMeshType::MyConnType; static const NumberingPolicy numPol=MyMeshType::My_numPol; CurveIntersectorP1P1(const MyMeshType& meshT, const MyMeshType& meshS, diff --git a/src/INTERP_KERNEL/CurveIntersectorP1P1.txx b/src/INTERP_KERNEL/CurveIntersectorP1P1.txx index 17d7c8bd2..8ea554760 100644 --- a/src/INTERP_KERNEL/CurveIntersectorP1P1.txx +++ b/src/INTERP_KERNEL/CurveIntersectorP1P1.txx @@ -20,8 +20,10 @@ #ifndef __CurveIntersectorP1P1_TXX__ #define __CurveIntersectorP1P1_TXX__ +#include "CurveIntersector.hxx" #include "CurveIntersectorP1P1.hxx" -#include "CurveIntersector.txx" +#include +#include "InterpolationUtils.hxx" #define BASE_INTERSECTOR CurveIntersector diff --git a/src/INTERP_KERNEL/CurveIntersectorP1P1PL.hxx b/src/INTERP_KERNEL/CurveIntersectorP1P1PL.hxx index 891b9fcad..d9ef537a7 100644 --- a/src/INTERP_KERNEL/CurveIntersectorP1P1PL.hxx +++ b/src/INTERP_KERNEL/CurveIntersectorP1P1PL.hxx @@ -22,6 +22,8 @@ #define __CURVEINTERSECTORP1P1PL_HXX__ #include "CurveIntersector.hxx" +#include "NormalizedUnstructuredMesh.hxx" +#include namespace INTERP_KERNEL { @@ -31,7 +33,7 @@ namespace INTERP_KERNEL public: static const int SPACEDIM=MyMeshType::MY_SPACEDIM; static const int MESHDIM=MyMeshType::MY_MESHDIM; - typedef typename MyMeshType::MyConnType ConnType; + using ConnType = typename MyMeshType::MyConnType; static const NumberingPolicy numPol=MyMeshType::My_numPol; CurveIntersectorP1P1PL(const MyMeshType& meshT, const MyMeshType& meshS, diff --git a/src/INTERP_KERNEL/CurveIntersectorP1P1PL.txx b/src/INTERP_KERNEL/CurveIntersectorP1P1PL.txx index 4fac5779a..7a45d51a4 100644 --- a/src/INTERP_KERNEL/CurveIntersectorP1P1PL.txx +++ b/src/INTERP_KERNEL/CurveIntersectorP1P1PL.txx @@ -20,10 +20,14 @@ #pragma once +#include "CurveIntersector.hxx" #include "CurveIntersectorP1P1PL.hxx" -#include "CurveIntersector.txx" +#include "InterpolationUtils.hxx" +#include "MCIdType.hxx" #include +#include +#include namespace INTERP_KERNEL { diff --git a/src/INTERP_KERNEL/DiameterCalculator.cxx b/src/INTERP_KERNEL/DiameterCalculator.cxx index a168bc702..d6ea869c8 100644 --- a/src/INTERP_KERNEL/DiameterCalculator.cxx +++ b/src/INTERP_KERNEL/DiameterCalculator.cxx @@ -21,8 +21,11 @@ #include "DiameterCalculator.hxx" #include "InterpKernelException.hxx" #include "CellModel.hxx" +#include "NormalizedGeometricTypes" +#include "MCIdType.hxx" #include +#include #include #include @@ -97,11 +100,11 @@ template void ComputeForListOfCellIdsUMeshFrmt(const mcIdType *bgIds, const mcIdType *endIds, const mcIdType *indPtr, const mcIdType *connPtr, const double *coordsPtr, double *resPtr) { Evaluator evtor; - NormalizedCellType ct(Evaluator::TYPE); - int cti((int) ct); + NormalizedCellType const ct(Evaluator::TYPE); + int const cti((int) ct); for(const mcIdType *it=bgIds;it!=endIds;it++) { - mcIdType offset(indPtr[*it]); + mcIdType const offset(indPtr[*it]); if(connPtr[offset]==cti) resPtr[*it]=evtor.ComputeForOneCellInternal(connPtr+offset+1,connPtr+indPtr[(*it)+1],coordsPtr); else @@ -116,11 +119,11 @@ template void ComputeForRangeOfCellIdsUMeshFrmt(mcIdType bgId, mcIdType endId, const mcIdType *indPtr, const mcIdType *connPtr, const double *coordsPtr, double *resPtr) { Evaluator evtor; - NormalizedCellType ct(Evaluator::TYPE); - int cti((int) ct); + NormalizedCellType const ct(Evaluator::TYPE); + int const cti((int) ct); for(mcIdType it=bgId;it void ComputeFor1SGTUMeshFrmt(mcIdType nbOfCells, const mcIdType *connPtr, const double *coordsPtr, double *resPtr) { Evaluator evtor; - NormalizedCellType ct(Evaluator::TYPE); + NormalizedCellType const ct(Evaluator::TYPE); const CellModel& cm(CellModel::GetCellModel(ct)); - unsigned nbNodes(cm.getNumberOfNodes()); + unsigned const nbNodes(cm.getNumberOfNodes()); const mcIdType *ptr(connPtr); for(mcIdType i=0;i +#include +#include +#include +#include #define __TENSOR(i,j) tensor[(i)*_dim+(j)] #define __AXIS(i) (&_axes[(i)*_dim]) @@ -120,7 +125,7 @@ namespace // Rotate to make __TENSOR(k,l) == 0 - double diff = __TENSOR(l,l) - __TENSOR(k,k); + double const diff = __TENSOR(l,l) - __TENSOR(k,k); double t; // tangent of rotation angle if ( fabs(__TENSOR(k,l)) < abs(diff)*1.0e-36) { @@ -128,13 +133,13 @@ namespace } else { - double phi = diff/(2.0*__TENSOR(k,l)); + double const phi = diff/(2.0*__TENSOR(k,l)); t = 1.0/(abs(phi) + sqrt(phi*phi + 1.0)); if ( phi < 0.0) t = -t; } - double c = 1.0/sqrt(t*t + 1.0); // cosine of rotation angle - double s = t*c; // sine of rotation angle - double tau = s/(1.0 + c); + double const c = 1.0/sqrt(t*t + 1.0); // cosine of rotation angle + double const s = t*c; // sine of rotation angle + double const tau = s/(1.0 + c); __TENSOR(k,k) -= t*__TENSOR(k,l); __TENSOR(l,l) += t*__TENSOR(k,l); __TENSOR(k,l) = 0.0; @@ -609,7 +614,7 @@ namespace INTERP_KERNEL // find minmax of cornerBox in the CS of axisBox - DirectedBoundingBox mmBox((double*)0,0,_dim); //!< empty box with CS == axisBox->_axes + DirectedBoundingBox mmBox((double*)nullptr,0,_dim); //!< empty box with CS == axisBox->_axes mmBox._axes = axisBox->_axes; vector corners; @@ -646,7 +651,7 @@ namespace INTERP_KERNEL { vector cornersOther; getCorners( cornersOther, box ); - DirectedBoundingBox mmBox((double*)0,0,_dim); //!< empty box with CS == this->_axes + DirectedBoundingBox mmBox((double*)nullptr,0,_dim); //!< empty box with CS == this->_axes mmBox._axes = this->_axes; for ( std::size_t iC = 0, nC = cornersOther.size()/_dim; iC < nC; ++iC) mmBox.addPointToBox( &cornersOther[iC*_dim] ); @@ -659,7 +664,7 @@ namespace INTERP_KERNEL { vector cornersThis; getCorners( cornersThis, &_minmax[0] ); - DirectedBoundingBox mmBox((double*)0,0,_dim); //!< initailized _minmax + DirectedBoundingBox mmBox((double*)nullptr,0,_dim); //!< initailized _minmax double globCorner[3]; for ( std::size_t iC = 0, nC = cornersThis.size()/_dim; iC < nC; ++iC) { @@ -688,7 +693,7 @@ namespace INTERP_KERNEL double pLoc[3]; toLocalCS( point, pLoc ); - bool out = isLocalOut( pLoc ); + bool const out = isLocalOut( pLoc ); #ifdef _DEBUG_ switch (_dim) { diff --git a/src/INTERP_KERNEL/ExprEval/InterpKernelAsmX86.cxx b/src/INTERP_KERNEL/ExprEval/InterpKernelAsmX86.cxx index 492f88356..4d1e625d0 100644 --- a/src/INTERP_KERNEL/ExprEval/InterpKernelAsmX86.cxx +++ b/src/INTERP_KERNEL/ExprEval/InterpKernelAsmX86.cxx @@ -19,10 +19,13 @@ // Author : Anthony Geay (CEA/DEN) #include "InterpKernelAsmX86.hxx" +#include "InterpKernelException.hxx"//" #include #include #include +#include +#include #ifdef _POSIX_MAPPED_FILES #include @@ -37,20 +40,20 @@ const char *INTERP_KERNEL::AsmX86::OPS[NB_OF_OPS]={"mov","push","pop","fld","fad std::vector INTERP_KERNEL::AsmX86::convertIntoMachineLangage(const std::vector& asmb) const { std::vector ret; - for(std::vector::const_iterator iter=asmb.begin();iter!=asmb.end();iter++) - convertOneInstructionInML(*iter,ret); + for(const auto & iter : asmb) + convertOneInstructionInML(iter,ret); return ret; } -char *INTERP_KERNEL::AsmX86::copyToExecMemZone(const std::vector& ml, unsigned& offset) const +char *INTERP_KERNEL::AsmX86::copyToExecMemZone(const std::vector& ml, unsigned& /*offset*/) const { - char *ret=0; - std::size_t lgth=ml.size(); + char *ret=nullptr; + std::size_t const lgth=ml.size(); #ifdef _POSIX_MAPPED_FILES # ifdef __APPLE__ ret=(char *)mmap(0,lgth,PROT_EXEC | PROT_WRITE,MAP_ANON | MAP_PRIVATE,-1,0); # else - ret=(char *)mmap(0,lgth,PROT_EXEC | PROT_WRITE,MAP_ANONYMOUS | MAP_PRIVATE,-1,0); + ret=(char *)mmap(nullptr,lgth,PROT_EXEC | PROT_WRITE,MAP_ANONYMOUS | MAP_PRIVATE,-1,0); # endif #else #ifdef WIN32 @@ -65,7 +68,7 @@ char *INTERP_KERNEL::AsmX86::copyToExecMemZone(const std::vector& ml, unsi void INTERP_KERNEL::AsmX86::convertOneInstructionInML(const std::string& inst, std::vector& ml) const { - std::string::size_type pos=inst.find_first_of(' '); + std::string::size_type const pos=inst.find_first_of(' '); std::string op; std::string param; if(pos!=std::string::npos) @@ -78,7 +81,7 @@ void INTERP_KERNEL::AsmX86::convertOneInstructionInML(const std::string& inst, s int id=0; for(const char **it=OPS;it!=OPS+NB_OF_OPS;it++,id++) { - std::string tmp(*it); + std::string const tmp(*it); if(op==tmp) break; } @@ -173,15 +176,15 @@ void INTERP_KERNEL::AsmX86::convertMov(const std::string& inst, std::vector& ml) { - std::string::size_type pos=inst.find_first_of(' '); - std::string inst2=inst.substr(pos+1); + std::string::size_type const pos=inst.find_first_of(' '); + std::string const inst2=inst.substr(pos+1); const char ASM1[]="ebp"; const unsigned char ML1[1]={0x55}; if(inst2==ASM1) @@ -269,8 +272,8 @@ void INTERP_KERNEL::AsmX86::convertPush(const std::string& inst, std::vector& ml) { - std::string::size_type pos=inst.find_first_of(' '); - std::string inst2=inst.substr(pos+1); + std::string::size_type const pos=inst.find_first_of(' '); + std::string const inst2=inst.substr(pos+1); const char ASM1[]="ebp"; const unsigned char ML1[1]={0x5d}; if(inst2==ASM1) @@ -291,8 +294,8 @@ void INTERP_KERNEL::AsmX86::convertPop(const std::string& inst, std::vector& ml) { std::string::size_type pos=inst.find_first_of(' '); - std::string params=inst.substr(pos+1); - std::string params2=params.substr(1,params.length()-2); + std::string const params=inst.substr(pos+1); + std::string const params2=params.substr(1,params.length()-2); if(params2.substr(0,3)=="esp") { const unsigned char ML1[3]={0xdd,0x04,0x24}; @@ -305,7 +308,7 @@ void INTERP_KERNEL::AsmX86::convertFld(const std::string& inst, std::vector& ml) +void INTERP_KERNEL::AsmX86::convertFaddp(const std::string& /*inst*/, std::vector& ml) { const unsigned char ML1[2]={0xde,0xc1}; ml.insert(ml.end(),ML1,ML1+sizeof(ML1)); } -void INTERP_KERNEL::AsmX86::convertFsubp(const std::string& inst, std::vector& ml) +void INTERP_KERNEL::AsmX86::convertFsubp(const std::string& /*inst*/, std::vector& ml) { const unsigned char ML1[2]={0xde,0xe9}; ml.insert(ml.end(),ML1,ML1+sizeof(ML1)); } -void INTERP_KERNEL::AsmX86::convertFmulp(const std::string& inst, std::vector& ml) +void INTERP_KERNEL::AsmX86::convertFmulp(const std::string& /*inst*/, std::vector& ml) { const unsigned char ML1[2]={0xde,0xc9}; ml.insert(ml.end(),ML1,ML1+sizeof(ML1)); } -void INTERP_KERNEL::AsmX86::convertFdivp(const std::string& inst, std::vector& ml) +void INTERP_KERNEL::AsmX86::convertFdivp(const std::string& /*inst*/, std::vector& ml) { const unsigned char ML1[2]={0xde,0xf9}; ml.insert(ml.end(),ML1,ML1+sizeof(ML1)); } -void INTERP_KERNEL::AsmX86::convertFcos(const std::string& inst, std::vector& ml) +void INTERP_KERNEL::AsmX86::convertFcos(const std::string& /*inst*/, std::vector& ml) { const unsigned char ML[2]={0xd9,0xff}; ml.insert(ml.end(),ML,ML+sizeof(ML)); } -void INTERP_KERNEL::AsmX86::convertFsin(const std::string& inst, std::vector& ml) +void INTERP_KERNEL::AsmX86::convertFsin(const std::string& /*inst*/, std::vector& ml) { const unsigned char ML[2]={0xd9,0xfe}; ml.insert(ml.end(),ML,ML+sizeof(ML)); } -void INTERP_KERNEL::AsmX86::convertFabs(const std::string& inst, std::vector& ml) +void INTERP_KERNEL::AsmX86::convertFabs(const std::string& /*inst*/, std::vector& ml) { const unsigned char ML[2]={0xd9,0xe1}; ml.insert(ml.end(),ML,ML+sizeof(ML)); } -void INTERP_KERNEL::AsmX86::convertFchs(const std::string& inst, std::vector& ml) +void INTERP_KERNEL::AsmX86::convertFchs(const std::string& /*inst*/, std::vector& ml) { const unsigned char ML[2]={0xd9,0xe0}; ml.insert(ml.end(),ML,ML+sizeof(ML)); } -void INTERP_KERNEL::AsmX86::convertFsqrt(const std::string& inst, std::vector& ml) +void INTERP_KERNEL::AsmX86::convertFsqrt(const std::string& /*inst*/, std::vector& ml) { const unsigned char ML[2]={0xd9,0xfa}; ml.insert(ml.end(),ML,ML+sizeof(ML)); @@ -399,7 +402,7 @@ void INTERP_KERNEL::AsmX86::convertSub(const std::string& inst, std::vector& ml) +void INTERP_KERNEL::AsmX86::convertRet(const std::string& /*inst*/, std::vector& ml) { const unsigned char ML[1]={0xc3}; ml.insert(ml.end(),ML,ML+sizeof(ML)); } -void INTERP_KERNEL::AsmX86::convertLeave(const std::string& inst, std::vector& ml) +void INTERP_KERNEL::AsmX86::convertLeave(const std::string& /*inst*/, std::vector& ml) { const unsigned char ML[1]={0xc9}; ml.insert(ml.end(),ML,ML+sizeof(ML)); diff --git a/src/INTERP_KERNEL/ExprEval/InterpKernelAsmX86.hxx b/src/INTERP_KERNEL/ExprEval/InterpKernelAsmX86.hxx index 738de4407..5e4c82847 100644 --- a/src/INTERP_KERNEL/ExprEval/InterpKernelAsmX86.hxx +++ b/src/INTERP_KERNEL/ExprEval/InterpKernelAsmX86.hxx @@ -21,8 +21,6 @@ #ifndef __INTERPKERNELASMX86_HXX__ #define __INTERPKERNELASMX86_HXX__ -#include "INTERPKERNELDefines.hxx" -#include "InterpKernelException.hxx" #include #include diff --git a/src/INTERP_KERNEL/ExprEval/InterpKernelExprParser.cxx b/src/INTERP_KERNEL/ExprEval/InterpKernelExprParser.cxx index 3ab05105f..920c63fc5 100644 --- a/src/INTERP_KERNEL/ExprEval/InterpKernelExprParser.cxx +++ b/src/INTERP_KERNEL/ExprEval/InterpKernelExprParser.cxx @@ -19,13 +19,20 @@ // Author : Anthony Geay (CEA/DEN) #include "InterpKernelExprParser.hxx" +#include "InterpKernelFunction.hxx" +#include "InterpKernelUnit.hxx" #include "InterpKernelValue.hxx" #include "InterpKernelAsmX86.hxx" #include "InterpKernelAutoPtr.hxx" +#include "InterpKernelException.hxx" #include +#include +#include #include #include +#include +#include #include #include #include @@ -60,16 +67,14 @@ LeafExpr *LeafExpr::buildInstanceFrom(const std::string& expr) } LeafExpr::~LeafExpr() -{ -} += default; LeafExprVal::LeafExprVal(double value):_value(value) { } LeafExprVal::~LeafExprVal() -{ -} += default; void LeafExprVal::fillValue(Value *val) const { @@ -78,8 +83,8 @@ void LeafExprVal::fillValue(Value *val) const void LeafExprVal::replaceValues(const std::vector& valuesInExpr) { - int pos=(int)_value; - int lgth=(int)valuesInExpr.size(); + int const pos=(int)_value; + int const lgth=(int)valuesInExpr.size(); if(pos>=lgth || pos<0) throw INTERP_KERNEL::Exception("LeafExprVal::replaceValues : Big Problem detected! Send a mail to Salome support with expression."); _value=valuesInExpr[pos]; @@ -90,7 +95,7 @@ LeafExprVal *LeafExprVal::deepCopy() const return new LeafExprVal(*this); } -LeafExprVar::LeafExprVar(const std::string& var):_fast_pos(-1),_var_name(var),_val(0) +LeafExprVar::LeafExprVar(const std::string& var):_fast_pos(-1),_var_name(var),_val(nullptr) { } @@ -105,7 +110,7 @@ void LeafExprVar::fillValue(Value *val) const void LeafExprVar::prepareExprEvaluation(const std::vector& vars, int nbOfCompo, int targetNbOfCompo) const { - std::vector::const_iterator iter=std::find(vars.begin(),vars.end(),_var_name); + auto const iter=std::find(vars.begin(),vars.end(),_var_name); if(iter==vars.end()) { if(!isRecognizedKeyVar(_var_name,_fast_pos)) @@ -116,7 +121,7 @@ void LeafExprVar::prepareExprEvaluation(const std::vector& vars, in } else { - int relPos=-7-_fast_pos; + int const relPos=-7-_fast_pos; if(relPos>=targetNbOfCompo) { std::ostringstream oss; oss << "LeafExprVar::prepareExprEvaluation : Found recognized unitary vector \"" << _var_name << "\" which implies that component #" << relPos; @@ -161,10 +166,10 @@ bool LeafExprVar::isRecognizedKeyVar(const std::string& var, int& pos) { if(var.length()!=sizeof(END_OF_RECOGNIZED_VAR)) return false; - std::string end=var.substr(1); + std::string const end=var.substr(1); if(end!=END_OF_RECOGNIZED_VAR) return false; - char first=var[0]; + char const first=var[0]; if(first<'I' || first>'Z') return false; pos=-7-(first-'I'); @@ -184,36 +189,35 @@ void LeafExprVar::replaceValues(const std::vector& valuesInExpr) } LeafExprVar::~LeafExprVar() -{ -} += default; void ExprParserOfEval::clearSortedMemory() { delete _leaf; - for(std::vector::iterator it=_sub_parts.begin();it!=_sub_parts.end();it++) - (*it).clearSortedMemory(); - for(std::vector::iterator it=_funcs.begin();it!=_funcs.end();it++) - delete *it; + for(auto & _sub_part : _sub_parts) + _sub_part.clearSortedMemory(); + for(auto & _func : _funcs) + delete _func; } void ExprParserOfEval::sortMemory() { - for(std::vector::iterator it=_sub_parts.begin();it!=_sub_parts.end();it++) - (*it).sortMemory(); + for(auto & _sub_part : _sub_parts) + _sub_part.sortMemory(); if(_leaf) _leaf=_leaf->deepCopy(); - for(std::vector::iterator it=_funcs.begin();it!=_funcs.end();it++) - if(*it) - *it=(*it)->deepCopy(); + for(auto & _func : _funcs) + if(_func) + _func=_func->deepCopy(); } -ExprParser::ExprParser(const std::string& expr, ExprParser *father):_father(father),_is_parsed(false),_leaf(0),_is_parsing_ok(false),_expr(expr) +ExprParser::ExprParser(const std::string& expr, ExprParser *father):_father(father),_is_parsed(false),_leaf(nullptr),_is_parsing_ok(false),_expr(expr) { _expr=deleteWhiteSpaces(_expr); } //! For \b NOT null terminated strings coming from FORTRAN. -ExprParser::ExprParser(const char *expr, int lgth, ExprParser *father):_father(father),_is_parsed(false),_leaf(0),_is_parsing_ok(false) +ExprParser::ExprParser(const char *expr, int lgth, ExprParser *father):_father(father),_is_parsed(false),_leaf(nullptr),_is_parsing_ok(false) { _expr=buildStringFromFortran(expr,lgth); _expr=deleteWhiteSpaces(_expr); @@ -231,7 +235,7 @@ std::size_t ExprParser::FindCorrespondingOpenBracket(const std::string& expr, st int level=0; for(std::size_t iter=0;iter valuesInExpr; fillValuesInExpr(valuesInExpr); checkBracketsParity(); @@ -308,7 +312,7 @@ double ExprParser::evaluate() const DecompositionInUnitBase ExprParser::evaluateUnit() const { Value *gen=new ValueUnit; - ValueUnit *res=0; + ValueUnit *res=nullptr; try { res=(ValueUnit *)evaluateLowLev(gen); @@ -335,13 +339,13 @@ void ExprParser::prepareExprEvaluation(const std::vector& vars, int { if(_leaf) { - LeafExprVar *leafC=dynamic_cast(_leaf); + auto *leafC=dynamic_cast(_leaf); if(leafC) leafC->prepareExprEvaluation(vars,nbOfCompo,targetNbOfCompo); } else - for(std::vector::const_iterator iter=_sub_expr.begin();iter!=_sub_expr.end();iter++) - (*iter).prepareExprEvaluation(vars,nbOfCompo,targetNbOfCompo); + for(const auto & iter : _sub_expr) + iter.prepareExprEvaluation(vars,nbOfCompo,targetNbOfCompo); } /*! @@ -357,13 +361,13 @@ void ExprParser::prepareExprEvaluationDouble(const std::vector& var throw INTERP_KERNEL::Exception("ExprParser::prepareExprEvaluationDouble : size of input vector must be equal to the input vector !"); if(_leaf) { - LeafExprVar *leafC=dynamic_cast(_leaf); + auto *leafC=dynamic_cast(_leaf); if(leafC) leafC->prepareExprEvaluationDouble(vars,nbOfCompo,targetNbOfCompo,refPos,ptOfInputStart,ptOfInputEnd); } else - for(std::vector::const_iterator iter=_sub_expr.begin();iter!=_sub_expr.end();iter++) - (*iter).prepareExprEvaluationDouble(vars,nbOfCompo,targetNbOfCompo,refPos,ptOfInputStart,ptOfInputEnd); + for(const auto & iter : _sub_expr) + iter.prepareExprEvaluationDouble(vars,nbOfCompo,targetNbOfCompo,refPos,ptOfInputStart,ptOfInputEnd); } void ExprParser::prepareFastEvaluator() const @@ -410,13 +414,13 @@ void ExprParser::prepareExprEvaluationVecLowLev() const { if(_leaf) { - LeafExprVar *leafC=dynamic_cast(_leaf); + auto *leafC=dynamic_cast(_leaf); if(leafC) leafC->prepareExprEvaluationVec(); } else - for(std::vector::const_iterator iter=_sub_expr.begin();iter!=_sub_expr.end();iter++) - (*iter).prepareExprEvaluationVecLowLev(); + for(const auto & iter : _sub_expr) + iter.prepareExprEvaluationVecLowLev(); } Value *ExprParser::evaluateLowLev(Value *valGen) const @@ -443,17 +447,17 @@ Value *ExprParser::evaluateLowLev(Value *valGen) const else { stackOfVal.resize(_sub_expr.size()); - std::vector::iterator iter2=stackOfVal.begin(); - for(std::vector::const_iterator iter=_sub_expr.begin();iter!=_sub_expr.end();iter++,iter2++) + auto iter2=stackOfVal.begin(); + for(auto iter=_sub_expr.begin();iter!=_sub_expr.end();iter++,iter2++) *iter2=(*iter).evaluateLowLev(valGen); } - for(std::vector::const_iterator iter3=_func_btw_sub_expr.begin();iter3!=_func_btw_sub_expr.end();iter3++) - (*iter3)->operate(stackOfVal); + for(auto iter3 : _func_btw_sub_expr) + iter3->operate(stackOfVal); } catch(INTERP_KERNEL::Exception& e) { - for(std::vector::iterator iter4=stackOfVal.begin();iter4!=stackOfVal.end();iter4++) - delete *iter4; + for(auto & iter4 : stackOfVal) + delete iter4; throw e; } return stackOfVal.back(); @@ -461,7 +465,7 @@ Value *ExprParser::evaluateLowLev(Value *valGen) const ExprParser::ExprParser(ExprParser&& other):_father(other._father),_leaf(other._leaf),_is_parsing_ok(std::move(other._is_parsing_ok)),_expr(std::move(other._expr)),_sub_expr(std::move(other._sub_expr)),_func_btw_sub_expr(std::move(other._func_btw_sub_expr)) { - other._leaf=0; + other._leaf=nullptr; } ExprParser& ExprParser::operator=(ExprParser&& other) @@ -473,7 +477,7 @@ ExprParser& ExprParser::operator=(ExprParser&& other) _sub_expr=std::move(other._sub_expr); _func_btw_sub_expr=std::move(other._func_btw_sub_expr); other._leaf=other._leaf; - other._leaf=0; + other._leaf=nullptr; return *this; } @@ -481,17 +485,17 @@ void ExprParser::reverseThis() { if(_leaf) return ; - for(std::vector::iterator iter=_sub_expr.begin();iter!=_sub_expr.end();iter++) - (*iter).reverseThis(); - std::size_t sz(_sub_expr.size()); - std::size_t nbOfTurn(sz/2); + for(auto & iter : _sub_expr) + iter.reverseThis(); + std::size_t const sz(_sub_expr.size()); + std::size_t const nbOfTurn(sz/2); for(std::size_t i=0;i subExpr(sz); for(std::size_t i=0;i& vars) const { if(_leaf) { - LeafExprVar *leafC=dynamic_cast(_leaf); + auto *leafC=dynamic_cast(_leaf); if(leafC) vars.insert(leafC->getVar()); } else - for(std::vector::const_iterator iter=_sub_expr.begin();iter!=_sub_expr.end();iter++) - (*iter).getSetOfVars(vars); + for(const auto & iter : _sub_expr) + iter.getSetOfVars(vars); } void ExprParser::getTrueSetOfVars(std::set& trueVars) const @@ -516,19 +520,19 @@ void ExprParser::getTrueSetOfVars(std::set& trueVars) const std::set vars; getSetOfVars(vars); trueVars.clear(); - for(std::set::const_iterator iter=vars.begin();iter!=vars.end();iter++) + for(const auto & var : vars) { int tmp; - if(!LeafExprVar::isRecognizedKeyVar(*iter,tmp)) - trueVars.insert(*iter); + if(!LeafExprVar::isRecognizedKeyVar(var,tmp)) + trueVars.insert(var); } } void ExprParser::parseDeeper() { - for(std::vector::iterator iter=_sub_expr.begin();iter!=_sub_expr.end();iter++) - if(!(*iter).simplify()) - (*iter).parseDeeper(); + for(auto & iter : _sub_expr) + if(!iter.simplify()) + iter.parseDeeper(); } /*! @@ -541,22 +545,22 @@ void ExprParser::parseUnaryFunc() if(_expr[_expr.length()-1]!=')') return ; //at this level of code _expr - std::size_t pos1=_expr.find_first_of('('); - std::size_t pos4=FindCorrespondingOpenBracket(_expr,_expr.length()-1); + std::size_t const pos1=_expr.find_first_of('('); + std::size_t const pos4=FindCorrespondingOpenBracket(_expr,_expr.length()-1); if(pos4!=pos1) return ; std::string funcName=_expr.substr(0,pos1); - std::size_t pos2=funcName.find_first_of("+-*/^><",0,7); - std::size_t pos3=funcName.find_first_not_of("+-*/^><",0,7); + std::size_t const pos2=funcName.find_first_of("+-*/^><",0,7); + std::size_t const pos3=funcName.find_first_not_of("+-*/^><",0,7); if(pos2!=std::string::npos && pos3!=std::string::npos) return ;//Bracket group is not alone, can't conclude not recursively. std::string newExp2=_expr.substr(pos1+1,_expr.length()-pos1-2); - std::size_t nbOfParamsInFunc=std::count(newExp2.begin(),newExp2.end(),',')+1; + std::size_t const nbOfParamsInFunc=std::count(newExp2.begin(),newExp2.end(),',')+1; if(pos3!=std::string::npos) _func_btw_sub_expr.push_back(FunctionsFactory::buildFuncFromString(funcName.c_str(),(int)nbOfParamsInFunc)); else { - std::size_t lgth=funcName.length(); + std::size_t const lgth=funcName.length(); char tmp[2]; tmp[1]='\0'; for(std::size_t i=0;i",0,9); + std::size_t const pos=_expr.find_first_not_of("+-",0,2); + std::string const minimizedExpr=_expr.substr(pos); + std::size_t const pos2=minimizedExpr.find_first_of("+-*/^()<>",0,9); if(pos2!=std::string::npos) return false; delete _leaf; @@ -627,7 +631,7 @@ void ExprParser::parseForCmp() std::ostringstream errMsg; char MSGTYP1[]="Error non unary function for '"; errMsg << EXPR_PARSE_ERR_MSG << MSGTYP1 << *iter << "'"; - std::string tmp=_expr.substr(iter-_expr.begin()); + std::string const tmp=_expr.substr(iter-_expr.begin()); LocateError(errMsg,tmp,0); throw INTERP_KERNEL::Exception(errMsg.str().c_str()); } @@ -680,7 +684,7 @@ void ExprParser::parseForAddMin() { if(!curPart.empty()) { - std::string::reverse_iterator accessor=curPart.rbegin(); + std::string::reverse_iterator const accessor=curPart.rbegin(); if(*accessor!='*' && *accessor!='/' && *accessor!='^') { isParsingSucceed=true; @@ -752,7 +756,7 @@ void ExprParser::parseForMulDiv() std::ostringstream errMsg; char MSGTYP1[]="Error non unary function for '"; errMsg << EXPR_PARSE_ERR_MSG << MSGTYP1 << *iter << "'"; - std::string tmp=_expr.substr(iter-_expr.begin()); + std::string const tmp=_expr.substr(iter-_expr.begin()); LocateError(errMsg,tmp,0); throw INTERP_KERNEL::Exception(errMsg.str().c_str()); } @@ -813,7 +817,7 @@ void ExprParser::parseForPow() std::ostringstream errMsg; char MSGTYP1[]="Error non unary function for '"; errMsg << EXPR_PARSE_ERR_MSG << MSGTYP1 << *iter << "'"; - std::string tmp=_expr.substr(iter-_expr.begin()); + std::string const tmp=_expr.substr(iter-_expr.begin()); LocateError(errMsg,tmp,0);curPart+=*iter; throw INTERP_KERNEL::Exception(errMsg.str().c_str()); } @@ -849,8 +853,8 @@ void ExprParser::parseForPow() void ExprParser::releaseFunctions() { - for(std::vector::iterator iter=_func_btw_sub_expr.begin();iter!=_func_btw_sub_expr.end();iter++) - delete *iter; + for(auto & iter : _func_btw_sub_expr) + delete iter; _func_btw_sub_expr.clear(); } @@ -929,8 +933,8 @@ double ExprParser::ReplaceAndTraduce(std::string& expr, int id, std::size_t bg, static const char MSG[]="Internal error : A string expected to be a float is not one ! Bug to signal !"; std::istringstream stream; std::ostringstream oss; - std::size_t end2=end!=std::string::npos?end-bg:end; - std::string tmp=expr.substr(bg,end2); + std::size_t const end2=end!=std::string::npos?end-bg:end; + std::string const tmp=expr.substr(bg,end2); stream.str(tmp); double ret=std::numeric_limits::max(); stream >> ret; @@ -939,8 +943,8 @@ double ExprParser::ReplaceAndTraduce(std::string& expr, int id, std::size_t bg, if(!stream.eof()) throw INTERP_KERNEL::Exception(MSG); oss << id; - std::string tmp2(oss.str()); - std::size_t l1=tmp.length(); + std::string const tmp2(oss.str()); + std::size_t const l1=tmp.length(); delta=(int)tmp2.length()-(int)l1; expr.replace(bg,l1,tmp2); return ret; @@ -955,11 +959,11 @@ void ExprParser::fillValuesInExpr(std::vector& valuesInExpr) { const char FIGURES[]="0123456789"; const std::string other("+-*^/(<>,"); - std::size_t lgth=_expr.length(); + std::size_t const lgth=_expr.length(); int id=0,delta; for(std::size_t pos=0;pos!=std::string::npos;id++) { - std::size_t pos2=_expr.find_first_of(FIGURES,pos,10); + std::size_t const pos2=_expr.find_first_of(FIGURES,pos,10); if(pos2==std::string::npos) break; if(pos2>0) @@ -1013,7 +1017,7 @@ void ExprParser::fillValuesInExpr(std::vector& valuesInExpr) std::ostringstream oss; oss << "Invalid expr : float number at the end of expr is invalid lacking number after exponential and sign ! -> \"" << _expr.substr(pos2) << "\""; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - std::size_t pos5=_expr.find_first_not_of(FIGURES,pos4,10); + std::size_t const pos5=_expr.find_first_not_of(FIGURES,pos4,10); if(pos4==pos5) {//"x+1223334.223e+x" or "1223334.223E-y" std::ostringstream oss; oss << "Invalid expr : float number in expr is invalid lacking number after exponential ! -> \"" << _expr.substr(pos2,pos4-pos2) << "\""; @@ -1046,8 +1050,8 @@ void ExprParser::replaceValues(const std::vector& valuesInExpr) _leaf->replaceValues(valuesInExpr); else { - for(std::vector::iterator iter=_sub_expr.begin();iter!=_sub_expr.end();iter++) - (*iter).replaceValues(valuesInExpr); + for(auto & iter : _sub_expr) + iter.replaceValues(valuesInExpr); } } @@ -1066,12 +1070,12 @@ char *ExprParser::compileX86() const ass.push_back("pop ebp"); ass.push_back("ret"); std::cout << std::endl; - for(std::vector::const_iterator iter=ass.begin();iter!=ass.end();iter++) - std::cout << " " << *iter << std::endl; - AsmX86 asmb; - std::vector output=asmb.convertIntoMachineLangage(ass); - for(std::vector::const_iterator iter=output.begin();iter!=output.end();iter++) - std::cout << std::hex << (int)((unsigned char)(*iter)) << " "; + for(const auto & as : ass) + std::cout << " " << as << std::endl; + AsmX86 const asmb; + std::vector const output=asmb.convertIntoMachineLangage(ass); + for(char const iter : output) + std::cout << std::hex << (int)((unsigned char)iter) << " "; std::cout << std::endl; unsigned offset; return asmb.copyToExecMemZone(output,offset); @@ -1091,12 +1095,12 @@ char *ExprParser::compileX86_64() const ass.push_back("leave"); ass.push_back("ret"); std::cout << std::endl; - for(std::vector::const_iterator iter=ass.begin();iter!=ass.end();iter++) - std::cout << " " << *iter << std::endl; - AsmX86 asmb; - std::vector output=asmb.convertIntoMachineLangage(ass); - for(std::vector::const_iterator iter=output.begin();iter!=output.end();iter++) - std::cout << std::hex << (int)((unsigned char)(*iter)) << " "; + for(const auto & as : ass) + std::cout << " " << as << std::endl; + AsmX86 const asmb; + std::vector const output=asmb.convertIntoMachineLangage(ass); + for(char const iter : output) + std::cout << std::hex << (int)((unsigned char)iter) << " "; std::cout << std::endl; unsigned offset; return asmb.copyToExecMemZone(output,offset); @@ -1108,11 +1112,11 @@ void ExprParser::compileX86LowLev(std::vector& ass) const _leaf->compileX86(ass); else { - for(std::vector::const_iterator iter=_sub_expr.begin();iter!=_sub_expr.end();iter++) - (*iter).compileX86LowLev(ass); + for(const auto & iter : _sub_expr) + iter.compileX86LowLev(ass); } - for(std::vector::const_iterator iter2=_func_btw_sub_expr.begin();iter2!=_func_btw_sub_expr.end();iter2++) - (*iter2)->operateX86(ass); + for(auto iter2 : _func_btw_sub_expr) + iter2->operateX86(ass); } void ExprParser::compileX86_64LowLev(std::vector& ass) const @@ -1121,11 +1125,11 @@ void ExprParser::compileX86_64LowLev(std::vector& ass) const _leaf->compileX86_64(ass); else { - for(std::vector::const_iterator iter=_sub_expr.begin();iter!=_sub_expr.end();iter++) - (*iter).compileX86_64LowLev(ass); + for(const auto & iter : _sub_expr) + iter.compileX86_64LowLev(ass); } - for(std::vector::const_iterator iter2=_func_btw_sub_expr.begin();iter2!=_func_btw_sub_expr.end();iter2++) - (*iter2)->operateX86(ass); + for(auto iter2 : _func_btw_sub_expr) + iter2->operateX86(ass); } double LeafExprVal::getDoubleValue() const @@ -1171,7 +1175,7 @@ double LeafExprVar::getDoubleValue() const return _val[_fast_pos]; else { - int pos(-7-_fast_pos); + int const pos(-7-_fast_pos); return pos==_ref_pos?1.:0.; } } @@ -1193,9 +1197,9 @@ int ExprParser::getStackSizeToPlayX86(const ExprParser *asker) const { if(asker) { - int sz=_father->getStackSizeToPlayX86(this); + int const sz=_father->getStackSizeToPlayX86(this); int i=0; - for(std::vector::const_reverse_iterator iter=_sub_expr.rbegin();iter!=_sub_expr.rend();iter++,i++) + for(auto iter=_sub_expr.rbegin();iter!=_sub_expr.rend();iter++,i++) { const ExprParser& obj=(*iter); const ExprParser *pt=&obj; diff --git a/src/INTERP_KERNEL/ExprEval/InterpKernelExprParser.hxx b/src/INTERP_KERNEL/ExprEval/InterpKernelExprParser.hxx index 8d6099c72..e154c52e9 100644 --- a/src/INTERP_KERNEL/ExprEval/InterpKernelExprParser.hxx +++ b/src/INTERP_KERNEL/ExprEval/InterpKernelExprParser.hxx @@ -23,13 +23,13 @@ #include "INTERPKERNELDefines.hxx" #include "InterpKernelUnit.hxx" -#include "InterpKernelException.hxx" #include "InterpKernelFunction.hxx" +#include +#include #include -#include -#include #include +#include namespace INTERP_KERNEL { @@ -52,13 +52,13 @@ namespace INTERP_KERNEL { public: INTERPKERNEL_EXPORT LeafExprVal(double value); - INTERPKERNEL_EXPORT ~LeafExprVal(); - INTERPKERNEL_EXPORT double getDoubleValue() const; - INTERPKERNEL_EXPORT void compileX86(std::vector& ass) const; - INTERPKERNEL_EXPORT void compileX86_64(std::vector& ass) const; - INTERPKERNEL_EXPORT void fillValue(Value *val) const; - INTERPKERNEL_EXPORT void replaceValues(const std::vector& valuesInExpr); - INTERPKERNEL_EXPORT LeafExprVal *deepCopy() const; + INTERPKERNEL_EXPORT ~LeafExprVal() override; + INTERPKERNEL_EXPORT double getDoubleValue() const override; + INTERPKERNEL_EXPORT void compileX86(std::vector& ass) const override; + INTERPKERNEL_EXPORT void compileX86_64(std::vector& ass) const override; + INTERPKERNEL_EXPORT void fillValue(Value *val) const override; + INTERPKERNEL_EXPORT void replaceValues(const std::vector& valuesInExpr) override; + INTERPKERNEL_EXPORT LeafExprVal *deepCopy() const override; private: double _value; }; @@ -68,18 +68,18 @@ namespace INTERP_KERNEL public: INTERPKERNEL_EXPORT LeafExprVar(const LeafExprVar& other):_fast_pos(other._fast_pos),_ref_pos(other._ref_pos),_var_name(other._var_name),_val(other._val) { } INTERPKERNEL_EXPORT LeafExprVar(const std::string& var); - INTERPKERNEL_EXPORT ~LeafExprVar(); - INTERPKERNEL_EXPORT double getDoubleValue() const; - INTERPKERNEL_EXPORT void compileX86(std::vector& ass) const; - INTERPKERNEL_EXPORT void compileX86_64(std::vector& ass) const; - INTERPKERNEL_EXPORT void fillValue(Value *val) const; + INTERPKERNEL_EXPORT ~LeafExprVar() override; + INTERPKERNEL_EXPORT double getDoubleValue() const override; + INTERPKERNEL_EXPORT void compileX86(std::vector& ass) const override; + INTERPKERNEL_EXPORT void compileX86_64(std::vector& ass) const override; + INTERPKERNEL_EXPORT void fillValue(Value *val) const override; INTERPKERNEL_EXPORT std::string getVar() const { return _var_name; } INTERPKERNEL_EXPORT void prepareExprEvaluation(const std::vector& vars, int nbOfCompo, int targetNbOfCompo) const; INTERPKERNEL_EXPORT void prepareExprEvaluationDouble(const std::vector& vars, int nbOfCompo, int targetNbOfCompo, int refPos, const double *ptOfInputStart, const double *ptOfInputEnd) const; INTERPKERNEL_EXPORT void prepareExprEvaluationVec() const; - INTERPKERNEL_EXPORT void replaceValues(const std::vector& valuesInExpr); + INTERPKERNEL_EXPORT void replaceValues(const std::vector& valuesInExpr) override; INTERPKERNEL_EXPORT static bool isRecognizedKeyVar(const std::string& var, int& pos); - INTERPKERNEL_EXPORT LeafExprVar *deepCopy() const; + INTERPKERNEL_EXPORT LeafExprVar *deepCopy() const override; public: static const char END_OF_RECOGNIZED_VAR[]; private: @@ -92,27 +92,27 @@ namespace INTERP_KERNEL class ExprParserOfEval { public: - ExprParserOfEval():_leaf(0) { } + ExprParserOfEval():_leaf(nullptr) { } ExprParserOfEval(LeafExpr *leaf, const std::vector& subParts, const std::vector& funcs):_leaf(leaf),_sub_parts(subParts),_funcs(funcs) { } void evaluateDoubleInternal(std::vector& stck) const { if(_leaf) stck.push_back(_leaf->getDoubleValue()); else - for(std::vector::const_iterator iter=_sub_parts.begin();iter!=_sub_parts.end();iter++) - (*iter).evaluateDoubleInternal(stck); - for(std::vector::const_iterator iter3=_funcs.begin();iter3!=_funcs.end();iter3++) - (*iter3)->operateStackOfDouble(stck); + for(const auto & _sub_part : _sub_parts) + _sub_part.evaluateDoubleInternal(stck); + for(auto _func : _funcs) + _func->operateStackOfDouble(stck); } void evaluateDoubleInternalSafe(std::vector& stck) const { if(_leaf) stck.push_back(_leaf->getDoubleValue()); else - for(std::vector::const_iterator iter=_sub_parts.begin();iter!=_sub_parts.end();iter++) - (*iter).evaluateDoubleInternalSafe(stck); - for(std::vector::const_iterator iter3=_funcs.begin();iter3!=_funcs.end();iter3++) - (*iter3)->operateStackOfDoubleSafe(stck); + for(const auto & _sub_part : _sub_parts) + _sub_part.evaluateDoubleInternalSafe(stck); + for(auto _func : _funcs) + _func->operateStackOfDoubleSafe(stck); } void clearSortedMemory(); void sortMemory(); @@ -127,8 +127,8 @@ namespace INTERP_KERNEL public: INTERPKERNEL_EXPORT ExprParser(ExprParser&& other); INTERPKERNEL_EXPORT ExprParser& operator=(ExprParser&& other); - INTERPKERNEL_EXPORT ExprParser(const std::string& expr, ExprParser *father=0); - INTERPKERNEL_EXPORT ExprParser(const char *expr, int lgth, ExprParser *father=0); + INTERPKERNEL_EXPORT ExprParser(const std::string& expr, ExprParser *father=nullptr); + INTERPKERNEL_EXPORT ExprParser(const char *expr, int lgth, ExprParser *father=nullptr); INTERPKERNEL_EXPORT ~ExprParser(); INTERPKERNEL_EXPORT void parse(); INTERPKERNEL_EXPORT bool isParsingSuccessfull() const { return _is_parsing_ok; } diff --git a/src/INTERP_KERNEL/ExprEval/InterpKernelFunction.cxx b/src/INTERP_KERNEL/ExprEval/InterpKernelFunction.cxx index 041283f95..0c66c265f 100644 --- a/src/INTERP_KERNEL/ExprEval/InterpKernelFunction.cxx +++ b/src/INTERP_KERNEL/ExprEval/InterpKernelFunction.cxx @@ -20,10 +20,13 @@ #include "InterpKernelFunction.hxx" #include "InterpKernelValue.hxx" +#include "InterpKernelException.hxx" #include #include #include +#include +#include using namespace INTERP_KERNEL; @@ -100,7 +103,7 @@ Function *FunctionsFactory::buildFuncFromString(const char *type, int nbOfParams Function *FunctionsFactory::buildUnaryFuncFromString(const char *type) { - std::string tmp(type); + std::string const tmp(type); if(tmp.empty()) return new IdentityFunction; if(tmp==CosFunction::REPR) @@ -145,7 +148,7 @@ Function *FunctionsFactory::buildUnaryFuncFromString(const char *type) Function *FunctionsFactory::buildBinaryFuncFromString(const char *type) { - std::string tmp(type); + std::string const tmp(type); if(tmp==PositiveFunction::REPR) return new PlusFunction; if(tmp==NegateFunction::REPR) @@ -171,7 +174,7 @@ Function *FunctionsFactory::buildBinaryFuncFromString(const char *type) Function *FunctionsFactory::buildTernaryFuncFromString(const char *type) { - std::string tmp(type); + std::string const tmp(type); if(tmp==IfFunction::REPR) return new IfFunction(); std::string msg("Invalid ternary function detected : \""); @@ -186,12 +189,10 @@ Function *FunctionsFactory::buildBinaryFuncFromString(char type) } Function::~Function() -{ -} += default; IdentityFunction::~IdentityFunction() -{ -} += default; void IdentityFunction::operate(std::vector& stck) const { @@ -216,8 +217,7 @@ bool IdentityFunction::isACall() const } PositiveFunction::~PositiveFunction() -{ -} += default; int UnaryFunction::getNbInputParams() const { @@ -247,8 +247,7 @@ bool PositiveFunction::isACall() const } NegateFunction::~NegateFunction() -{ -} += default; void NegateFunction::operate(std::vector& stck) const { @@ -263,7 +262,7 @@ void NegateFunction::operateX86(std::vector& asmb) const void NegateFunction::operateStackOfDouble(std::vector& stck) const { - double v(stck.back()); + double const v(stck.back()); stck.back()=-v; } @@ -278,8 +277,7 @@ bool NegateFunction::isACall() const } CosFunction::~CosFunction() -{ -} += default; void CosFunction::operate(std::vector& stck) const { @@ -294,7 +292,7 @@ void CosFunction::operateX86(std::vector& asmb) const void CosFunction::operateStackOfDouble(std::vector& stck) const { - double v(stck.back()); + double const v(stck.back()); stck.back()=cos(v); } @@ -309,8 +307,7 @@ bool CosFunction::isACall() const } SinFunction::~SinFunction() -{ -} += default; void SinFunction::operate(std::vector& stck) const { @@ -325,7 +322,7 @@ void SinFunction::operateX86(std::vector& asmb) const void SinFunction::operateStackOfDouble(std::vector& stck) const { - double v(stck.back()); + double const v(stck.back()); stck.back()=sin(v); } @@ -340,8 +337,7 @@ bool SinFunction::isACall() const } TanFunction::~TanFunction() -{ -} += default; void TanFunction::operate(std::vector& stck) const { @@ -349,14 +345,14 @@ void TanFunction::operate(std::vector& stck) const val->tan(); } -void TanFunction::operateX86(std::vector& asmb) const +void TanFunction::operateX86(std::vector& /*asmb*/) const { throw INTERP_KERNEL::Exception("Assembly Not implemented yet !"); } void TanFunction::operateStackOfDouble(std::vector& stck) const { - double v(stck.back()); + double const v(stck.back()); stck.back()=tan(v); } @@ -371,8 +367,7 @@ bool TanFunction::isACall() const } ACosFunction::~ACosFunction() -{ -} += default; void ACosFunction::operate(std::vector& stck) const { @@ -380,20 +375,20 @@ void ACosFunction::operate(std::vector& stck) const val->acos(); } -void ACosFunction::operateX86(std::vector& asmb) const +void ACosFunction::operateX86(std::vector& /*asmb*/) const { throw INTERP_KERNEL::Exception("Assembly Not implemented yet !"); } void ACosFunction::operateStackOfDouble(std::vector& stck) const { - double v(stck.back()); + double const v(stck.back()); stck.back()=acos(v); } void ACosFunction::operateStackOfDoubleSafe(std::vector& stck) const { - double v(stck.back()); + double const v(stck.back()); if(fabs(v)>1.) throw INTERP_KERNEL::Exception("acos on a value which absolute is > 1 !"); stck.back()=acos(v); @@ -410,8 +405,7 @@ bool ACosFunction::isACall() const } ASinFunction::~ASinFunction() -{ -} += default; void ASinFunction::operate(std::vector& stck) const { @@ -419,20 +413,20 @@ void ASinFunction::operate(std::vector& stck) const val->asin(); } -void ASinFunction::operateX86(std::vector& asmb) const +void ASinFunction::operateX86(std::vector& /*asmb*/) const { throw INTERP_KERNEL::Exception("Assembly Not implemented yet !"); } void ASinFunction::operateStackOfDouble(std::vector& stck) const { - double v(stck.back()); + double const v(stck.back()); stck.back()=asin(v); } void ASinFunction::operateStackOfDoubleSafe(std::vector& stck) const { - double v(stck.back()); + double const v(stck.back()); if(fabs(v)>1.) throw INTERP_KERNEL::Exception("asin on a value which absolute is > 1 !"); stck.back()=asin(v); @@ -449,8 +443,7 @@ bool ASinFunction::isACall() const } ATanFunction::~ATanFunction() -{ -} += default; void ATanFunction::operate(std::vector& stck) const { @@ -458,14 +451,14 @@ void ATanFunction::operate(std::vector& stck) const val->atan(); } -void ATanFunction::operateX86(std::vector& asmb) const +void ATanFunction::operateX86(std::vector& /*asmb*/) const { throw INTERP_KERNEL::Exception("Assembly Not implemented yet !"); } void ATanFunction::operateStackOfDouble(std::vector& stck) const { - double v(stck.back()); + double const v(stck.back()); stck.back()=atan(v); } @@ -480,8 +473,7 @@ bool ATanFunction::isACall() const } CoshFunction::~CoshFunction() -{ -} += default; void CoshFunction::operate(std::vector& stck) const { @@ -489,14 +481,14 @@ void CoshFunction::operate(std::vector& stck) const val->cosh(); } -void CoshFunction::operateX86(std::vector& asmb) const +void CoshFunction::operateX86(std::vector& /*asmb*/) const { throw INTERP_KERNEL::Exception("Assembly Not implemented yet !"); } void CoshFunction::operateStackOfDouble(std::vector& stck) const { - double v(stck.back()); + double const v(stck.back()); stck.back()=cosh(v); } @@ -511,8 +503,7 @@ bool CoshFunction::isACall() const } SinhFunction::~SinhFunction() -{ -} += default; void SinhFunction::operate(std::vector& stck) const { @@ -520,14 +511,14 @@ void SinhFunction::operate(std::vector& stck) const val->sinh(); } -void SinhFunction::operateX86(std::vector& asmb) const +void SinhFunction::operateX86(std::vector& /*asmb*/) const { throw INTERP_KERNEL::Exception("Assembly Not implemented yet !"); } void SinhFunction::operateStackOfDouble(std::vector& stck) const { - double v(stck.back()); + double const v(stck.back()); stck.back()=sinh(v); } @@ -542,8 +533,7 @@ bool SinhFunction::isACall() const } TanhFunction::~TanhFunction() -{ -} += default; void TanhFunction::operate(std::vector& stck) const { @@ -551,14 +541,14 @@ void TanhFunction::operate(std::vector& stck) const val->tanh(); } -void TanhFunction::operateX86(std::vector& asmb) const +void TanhFunction::operateX86(std::vector& /*asmb*/) const { throw INTERP_KERNEL::Exception("Assembly Not implemented yet !"); } void TanhFunction::operateStackOfDouble(std::vector& stck) const { - double v(stck.back()); + double const v(stck.back()); stck.back()=tanh(v); } @@ -573,8 +563,7 @@ bool TanhFunction::isACall() const } SqrtFunction::~SqrtFunction() -{ -} += default; void SqrtFunction::operate(std::vector& stck) const { @@ -589,13 +578,13 @@ void SqrtFunction::operateX86(std::vector& asmb) const void SqrtFunction::operateStackOfDouble(std::vector& stck) const { - double v(stck.back()); + double const v(stck.back()); stck.back()=sqrt(v); } void SqrtFunction::operateStackOfDoubleSafe(std::vector& stck) const { - double v(stck.back()); + double const v(stck.back()); if(v<0.) throw INTERP_KERNEL::Exception("sqrt on a value < 0. !"); stck.back()=sqrt(v); @@ -612,8 +601,7 @@ bool SqrtFunction::isACall() const } AbsFunction::~AbsFunction() -{ -} += default; void AbsFunction::operate(std::vector& stck) const { @@ -628,7 +616,7 @@ void AbsFunction::operateX86(std::vector& asmb) const void AbsFunction::operateStackOfDouble(std::vector& stck) const { - double v(stck.back()); + double const v(stck.back()); stck.back()=fabs(v); } @@ -648,14 +636,14 @@ void ExpFunction::operate(std::vector& stck) const val->exp(); } -void ExpFunction::operateX86(std::vector& asmb) const +void ExpFunction::operateX86(std::vector& /*asmb*/) const { throw INTERP_KERNEL::Exception("Assembly Not implemented yet !"); } void ExpFunction::operateStackOfDouble(std::vector& stck) const { - double v(stck.back()); + double const v(stck.back()); stck.back()=std::exp(v); } @@ -670,8 +658,7 @@ bool ExpFunction::isACall() const } LnFunction::~LnFunction() -{ -} += default; void LnFunction::operate(std::vector& stck) const { @@ -679,20 +666,20 @@ void LnFunction::operate(std::vector& stck) const val->ln(); } -void LnFunction::operateX86(std::vector& asmb) const +void LnFunction::operateX86(std::vector& /*asmb*/) const { throw INTERP_KERNEL::Exception("Assembly Not implemented yet !"); } void LnFunction::operateStackOfDouble(std::vector& stck) const { - double v(stck.back()); + double const v(stck.back()); stck.back()=std::log(v); } void LnFunction::operateStackOfDoubleSafe(std::vector& stck) const { - double v(stck.back()); + double const v(stck.back()); if(v<0.) throw INTERP_KERNEL::Exception("ln on a value < 0. !"); stck.back()=std::log(v); @@ -709,8 +696,7 @@ bool LnFunction::isACall() const } LogFunction::~LogFunction() -{ -} += default; void LogFunction::operate(std::vector& stck) const { @@ -718,20 +704,20 @@ void LogFunction::operate(std::vector& stck) const val->ln(); } -void LogFunction::operateX86(std::vector& asmb) const +void LogFunction::operateX86(std::vector& /*asmb*/) const { throw INTERP_KERNEL::Exception("Assembly for log Not implemented yet !"); } void LogFunction::operateStackOfDouble(std::vector& stck) const { - double v(stck.back()); + double const v(stck.back()); stck.back()=std::log(v); } void LogFunction::operateStackOfDoubleSafe(std::vector& stck) const { - double v(stck.back()); + double const v(stck.back()); if(v<0.) throw INTERP_KERNEL::Exception("log on a value < 0. !"); stck.back()=std::log(v); @@ -748,8 +734,7 @@ bool LogFunction::isACall() const } Log10Function::~Log10Function() -{ -} += default; void Log10Function::operate(std::vector& stck) const { @@ -757,20 +742,20 @@ void Log10Function::operate(std::vector& stck) const val->log10(); } -void Log10Function::operateX86(std::vector& asmb) const +void Log10Function::operateX86(std::vector& /*asmb*/) const { throw INTERP_KERNEL::Exception("Assembly for log Not implemented yet !"); } void Log10Function::operateStackOfDouble(std::vector& stck) const { - double v(stck.back()); + double const v(stck.back()); stck.back()=std::log10(v); } void Log10Function::operateStackOfDoubleSafe(std::vector& stck) const { - double v(stck.back()); + double const v(stck.back()); if(v<0.) throw INTERP_KERNEL::Exception("log10 on a value < 0. !"); stck.back()=std::log10(v); @@ -792,8 +777,7 @@ int BinaryFunction::getNbInputParams() const } PlusFunction::~PlusFunction() -{ -} += default; void PlusFunction::operate(std::vector& stck) const { @@ -822,7 +806,7 @@ void PlusFunction::operateX86(std::vector& asmb) const void PlusFunction::operateStackOfDouble(std::vector& stck) const { - double a(stck.back()); + double const a(stck.back()); stck.pop_back(); stck.back()=a+stck.back(); } @@ -838,8 +822,7 @@ bool PlusFunction::isACall() const } MinusFunction::~MinusFunction() -{ -} += default; void MinusFunction::operate(std::vector& stck) const { @@ -868,7 +851,7 @@ void MinusFunction::operateX86(std::vector& asmb) const void MinusFunction::operateStackOfDouble(std::vector& stck) const { - double a(stck.back()); + double const a(stck.back()); stck.pop_back(); stck.back()=a-stck.back(); } @@ -884,8 +867,7 @@ bool MinusFunction::isACall() const } MultFunction::~MultFunction() -{ -} += default; void MultFunction::operate(std::vector& stck) const { @@ -905,7 +887,7 @@ void MultFunction::operateX86(std::vector& asmb) const void MultFunction::operateStackOfDouble(std::vector& stck) const { - double a(stck.back()); + double const a(stck.back()); stck.pop_back(); stck.back()=a*stck.back(); } @@ -921,8 +903,7 @@ bool MultFunction::isACall() const } DivFunction::~DivFunction() -{ -} += default; void DivFunction::operate(std::vector& stck) const { @@ -951,14 +932,14 @@ void DivFunction::operateX86(std::vector& asmb) const void DivFunction::operateStackOfDouble(std::vector& stck) const { - double a(stck.back()); + double const a(stck.back()); stck.pop_back(); stck.back()=a/stck.back(); } void DivFunction::operateStackOfDoubleSafe(std::vector& stck) const { - double a(stck.back()); + double const a(stck.back()); stck.pop_back(); if(stck.back()==0.) throw INTERP_KERNEL::Exception("division by 0. !"); @@ -976,8 +957,7 @@ bool DivFunction::isACall() const } PowFunction::~PowFunction() -{ -} += default; void PowFunction::operate(std::vector& stck) const { @@ -999,23 +979,23 @@ void PowFunction::operate(std::vector& stck) const val2=val3; } -void PowFunction::operateX86(std::vector& asmb) const +void PowFunction::operateX86(std::vector& /*asmb*/) const { throw INTERP_KERNEL::Exception("Assembly Not implemented yet !"); } void PowFunction::operateStackOfDouble(std::vector& stck) const { - double a(stck.back()); + double const a(stck.back()); stck.pop_back(); stck.back()=std::pow(a,stck.back()); } void PowFunction::operateStackOfDoubleSafe(std::vector& stck) const { - double a(stck.back()); + double const a(stck.back()); stck.pop_back(); - double b(stck.back()); + double const b(stck.back()); if(a<0.) throw INTERP_KERNEL::Exception("pow with val < 0. !"); stck.back()=std::pow(a,b); @@ -1032,12 +1012,10 @@ bool PowFunction::isACall() const } ExpFunction::~ExpFunction() -{ -} += default; MaxFunction::~MaxFunction() -{ -} += default; void MaxFunction::operate(std::vector& stck) const { @@ -1059,14 +1037,14 @@ void MaxFunction::operate(std::vector& stck) const val2=val3; } -void MaxFunction::operateX86(std::vector& asmb) const +void MaxFunction::operateX86(std::vector& /*asmb*/) const { throw INTERP_KERNEL::Exception("Assembly Not implemented yet !"); } void MaxFunction::operateStackOfDouble(std::vector& stck) const { - double a(stck.back()); + double const a(stck.back()); stck.pop_back(); stck.back()=std::max(stck.back(),a); } @@ -1082,8 +1060,7 @@ bool MaxFunction::isACall() const } MinFunction::~MinFunction() -{ -} += default; void MinFunction::operate(std::vector& stck) const { @@ -1105,14 +1082,14 @@ void MinFunction::operate(std::vector& stck) const val2=val3; } -void MinFunction::operateX86(std::vector& asmb) const +void MinFunction::operateX86(std::vector& /*asmb*/) const { throw INTERP_KERNEL::Exception("Assembly Not implemented yet !"); } void MinFunction::operateStackOfDouble(std::vector& stck) const { - double a(stck.back()); + double const a(stck.back()); stck.pop_back(); stck.back()=std::min(stck.back(),a); } @@ -1128,8 +1105,7 @@ bool MinFunction::isACall() const } GreaterThanFunction::~GreaterThanFunction() -{ -} += default; void GreaterThanFunction::operate(std::vector& stck) const { @@ -1151,16 +1127,16 @@ void GreaterThanFunction::operate(std::vector& stck) const val2=val3; } -void GreaterThanFunction::operateX86(std::vector& asmb) const +void GreaterThanFunction::operateX86(std::vector& /*asmb*/) const { throw INTERP_KERNEL::Exception("Assembly Not implemented yet !"); } void GreaterThanFunction::operateStackOfDouble(std::vector& stck) const { - double a(stck.back()); + double const a(stck.back()); stck.pop_back(); - double b(stck.back()); + double const b(stck.back()); stck.back()=a>b?std::numeric_limits::max():-std::numeric_limits::max(); } @@ -1175,8 +1151,7 @@ bool GreaterThanFunction::isACall() const } LowerThanFunction::~LowerThanFunction() -{ -} += default; void LowerThanFunction::operate(std::vector& stck) const { @@ -1198,16 +1173,16 @@ void LowerThanFunction::operate(std::vector& stck) const val2=val3; } -void LowerThanFunction::operateX86(std::vector& asmb) const +void LowerThanFunction::operateX86(std::vector& /*asmb*/) const { throw INTERP_KERNEL::Exception("Assembly Not implemented yet !"); } void LowerThanFunction::operateStackOfDouble(std::vector& stck) const { - double a(stck.back()); + double const a(stck.back()); stck.pop_back(); - double b(stck.back()); + double const b(stck.back()); stck.back()=a::max():-std::numeric_limits::max(); } @@ -1227,8 +1202,7 @@ int TernaryFunction::getNbInputParams() const } IfFunction::~IfFunction() -{ -} += default; void IfFunction::operate(std::vector& stck) const { @@ -1254,16 +1228,16 @@ void IfFunction::operate(std::vector& stck) const val3=val4; } -void IfFunction::operateX86(std::vector& asmb) const +void IfFunction::operateX86(std::vector& /*asmb*/) const { throw INTERP_KERNEL::Exception("Assembly Not implemented yet !"); } void IfFunction::operateStackOfDouble(std::vector& stck) const { - double cond(stck.back()); + double const cond(stck.back()); stck.pop_back(); - double the(stck.back()); + double const the(stck.back()); stck.pop_back(); if(cond==std::numeric_limits::max()) stck.back()=the; @@ -1271,9 +1245,9 @@ void IfFunction::operateStackOfDouble(std::vector& stck) const void IfFunction::operateStackOfDoubleSafe(std::vector& stck) const { - double cond(stck.back()); + double const cond(stck.back()); stck.pop_back(); - double the(stck.back()); + double const the(stck.back()); stck.pop_back(); if(cond!=std::numeric_limits::max() && cond!=-std::numeric_limits::max()) throw INTERP_KERNEL::Exception("ifFunc : first parameter of ternary func is NOT a consequence of a boolean op !"); diff --git a/src/INTERP_KERNEL/ExprEval/InterpKernelFunction.hxx b/src/INTERP_KERNEL/ExprEval/InterpKernelFunction.hxx index c55fbc921..5b0240141 100644 --- a/src/INTERP_KERNEL/ExprEval/InterpKernelFunction.hxx +++ b/src/INTERP_KERNEL/ExprEval/InterpKernelFunction.hxx @@ -22,8 +22,8 @@ #define __INTERPKERNELFUNCTION_HXX__ #include "INTERPKERNELDefines.hxx" -#include "InterpKernelException.hxx" +#include #include namespace INTERP_KERNEL @@ -59,19 +59,19 @@ namespace INTERP_KERNEL class INTERPKERNEL_EXPORT UnaryFunction : public Function { public: - int getNbInputParams() const; + int getNbInputParams() const override; }; class INTERPKERNEL_EXPORT IdentityFunction : public UnaryFunction { public: - ~IdentityFunction(); - void operate(std::vector& stck) const; - void operateX86(std::vector& asmb) const; - void operateStackOfDouble(std::vector& stck) const; - const char *getRepr() const; - bool isACall() const; - IdentityFunction *deepCopy() const { return new IdentityFunction; } + ~IdentityFunction() override; + void operate(std::vector& stck) const override; + void operateX86(std::vector& asmb) const override; + void operateStackOfDouble(std::vector& stck) const override; + const char *getRepr() const override; + bool isACall() const override; + IdentityFunction *deepCopy() const override { return new IdentityFunction; } public: static const char REPR[]; }; @@ -79,13 +79,13 @@ namespace INTERP_KERNEL class INTERPKERNEL_EXPORT PositiveFunction : public UnaryFunction { public: - ~PositiveFunction(); - void operate(std::vector& stck) const; - void operateX86(std::vector& asmb) const; - void operateStackOfDouble(std::vector& stck) const; - const char *getRepr() const; - bool isACall() const; - PositiveFunction *deepCopy() const { return new PositiveFunction; } + ~PositiveFunction() override; + void operate(std::vector& stck) const override; + void operateX86(std::vector& asmb) const override; + void operateStackOfDouble(std::vector& stck) const override; + const char *getRepr() const override; + bool isACall() const override; + PositiveFunction *deepCopy() const override { return new PositiveFunction; } public: static const char REPR[]; }; @@ -93,13 +93,13 @@ namespace INTERP_KERNEL class INTERPKERNEL_EXPORT NegateFunction : public UnaryFunction { public: - ~NegateFunction(); - void operate(std::vector& stck) const; - void operateX86(std::vector& asmb) const; - void operateStackOfDouble(std::vector& stck) const; - const char *getRepr() const; - bool isACall() const; - NegateFunction *deepCopy() const { return new NegateFunction; } + ~NegateFunction() override; + void operate(std::vector& stck) const override; + void operateX86(std::vector& asmb) const override; + void operateStackOfDouble(std::vector& stck) const override; + const char *getRepr() const override; + bool isACall() const override; + NegateFunction *deepCopy() const override { return new NegateFunction; } public: static const char REPR[]; }; @@ -107,13 +107,13 @@ namespace INTERP_KERNEL class INTERPKERNEL_EXPORT CosFunction : public UnaryFunction { public: - ~CosFunction(); - void operate(std::vector& stck) const; - void operateX86(std::vector& asmb) const; - void operateStackOfDouble(std::vector& stck) const; - const char *getRepr() const; - bool isACall() const; - CosFunction *deepCopy() const { return new CosFunction; } + ~CosFunction() override; + void operate(std::vector& stck) const override; + void operateX86(std::vector& asmb) const override; + void operateStackOfDouble(std::vector& stck) const override; + const char *getRepr() const override; + bool isACall() const override; + CosFunction *deepCopy() const override { return new CosFunction; } public: static const char REPR[]; }; @@ -121,13 +121,13 @@ namespace INTERP_KERNEL class INTERPKERNEL_EXPORT SinFunction : public UnaryFunction { public: - ~SinFunction(); - void operate(std::vector& stck) const; - void operateX86(std::vector& asmb) const; - void operateStackOfDouble(std::vector& stck) const; - const char *getRepr() const; - bool isACall() const; - SinFunction *deepCopy() const { return new SinFunction; } + ~SinFunction() override; + void operate(std::vector& stck) const override; + void operateX86(std::vector& asmb) const override; + void operateStackOfDouble(std::vector& stck) const override; + const char *getRepr() const override; + bool isACall() const override; + SinFunction *deepCopy() const override { return new SinFunction; } public: static const char REPR[]; }; @@ -135,13 +135,13 @@ namespace INTERP_KERNEL class INTERPKERNEL_EXPORT TanFunction : public UnaryFunction { public: - ~TanFunction(); - void operate(std::vector& stck) const; - void operateX86(std::vector& asmb) const; - void operateStackOfDouble(std::vector& stck) const; - const char *getRepr() const; - bool isACall() const; - TanFunction *deepCopy() const { return new TanFunction; } + ~TanFunction() override; + void operate(std::vector& stck) const override; + void operateX86(std::vector& asmb) const override; + void operateStackOfDouble(std::vector& stck) const override; + const char *getRepr() const override; + bool isACall() const override; + TanFunction *deepCopy() const override { return new TanFunction; } public: static const char REPR[]; }; @@ -149,14 +149,14 @@ namespace INTERP_KERNEL class INTERPKERNEL_EXPORT ACosFunction : public UnaryFunction { public: - ~ACosFunction(); - void operate(std::vector& stck) const; - void operateX86(std::vector& asmb) const; - void operateStackOfDouble(std::vector& stck) const; - void operateStackOfDoubleSafe(std::vector& stck) const; - const char *getRepr() const; - bool isACall() const; - ACosFunction *deepCopy() const { return new ACosFunction; } + ~ACosFunction() override; + void operate(std::vector& stck) const override; + void operateX86(std::vector& asmb) const override; + void operateStackOfDouble(std::vector& stck) const override; + void operateStackOfDoubleSafe(std::vector& stck) const override; + const char *getRepr() const override; + bool isACall() const override; + ACosFunction *deepCopy() const override { return new ACosFunction; } public: static const char REPR[]; }; @@ -164,14 +164,14 @@ namespace INTERP_KERNEL class INTERPKERNEL_EXPORT ASinFunction : public UnaryFunction { public: - ~ASinFunction(); - void operate(std::vector& stck) const; - void operateX86(std::vector& asmb) const; - void operateStackOfDouble(std::vector& stck) const; - void operateStackOfDoubleSafe(std::vector& stck) const; - const char *getRepr() const; - bool isACall() const; - ASinFunction *deepCopy() const { return new ASinFunction; } + ~ASinFunction() override; + void operate(std::vector& stck) const override; + void operateX86(std::vector& asmb) const override; + void operateStackOfDouble(std::vector& stck) const override; + void operateStackOfDoubleSafe(std::vector& stck) const override; + const char *getRepr() const override; + bool isACall() const override; + ASinFunction *deepCopy() const override { return new ASinFunction; } public: static const char REPR[]; }; @@ -179,13 +179,13 @@ namespace INTERP_KERNEL class INTERPKERNEL_EXPORT ATanFunction : public UnaryFunction { public: - ~ATanFunction(); - void operate(std::vector& stck) const; - void operateX86(std::vector& asmb) const; - void operateStackOfDouble(std::vector& stck) const; - const char *getRepr() const; - bool isACall() const; - ATanFunction *deepCopy() const { return new ATanFunction; } + ~ATanFunction() override; + void operate(std::vector& stck) const override; + void operateX86(std::vector& asmb) const override; + void operateStackOfDouble(std::vector& stck) const override; + const char *getRepr() const override; + bool isACall() const override; + ATanFunction *deepCopy() const override { return new ATanFunction; } public: static const char REPR[]; }; @@ -193,13 +193,13 @@ namespace INTERP_KERNEL class INTERPKERNEL_EXPORT CoshFunction : public UnaryFunction { public: - ~CoshFunction(); - void operate(std::vector& stck) const; - void operateX86(std::vector& asmb) const; - void operateStackOfDouble(std::vector& stck) const; - const char *getRepr() const; - bool isACall() const; - CoshFunction *deepCopy() const { return new CoshFunction; } + ~CoshFunction() override; + void operate(std::vector& stck) const override; + void operateX86(std::vector& asmb) const override; + void operateStackOfDouble(std::vector& stck) const override; + const char *getRepr() const override; + bool isACall() const override; + CoshFunction *deepCopy() const override { return new CoshFunction; } public: static const char REPR[]; }; @@ -207,13 +207,13 @@ namespace INTERP_KERNEL class INTERPKERNEL_EXPORT SinhFunction : public UnaryFunction { public: - ~SinhFunction(); - void operate(std::vector& stck) const; - void operateX86(std::vector& asmb) const; - void operateStackOfDouble(std::vector& stck) const; - const char *getRepr() const; - bool isACall() const; - SinhFunction *deepCopy() const { return new SinhFunction; } + ~SinhFunction() override; + void operate(std::vector& stck) const override; + void operateX86(std::vector& asmb) const override; + void operateStackOfDouble(std::vector& stck) const override; + const char *getRepr() const override; + bool isACall() const override; + SinhFunction *deepCopy() const override { return new SinhFunction; } public: static const char REPR[]; }; @@ -221,13 +221,13 @@ namespace INTERP_KERNEL class INTERPKERNEL_EXPORT TanhFunction : public UnaryFunction { public: - ~TanhFunction(); - void operate(std::vector& stck) const; - void operateX86(std::vector& asmb) const; - void operateStackOfDouble(std::vector& stck) const; - const char *getRepr() const; - bool isACall() const; - TanhFunction *deepCopy() const { return new TanhFunction; } + ~TanhFunction() override; + void operate(std::vector& stck) const override; + void operateX86(std::vector& asmb) const override; + void operateStackOfDouble(std::vector& stck) const override; + const char *getRepr() const override; + bool isACall() const override; + TanhFunction *deepCopy() const override { return new TanhFunction; } public: static const char REPR[]; }; @@ -235,14 +235,14 @@ namespace INTERP_KERNEL class INTERPKERNEL_EXPORT SqrtFunction : public UnaryFunction { public: - ~SqrtFunction(); - void operateX86(std::vector& asmb) const; - void operate(std::vector& stck) const; - void operateStackOfDouble(std::vector& stck) const; - void operateStackOfDoubleSafe(std::vector& stck) const; - const char *getRepr() const; - bool isACall() const; - SqrtFunction *deepCopy() const { return new SqrtFunction; } + ~SqrtFunction() override; + void operateX86(std::vector& asmb) const override; + void operate(std::vector& stck) const override; + void operateStackOfDouble(std::vector& stck) const override; + void operateStackOfDoubleSafe(std::vector& stck) const override; + const char *getRepr() const override; + bool isACall() const override; + SqrtFunction *deepCopy() const override { return new SqrtFunction; } public: static const char REPR[]; }; @@ -250,13 +250,13 @@ namespace INTERP_KERNEL class INTERPKERNEL_EXPORT AbsFunction : public UnaryFunction { public: - ~AbsFunction(); - void operate(std::vector& stck) const; - void operateX86(std::vector& asmb) const; - void operateStackOfDouble(std::vector& stck) const; - const char *getRepr() const; - bool isACall() const; - AbsFunction *deepCopy() const { return new AbsFunction; } + ~AbsFunction() override; + void operate(std::vector& stck) const override; + void operateX86(std::vector& asmb) const override; + void operateStackOfDouble(std::vector& stck) const override; + const char *getRepr() const override; + bool isACall() const override; + AbsFunction *deepCopy() const override { return new AbsFunction; } public: static const char REPR[]; }; @@ -264,13 +264,13 @@ namespace INTERP_KERNEL class INTERPKERNEL_EXPORT ExpFunction : public UnaryFunction { public: - ~ExpFunction(); - void operate(std::vector& stck) const; - void operateX86(std::vector& asmb) const; - void operateStackOfDouble(std::vector& stck) const; - const char *getRepr() const; - bool isACall() const; - ExpFunction *deepCopy() const { return new ExpFunction; } + ~ExpFunction() override; + void operate(std::vector& stck) const override; + void operateX86(std::vector& asmb) const override; + void operateStackOfDouble(std::vector& stck) const override; + const char *getRepr() const override; + bool isACall() const override; + ExpFunction *deepCopy() const override { return new ExpFunction; } public: static const char REPR[]; }; @@ -278,14 +278,14 @@ namespace INTERP_KERNEL class INTERPKERNEL_EXPORT LnFunction : public UnaryFunction { public: - ~LnFunction(); - void operate(std::vector& stck) const; - void operateX86(std::vector& asmb) const; - void operateStackOfDouble(std::vector& stck) const; - void operateStackOfDoubleSafe(std::vector& stck) const; - const char *getRepr() const; - bool isACall() const; - LnFunction *deepCopy() const { return new LnFunction; } + ~LnFunction() override; + void operate(std::vector& stck) const override; + void operateX86(std::vector& asmb) const override; + void operateStackOfDouble(std::vector& stck) const override; + void operateStackOfDoubleSafe(std::vector& stck) const override; + const char *getRepr() const override; + bool isACall() const override; + LnFunction *deepCopy() const override { return new LnFunction; } public: static const char REPR[]; }; @@ -293,14 +293,14 @@ namespace INTERP_KERNEL class INTERPKERNEL_EXPORT LogFunction : public UnaryFunction { public: - ~LogFunction(); - void operate(std::vector& stck) const; - void operateX86(std::vector& asmb) const; - void operateStackOfDouble(std::vector& stck) const; - void operateStackOfDoubleSafe(std::vector& stck) const; - const char *getRepr() const; - bool isACall() const; - LogFunction *deepCopy() const { return new LogFunction; } + ~LogFunction() override; + void operate(std::vector& stck) const override; + void operateX86(std::vector& asmb) const override; + void operateStackOfDouble(std::vector& stck) const override; + void operateStackOfDoubleSafe(std::vector& stck) const override; + const char *getRepr() const override; + bool isACall() const override; + LogFunction *deepCopy() const override { return new LogFunction; } public: static const char REPR[]; }; @@ -308,14 +308,14 @@ namespace INTERP_KERNEL class INTERPKERNEL_EXPORT Log10Function : public UnaryFunction { public: - ~Log10Function(); - void operate(std::vector& stck) const; - void operateX86(std::vector& asmb) const; - void operateStackOfDouble(std::vector& stck) const; - void operateStackOfDoubleSafe(std::vector& stck) const; - const char *getRepr() const; - bool isACall() const; - Log10Function *deepCopy() const { return new Log10Function; } + ~Log10Function() override; + void operate(std::vector& stck) const override; + void operateX86(std::vector& asmb) const override; + void operateStackOfDouble(std::vector& stck) const override; + void operateStackOfDoubleSafe(std::vector& stck) const override; + const char *getRepr() const override; + bool isACall() const override; + Log10Function *deepCopy() const override { return new Log10Function; } public: static const char REPR[]; }; @@ -323,19 +323,19 @@ namespace INTERP_KERNEL class INTERPKERNEL_EXPORT BinaryFunction : public Function { public: - int getNbInputParams() const; + int getNbInputParams() const override; }; class PlusFunction : public BinaryFunction { public: - ~PlusFunction(); - void operate(std::vector& stck) const; - void operateX86(std::vector& asmb) const; - void operateStackOfDouble(std::vector& stck) const; - const char *getRepr() const; - bool isACall() const; - PlusFunction *deepCopy() const { return new PlusFunction; } + ~PlusFunction() override; + void operate(std::vector& stck) const override; + void operateX86(std::vector& asmb) const override; + void operateStackOfDouble(std::vector& stck) const override; + const char *getRepr() const override; + bool isACall() const override; + PlusFunction *deepCopy() const override { return new PlusFunction; } public: static const char REPR[]; }; @@ -343,13 +343,13 @@ namespace INTERP_KERNEL class INTERPKERNEL_EXPORT MinusFunction : public BinaryFunction { public: - ~MinusFunction(); - void operate(std::vector& stck) const; - void operateX86(std::vector& asmb) const; - void operateStackOfDouble(std::vector& stck) const; - const char *getRepr() const; - bool isACall() const; - MinusFunction *deepCopy() const { return new MinusFunction; } + ~MinusFunction() override; + void operate(std::vector& stck) const override; + void operateX86(std::vector& asmb) const override; + void operateStackOfDouble(std::vector& stck) const override; + const char *getRepr() const override; + bool isACall() const override; + MinusFunction *deepCopy() const override { return new MinusFunction; } public: static const char REPR[]; }; @@ -357,13 +357,13 @@ namespace INTERP_KERNEL class INTERPKERNEL_EXPORT MultFunction : public BinaryFunction { public: - ~MultFunction(); - void operate(std::vector& stck) const; - void operateX86(std::vector& asmb) const; - void operateStackOfDouble(std::vector& stck) const; - const char *getRepr() const; - bool isACall() const; - MultFunction *deepCopy() const { return new MultFunction; } + ~MultFunction() override; + void operate(std::vector& stck) const override; + void operateX86(std::vector& asmb) const override; + void operateStackOfDouble(std::vector& stck) const override; + const char *getRepr() const override; + bool isACall() const override; + MultFunction *deepCopy() const override { return new MultFunction; } public: static const char REPR[]; }; @@ -371,14 +371,14 @@ namespace INTERP_KERNEL class INTERPKERNEL_EXPORT DivFunction : public BinaryFunction { public: - ~DivFunction(); - void operate(std::vector& stck) const; - void operateX86(std::vector& asmb) const; - void operateStackOfDouble(std::vector& stck) const; - void operateStackOfDoubleSafe(std::vector& stck) const; - const char *getRepr() const; - bool isACall() const; - DivFunction *deepCopy() const { return new DivFunction; } + ~DivFunction() override; + void operate(std::vector& stck) const override; + void operateX86(std::vector& asmb) const override; + void operateStackOfDouble(std::vector& stck) const override; + void operateStackOfDoubleSafe(std::vector& stck) const override; + const char *getRepr() const override; + bool isACall() const override; + DivFunction *deepCopy() const override { return new DivFunction; } public: static const char REPR[]; }; @@ -386,14 +386,14 @@ namespace INTERP_KERNEL class INTERPKERNEL_EXPORT PowFunction : public BinaryFunction { public: - ~PowFunction(); - void operate(std::vector& stck) const; - void operateX86(std::vector& asmb) const; - void operateStackOfDouble(std::vector& stck) const; - void operateStackOfDoubleSafe(std::vector& stck) const; - const char *getRepr() const; - bool isACall() const; - PowFunction *deepCopy() const { return new PowFunction; } + ~PowFunction() override; + void operate(std::vector& stck) const override; + void operateX86(std::vector& asmb) const override; + void operateStackOfDouble(std::vector& stck) const override; + void operateStackOfDoubleSafe(std::vector& stck) const override; + const char *getRepr() const override; + bool isACall() const override; + PowFunction *deepCopy() const override { return new PowFunction; } public: static const char REPR[]; }; @@ -401,13 +401,13 @@ namespace INTERP_KERNEL class INTERPKERNEL_EXPORT MaxFunction : public BinaryFunction { public: - ~MaxFunction(); - void operate(std::vector& stck) const; - void operateX86(std::vector& asmb) const; - void operateStackOfDouble(std::vector& stck) const; - const char *getRepr() const; - bool isACall() const; - MaxFunction *deepCopy() const { return new MaxFunction; } + ~MaxFunction() override; + void operate(std::vector& stck) const override; + void operateX86(std::vector& asmb) const override; + void operateStackOfDouble(std::vector& stck) const override; + const char *getRepr() const override; + bool isACall() const override; + MaxFunction *deepCopy() const override { return new MaxFunction; } public: static const char REPR[]; }; @@ -415,13 +415,13 @@ namespace INTERP_KERNEL class INTERPKERNEL_EXPORT MinFunction : public BinaryFunction { public: - ~MinFunction(); - void operate(std::vector& stck) const; - void operateX86(std::vector& asmb) const; - void operateStackOfDouble(std::vector& stck) const; - const char *getRepr() const; - bool isACall() const; - MinFunction *deepCopy() const { return new MinFunction; } + ~MinFunction() override; + void operate(std::vector& stck) const override; + void operateX86(std::vector& asmb) const override; + void operateStackOfDouble(std::vector& stck) const override; + const char *getRepr() const override; + bool isACall() const override; + MinFunction *deepCopy() const override { return new MinFunction; } public: static const char REPR[]; }; @@ -429,13 +429,13 @@ namespace INTERP_KERNEL class INTERPKERNEL_EXPORT GreaterThanFunction : public BinaryFunction { public: - ~GreaterThanFunction(); - void operate(std::vector& stck) const; - void operateX86(std::vector& asmb) const; - void operateStackOfDouble(std::vector& stck) const; - const char *getRepr() const; - bool isACall() const; - GreaterThanFunction *deepCopy() const { return new GreaterThanFunction; } + ~GreaterThanFunction() override; + void operate(std::vector& stck) const override; + void operateX86(std::vector& asmb) const override; + void operateStackOfDouble(std::vector& stck) const override; + const char *getRepr() const override; + bool isACall() const override; + GreaterThanFunction *deepCopy() const override { return new GreaterThanFunction; } public: static const char REPR[]; }; @@ -443,13 +443,13 @@ namespace INTERP_KERNEL class INTERPKERNEL_EXPORT LowerThanFunction : public BinaryFunction { public: - ~LowerThanFunction(); - void operate(std::vector& stck) const; - void operateX86(std::vector& asmb) const; - void operateStackOfDouble(std::vector& stck) const; - const char *getRepr() const; - bool isACall() const; - LowerThanFunction *deepCopy() const { return new LowerThanFunction; } + ~LowerThanFunction() override; + void operate(std::vector& stck) const override; + void operateX86(std::vector& asmb) const override; + void operateStackOfDouble(std::vector& stck) const override; + const char *getRepr() const override; + bool isACall() const override; + LowerThanFunction *deepCopy() const override { return new LowerThanFunction; } public: static const char REPR[]; }; @@ -457,20 +457,20 @@ namespace INTERP_KERNEL class INTERPKERNEL_EXPORT TernaryFunction : public Function { public: - int getNbInputParams() const; + int getNbInputParams() const override; }; class INTERPKERNEL_EXPORT IfFunction : public TernaryFunction { public: - ~IfFunction(); - void operate(std::vector& stck) const; - void operateX86(std::vector& asmb) const; - void operateStackOfDouble(std::vector& stck) const; - void operateStackOfDoubleSafe(std::vector& stck) const; - const char *getRepr() const; - bool isACall() const; - IfFunction *deepCopy() const { return new IfFunction; } + ~IfFunction() override; + void operate(std::vector& stck) const override; + void operateX86(std::vector& asmb) const override; + void operateStackOfDouble(std::vector& stck) const override; + void operateStackOfDoubleSafe(std::vector& stck) const override; + const char *getRepr() const override; + bool isACall() const override; + IfFunction *deepCopy() const override { return new IfFunction; } public: static const char REPR[]; }; diff --git a/src/INTERP_KERNEL/ExprEval/InterpKernelUnit.cxx b/src/INTERP_KERNEL/ExprEval/InterpKernelUnit.cxx index f02596139..b337123bb 100644 --- a/src/INTERP_KERNEL/ExprEval/InterpKernelUnit.cxx +++ b/src/INTERP_KERNEL/ExprEval/InterpKernelUnit.cxx @@ -20,18 +20,22 @@ #include "InterpKernelUnit.hxx" #include "InterpKernelExprParser.hxx" +#include "InterpKernelException.hxx" #include #include +#include +#include #include #include #include +#include using namespace INTERP_KERNEL; const UnitDataBase& UnitDataBase::GetUniqueMapForExpr() { - static UnitDataBase db; + static UnitDataBase const db; return db; } @@ -112,19 +116,19 @@ UnitDataBase::UnitDataBase() const short *UnitDataBase::getInfoForUnit(const std::string& unit, double& addFact, double& mFact) const { - std::size_t lgth=unit.length(); + std::size_t const lgth=unit.length(); std::string work,work2; - const short *ret=0; + const short *ret=nullptr; for(std::size_t i=0;i::const_iterator iter=_units_semantic.find(work); + auto const iter=_units_semantic.find(work); if(iter!=_units_semantic.end()) { ret=(*iter).second; - std::map::const_iterator iter2=_units_add.find(work); + auto const iter2=_units_add.find(work); addFact=(*iter2).second; - std::map::const_iterator iter3=_units_mul.find(work); + auto const iter3=_units_mul.find(work); mFact=(*iter3).second; work2=unit.substr(0,i); } @@ -137,7 +141,7 @@ const short *UnitDataBase::getInfoForUnit(const std::string& unit, double& addFa } if(!work2.empty()) { - std::map::const_iterator iter4=_prefix_pow_10.find(work2); + auto const iter4=_prefix_pow_10.find(work2); if(iter4==_prefix_pow_10.end()) { std::ostringstream os; @@ -192,13 +196,13 @@ void DecompositionInUnitBase::getTranslationParams(const DecompositionInUnitBase bool DecompositionInUnitBase::isEqual(short mass, short lgth, short time, short intensity, short temp, double add, double mult) { - bool ret1=mass==_value[0]; - bool ret2=lgth==_value[1]; - bool ret3=time==_value[2]; - bool ret4=intensity==_value[3]; - bool ret5=temp==_value[4]; - bool ret6=areDoubleEquals(add,_add_to_base); - bool ret7=areDoubleEquals(mult,_mult_fact_to_base); + bool const ret1=mass==_value[0]; + bool const ret2=lgth==_value[1]; + bool const ret3=time==_value[2]; + bool const ret4=intensity==_value[3]; + bool const ret5=temp==_value[4]; + bool const ret6=areDoubleEquals(add,_add_to_base); + bool const ret7=areDoubleEquals(mult,_mult_fact_to_base); return ret1 && ret2 && ret3 && ret4 && ret5 && ret6 && ret7; } @@ -219,7 +223,7 @@ bool DecompositionInUnitBase::isUnitary() const void DecompositionInUnitBase::tryToConvertInUnit(double val) { - int valI=(int)val; + int const valI=(int)val; if((val-(double)valI)!=0.) { std::ostringstream os; @@ -257,7 +261,7 @@ DecompositionInUnitBase &DecompositionInUnitBase::operator^(const DecompositionI { if(!other.isAdimensional()) throw INTERP_KERNEL::Exception("Trying to execute operator ^ with a second member not adimensionnal"); - int exp=couldItBeConsideredAsInt(other._mult_fact_to_base); + int const exp=couldItBeConsideredAsInt(other._mult_fact_to_base); // *= causes ' conversion to 'short int' from 'int' may alter its value [-Wconversion]' _value[0]=(short)(_value[0]*exp); _value[1]=(short)(_value[1]*exp); _value[2]=(short)(_value[2]*exp); _value[3]=(short)(_value[3]*exp); _value[4]=(short)(_value[4]*exp); _mult_fact_to_base=powInt(_mult_fact_to_base,exp); @@ -288,7 +292,7 @@ double DecompositionInUnitBase::powInt(double val, int exp) work*=val; else { - int tmp=-exp; + int const tmp=-exp; for(int i=0;i -#include +#include namespace INTERP_KERNEL { diff --git a/src/INTERP_KERNEL/ExprEval/InterpKernelValue.cxx b/src/INTERP_KERNEL/ExprEval/InterpKernelValue.cxx index 9c6b83ab0..15f542d98 100644 --- a/src/INTERP_KERNEL/ExprEval/InterpKernelValue.cxx +++ b/src/INTERP_KERNEL/ExprEval/InterpKernelValue.cxx @@ -20,11 +20,14 @@ #include "InterpKernelValue.hxx" #include "InterpKernelFunction.hxx" +#include "InterpKernelUnit.hxx" +#include "InterpKernelException.hxx" #include #include #include #include +#include using namespace INTERP_KERNEL; @@ -46,7 +49,7 @@ void ValueDouble::setDouble(double val) _data=val; } -void ValueDouble::setVarname(int fastPos, const std::string& var) +void ValueDouble::setVarname(int /*fastPos*/, const std::string& var) { std::string msg("Error var : "); msg+=var; msg+=" not numeric : use another expression evaluator !"; throw INTERP_KERNEL::Exception(msg.c_str()); @@ -199,15 +202,14 @@ Value *ValueDouble::ifFunc(const Value *the, const Value *els) const const ValueDouble *ValueDouble::checkSameType(const Value *val) { - const ValueDouble *valC=dynamic_cast(val); + const auto *valC=dynamic_cast(val); if(!valC) throw INTERP_KERNEL::Exception("Trying to operate on non homogeneous Values (double with other type) !"); return valC; } ValueUnit::ValueUnit() -{ -} += default; Value *ValueUnit::newInstance() const { @@ -223,7 +225,7 @@ void ValueUnit::setDouble(double val) _data.tryToConvertInUnit(val); } -void ValueUnit::setVarname(int fastPos, const std::string& var) +void ValueUnit::setVarname(int /*fastPos*/, const std::string& var) { double add,mul; const short *projInBase=UnitDataBase::GetUniqueMapForExpr().getInfoForUnit(var,add,mul); @@ -310,34 +312,34 @@ void ValueUnit::log10() unsupportedOp(Log10Function::REPR); } -Value *ValueUnit::plus(const Value *other) const +Value *ValueUnit::plus(const Value * /*other*/) const { unsupportedOp(PlusFunction::REPR); - return 0; + return nullptr; } -Value *ValueUnit::minus(const Value *other) const +Value *ValueUnit::minus(const Value * /*other*/) const { unsupportedOp(MinusFunction::REPR); - return 0; + return nullptr; } -Value *ValueUnit::greaterThan(const Value *other) const +Value *ValueUnit::greaterThan(const Value * /*other*/) const { unsupportedOp(GreaterThanFunction::REPR); - return 0; + return nullptr; } -Value *ValueUnit::lowerThan(const Value *other) const +Value *ValueUnit::lowerThan(const Value * /*other*/) const { unsupportedOp(LowerThanFunction::REPR); - return 0; + return nullptr; } -Value *ValueUnit::ifFunc(const Value *the, const Value *els) const +Value *ValueUnit::ifFunc(const Value * /*the*/, const Value * /*els*/) const { unsupportedOp(IfFunction::REPR); - return 0; + return nullptr; } Value *ValueUnit::mult(const Value *other) const @@ -364,21 +366,21 @@ Value *ValueUnit::pow(const Value *other) const return new ValueUnit(tmp); } -Value *ValueUnit::max(const Value *other) const +Value *ValueUnit::max(const Value * /*other*/) const { unsupportedOp(MaxFunction::REPR); - return 0; + return nullptr; } -Value *ValueUnit::min(const Value *other) const +Value *ValueUnit::min(const Value * /*other*/) const { unsupportedOp(MinFunction::REPR); - return 0; + return nullptr; } const ValueUnit *ValueUnit::checkSameType(const Value *val) { - const ValueUnit *valC=dynamic_cast(val); + const auto *valC=dynamic_cast(val); if(!valC) throw INTERP_KERNEL::Exception("Trying to operate on non homogeneous Values (Units with other type) !"); return valC; @@ -411,7 +413,7 @@ void ValueDoubleExpr::setDouble(double val) std::fill(_dest_data,_dest_data+_sz_dest_data,val); } -void ValueDoubleExpr::setVarname(int fastPos, const std::string& var) +void ValueDoubleExpr::setVarname(int fastPos, const std::string& /*var*/) { if(fastPos==-2) std::copy(_src_data,_src_data+_sz_dest_data,_dest_data); @@ -526,71 +528,71 @@ void ValueDoubleExpr::log10() Value *ValueDoubleExpr::plus(const Value *other) const { - const ValueDoubleExpr *otherC=static_cast(other); - ValueDoubleExpr *ret=new ValueDoubleExpr(_sz_dest_data,_src_data); + const auto *otherC=static_cast(other); + auto *ret=new ValueDoubleExpr(_sz_dest_data,_src_data); std::transform(_dest_data,_dest_data+_sz_dest_data,otherC->getData(),ret->getData(),std::plus()); return ret; } Value *ValueDoubleExpr::minus(const Value *other) const { - const ValueDoubleExpr *otherC=static_cast(other); - ValueDoubleExpr *ret=new ValueDoubleExpr(_sz_dest_data,_src_data); + const auto *otherC=static_cast(other); + auto *ret=new ValueDoubleExpr(_sz_dest_data,_src_data); std::transform(_dest_data,_dest_data+_sz_dest_data,otherC->getData(),ret->getData(),std::minus()); return ret; } Value *ValueDoubleExpr::mult(const Value *other) const { - const ValueDoubleExpr *otherC=static_cast(other); - ValueDoubleExpr *ret=new ValueDoubleExpr(_sz_dest_data,_src_data); + const auto *otherC=static_cast(other); + auto *ret=new ValueDoubleExpr(_sz_dest_data,_src_data); std::transform(_dest_data,_dest_data+_sz_dest_data,otherC->getData(),ret->getData(),std::multiplies()); return ret; } Value *ValueDoubleExpr::div(const Value *other) const { - const ValueDoubleExpr *otherC=static_cast(other); + const auto *otherC=static_cast(other); double *it=std::find(otherC->getData(),otherC->getData()+_sz_dest_data,0.); if(it!=otherC->getData()+_sz_dest_data) throw INTERP_KERNEL::Exception("Trying to operate division by 0. !"); - ValueDoubleExpr *ret=new ValueDoubleExpr(_sz_dest_data,_src_data); + auto *ret=new ValueDoubleExpr(_sz_dest_data,_src_data); std::transform(_dest_data,_dest_data+_sz_dest_data,otherC->getData(),ret->getData(),std::divides()); return ret; } Value *ValueDoubleExpr::pow(const Value *other) const { - const ValueDoubleExpr *otherC=static_cast(other); - double p=otherC->getData()[0]; + const auto *otherC=static_cast(other); + double const p=otherC->getData()[0]; double *it=std::find_if(_dest_data,_dest_data+_sz_dest_data,std::bind(std::less(),std::placeholders::_1,0.)); if(it!=_dest_data+_sz_dest_data) throw INTERP_KERNEL::Exception("Trying to operate pow(a,b) with a<0. !"); - ValueDoubleExpr *ret=new ValueDoubleExpr(_sz_dest_data,_src_data); + auto *ret=new ValueDoubleExpr(_sz_dest_data,_src_data); std::transform(_dest_data,_dest_data+_sz_dest_data,ret->getData(),std::bind([](double x, double y){return std::pow(x,y);},std::placeholders::_1,p)); return ret; } Value *ValueDoubleExpr::max(const Value *other) const { - const ValueDoubleExpr *otherC=static_cast(other); - ValueDoubleExpr *ret=new ValueDoubleExpr(_sz_dest_data,_src_data); + const auto *otherC=static_cast(other); + auto *ret=new ValueDoubleExpr(_sz_dest_data,_src_data); std::transform(_dest_data,_dest_data+_sz_dest_data,otherC->getData(),ret->getData(),[](const double& x, const double& y){return std::max(x,y);}); return ret; } Value *ValueDoubleExpr::min(const Value *other) const { - const ValueDoubleExpr *otherC=static_cast(other); - ValueDoubleExpr *ret=new ValueDoubleExpr(_sz_dest_data,_src_data); + const auto *otherC=static_cast(other); + auto *ret=new ValueDoubleExpr(_sz_dest_data,_src_data); std::transform(_dest_data,_dest_data+_sz_dest_data,otherC->getData(),ret->getData(),[](const double& x, const double& y){return std::min(x,y);}); return ret; } Value *ValueDoubleExpr::greaterThan(const Value *other) const { - const ValueDoubleExpr *otherC=static_cast(other); - ValueDoubleExpr *ret=new ValueDoubleExpr(_sz_dest_data,_src_data); + const auto *otherC=static_cast(other); + auto *ret=new ValueDoubleExpr(_sz_dest_data,_src_data); for(int i=0;i<_sz_dest_data;i++) if(_dest_data[i]<=otherC->getData()[i]) { @@ -603,8 +605,8 @@ Value *ValueDoubleExpr::greaterThan(const Value *other) const Value *ValueDoubleExpr::lowerThan(const Value *other) const { - const ValueDoubleExpr *otherC=static_cast(other); - ValueDoubleExpr *ret=new ValueDoubleExpr(_sz_dest_data,_src_data); + const auto *otherC=static_cast(other); + auto *ret=new ValueDoubleExpr(_sz_dest_data,_src_data); for(int i=0;i<_sz_dest_data;i++) if(_dest_data[i]>=otherC->getData()[i]) { @@ -617,9 +619,9 @@ Value *ValueDoubleExpr::lowerThan(const Value *other) const Value *ValueDoubleExpr::ifFunc(const Value *the, const Value *els) const { - const ValueDoubleExpr *theC=static_cast(the); - const ValueDoubleExpr *elsC=static_cast(els); - ValueDoubleExpr *ret=new ValueDoubleExpr(_sz_dest_data,_src_data); + const auto *theC=static_cast(the); + const auto *elsC=static_cast(els); + auto *ret=new ValueDoubleExpr(_sz_dest_data,_src_data); bool okmax=true; bool okmin=true; for(int i=0;i<_sz_dest_data && (okmax || okmin);i++) diff --git a/src/INTERP_KERNEL/ExprEval/InterpKernelValue.hxx b/src/INTERP_KERNEL/ExprEval/InterpKernelValue.hxx index e0b80ff65..5b69033f6 100644 --- a/src/INTERP_KERNEL/ExprEval/InterpKernelValue.hxx +++ b/src/INTERP_KERNEL/ExprEval/InterpKernelValue.hxx @@ -22,8 +22,8 @@ #define __INTERPKERNELVALUE_HXX__ #include "INTERPKERNELDefines.hxx" -#include "InterpKernelException.hxx" #include "InterpKernelUnit.hxx" +#include namespace INTERP_KERNEL { @@ -31,7 +31,7 @@ namespace INTERP_KERNEL { public: virtual Value *newInstance() const = 0; - virtual ~Value() { } + virtual ~Value() = default; virtual void setDouble(double val) = 0; virtual void setVarname(int fastPos, const std::string& var) = 0; //unary @@ -69,39 +69,39 @@ namespace INTERP_KERNEL { public: ValueDouble(); - Value *newInstance() const; - void setDouble(double val); - void setVarname(int fastPos, const std::string& var); + Value *newInstance() const override; + void setDouble(double val) override; + void setVarname(int fastPos, const std::string& var) override; // double getData() const { return _data; } - void positive(); - void negate(); - void sqrt(); - void cos(); - void sin(); - void tan(); - void acos(); - void asin(); - void atan(); - void cosh(); - void sinh(); - void tanh(); - void abs(); - void exp(); - void ln(); - void log10(); + void positive() override; + void negate() override; + void sqrt() override; + void cos() override; + void sin() override; + void tan() override; + void acos() override; + void asin() override; + void atan() override; + void cosh() override; + void sinh() override; + void tanh() override; + void abs() override; + void exp() override; + void ln() override; + void log10() override; // - Value *plus(const Value *other) const; - Value *minus(const Value *other) const; - Value *mult(const Value *other) const; - Value *div(const Value *other) const; - Value *pow(const Value *other) const; - Value *max(const Value *other) const; - Value *min(const Value *other) const; - Value *greaterThan(const Value *other) const; - Value *lowerThan(const Value *other) const; + Value *plus(const Value *other) const override; + Value *minus(const Value *other) const override; + Value *mult(const Value *other) const override; + Value *div(const Value *other) const override; + Value *pow(const Value *other) const override; + Value *max(const Value *other) const override; + Value *min(const Value *other) const override; + Value *greaterThan(const Value *other) const override; + Value *lowerThan(const Value *other) const override; // - Value *ifFunc(const Value *the, const Value *els) const; + Value *ifFunc(const Value *the, const Value *els) const override; private: ValueDouble(double val); static const ValueDouble *checkSameType(const Value *val); @@ -113,39 +113,39 @@ namespace INTERP_KERNEL { public: INTERPKERNEL_EXPORT ValueUnit(); - INTERPKERNEL_EXPORT Value *newInstance() const; - INTERPKERNEL_EXPORT void setDouble(double val); - INTERPKERNEL_EXPORT void setVarname(int fastPos, const std::string& var); + INTERPKERNEL_EXPORT Value *newInstance() const override; + INTERPKERNEL_EXPORT void setDouble(double val) override; + INTERPKERNEL_EXPORT void setVarname(int fastPos, const std::string& var) override; // INTERPKERNEL_EXPORT DecompositionInUnitBase getData() const { return _data; } - INTERPKERNEL_EXPORT void positive(); - INTERPKERNEL_EXPORT void negate(); - INTERPKERNEL_EXPORT void sqrt(); - INTERPKERNEL_EXPORT void cos(); - INTERPKERNEL_EXPORT void sin(); - INTERPKERNEL_EXPORT void tan(); - INTERPKERNEL_EXPORT void acos(); - INTERPKERNEL_EXPORT void asin(); - INTERPKERNEL_EXPORT void atan(); - INTERPKERNEL_EXPORT void cosh(); - INTERPKERNEL_EXPORT void sinh(); - INTERPKERNEL_EXPORT void tanh(); - INTERPKERNEL_EXPORT void abs(); - INTERPKERNEL_EXPORT void exp(); - INTERPKERNEL_EXPORT void ln(); - INTERPKERNEL_EXPORT void log10(); + INTERPKERNEL_EXPORT void positive() override; + INTERPKERNEL_EXPORT void negate() override; + INTERPKERNEL_EXPORT void sqrt() override; + INTERPKERNEL_EXPORT void cos() override; + INTERPKERNEL_EXPORT void sin() override; + INTERPKERNEL_EXPORT void tan() override; + INTERPKERNEL_EXPORT void acos() override; + INTERPKERNEL_EXPORT void asin() override; + INTERPKERNEL_EXPORT void atan() override; + INTERPKERNEL_EXPORT void cosh() override; + INTERPKERNEL_EXPORT void sinh() override; + INTERPKERNEL_EXPORT void tanh() override; + INTERPKERNEL_EXPORT void abs() override; + INTERPKERNEL_EXPORT void exp() override; + INTERPKERNEL_EXPORT void ln() override; + INTERPKERNEL_EXPORT void log10() override; // - INTERPKERNEL_EXPORT Value *plus(const Value *other) const; - INTERPKERNEL_EXPORT Value *minus(const Value *other) const; - INTERPKERNEL_EXPORT Value *mult(const Value *other) const; - INTERPKERNEL_EXPORT Value *div(const Value *other) const; - INTERPKERNEL_EXPORT Value *pow(const Value *other) const; - INTERPKERNEL_EXPORT Value *max(const Value *other) const; - INTERPKERNEL_EXPORT Value *min(const Value *other) const; - INTERPKERNEL_EXPORT Value *greaterThan(const Value *other) const; - INTERPKERNEL_EXPORT Value *lowerThan(const Value *other) const; + INTERPKERNEL_EXPORT Value *plus(const Value *other) const override; + INTERPKERNEL_EXPORT Value *minus(const Value *other) const override; + INTERPKERNEL_EXPORT Value *mult(const Value *other) const override; + INTERPKERNEL_EXPORT Value *div(const Value *other) const override; + INTERPKERNEL_EXPORT Value *pow(const Value *other) const override; + INTERPKERNEL_EXPORT Value *max(const Value *other) const override; + INTERPKERNEL_EXPORT Value *min(const Value *other) const override; + INTERPKERNEL_EXPORT Value *greaterThan(const Value *other) const override; + INTERPKERNEL_EXPORT Value *lowerThan(const Value *other) const override; // - INTERPKERNEL_EXPORT Value *ifFunc(const Value *the, const Value *els) const; + INTERPKERNEL_EXPORT Value *ifFunc(const Value *the, const Value *els) const override; private: ValueUnit(const DecompositionInUnitBase& unit); static void unsupportedOp(const char *type); @@ -158,40 +158,40 @@ namespace INTERP_KERNEL { public: ValueDoubleExpr(int szDestData, const double *srcData); - ~ValueDoubleExpr(); + ~ValueDoubleExpr() override; double *getData() const { return _dest_data; } - Value *newInstance() const; - void setDouble(double val); - void setVarname(int fastPos, const std::string& var); + Value *newInstance() const override; + void setDouble(double val) override; + void setVarname(int fastPos, const std::string& var) override; // - void positive(); - void negate(); - void sqrt(); - void cos(); - void sin(); - void tan(); - void acos(); - void asin(); - void atan(); - void cosh(); - void sinh(); - void tanh(); - void abs(); - void exp(); - void ln(); - void log10(); + void positive() override; + void negate() override; + void sqrt() override; + void cos() override; + void sin() override; + void tan() override; + void acos() override; + void asin() override; + void atan() override; + void cosh() override; + void sinh() override; + void tanh() override; + void abs() override; + void exp() override; + void ln() override; + void log10() override; // - Value *plus(const Value *other) const; - Value *minus(const Value *other) const; - Value *mult(const Value *other) const; - Value *div(const Value *other) const; - Value *pow(const Value *other) const; - Value *max(const Value *other) const; - Value *min(const Value *other) const; - Value *greaterThan(const Value *other) const; - Value *lowerThan(const Value *other) const; + Value *plus(const Value *other) const override; + Value *minus(const Value *other) const override; + Value *mult(const Value *other) const override; + Value *div(const Value *other) const override; + Value *pow(const Value *other) const override; + Value *max(const Value *other) const override; + Value *min(const Value *other) const override; + Value *greaterThan(const Value *other) const override; + Value *lowerThan(const Value *other) const override; // - Value *ifFunc(const Value *the, const Value *els) const; + Value *ifFunc(const Value *the, const Value *els) const override; private: int _sz_dest_data; double *_dest_data; diff --git a/src/INTERP_KERNEL/GaussPoints/InterpKernelGaussCoords.cxx b/src/INTERP_KERNEL/GaussPoints/InterpKernelGaussCoords.cxx index fe06a52bd..fccd67bfa 100644 --- a/src/INTERP_KERNEL/GaussPoints/InterpKernelGaussCoords.cxx +++ b/src/INTERP_KERNEL/GaussPoints/InterpKernelGaussCoords.cxx @@ -20,12 +20,17 @@ //Local includes #include "InterpKernelGaussCoords.hxx" #include "CellModel.hxx" +#include "NormalizedGeometricTypes" +#include "InterpKernelException.hxx" +#include "MCIdType.hxx" //STL includes +#include #include #include #include #include +#include using namespace INTERP_KERNEL; @@ -144,7 +149,7 @@ const double GaussInfo::HEXA27A_REF[81]={-1.0, -1.0, -1.0, -1.0, 1.0, -1.0, 1.0, //--------------------------------------------------------------- static bool IsEqual(double theLeft, double theRight) { - static double EPS = 1.0E-3; + static double const EPS = 1.0E-3; if(fabs(theLeft) + fabs(theRight) > EPS) return fabs(theLeft-theRight)/(fabs(theLeft)+fabs(theRight)) < EPS; return true; @@ -178,8 +183,7 @@ GaussInfo::GaussInfo( NormalizedCellType theGeometry, * Destructor */ GaussInfo::~GaussInfo() -{ -} += default; /*! * Return dimension of the gauss coordinates @@ -241,10 +245,10 @@ GaussInfo GaussInfo::convertToLinear() const { case NORM_SEG3: { - std::vector a(SEG3_REF,SEG3_REF+3); + std::vector const a(SEG3_REF,SEG3_REF+3); if(IsSatisfy(a,_my_reference_coord)) { - std::vector c(SEG2A_REF,SEG2A_REF+2); + std::vector const c(SEG2A_REF,SEG2A_REF+2); return GaussInfo(NORM_SEG2,_my_gauss_coord,getNbGauss(),c,2); } throw INTERP_KERNEL::Exception("GaussInfo::convertToLinear : not recognized pattern for SEG3 !"); @@ -254,22 +258,22 @@ GaussInfo GaussInfo::convertToLinear() const std::vector a(TRIA6A_REF,TRIA6A_REF+12),b(TRIA6B_REF,TRIA6B_REF+12); if(IsSatisfy(a,_my_reference_coord)) { - std::vector c(TRIA3A_REF,TRIA3A_REF+6); + std::vector const c(TRIA3A_REF,TRIA3A_REF+6); return GaussInfo(NORM_TRI3,_my_gauss_coord,getNbGauss(),c,3); } if(IsSatisfy(b,_my_reference_coord)) { - std::vector c(TRIA3B_REF,TRIA3B_REF+6); + std::vector const c(TRIA3B_REF,TRIA3B_REF+6); return GaussInfo(NORM_TRI3,_my_gauss_coord,getNbGauss(),c,3); } throw INTERP_KERNEL::Exception("GaussInfo::convertToLinear : not recognized pattern for TRI6 !"); } case NORM_TRI7: { - std::vector a(TRIA7A_REF,TRIA7A_REF+14); + std::vector const a(TRIA7A_REF,TRIA7A_REF+14); if(IsSatisfy(a,_my_reference_coord)) { - std::vector c(TRIA3B_REF,TRIA3B_REF+6); + std::vector const c(TRIA3B_REF,TRIA3B_REF+6); return GaussInfo(NORM_TRI3,_my_gauss_coord,getNbGauss(),c,3); } throw INTERP_KERNEL::Exception("GaussInfo::convertToLinear : not recognized pattern for TRI7 !"); @@ -279,22 +283,22 @@ GaussInfo GaussInfo::convertToLinear() const std::vector a(QUAD8A_REF,QUAD8A_REF+16),b(QUAD8B_REF,QUAD8B_REF+16); if(IsSatisfy(a,_my_reference_coord)) { - std::vector c(QUAD4A_REF,QUAD4A_REF+8); + std::vector const c(QUAD4A_REF,QUAD4A_REF+8); return GaussInfo(NORM_QUAD4,_my_gauss_coord,getNbGauss(),c,4); } if(IsSatisfy(b,_my_reference_coord)) { - std::vector c(QUAD4B_REF,QUAD4B_REF+8); + std::vector const c(QUAD4B_REF,QUAD4B_REF+8); return GaussInfo(NORM_QUAD4,_my_gauss_coord,getNbGauss(),c,4); } throw INTERP_KERNEL::Exception("GaussInfo::convertToLinear : not recognized pattern for QUAD8 !"); } case NORM_QUAD9: { - std::vector a(QUAD9A_REF,QUAD9A_REF+18); + std::vector const a(QUAD9A_REF,QUAD9A_REF+18); if(IsSatisfy(a,_my_reference_coord)) { - std::vector c(QUAD4B_REF,QUAD4B_REF+8); + std::vector const c(QUAD4B_REF,QUAD4B_REF+8); return GaussInfo(NORM_QUAD4,_my_gauss_coord,getNbGauss(),c,4); } throw INTERP_KERNEL::Exception("GaussInfo::convertToLinear : not recognized pattern for QUAD9 !"); @@ -304,7 +308,7 @@ GaussInfo GaussInfo::convertToLinear() const std::vector a(TETRA10A_REF,TETRA10A_REF+30),b(TETRA10B_REF,TETRA10B_REF+30); if(IsSatisfy(a,_my_reference_coord)) { - std::vector c(TETRA4A_REF,TETRA4A_REF+12); + std::vector const c(TETRA4A_REF,TETRA4A_REF+12); return GaussInfo(NORM_TETRA4,_my_gauss_coord,getNbGauss(),c,4); } if(IsSatisfy(b,_my_reference_coord)) @@ -407,7 +411,7 @@ bool GaussInfo::IsSatisfy(const std::vector& ref1, const std::vector GaussInfo::NormalizeCoordinatesIfNecessary(NormalizedCellTyp if(sz%dim!=0) throw INTERP_KERNEL::Exception("GaussInfo::NormalizeCoordinatesIfNecessary : invalid input array ! Inconsistent with the given dimension !"); const CellModel& cm(CellModel::GetCellModel(ct)); - std::size_t baseDim((std::size_t)cm.getDimension()); + auto const baseDim((std::size_t)cm.getDimension()); if(baseDim==dim) return inputArray; - std::size_t nbOfItems(sz/dim); + std::size_t const nbOfItems(sz/dim); std::vector ret(nbOfItems*baseDim); if(baseDim>dim) { @@ -542,7 +546,7 @@ bool GaussInfo::IsInOrOutForReference(NormalizedCellType ct, const double *ptInR } } -typedef void (*MapToShapeFunction)(GaussInfo& obj); +using MapToShapeFunction = void (*)(GaussInfo &); /*! * Initialize the internal vectors @@ -630,7 +634,7 @@ void GaussInfo::initLocalInfo() _my_local_ref_dim = 2; _my_local_nb_ref = 4; MapToShapeFunction QUAD4PTR[]={Quad4aInit,Quad4bInit,Quad4cInit,Quad4DegSeg2Init}; - std::size_t NB_OF_QUAD4PTR(sizeof(QUAD4PTR)/sizeof(MapToShapeFunction)); + std::size_t const NB_OF_QUAD4PTR(sizeof(QUAD4PTR)/sizeof(MapToShapeFunction)); for(std::size_t i=0;i(theNbGauss), aReferenceCoord, FromIdType(theNbRef)); + auto* info = new GaussInfo( theGeometry, aGaussCoord, FromIdType(theNbGauss), aReferenceCoord, FromIdType(theNbRef)); info->initLocalInfo(); //If info with cell type doesn't exist add it @@ -4774,8 +4777,8 @@ double* GaussCoords::calculateCoords( NormalizedCellType theGeometry, const mcIdType *theIndex) { const GaussInfo *info = getInfoGivenCellType(theGeometry); - int nbCoords = theSpaceDim * info->getNbGauss(); - double *aCoords = new double[nbCoords]; + int const nbCoords = theSpaceDim * info->getNbGauss(); + auto *aCoords = new double[nbCoords]; calculateCoordsAlg(info,theNodeCoords,theSpaceDim,theIndex,aCoords); return aCoords; } @@ -4789,9 +4792,9 @@ void GaussCoords::calculateCoords( NormalizedCellType theGeometry, const double void GaussCoords::calculateCoordsAlg(const GaussInfo *info, const double* theNodeCoords, const int theSpaceDim, const mcIdType *theIndex, double *result) { - int aConn = info->getNbRef(); + int const aConn = info->getNbRef(); - int nbCoords = theSpaceDim * info->getNbGauss(); + int const nbCoords = theSpaceDim * info->getNbGauss(); std::fill(result,result+nbCoords,0.); for( int gaussId = 0; gaussId < info->getNbGauss(); gaussId++ ) diff --git a/src/INTERP_KERNEL/GaussPoints/InterpKernelGaussCoords.hxx b/src/INTERP_KERNEL/GaussPoints/InterpKernelGaussCoords.hxx index a4aa652e7..a5a8a76e6 100644 --- a/src/INTERP_KERNEL/GaussPoints/InterpKernelGaussCoords.hxx +++ b/src/INTERP_KERNEL/GaussPoints/InterpKernelGaussCoords.hxx @@ -21,16 +21,15 @@ #define __INTERPKERNELGAUSSCOORDS_HXX__ #include "INTERPKERNELDefines.hxx" -#include "NormalizedUnstructuredMesh.hxx" -#include "InterpKernelException.hxx" #include "MCIdType.hxx" +#include "NormalizedGeometricTypes" #include namespace INTERP_KERNEL { - typedef std::vector DataVector; - typedef std::vector IndexVector; + using DataVector = std::vector; + using IndexVector = std::vector; //Class to store Gauss Points information class GaussInfo @@ -231,7 +230,7 @@ namespace INTERP_KERNEL void calculateCoordsAlg(const GaussInfo *info, const double* theNodeCoords, const int theSpaceDim, const mcIdType *theIndex, double *result); private: - typedef std::vector GaussInfoVector; + using GaussInfoVector = std::vector; GaussInfoVector _my_gauss_info; }; } diff --git a/src/INTERP_KERNEL/GenMathFormulae.hxx b/src/INTERP_KERNEL/GenMathFormulae.hxx index 07ebea013..d1d6a1d23 100644 --- a/src/INTERP_KERNEL/GenMathFormulae.hxx +++ b/src/INTERP_KERNEL/GenMathFormulae.hxx @@ -21,9 +21,9 @@ #ifndef __GENMATHFORMULAE_HXX__ #define __GENMATHFORMULAE_HXX__ -#include "InterpKernelException.hxx" #include +#include namespace INTERP_KERNEL { @@ -37,13 +37,13 @@ namespace INTERP_KERNEL */ void computeEigenValues6(const double *matrix, double *eigenVals) { - double tr=(matrix[0]+matrix[1]+matrix[2])/3.; - double K[6]={matrix[0]-tr,matrix[1]-tr,matrix[2]-tr,matrix[3],matrix[4],matrix[5]}; - double q=(K[0]*K[1]*K[2]+2.*K[4]*K[5]*K[3]-K[0]*K[4]*K[4]-K[2]*K[3]*K[3]-K[1]*K[5]*K[5])/2.; + double const tr=(matrix[0]+matrix[1]+matrix[2])/3.; + double const K[6]={matrix[0]-tr,matrix[1]-tr,matrix[2]-tr,matrix[3],matrix[4],matrix[5]}; + double const q=(K[0]*K[1]*K[2]+2.*K[4]*K[5]*K[3]-K[0]*K[4]*K[4]-K[2]*K[3]*K[3]-K[1]*K[5]*K[5])/2.; double p=K[0]*K[0]+K[1]*K[1]+K[2]*K[2]+2*(K[3]*K[3]+K[4]*K[4]+K[5]*K[5]); p/=6.; - double sqp=sqrt(p); - double tmp=p*sqp; + double const sqp=sqrt(p); + double const tmp=p*sqp; double phi; if(fabs(q)<=fabs(tmp)) if(tmp !=0) @@ -72,14 +72,14 @@ namespace INTERP_KERNEL const double m9[9]={matrix[0]-eigenVal,matrix[3],matrix[5],matrix[3],matrix[1]-eigenVal,matrix[4],matrix[5],matrix[4],matrix[2]-eigenVal}; for(int i=0;i<3;i++) { - double w[9]={m9[0+3*i],m9[1+3*i],m9[2+3*i],m9[0+(3*(i+1))%6],m9[1+(3*(i+1))%6],m9[2+(3*(i+1))%6],1.,1.,1.}; - double det=w[0]*w[4]*w[8]+w[1]*w[5]*w[6]+w[2]*w[3]*w[7]-w[0]*w[5]*w[7]-w[1]*w[3]*w[8]-w[2]*w[4]*w[6]; + double const w[9]={m9[0+3*i],m9[1+3*i],m9[2+3*i],m9[0+(3*(i+1))%6],m9[1+(3*(i+1))%6],m9[2+(3*(i+1))%6],1.,1.,1.}; + double const det=w[0]*w[4]*w[8]+w[1]*w[5]*w[6]+w[2]*w[3]*w[7]-w[0]*w[5]*w[7]-w[1]*w[3]*w[8]-w[2]*w[4]*w[6]; if(fabs(det)>eps) { eigenVector[0]=(w[1]*w[5]-w[4]*w[2])/det; eigenVector[1]=(w[2]*w[3]-w[0]*w[5])/det; eigenVector[2]=(w[0]*w[4]-w[1]*w[3])/det; - double norm=sqrt(eigenVector[0]*eigenVector[0]+eigenVector[1]*eigenVector[1]+eigenVector[2]*eigenVector[2]); + double const norm=sqrt(eigenVector[0]*eigenVector[0]+eigenVector[1]*eigenVector[1]+eigenVector[2]*eigenVector[2]); eigenVector[0]/=norm; eigenVector[1]/=norm; eigenVector[2]/=norm; diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DAbstractEdge.cxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DAbstractEdge.cxx index 7f539da88..a7ca9ef1b 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DAbstractEdge.cxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DAbstractEdge.cxx @@ -20,11 +20,14 @@ #include "InterpKernelGeo2DAbstractEdge.hxx" #include "InterpKernelGeo2DComposedEdge.hxx" +#include "InterpKernelGeo2DEdge.hxx" #include "InterpKernelGeo2DElementaryEdge.hxx" +#include +#include using namespace INTERP_KERNEL; -IteratorOnComposedEdge::IteratorOnComposedEdge():_list_handle(0) +IteratorOnComposedEdge::IteratorOnComposedEdge():_list_handle(nullptr) { } @@ -96,18 +99,18 @@ bool IteratorOnComposedEdge::goToNextInOn(bool direction, int& i, int nbMax) void IteratorOnComposedEdge::assignMySelfToAllElems(ComposedEdge *elems) { std::list *myList=elems->getListBehind(); - for(std::list::iterator iter=myList->begin();iter!=myList->end();iter++) - (*iter)->getIterator()=(*this); + for(auto & iter : *myList) + iter->getIterator()=(*this); } void IteratorOnComposedEdge::insertElemEdges(ComposedEdge *elems, bool changeMySelf) { std::list *myListToInsert=elems->getListBehind(); - std::list::iterator iter=myListToInsert->begin(); + auto iter=myListToInsert->begin(); *_deep_it=*iter; _deep_it++; iter++; - std::size_t sizeOfMyList=myListToInsert->size(); + std::size_t const sizeOfMyList=myListToInsert->size(); _list_handle->insert(_deep_it,iter,myListToInsert->end()); if(!changeMySelf) { diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DAbstractEdge.hxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DAbstractEdge.hxx index 1b544216a..805aa26af 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DAbstractEdge.hxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DAbstractEdge.hxx @@ -23,9 +23,7 @@ #include "INTERPKERNELDefines.hxx" -#include #include -#include namespace INTERP_KERNEL { @@ -47,7 +45,7 @@ namespace INTERP_KERNEL public: INTERPKERNEL_EXPORT IteratorOnComposedEdge(); INTERPKERNEL_EXPORT IteratorOnComposedEdge(ComposedEdge *compEdges); - INTERPKERNEL_EXPORT bool isValid() const { return _list_handle!=0; } + INTERPKERNEL_EXPORT bool isValid() const { return _list_handle!=nullptr; } INTERPKERNEL_EXPORT void operator=(const IteratorOnComposedEdge& other); INTERPKERNEL_EXPORT void first() { _deep_it=_list_handle->begin(); } INTERPKERNEL_EXPORT void next() { _deep_it++; } diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DBounds.cxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DBounds.cxx index b6429829f..c66569978 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DBounds.cxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DBounds.cxx @@ -22,6 +22,9 @@ #include "InterpKernelException.hxx" #include "InterpKernelGeo2DEdgeArcCircle.hxx" #include "InterpKernelGeo2DNode.hxx" +#include +#include +#include "InterpKernelGeo2DPrecision.hxx" using namespace INTERP_KERNEL; @@ -59,8 +62,8 @@ double &Bounds::operator[](int i) double Bounds::getDiagonal() const { - double a=_x_max-_x_min; - double b=_y_max-_y_min; + double const a=_x_max-_x_min; + double const b=_y_max-_y_min; return sqrt(a*a+b*b); } @@ -108,14 +111,14 @@ void Bounds::prepareForAggregation() */ void Bounds::getInterceptedArc(const double *center, double radius, double& intrcptArcAngle0, double& intrcptArcDelta) const { - double diag=getDiagonal(); + double const diag=getDiagonal(); if(diag<2.*radius) { double v1[2],v2[2],w1[2],w2[2]; v1[0]=_x_min-center[0]; v1[1]=_y_max-center[1]; v2[0]=_x_max-center[0]; v2[1]=_y_min-center[1]; w1[0]=v1[0]; w1[1]=_y_min-center[1]; w2[0]=v2[0]; w2[1]=_y_max-center[1]; - double delta1=EdgeArcCircle::SafeAsin(v1[0]*v2[1]-v1[1]*v2[0]); - double delta2=EdgeArcCircle::SafeAsin(w1[0]*w2[1]-w1[1]*w2[0]); + double const delta1=EdgeArcCircle::SafeAsin(v1[0]*v2[1]-v1[1]*v2[0]); + double const delta2=EdgeArcCircle::SafeAsin(w1[0]*w2[1]-w1[1]*w2[0]); double tmp; if(fabs(delta1)>fabs(delta2)) { @@ -133,7 +136,7 @@ void Bounds::getInterceptedArc(const double *center, double radius, double& intr double Bounds::fitXForXFigD(double val, int res) const { double delta=std::max(_x_max-_x_min,_y_max-_y_min)/2.; - double ret=val-(_x_max+_x_min)/2.+delta; + double const ret=val-(_x_max+_x_min)/2.+delta; delta=11.1375*res/(2.*delta); return ret*delta; } @@ -141,17 +144,17 @@ double Bounds::fitXForXFigD(double val, int res) const double Bounds::fitYForXFigD(double val, int res) const { double delta=std::max(_x_max-_x_min,_y_max-_y_min)/2.; - double ret=(_y_max+_y_min)/2.-val+delta; + double const ret=(_y_max+_y_min)/2.-val+delta; delta=11.1375*res/(2.*delta); return ret*delta; } Bounds *Bounds::nearlyAmIIntersectingWith(const Bounds& other) const { - double eps = QuadraticPlanarPrecision::getPrecision(); + double const eps = QuadraticPlanarPrecision::getPrecision(); if( (other._x_min > _x_max+eps) || (other._x_max < _x_min-eps) || (other._y_min > _y_max+eps) || (other._y_max < _y_min-eps) ) - return 0; + return nullptr; if( (other._x_min >= _x_max ) || (other._x_max <= _x_min) || (other._y_min >= _y_max) || (other._y_max <= _y_min) ) { return new Bounds(std::max(_x_min-eps,other._x_min), @@ -166,7 +169,7 @@ Bounds *Bounds::nearlyAmIIntersectingWith(const Bounds& other) const Bounds *Bounds::amIIntersectingWith(const Bounds& other) const { if( (other._x_min > _x_max) || (other._x_max < _x_min) || (other._y_min > _y_max) || (other._y_max < _y_min) ) - return 0; + return nullptr; return new Bounds(std::max(_x_min,other._x_min),std::min(_x_max,other._x_max),std::max(_y_min,other._y_min),std::min(_y_max,other._y_max)); } @@ -180,8 +183,8 @@ Position Bounds::where(double x, double y) const Position Bounds::nearlyWhere(double x, double y) const { - bool thinX=Node::areDoubleEquals(_x_min,_x_max); - bool thinY=Node::areDoubleEquals(_y_min,_y_max); + bool const thinX=Node::areDoubleEquals(_x_min,_x_max); + bool const thinY=Node::areDoubleEquals(_y_min,_y_max); if(!thinX) { if((Node::areDoubleEquals(x,_x_min) || Node::areDoubleEquals(x,_x_max)) && ((y<_y_max+QuadraticPlanarPrecision::getPrecision()) && (y>_y_min-QuadraticPlanarPrecision::getPrecision()))) diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DBounds.hxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DBounds.hxx index 3f267f476..806763b65 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DBounds.hxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DBounds.hxx @@ -52,7 +52,7 @@ namespace INTERP_KERNEL void getBarycenter(double& xBary, double& yBary) const; void applySimilarity(double xBary, double yBary, double dimChar); void unApplySimilarity(double xBary, double yBary, double dimChar); - Bounds& operator=(const Bounds& other) { _x_min=other._x_min; _x_max=other._x_max; _y_min=other._y_min; _y_max=other._y_max; return *this; } + Bounds& operator=(const Bounds& other) = default; Bounds(double xMin, double xMax, double yMin, double yMax):_x_min(xMin),_x_max(xMax),_y_min(yMin),_y_max(yMax) { } void setValues(double xMin, double xMax, double yMin, double yMax) { _x_min=xMin; _x_max=xMax; _y_min=yMin; _y_max=yMax; } void prepareForAggregation(); diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.cxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.cxx index 94d4e5363..2488095a6 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.cxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.cxx @@ -19,22 +19,35 @@ // Author : Anthony Geay (CEA/DEN) #include "InterpKernelGeo2DComposedEdge.hxx" +#include "InterpKernelGeo2DEdge.hxx" +#include "InterpKernelGeo2DBounds.hxx" #include "InterpKernelGeo2DElementaryEdge.hxx" #include "InterpKernelGeo2DEdgeArcCircle.hxx" #include "InterpKernelGeo2DEdgeInfLin.hxx" #include "InterpKernelException.hxx" +#include "InterpKernelGeo2DNode.hxx" +#include "InterpKernelGeo2DPrecision.hxx" #include +#include +#include +#include +#include +#include +#include +#include #include #include +#include #include +#include using namespace INTERP_KERNEL; ComposedEdge::ComposedEdge(const ComposedEdge& other) { - for(std::list::const_iterator iter=other._sub_edges.begin();iter!=other._sub_edges.end();iter++) - _sub_edges.push_back((*iter)->clone()); + for(auto _sub_edge : other._sub_edges) + _sub_edges.push_back(_sub_edge->clone()); } ComposedEdge::~ComposedEdge() @@ -44,7 +57,7 @@ ComposedEdge::~ComposedEdge() void ComposedEdge::setValueAt(int i, Edge *e, bool direction) { - std::list::iterator it=_sub_edges.begin(); + auto it=_sub_edges.begin(); for(int j=0;j::const_iterator iter=_sub_edges.begin();iter!=_sub_edges.end();iter++) + for(auto _sub_edge : _sub_edges) { - if(find_if(other._sub_edges.begin(),other._sub_edges.end(),AbsEdgeCmp(*iter))!=other._sub_edges.end()) + if(find_if(other._sub_edges.begin(),other._sub_edges.end(),AbsEdgeCmp(_sub_edge))!=other._sub_edges.end()) { - const ElementaryEdge *tmp=static_cast(*iter); + const auto *tmp=static_cast(_sub_edge); ret+=tmp->getCurveLength(); } } @@ -99,7 +112,7 @@ void ComposedEdge::pushBack(ComposedEdge *elem) ElementaryEdge *ComposedEdge::operator[](int i) const { - std::list::const_iterator iter=_sub_edges.begin(); + auto iter=_sub_edges.begin(); for(int ii=0;ii::iterator iter=_sub_edges.begin();iter!=_sub_edges.end();iter++) - (*iter)->reverse(); + for(auto & _sub_edge : _sub_edges) + _sub_edge->reverse(); } bool ComposedEdge::presenceOfOn() const { bool ret=false; - for(std::list::const_iterator iter=_sub_edges.begin();iter!=_sub_edges.end() && !ret;iter++) + for(auto iter=_sub_edges.begin();iter!=_sub_edges.end() && !ret;iter++) ret=((*iter)->getLoc()==FULL_ON_1); return ret; } @@ -123,19 +136,19 @@ bool ComposedEdge::presenceOfOn() const bool ComposedEdge::presenceOfQuadraticEdge() const { bool ret=false; - for(std::list::const_iterator iter=_sub_edges.begin();iter!=_sub_edges.end() && !ret;iter++) + for(auto iter=_sub_edges.begin();iter!=_sub_edges.end() && !ret;iter++) { Edge *e=(*iter)->getPtr(); if(e) - ret=dynamic_cast(e)!=0; + ret=dynamic_cast(e)!=nullptr; } return ret; } void ComposedEdge::initLocations() const { - for(std::list::const_iterator iter=_sub_edges.begin();iter!=_sub_edges.end();iter++) - (*iter)->initLocations(); + for(auto _sub_edge : _sub_edges) + _sub_edge->initLocations(); } /** @@ -145,16 +158,16 @@ void ComposedEdge::initLocations() const void ComposedEdge::InitLocationsWithOther(const ComposedEdge& first, const ComposedEdge& other) { std::set s1,s2; - for(std::list::const_iterator it1=first._sub_edges.begin();it1!=first._sub_edges.end();it1++) - s1.insert((*it1)->getPtr()); - for(std::list::const_iterator it2=other._sub_edges.begin();it2!=other._sub_edges.end();it2++) - s2.insert((*it2)->getPtr()); + for(auto _sub_edge : first._sub_edges) + s1.insert(_sub_edge->getPtr()); + for(auto _sub_edge : other._sub_edges) + s2.insert(_sub_edge->getPtr()); first.initLocations(); other.initLocations(); std::vector s3; std::set_intersection(s1.begin(),s1.end(),s2.begin(),s2.end(),std::back_insert_iterator< std::vector >(s3)); - for(std::vector::const_iterator it3=s3.begin();it3!=s3.end();it3++) - (*it3)->declareOn(); + for(auto it3 : s3) + it3->declareOn(); } ComposedEdge *ComposedEdge::clone() const @@ -165,7 +178,7 @@ ComposedEdge *ComposedEdge::clone() const bool ComposedEdge::isNodeIn(Node *n) const { bool ret=false; - for(std::list::const_iterator iter=_sub_edges.begin();iter!=_sub_edges.end() && !ret;iter++) + for(auto iter=_sub_edges.begin();iter!=_sub_edges.end() && !ret;iter++) ret=(*iter)->isNodeIn(n); return ret; } @@ -188,16 +201,16 @@ bool ComposedEdge::isNodeIn(Node *n) const double ComposedEdge::getArea() const { double ret=0.; - for(std::list::const_iterator iter=_sub_edges.begin();iter!=_sub_edges.end();iter++) - ret+=(*iter)->getAreaOfZone(); + for(auto _sub_edge : _sub_edges) + ret+=_sub_edge->getAreaOfZone(); return ret; } double ComposedEdge::getPerimeter() const { double ret=0.; - for(std::list::const_iterator iter=_sub_edges.begin();iter!=_sub_edges.end();iter++) - ret+=(*iter)->getCurveLength(); + for(auto _sub_edge : _sub_edges) + ret+=_sub_edge->getCurveLength(); return ret; } @@ -230,10 +243,10 @@ void ComposedEdge::getBarycenter(double *bary) const bary[0]=0.; bary[1]=0.; double area=0.; - for(std::list::const_iterator iter=_sub_edges.begin();iter!=_sub_edges.end();iter++) + for(auto _sub_edge : _sub_edges) { - (*iter)->getBarycenterOfZone(bary); - area+=(*iter)->getAreaOfZone(); + _sub_edge->getBarycenterOfZone(bary); + area+=_sub_edge->getAreaOfZone(); } bary[0]/=area; bary[1]/=area; @@ -257,7 +270,7 @@ double ComposedEdge::normalizeMe(double& xBary, double& yBary) Bounds b; b.prepareForAggregation(); fillBounds(b); - double dimChar=b.getCaracteristicDim(); + double const dimChar=b.getCaracteristicDim(); b.getBarycenter(xBary,yBary); applyGlobalSimilarity(xBary,yBary,dimChar); return dimChar; @@ -269,7 +282,7 @@ double ComposedEdge::normalize(ComposedEdge *other, double& xBary, double& yBary b.prepareForAggregation(); fillBounds(b); other->fillBounds(b); - double dimChar=b.getCaracteristicDim(); + double const dimChar=b.getCaracteristicDim(); b.getBarycenter(xBary,yBary); applyGlobalSimilarity(xBary,yBary,dimChar); other->applyGlobalSimilarity(xBary,yBary,dimChar); @@ -297,7 +310,7 @@ double ComposedEdge::normalizeExt(ComposedEdge *other, double& xBary, double& yB b.prepareForAggregation(); fillBounds(b); other->fillBounds(b); - double dimChar=b.getCaracteristicDim(); + double const dimChar=b.getCaracteristicDim(); b.getBarycenter(xBary,yBary); applyGlobalSimilarity2(other,xBary,yBary,dimChar); return dimChar; @@ -306,14 +319,14 @@ double ComposedEdge::normalizeExt(ComposedEdge *other, double& xBary, double& yB void ComposedEdge::dumpInXfigFile(std::ostream& stream, int resolution, const Bounds& box) const { stream.precision(10); - for(std::list::const_iterator iter=_sub_edges.begin();iter!=_sub_edges.end();iter++) - (*iter)->dumpInXfigFile(stream,resolution,box); + for(auto _sub_edge : _sub_edges) + _sub_edge->dumpInXfigFile(stream,resolution,box); } void ComposedEdge::dumpToCout(const std::map& mapp) const { int i=0; - for(std::list::const_iterator iter=_sub_edges.begin();iter!=_sub_edges.end();iter++, i++) + for(auto iter=_sub_edges.begin();iter!=_sub_edges.end();iter++, i++) (*iter)->dumpToCout(mapp, i); std::cout << std::endl; } @@ -340,8 +353,8 @@ bool ComposedEdge::changeStartNodeWith(Node *node) const void ComposedEdge::fillBounds(Bounds& output) const { - for(std::list::const_iterator iter=_sub_edges.begin();iter!=_sub_edges.end();iter++) - (*iter)->fillBounds(output); + for(auto _sub_edge : _sub_edges) + _sub_edge->fillBounds(output); } /*! @@ -349,8 +362,8 @@ void ComposedEdge::fillBounds(Bounds& output) const */ void ComposedEdge::applySimilarity(double xBary, double yBary, double dimChar) { - for(std::list::iterator iter=_sub_edges.begin();iter!=_sub_edges.end();iter++) - (*iter)->applySimilarity(xBary,yBary,dimChar); + for(auto & _sub_edge : _sub_edges) + _sub_edge->applySimilarity(xBary,yBary,dimChar); } /*! @@ -360,10 +373,10 @@ void ComposedEdge::applyGlobalSimilarity(double xBary, double yBary, double dimC { std::set allNodes; getAllNodes(allNodes); - for(std::set::iterator iter=allNodes.begin();iter!=allNodes.end();iter++) - (*iter)->applySimilarity(xBary,yBary,dimChar); - for(std::list::iterator iter=_sub_edges.begin();iter!=_sub_edges.end();iter++) - (*iter)->applySimilarity(xBary,yBary,dimChar); + for(auto allNode : allNodes) + allNode->applySimilarity(xBary,yBary,dimChar); + for(auto & _sub_edge : _sub_edges) + _sub_edge->applySimilarity(xBary,yBary,dimChar); } /*! @@ -388,11 +401,11 @@ void ComposedEdge::applyGlobalSimilarity2(ComposedEdge *other, double xBary, dou */ void ComposedEdge::dispatchPerimeter(double& partConsidered) const { - for(std::list::const_iterator iter=_sub_edges.begin();iter!=_sub_edges.end();iter++) + for(auto _sub_edge : _sub_edges) { - TypeOfEdgeLocInPolygon loc=(*iter)->getLoc(); + TypeOfEdgeLocInPolygon const loc=_sub_edge->getLoc(); if(loc==FULL_IN_1 || loc==FULL_ON_1) - partConsidered+=(*iter)->getCurveLength(); + partConsidered+=_sub_edge->getCurveLength(); } } @@ -401,105 +414,105 @@ void ComposedEdge::dispatchPerimeter(double& partConsidered) const */ void ComposedEdge::dispatchPerimeterExcl(double& partConsidered, double& commonPart) const { - for(std::list::const_iterator iter=_sub_edges.begin();iter!=_sub_edges.end();iter++) + for(auto _sub_edge : _sub_edges) { - TypeOfEdgeLocInPolygon loc=(*iter)->getLoc(); + TypeOfEdgeLocInPolygon const loc=_sub_edge->getLoc(); if(loc==FULL_IN_1) - partConsidered+=(*iter)->getCurveLength(); + partConsidered+=_sub_edge->getCurveLength(); if(loc==FULL_ON_1) - commonPart+=(*iter)->getCurveLength(); + commonPart+=_sub_edge->getCurveLength(); } } void ComposedEdge::getAllNodes(std::set& output) const { - std::list::const_iterator iter=_sub_edges.begin(); + auto iter=_sub_edges.begin(); for(;iter!=_sub_edges.end();iter++) (*iter)->getAllNodes(output); } void ComposedEdge::initNodeHitStatus() const { - for(std::list::const_iterator iter=_sub_edges.begin();iter!=_sub_edges.end();iter++) + for(auto _sub_edge : _sub_edges) { - (*iter)->getStartNode()->initHitStatus(); - (*iter)->getEndNode()->initHitStatus(); + _sub_edge->getStartNode()->initHitStatus(); + _sub_edge->getEndNode()->initHitStatus(); } } void ComposedEdge::applySimilarityOnMyNodes(double xBary, double yBary, double dimChar) const { - for(std::list::const_iterator iter=_sub_edges.begin();iter!=_sub_edges.end();iter++) + for(auto _sub_edge : _sub_edges) { - (*iter)->getStartNode()->hitMeAlone(xBary,yBary,dimChar); - (*iter)->getEndNode()->hitMeAlone(xBary,yBary,dimChar); + _sub_edge->getStartNode()->hitMeAlone(xBary,yBary,dimChar); + _sub_edge->getEndNode()->hitMeAlone(xBary,yBary,dimChar); } } void ComposedEdge::unApplySimilarityOnMyNodes(double xBary, double yBary, double dimChar) const { - for(std::list::const_iterator iter=_sub_edges.begin();iter!=_sub_edges.end();iter++) + for(auto _sub_edge : _sub_edges) { - (*iter)->getStartNode()->unHitMeAlone(xBary,yBary,dimChar); - (*iter)->getEndNode()->unHitMeAlone(xBary,yBary,dimChar); + _sub_edge->getStartNode()->unHitMeAlone(xBary,yBary,dimChar); + _sub_edge->getEndNode()->unHitMeAlone(xBary,yBary,dimChar); } } void ComposedEdge::applySimilarityOnMyNodesIfNotAlreadyHit(double xBary, double yBary, double dimChar) const { - for(std::list::const_iterator iter=_sub_edges.begin();iter!=_sub_edges.end();iter++) + for(auto _sub_edge : _sub_edges) { - (*iter)->getStartNode()->hitMeAfter(xBary,yBary,dimChar); - (*iter)->getEndNode()->hitMeAfter(xBary,yBary,dimChar); + _sub_edge->getStartNode()->hitMeAfter(xBary,yBary,dimChar); + _sub_edge->getEndNode()->hitMeAfter(xBary,yBary,dimChar); } } void ComposedEdge::unApplySimilarityOnMyNodesIfNotAlreadyHit(double xBary, double yBary, double dimChar) const { - for(std::list::const_iterator iter=_sub_edges.begin();iter!=_sub_edges.end();iter++) + for(auto _sub_edge : _sub_edges) { - (*iter)->getStartNode()->unHitMeAfter(xBary,yBary,dimChar); - (*iter)->getEndNode()->unHitMeAfter(xBary,yBary,dimChar); + _sub_edge->getStartNode()->unHitMeAfter(xBary,yBary,dimChar); + _sub_edge->getEndNode()->unHitMeAfter(xBary,yBary,dimChar); } } void ComposedEdge::initEdgeHitStatus() const { - for(std::list::const_iterator iter=_sub_edges.begin();iter!=_sub_edges.end();iter++) - (*iter)->getPtr()->initHitStatus(); + for(auto _sub_edge : _sub_edges) + _sub_edge->getPtr()->initHitStatus(); } void ComposedEdge::applySimilarityOnMyEdges(double xBary, double yBary, double dimChar) const { - for(std::list::const_iterator iter=_sub_edges.begin();iter!=_sub_edges.end();iter++) - (*iter)->getPtr()->hitMeAlone(xBary,yBary,dimChar); + for(auto _sub_edge : _sub_edges) + _sub_edge->getPtr()->hitMeAlone(xBary,yBary,dimChar); } void ComposedEdge::unApplySimilarityOnMyEdges(double xBary, double yBary, double dimChar) const { - for(std::list::const_iterator iter=_sub_edges.begin();iter!=_sub_edges.end();iter++) - (*iter)->getPtr()->unHitMeAlone(xBary,yBary,dimChar); + for(auto _sub_edge : _sub_edges) + _sub_edge->getPtr()->unHitMeAlone(xBary,yBary,dimChar); } void ComposedEdge::applySimilarityOnMyEdgesIfNotAlreadyHit(double xBary, double yBary, double dimChar) const { - for(std::list::const_iterator iter=_sub_edges.begin();iter!=_sub_edges.end();iter++) - (*iter)->getPtr()->hitMeAfter(xBary,yBary,dimChar); + for(auto _sub_edge : _sub_edges) + _sub_edge->getPtr()->hitMeAfter(xBary,yBary,dimChar); } void ComposedEdge::unApplySimilarityOnMyEdgesIfNotAlreadyHit(double xBary, double yBary, double dimChar) const { - for(std::list::const_iterator iter=_sub_edges.begin();iter!=_sub_edges.end();iter++) - (*iter)->getPtr()->unHitMeAfter(xBary,yBary,dimChar); + for(auto _sub_edge : _sub_edges) + _sub_edge->getPtr()->unHitMeAfter(xBary,yBary,dimChar); } void ComposedEdge::getBarycenter(double *bary, double& weigh) const { weigh=0.; bary[0]=0.; bary[1]=0.; double tmp1,tmp2[2]; - for(std::list::const_iterator iter=_sub_edges.begin();iter!=_sub_edges.end();iter++) + for(auto _sub_edge : _sub_edges) { - (*iter)->getBarycenter(tmp2,tmp1); + _sub_edge->getBarycenter(tmp2,tmp1); weigh+=tmp1; bary[0]+=tmp1*tmp2[0]; bary[1]+=tmp1*tmp2[1]; @@ -522,13 +535,13 @@ bool ComposedEdge::isInOrOut(Node *nodeToTest) const std::set< IntersectElement > inOutSwitch; std::set nodes; getAllNodes(nodes); - double ref(isInOrOutAlg(nodeToTest,nodes,inOutSwitch)); + double const ref(isInOrOutAlg(nodeToTest,nodes,inOutSwitch)); bool ret(false); - for(std::set< IntersectElement >::iterator iter4=inOutSwitch.begin();iter4!=inOutSwitch.end();iter4++) + for(const auto & iter4 : inOutSwitch) { - if((*iter4).getVal1()getLoc()==ON_1) + if(iter4.getNodeOnly()->getLoc()==ON_1) ret=!ret; } else @@ -548,19 +561,19 @@ bool ComposedEdge::isInOrOut2(Node *nodeToTest) const std::set< IntersectElement > inOutSwitch; std::set nodes; getAllNodes(nodes); - for(std::set::const_iterator iter=nodes.begin();iter!=nodes.end();iter++) - if(sqrt((*iter)->distanceWithSq(*nodeToTest))distanceWithSq(*nodeToTest))::iterator iter4=inOutSwitch.begin();iter4!=inOutSwitch.end();iter4++) + for(const auto & iter4 : inOutSwitch) { - double val((*iter4).getVal1()); + double const val(iter4.getVal1()); if(fabs(val-ref)>=QuadraticPlanarPrecision::getPrecision()) { if(valgetLoc()==ON_1) + if(iter4.getNodeOnly()->getLoc()==ON_1) ret=!ret; } else @@ -586,14 +599,13 @@ double ComposedEdge::isInOrOutAlg(Node *nodeToTest, const std::set& nodes radialDistrib2.back()=M_PI+radialDistrib.front(); std::vector radialDistrib3(radialDistrib.size()); std::transform(radialDistrib2.begin(),radialDistrib2.end(),radialDistrib.begin(),radialDistrib3.begin(),std::minus()); - std::vector::iterator iter3=max_element(radialDistrib3.begin(),radialDistrib3.end()); - std::size_t i=iter3-radialDistrib3.begin(); + auto const iter3=max_element(radialDistrib3.begin(),radialDistrib3.end()); + std::size_t const i=iter3-radialDistrib3.begin(); // ok for e1 - Let's go. - EdgeInfLin *e1=new EdgeInfLin(nodeToTest,radialDistrib[i]+radialDistrib3[i]/2.); - double ref=e1->getCharactValue(*nodeToTest); - for(std::list::const_iterator iter4=_sub_edges.begin();iter4!=_sub_edges.end();iter4++) + auto *e1=new EdgeInfLin(nodeToTest,radialDistrib[i]+radialDistrib3[i]/2.); + double const ref=e1->getCharactValue(*nodeToTest); + for(auto val : _sub_edges) { - ElementaryEdge *val=(*iter4); if(val) { Edge *e=val->getPtr(); @@ -606,10 +618,10 @@ double ComposedEdge::isInOrOutAlg(Node *nodeToTest, const std::set& nodes } if(!areOverlapped) { - std::list< IntersectElement > listOfIntesc=intersc->getIntersectionsCharacteristicVal(); - for(std::list< IntersectElement >::iterator iter2=listOfIntesc.begin();iter2!=listOfIntesc.end();iter2++) - if((*iter2).isIncludedByBoth()) - inOutSwitch.insert(*iter2); + std::list< IntersectElement > const listOfIntesc=intersc->getIntersectionsCharacteristicVal(); + for(auto & iter2 : listOfIntesc) + if(iter2.isIncludedByBoth()) + inOutSwitch.insert(iter2); } //if overlapped we can forget } @@ -634,6 +646,6 @@ bool ComposedEdge::intresincEqCoarse(const Edge *other) const void ComposedEdge::clearAll(std::list::iterator startToDel) { - for(std::list::iterator iter=startToDel;iter!=_sub_edges.end();iter++) + for(auto iter=startToDel;iter!=_sub_edges.end();iter++) delete (*iter); } diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.hxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.hxx index b21c03c9c..fb1a9ef64 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.hxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.hxx @@ -24,6 +24,7 @@ #include "INTERPKERNELDefines.hxx" #include "InterpKernelGeo2DEdge.hxx" +#include #include #include #include @@ -46,7 +47,7 @@ namespace INTERP_KERNEL { friend class IteratorOnComposedEdge; public: - INTERPKERNEL_EXPORT ComposedEdge() { } + INTERPKERNEL_EXPORT ComposedEdge() = default; INTERPKERNEL_EXPORT ComposedEdge(const ComposedEdge& other); INTERPKERNEL_EXPORT ComposedEdge(int sz):_sub_edges(sz) { } INTERPKERNEL_EXPORT static void Delete(ComposedEdge *pt) { delete pt; } diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.cxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.cxx index b184345d5..b5697b8d5 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.cxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.cxx @@ -20,15 +20,26 @@ #include "InterpKernelGeo2DEdge.hxx" #include "InterpKernelGeo2DEdgeLin.hxx" -#include "InterpKernelGeo2DEdgeInfLin.hxx" //#include "EdgeParabol.hxx" #include "InterpKernelGeo2DEdgeArcCircle.hxx" #include "InterpKernelGeo2DComposedEdge.hxx" #include "InterpKernelException.hxx" +#include "MCIdType.hxx" #include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include using namespace INTERP_KERNEL; @@ -40,7 +51,7 @@ MergePoints::MergePoints():_ass1Start1(0),_ass1End1(0),_ass1Start2(0),_ass1End2( void MergePoints::start1Replaced() { - unsigned nbOfAsso=getNumberOfAssociations(); + unsigned const nbOfAsso=getNumberOfAssociations(); if(nbOfAsso==0) _ass1Start1=1; else @@ -49,7 +60,7 @@ void MergePoints::start1Replaced() void MergePoints::end1Replaced() { - unsigned nbOfAsso=getNumberOfAssociations(); + unsigned const nbOfAsso=getNumberOfAssociations(); if(nbOfAsso==0) _ass1End1=1; else @@ -58,7 +69,7 @@ void MergePoints::end1Replaced() void MergePoints::start1OnStart2() { - unsigned nbOfAsso=getNumberOfAssociations(); + unsigned const nbOfAsso=getNumberOfAssociations(); if(nbOfAsso==0) { _ass1Start1=1; @@ -73,7 +84,7 @@ void MergePoints::start1OnStart2() void MergePoints::start1OnEnd2() { - unsigned nbOfAsso=getNumberOfAssociations(); + unsigned const nbOfAsso=getNumberOfAssociations(); if(nbOfAsso==0) { _ass1Start1=1; @@ -88,7 +99,7 @@ void MergePoints::start1OnEnd2() void MergePoints::end1OnStart2() { - unsigned nbOfAsso=getNumberOfAssociations(); + unsigned const nbOfAsso=getNumberOfAssociations(); if(nbOfAsso==0) { _ass1End1=1; @@ -103,7 +114,7 @@ void MergePoints::end1OnStart2() void MergePoints::end1OnEnd2() { - unsigned nbOfAsso=getNumberOfAssociations(); + unsigned const nbOfAsso=getNumberOfAssociations(); if(nbOfAsso==0) { _ass1End1=1; @@ -352,7 +363,7 @@ bool EdgeIntersector::intersect(std::vector& newNodes, bool& order, Merg iter=listOfIntesc.erase(iter); continue; } - unsigned tmp=(*iter).isOnExtrForAnEdgeAndInForOtherEdge(); + unsigned const tmp=(*iter).isOnExtrForAnEdgeAndInForOtherEdge(); if(tmp==IntersectElement::LIMIT_ALONE) { iter=listOfIntesc.erase(iter); @@ -384,8 +395,8 @@ bool EdgeIntersector::intersect(std::vector& newNodes, bool& order, Merg std::vector vecOfIntesc(listOfIntesc.begin(),listOfIntesc.end()); listOfIntesc.clear(); sort(vecOfIntesc.begin(),vecOfIntesc.end()); - for(std::vector::iterator iterV=vecOfIntesc.begin();iterV!=vecOfIntesc.end();iterV++) - newNodes.push_back((*iterV).getNodeAndReleaseIt()); + for(auto & iterV : vecOfIntesc) + newNodes.push_back(iterV.getNodeAndReleaseIt()); order=vecOfIntesc.front().isLowerOnOther(vecOfIntesc.back()); } return true; @@ -467,7 +478,7 @@ Edge::~Edge() bool Edge::decrRef() { - bool ret=(--_cnt==0); + bool const ret=(--_cnt==0); if(ret) delete this; return ret; @@ -604,9 +615,9 @@ void Edge::getNormalVector(double *vectOutput) const { std::copy((const double *)(*_end),(const double *)(*_end)+2,vectOutput); std::transform(vectOutput,vectOutput+2,(const double *)(*_start),vectOutput,std::minus()); - double norm=1./Node::norm(vectOutput); + double const norm=1./Node::norm(vectOutput); std::transform(vectOutput,vectOutput+2,vectOutput,bind(std::multiplies(),std::placeholders::_1,norm)); - double tmp=vectOutput[0]; + double const tmp=vectOutput[0]; vectOutput[0]=vectOutput[1]; vectOutput[1]=-tmp; } @@ -614,9 +625,9 @@ void Edge::getNormalVector(double *vectOutput) const Edge *Edge::BuildEdgeFrom3Points(const double *start, const double *middle, const double *end) { Node *b(new Node(start[0],start[1])),*m(new Node(middle[0],middle[1])),*e(new Node(end[0],end[1])); - EdgeLin *e1(new EdgeLin(b,m)),*e2(new EdgeLin(m,e)); - SegSegIntersector inters(*e1,*e2); bool colinearity=inters.areColinears(); delete e1; delete e2; - Edge *ret=0; + auto *e1(new EdgeLin(b,m)),*e2(new EdgeLin(m,e)); + SegSegIntersector const inters(*e1,*e2); bool const colinearity=inters.areColinears(); delete e1; delete e2; + Edge *ret=nullptr; if(colinearity) ret=new EdgeLin(b,e); else @@ -641,7 +652,7 @@ Edge *Edge::BuildFromXfigLine(std::istream& str) else { std::cerr << "Unknown line found..."; - return 0; + return nullptr; } } @@ -660,7 +671,7 @@ bool Edge::intersectWith(const Edge *other, MergePoints& commonNode, if(!merge) return false; delete merge; - merge=0; + merge=nullptr; EdgeIntersector *intersector=BuildIntersectorWith(this,other); ret=Intersect(this,other,intersector,commonNode,outVal1,outVal2); delete intersector; @@ -670,12 +681,12 @@ bool Edge::intersectWith(const Edge *other, MergePoints& commonNode, bool Edge::IntersectOverlapped(const Edge *f1, const Edge *f2, EdgeIntersector *intersector, MergePoints& commonNode, ComposedEdge& outValForF1, ComposedEdge& outValForF2) { - bool rev=intersector->haveTheySameDirection(); + bool const rev=intersector->haveTheySameDirection(); Node *f2Start=f2->getNode(rev?START:END); Node *f2End=f2->getNode(rev?END:START); TypeOfLocInEdge place1, place2; intersector->getPlacements(f2Start,f2End,place1,place2,commonNode); - int codeForIntersectionCase=CombineCodes(place1,place2); + int const codeForIntersectionCase=CombineCodes(place1,place2); return SplitOverlappedEdges(f1,f2,f2Start,f2End,rev,codeForIntersectionCase,outValForF1,outValForF2); } @@ -684,25 +695,25 @@ bool Edge::IntersectOverlapped(const Edge *f1, const Edge *f2, EdgeIntersector * */ void Edge::Interpolate1DLin(const std::vector& distrib1, const std::vector& distrib2, std::map >& result) { - std::size_t nbOfV1=distrib1.size()-1; - std::size_t nbOfV2=distrib2.size()-1; + std::size_t const nbOfV1=distrib1.size()-1; + std::size_t const nbOfV2=distrib2.size()-1; Node *n1=new Node(0.,0.); Node *n3=new Node(0.,0.); Node *n2=new Node(0.,0.); Node *n4=new Node(0.,0.); MergePoints commonNode; for(unsigned int i=0;i::const_iterator iter=find_if(distrib2.begin()+1,distrib2.end(),bind(std::greater_equal(),std::placeholders::_1,distrib1[i])); + auto const iter=find_if(distrib2.begin()+1,distrib2.end(),bind(std::greater_equal(),std::placeholders::_1,distrib1[i])); if(iter!=distrib2.end()) { for(unsigned int j=(unsigned)((iter-1)-distrib2.begin());jsetNewCoords(distrib1[i],0.); n2->setNewCoords(distrib1[i+1],0.); n3->setNewCoords(distrib2[j],0.); n4->setNewCoords(distrib2[j+1],0.); - ComposedEdge *f1=new ComposedEdge; - ComposedEdge *f2=new ComposedEdge; + auto *f1=new ComposedEdge; + auto *f2=new ComposedEdge; SegSegIntersector inters(*e1,*e2); bool b1,b2; inters.areOverlappedOrOnlyColinears(b1,b2); @@ -721,12 +732,12 @@ void Edge::Interpolate1DLin(const std::vector& distrib1, const std::vect EdgeIntersector *Edge::BuildIntersectorWith(const Edge *e1, const Edge *e2) { - EdgeIntersector *ret=0; - const EdgeLin *tmp1=0; - const EdgeArcCircle *tmp2=0; + EdgeIntersector *ret=nullptr; + const EdgeLin *tmp1=nullptr; + const EdgeArcCircle *tmp2=nullptr; unsigned char type1=e1->getTypeOfFunc(); e1->dynCastFunction(tmp1,tmp2); - unsigned char type2=e2->getTypeOfFunc(); + unsigned char const type2=e2->getTypeOfFunc(); e2->dynCastFunction(tmp1,tmp2); type1|=type2; switch(type1) @@ -781,11 +792,11 @@ bool Edge::Intersect(const Edge *f1, const Edge *f2, EdgeIntersector *intersecto { if(newNodes.empty()) throw Exception("Internal error occurred - error in intersector implementation!");// This case should never happen - std::vector::iterator iter=newNodes.begin(); - std::vector::reverse_iterator iterR=newNodes.rbegin(); + auto const iter=newNodes.begin(); + auto iterR=newNodes.rbegin(); f1->addSubEdgeInVector(f1->getStartNode(),*iter,outValForF1); f2->addSubEdgeInVector(f2->getStartNode(),order?*iter:*iterR,outValForF2); - for(std::vector::iterator iter2=newNodes.begin();iter2!=newNodes.end();iter2++,iterR++) + for(auto iter2=newNodes.begin();iter2!=newNodes.end();iter2++,iterR++) { if((iter2+1)==newNodes.end()) { @@ -990,7 +1001,7 @@ bool Edge::sortSubNodesAbs(const double *coo, std::vector& subNodes) b.prepareForAggregation(); b.aggregate(getBounds()); double xBary,yBary; - double dimChar(b.getCaracteristicDim()); + double const dimChar(b.getCaracteristicDim()); b.getBarycenter(xBary,yBary); applySimilarity(xBary,yBary,dimChar); _start->applySimilarity(xBary,yBary,dimChar); @@ -1011,7 +1022,7 @@ bool Edge::sortSubNodesAbs(const double *coo, std::vector& subNodes) bool ret(false); for(i=0;i& subNodes) void Edge::sortIdsAbs(const std::vector& addNodes, const std::map& mapp1, const std::map& mapp2, std::vector& edgesThis) { - mcIdType startId=(*mapp1.find(_start)).second; - mcIdType endId=(*mapp1.find(_end)).second; + mcIdType const startId=(*mapp1.find(_start)).second; + mcIdType const endId=(*mapp1.find(_end)).second; if (! addNodes.size()) // quick way out, no new node to add. { edgesThis.push_back(startId); @@ -1040,31 +1051,31 @@ void Edge::sortIdsAbs(const std::vector& addNodes, const b.prepareForAggregation(); b.aggregate(getBounds()); double xBary,yBary; - double dimChar=b.getCaracteristicDim(); + double const dimChar=b.getCaracteristicDim(); b.getBarycenter(xBary,yBary); - for(std::vector::const_iterator iter=addNodes.begin();iter!=addNodes.end();iter++) - (*iter)->applySimilarity(xBary,yBary,dimChar); + for(auto addNode : addNodes) + addNode->applySimilarity(xBary,yBary,dimChar); applySimilarity(xBary,yBary,dimChar); _start->applySimilarity(xBary,yBary,dimChar); _end->applySimilarity(xBary,yBary,dimChar); - std::size_t sz=addNodes.size(); + std::size_t const sz=addNodes.size(); std::vector< std::pair > an2(sz); for(std::size_t i=0;i(getCharactValueBtw0And1(*addNodes[i]),addNodes[i]); std::sort(an2.begin(),an2.end()); std::vector tmpp; - for(std::vector< std::pair >::const_iterator it=an2.begin();it!=an2.end();it++) + for(const auto & it : an2) { - mcIdType idd=(*mapp2.find((*it).second)).second; + mcIdType const idd=(*mapp2.find(it.second)).second; tmpp.push_back(idd); } std::vector tmpp2(tmpp.size()+2); tmpp2[0]=startId; std::copy(tmpp.begin(),tmpp.end(),tmpp2.begin()+1); tmpp2[tmpp.size()+1]=endId; - std::vector::iterator itt=std::unique(tmpp2.begin(),tmpp2.end()); + auto const itt=std::unique(tmpp2.begin(),tmpp2.end()); tmpp2.resize(std::distance(tmpp2.begin(),itt)); - std::size_t nbOfEdges=tmpp2.size()-1; + std::size_t const nbOfEdges=tmpp2.size()-1; for(std::size_t i=0;i see areOverlappedOrOnlyColinears() + IntersectElement *_earlyInter{nullptr}; // Non null if the intersection can be determined early -> see areOverlappedOrOnlyColinears() }; class INTERPKERNEL_EXPORT SameTypeEdgeIntersector : public EdgeIntersector { protected: SameTypeEdgeIntersector(const Edge& e1, const Edge& e2):EdgeIntersector(e1,e2) { } - bool keepOrder() const { return true; } + bool keepOrder() const override { return true; } }; class INTERPKERNEL_EXPORT CrossTypeEdgeIntersector : public EdgeIntersector { protected: CrossTypeEdgeIntersector(const Edge& e1, const Edge& e2, bool reverse):EdgeIntersector(e1,e2),_reverse(reverse) { } - bool keepOrder() const { return _reverse; } - bool haveTheySameDirection() const { throw Exception("Cross type intersector is not supposed to deal with overlapped in cross type."); } + bool keepOrder() const override { return _reverse; } + bool haveTheySameDirection() const override { throw Exception("Cross type intersector is not supposed to deal with overlapped in cross type."); } const Edge *myE1() { if(_reverse) return &_e1; else return &_e2; } const Edge *myE2() { if(_reverse) return &_e2; else return &_e1; } protected: @@ -223,7 +223,7 @@ namespace INTERP_KERNEL void unHitMeAfter(double xBary, double yBary, double dimChar) { if(!_hit) unHitMeAlone(xBary,yBary,dimChar); } const Bounds& getBounds() const { return _bounds; } void fillXfigStreamForLoc(std::ostream& stream) const; - Node *getNode(TypeOfLocInEdge where) const { if(where==START) return _start; else if(where==END) return _end; else return 0; } + Node *getNode(TypeOfLocInEdge where) const { if(where==START) return _start; else if(where==END) return _end; else return nullptr; } Node *getStartNode() const { return _start; } Node *getEndNode() const { return _end; } void setEndNodeWithoutChange(Node *newEnd); @@ -292,7 +292,7 @@ namespace INTERP_KERNEL std::vector& edgesOther, std::vector& addCoo, std::map& mapAddCoo) const; protected: - Edge():_cnt(1),_loc(FULL_UNKNOWN),_start(0),_end(0) { } + Edge():_cnt(1),_loc(FULL_UNKNOWN),_start(nullptr),_end(nullptr) { } virtual ~Edge(); static int CombineCodes(TypeOfLocInEdge code1, TypeOfLocInEdge code2); static bool Intersect(const Edge *f1, const Edge *f2, EdgeIntersector *intersector, MergePoints& commonNode, diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.txx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.txx index fa44acd77..66287ebd7 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.txx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.txx @@ -20,7 +20,9 @@ #ifndef __INTERPKERNELGEO2DEDGE_TXX__ #define __INTERPKERNELGEO2DEDGE_TXX__ +#include "InterpKernelGeo2DEdge.hxx" #include "InterpKernelGeo2DEdgeArcCircle.hxx" +#include "InterpKernelGeo2DNode.hxx" template INTERP_KERNEL::Edge *INTERP_KERNEL::Edge::BuildEdgeFrom(Node *start, Node *middle, Node *end) diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeArcCircle.cxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeArcCircle.cxx index 41624df7f..c0932b940 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeArcCircle.cxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeArcCircle.cxx @@ -19,14 +19,23 @@ // Author : Anthony Geay (CEA/DEN) #include "InterpKernelGeo2DEdgeArcCircle.hxx" +#include "InterpKernelGeo2DEdge.hxx" #include "InterpKernelGeo2DEdgeLin.hxx" #include "InterpKernelException.hxx" #include "InterpKernelGeo2DNode.hxx" -#include "NormalizedUnstructuredMesh.hxx" - -#include +#include "InterpKernelGeo2DPrecision.hxx" +#include "MCIdType.hxx" +#include "NormalizedGeometricTypes" + +#include +#include +#include +#include +#include #include #include +#include +#include using namespace INTERP_KERNEL; @@ -57,8 +66,8 @@ void ArcCArcCIntersector::getPlacements(Node *start, Node *end, TypeOfLocInEdge& obviousCaseForCurvAbscisse(end,whereEnd,commonNode,obvious2); if(obvious1 && obvious2) return ; - double angleInRadStart=getAngle(start); - double angleInRadEnd=getAngle(end); + double const angleInRadStart=getAngle(start); + double const angleInRadEnd=getAngle(end); if(obvious1 || obvious2) { if(obvious1) @@ -120,8 +129,8 @@ double ArcCArcCIntersector::getAngle(Node *node) const bool ArcCArcCIntersector::internalAreColinears(const EdgeArcCircle& a1, const EdgeArcCircle& a2, double& distBetweenCenters, double& cst, double& radiusL, double centerL[2], double& radiusB, double centerB[2]) { - double lgth1=fabs(a1.getAngle()*a1.getRadius()); - double lgth2=fabs(a2.getAngle()*a2.getRadius()); + double const lgth1=fabs(a1.getAngle()*a1.getRadius()); + double const lgth2=fabs(a2.getAngle()*a2.getRadius()); if(lgth1radius1+radius2+QuadraticPlanarPrecision::getPrecision() || _dist+std::min(radius1,radius2)+QuadraticPlanarPrecision::getPrecision() ArcCArcCIntersector::getIntersectionsCharacteristi std::list< IntersectElement > ret; const double *center1=getE1().getCenter(); const double *center2=getE2().getCenter(); - double radius1=getE1().getRadius(); double radius2=getE2().getRadius(); - double d1_1=(_dist*_dist-radius2*radius2+radius1*radius1)/(2.*_dist); // computation of 'x' on wolfram + double const radius1=getE1().getRadius(); double const radius2=getE2().getRadius(); + double const d1_1=(_dist*_dist-radius2*radius2+radius1*radius1)/(2.*_dist); // computation of 'x' on wolfram double u[2];//u is normalized vector from center1 to center2. u[0]=(center2[0]-center1[0])/_dist; u[1]=(center2[1]-center1[1])/_dist; - double d1_1y=EdgeArcCircle::SafeSqrt(radius1*radius1-d1_1*d1_1); // computation of 'y' on wolfram - double angleE1=EdgeArcCircle::NormalizeAngle(getE1().getAngle0()+getE1().getAngle()); - double angleE2=EdgeArcCircle::NormalizeAngle(getE2().getAngle0()+getE2().getAngle()); + double const d1_1y=EdgeArcCircle::SafeSqrt(radius1*radius1-d1_1*d1_1); // computation of 'y' on wolfram + double const angleE1=EdgeArcCircle::NormalizeAngle(getE1().getAngle0()+getE1().getAngle()); + double const angleE2=EdgeArcCircle::NormalizeAngle(getE2().getAngle0()+getE2().getAngle()); if(!Node::areDoubleEquals(d1_1y,0)) { //2 intersections @@ -219,24 +228,24 @@ std::list< IntersectElement > ArcCArcCIntersector::getIntersectionsCharacteristi v2[0]=u[0]*d1_1+u[1]*d1_1y; v2[1]=u[1]*d1_1-u[0]*d1_1y; Node *node1=new Node(center1[0]+v1[0],center1[1]+v1[1]); node1->declareOn(); Node *node2=new Node(center1[0]+v2[0],center1[1]+v2[1]); node2->declareOn(); - double angle1_1=EdgeArcCircle::GetAbsoluteAngleOfNormalizedVect(v1[0]/radius1,v1[1]/radius1); - double angle2_1=EdgeArcCircle::GetAbsoluteAngleOfNormalizedVect(v2[0]/radius1,v2[1]/radius1); + double const angle1_1=EdgeArcCircle::GetAbsoluteAngleOfNormalizedVect(v1[0]/radius1,v1[1]/radius1); + double const angle2_1=EdgeArcCircle::GetAbsoluteAngleOfNormalizedVect(v2[0]/radius1,v2[1]/radius1); double v3[2],v4[2]; v3[0]=center1[0]-center2[0]+v1[0]; v3[1]=center1[1]-center2[1]+v1[1]; v4[0]=center1[0]-center2[0]+v2[0]; v4[1]=center1[1]-center2[1]+v2[1]; - double angle1_2=EdgeArcCircle::GetAbsoluteAngleOfNormalizedVect(v3[0]/radius2,v3[1]/radius2); - double angle2_2=EdgeArcCircle::GetAbsoluteAngleOfNormalizedVect(v4[0]/radius2,v4[1]/radius2); + double const angle1_2=EdgeArcCircle::GetAbsoluteAngleOfNormalizedVect(v3[0]/radius2,v3[1]/radius2); + double const angle2_2=EdgeArcCircle::GetAbsoluteAngleOfNormalizedVect(v4[0]/radius2,v4[1]/radius2); // Check whether intersection points are exactly ON the other arc or not // -> the curvilinear distance (=radius*angle) must below eps - bool e1_1S=Node::areDoubleEqualsWPLeft(angle1_1,getE1().getAngle0(),radius1); - bool e1_1E=Node::areDoubleEqualsWPLeft(angle1_1,angleE1,radius1); - bool e1_2S=Node::areDoubleEqualsWPLeft(angle1_2,getE2().getAngle0(),radius1); - bool e1_2E=Node::areDoubleEqualsWPLeft(angle1_2,angleE2,radius1); + bool const e1_1S=Node::areDoubleEqualsWPLeft(angle1_1,getE1().getAngle0(),radius1); + bool const e1_1E=Node::areDoubleEqualsWPLeft(angle1_1,angleE1,radius1); + bool const e1_2S=Node::areDoubleEqualsWPLeft(angle1_2,getE2().getAngle0(),radius1); + bool const e1_2E=Node::areDoubleEqualsWPLeft(angle1_2,angleE2,radius1); // - bool e2_1S=Node::areDoubleEqualsWPLeft(angle2_1,getE1().getAngle0(),radius2); - bool e2_1E=Node::areDoubleEqualsWPLeft(angle2_1,angleE1,radius2); - bool e2_2S=Node::areDoubleEqualsWPLeft(angle2_2,getE2().getAngle0(),radius2); - bool e2_2E=Node::areDoubleEqualsWPLeft(angle2_2,angleE2,radius2); + bool const e2_1S=Node::areDoubleEqualsWPLeft(angle2_1,getE1().getAngle0(),radius2); + bool const e2_1E=Node::areDoubleEqualsWPLeft(angle2_1,angleE1,radius2); + bool const e2_2S=Node::areDoubleEqualsWPLeft(angle2_2,getE2().getAngle0(),radius2); + bool const e2_2E=Node::areDoubleEqualsWPLeft(angle2_2,angleE2,radius2); ret.push_back(IntersectElement(angle1_1,angle1_2,e1_1S,e1_1E,e1_2S,e1_2E,node1,_e1,_e2,keepOrder())); ret.push_back(IntersectElement(angle2_1,angle2_2,e2_1S,e2_1E,e2_2S,e2_2E,node2,_e1,_e2,keepOrder())); } @@ -246,12 +255,12 @@ std::list< IntersectElement > ArcCArcCIntersector::getIntersectionsCharacteristi double v1[2],v2[2]; v1[0]=d1_1*u[0]; v1[1]=d1_1*u[1]; v2[0]=center1[0]-center2[0]+v1[0]; v2[1]=center1[1]-center2[1]+v1[1]; - double angle0_1=EdgeArcCircle::GetAbsoluteAngleOfNormalizedVect(v1[0]/radius1,v1[1]/radius1); - double angle0_2=EdgeArcCircle::GetAbsoluteAngleOfNormalizedVect(v2[0]/radius2,v2[1]/radius2); - bool e0_1S=Node::areDoubleEqualsWPLeft(angle0_1,getE1().getAngle0(),radius1); - bool e0_1E=Node::areDoubleEqualsWPLeft(angle0_1,angleE1,radius1); - bool e0_2S=Node::areDoubleEqualsWPLeft(angle0_2,getE2().getAngle0(),radius2); - bool e0_2E=Node::areDoubleEqualsWPLeft(angle0_2,angleE2,radius2); + double const angle0_1=EdgeArcCircle::GetAbsoluteAngleOfNormalizedVect(v1[0]/radius1,v1[1]/radius1); + double const angle0_2=EdgeArcCircle::GetAbsoluteAngleOfNormalizedVect(v2[0]/radius2,v2[1]/radius2); + bool const e0_1S=Node::areDoubleEqualsWPLeft(angle0_1,getE1().getAngle0(),radius1); + bool const e0_1E=Node::areDoubleEqualsWPLeft(angle0_1,angleE1,radius1); + bool const e0_2S=Node::areDoubleEqualsWPLeft(angle0_2,getE2().getAngle0(),radius2); + bool const e0_2E=Node::areDoubleEqualsWPLeft(angle0_2,angleE2,radius2); Node *node=new Node(center1[0]+d1_1*u[0],center1[1]+d1_1*u[1]); node->declareOnTangent(); ret.push_back(IntersectElement(angle0_1,angle0_2,e0_1S,e0_1E,e0_2S,e0_2E,node,_e1,_e2,keepOrder())); } @@ -351,14 +360,14 @@ void ArcCSegIntersector::areOverlappedOrOnlyColinears(bool& obviousNoIntersectio // We need to compute d = R*R-_cross*_cross/_drSq // In terms of numerical precision, this can trigger 'catastrophic cancellation' and is hence better expressed as: - double _dr = sqrt(_drSq); + double const _dr = sqrt(_drSq); double diff = (R-_cross/_dr), add=(R+_cross/_dr); // Ah ah: we will be taking a square root later. If we want the user to be able to use an epsilon finer than 1.0e-8, then we need // to prevent ourselves going below machine precision (typ. 1.0e-16 for double). const double eps_machine = std::numeric_limits::epsilon(); diff = fabs(diff/R) < eps_machine ? 0.0 : diff; add = fabs(add/R) < eps_machine ? 0.0 : add; - double d = add*diff; + double const d = add*diff; // Compute deltaRoot_div_dr := sqrt(delta)/dr, where delta has the meaning of Wolfram. // Then 2*deltaRoot_div_dr is the distance between the two intersection points of the line with the circle. This is what we compare to eps. // We compute it in such a way that it can be used in boolean tests too (a very negative value means we're far apart from intersection) @@ -378,7 +387,7 @@ bool ArcCSegIntersector::areColinears() const return false; } -void ArcCSegIntersector::getPlacements(Node *start, Node *end, TypeOfLocInEdge& whereStart, TypeOfLocInEdge& whereEnd, MergePoints& commonNode) const +void ArcCSegIntersector::getPlacements(Node * /*start*/, Node * /*end*/, TypeOfLocInEdge& /*whereStart*/, TypeOfLocInEdge& /*whereEnd*/, MergePoints& /*commonNode*/) const { throw Exception("Internal error. Should never been called : no overlapping possible between arc of circle and a segment."); } @@ -396,9 +405,9 @@ std::list< IntersectElement > ArcCSegIntersector::getIntersectionsCharacteristic // There we can tell if the arc of circle is 'moving away' from the seg, or if it might intersect it twice const Node &n(*_earlyInter->getNodeOnly()); - double tang[2] = {-(n[1]-center[1]), n[0]-center[0]}; // (-y, x) is the tangent vector in the trigo direction with (x,y) = (center->node) - bool invSeg = _i1S2E || _i1E2E; - double linEdge[2] = {invSeg ? (-_dx) : _dx, invSeg ? (-_dy) : _dy}; + double const tang[2] = {-(n[1]-center[1]), n[0]-center[0]}; // (-y, x) is the tangent vector in the trigo direction with (x,y) = (center->node) + bool const invSeg = _i1S2E || _i1E2E; + double const linEdge[2] = {invSeg ? (-_dx) : _dx, invSeg ? (-_dy) : _dy}; if(tang[1]*linEdge[0]-tang[0]*linEdge[1] < 0) { ret.push_back(*_earlyInter); @@ -406,12 +415,12 @@ std::list< IntersectElement > ArcCSegIntersector::getIntersectionsCharacteristic } } - double determinant=fabs(_deltaRoot_div_dr)/sqrt(_drSq); - double x1=(_cross*_dy/_drSq+Node::sign(_dy)*_dx*determinant)+center[0]; - double y1=(-_cross*_dx/_drSq+fabs(_dy)*determinant)+center[1]; + double const determinant=fabs(_deltaRoot_div_dr)/sqrt(_drSq); + double const x1=(_cross*_dy/_drSq+Node::sign(_dy)*_dx*determinant)+center[0]; + double const y1=(-_cross*_dx/_drSq+fabs(_dy)*determinant)+center[1]; Node *intersect1=new Node(x1,y1); intersect1->declareOn(); - double x2=(_cross*_dy/_drSq-Node::sign(_dy)*_dx*determinant)+center[0]; - double y2=(-_cross*_dx/_drSq-fabs(_dy)*determinant)+center[1]; + double const x2=(_cross*_dy/_drSq-Node::sign(_dy)*_dx*determinant)+center[0]; + double const y2=(-_cross*_dx/_drSq-fabs(_dy)*determinant)+center[1]; Node *intersect2=new Node(x2,y2); intersect2->declareOn(); bool isN1(false), isN2(false); @@ -420,8 +429,8 @@ std::list< IntersectElement > ArcCSegIntersector::getIntersectionsCharacteristic // Which node do we actually already found? Assume this is the closest ... const Node &iN = *(_earlyInter->getNodeOnly()); const Node &n1(*intersect1), &n2(*intersect2); - double d1 = std::max(fabs(iN[0]-n1[0]), fabs(iN[1]-n1[1])); - double d2 = std::max(fabs(iN[0]-n2[0]), fabs(iN[1]-n2[1])); + double const d1 = std::max(fabs(iN[0]-n1[0]), fabs(iN[1]-n1[1])); + double const d2 = std::max(fabs(iN[0]-n2[0]), fabs(iN[1]-n2[1])); isN1 = d1 < d2; isN2 = !isN1; if (isN1) intersect1->decrRef(); if (isN2) intersect2->decrRef(); @@ -429,18 +438,18 @@ std::list< IntersectElement > ArcCSegIntersector::getIntersectionsCharacteristic } if (!isN1) { - bool i1_1S=_e1.getStartNode()->isEqual(*intersect1); - bool i1_1E=_e1.getEndNode()->isEqual(*intersect1); - bool i1_2S=_e2.getStartNode()->isEqual(*intersect1); - bool i1_2E=_e2.getEndNode()->isEqual(*intersect1); + bool const i1_1S=_e1.getStartNode()->isEqual(*intersect1); + bool const i1_1E=_e1.getEndNode()->isEqual(*intersect1); + bool const i1_2S=_e2.getStartNode()->isEqual(*intersect1); + bool const i1_2E=_e2.getEndNode()->isEqual(*intersect1); ret.push_back(IntersectElement(getE1().getCharactValue(*intersect1),getE2().getCharactValue(*intersect1),i1_1S,i1_1E,i1_2S,i1_2E,intersect1,_e1,_e2,keepOrder())); } if(!isN2) { - bool i2_1S=_e1.getStartNode()->isEqual(*intersect2); - bool i2_1E=_e1.getEndNode()->isEqual(*intersect2); - bool i2_2S=_e2.getStartNode()->isEqual(*intersect2); - bool i2_2E=_e2.getEndNode()->isEqual(*intersect2); + bool const i2_1S=_e1.getStartNode()->isEqual(*intersect2); + bool const i2_1E=_e1.getEndNode()->isEqual(*intersect2); + bool const i2_2S=_e2.getStartNode()->isEqual(*intersect2); + bool const i2_2E=_e2.getEndNode()->isEqual(*intersect2); ret.push_back(IntersectElement(getE1().getCharactValue(*intersect2),getE2().getCharactValue(*intersect2),i2_1S,i2_1E,i2_2S,i2_2E,intersect2,_e1,_e2,keepOrder())); } } @@ -451,13 +460,13 @@ std::list< IntersectElement > ArcCSegIntersector::getIntersectionsCharacteristic ret.push_back(*_earlyInter); return ret; } - double x=(_cross*_dy)/_drSq+center[0]; - double y=(-_cross*_dx)/_drSq+center[1]; + double const x=(_cross*_dy)/_drSq+center[0]; + double const y=(-_cross*_dx)/_drSq+center[1]; Node *intersect3=new Node(x,y); intersect3->declareOnTangent(); - bool i_1S=_e1.getStartNode()->isEqual(*intersect3); - bool i_1E=_e1.getEndNode()->isEqual(*intersect3); - bool i_2S=_e2.getStartNode()->isEqual(*intersect3); - bool i_2E=_e2.getEndNode()->isEqual(*intersect3); + bool const i_1S=_e1.getStartNode()->isEqual(*intersect3); + bool const i_1E=_e1.getEndNode()->isEqual(*intersect3); + bool const i_2S=_e2.getStartNode()->isEqual(*intersect3); + bool const i_2E=_e2.getEndNode()->isEqual(*intersect3); ret.push_back(IntersectElement(_e1.getCharactValue(*intersect3),_e2.getCharactValue(*intersect3),i_1S,i_1E,i_2S,i_2E,intersect3,_e1,_e2,keepOrder())); } return ret; @@ -510,11 +519,11 @@ void EdgeArcCircle::changeMiddle(Node *newMiddle) Edge *EdgeArcCircle::buildEdgeLyingOnMe(Node *start, Node *end, bool direction) const { - double sx=((*start)[0]-_center[0])/_radius; - double sy=((*start)[1]-_center[1])/_radius; - double ex=((*end)[0]-_center[0])/_radius; - double ey=((*end)[1]-_center[1])/_radius; - double angle0=GetAbsoluteAngleOfNormalizedVect(direction?sx:ex,direction?sy:ey); + double const sx=((*start)[0]-_center[0])/_radius; + double const sy=((*start)[1]-_center[1])/_radius; + double const ex=((*end)[0]-_center[0])/_radius; + double const ey=((*end)[1]-_center[1])/_radius; + double const angle0=GetAbsoluteAngleOfNormalizedVect(direction?sx:ex,direction?sy:ey); double deltaAngle=GetAbsoluteAngleOfNormalizedVect(sx*ex+sy*ey,sx*ey-sy*ex); if(deltaAngle>0. && _angle<0.) deltaAngle-=2.*M_PI; @@ -548,18 +557,18 @@ void EdgeArcCircle::unApplySimilarity(double xBary, double yBary, double dimChar void EdgeArcCircle::tesselate(const mcIdType *conn, mcIdType offset, double eps, std::vector& newConn, std::vector& addCoo) const { newConn.push_back(INTERP_KERNEL::NORM_POLYL); - int nbOfSubDiv=(int)(fabs(_angle)/eps); + int const nbOfSubDiv=(int)(fabs(_angle)/eps); if(nbOfSubDiv<=2) { newConn.push_back(conn[0]); newConn.push_back(conn[2]); newConn.push_back(conn[1]); return ; } - double signOfAngle=_angle>0.?1.:-1.; + double const signOfAngle=_angle>0.?1.:-1.; mcIdType offset2=offset+(ToIdType(addCoo.size()))/2; newConn.push_back(conn[0]); for(int i=1;idecrRef(); middle->decrRef(); end->decrRef(); - return 0; + return nullptr; } else { - EdgeArcCircle *ret=new EdgeArcCircle(start,middle,end); + auto *ret=new EdgeArcCircle(start,middle,end); start->decrRef(); middle->decrRef(); end->decrRef(); return ret; } @@ -609,14 +618,14 @@ double EdgeArcCircle::GetAbsoluteAngleOfNormalizedVect(double ux, double uy) void EdgeArcCircle::GetArcOfCirclePassingThru(const double *start, const double *middle, const double *end, double *center, double& radius, double& angleInRad, double& angleInRad0) { - double delta=(middle[0]-start[0])*(end[1]-middle[1])-(end[0]-middle[0])*(middle[1]-start[1]); - double b1=(middle[1]*middle[1]+middle[0]*middle[0]-start[0]*start[0]-start[1]*start[1])/2; - double b2=(end[1]*end[1]+end[0]*end[0]-middle[0]*middle[0]-middle[1]*middle[1])/2; + double const delta=(middle[0]-start[0])*(end[1]-middle[1])-(end[0]-middle[0])*(middle[1]-start[1]); + double const b1=(middle[1]*middle[1]+middle[0]*middle[0]-start[0]*start[0]-start[1]*start[1])/2; + double const b2=(end[1]*end[1]+end[0]*end[0]-middle[0]*middle[0]-middle[1]*middle[1])/2; center[0]=((end[1]-middle[1])*b1+(start[1]-middle[1])*b2)/delta; center[1]=((middle[0]-end[0])*b1+(middle[0]-start[0])*b2)/delta; radius=SafeSqrt((start[0]-center[0])*(start[0]-center[0])+(start[1]-center[1])*(start[1]-center[1])); angleInRad0=GetAbsoluteAngleOfNormalizedVect((start[0]-center[0])/radius,(start[1]-center[1])/radius); - double angleInRadM=GetAbsoluteAngleOfNormalizedVect((middle[0]-center[0])/radius,(middle[1]-center[1])/radius); + double const angleInRadM=GetAbsoluteAngleOfNormalizedVect((middle[0]-center[0])/radius,(middle[1]-center[1])/radius); angleInRad=GetAbsoluteAngleOfNormalizedVect(((start[0]-center[0])*(end[0]-center[0])+(start[1]-center[1])*(end[1]-center[1]))/(radius*radius), ((start[0]-center[0])*(end[1]-center[1])-(start[1]-center[1])*(end[0]-center[0]))/(radius*radius)); if(IsAngleNotIn(angleInRad0,angleInRad,angleInRadM)) @@ -690,14 +699,14 @@ void EdgeArcCircle::getBarycenter(double *bary) const */ void EdgeArcCircle::getBarycenterOfZone(double *bary) const { - double x0=_center[0]; - double y0=_center[1]; - double angle1=_angle0+_angle; - double tmp1=sin(angle1); - double tmp0=sin(_angle0); - double tmp2=_radius*_radius*_radius; - double tmp3=cos(angle1); - double tmp4=cos(_angle0); + double const x0=_center[0]; + double const y0=_center[1]; + double const angle1=_angle0+_angle; + double const tmp1=sin(angle1); + double const tmp0=sin(_angle0); + double const tmp2=_radius*_radius*_radius; + double const tmp3=cos(angle1); + double const tmp4=cos(_angle0); bary[0]=_radius*x0*y0*(tmp4-tmp3)+_radius*_radius*(y0*(cos(2*_angle0)-cos(2*angle1))/4.+ x0*(_angle/2.+(sin(2.*_angle0)-sin(2.*angle1))/4.)) +tmp2*(tmp1*tmp1*tmp1-tmp0*tmp0*tmp0)/3.; @@ -794,16 +803,16 @@ bool EdgeArcCircle::isLower(double val1, double val2) const */ double EdgeArcCircle::getCharactValue(const Node& node) const { - double dx=(node[0]-_center[0])/_radius; - double dy=(node[1]-_center[1])/_radius; + double const dx=(node[0]-_center[0])/_radius; + double const dy=(node[1]-_center[1])/_radius; return GetAbsoluteAngleOfNormalizedVect(dx,dy); } double EdgeArcCircle::getCharactValueBtw0And1(const Node& node) const { - double dx=(node[0]-_center[0])/_radius; - double dy=(node[1]-_center[1])/_radius; - double angle=GetAbsoluteAngleOfNormalizedVect(dx,dy); + double const dx=(node[0]-_center[0])/_radius; + double const dy=(node[1]-_center[1])/_radius; + double const angle=GetAbsoluteAngleOfNormalizedVect(dx,dy); // double myDelta=angle-_angle0; if(_angle>0.) @@ -815,23 +824,23 @@ double EdgeArcCircle::getCharactValueBtw0And1(const Node& node) const double EdgeArcCircle::getDistanceToPoint(const double *pt) const { - double angle=Node::computeAngle(_center,pt); + double const angle=Node::computeAngle(_center,pt); if(IsIn2Pi(_angle0,_angle,angle)) return fabs(Node::distanceBtw2Pt(_center,pt)-_radius); else { - double dist1=Node::distanceBtw2Pt(*_start,pt); - double dist2=Node::distanceBtw2Pt(*_end,pt); + double const dist1=Node::distanceBtw2Pt(*_start,pt); + double const dist2=Node::distanceBtw2Pt(*_end,pt); return std::min(dist1,dist2); } } bool EdgeArcCircle::isNodeLyingOn(const double *coordOfNode) const { - double dist=Node::distanceBtw2Pt(_center,coordOfNode); + double const dist=Node::distanceBtw2Pt(_center,coordOfNode); if(Node::areDoubleEquals(dist,_radius)) { - double angle=Node::computeAngle(_center,coordOfNode); + double const angle=Node::computeAngle(_center,coordOfNode); return IsIn2Pi(_angle0,_angle,angle); } else diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeArcCircle.hxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeArcCircle.hxx index 627bcbb33..f4c86e117 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeArcCircle.hxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeArcCircle.hxx @@ -22,8 +22,17 @@ #define __INTERPKERNELGEO2DEDGEARCCIRCLE_HXX__ #include "INTERPKERNELDefines.hxx" +#include "InterpKernelGeo2DBounds.hxx" #include "InterpKernelGeo2DEdge.hxx" +#include "InterpKernelGeo2DNode.hxx" #include "MCIdType.hxx" +#include +#include +#include +#include +#include +#include +#include namespace INTERP_KERNEL { @@ -31,11 +40,11 @@ namespace INTERP_KERNEL { public: ArcCArcCIntersector(const EdgeArcCircle& e1, const EdgeArcCircle& e2); - bool haveTheySameDirection() const; - bool areColinears() const; - void getPlacements(Node *start, Node *end, TypeOfLocInEdge& whereStart, TypeOfLocInEdge& whereEnd, MergePoints& commonNode) const; - void areOverlappedOrOnlyColinears(bool& obviousNoIntersection, bool& areOverlapped); - std::list< IntersectElement > getIntersectionsCharacteristicVal() const; + bool haveTheySameDirection() const override; + bool areColinears() const override; + void getPlacements(Node *start, Node *end, TypeOfLocInEdge& whereStart, TypeOfLocInEdge& whereEnd, MergePoints& commonNode) const override; + void areOverlappedOrOnlyColinears(bool& obviousNoIntersection, bool& areOverlapped) override; + std::list< IntersectElement > getIntersectionsCharacteristicVal() const override; private: //! return angle in ]-Pi;Pi[ - 'node' must be on curve of '_e1' double getAngle(Node *node) const; @@ -56,10 +65,10 @@ namespace INTERP_KERNEL public: ArcCSegIntersector(const EdgeArcCircle& e1, const EdgeLin& e2, bool reverse=true); //virtual overloading - bool areColinears() const; - void getPlacements(Node *start, Node *end, TypeOfLocInEdge& whereStart, TypeOfLocInEdge& whereEnd, MergePoints& commonNode) const; - void areOverlappedOrOnlyColinears(bool& obviousNoIntersection, bool& areOverlapped); - std::list< IntersectElement > getIntersectionsCharacteristicVal() const; + bool areColinears() const override; + void getPlacements(Node *start, Node *end, TypeOfLocInEdge& whereStart, TypeOfLocInEdge& whereEnd, MergePoints& commonNode) const override; + void areOverlappedOrOnlyColinears(bool& obviousNoIntersection, bool& areOverlapped) override; + std::list< IntersectElement > getIntersectionsCharacteristicVal() const override; private: const EdgeArcCircle& getE1() const { return (const EdgeArcCircle&)_e1; } const EdgeLin& getE2() const { return (const EdgeLin&)_e2; } @@ -81,29 +90,29 @@ namespace INTERP_KERNEL EdgeArcCircle(Node *start, Node *end, const double *center, double radius, double angle0, double deltaAngle, bool direction=true); //! for tests void changeMiddle(Node *newMiddle); - void dumpInXfigFile(std::ostream& stream, bool direction, int resolution, const Bounds& box) const; - void update(Node *m); - double getAreaOfZone() const; - double getCurveLength() const; - void getBarycenter(double *bary) const; - void getBarycenterOfZone(double *bary) const; - void getMiddleOfPoints(const double *p1, const double *p2, double *mid) const; - void getMiddleOfPointsOriented(const double *p1, const double *p2, double *mid) const; - bool isIn(double characterVal) const; - Node *buildRepresentantOfMySelf() const; - bool isLower(double val1, double val2) const; - double getCharactValue(const Node& node) const; - double getCharactValueBtw0And1(const Node& node) const; - double getDistanceToPoint(const double *pt) const; - bool isNodeLyingOn(const double *coordOfNode) const; - TypeOfFunction getTypeOfFunc() const { return ARC_CIRCLE; } - void dynCastFunction(const EdgeLin * &seg, - const EdgeArcCircle * &arcSeg) const { arcSeg=this; } + void dumpInXfigFile(std::ostream& stream, bool direction, int resolution, const Bounds& box) const override; + void update(Node *m) override; + double getAreaOfZone() const override; + double getCurveLength() const override; + void getBarycenter(double *bary) const override; + void getBarycenterOfZone(double *bary) const override; + void getMiddleOfPoints(const double *p1, const double *p2, double *mid) const override; + void getMiddleOfPointsOriented(const double *p1, const double *p2, double *mid) const override; + bool isIn(double characterVal) const override; + Node *buildRepresentantOfMySelf() const override; + bool isLower(double val1, double val2) const override; + double getCharactValue(const Node& node) const override; + double getCharactValueBtw0And1(const Node& node) const override; + double getDistanceToPoint(const double *pt) const override; + bool isNodeLyingOn(const double *coordOfNode) const override; + TypeOfFunction getTypeOfFunc() const override { return ARC_CIRCLE; } + void dynCastFunction(const EdgeLin * & /*seg*/, + const EdgeArcCircle * &arcSeg) const override { arcSeg=this; } const double *getCenter() const { return _center; } void getCenter(double *center) const { center[0]=_center[0]; center[1]=_center[1]; } - bool doIHaveSameDirectionAs(const Edge& other) const { return false; } - void applySimilarity(double xBary, double yBary, double dimChar); - void unApplySimilarity(double xBary, double yBary, double dimChar); + bool doIHaveSameDirectionAs(const Edge& /*other*/) const { return false; } + void applySimilarity(double xBary, double yBary, double dimChar) override; + void unApplySimilarity(double xBary, double yBary, double dimChar) override; double getAngle0() const { return _angle0; } double getRadius() const { return _radius; } double getAngle() const { return _angle; } @@ -114,7 +123,7 @@ namespace INTERP_KERNEL static void GetArcOfCirclePassingThru(const double *start, const double *middle, const double *end, double *center, double& radius, double& angleInRad, double& angleInRad0); //! To avoid in aggressive optimizations nan. - static double SafeSqrt(double val) { double ret=std::max(val,0.); return sqrt(ret); } + static double SafeSqrt(double val) { double const ret=std::max(val,0.); return sqrt(ret); } static double SafeAcos(double cosAngle) { double ret=std::min(cosAngle,1.); ret=std::max(ret,-1.); return acos(ret); } static double SafeAsin(double sinAngle) { double ret=std::min(sinAngle,1.); ret=std::max(ret,-1.); return asin(ret); } //! @param start and @param angleIn in ]-Pi;Pi] and @param delta in ]-2*Pi,2*Pi[ @@ -125,7 +134,7 @@ namespace INTERP_KERNEL static double NormalizeAngle(double angle) { if(angle>M_PI) return angle-2.*M_PI; if(angle<-M_PI) return angle+2.*M_PI; return angle; } protected: void updateBounds(); - Edge *buildEdgeLyingOnMe(Node *start, Node *end, bool direction=true) const; + Edge *buildEdgeLyingOnMe(Node *start, Node *end, bool direction=true) const override; protected: //! Absolute angle where the arc starts. Value between -Pi and Pi diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeInfLin.cxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeInfLin.cxx index bd3b45ac2..294840ada 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeInfLin.cxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeInfLin.cxx @@ -19,6 +19,8 @@ // Author : Anthony Geay (CEA/DEN) #include "InterpKernelGeo2DEdgeInfLin.hxx" +#include "InterpKernelGeo2DNode.hxx" +#include using namespace INTERP_KERNEL; diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeInfLin.hxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeInfLin.hxx index 13aa21895..4d36d69ba 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeInfLin.hxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeInfLin.hxx @@ -21,7 +21,9 @@ #ifndef __INTERPKERNELGEO2DEDGEINFLIN_HXX__ #define __INTERPKERNELGEO2DEDGEINFLIN_HXX__ +#include "InterpKernelGeo2DEdge.hxx" #include "InterpKernelGeo2DEdgeLin.hxx" +#include "InterpKernelGeo2DNode.hxx" namespace INTERP_KERNEL { @@ -30,11 +32,11 @@ namespace INTERP_KERNEL public: EdgeInfLin(Node *start, Node *end):EdgeLin(start,end,true) { } EdgeInfLin(Node *pointPassingThrough, double slope); - bool isIn(double characterVal) const { return true; } + bool isIn(double /*characterVal*/) const override { return true; } void dynCastFunction(const EdgeLin * &seg, - const EdgeArcCircle * &arcSeg) const { seg=this; } + const EdgeArcCircle * & /*arcSeg*/) const override { seg=this; } protected: - ~EdgeInfLin() { } + ~EdgeInfLin() override = default; }; } diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeLin.cxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeLin.cxx index a1044f94e..695e5d463 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeLin.cxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeLin.cxx @@ -19,9 +19,14 @@ // Author : Anthony Geay (CEA/DEN) #include "InterpKernelGeo2DEdgeLin.hxx" +#include "InterpKernelGeo2DEdge.hxx" #include "InterpKernelGeo2DNode.hxx" -#include "InterpKernelException.hxx" -#include "NormalizedUnstructuredMesh.hxx" +#include "InterpKernelGeo2DPrecision.hxx" +#include +#include +#include +#include +#include using namespace INTERP_KERNEL; @@ -73,7 +78,7 @@ void SegSegIntersector::getCurveAbscisse(Node *node, TypeOfLocInEdge& where, Mer obviousCaseForCurvAbscisse(node,where,commonNode,obvious); if(obvious) return ; - double ret=((*node)[!_ind]-(*_e1.getStartNode())[!_ind])/((*_e1.getEndNode())[!_ind]-(*_e1.getStartNode())[!_ind]); + double const ret=((*node)[!_ind]-(*_e1.getStartNode())[!_ind])/((*_e1.getEndNode())[!_ind]-(*_e1.getStartNode())[!_ind]); if(ret>0. && ret <1.) where=INSIDE; else if(ret<0.) @@ -95,15 +100,15 @@ std::list< IntersectElement > SegSegIntersector::getIntersectionsCharacteristicV return ret; } - double x= (-_matrix[2]*_col[0]+_matrix[0]*_col[1]) / _determinant; - double y= (-_matrix[3]*_col[0]+_matrix[1]*_col[1]) / _determinant; + double const x= (-_matrix[2]*_col[0]+_matrix[0]*_col[1]) / _determinant; + double const y= (-_matrix[3]*_col[0]+_matrix[1]*_col[1]) / _determinant; //Only one intersect point possible Node *node=new Node(x,y); node->declareOn(); - bool i_1S=_e1.getStartNode()->isEqual(*node); - bool i_1E=_e1.getEndNode()->isEqual(*node); - bool i_2S=_e2.getStartNode()->isEqual(*node); - bool i_2E=_e2.getEndNode()->isEqual(*node); + bool const i_1S=_e1.getStartNode()->isEqual(*node); + bool const i_1E=_e1.getEndNode()->isEqual(*node); + bool const i_2S=_e2.getStartNode()->isEqual(*node); + bool const i_2E=_e2.getEndNode()->isEqual(*node); ret.push_back(IntersectElement(_e1.getCharactValue(*node), _e2.getCharactValue(*node), i_1S,i_1E,i_2S,i_2E,node,_e1,_e2,keepOrder())); @@ -157,15 +162,15 @@ void SegSegIntersector::areOverlappedOrOnlyColinears(bool& obviousNoIntersection else // Colinear vectors { // Compute vectors joining tips of e1 and e2 - double xS=(*(_e1.getStartNode()))[0]-(*(_e2.getStartNode()))[0]; - double yS=(*(_e1.getStartNode()))[1]-(*(_e2.getStartNode()))[1]; - double xE=(*(_e1.getEndNode()))[0]-(*(_e2.getEndNode()))[0]; - double yE=(*(_e1.getEndNode()))[1]-(*(_e2.getEndNode()))[1]; + double const xS=(*(_e1.getStartNode()))[0]-(*(_e2.getStartNode()))[0]; + double const yS=(*(_e1.getStartNode()))[1]-(*(_e2.getStartNode()))[1]; + double const xE=(*(_e1.getEndNode()))[0]-(*(_e2.getEndNode()))[0]; + double const yE=(*(_e1.getEndNode()))[1]-(*(_e2.getEndNode()))[1]; double maxDimS(std::max(fabs(xS),fabs(yS))), maxDimE(std::max(fabs(xE), fabs(yE))); bool isS = (maxDimS > maxDimE), isE1 = (dimCharE1 >= dimCharE2); - double x = isS ? xS : xE; - double y = isS ? yS : yE; - unsigned shift = isE1 ? 0 : 2; + double const x = isS ? xS : xE; + double const y = isS ? yS : yE; + unsigned const shift = isE1 ? 0 : 2; // test colinearity of the greatest tip-joining vector and greatest vector among {e1, e2} areOverlapped = fabs(x*_matrix[1+shift]-y*_matrix[0+shift]) < dimCharE1*dimCharE2*QuadraticPlanarPrecision::getPrecision(); // explanation: if areOverlapped is true, we don't know yet if there will be an intersection (see meaning of areOverlapped in method doxy above) @@ -194,8 +199,7 @@ EdgeLin::EdgeLin(double sX, double sY, double eX, double eY):Edge(sX,sY,eX,eY) } EdgeLin::~EdgeLin() -{ -} += default; /*! * Characteristic for edges is relative position btw 0.;1. @@ -222,7 +226,7 @@ double EdgeLin::getCharactValueBtw0And1(const Node& node) const double EdgeLin::getDistanceToPoint(const double *pt) const { - double loc=getCharactValueEng(pt); + double const loc=getCharactValueEng(pt); if(loc>0. && loc<1.) { double tmp[2]; @@ -232,15 +236,15 @@ double EdgeLin::getDistanceToPoint(const double *pt) const } else { - double dist1=Node::distanceBtw2Pt(*_start,pt); - double dist2=Node::distanceBtw2Pt(*_end,pt); + double const dist1=Node::distanceBtw2Pt(*_start,pt); + double const dist2=Node::distanceBtw2Pt(*_end,pt); return std::min(dist1,dist2); } } bool EdgeLin::isNodeLyingOn(const double *coordOfNode) const { - double dBase=sqrt(_start->distanceWithSq(*_end)); + double const dBase=sqrt(_start->distanceWithSq(*_end)); double d1=Node::distanceBtw2Pt(*_start,coordOfNode); d1+=Node::distanceBtw2Pt(*_end,coordOfNode); return Node::areDoubleEquals(dBase,d1); @@ -256,7 +260,7 @@ void EdgeLin::dumpInXfigFile(std::ostream& stream, bool direction, int resolutio stream << std::endl; } -void EdgeLin::update(Node *m) +void EdgeLin::update(Node * /*m*/) { updateBounds(); } @@ -297,10 +301,10 @@ void EdgeLin::getBarycenter(double *bary) const */ void EdgeLin::getBarycenterOfZone(double *bary) const { - double x1=(*_start)[0]; - double y1=(*_start)[1]; - double x2=(*_end)[0]; - double y2=(*_end)[1]; + double const x1=(*_start)[0]; + double const y1=(*_start)[1]; + double const x2=(*_end)[0]; + double const y2=(*_end)[1]; bary[0]=(x1-x2)*(y1*(2.*x1+x2)+y2*(2.*x2+x1))/6.; //bary[0]+=(y1-y2)*(x2*x2/3.-(x1*x2+x1*x1)/6.)+y1*(x1*x1-x2*x2)/2.; //bary[0]+=(y1-y2)*((x2*x2+x1*x2+x1*x1)/3.-(x2+x1)*x1/2.)+y1*(x1*x1-x2*x2)/2.; @@ -318,8 +322,8 @@ void EdgeLin::getMiddleOfPoints(const double *p1, const double *p2, double *mid) double EdgeLin::getCurveLength() const { - double x=(*_start)[0]-(*_end)[0]; - double y=(*_start)[1]-(*_end)[1]; + double const x=(*_start)[0]-(*_end)[0]; + double const y=(*_start)[1]-(*_end)[1]; return sqrt(x*x+y*y); } @@ -338,7 +342,7 @@ void EdgeLin::updateBounds() double EdgeLin::getCharactValueEng(const double *node) const { - double car1_1x=node[0]-(*(_start))[0]; double car1_2x=(*(_end))[0]-(*(_start))[0]; - double car1_1y=node[1]-(*(_start))[1]; double car1_2y=(*(_end))[1]-(*(_start))[1]; + double const car1_1x=node[0]-(*(_start))[0]; double const car1_2x=(*(_end))[0]-(*(_start))[0]; + double const car1_1y=node[1]-(*(_start))[1]; double const car1_2y=(*(_end))[1]-(*(_start))[1]; return (car1_1x*car1_2x+car1_1y*car1_2y)/(car1_2x*car1_2x+car1_2y*car1_2y); } diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeLin.hxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeLin.hxx index dca0e1d08..0c7408f0c 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeLin.hxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdgeLin.hxx @@ -22,7 +22,12 @@ #define __INTERPKERNELGEO2DEDGELIN_HXX__ #include "INTERPKERNELDefines.hxx" +#include "InterpKernelGeo2DBounds.hxx" #include "InterpKernelGeo2DEdge.hxx" +#include "InterpKernelGeo2DNode.hxx" +#include +#include +#include namespace INTERP_KERNEL { @@ -31,11 +36,11 @@ namespace INTERP_KERNEL friend class Edge; public: SegSegIntersector(const EdgeLin& e1, const EdgeLin& e2); - bool areColinears() const; - bool haveTheySameDirection() const; - void getPlacements(Node *start, Node *end, TypeOfLocInEdge& whereStart, TypeOfLocInEdge& whereEnd, MergePoints& commonNode) const; - void areOverlappedOrOnlyColinears(bool& obviousNoIntersection, bool& areOverlapped); - std::list< IntersectElement > getIntersectionsCharacteristicVal() const; + bool areColinears() const override; + bool haveTheySameDirection() const override; + void getPlacements(Node *start, Node *end, TypeOfLocInEdge& whereStart, TypeOfLocInEdge& whereEnd, MergePoints& commonNode) const override; + void areOverlappedOrOnlyColinears(bool& obviousNoIntersection, bool& areOverlapped) override; + std::list< IntersectElement > getIntersectionsCharacteristicVal() const override; private: void getCurveAbscisse(Node *node, TypeOfLocInEdge& where, MergePoints& commonNode) const; private: @@ -53,31 +58,31 @@ namespace INTERP_KERNEL EdgeLin(std::istream& lineInXfig); EdgeLin(Node *start, Node *end, bool direction=true); EdgeLin(double sX, double sY, double eX, double eY); - ~EdgeLin(); - TypeOfFunction getTypeOfFunc() const { return SEG; } - void dumpInXfigFile(std::ostream& stream, bool direction, int resolution, const Bounds& box) const; - void update(Node *m); + ~EdgeLin() override; + TypeOfFunction getTypeOfFunc() const override { return SEG; } + void dumpInXfigFile(std::ostream& stream, bool direction, int resolution, const Bounds& box) const override; + void update(Node *m) override; double getNormSq() const; - double getAreaOfZone() const; - double getCurveLength() const; - void getBarycenter(double *bary) const; - void getBarycenterOfZone(double *bary) const; - void getMiddleOfPoints(const double *p1, const double *p2, double *mid) const; - bool isIn(double characterVal) const; - Node *buildRepresentantOfMySelf() const; - double getCharactValue(const Node& node) const; - double getCharactValueBtw0And1(const Node& node) const; - double getDistanceToPoint(const double *pt) const; - bool isNodeLyingOn(const double *coordOfNode) const; - bool isLower(double val1, double val2) const { return val1 +#include "InterpKernelGeo2DNode.hxx" +#include +#include +#include "MCIdType.hxx" +#include using namespace INTERP_KERNEL; diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DElementaryEdge.hxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DElementaryEdge.hxx index 22ca3b4c3..9b710a444 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DElementaryEdge.hxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DElementaryEdge.hxx @@ -22,9 +22,13 @@ #define __INTERPKERNELGEO2DELEMENTARYEDGE_HXX__ #include "INTERPKERNELDefines.hxx" -#include "InterpKernelException.hxx" #include "InterpKernelGeo2DAbstractEdge.hxx" #include "InterpKernelGeo2DEdge.hxx" +#include +#include +#include +#include "MCIdType.hxx" +#include namespace INTERP_KERNEL { @@ -44,7 +48,7 @@ namespace INTERP_KERNEL INTERPKERNEL_EXPORT Edge *getPtr() const { return _ptr; } INTERPKERNEL_EXPORT void reverse() { _direction=(!_direction); } INTERPKERNEL_EXPORT bool isNodeIn(Node *n) const; - INTERPKERNEL_EXPORT double getAreaOfZone() const { double ret=_ptr->getAreaOfZone(); return _direction?ret:-ret; } + INTERPKERNEL_EXPORT double getAreaOfZone() const { double const ret=_ptr->getAreaOfZone(); return _direction?ret:-ret; } INTERPKERNEL_EXPORT void getBarycenterOfZone(double *bary) const; INTERPKERNEL_EXPORT void fillBounds(Bounds& output) const; INTERPKERNEL_EXPORT void applySimilarity(double xBary, double yBary, double dimChar) { _ptr->applySimilarity(xBary,yBary,dimChar); } diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DNode.cxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DNode.cxx index 57c6c977c..9ca2ab366 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DNode.cxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DNode.cxx @@ -20,6 +20,15 @@ #include "InterpKernelGeo2DNode.hxx" #include "InterpKernelGeo2DEdgeArcCircle.hxx" +#include +#include +#include +#include +#include +#include +#include "MCIdType.hxx" +#include +#include using namespace INTERP_KERNEL; @@ -44,12 +53,11 @@ Node::Node(std::istream& stream):_cnt(1),_loc(UNKNOWN) } Node::~Node() -{ -} += default; bool Node::decrRef() { - bool ret=(--_cnt==0); + bool const ret=(--_cnt==0); if(ret) delete this; return ret; @@ -75,7 +83,7 @@ double Node::getSlope(const Node& other) const */ bool Node::isEqualAndKeepTrack(const Node& other, std::vector& track) const { - bool ret=isEqual(other); + bool const ret=isEqual(other); if(ret) track.push_back(const_cast(&other)); return ret; @@ -98,10 +106,10 @@ double Node::distanceWithSq(const Node& other) const */ double Node::computeSlope(const double *pt1, const double *pt2) { - double x=pt2[0]-pt1[0]; - double y=pt2[1]-pt1[1]; - double norm=sqrt(x*x+y*y); - double ret=EdgeArcCircle::SafeAcos(fabs(x)/norm); + double const x=pt2[0]-pt1[0]; + double const y=pt2[1]-pt1[1]; + double const norm=sqrt(x*x+y*y); + double const ret=EdgeArcCircle::SafeAcos(fabs(x)/norm); if( (x>=0. && y>=0.) || (x<0. && y<0.) ) return ret; else @@ -114,9 +122,9 @@ double Node::computeSlope(const double *pt1, const double *pt2) */ double Node::computeAngle(const double *pt1, const double *pt2) { - double x=pt2[0]-pt1[0]; - double y=pt2[1]-pt1[1]; - double norm=sqrt(x*x+y*y); + double const x=pt2[0]-pt1[0]; + double const y=pt2[1]-pt1[1]; + double const norm=sqrt(x*x+y*y); return EdgeArcCircle::GetAbsoluteAngleOfNormalizedVect(x/norm,y/norm); } @@ -151,7 +159,7 @@ void Node::unApplySimilarity(double xBary, double yBary, double dimChar) void Node::fillGlobalInfoAbs(const std::map& mapThis, const std::map& mapOther, mcIdType offset1, mcIdType offset2, double fact, double baryX, double baryY, std::vector& addCoo, std::map& mapAddCoo, mcIdType *nodeId) const { - std::map::const_iterator it=mapOther.find(const_cast(this)); + auto it=mapOther.find(const_cast(this)); if(it!=mapOther.end()) // order matters, try in mapOther first. { *nodeId=(*it).second+offset1; @@ -169,7 +177,7 @@ void Node::fillGlobalInfoAbs(const std::map& map *nodeId=(*it).second; return; } - int id=(int)addCoo.size()/2; + int const id=(int)addCoo.size()/2; addCoo.push_back(fact*_coords[0]+baryX); addCoo.push_back(fact*_coords[1]+baryY); *nodeId=offset2+id; @@ -183,7 +191,7 @@ void Node::fillGlobalInfoAbs2(const std::map& ma std::vector& addCoo, std::map& mapAddCoo, std::vector& pointsOther) const { mcIdType tmp; - std::size_t sz1=addCoo.size(); + std::size_t const sz1=addCoo.size(); fillGlobalInfoAbs(mapThis,mapOther,offset1,offset2,fact,baryX,baryY,addCoo,mapAddCoo,&tmp); if(sz1!=addCoo.size() // newly created point || (tmp >= offset2 // or previously created point merged with a neighbour @@ -192,7 +200,7 @@ void Node::fillGlobalInfoAbs2(const std::map& ma pointsOther.push_back(tmp); return ; } - std::vector::const_iterator it=std::find(pointsOther.begin(),pointsOther.end(),tmp); + std::vector::const_iterator const it=std::find(pointsOther.begin(),pointsOther.end(),tmp); if(it!=pointsOther.end()) return ; pointsOther.push_back(tmp); diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.cxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.cxx index a1f38483d..18d7d2048 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.cxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.cxx @@ -19,20 +19,35 @@ // Author : Anthony Geay (CEA/DEN) #include "InterpKernelGeo2DQuadraticPolygon.hxx" +#include "InterpKernelGeo2DEdge.hxx" #include "InterpKernelGeo2DElementaryEdge.hxx" #include "InterpKernelGeo2DEdgeArcCircle.hxx" #include "InterpKernelGeo2DAbstractEdge.hxx" #include "InterpKernelGeo2DEdgeLin.hxx" #include "InterpKernelGeo2DBounds.hxx" -#include "InterpKernelGeo2DEdge.txx" +#include "NormalizedGeometricTypes" -#include "NormalizedUnstructuredMesh.hxx" +#include "MCIdType.hxx" +#include "InterpKernelGeo2DNode.hxx" +#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include #include #include #include #include +#include +#include +#include using namespace INTERP_KERNEL; @@ -58,7 +73,7 @@ QuadraticPolygon::QuadraticPolygon(const char *file) newEdge->changeStartNodeWith(back()->getEndNode()); pushBack(newEdge); } - while(1); + while(true); } catch(const std::ifstream::failure&) { @@ -82,13 +97,12 @@ QuadraticPolygon::QuadraticPolygon(const char *file) } QuadraticPolygon::~QuadraticPolygon() -{ -} += default; QuadraticPolygon *QuadraticPolygon::BuildLinearPolygon(std::vector& nodes) { - QuadraticPolygon *ret(new QuadraticPolygon); - std::size_t size=nodes.size(); + auto *ret(new QuadraticPolygon); + std::size_t const size=nodes.size(); for(std::size_t i=0;ipushBack(new EdgeLin(nodes[i],nodes[(i+1)%size])); @@ -99,16 +113,16 @@ QuadraticPolygon *QuadraticPolygon::BuildLinearPolygon(std::vector& node QuadraticPolygon *QuadraticPolygon::BuildArcCirclePolygon(std::vector& nodes) { - QuadraticPolygon *ret(new QuadraticPolygon); - std::size_t size=nodes.size(); + auto *ret(new QuadraticPolygon); + std::size_t const size=nodes.size(); for(std::size_t i=0;ipushBack(new EdgeLin(nodes[i],nodes[(i+1)%(size/2)])); @@ -132,11 +146,11 @@ Edge *QuadraticPolygon::BuildArcCircleEdge(std::vector& nodes) { if(nodes.size()!=3) throw INTERP_KERNEL::Exception("QuadraticPolygon::BuildArcCircleEdge : input vector is expected to be of size 3 !"); - EdgeLin *e1(new EdgeLin(nodes[0],nodes[2])),*e2(new EdgeLin(nodes[2],nodes[1])); - SegSegIntersector inters(*e1,*e2); - bool colinearity=inters.areColinears(); + auto *e1(new EdgeLin(nodes[0],nodes[2])),*e2(new EdgeLin(nodes[2],nodes[1])); + SegSegIntersector const inters(*e1,*e2); + bool const colinearity=inters.areColinears(); delete e1; delete e2; - Edge *ret(0); + Edge *ret(nullptr); if(colinearity) ret=new EdgeLin(nodes[0],nodes[1]); else @@ -150,7 +164,7 @@ void QuadraticPolygon::BuildDbgFile(const std::vector& nodes, const char std::ofstream file(fileName); file << std::setprecision(16); file << " double coords[]=" << std::endl << " { "; - for(std::vector::const_iterator iter=nodes.begin();iter!=nodes.end();iter++) + for(auto iter=nodes.begin();iter!=nodes.end();iter++) { if(iter!=nodes.begin()) file << "," << std::endl << " "; @@ -181,7 +195,7 @@ bool QuadraticPolygon::isButterflyAbs() double xBary,yBary; b.prepareForAggregation(); fillBounds(b); - double dimChar=b.getCaracteristicDim(); + double const dimChar=b.getCaracteristicDim(); b.getBarycenter(xBary,yBary); applyGlobalSimilarity(xBary,yBary,dimChar); // @@ -190,16 +204,16 @@ bool QuadraticPolygon::isButterflyAbs() bool QuadraticPolygon::isButterfly() const { - for(std::list::const_iterator it=_sub_edges.begin();it!=_sub_edges.end();it++) + for(auto it=_sub_edges.begin();it!=_sub_edges.end();it++) { Edge *e1=(*it)->getPtr(); - std::list::const_iterator it2=it; + auto it2=it; it2++; for(;it2!=_sub_edges.end();it2++) { MergePoints commonNode; - ComposedEdge *outVal1=new ComposedEdge; - ComposedEdge *outVal2=new ComposedEdge; + auto *outVal1=new ComposedEdge; + auto *outVal2=new ComposedEdge; Edge *e2=(*it2)->getPtr(); if(e1->intersectWith(e2,commonNode,*outVal1,*outVal2)) { @@ -256,12 +270,12 @@ void QuadraticPolygon::dumpInXfigFile(std::ostream& stream, int resolution, cons double QuadraticPolygon::intersectWithAbs(QuadraticPolygon& other) { double ret=0.,xBaryBB,yBaryBB; - double fact=normalize(&other,xBaryBB,yBaryBB); - std::vector polygs=intersectMySelfWith(other); - for(std::vector::iterator iter=polygs.begin();iter!=polygs.end();iter++) + double const fact=normalize(&other,xBaryBB,yBaryBB); + std::vector const polygs=intersectMySelfWith(other); + for(auto & polyg : polygs) { - ret+=fabs((*iter)->getArea()); - delete *iter; + ret+=fabs(polyg->getArea()); + delete polyg; } return ret*fact*fact; } @@ -292,13 +306,13 @@ void QuadraticPolygon::splitAbs(QuadraticPolygon& other, std::vector& addCoo, std::map& mergedNodes) { double xBaryBB, yBaryBB; - double fact=normalizeExt(&other, xBaryBB, yBaryBB); + double const fact=normalizeExt(&other, xBaryBB, yBaryBB); // IteratorOnComposedEdge itThis(this),itOther(&other); // other is (part of) the tool mesh MergePoints merge; - ComposedEdge *cThis=new ComposedEdge; - ComposedEdge *cOther=new ComposedEdge; + auto *cThis=new ComposedEdge; + auto *cOther=new ComposedEdge; int i=0; std::map mapAddCoo; for(itOther.first();!itOther.finished();itOther.next(),i++) @@ -322,7 +336,7 @@ void QuadraticPolygon::splitAbs(QuadraticPolygon& other, ElementaryEdge* curThis=itThis.current(); merge.clear(); // - std::map::const_iterator thisStart(mapThis.find(curThis->getStartNode())),thisEnd(mapThis.find(curThis->getEndNode())), + auto thisStart(mapThis.find(curThis->getStartNode())),thisEnd(mapThis.find(curThis->getEndNode())), otherStart(mapOther.find(curOtherTmp->getStartNode())),otherEnd(mapOther.find(curOtherTmp->getEndNode())); mcIdType thisStart2(thisStart==mapThis.end()?-1:(*thisStart).second), thisEnd2(thisEnd==mapThis.end()?-1:(*thisEnd).second), otherStart2(otherStart==mapOther.end()?-1:(*otherStart).second+offset1),otherEnd2(otherEnd==mapOther.end()?-1:(*otherEnd).second+offset1); @@ -365,7 +379,7 @@ void QuadraticPolygon::splitAbs(QuadraticPolygon& other, std::size_t jj = 0, sz(otherTmp._sub_edges.size()); for(std::list::const_iterator it=otherTmp._sub_edges.begin();it!=otherTmp._sub_edges.end();it++, jj++) { - short skipStartOrEnd = jj == 0 ? -1 : (jj == sz-1 ? 1 : 0); // -1 means START, 1 means END, 0 other + short const skipStartOrEnd = jj == 0 ? -1 : (jj == sz-1 ? 1 : 0); // -1 means START, 1 means END, 0 other (*it)->fillGlobalInfoAbs2(mapThis,mapOther,offset1,offset2, fact,xBaryBB,yBaryBB, skipStartOrEnd, /*out*/ subDivOther[otherEdgeIds[i]],addCoo,mapAddCoo); @@ -389,7 +403,7 @@ void QuadraticPolygon::splitAbs(QuadraticPolygon& other, void QuadraticPolygon::buildFromCrudeDataArray(const std::map& mapp, bool isQuad, const mcIdType *nodalBg, const double *coords, const mcIdType *descBg, const mcIdType *descEnd, const std::vector >& intersectEdges) { - std::size_t nbOfSeg=std::distance(descBg,descEnd); + std::size_t const nbOfSeg=std::distance(descBg,descEnd); for(std::size_t i=0;i0; - mcIdType edgeId=std::abs(descBg[edgePos])-1; // back to C indexing mode + bool const direct=descBg[edgePos]>0; + mcIdType const edgeId=std::abs(descBg[edgePos])-1; // back to C indexing mode const std::vector& subEdge=intersectEdges[edgeId]; - std::size_t nbOfSubEdges=subEdge.size()/2; + std::size_t const nbOfSubEdges=subEdge.size()/2; for(std::size_t j=0;j0; - mcIdType edgeId=std::abs(descBg[edgePos])-1; + bool const direct=descBg[edgePos]>0; + mcIdType const edgeId=std::abs(descBg[edgePos])-1; const std::vector& subEdge=intersectEdges[edgeId]; - std::size_t nbOfSubEdges=subEdge.size()/2; + std::size_t const nbOfSubEdges=subEdge.size()/2; if(colinearity) { for(std::size_t j=0;j& subEdge, const std::map& mapp) +void QuadraticPolygon::appendSubEdgeFromCrudeDataArray(Edge *baseEdge, std::size_t j, bool direct, mcIdType /*edgeId*/, const std::vector& subEdge, const std::map& mapp) { - std::size_t nbOfSubEdges=subEdge.size()/2; + std::size_t const nbOfSubEdges=subEdge.size()/2; if(!baseEdge) {//it is not a quadratic subedge Node *start=(*mapp.find(direct?subEdge[2*j]:subEdge[2*nbOfSubEdges-2*j-1])).second; @@ -460,7 +474,7 @@ void QuadraticPolygon::appendSubEdgeFromCrudeDataArray(Edge *baseEdge, std::size Node *start=(*mapp.find(direct?subEdge[2*j]:subEdge[2*nbOfSubEdges-2*j-1])).second; Node *end=(*mapp.find(direct?subEdge[2*j+1]:subEdge[2*nbOfSubEdges-2*j-2])).second; Edge *ee=baseEdge->buildEdgeLyingOnMe(start,end); - ElementaryEdge *eee=new ElementaryEdge(ee,true); + auto *eee=new ElementaryEdge(ee,true); pushBack(eee); } } @@ -474,27 +488,27 @@ void QuadraticPolygon::buildFromCrudeDataArray2(const std::map >& colinear1, std::map >& alreadyExistingIn2) { - std::size_t nbOfSeg=std::distance(descBg,descEnd); + std::size_t const nbOfSeg=std::distance(descBg,descEnd); for(std::size_t i=0;i0; - mcIdType edgeId=std::abs(descBg[i])-1;//current edge id of pol2 + bool const direct=descBg[i]>0; + mcIdType const edgeId=std::abs(descBg[i])-1;//current edge id of pol2 std::map >::const_iterator it1=alreadyExistingIn2.find(descBg[i]),it2=alreadyExistingIn2.find(-descBg[i]); if(it1!=alreadyExistingIn2.end() || it2!=alreadyExistingIn2.end()) { - bool sameDir=(it1!=alreadyExistingIn2.end()); + bool const sameDir=(it1!=alreadyExistingIn2.end()); const std::vector& edgesAlreadyBuilt=sameDir?(*it1).second:(*it2).second; if(sameDir) { - for(std::vector::const_iterator it3=edgesAlreadyBuilt.begin();it3!=edgesAlreadyBuilt.end();it3++) + for(auto it3 : edgesAlreadyBuilt) { - Edge *ee=(*it3)->getPtr(); ee->incrRef(); - pushBack(new ElementaryEdge(ee,(*it3)->getDirection())); + Edge *ee=it3->getPtr(); ee->incrRef(); + pushBack(new ElementaryEdge(ee,it3->getDirection())); } } else { - for(std::vector::const_reverse_iterator it4=edgesAlreadyBuilt.rbegin();it4!=edgesAlreadyBuilt.rend();it4++) + for(auto it4=edgesAlreadyBuilt.rbegin();it4!=edgesAlreadyBuilt.rend();it4++) { Edge *ee=(*it4)->getPtr(); ee->incrRef(); pushBack(new ElementaryEdge(ee,!(*it4)->getDirection())); @@ -508,10 +522,10 @@ void QuadraticPolygon::buildFromCrudeDataArray2(const std::map& c=colinear1[edgeId]; - std::size_t nbOfEdgesIn1=std::distance(descBg1,descEnd1); + std::size_t const nbOfEdgesIn1=std::distance(descBg1,descEnd1); for(std::size_t j=0;j >(edgeId1,std::pair(descBg1[j]>0,offset1)));// it exists an edge into pol1 given by tuple (idIn1,direct1) that is colinear at edge 'edgeId' in pol2 @@ -523,10 +537,10 @@ void QuadraticPolygon::buildFromCrudeDataArray2(const std::map::const_reverse_iterator it5=_sub_edges.rbegin(); for(std::size_t p=0;p& subEdge=intersectEdges2[edgeId]; - std::size_t nbOfSubEdges=subEdge.size()/2; + std::size_t const nbOfSubEdges=subEdge.size()/2; for(std::size_t j=0;j > >::const_iterator it=idIns1.begin();it!=idIns1.end() && !found;it++) { - mcIdType idIn1=(*it).first;//store if needed the cell id in 1 + mcIdType const idIn1=(*it).first;//store if needed the cell id in 1 direct1=(*it).second.first; offset1=(*it).second.second; const std::vector& subEdge1PossiblyAlreadyIn1=intersectEdges1[idIn1]; @@ -576,7 +590,7 @@ void QuadraticPolygon::buildFromCrudeDataArray2(const std::map(offset1+(direct1?offset2:nbOfSubEdges1-offset2-1))]; Edge *ee=e->getPtr(); ee->incrRef(); - ElementaryEdge *e2=new ElementaryEdge(ee,!(direct1^direction11)); + auto *e2=new ElementaryEdge(ee,!(direct1^direction11)); pushBack(e2); alreadyExistingIn2[descBg[i]].push_back(e2); } @@ -593,32 +607,32 @@ void QuadraticPolygon::updateLocOfEdgeFromCrudeDataArray2(const mcIdType *descBg const INTERP_KERNEL::QuadraticPolygon& pol1, const mcIdType *descBg1, const mcIdType *descEnd1, const std::vector >& intersectEdges1, const std::vector< std::vector >& colinear1) const { - std::size_t nbOfSeg=std::distance(descBg,descEnd); + std::size_t const nbOfSeg=std::distance(descBg,descEnd); for(std::size_t i=0;i0; - mcIdType edgeId=std::abs(descBg[i])-1;//current edge id of pol2 + bool const direct=descBg[i]>0; + mcIdType const edgeId=std::abs(descBg[i])-1;//current edge id of pol2 const std::vector& c=colinear1[edgeId]; if(c.empty()) continue; const std::vector& subEdge=intersectEdges[edgeId]; - std::size_t nbOfSubEdges=subEdge.size()/2; + std::size_t const nbOfSubEdges=subEdge.size()/2; // - std::size_t nbOfEdgesIn1=std::distance(descBg1,descEnd1); + std::size_t const nbOfEdgesIn1=std::distance(descBg1,descEnd1); mcIdType offset1=0; for(std::size_t j=0;j0; + mcIdType const idBg=direct?subEdge[2*k]:subEdge[2*nbOfSubEdges-2*k-1]; + mcIdType const idEnd=direct?subEdge[2*k+1]:subEdge[2*nbOfSubEdges-2*k-2]; + mcIdType const idIn1=edgeId1; + bool const direct1=descBg1[j]>0; const std::vector& subEdge1PossiblyAlreadyIn1=intersectEdges1[idIn1]; - mcIdType nbOfSubEdges1=ToIdType(subEdge1PossiblyAlreadyIn1.size()/2); + mcIdType const nbOfSubEdges1=ToIdType(subEdge1PossiblyAlreadyIn1.size()/2); mcIdType offset2=0; bool found=false; for(mcIdType kk=0;kk& mapp, double xBary, double yBary, double fact, mcIdType offset, std::vector& addCoordsQuadratic, std::vector& conn, std::vector& connI) const { int nbOfNodesInPg=0; - bool presenceOfQuadratic=presenceOfQuadraticEdge(); + bool const presenceOfQuadratic=presenceOfQuadraticEdge(); conn.push_back(presenceOfQuadratic?NORM_QPOLYG:NORM_POLYGON); - for(std::list::const_iterator it=_sub_edges.begin();it!=_sub_edges.end();it++) + for(auto _sub_edge : _sub_edges) { - Node *tmp=0; - tmp=(*it)->getStartNode(); - std::map::const_iterator it1=mapp.find(tmp); + Node *tmp=nullptr; + tmp=_sub_edge->getStartNode(); + auto const it1=mapp.find(tmp); conn.push_back((*it1).second); nbOfNodesInPg++; } if(presenceOfQuadratic) { int j=0; - mcIdType off=offset+ToIdType(addCoordsQuadratic.size())/2; - for(std::list::const_iterator it=_sub_edges.begin();it!=_sub_edges.end();it++,j++,nbOfNodesInPg++) + mcIdType const off=offset+ToIdType(addCoordsQuadratic.size())/2; + for(auto it=_sub_edges.begin();it!=_sub_edges.end();it++,j++,nbOfNodesInPg++) { INTERP_KERNEL::Node *node=(*it)->getPtr()->buildRepresentantOfMySelf(); node->unApplySimilarity(xBary,yBary,fact); @@ -681,14 +695,14 @@ void QuadraticPolygon::buildPartitionsAbs(QuadraticPolygon& other, std::set& nbThis, std::vector& nbOther) { double xBaryBB, yBaryBB; - double fact=normalizeExt(&other, xBaryBB, yBaryBB); + double const fact=normalizeExt(&other, xBaryBB, yBaryBB); //Locate \a this relative to \a other (edges of \a this, aka \a pol1 are marked as IN or OUT) other.performLocatingOperationSlow(*this); // without any assumption - std::vector res=buildIntersectionPolygons(*this,other); - for(std::vector::iterator it=res.begin();it!=res.end();it++) + std::vector const res=buildIntersectionPolygons(*this,other); + for(auto & re : res) { - (*it)->appendCrudeData(mapp,xBaryBB,yBaryBB,fact,offset,addCoordsQuadratic,conn,connI); - INTERP_KERNEL::IteratorOnComposedEdge it1(*it); + re->appendCrudeData(mapp,xBaryBB,yBaryBB,fact,offset,addCoordsQuadratic,conn,connI); + INTERP_KERNEL::IteratorOnComposedEdge it1(re); for(it1.first();!it1.finished();it1.next()) { Edge *e=it1.current()->getPtr(); @@ -704,7 +718,7 @@ void QuadraticPolygon::buildPartitionsAbs(QuadraticPolygon& other, std::set 2) for(it.first();!it.finished();it.next()) { @@ -738,7 +752,7 @@ void QuadraticPolygon::cleanDegeneratedConsecutiveEdges() double QuadraticPolygon::intersectWithAbs1D(QuadraticPolygon& other, bool& isColinear) { double ret = 0., xBaryBB, yBaryBB; - double fact = normalize(&other, xBaryBB, yBaryBB); + double const fact = normalize(&other, xBaryBB, yBaryBB); QuadraticPolygon cpyOfThis(*this); QuadraticPolygon cpyOfOther(other); @@ -777,13 +791,13 @@ double QuadraticPolygon::intersectWithAbs(QuadraticPolygon& other, double* baryc { double ret=0.,bary[2],area,xBaryBB,yBaryBB; barycenter[0] = barycenter[1] = 0.; - double fact=normalize(&other,xBaryBB,yBaryBB); - std::vector polygs=intersectMySelfWith(other); - for(std::vector::iterator iter=polygs.begin();iter!=polygs.end();iter++) + double const fact=normalize(&other,xBaryBB,yBaryBB); + std::vector const polygs=intersectMySelfWith(other); + for(auto & polyg : polygs) { - area=fabs((*iter)->getArea()); - (*iter)->getBarycenter(bary); - delete *iter; + area=fabs(polyg->getArea()); + polyg->getBarycenter(bary); + delete polyg; ret+=area; barycenter[0] += bary[0]*area; barycenter[1] += bary[1]*area; @@ -805,11 +819,11 @@ double QuadraticPolygon::intersectWithAbs(QuadraticPolygon& other, double* baryc double QuadraticPolygon::intersectWith(const QuadraticPolygon& other) const { double ret=0.; - std::vector polygs=intersectMySelfWith(other); - for(std::vector::iterator iter=polygs.begin();iter!=polygs.end();iter++) + std::vector const polygs=intersectMySelfWith(other); + for(auto & polyg : polygs) { - ret+=fabs((*iter)->getArea()); - delete *iter; + ret+=fabs(polyg->getArea()); + delete polyg; } return ret; } @@ -823,12 +837,12 @@ double QuadraticPolygon::intersectWith(const QuadraticPolygon& other, double* ba { double ret=0., bary[2]; barycenter[0] = barycenter[1] = 0.; - std::vector polygs=intersectMySelfWith(other); - for(std::vector::iterator iter=polygs.begin();iter!=polygs.end();iter++) + std::vector const polygs=intersectMySelfWith(other); + for(auto & polyg : polygs) { - double area = fabs((*iter)->getArea()); - (*iter)->getBarycenter(bary); - delete *iter; + double const area = fabs(polyg->getArea()); + polyg->getBarycenter(bary); + delete polyg; ret+=area; barycenter[0] += bary[0]*area; barycenter[1] += bary[1]*area; @@ -951,8 +965,8 @@ void QuadraticPolygon::SplitPolygonsEachOther(QuadraticPolygon& pol1, QuadraticP { IteratorOnComposedEdge it1(&pol1),it2(&pol2); MergePoints merge; - ComposedEdge *c1=new ComposedEdge; - ComposedEdge *c2=new ComposedEdge; + auto *c1=new ComposedEdge; + auto *c2=new ComposedEdge; for(it2.first();!it2.finished();it2.next()) { ElementaryEdge* curE2=it2.current(); @@ -1051,7 +1065,7 @@ std::list QuadraticPolygon::zipConsecutiveInSegments() const { std::list ret; IteratorOnComposedEdge it(const_cast(this)); - int nbOfTurns=recursiveSize(); + int const nbOfTurns=recursiveSize(); int i=0; if(!it.goToNextInOn(false,i,nbOfTurns)) return ret; @@ -1059,7 +1073,7 @@ std::list QuadraticPolygon::zipConsecutiveInSegments() const // while(igetLoc(); while(loc!=FULL_OUT_1 && i& pol1Zip, con bool directionKnownInPol2=false; bool directionInPol2=false; bool needCleaning = false; - for(std::list::iterator iter=pol1Zip.begin();iter!=pol1Zip.end();) + for(auto iter=pol1Zip.begin();iter!=pol1Zip.end();) { // Build incrementally the full closed cells from the consecutive line parts already built in pol1Zip. // At the end of the process the item currently iterated has been totally completed (start_node=end_node) @@ -1113,9 +1127,9 @@ void QuadraticPolygon::ClosePolygons(std::list& pol1Zip, con else directionKnownInPol2=true; } - std::list::iterator iter2=iter; iter2++; + auto iter2=iter; iter2++; // Fill as much as possible the current iterate (=a part of pol1) with consecutive pieces from pol2: - std::list::iterator iter3=(*iter)->fillAsMuchAsPossibleWith(pol2,iter2,pol1Zip.end(),directionInPol2); + auto const iter3=(*iter)->fillAsMuchAsPossibleWith(pol2,iter2,pol1Zip.end(),directionInPol2); // and now add a full connected piece from pol1Zip: if(iter3!=pol1Zip.end()) { @@ -1161,7 +1175,7 @@ bool QuadraticPolygon::haveIAChanceToBeCompletedBy(const QuadraticPolygon& pol1N it2.nextLoop(); cur=it2.current(); Node *repr=cur->getPtr()->buildRepresentantOfMySelf(); - bool ret=pol1NotSplitted.isInOrOut(repr); + bool const ret=pol1NotSplitted.isInOrOut(repr); repr->decrRef(); direction = ret; needCleaning = ret; // if true we are in tricky case 2 above, we know that we will produce two consecutive overlapping edges in result @@ -1170,7 +1184,7 @@ bool QuadraticPolygon::haveIAChanceToBeCompletedBy(const QuadraticPolygon& pol1N else // here we don't need to go prev or next: { Node *repr=cur->getPtr()->buildRepresentantOfMySelf(); - bool ret=pol1NotSplitted.isInOrOut(repr); + bool const ret=pol1NotSplitted.isInOrOut(repr); repr->decrRef(); direction = ret; return ret; @@ -1228,7 +1242,7 @@ std::list::iterator QuadraticPolygon::fillAsMuchAsPossibleWi std::list::iterator QuadraticPolygon::CheckInList(Node *n, std::list::iterator iStart, std::list::iterator iEnd) { - for(std::list::iterator iter=iStart;iter!=iEnd;iter++) + for(auto iter=iStart;iter!=iEnd;iter++) if((*iter)->isNodeIn(n)) return iter; return iEnd; @@ -1250,14 +1264,14 @@ void QuadraticPolygon::ComputeResidual(const QuadraticPolygon& pol1, const std:: { // Initialise locations on pol1. Remember that edges found in 'notUsedInPol1' are also part of the edges forming pol1. pol1.initLocations(); - for(std::set::const_iterator it1=notUsedInPol1.begin();it1!=notUsedInPol1.end();it1++) - { (*it1)->initLocs(); (*it1)->declareOn(); } - for(std::set::const_iterator it2=edgesInPol2OnBoundary.begin();it2!=edgesInPol2OnBoundary.end();it2++) - { (*it2)->initLocs(); (*it2)->declareIn(); } + for(auto it1 : notUsedInPol1) + { it1->initLocs(); it1->declareOn(); } + for(auto it2 : edgesInPol2OnBoundary) + { it2->initLocs(); it2->declareIn(); } //// std::set notUsedInPol1L(notUsedInPol1); IteratorOnComposedEdge itPol1(const_cast(&pol1)); - int sz=pol1.size(); + int const sz=pol1.size(); std::list pol1Zip; // If none of the edges of pol1 was consumed by the rebuilding process, we can directly take pol1 as it is to form a cell: if(pol1.size()==(int)notUsedInPol1.size() && edgesInPol2OnBoundary.empty()) @@ -1273,7 +1287,7 @@ void QuadraticPolygon::ComputeResidual(const QuadraticPolygon& pol1, const std:: itPol1.nextLoop(); if(itPol1.current()->getStartNode()->getLoc()!=IN_1 || itPol1.current()->getLoc()!=FULL_ON_1) throw INTERP_KERNEL::Exception("Presence of a target polygon fully included in source polygon ! The partition of this leads to a non simply connex cell (with hole) ! Impossible ! Such resulting cell cannot be stored in MED cell format !"); - QuadraticPolygon *tmp1=new QuadraticPolygon; + auto *tmp1=new QuadraticPolygon; do { Edge *ee=itPol1.current()->getPtr(); @@ -1302,7 +1316,7 @@ void QuadraticPolygon::ComputeResidual(const QuadraticPolygon& pol1, const std:: while(nbOfTurn see if(!pol1Zip.empty()) below ... - for(std::list::iterator itConstr=retPolsUnderContruction.begin();itConstr!=retPolsUnderContruction.end();) + for(auto itConstr=retPolsUnderContruction.begin();itConstr!=retPolsUnderContruction.end();) { Node *startN = (*itConstr)->getStartNode(); Node *curN = (*itConstr)->getEndNode(); @@ -1311,7 +1325,7 @@ void QuadraticPolygon::ComputeResidual(const QuadraticPolygon& pol1, const std:: bool smthHappened=false, doneEarly=false; // Complete a partially reconstructed polygon with boundary edges of pol2 by matching nodes: - for(std::list::iterator it2=edgesInPol2OnBoundaryL.begin();it2!=edgesInPol2OnBoundaryL.end();) + for(auto it2=edgesInPol2OnBoundaryL.begin();it2!=edgesInPol2OnBoundaryL.end();) { if(curN==(*it2)->getEndNode()) // only end node should be considered if orientation is correct for input meshes // in the funny case of cells exactly included (see test case testIntersect2DMeshesTmp13) this is mandatory to take edges from pol2 in the right order. @@ -1332,7 +1346,7 @@ void QuadraticPolygon::ComputeResidual(const QuadraticPolygon& pol1, const std:: // Be somewhat flexible and keep on supporting this case here (useful for voronisation notably): if(!smthHappened) { - for(std::list::iterator it2=edgesInPol2OnBoundaryL.begin();it2!=edgesInPol2OnBoundaryL.end();) + for(auto it2=edgesInPol2OnBoundaryL.begin();it2!=edgesInPol2OnBoundaryL.end();) { if(curN==(*it2)->getStartNode()) { @@ -1354,12 +1368,12 @@ void QuadraticPolygon::ComputeResidual(const QuadraticPolygon& pol1, const std:: if(smthHappened) // Now continue the construction by finding the next bit in pol1Zip. Not too sure what are the cases where the boolean if False ... { - for(std::list::iterator itZip=pol1Zip.begin();itZip!=pol1Zip.end();) + for(auto itZip=pol1Zip.begin();itZip!=pol1Zip.end();) { if(curN==(*itZip)->getStartNode()) // we found a matching piece to append in pol1Zip. Append all of it to the current polygon being reconstr { for(std::list::const_iterator it4=(*itZip)->_sub_edges.begin();it4!=(*itZip)->_sub_edges.end();it4++) - { (*it4)->getPtr()->incrRef(); bool dir=(*it4)->getDirection(); (*itConstr)->pushBack(new ElementaryEdge((*it4)->getPtr(),dir)); } + { (*it4)->getPtr()->incrRef(); bool const dir=(*it4)->getDirection(); (*itConstr)->pushBack(new ElementaryEdge((*it4)->getPtr(),dir)); } pol1ZipConsumed[*itConstr].push_back(*itZip); curN=(*itZip)->getEndNode(); itZip=pol1Zip.erase(itZip); // one zipped piece has been consumed @@ -1377,8 +1391,8 @@ void QuadraticPolygon::ComputeResidual(const QuadraticPolygon& pol1, const std:: if(edgesInPol2OnBoundary.find(ee)!=edgesInPol2OnBoundary.end()) edgesInPol2OnBoundaryL.push_back(ee); } - for(std::list::iterator it6=pol1ZipConsumed[*itConstr].begin();it6!=pol1ZipConsumed[*itConstr].end();it6++) - pol1Zip.push_front(*it6); + for(auto & it6 : pol1ZipConsumed[*itConstr]) + pol1Zip.push_front(it6); pol1ZipConsumed.erase(*itConstr); delete *itConstr; itConstr=retPolsUnderContruction.erase(itConstr); @@ -1386,10 +1400,10 @@ void QuadraticPolygon::ComputeResidual(const QuadraticPolygon& pol1, const std:: } if(!pol1Zip.empty()) // the filling process of retPolsUnderConstruction starts here { - QuadraticPolygon *tmp=new QuadraticPolygon; + auto *tmp=new QuadraticPolygon; QuadraticPolygon *first=*(pol1Zip.begin()); for(std::list::const_iterator it4=first->_sub_edges.begin();it4!=first->_sub_edges.end();it4++) - { (*it4)->getPtr()->incrRef(); bool dir=(*it4)->getDirection(); tmp->pushBack(new ElementaryEdge((*it4)->getPtr(),dir)); } + { (*it4)->getPtr()->incrRef(); bool const dir=(*it4)->getDirection(); tmp->pushBack(new ElementaryEdge((*it4)->getPtr(),dir)); } pol1ZipConsumed[tmp].push_back(first); retPolsUnderContruction.push_back(tmp); pol1Zip.erase(pol1Zip.begin()); @@ -1405,15 +1419,15 @@ void QuadraticPolygon::ComputeResidual(const QuadraticPolygon& pol1, const std:: throw INTERP_KERNEL::Exception(oss.str().c_str()); } // Convert to integer connectivity: - for(std::list::iterator itConstr=retPolsUnderContruction.begin();itConstr!=retPolsUnderContruction.end();itConstr++) + for(auto & itConstr : retPolsUnderContruction) { - if((*itConstr)->getStartNode()==(*itConstr)->getEndNode()) // take only fully closed reconstructed polygon + if(itConstr->getStartNode()==itConstr->getEndNode()) // take only fully closed reconstructed polygon { - (*itConstr)->cleanDegeneratedConsecutiveEdges(); - (*itConstr)->appendCrudeData(mapp,0.,0.,1.,offset,addCoordsQuadratic,conn,connI); nb1.push_back(idThis); nb2.push_back(-1); - for(std::list::iterator it6=pol1ZipConsumed[*itConstr].begin();it6!=pol1ZipConsumed[*itConstr].end();it6++) - delete *it6; - delete *itConstr; + itConstr->cleanDegeneratedConsecutiveEdges(); + itConstr->appendCrudeData(mapp,0.,0.,1.,offset,addCoordsQuadratic,conn,connI); nb1.push_back(idThis); nb2.push_back(-1); + for(auto & it6 : pol1ZipConsumed[itConstr]) + delete it6; + delete itConstr; } else { diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.hxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.hxx index 4fff24c8e..0f4b4aa4d 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.hxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.hxx @@ -26,8 +26,14 @@ #include "InterpKernelGeo2DComposedEdge.hxx" #include "InterpKernelGeo2DAbstractEdge.hxx" #include "InterpKernelGeo2DElementaryEdge.hxx" +#include "MCIdType.hxx" +#include #include +#include +#include +#include +#include #include namespace INTERP_KERNEL @@ -36,7 +42,7 @@ namespace INTERP_KERNEL class MergePoints; enum NodeUsage { USAGE_UNKNOWN, USAGE_LINEAR, USAGE_QUADRATIC_ONLY }; - typedef std::pair NodeWithUsage; + using NodeWithUsage = std::pair; /** * A set of quadratic or linear edges, not necessarily connected to form a closed polygon. @@ -46,8 +52,8 @@ namespace INTERP_KERNEL class QuadraticPolygon : public ComposedEdge { public: - INTERPKERNEL_EXPORT QuadraticPolygon() { } - INTERPKERNEL_EXPORT QuadraticPolygon(const QuadraticPolygon& other):ComposedEdge(other) { } + INTERPKERNEL_EXPORT QuadraticPolygon() = default; + INTERPKERNEL_EXPORT QuadraticPolygon(const QuadraticPolygon& other) = default; INTERPKERNEL_EXPORT QuadraticPolygon(const char *fileName); INTERPKERNEL_EXPORT static QuadraticPolygon *BuildLinearPolygon(std::vector& nodes); INTERPKERNEL_EXPORT static QuadraticPolygon *BuildArcCirclePolygon(std::vector& nodes); @@ -118,7 +124,7 @@ namespace INTERP_KERNEL namespace INTERP_KERNEL { template - void QuadraticPolygon::UpdateNeighbours(const MergePoints& merger, IteratorOnComposedEdge it1, IteratorOnComposedEdge it2, + void QuadraticPolygon::UpdateNeighbours(const MergePoints& /*merger*/, IteratorOnComposedEdge it1, IteratorOnComposedEdge it2, const EDGES *e1, const EDGES *e2) { it1.previousLoop(); it2.previousLoop(); diff --git a/src/INTERP_KERNEL/Geometric2DIntersector.hxx b/src/INTERP_KERNEL/Geometric2DIntersector.hxx index fe5ff129c..53c9d088a 100644 --- a/src/INTERP_KERNEL/Geometric2DIntersector.hxx +++ b/src/INTERP_KERNEL/Geometric2DIntersector.hxx @@ -21,12 +21,10 @@ #ifndef __GEOMETRIC2DINTERSECTOR_HXX__ #define __GEOMETRIC2DINTERSECTOR_HXX__ -#include "PlanarIntersectorP0P0.hxx" -#include "PlanarIntersectorP0P1.hxx" -#include "PlanarIntersectorP1P0.hxx" -#include "PlanarIntersectorP1P1.hxx" -#include "PlanarIntersectorP1P0Bary.hxx" -#include "PlanarIntersectorP0P1Bary.hxx" +#include "NormalizedUnstructuredMesh.hxx" +#include "NormalizedGeometricTypes" +#include "InterpKernelGeo2DPrecision.hxx" +#include namespace INTERP_KERNEL { @@ -38,7 +36,7 @@ namespace INTERP_KERNEL public: static const int SPACEDIM=MyMeshType::MY_SPACEDIM; static const int MESHDIM=MyMeshType::MY_MESHDIM; - typedef typename MyMeshType::MyConnType ConnType; + using ConnType = typename MyMeshType::MyConnType; static const NumberingPolicy numPol=MyMeshType::My_numPol; public: Geometric2DIntersector(const MyMeshType& meshT, const MyMeshType& meshS, diff --git a/src/INTERP_KERNEL/Geometric2DIntersector.txx b/src/INTERP_KERNEL/Geometric2DIntersector.txx index a66b2ab22..53caa6734 100644 --- a/src/INTERP_KERNEL/Geometric2DIntersector.txx +++ b/src/INTERP_KERNEL/Geometric2DIntersector.txx @@ -21,6 +21,7 @@ #define __GEOMETRIC2DINTERSECTOR_TXX__ #include "Geometric2DIntersector.hxx" +#include "PlanarIntersector.txx" #include "PlanarIntersectorP0P0.txx" #include "Planar2D1DIntersectorP0P0.txx" #include "PlanarIntersectorP0P1.txx" @@ -28,13 +29,20 @@ #include "PlanarIntersectorP1P1.txx" #include "PlanarIntersectorP1P0Bary.txx" #include "PlanarIntersectorP0P1Bary.txx" +#include "InterpolationUtils.hxx" #include "CellModel.hxx" +#include "NormalizedGeometricTypes" #include "InterpKernelGeo2DQuadraticPolygon.hxx" #include "InterpKernelGeo2DEdgeArcCircle.hxx" #include "InterpKernelGeo2DEdgeLin.hxx" #include "InterpKernelGeo2DNode.hxx" +#include +#include +#include + + #define GEO2D_INTERSECTOR Geometric2DIntersector #define INTERSECTOR_TEMPLATE template class InterpType> diff --git a/src/INTERP_KERNEL/IntegralUniformIntersector.hxx b/src/INTERP_KERNEL/IntegralUniformIntersector.hxx index a5e5fe39a..cb191fc71 100644 --- a/src/INTERP_KERNEL/IntegralUniformIntersector.hxx +++ b/src/INTERP_KERNEL/IntegralUniformIntersector.hxx @@ -21,9 +21,10 @@ #ifndef __INTEGRALUNIFORMINTERSECTOR_HXX__ #define __INTEGRALUNIFORMINTERSECTOR_HXX__ -#include "TargetIntersector.txx" +#include "TargetIntersector.hxx" #include +#include namespace INTERP_KERNEL { @@ -31,7 +32,7 @@ namespace INTERP_KERNEL class IntegralUniformIntersector : public TargetIntersector { public: - typedef typename MyMeshType::MyConnType ConnType; + using ConnType = typename MyMeshType::MyConnType; public: IntegralUniformIntersector(const MyMeshType& mesh, bool isAbs); double performNormalization(double val) const { if(_is_abs) return fabs(val); else return val; } @@ -48,7 +49,7 @@ namespace INTERP_KERNEL class IntegralUniformIntersectorP0 : public IntegralUniformIntersector { public: - typedef typename MyMeshType::MyConnType ConnType; + using ConnType = typename MyMeshType::MyConnType; public: IntegralUniformIntersectorP0(const MyMeshType& mesh, bool isAbs); ConnType getNumberOfRowsOfResMatrix() const; @@ -60,7 +61,7 @@ namespace INTERP_KERNEL class IntegralUniformIntersectorP1 : public IntegralUniformIntersector { public: - typedef typename MyMeshType::MyConnType ConnType; + using ConnType = typename MyMeshType::MyConnType; public: IntegralUniformIntersectorP1(const MyMeshType& mesh, bool isAbs); ConnType getNumberOfRowsOfResMatrix() const; diff --git a/src/INTERP_KERNEL/IntegralUniformIntersector.txx b/src/INTERP_KERNEL/IntegralUniformIntersector.txx old mode 100755 new mode 100644 index e603fcbc3..3016fe3ce --- a/src/INTERP_KERNEL/IntegralUniformIntersector.txx +++ b/src/INTERP_KERNEL/IntegralUniformIntersector.txx @@ -21,7 +21,11 @@ #define __INTEGRALUNIFORMINTERSECTOR_TXX__ #include "IntegralUniformIntersector.hxx" +#include "NormalizedGeometricTypes" +#include "NormalizedUnstructuredMesh.hxx" +#include "InterpolationUtils.hxx" #include "VolSurfUser.txx" +#include namespace INTERP_KERNEL { @@ -87,7 +91,7 @@ namespace INTERP_KERNEL } template - void IntegralUniformIntersectorP0::intersectCells(ConnType targetCell, const std::vector& srcCells, MyMatrix& res) + void IntegralUniformIntersectorP0::intersectCells(ConnType /*targetCell*/, const std::vector& /*srcCells*/, MyMatrix& res) { static const NumberingPolicy numPol=MyMeshType::My_numPol; res.resize(getNumberOfRowsOfResMatrix()); @@ -127,7 +131,7 @@ namespace INTERP_KERNEL } template - void IntegralUniformIntersectorP1::intersectCells(ConnType targetCell, const std::vector& srcCells, MyMatrix& res) + void IntegralUniformIntersectorP1::intersectCells(ConnType /*targetCell*/, const std::vector& /*srcCells*/, MyMatrix& res) { static const NumberingPolicy numPol=MyMeshType::My_numPol; res.resize(getNumberOfRowsOfResMatrix()); diff --git a/src/INTERP_KERNEL/InterpKernelCellSimplify.cxx b/src/INTERP_KERNEL/InterpKernelCellSimplify.cxx index f28635998..be8853fcd 100644 --- a/src/INTERP_KERNEL/InterpKernelCellSimplify.cxx +++ b/src/INTERP_KERNEL/InterpKernelCellSimplify.cxx @@ -20,16 +20,16 @@ #include "InterpKernelCellSimplify.hxx" #include "CellModel.hxx" +#include "NormalizedGeometricTypes" +#include "MCIdType.hxx" +#include "InterpKernelException.hxx" #include #include #include -#include -#include #include -#include +#include #include -#include #include using namespace INTERP_KERNEL; @@ -44,11 +44,11 @@ INTERP_KERNEL::NormalizedCellType CellSimplify::simplifyDegeneratedCell(INTERP_K const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(type); std::set c(conn,conn+lgth); c.erase(-1); - bool isObviousNonDegeneratedCell=(ToIdType(c.size())==lgth); + bool const isObviousNonDegeneratedCell=(ToIdType(c.size())==lgth); if((cm.getDimension()==3 && cm.isQuadratic()) || isObviousNonDegeneratedCell) {//quadratic 3D, do nothing for the moment. retLgth=lgth; - mcIdType *tmp=new mcIdType[lgth];//no direct std::copy ! overlapping of conn and retConn ! + auto *tmp=new mcIdType[lgth];//no direct std::copy ! overlapping of conn and retConn ! std::copy(conn,conn+lgth,tmp); std::copy(tmp,tmp+lgth,retConn); delete [] tmp; @@ -56,7 +56,7 @@ INTERP_KERNEL::NormalizedCellType CellSimplify::simplifyDegeneratedCell(INTERP_K } if(cm.getDimension()==2) { - mcIdType *tmp=new mcIdType[lgth]; + auto *tmp=new mcIdType[lgth]; int newPos=0; if(!cm.isQuadratic()) { @@ -66,8 +66,8 @@ INTERP_KERNEL::NormalizedCellType CellSimplify::simplifyDegeneratedCell(INTERP_K } else { - mcIdType quadOff = lgth/2; - mcIdType *tmpQuad = new mcIdType[quadOff]; + mcIdType const quadOff = lgth/2; + auto *tmpQuad = new mcIdType[quadOff]; for(int i = 0; i < quadOff; i++) if(conn[i] != conn[(i+1)%quadOff] || conn[i] != conn[i+quadOff]) // zip nul segments/arcs (quad point must match too) { @@ -79,7 +79,7 @@ INTERP_KERNEL::NormalizedCellType CellSimplify::simplifyDegeneratedCell(INTERP_K delete [] tmpQuad; newPos *= 2; // take in quad points in the final length } - INTERP_KERNEL::NormalizedCellType ret=tryToUnPoly2D(cm.isQuadratic(),tmp,newPos,retConn,retLgth); + INTERP_KERNEL::NormalizedCellType const ret=tryToUnPoly2D(cm.isQuadratic(),tmp,newPos,retConn,retLgth); delete [] tmp; return ret; } @@ -87,7 +87,7 @@ INTERP_KERNEL::NormalizedCellType CellSimplify::simplifyDegeneratedCell(INTERP_K { mcIdType nbOfFaces,lgthOfPolyhConn; mcIdType *zipFullReprOfPolyh=getFullPolyh3DCell(type,conn,lgth,nbOfFaces,lgthOfPolyhConn); - INTERP_KERNEL::NormalizedCellType ret=tryToUnPoly3D(zipFullReprOfPolyh,nbOfFaces,lgthOfPolyhConn,retConn,retLgth); + INTERP_KERNEL::NormalizedCellType const ret=tryToUnPoly3D(zipFullReprOfPolyh,nbOfFaces,lgthOfPolyhConn,retConn,retLgth); delete [] zipFullReprOfPolyh; return ret; } @@ -139,16 +139,16 @@ mcIdType *CellSimplify::getFullPolyh3DCell(INTERP_KERNEL::NormalizedCellType typ mcIdType& retNbOfFaces, mcIdType& retLgth) { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(type); - unsigned nbOfFaces=cm.getNumberOfSons2(conn,lgth); - mcIdType *tmp=new mcIdType[nbOfFaces*(lgth+1)]; + unsigned const nbOfFaces=cm.getNumberOfSons2(conn,lgth); + auto *tmp=new mcIdType[nbOfFaces*(lgth+1)]; mcIdType *work=tmp; std::vector faces; for(unsigned j=0;j nodes(conn,conn+lgth); nodes.erase(-1); - std::size_t nbOfNodes=nodes.size(); - std::size_t magicNumber=100*nbOfNodes+nbOfFaces; + std::size_t const nbOfNodes=nodes.size(); + std::size_t const magicNumber=100*nbOfNodes+nbOfFaces; switch(magicNumber) { case 806: @@ -205,8 +205,8 @@ INTERP_KERNEL::NormalizedCellType CellSimplify::tryToUnPoly3D(const mcIdType *co bool CellSimplify::orientOppositeFace(const mcIdType *baseFace, mcIdType *retConn, const mcIdType *sideFace, mcIdType lgthBaseFace) { std::vector tmp2; - std::set bases(baseFace,baseFace+lgthBaseFace); - std::set sides(sideFace,sideFace+4); + std::set const bases(baseFace,baseFace+lgthBaseFace); + std::set const sides(sideFace,sideFace+4); std::set_intersection(bases.begin(),bases.end(),sides.begin(),sides.end(),std::back_insert_iterator< std::vector >(tmp2)); if(tmp2.size()!=2) return false; @@ -221,21 +221,21 @@ bool CellSimplify::orientOppositeFace(const mcIdType *baseFace, mcIdType *retCon for(int i=0;i<4;i++) sideEdges[i]=std::pair(sideFace[i],sideFace[(i+1)%4]); std::vector< std::pair > tmp; - std::set< std::pair > baseEdgesS(baseEdges.begin(),baseEdges.end()); - std::set< std::pair > sideEdgesS(sideEdges.begin(),sideEdges.end()); + std::set< std::pair > const baseEdgesS(baseEdges.begin(),baseEdges.end()); + std::set< std::pair > const sideEdgesS(sideEdges.begin(),sideEdges.end()); std::set_intersection(baseEdgesS.begin(),baseEdgesS.end(),sideEdgesS.begin(),sideEdgesS.end(),std::back_insert_iterator< std::vector< std::pair > >(tmp)); if(tmp.empty()) { //reverse sideFace for(int i=0;i<4;i++) { - std::pair p=sideEdges[i]; - std::pair r(p.second,p.first); + std::pair const p=sideEdges[i]; + std::pair const r(p.second,p.first); sideEdges[i]=r; } //end reverse sideFace - std::set< std::pair > baseEdgesS2(baseEdges.begin(),baseEdges.end()); - std::set< std::pair > sideEdgesS2(sideEdges.begin(),sideEdges.end()); + std::set< std::pair > const baseEdgesS2(baseEdges.begin(),baseEdges.end()); + std::set< std::pair > const sideEdgesS2(sideEdges.begin(),sideEdges.end()); std::set_intersection(baseEdgesS2.begin(),baseEdgesS2.end(),sideEdgesS2.begin(),sideEdgesS2.end(),std::back_insert_iterator< std::vector< std::pair > >(tmp)); if(tmp.empty()) return false; @@ -256,16 +256,16 @@ bool CellSimplify::orientOppositeFace(const mcIdType *baseFace, mcIdType *retCon } if(!found) return false; - int pos=(int)std::distance(baseEdges.begin(),std::find(baseEdges.begin(),baseEdges.end(),tmp[0])); - std::vector< std::pair >::iterator it=std::find(oppEdges.begin(),oppEdges.end(),pInOpp); + int const pos=(int)std::distance(baseEdges.begin(),std::find(baseEdges.begin(),baseEdges.end(),tmp[0])); + auto const it=std::find(oppEdges.begin(),oppEdges.end(),pInOpp); if(it==oppEdges.end())//the opposite edge of side face is not found opposite face ... maybe problem of orientation of polyhedron return false; - mcIdType pos2=ToIdType(std::distance(oppEdges.begin(),it)); + mcIdType const pos2=ToIdType(std::distance(oppEdges.begin(),it)); mcIdType offset=pos-pos2; if(offset<0) offset+=lgthBaseFace; //this is the end copy the result - mcIdType *tmp3=new mcIdType[lgthBaseFace]; + auto *tmp3=new mcIdType[lgthBaseFace]; for(int i=0;i(),std::placeholders::_1,ToIdType(INTERP_KERNEL::NORM_QUAD4)))==conn+lgth+nbOfFaces) {//6 faces are QUAD4. int oppositeFace=-1; - std::set conn1(conn,conn+4); + std::set const conn1(conn,conn+4); for(int i=1;i<6 && oppositeFace<0;i++) { std::vector tmp; - std::set conn2(conn+5*i,conn+5*i+4); + std::set const conn2(conn+5*i,conn+5*i+4); std::set_intersection(conn1.begin(),conn1.end(),conn2.begin(),conn2.end(),std::back_insert_iterator< std::vector >(tmp)); if(tmp.empty()) oppositeFace=i; @@ -345,25 +345,25 @@ INTERP_KERNEL::NormalizedCellType CellSimplify::tryToUnPolyHex8(const mcIdType * INTERP_KERNEL::NormalizedCellType CellSimplify::tryToUnPolyHexp12(const mcIdType *conn, mcIdType nbOfFaces, mcIdType lgth, mcIdType *retConn, mcIdType& retLgth) { - std::size_t nbOfHexagon=std::count(conn+lgth,conn+lgth+nbOfFaces,ToIdType(INTERP_KERNEL::NORM_POLYGON)); - std::size_t nbOfQuad=std::count(conn+lgth,conn+lgth+nbOfFaces,ToIdType(INTERP_KERNEL::NORM_QUAD4)); + std::size_t const nbOfHexagon=std::count(conn+lgth,conn+lgth+nbOfFaces,ToIdType(INTERP_KERNEL::NORM_POLYGON)); + std::size_t const nbOfQuad=std::count(conn+lgth,conn+lgth+nbOfFaces,ToIdType(INTERP_KERNEL::NORM_QUAD4)); if(nbOfQuad==6 && nbOfHexagon==2) { const mcIdType *hexag0=std::find(conn+lgth,conn+lgth+nbOfFaces,ToIdType(INTERP_KERNEL::NORM_POLYGON)); - std::size_t hexg0Id=std::distance(conn+lgth,hexag0); + std::size_t const hexg0Id=std::distance(conn+lgth,hexag0); const mcIdType *hexag1=std::find(hexag0+1,conn+lgth+nbOfFaces,ToIdType(INTERP_KERNEL::NORM_POLYGON)); - std::size_t hexg1Id=std::distance(conn+lgth,hexag1); + std::size_t const hexg1Id=std::distance(conn+lgth,hexag1); const mcIdType *connHexag0=conn+5*hexg0Id; - std::size_t lgthH0=std::distance(connHexag0,std::find(connHexag0,conn+lgth,-1)); + std::size_t const lgthH0=std::distance(connHexag0,std::find(connHexag0,conn+lgth,-1)); if(lgthH0==6) { const mcIdType *connHexag1=conn+5*hexg0Id+7+(hexg1Id-hexg0Id-1)*5; - std::size_t lgthH1=std::distance(connHexag1,std::find(connHexag1,conn+lgth,-1)); + std::size_t const lgthH1=std::distance(connHexag1,std::find(connHexag1,conn+lgth,-1)); if(lgthH1==6) { std::vector tmp; - std::set conn1(connHexag0,connHexag0+6); - std::set conn2(connHexag1,connHexag1+6); + std::set const conn1(connHexag0,connHexag0+6); + std::set const conn2(connHexag1,connHexag1+6); std::set_intersection(conn1.begin(),conn1.end(),conn2.begin(),conn2.end(),std::back_insert_iterator< std::vector >(tmp)); if(tmp.empty()) { @@ -390,13 +390,13 @@ INTERP_KERNEL::NormalizedCellType CellSimplify::tryToUnPolyHexp12(const mcIdType */ INTERP_KERNEL::NormalizedCellType CellSimplify::tryToUnPolyPenta6(const mcIdType *conn, mcIdType nbOfFaces, mcIdType lgth, mcIdType *retConn, mcIdType& retLgth) { - std::size_t nbOfTriFace=std::count(conn+lgth,conn+lgth+nbOfFaces,ToIdType(INTERP_KERNEL::NORM_TRI3)); - std::size_t nbOfQuadFace=std::count(conn+lgth,conn+lgth+nbOfFaces,ToIdType(INTERP_KERNEL::NORM_QUAD4)); + std::size_t const nbOfTriFace=std::count(conn+lgth,conn+lgth+nbOfFaces,ToIdType(INTERP_KERNEL::NORM_TRI3)); + std::size_t const nbOfQuadFace=std::count(conn+lgth,conn+lgth+nbOfFaces,ToIdType(INTERP_KERNEL::NORM_QUAD4)); if(nbOfTriFace==2 && nbOfQuadFace==3) { - std::size_t tri3_0=std::distance(conn+lgth,std::find(conn+lgth,conn+lgth+nbOfFaces,ToIdType(INTERP_KERNEL::NORM_TRI3))); - std::size_t tri3_1=std::distance(conn+lgth,std::find(conn+lgth+tri3_0+1,conn+lgth+nbOfFaces,ToIdType(INTERP_KERNEL::NORM_TRI3))); - const mcIdType *tri_0=0,*tri_1=0; + std::size_t const tri3_0=std::distance(conn+lgth,std::find(conn+lgth,conn+lgth+nbOfFaces,ToIdType(INTERP_KERNEL::NORM_TRI3))); + std::size_t const tri3_1=std::distance(conn+lgth,std::find(conn+lgth+tri3_0+1,conn+lgth+nbOfFaces,ToIdType(INTERP_KERNEL::NORM_TRI3))); + const mcIdType *tri_0=nullptr,*tri_1=nullptr; const mcIdType *w=conn; for(std::size_t i=0;i<5;i++) { @@ -408,8 +408,8 @@ INTERP_KERNEL::NormalizedCellType CellSimplify::tryToUnPolyPenta6(const mcIdType w++; } std::vector tmp; - std::set conn1(tri_0,tri_0+3); - std::set conn2(tri_1,tri_1+3); + std::set const conn1(tri_0,tri_0+3); + std::set const conn2(tri_1,tri_1+3); std::set_intersection(conn1.begin(),conn1.end(),conn2.begin(),conn2.end(),std::back_insert_iterator< std::vector >(tmp)); if(tmp.empty()) { @@ -434,21 +434,21 @@ INTERP_KERNEL::NormalizedCellType CellSimplify::tryToUnPolyPenta6(const mcIdType */ INTERP_KERNEL::NormalizedCellType CellSimplify::tryToUnPolyPyra5(const mcIdType *conn, mcIdType nbOfFaces, mcIdType lgth, mcIdType *retConn, mcIdType& retLgth) { - std::size_t nbOfTriFace=std::count(conn+lgth,conn+lgth+nbOfFaces,ToIdType(INTERP_KERNEL::NORM_TRI3)); - std::size_t nbOfQuadFace=std::count(conn+lgth,conn+lgth+nbOfFaces,ToIdType(INTERP_KERNEL::NORM_QUAD4)); + std::size_t const nbOfTriFace=std::count(conn+lgth,conn+lgth+nbOfFaces,ToIdType(INTERP_KERNEL::NORM_TRI3)); + std::size_t const nbOfQuadFace=std::count(conn+lgth,conn+lgth+nbOfFaces,ToIdType(INTERP_KERNEL::NORM_QUAD4)); if(nbOfTriFace==4 && nbOfQuadFace==1) { - std::size_t quad4_pos=std::distance(conn+lgth,std::find(conn+lgth,conn+lgth+nbOfFaces,ToIdType(INTERP_KERNEL::NORM_QUAD4))); - const mcIdType *quad4=0; + std::size_t const quad4_pos=std::distance(conn+lgth,std::find(conn+lgth,conn+lgth+nbOfFaces,ToIdType(INTERP_KERNEL::NORM_QUAD4))); + const mcIdType *quad4=nullptr; const mcIdType *w=conn; - for(std::size_t i=0;i<5 && quad4==0;i++) + for(std::size_t i=0;i<5 && quad4==nullptr;i++) { if(i==quad4_pos) quad4=w; w=std::find(w,conn+lgth,-1); w++; } - std::set quad4S(quad4,quad4+4); + std::set const quad4S(quad4,quad4+4); w=conn; bool ok=true; mcIdType point=-1; @@ -457,7 +457,7 @@ INTERP_KERNEL::NormalizedCellType CellSimplify::tryToUnPolyPyra5(const mcIdType if(i!=quad4_pos) { std::vector tmp; - std::set conn2(w,w+3); + std::set const conn2(w,w+3); std::set_intersection(conn2.begin(),conn2.end(),quad4S.begin(),quad4S.end(),std::back_insert_iterator< std::vector >(tmp)); ok=tmp.size()==2; tmp.clear(); @@ -495,13 +495,13 @@ INTERP_KERNEL::NormalizedCellType CellSimplify::tryToUnPolyTetra4(const mcIdType { if(std::find_if(conn+lgth,conn+lgth+nbOfFaces,std::bind(std::not_equal_to(),std::placeholders::_1,ToIdType(INTERP_KERNEL::NORM_TRI3)))==conn+lgth+nbOfFaces) { - std::set tribase(conn,conn+3); + std::set const tribase(conn,conn+3); mcIdType point=-1; bool ok=true; for(int i=1;i<4 && ok;i++) { std::vector tmp; - std::set conn2(conn+i*4,conn+4*i+3); + std::set const conn2(conn+i*4,conn+4*i+3); std::set_intersection(conn2.begin(),conn2.end(),tribase.begin(),tribase.end(),std::back_insert_iterator< std::vector >(tmp)); ok=tmp.size()==2; tmp.clear(); diff --git a/src/INTERP_KERNEL/InterpKernelCellSimplify.hxx b/src/INTERP_KERNEL/InterpKernelCellSimplify.hxx index fde75b7f1..c1688b826 100644 --- a/src/INTERP_KERNEL/InterpKernelCellSimplify.hxx +++ b/src/INTERP_KERNEL/InterpKernelCellSimplify.hxx @@ -22,9 +22,8 @@ #define __INTERPKERNELCELLSIMPLIFY_HXX__ #include "INTERPKERNELDefines.hxx" -#include "NormalizedUnstructuredMesh.hxx" -#include "InterpKernelException.hxx" #include "MCIdType.hxx" +#include "NormalizedGeometricTypes" namespace INTERP_KERNEL { diff --git a/src/INTERP_KERNEL/InterpKernelDenseMatrix.txx b/src/INTERP_KERNEL/InterpKernelDenseMatrix.txx index e4e2bd7de..e3595b33b 100644 --- a/src/INTERP_KERNEL/InterpKernelDenseMatrix.txx +++ b/src/INTERP_KERNEL/InterpKernelDenseMatrix.txx @@ -21,6 +21,7 @@ #include "InterpKernelDenseMatrix.hxx" #include "InterpKernelException.hxx" +#include "MCIdType.hxx" #include "VectorUtils.hxx" #include diff --git a/src/INTERP_KERNEL/InterpKernelMatrix.hxx b/src/INTERP_KERNEL/InterpKernelMatrix.hxx index 197027b33..693fecf4d 100644 --- a/src/INTERP_KERNEL/InterpKernelMatrix.hxx +++ b/src/INTERP_KERNEL/InterpKernelMatrix.hxx @@ -18,10 +18,12 @@ // #ifndef __INTERPKERNELMATRIX_HXX_ -#define __INTERPKERNELMATRIX_HXX__ +#define __INTERPKERNELMATRIX_HXX_ #include "InterpolationUtils.hxx" +#include "NormalizedUnstructuredMesh.hxx" +#include #include #include #include @@ -75,7 +77,7 @@ namespace INTERP_KERNEL void erase(int elem) { std::vector< std::pair >::erase(std::find_if(std::vector< std::pair >::begin(),std::vector< std::pair >::end(),KeyComparator(elem))); } - void insert(const std::pair& myPair) { vector >::push_back(myPair); } + void insert(const std::pair& myPair) { std::vector >::push_back(myPair); } }; private: @@ -88,14 +90,14 @@ namespace INTERP_KERNEL friend std::istream& operator>><>(std::istream& in, Matrix& m); bool _is_configured; public: - typedef Row value_type; + using value_type = Row; public: - Matrix():_coeffs(0), _cols(0), _nb_rows(0), _is_configured(false) + Matrix():_coeffs(0), _cols(nullptr), _nb_rows(0), _is_configured(false) { } - Matrix(int nbrows):_coeffs(0), _cols(0), _is_configured(false) + Matrix(int nbrows):_coeffs(0), _cols(nullptr), _is_configured(false) { _nb_rows=nbrows; } Matrix(std::vector > & matrix) : - _coeffs(0), _cols(0), _is_configured(false) + _coeffs(0), _cols(nullptr), _is_configured(false) { _nb_rows=matrix.size(); _auxiliary_matrix.resize(_nb_rows); diff --git a/src/INTERP_KERNEL/InterpKernelMatrixTools.cxx b/src/INTERP_KERNEL/InterpKernelMatrixTools.cxx index 56f29c75d..ce866b692 100644 --- a/src/INTERP_KERNEL/InterpKernelMatrixTools.cxx +++ b/src/INTERP_KERNEL/InterpKernelMatrixTools.cxx @@ -21,6 +21,7 @@ #include "InterpKernelMatrixTools.hxx" #include "InterpKernelException.hxx" #include "InterpKernelAutoPtr.hxx" +#include "MCIdType.hxx" #include #include @@ -390,7 +391,7 @@ namespace INTERP_KERNEL t=work[j]; daxpy(n,t,a+0+j*lda,1,a+0+k*lda,1); } - mcIdType l=ipvt[k]; + mcIdType const l=ipvt[k]; if(l!=k-1) dswap(n,a+0+k*lda,1,a+0+l*lda,1); } diff --git a/src/INTERP_KERNEL/InterpKernelMeshQuality.cxx b/src/INTERP_KERNEL/InterpKernelMeshQuality.cxx index 5f1d2980f..b3b5100f7 100644 --- a/src/INTERP_KERNEL/InterpKernelMeshQuality.cxx +++ b/src/INTERP_KERNEL/InterpKernelMeshQuality.cxx @@ -22,7 +22,6 @@ #include #include -#include #include double INTERP_KERNEL::quadSkew(const double *coo) @@ -37,8 +36,8 @@ double INTERP_KERNEL::quadSkew(const double *coo) coo[7]+coo[10]-coo[1]-coo[4], coo[8]+coo[11]-coo[2]-coo[5], }; - double l0=sqrt(pa0[0]*pa0[0]+pa0[1]*pa0[1]+pa0[2]*pa0[2]); - double l1=sqrt(pa1[0]*pa1[0]+pa1[1]*pa1[1]+pa1[2]*pa1[2]); + double const l0=sqrt(pa0[0]*pa0[0]+pa0[1]*pa0[1]+pa0[2]*pa0[2]); + double const l1=sqrt(pa1[0]*pa1[0]+pa1[1]*pa1[1]+pa1[2]*pa1[2]); if(l0<1.e-15) return 0.; if(l1<1.e-15) @@ -50,16 +49,16 @@ double INTERP_KERNEL::quadSkew(const double *coo) double INTERP_KERNEL::quadEdgeRatio(const double *coo) { - double a2=(coo[3]-coo[0])*(coo[3]-coo[0])+(coo[4]-coo[1])*(coo[4]-coo[1])+(coo[5]-coo[2])*(coo[5]-coo[2]); - double b2=(coo[6]-coo[3])*(coo[6]-coo[3])+(coo[7]-coo[4])*(coo[7]-coo[4])+(coo[8]-coo[5])*(coo[8]-coo[5]); - double c2=(coo[9]-coo[6])*(coo[9]-coo[6])+(coo[10]-coo[7])*(coo[10]-coo[7])+(coo[11]-coo[8])*(coo[11]-coo[8]); - double d2=(coo[0]-coo[9])*(coo[0]-coo[9])+(coo[1]-coo[10])*(coo[1]-coo[10])+(coo[2]-coo[11])*(coo[2]-coo[11]); - double mab=a2Mcd?Mab:Mcd; + double const a2=(coo[3]-coo[0])*(coo[3]-coo[0])+(coo[4]-coo[1])*(coo[4]-coo[1])+(coo[5]-coo[2])*(coo[5]-coo[2]); + double const b2=(coo[6]-coo[3])*(coo[6]-coo[3])+(coo[7]-coo[4])*(coo[7]-coo[4])+(coo[8]-coo[5])*(coo[8]-coo[5]); + double const c2=(coo[9]-coo[6])*(coo[9]-coo[6])+(coo[10]-coo[7])*(coo[10]-coo[7])+(coo[11]-coo[8])*(coo[11]-coo[8]); + double const d2=(coo[0]-coo[9])*(coo[0]-coo[9])+(coo[1]-coo[10])*(coo[1]-coo[10])+(coo[2]-coo[11])*(coo[2]-coo[11]); + double const mab=a2Mcd?Mab:Mcd; if(m2>1.e-15) return sqrt(M2/m2); else @@ -68,20 +67,20 @@ double INTERP_KERNEL::quadEdgeRatio(const double *coo) double INTERP_KERNEL::quadAspectRatio(const double *coo) { - double a=sqrt((coo[3]-coo[0])*(coo[3]-coo[0])+(coo[4]-coo[1])*(coo[4]-coo[1])+(coo[5]-coo[2])*(coo[5]-coo[2])); - double b=sqrt((coo[6]-coo[3])*(coo[6]-coo[3])+(coo[7]-coo[4])*(coo[7]-coo[4])+(coo[8]-coo[5])*(coo[8]-coo[5])); - double c=sqrt((coo[9]-coo[6])*(coo[9]-coo[6])+(coo[10]-coo[7])*(coo[10]-coo[7])+(coo[11]-coo[8])*(coo[11]-coo[8])); - double d=sqrt((coo[0]-coo[9])*(coo[0]-coo[9])+(coo[1]-coo[10])*(coo[1]-coo[10])+(coo[2]-coo[11])*(coo[2]-coo[11])); - double ma=a>b?a:b; - double mb=c>d?c:d; - double hm=ma>mb?ma:mb; - double ab[3]={(coo[4]-coo[1])*(coo[8]-coo[5])-(coo[7]-coo[4])*(coo[5]-coo[2]), + double const a=sqrt((coo[3]-coo[0])*(coo[3]-coo[0])+(coo[4]-coo[1])*(coo[4]-coo[1])+(coo[5]-coo[2])*(coo[5]-coo[2])); + double const b=sqrt((coo[6]-coo[3])*(coo[6]-coo[3])+(coo[7]-coo[4])*(coo[7]-coo[4])+(coo[8]-coo[5])*(coo[8]-coo[5])); + double const c=sqrt((coo[9]-coo[6])*(coo[9]-coo[6])+(coo[10]-coo[7])*(coo[10]-coo[7])+(coo[11]-coo[8])*(coo[11]-coo[8])); + double const d=sqrt((coo[0]-coo[9])*(coo[0]-coo[9])+(coo[1]-coo[10])*(coo[1]-coo[10])+(coo[2]-coo[11])*(coo[2]-coo[11])); + double const ma=a>b?a:b; + double const mb=c>d?c:d; + double const hm=ma>mb?ma:mb; + double const ab[3]={(coo[4]-coo[1])*(coo[8]-coo[5])-(coo[7]-coo[4])*(coo[5]-coo[2]), (coo[5]-coo[2])*(coo[6]-coo[3])-(coo[3]-coo[0])*(coo[8]-coo[5]), (coo[3]-coo[0])*(coo[7]-coo[4])-(coo[4]-coo[1])*(coo[6]-coo[3])}; - double cd[3]={(coo[10]-coo[7])*(coo[2]-coo[11])-(coo[1]-coo[10])*(coo[11]-coo[8]), + double const cd[3]={(coo[10]-coo[7])*(coo[2]-coo[11])-(coo[1]-coo[10])*(coo[11]-coo[8]), (coo[11]-coo[8])*(coo[0]-coo[9])-(coo[9]-coo[6])*(coo[2]-coo[11]), (coo[9]-coo[6])*(coo[1]-coo[10])-(coo[10]-coo[7])*(coo[0]-coo[9])}; - double e=sqrt(ab[0]*ab[0]+ab[1]*ab[1]+ab[2]*ab[2])+sqrt(cd[0]*cd[0]+cd[1]*cd[1]+cd[2]*cd[2]); + double const e=sqrt(ab[0]*ab[0]+ab[1]*ab[1]+ab[2]*ab[2])+sqrt(cd[0]*cd[0]+cd[1]*cd[1]+cd[2]*cd[2]); if(d>1e-15) return 0.5*(a+b+c+d)*hm/e; else @@ -90,37 +89,37 @@ double INTERP_KERNEL::quadAspectRatio(const double *coo) double INTERP_KERNEL::quadWarp(const double *coo) { - double e0[3]={coo[3]-coo[0],coo[4]-coo[1],coo[5]-coo[2]}; - double e1[3]={coo[6]-coo[3],coo[7]-coo[4],coo[8]-coo[5]}; - double e2[3]={coo[9]-coo[6],coo[10]-coo[7],coo[11]-coo[8]}; - double e3[3]={coo[0]-coo[9],coo[1]-coo[10],coo[2]-coo[11]}; + double const e0[3]={coo[3]-coo[0],coo[4]-coo[1],coo[5]-coo[2]}; + double const e1[3]={coo[6]-coo[3],coo[7]-coo[4],coo[8]-coo[5]}; + double const e2[3]={coo[9]-coo[6],coo[10]-coo[7],coo[11]-coo[8]}; + double const e3[3]={coo[0]-coo[9],coo[1]-coo[10],coo[2]-coo[11]}; - double n0[3]={e3[1]*e0[2]-e3[2]*e0[1],e3[2]*e0[0]-e3[0]*e0[2],e3[0]*e0[1]-e3[1]*e0[0]}; - double n1[3]={e0[1]*e1[2]-e0[2]*e1[1],e0[2]*e1[0]-e0[0]*e1[2],e0[0]*e1[1]-e0[1]*e1[0]}; - double n2[3]={e1[1]*e2[2]-e1[2]*e2[1],e1[2]*e2[0]-e1[0]*e2[2],e1[0]*e2[1]-e1[1]*e2[0]}; - double n3[3]={e2[1]*e3[2]-e2[2]*e3[1],e2[2]*e3[0]-e2[0]*e3[2],e2[0]*e3[1]-e2[1]*e3[0]}; + double const n0[3]={e3[1]*e0[2]-e3[2]*e0[1],e3[2]*e0[0]-e3[0]*e0[2],e3[0]*e0[1]-e3[1]*e0[0]}; + double const n1[3]={e0[1]*e1[2]-e0[2]*e1[1],e0[2]*e1[0]-e0[0]*e1[2],e0[0]*e1[1]-e0[1]*e1[0]}; + double const n2[3]={e1[1]*e2[2]-e1[2]*e2[1],e1[2]*e2[0]-e1[0]*e2[2],e1[0]*e2[1]-e1[1]*e2[0]}; + double const n3[3]={e2[1]*e3[2]-e2[2]*e3[1],e2[2]*e3[0]-e2[0]*e3[2],e2[0]*e3[1]-e2[1]*e3[0]}; - double l0=sqrt(n0[0]*n0[0]+n0[1]*n0[1]+n0[2]*n0[2]); - double l1=sqrt(n1[0]*n1[0]+n1[1]*n1[1]+n1[2]*n1[2]); - double l2=sqrt(n2[0]*n2[0]+n2[1]*n2[1]+n2[2]*n2[2]); - double l3=sqrt(n3[0]*n3[0]+n3[1]*n3[1]+n3[2]*n3[2]); + double const l0=sqrt(n0[0]*n0[0]+n0[1]*n0[1]+n0[2]*n0[2]); + double const l1=sqrt(n1[0]*n1[0]+n1[1]*n1[1]+n1[2]*n1[2]); + double const l2=sqrt(n2[0]*n2[0]+n2[1]*n2[1]+n2[2]*n2[2]); + double const l3=sqrt(n3[0]*n3[0]+n3[1]*n3[1]+n3[2]*n3[2]); if(l0<1.e-15 || l1<1.e-15 || l2<1.e-15 || l3<1e-15) return std::numeric_limits::min(); - double warp=std::min(n0[0]/l0*n2[0]/l2+n0[1]/l0*n2[1]/l2+n0[2]/l0*n2[2]/l2,n1[0]/l1*n3[0]/l3+n1[1]/l1*n3[1]/l3+n1[2]/l1*n3[2]/l3); + double const warp=std::min(n0[0]/l0*n2[0]/l2+n0[1]/l0*n2[1]/l2+n0[2]/l0*n2[2]/l2,n1[0]/l1*n3[0]/l3+n1[1]/l1*n3[1]/l3+n1[2]/l1*n3[2]/l3); return warp*warp*warp; } double INTERP_KERNEL::triEdgeRatio(const double *coo) { - double a2=(coo[3]-coo[0])*(coo[3]-coo[0])+(coo[4]-coo[1])*(coo[4]-coo[1])+(coo[5]-coo[2])*(coo[5]-coo[2]); - double b2=(coo[6]-coo[3])*(coo[6]-coo[3])+(coo[7]-coo[4])*(coo[7]-coo[4])+(coo[8]-coo[5])*(coo[8]-coo[5]); - double c2=(coo[0]-coo[6])*(coo[0]-coo[6])+(coo[1]-coo[7])*(coo[1]-coo[7])+(coo[2]-coo[8])*(coo[2]-coo[8]); - double mab=a2mab?mab:c2; - double M2=c2>Mab?c2:Mab; + double const a2=(coo[3]-coo[0])*(coo[3]-coo[0])+(coo[4]-coo[1])*(coo[4]-coo[1])+(coo[5]-coo[2])*(coo[5]-coo[2]); + double const b2=(coo[6]-coo[3])*(coo[6]-coo[3])+(coo[7]-coo[4])*(coo[7]-coo[4])+(coo[8]-coo[5])*(coo[8]-coo[5]); + double const c2=(coo[0]-coo[6])*(coo[0]-coo[6])+(coo[1]-coo[7])*(coo[1]-coo[7])+(coo[2]-coo[8])*(coo[2]-coo[8]); + double const mab=a2mab?mab:c2; + double const M2=c2>Mab?c2:Mab; if(m2>1.e-15) return sqrt(M2/m2); else @@ -129,17 +128,17 @@ double INTERP_KERNEL::triEdgeRatio(const double *coo) double INTERP_KERNEL::triAspectRatio(const double *coo) { - double a=sqrt((coo[3]-coo[0])*(coo[3]-coo[0])+(coo[4]-coo[1])*(coo[4]-coo[1])+(coo[5]-coo[2])*(coo[5]-coo[2])); - double b=sqrt((coo[6]-coo[3])*(coo[6]-coo[3])+(coo[7]-coo[4])*(coo[7]-coo[4])+(coo[8]-coo[5])*(coo[8]-coo[5])); - double c=sqrt((coo[0]-coo[6])*(coo[0]-coo[6])+(coo[1]-coo[7])*(coo[1]-coo[7])+(coo[2]-coo[8])*(coo[2]-coo[8])); + double const a=sqrt((coo[3]-coo[0])*(coo[3]-coo[0])+(coo[4]-coo[1])*(coo[4]-coo[1])+(coo[5]-coo[2])*(coo[5]-coo[2])); + double const b=sqrt((coo[6]-coo[3])*(coo[6]-coo[3])+(coo[7]-coo[4])*(coo[7]-coo[4])+(coo[8]-coo[5])*(coo[8]-coo[5])); + double const c=sqrt((coo[0]-coo[6])*(coo[0]-coo[6])+(coo[1]-coo[7])*(coo[1]-coo[7])+(coo[2]-coo[8])*(coo[2]-coo[8])); double hm=a>b?a:b; hm=hm>c?hm:c; - double ab[3]={(coo[4]-coo[1])*(coo[8]-coo[5])-(coo[7]-coo[4])*(coo[5]-coo[2]), + double const ab[3]={(coo[4]-coo[1])*(coo[8]-coo[5])-(coo[7]-coo[4])*(coo[5]-coo[2]), (coo[5]-coo[2])*(coo[6]-coo[3])-(coo[3]-coo[0])*(coo[8]-coo[5]), (coo[3]-coo[0])*(coo[7]-coo[4])-(coo[4]-coo[1])*(coo[6]-coo[3])}; - double d=sqrt(ab[0]*ab[0]+ab[1]*ab[1]+ab[2]*ab[2]); + double const d=sqrt(ab[0]*ab[0]+ab[1]*ab[1]+ab[2]*ab[2]); static const double normalizeCoeff=sqrt(3.)/6.; if(d>1.e-15) return normalizeCoeff*hm*(a+b+c)/d; @@ -149,12 +148,12 @@ double INTERP_KERNEL::triAspectRatio(const double *coo) double INTERP_KERNEL::tetraEdgeRatio(const double *coo) { - double a[3]={coo[3]-coo[0],coo[4]-coo[1],coo[5]-coo[2]}; - double b[3]={coo[6]-coo[3],coo[7]-coo[4],coo[8]-coo[5]}; - double c[3]={coo[0]-coo[6],coo[1]-coo[7],coo[2]-coo[8]}; - double d[3]={coo[9]-coo[0],coo[10]-coo[1],coo[11]-coo[2]}; - double e[3]={coo[9]-coo[3],coo[10]-coo[4],coo[11]-coo[5]}; - double f[3]={coo[9]-coo[6],coo[10]-coo[7],coo[11]-coo[8]}; + double const a[3]={coo[3]-coo[0],coo[4]-coo[1],coo[5]-coo[2]}; + double const b[3]={coo[6]-coo[3],coo[7]-coo[4],coo[8]-coo[5]}; + double const c[3]={coo[0]-coo[6],coo[1]-coo[7],coo[2]-coo[8]}; + double const d[3]={coo[9]-coo[0],coo[10]-coo[1],coo[11]-coo[2]}; + double const e[3]={coo[9]-coo[3],coo[10]-coo[4],coo[11]-coo[5]}; + double const f[3]={coo[9]-coo[6],coo[10]-coo[7],coo[11]-coo[8]}; double l2[6]= {a[0]*a[0]+a[1]*a[1]+a[2]*a[2], @@ -164,8 +163,8 @@ double INTERP_KERNEL::tetraEdgeRatio(const double *coo) e[0]*e[0]+e[1]*e[1]+e[2]*e[2], f[0]*f[0]+f[1]*f[1]+f[2]*f[2]}; - double M2=*std::max_element(l2,l2+6); - double m2=*std::min_element(l2,l2+6); + double const M2=*std::max_element(l2,l2+6); + double const m2=*std::min_element(l2,l2+6); if(m2>1e-15) return sqrt(M2/m2); else @@ -175,28 +174,28 @@ double INTERP_KERNEL::tetraEdgeRatio(const double *coo) double INTERP_KERNEL::tetraAspectRatio(const double *coo) { static const double normalizeCoeff=sqrt(6.)/12.; - double ab[3]={coo[3]-coo[0],coo[4]-coo[1],coo[5]-coo[2]}; - double ac[3]={coo[6]-coo[0],coo[7]-coo[1],coo[8]-coo[2]}; - double ad[3]={coo[9]-coo[0],coo[10]-coo[1],coo[11]-coo[2]}; - double detTet=(ab[0]*(ac[1]*ad[2]-ac[2]*ad[1]))+(ab[1]*(ac[2]*ad[0]-ac[0]*ad[2]))+(ab[2]*(ac[0]*ad[1]-ac[1]*ad[0])); + double const ab[3]={coo[3]-coo[0],coo[4]-coo[1],coo[5]-coo[2]}; + double const ac[3]={coo[6]-coo[0],coo[7]-coo[1],coo[8]-coo[2]}; + double const ad[3]={coo[9]-coo[0],coo[10]-coo[1],coo[11]-coo[2]}; + double const detTet=(ab[0]*(ac[1]*ad[2]-ac[2]*ad[1]))+(ab[1]*(ac[2]*ad[0]-ac[0]*ad[2]))+(ab[2]*(ac[0]*ad[1]-ac[1]*ad[0])); //if(detTet<1.e-15) // return std::numeric_limits::max(); - double bc[3]={coo[6]-coo[3],coo[7]-coo[4],coo[8]-coo[5]}; + double const bc[3]={coo[6]-coo[3],coo[7]-coo[4],coo[8]-coo[5]}; double bd[3]={coo[9]-coo[3],coo[10]-coo[4],coo[11]-coo[5]}; - double cd[3]={coo[9]-coo[6],coo[10]-coo[7],coo[11]-coo[8]}; + double const cd[3]={coo[9]-coo[6],coo[10]-coo[7],coo[11]-coo[8]}; - double ab2=ab[0]*ab[0]+ab[1]*ab[1]+ab[2]*ab[2]; - double bc2=bc[0]*bc[0]+bc[1]*bc[1]+bc[2]*bc[2]; - double ac2=ac[0]*ac[0]+ac[1]*ac[1]+ac[2]*ac[2]; - double ad2=ad[0]*ad[0]+ad[1]*ad[1]+ad[2]*ad[2]; - double bd2=bd[0]*bd[0]+bd[1]*bd[1]+bd[2]*bd[2]; - double cd2=cd[0]*cd[0]+cd[1]*cd[1]+cd[2]*cd[2]; + double const ab2=ab[0]*ab[0]+ab[1]*ab[1]+ab[2]*ab[2]; + double const bc2=bc[0]*bc[0]+bc[1]*bc[1]+bc[2]*bc[2]; + double const ac2=ac[0]*ac[0]+ac[1]*ac[1]+ac[2]*ac[2]; + double const ad2=ad[0]*ad[0]+ad[1]*ad[1]+ad[2]*ad[2]; + double const bd2=bd[0]*bd[0]+bd[1]*bd[1]+bd[2]*bd[2]; + double const cd2=cd[0]*cd[0]+cd[1]*cd[1]+cd[2]*cd[2]; double A=ab2>bc2?ab2:bc2; double B=ac2>ad2?ac2:ad2; double C=bd2>cd2?bd2:cd2; double D=A>B?A:B; - double hm=D>C?sqrt(D):sqrt(C); + double const hm=D>C?sqrt(D):sqrt(C); bd[0]=ab[1]*bc[2]-ab[2]*bc[1]; bd[1]=ab[2]*bc[0]-ab[0]*bc[2]; bd[2]=ab[0]*bc[1]-ab[1]*bc[0]; A=sqrt(bd[0]*bd[0]+bd[1]*bd[1]+bd[2]*bd[2]); diff --git a/src/INTERP_KERNEL/InterpKernelRootsMultiDim.hxx b/src/INTERP_KERNEL/InterpKernelRootsMultiDim.hxx index c518349c6..01114b440 100644 --- a/src/INTERP_KERNEL/InterpKernelRootsMultiDim.hxx +++ b/src/INTERP_KERNEL/InterpKernelRootsMultiDim.hxx @@ -22,13 +22,14 @@ #include "InterpKernelDenseMatrix.hxx" #include "InterpKernelLUDecomp.hxx" -#include "InterpKernelQRDecomp.hxx" #include "InterpKernelException.hxx" #include "MCIdType.hxx" +#include #include #include #include +#include template inline T sqr(const T a) { return a*a; } @@ -100,18 +101,18 @@ namespace INTERP_KERNEL class JacobianCalculator { private: - const double EPS; + const double EPS{1.0e-8}; T &func; public: - JacobianCalculator(T &funcc) : EPS(1.0e-8),func(funcc) {} + JacobianCalculator(T &funcc) : func(funcc) {} INTERP_KERNEL::DenseMatrix operator() (const std::vector& x, const std::vector& fvec) { - mcIdType n=x.size(); + mcIdType const n=x.size(); INTERP_KERNEL::DenseMatrix df(n,n); std::vector xh=x; for (mcIdType j=0;j @@ -33,7 +31,7 @@ namespace INTERP_KERNEL class Interpolation : public InterpolationOptions { public: - Interpolation() { } + Interpolation() = default; Interpolation(const InterpolationOptions& io) :InterpolationOptions(io){} //interpolation of two triangular meshes. template diff --git a/src/INTERP_KERNEL/Interpolation.txx b/src/INTERP_KERNEL/Interpolation.txx old mode 100755 new mode 100644 index 33848df42..8533cbe63 --- a/src/INTERP_KERNEL/Interpolation.txx +++ b/src/INTERP_KERNEL/Interpolation.txx @@ -21,9 +21,15 @@ #define __INTERPOLATION_TXX__ #include "Interpolation.hxx" -#include "IntegralUniformIntersector.hxx" #include "IntegralUniformIntersector.txx" +#include "InterpolationOptions.hxx" +#include "InterpKernelException.hxx" #include "VectorUtils.hxx" +#include +#include +#include +#include +#include namespace INTERP_KERNEL { diff --git a/src/INTERP_KERNEL/Interpolation1D.hxx b/src/INTERP_KERNEL/Interpolation1D.hxx index 8ed838fcb..3a8a3d755 100644 --- a/src/INTERP_KERNEL/Interpolation1D.hxx +++ b/src/INTERP_KERNEL/Interpolation1D.hxx @@ -21,14 +21,15 @@ #ifndef __INTERPOLATION1D_HXX__ #define __INTERPOLATION1D_HXX__ -#include "InterpolationCurve.hxx" +#include "InterpolationOptions.hxx" +#include "InterpolationCurve.txx" namespace INTERP_KERNEL { class Interpolation1D : public InterpolationCurve { public: - Interpolation1D() { } + Interpolation1D() = default; Interpolation1D(const InterpolationOptions& io):InterpolationCurve(io) {} }; } diff --git a/src/INTERP_KERNEL/Interpolation1D.txx b/src/INTERP_KERNEL/Interpolation1D.txx index 599092f73..3975b0f6b 100644 --- a/src/INTERP_KERNEL/Interpolation1D.txx +++ b/src/INTERP_KERNEL/Interpolation1D.txx @@ -20,8 +20,6 @@ #ifndef __INTERPOLATION1D_TXX__ #define __INTERPOLATION1D_TXX__ -#include "Interpolation1D.hxx" -#include "InterpolationCurve.txx" #endif diff --git a/src/INTERP_KERNEL/Interpolation1D0D.cxx b/src/INTERP_KERNEL/Interpolation1D0D.cxx index 1f09c091a..1e7bb369c 100644 --- a/src/INTERP_KERNEL/Interpolation1D0D.cxx +++ b/src/INTERP_KERNEL/Interpolation1D0D.cxx @@ -19,12 +19,14 @@ // Author : Anthony GEAY (EDF R&D) #include "Interpolation1D0D.hxx" -#include "Interpolation1D0D.txx" +#include "InterpolationOptions.hxx" +#include +#include namespace INTERP_KERNEL { Interpolation1D0D::Interpolation1D0D() - {} + = default; Interpolation1D0D::Interpolation1D0D(const InterpolationOptions& io):Interpolation(io) {} @@ -37,7 +39,7 @@ namespace INTERP_KERNEL const int SPACE_DIM = 3; const double adj(getPrecision());// here precision is used instead of getBoundingBoxAdjustment and getBoundingBoxAdjustmentAbs because in the context only precision is relevant - std::size_t size = bbox.size()/(2*SPACE_DIM); + std::size_t const size = bbox.size()/(2*SPACE_DIM); for (std::size_t i=0; i #include namespace INTERP_KERNEL diff --git a/src/INTERP_KERNEL/Interpolation1D0D.txx b/src/INTERP_KERNEL/Interpolation1D0D.txx old mode 100755 new mode 100644 index 6eec38723..8bae8193b --- a/src/INTERP_KERNEL/Interpolation1D0D.txx +++ b/src/INTERP_KERNEL/Interpolation1D0D.txx @@ -21,18 +21,18 @@ #ifndef __INTERPOLATION1D0D_TXX__ #define __INTERPOLATION1D0D_TXX__ +#include "InterpKernelException.hxx" #include "Interpolation1D0D.hxx" -#include "Interpolation.txx" -#include "MeshElement.txx" -#include "PointLocator3DIntersectorP0P0.txx" -#include "PointLocator3DIntersectorP0P1.txx" -#include "PointLocator3DIntersectorP1P0.txx" -#include "PointLocator3DIntersectorP1P1.txx" +#include "MeshElement.hxx" #include "Log.hxx" #include "BBTree.txx" #include "InterpKernelAssert.hxx" +#include +#include +#include +#include namespace INTERP_KERNEL { @@ -44,7 +44,7 @@ namespace INTERP_KERNEL typename MyMeshType::MyConnType Interpolation1D0D::interpolateMeshes(const MyMeshType& srcMesh, const MyMeshType& targetMesh, MatrixType& result, const std::string& method) { constexpr int SPACEDIM=MyMeshType::MY_SPACEDIM; - using ConnType=typename MyMeshType::MyConnType; + typedef typename MyMeshType::MyConnType ConnType; IKAssert(SPACEDIM==3); if(InterpolationOptions::getIntersectionType() != PointLocator) diff --git a/src/INTERP_KERNEL/Interpolation2D.hxx b/src/INTERP_KERNEL/Interpolation2D.hxx index 3902c024b..632152445 100644 --- a/src/INTERP_KERNEL/Interpolation2D.hxx +++ b/src/INTERP_KERNEL/Interpolation2D.hxx @@ -21,14 +21,17 @@ #ifndef __INTERPOLATION2D_HXX__ #define __INTERPOLATION2D_HXX__ -#include "InterpolationPlanar.hxx" +#include "InterpolationOptions.hxx" +#include "PlanarIntersector.hxx" +#include "InterpolationPlanar.txx" +#include namespace INTERP_KERNEL { class Interpolation2D : public InterpolationPlanar { public: - Interpolation2D() { } + Interpolation2D() = default; Interpolation2D(const InterpolationOptions& io):InterpolationPlanar(io) { } public: bool doRotate() const { return false; } diff --git a/src/INTERP_KERNEL/Interpolation2D.txx b/src/INTERP_KERNEL/Interpolation2D.txx index 67bf2188b..9e63d332b 100644 --- a/src/INTERP_KERNEL/Interpolation2D.txx +++ b/src/INTERP_KERNEL/Interpolation2D.txx @@ -20,8 +20,6 @@ #ifndef __INTERPOLATION2D_TXX__ #define __INTERPOLATION2D_TXX__ -#include "Interpolation2D.hxx" -#include "InterpolationPlanar.txx" #endif diff --git a/src/INTERP_KERNEL/Interpolation2D1D.hxx b/src/INTERP_KERNEL/Interpolation2D1D.hxx index a25996140..f6b05b949 100644 --- a/src/INTERP_KERNEL/Interpolation2D1D.hxx +++ b/src/INTERP_KERNEL/Interpolation2D1D.hxx @@ -21,10 +21,13 @@ #ifndef __INTERPOLATION2D1D_HXX__ #define __INTERPOLATION2D1D_HXX__ -#include "Interpolation.hxx" -#include "Planar2D1DIntersectorP0P0.hxx" -#include "NormalizedUnstructuredMesh.hxx" +#include +#include +#include + #include "InterpolationOptions.hxx" +#include "Interpolation.hxx" +#include "MCIdType.hxx" namespace INTERP_KERNEL { @@ -40,7 +43,7 @@ namespace INTERP_KERNEL class Interpolation2D1D : public Interpolation { public: - typedef std::map > DuplicateFacesType; + using DuplicateFacesType = std::map>; Interpolation2D1D() { setOrientation(2); } Interpolation2D1D(const InterpolationOptions& io):Interpolation(io) { } diff --git a/src/INTERP_KERNEL/Interpolation2D1D.txx b/src/INTERP_KERNEL/Interpolation2D1D.txx old mode 100755 new mode 100644 index 0e95ea59e..d2fd7cfb5 --- a/src/INTERP_KERNEL/Interpolation2D1D.txx +++ b/src/INTERP_KERNEL/Interpolation2D1D.txx @@ -21,6 +21,21 @@ #define __INTERPOLATION2D1D_TXX__ #include "Interpolation2D1D.hxx" +#include +#include "NormalizedUnstructuredMesh.hxx" +#include "PlanarIntersector.txx" +#include "Planar2D1DIntersectorP0P0.hxx" +#include "InterpolationOptions.hxx" +#include "Geometric2DIntersector.txx" +#include "InterpKernelException.hxx" +#include "BBTree.txx" +#include "InterpolationUtils.hxx" + +#include +#include +#include +#include +#include namespace INTERP_KERNEL { @@ -52,7 +67,7 @@ namespace INTERP_KERNEL typedef typename MyMeshType::MyConnType ConnType; static const NumberingPolicy numPol=MyMeshType::My_numPol; - long global_start =clock(); + long const global_start =clock(); std::size_t counter=0; /***********************************************************/ /* Check both meshes are made of triangles and quadrangles */ @@ -72,7 +87,7 @@ namespace INTERP_KERNEL } PlanarIntersector* intersector=0; - std::string meth = InterpolationOptions::filterInterpolationMethod(method); + std::string const meth = InterpolationOptions::filterInterpolationMethod(method); if(meth=="P0P0") { switch (InterpolationOptions::getIntersectionType()) @@ -97,23 +112,23 @@ namespace INTERP_KERNEL /* Instantiate the intersector and initialise the result vector */ /****************************************************************/ - long start_filtering=clock(); + long const start_filtering=clock(); std::vector bbox; intersector->createBoundingBoxes(myMeshS,bbox); // create the bounding boxes - const double *bboxPtr=0; + const double *bboxPtr=nullptr; if(nbMailleS>0) bboxPtr=&bbox[0]; BBTree my_tree(bboxPtr, 0, 0,nbMailleS, -getPrecision());//creating the search structure - long end_filtering=clock(); + long const end_filtering=clock(); result.resize(intersector->getNumberOfRowsOfResMatrix());//on initialise. /****************************************************/ /* Loop on the target cells - core of the algorithm */ /****************************************************/ - long start_intersection=clock(); + long const start_intersection=clock(); ConnType nbelem_type=myMeshT.getNumberOfElements(); const ConnType *connIndxT=myMeshT.getConnectivityIndexPtr(); for(ConnType iT=0; iT=1) { - long end_intersection=clock(); + long const end_intersection=clock(); std::cout << "Filtering time= " << end_filtering-start_filtering << std::endl; std::cout << "Intersection time= " << end_intersection-start_intersection << std::endl; - long global_end =clock(); + long const global_end =clock(); std::cout << "Number of computed intersections = " << counter << std::endl; std::cout << "Global time= " << global_end - global_start << std::endl; } diff --git a/src/INTERP_KERNEL/Interpolation2D3D.cxx b/src/INTERP_KERNEL/Interpolation2D3D.cxx index 483d87382..1583b8373 100644 --- a/src/INTERP_KERNEL/Interpolation2D3D.cxx +++ b/src/INTERP_KERNEL/Interpolation2D3D.cxx @@ -18,6 +18,7 @@ // #include "Interpolation2D3D.hxx" +#include "InterpolationOptions.hxx" namespace INTERP_KERNEL { @@ -26,8 +27,7 @@ namespace INTERP_KERNEL * */ Interpolation2D3D::Interpolation2D3D() - { - } + = default; Interpolation2D3D::Interpolation2D3D(const InterpolationOptions& io):Interpolation(io) { } diff --git a/src/INTERP_KERNEL/Interpolation2D3D.hxx b/src/INTERP_KERNEL/Interpolation2D3D.hxx index 43e730440..dc1ba1e71 100644 --- a/src/INTERP_KERNEL/Interpolation2D3D.hxx +++ b/src/INTERP_KERNEL/Interpolation2D3D.hxx @@ -20,16 +20,17 @@ #ifndef __INTERPOLATION2D3D_HXX__ #define __INTERPOLATION2D3D_HXX__ +#include #include #include #include "INTERPKERNELDefines.hxx" -#include "Interpolation.hxx" -#include "NormalizedUnstructuredMesh.hxx" #include "InterpolationOptions.hxx" #include "MCIdType.hxx" #include "Intersector3D.hxx" -#include +#include "NormalizedGeometricTypes" +#include "Interpolation.hxx" +#include namespace INTERP_KERNEL { @@ -45,7 +46,7 @@ namespace INTERP_KERNEL class Interpolation2D3D : public Interpolation { public: - typedef std::map > DuplicateFacesType; + using DuplicateFacesType = std::map>; INTERPKERNEL_EXPORT Interpolation2D3D(); INTERPKERNEL_EXPORT Interpolation2D3D(const InterpolationOptions& io); diff --git a/src/INTERP_KERNEL/Interpolation2D3D.txx b/src/INTERP_KERNEL/Interpolation2D3D.txx old mode 100755 new mode 100644 index c7f8dca2c..5dd719852 --- a/src/INTERP_KERNEL/Interpolation2D3D.txx +++ b/src/INTERP_KERNEL/Interpolation2D3D.txx @@ -19,22 +19,23 @@ #ifndef __INTERPOLATION2D3D_TXX__ #define __INTERPOLATION2D3D_TXX__ +#include "BBTreeStandAlone.txx" +#include "BoundingBox.hxx" #include "Interpolation2D3D.hxx" -#include "Interpolation.txx" +// #include "Interpolation.txx" +#include "Intersector3D.txx" +#include "Log.hxx" +#include "InterpolationOptions.hxx" #include "MeshElement.txx" -#include "TransformedTriangle.hxx" +#include "NormalizedGeometricTypes" #include "Polyhedron3D2DIntersectorP0P0.txx" -#include "PointLocator3DIntersectorP0P0.txx" -#include "PolyhedronIntersectorP0P1.txx" -#include "PointLocator3DIntersectorP0P1.txx" -#include "PolyhedronIntersectorP1P0.txx" -#include "PolyhedronIntersectorP1P0Bary.txx" -#include "PointLocator3DIntersectorP1P0.txx" -#include "PolyhedronIntersectorP1P1.txx" -#include "PointLocator3DIntersectorP1P1.txx" #include "InterpolationHelper.txx" +#include "InterpKernelException.hxx" -#include "BBTree.txx" +#include +#include +#include +#include namespace INTERP_KERNEL { diff --git a/src/INTERP_KERNEL/Interpolation2DCurve.cxx b/src/INTERP_KERNEL/Interpolation2DCurve.cxx index ee38edea5..baabef9c2 100644 --- a/src/INTERP_KERNEL/Interpolation2DCurve.cxx +++ b/src/INTERP_KERNEL/Interpolation2DCurve.cxx @@ -20,6 +20,7 @@ #include "Interpolation2DCurve.hxx" #include "InterpolationCurve.txx" +#include "InterpolationOptions.hxx" namespace INTERP_KERNEL { diff --git a/src/INTERP_KERNEL/Interpolation2DCurve.hxx b/src/INTERP_KERNEL/Interpolation2DCurve.hxx index 9f6f908ba..99390cfca 100644 --- a/src/INTERP_KERNEL/Interpolation2DCurve.hxx +++ b/src/INTERP_KERNEL/Interpolation2DCurve.hxx @@ -21,8 +21,9 @@ #ifndef __INTERPOLATION2DCURVE_HXX__ #define __INTERPOLATION2DCURVE_HXX__ -#include "InterpolationCurve.hxx" +#include "INTERPKERNELDefines.hxx" #include "InterpolationOptions.hxx" +#include "InterpolationCurve.hxx" namespace INTERP_KERNEL { diff --git a/src/INTERP_KERNEL/Interpolation3D.cxx b/src/INTERP_KERNEL/Interpolation3D.cxx index 530f2c45a..c79041fa0 100644 --- a/src/INTERP_KERNEL/Interpolation3D.cxx +++ b/src/INTERP_KERNEL/Interpolation3D.cxx @@ -19,7 +19,7 @@ // Author : Anthony Geay (CEA/DEN) #include "Interpolation3D.hxx" -#include "Interpolation3D.txx" +#include "InterpolationOptions.hxx" namespace INTERP_KERNEL { @@ -28,8 +28,7 @@ namespace INTERP_KERNEL * */ Interpolation3D::Interpolation3D() - { - } + = default; Interpolation3D::Interpolation3D(const InterpolationOptions& io):Interpolation(io) { } diff --git a/src/INTERP_KERNEL/Interpolation3D.hxx b/src/INTERP_KERNEL/Interpolation3D.hxx old mode 100755 new mode 100644 index b7ff8abc4..8fce0d3ac --- a/src/INTERP_KERNEL/Interpolation3D.hxx +++ b/src/INTERP_KERNEL/Interpolation3D.hxx @@ -22,9 +22,9 @@ #define __INTERPOLATION3D_HXX__ #include "INTERPKERNELDefines.hxx" -#include "Interpolation.hxx" -#include "NormalizedUnstructuredMesh.hxx" #include "InterpolationOptions.hxx" +#include "Interpolation.hxx" +#include namespace INTERP_KERNEL { diff --git a/src/INTERP_KERNEL/Interpolation3D.txx b/src/INTERP_KERNEL/Interpolation3D.txx old mode 100755 new mode 100644 index 6668dab81..ecee51b99 --- a/src/INTERP_KERNEL/Interpolation3D.txx +++ b/src/INTERP_KERNEL/Interpolation3D.txx @@ -22,9 +22,13 @@ #define __INTERPOLATION3D_TXX__ #include "Interpolation3D.hxx" -#include "Interpolation.txx" + +#include "BBTreeStandAlone.txx" +#include "BoundingBox.hxx" +#include "InterpolationOptions.hxx" +#include "Intersector3D.hxx" #include "MeshElement.txx" -#include "TransformedTriangle.hxx" + #include "PolyhedronIntersectorP0P0.txx" #include "PointLocator3DIntersectorP0P0.txx" #include "PolyhedronIntersectorP0P1.txx" @@ -37,6 +41,10 @@ #include "Barycentric3DIntersectorP1P1.txx" #include "MappedBarycentric3DIntersectorP1P1.txx" #include "Log.hxx" +#include "InterpKernelException.hxx" +#include +#include +#include // If defined, use recursion to traverse the binary search tree, else use the BBTree class //#define USE_RECURSIVE_BBOX_FILTER @@ -51,7 +59,6 @@ #endif -#include namespace INTERP_KERNEL { diff --git a/src/INTERP_KERNEL/Interpolation3D1D.cxx b/src/INTERP_KERNEL/Interpolation3D1D.cxx index 05e08aa76..5d8fe5bef 100644 --- a/src/INTERP_KERNEL/Interpolation3D1D.cxx +++ b/src/INTERP_KERNEL/Interpolation3D1D.cxx @@ -19,11 +19,14 @@ // Author : Adrien Bruneton (CEA/DEN) #include "Interpolation3D1D.hxx" -#include "Interpolation3D1D.txx" +#include "InterpolationOptions.hxx" +#include +#include +#include namespace INTERP_KERNEL { - Interpolation3D1D::Interpolation3D1D() { } + Interpolation3D1D::Interpolation3D1D() = default; Interpolation3D1D::Interpolation3D1D(const InterpolationOptions& io):Interpolation(io) { } @@ -33,13 +36,13 @@ namespace INTERP_KERNEL const double adj = getBoundingBoxAdjustmentAbs(); const double adjRel = getBoundingBoxAdjustment(); - std::size_t size = sz/(2*SPACE_DIM); + std::size_t const size = sz/(2*SPACE_DIM); for (std::size_t i=0; i::max(); for(int idim=0; idim +#include #include namespace INTERP_KERNEL diff --git a/src/INTERP_KERNEL/Interpolation3D1D.txx b/src/INTERP_KERNEL/Interpolation3D1D.txx old mode 100755 new mode 100644 index 35e01c71c..094abc509 --- a/src/INTERP_KERNEL/Interpolation3D1D.txx +++ b/src/INTERP_KERNEL/Interpolation3D1D.txx @@ -20,16 +20,22 @@ #pragma once +#include "InterpKernelException.hxx" +#include "BBTreeStandAlone.txx" +#include "BoundingBox.hxx" #include "Interpolation3D1D.hxx" -#include "Interpolation.txx" -#include "MeshElement.txx" -#include "PointLocator3DIntersectorP0P0.txx" -#include "PointLocator3DIntersectorP0P1.txx" -#include "PointLocator3DIntersectorP1P0.txx" -#include "PointLocator3DIntersectorP1P1.txx" +#include "Intersector3D.hxx" +#include "MeshElement.hxx" +#include "PointLocator3DIntersectorP0P0.hxx" +#include "PointLocator3DIntersectorP0P1.hxx" +#include "PointLocator3DIntersectorP1P0.hxx" +#include "PointLocator3DIntersectorP1P1.hxx" #include "Log.hxx" #include "InterpolationHelper.txx" +#include +#include +#include namespace INTERP_KERNEL { diff --git a/src/INTERP_KERNEL/Interpolation3DSurf.cxx b/src/INTERP_KERNEL/Interpolation3DSurf.cxx index 8ad977928..308a88a79 100644 --- a/src/INTERP_KERNEL/Interpolation3DSurf.cxx +++ b/src/INTERP_KERNEL/Interpolation3DSurf.cxx @@ -19,13 +19,13 @@ // Author : Anthony Geay (CEA/DEN) #include "Interpolation3DSurf.hxx" +#include "InterpolationOptions.hxx" #include "InterpolationPlanar.txx" namespace INTERP_KERNEL { Interpolation3DSurf::Interpolation3DSurf() - { - } + = default; Interpolation3DSurf::Interpolation3DSurf(const InterpolationOptions& io):InterpolationPlanar(io) { @@ -51,8 +51,8 @@ namespace INTERP_KERNEL - Values: integer between 0 and 3. - Default: 0. */ - void Interpolation3DSurf::setOptions(double precision, int printLevel, double medianPlan, - IntersectionType intersectionType, bool doRotat, int orientation) + void Interpolation3DSurf::setOptions(double precision, int printLevel, double medianPlan, + IntersectionType intersectionType, bool doRotat, int orientation) { InterpolationPlanar::setOptions(precision,printLevel,intersectionType, orientation); InterpolationPlanar::setDoRotate(doRotat); diff --git a/src/INTERP_KERNEL/Interpolation3DSurf.hxx b/src/INTERP_KERNEL/Interpolation3DSurf.hxx index ae8d1728e..8d4836001 100644 --- a/src/INTERP_KERNEL/Interpolation3DSurf.hxx +++ b/src/INTERP_KERNEL/Interpolation3DSurf.hxx @@ -21,9 +21,11 @@ #ifndef __INTERPOLATION3DSURF_HXX__ #define __INTERPOLATION3DSURF_HXX__ -#include "InterpolationPlanar.txx" #include "INTERPKERNELDefines.hxx" #include "InterpolationOptions.hxx" +#include "PlanarIntersector.hxx" +#include "InterpolationPlanar.txx" +#include namespace INTERP_KERNEL { diff --git a/src/INTERP_KERNEL/InterpolationCC.hxx b/src/INTERP_KERNEL/InterpolationCC.hxx index 2af069f72..db50aabd4 100644 --- a/src/INTERP_KERNEL/InterpolationCC.hxx +++ b/src/INTERP_KERNEL/InterpolationCC.hxx @@ -24,6 +24,7 @@ #ifndef __InterpolationCC_HXX__ #define __InterpolationCC_HXX__ +#include "InterpolationOptions.hxx" #include "Interpolation.hxx" namespace INTERP_KERNEL diff --git a/src/INTERP_KERNEL/InterpolationCC.txx b/src/INTERP_KERNEL/InterpolationCC.txx index 954fdd74e..3c109bfce 100644 --- a/src/INTERP_KERNEL/InterpolationCC.txx +++ b/src/INTERP_KERNEL/InterpolationCC.txx @@ -22,7 +22,11 @@ // #include "InterpolationCC.hxx" +#include "InterpolationOptions.hxx" #include "InterpolationUtils.hxx" +#include +#include +#include // convert index "From Mesh Index" #define _FMI(i) OTT::ind2C((i)) @@ -37,8 +41,7 @@ namespace INTERP_KERNEL */ //================================================================================ InterpolationCC::InterpolationCC() - { - } + = default; InterpolationCC::InterpolationCC(const InterpolationOptions& io):Interpolation(io) { @@ -217,12 +220,12 @@ namespace INTERP_KERNEL x2t = tgt_coords[ j ][ it+1 ]; x2s = src_coords[ j ][ is+1 ]; - double x1 = std::max( x1s ,x1t ); - double x2 = std::min( x2s ,x2t ); + double const x1 = std::max( x1s ,x1t ); + double const x2 = std::min( x2s ,x2t ); axis_interferences.push_back( Interference( is, it, x2 - x1 )); // to the next target and/or source cell - double diff2 = x2s - x2t; + double const diff2 = x2s - x2t; if ( diff2 > -eps ) intersection = ( ++it < tgt_nb_cells[j] ); if ( diff2 < eps ) diff --git a/src/INTERP_KERNEL/InterpolationCU.hxx b/src/INTERP_KERNEL/InterpolationCU.hxx index 5a64bb87b..96b211ebc 100644 --- a/src/INTERP_KERNEL/InterpolationCU.hxx +++ b/src/INTERP_KERNEL/InterpolationCU.hxx @@ -24,9 +24,8 @@ #ifndef __InterpolationCU_HXX__ #define __InterpolationCU_HXX__ +#include "InterpolationOptions.hxx" #include "Interpolation.hxx" -#include "NormalizedUnstructuredMesh.hxx" -#include "InterpKernelUtilities.hxx" namespace INTERP_KERNEL { diff --git a/src/INTERP_KERNEL/InterpolationCU.txx b/src/INTERP_KERNEL/InterpolationCU.txx index 9b8fc34ec..5db3a5fd9 100644 --- a/src/INTERP_KERNEL/InterpolationCU.txx +++ b/src/INTERP_KERNEL/InterpolationCU.txx @@ -25,12 +25,18 @@ #include "InterpolationCU.hxx" -#include "Interpolation.txx" +#include "InterpolationUtils.hxx" +#include "InterpolationOptions.hxx" +#include "IntersectorCU.txx" #include "IntersectorCU1D.txx" #include "IntersectorCU2D.txx" #include "IntersectorCU3D.txx" - +#include "NormalizedGeometricTypes" +#include "TargetIntersector.hxx" +#include #include +#include + // // convert index "From Mesh Index" #define _FMIU(i) OTT::ind2C((i)) @@ -59,8 +65,7 @@ namespace INTERP_KERNEL //================================================================================ InterpolationCU::InterpolationCU() - { - } + = default; InterpolationCU::InterpolationCU(const InterpolationOptions & io) :Interpolation(io) @@ -223,7 +228,7 @@ namespace INTERP_KERNEL MatrixType revResult; CConnType sizeT = interpolateMeshes( meshT, meshS, revResult, method ); - UConnType sizeS = static_cast(revResult.size()); + auto sizeS = static_cast(revResult.size()); result.resize( sizeT ); for ( CConnType iS = 0; iS < sizeS; ++iS ) diff --git a/src/INTERP_KERNEL/InterpolationCurve.hxx b/src/INTERP_KERNEL/InterpolationCurve.hxx old mode 100755 new mode 100644 index 37b3aca2b..c38ce7f52 --- a/src/INTERP_KERNEL/InterpolationCurve.hxx +++ b/src/INTERP_KERNEL/InterpolationCurve.hxx @@ -27,6 +27,8 @@ #include "BBTree.txx" #include +#include +#include namespace INTERP_KERNEL { diff --git a/src/INTERP_KERNEL/InterpolationCurve.txx b/src/INTERP_KERNEL/InterpolationCurve.txx old mode 100755 new mode 100644 index 9cd3cbf21..bb0e5bf02 --- a/src/INTERP_KERNEL/InterpolationCurve.txx +++ b/src/INTERP_KERNEL/InterpolationCurve.txx @@ -20,24 +20,34 @@ #ifndef __INTERPOLATIONCURVE_TXX__ #define __INTERPOLATIONCURVE_TXX__ -#include "InterpolationCurve.hxx" -#include "InterpolationOptions.hxx" +#include "Interpolation.txx" +#include "BBTree.txx" +#include "CurveIntersector.txx" #include "CurveIntersectorP0P0.txx" -#include "CurveIntersectorP1P0.txx" #include "CurveIntersectorP0P1.txx" +#include "CurveIntersectorP1P0.txx" #include "CurveIntersectorP1P1.txx" #include "CurveIntersectorP1P1PL.txx" +#include "InterpolationCurve.hxx" +#include "InterpolationOptions.hxx" +#include "NormalizedUnstructuredMesh.hxx" +#include "InterpolationUtils.hxx" +#include +#include +#include +#include +#include #include #include +#include namespace INTERP_KERNEL { template InterpolationCurve::InterpolationCurve() - { - } + = default; template InterpolationCurve::InterpolationCurve (const InterpolationOptions& io) @@ -80,7 +90,7 @@ namespace INTERP_KERNEL typedef typename MyMeshType::MyConnType ConnType; static const NumberingPolicy numPol = MyMeshType::My_numPol; - long global_start = clock(); + long const global_start = clock(); std::size_t counter=0; ConnType nbMailleS = myMeshS.getNumberOfElements(); @@ -169,7 +179,7 @@ namespace INTERP_KERNEL /* Instantiate the intersector and initialise the result vector */ /****************************************************************/ - long start_filtering=clock(); + long const start_filtering=clock(); std::vector bbox; intersector->createBoundingBoxes(myMeshS,bbox); // create the bounding boxes @@ -177,14 +187,14 @@ namespace INTERP_KERNEL InterpolationOptions::getBoundingBoxAdjustmentAbs()); BBTree my_tree(&bbox[0], 0, 0, nbMailleS);//creating the search structure - long end_filtering = clock(); + long const end_filtering = clock(); result.resize(intersector->getNumberOfRowsOfResMatrix());//on initialise. /****************************************************/ /* Loop on the target cells - core of the algorithm */ /****************************************************/ - long start_intersection = clock(); + long const start_intersection = clock(); const ConnType *connIndxT = myMeshT.getConnectivityIndexPtr(); for(ConnType iT=0; iT= 1) { - long end_intersection=clock(); + long const end_intersection=clock(); std::cout << "Filtering time= " << end_filtering-start_filtering << std::endl; std::cout << "Intersection time= " << end_intersection-start_intersection << std::endl; - long global_end =clock(); + long const global_end =clock(); std::cout << "Number of computed intersections = " << counter << std::endl; std::cout << "Global time= " << global_end - global_start << std::endl; } diff --git a/src/INTERP_KERNEL/InterpolationHelper.txx b/src/INTERP_KERNEL/InterpolationHelper.txx old mode 100755 new mode 100644 index e2ca32318..f0fead1c8 --- a/src/INTERP_KERNEL/InterpolationHelper.txx +++ b/src/INTERP_KERNEL/InterpolationHelper.txx @@ -22,10 +22,12 @@ #include "BBTreeStandAlone.txx" #include "MeshElement.txx" +#include "BoundingBox.hxx" #include "Log.hxx" #include #include +#include namespace INTERP_KERNEL { diff --git a/src/INTERP_KERNEL/InterpolationOptions.cxx b/src/INTERP_KERNEL/InterpolationOptions.cxx index 540f50c0d..e89b6c070 100644 --- a/src/INTERP_KERNEL/InterpolationOptions.cxx +++ b/src/INTERP_KERNEL/InterpolationOptions.cxx @@ -19,10 +19,13 @@ // Author : Anthony Geay (CEA/DEN) #include "InterpolationOptions.hxx" -#include "InterpKernelGeo2DPrecision.hxx" #include "InterpKernelException.hxx" +#include "NormalizedGeometricTypes" +#include +#include #include +#include const double INTERP_KERNEL::InterpolationOptions::DFT_MEDIAN_PLANE=0.5; @@ -165,7 +168,7 @@ bool INTERP_KERNEL::InterpolationOptions::setOptionInt(const std::string& key, i } else if(key==MEASURE_ABS_STR) { - bool valBool=(value!=0); + bool const valBool=(value!=0); setMeasureAbsStatus(valBool); return true; } diff --git a/src/INTERP_KERNEL/InterpolationOptions.hxx b/src/INTERP_KERNEL/InterpolationOptions.hxx index 58e2f238d..ff46b1e69 100644 --- a/src/INTERP_KERNEL/InterpolationOptions.hxx +++ b/src/INTERP_KERNEL/InterpolationOptions.hxx @@ -22,7 +22,7 @@ #define __INTERPOLATIONOPTIONS_HXX__ #include "INTERPKERNELDefines.hxx" -#include "NormalizedUnstructuredMesh.hxx" +#include "NormalizedGeometricTypes" #include diff --git a/src/INTERP_KERNEL/InterpolationPlanar.hxx b/src/INTERP_KERNEL/InterpolationPlanar.hxx old mode 100755 new mode 100644 index afe8b72dc..60ca49ef2 --- a/src/INTERP_KERNEL/InterpolationPlanar.hxx +++ b/src/INTERP_KERNEL/InterpolationPlanar.hxx @@ -23,8 +23,9 @@ #include "Interpolation.hxx" #include "PlanarIntersector.hxx" -#include "NormalizedUnstructuredMesh.hxx" #include "InterpolationOptions.hxx" +#include +#include namespace INTERP_KERNEL { diff --git a/src/INTERP_KERNEL/InterpolationPlanar.txx b/src/INTERP_KERNEL/InterpolationPlanar.txx old mode 100755 new mode 100644 index 65ab44f9c..29fe3fbc8 --- a/src/INTERP_KERNEL/InterpolationPlanar.txx +++ b/src/INTERP_KERNEL/InterpolationPlanar.txx @@ -22,31 +22,38 @@ #define __INTERPOLATIONPLANAR_TXX__ #include "InterpolationPlanar.hxx" + #include "Interpolation.txx" #include "InterpolationOptions.hxx" -#include "PlanarIntersector.hxx" +#include "NormalizedUnstructuredMesh.hxx" +#include "InterpolationUtils.hxx" + +#include "PlanarIntersectorP0P0.hxx" +#include "PlanarIntersectorP1P0.hxx" +#include "PlanarIntersectorP0P1.hxx" +#include "PlanarIntersectorP1P1.hxx" +#include "PlanarIntersectorP0P1Bary.hxx" +#include "PlanarIntersectorP1P0Bary.hxx" + #include "PlanarIntersector.txx" -#include "TriangulationIntersector.hxx" #include "TriangulationIntersector.txx" -#include "ConvexIntersector.hxx" #include "ConvexIntersector.txx" -#include "Geometric2DIntersector.hxx" #include "Geometric2DIntersector.txx" -#include "PointLocator2DIntersector.hxx" #include "PointLocator2DIntersector.txx" -#include "PlanarIntersectorP0P1PL.hxx" #include "PlanarIntersectorP0P1PL.txx" -#include "PlanarIntersectorP1P0PL.hxx" #include "PlanarIntersectorP1P0PL.txx" -#include "PlanarIntersectorP1P1PL.hxx" #include "PlanarIntersectorP1P1PL.txx" -#include "MappedBarycentric2DIntersectorP1P1.hxx" #include "MappedBarycentric2DIntersectorP1P1.txx" #include "VectorUtils.hxx" #include "BBTree.txx" +#include +#include +#include #include +#include #include +#include namespace INTERP_KERNEL { @@ -113,7 +120,7 @@ namespace INTERP_KERNEL typedef typename MyMeshType::MyConnType ConnType; static const NumberingPolicy numPol=MyMeshType::My_numPol; - long global_start =clock(); + long const global_start =clock(); std::size_t counter=0; /***********************************************************/ /* Check both meshes are made of triangles and quadrangles */ @@ -372,24 +379,24 @@ namespace INTERP_KERNEL /* Instantiate the intersector and initialise the result vector */ /****************************************************************/ - long start_filtering=clock(); + long const start_filtering=clock(); std::vector bbox; intersector->createBoundingBoxes(myMeshS,bbox); // create the bounding boxes performAdjustmentOfBB(intersector,bbox); - const double *bboxPtr=0; + const double *bboxPtr=nullptr; if(nbMailleS>0) bboxPtr=&bbox[0]; BBTree my_tree(bboxPtr, 0, 0,nbMailleS);//creating the search structure - long end_filtering=clock(); + long const end_filtering=clock(); result.resize(intersector->getNumberOfRowsOfResMatrix());//on initialise. /****************************************************/ /* Loop on the target cells - core of the algorithm */ /****************************************************/ - long start_intersection=clock(); + long const start_intersection=clock(); ConnType nbelem_type=myMeshT.getNumberOfElements(); const ConnType *connIndxT=myMeshT.getConnectivityIndexPtr(); for(ConnType iT=0; iT=1) { - long end_intersection=clock(); + long const end_intersection=clock(); std::cout << "Filtering time= " << end_filtering-start_filtering << std::endl; std::cout << "Intersection time= " << end_intersection-start_intersection << std::endl; - long global_end =clock(); + long const global_end =clock(); std::cout << "Number of computed intersections = " << counter << std::endl; std::cout << "Global time= " << global_end - global_start << std::endl; } diff --git a/src/INTERP_KERNEL/InterpolationUtils.hxx b/src/INTERP_KERNEL/InterpolationUtils.hxx index 901b27a23..c51c43b9f 100644 --- a/src/INTERP_KERNEL/InterpolationUtils.hxx +++ b/src/INTERP_KERNEL/InterpolationUtils.hxx @@ -21,16 +21,19 @@ #ifndef __INTERPOLATIONUTILS_HXX__ #define __INTERPOLATIONUTILS_HXX__ -#include "INTERPKERNELDefines.hxx" #include "InterpKernelException.hxx" +#include "MCIdType.hxx" #include "VolSurfUser.hxx" +#include "NormalizedGeometricTypes" #include "NormalizedUnstructuredMesh.hxx" +#include #include +#include #include #include -#include +#include #include #include #include @@ -70,8 +73,8 @@ namespace INTERP_KERNEL inline double Surf_Tri(const double *P_1,const double *P_2,const double *P_3) { - double A=(P_3[1]-P_1[1])*(P_2[0]-P_1[0])-(P_2[1]-P_1[1])*(P_3[0]-P_1[0]); - double Surface = 0.5*fabs(A); + double const A=(P_3[1]-P_1[1])*(P_2[0]-P_1[0])-(P_2[1]-P_1[1])*(P_3[0]-P_1[0]); + double const Surface = 0.5*fabs(A); return Surface; } @@ -87,7 +90,7 @@ namespace INTERP_KERNEL const double *P_2, const double *P_3) { - double mon_det=(P_1[0]-P_3[0])*(P_2[1]-P_3[1])-(P_2[0]-P_3[0])*(P_1[1]-P_3[1]); + double const mon_det=(P_1[0]-P_3[0])*(P_2[1]-P_3[1])-(P_2[0]-P_3[0])*(P_1[1]-P_3[1]); return mon_det; } @@ -96,8 +99,8 @@ namespace INTERP_KERNEL inline double norme_vecteur(const double* P_1,const double* P_2) { - double X=P_1[0]-P_2[0]; - double Y=P_1[1]-P_2[1]; + double const X=P_1[0]-P_2[0]; + double const Y=P_1[1]-P_2[1]; return sqrt(X*X+Y*Y); } @@ -117,18 +120,18 @@ namespace INTERP_KERNEL { std::vector Vect; - double P1_P2=norme_vecteur(P_1,P_2); - double P2_P3=norme_vecteur(P_2,P_3); - double P3_P1=norme_vecteur(P_3,P_1); + double const P1_P2=norme_vecteur(P_1,P_2); + double const P2_P3=norme_vecteur(P_2,P_3); + double const P3_P1=norme_vecteur(P_3,P_1); - double N=P1_P2*P1_P2+P3_P1*P3_P1-P2_P3*P2_P3; - double D=2.0*P1_P2*P3_P1; + double const N=P1_P2*P1_P2+P3_P1*P3_P1-P2_P3*P2_P3; + double const D=2.0*P1_P2*P3_P1; double COS=N/D; if (COS>1.0) COS=1.0; if (COS<-1.0) COS=-1.0; Vect.push_back(COS); - double V=mon_determinant(P_2,P_3,P_1); - double D_1=P1_P2*P3_P1; + double const V=mon_determinant(P_2,P_3,P_1); + double const D_1=P1_P2*P3_P1; double SIN=V/D_1; if (SIN>1.0) SIN=1.0; if (SIN<-1.0) SIN=-1.0; @@ -197,7 +200,7 @@ namespace INTERP_KERNEL inline std::vector bary_poly(const std::vector& V) { std::vector Bary; - std::size_t taille=V.size(); + std::size_t const taille=V.size(); double x=0; double y=0; @@ -206,8 +209,8 @@ namespace INTERP_KERNEL x=x+V[2*i]; y=y+V[2*i+1]; } - double A=2*x/(static_cast(taille)); - double B=2*y/(static_cast(taille)); + double const A=2*x/(static_cast(taille)); + double const B=2*y/(static_cast(taille)); Bary.push_back(A);//taille vecteur=2*nb de points. Bary.push_back(B); @@ -288,7 +291,7 @@ namespace INTERP_KERNEL double max = std::fabs( M[ iR[i] ][i] ); for ( int r = i+1; r < (int)nbRow; ++r ) { - double m = std::fabs( M[ iR[r] ][i] ); + double const m = std::fabs( M[ iR[r] ][i] ); if ( m > max ) { max = m; @@ -305,7 +308,7 @@ namespace INTERP_KERNEL for ( int r = i+1; r < (int)nbRow; ++r ) { double* mRow = M[ iR[r] ]; - double coef = mRow[ i ] / tUpRow[ i ]; + double const coef = mRow[ i ] / tUpRow[ i ]; for ( int c = i+1; c < nbCol; ++c ) mRow[ c ] -= tUpRow[ c ] * coef; } @@ -404,7 +407,7 @@ namespace INTERP_KERNEL T11 = triaCoords[0]-triaCoords[2*SPACEDIM], T12 = triaCoords[SPACEDIM]-triaCoords[2*SPACEDIM], T21 = triaCoords[1]-triaCoords[2*SPACEDIM+1], T22 = triaCoords[SPACEDIM+1]-triaCoords[2*SPACEDIM+1]; // matrix determinant - double Tdet = T11*T22 - T12*T21; + double const Tdet = T11*T22 - T12*T21; if ( fabs( Tdet ) < std::numeric_limits::min() ) { bc[0]=1; bc[1]=0; bc[2]=0; return; @@ -421,7 +424,7 @@ namespace INTERP_KERNEL inline void barycentric_coords_seg2(const std::vector& n, const double *p, double *bc) { - double delta=n[0][0]-n[1][0]; + double const delta=n[0][0]-n[1][0]; bc[0]=fabs((*p-n[1][0])/delta); bc[1]=fabs((*p-n[0][0])/delta); } @@ -434,7 +437,7 @@ namespace INTERP_KERNEL T11 = n[0][_XX]-n[2][_XX], T12 = n[1][_XX]-n[2][_XX], T21 = n[0][_YY]-n[2][_YY], T22 = n[1][_YY]-n[2][_YY]; // matrix determinant - double Tdet = T11*T22 - T12*T21; + double const Tdet = T11*T22 - T12*T21; if ( (std::fabs( Tdet) ) < (std::numeric_limits::min()) ) { bc[0]=1; bc[1]=bc[2]=0; // no solution @@ -612,11 +615,11 @@ namespace INTERP_KERNEL inline bool IsPointOn3DSeg(const double segStart[3], const double segStop[3], const double point[3], double eps, double& bc0, double& bc1) { double AB[3]={segStop[0]-segStart[0],segStop[1]-segStart[1],segStop[2]-segStart[2]},AP[3]={point[0]-segStart[0],point[1]-segStart[1],point[2]-segStart[2]}; - double l_AB(sqrt(AB[0]*AB[0]+AB[1]*AB[1]+AB[2]*AB[2])); + double const l_AB(sqrt(AB[0]*AB[0]+AB[1]*AB[1]+AB[2]*AB[2])); double AP_dot_AB((AP[0]*AB[0]+AP[1]*AB[1]+AP[2]*AB[2])/(l_AB*l_AB)); - double projOfPOnAB[3]={segStart[0]+AP_dot_AB*AB[0],segStart[1]+AP_dot_AB*AB[1],segStart[2]+AP_dot_AB*AB[2]}; - double V_dist_P_AB[3]={point[0]-projOfPOnAB[0],point[1]-projOfPOnAB[1],point[2]-projOfPOnAB[2]}; - double dist_P_AB(sqrt(V_dist_P_AB[0]*V_dist_P_AB[0]+V_dist_P_AB[1]*V_dist_P_AB[1]+V_dist_P_AB[2]*V_dist_P_AB[2])); + double const projOfPOnAB[3]={segStart[0]+AP_dot_AB*AB[0],segStart[1]+AP_dot_AB*AB[1],segStart[2]+AP_dot_AB*AB[2]}; + double const V_dist_P_AB[3]={point[0]-projOfPOnAB[0],point[1]-projOfPOnAB[1],point[2]-projOfPOnAB[2]}; + double const dist_P_AB(sqrt(V_dist_P_AB[0]*V_dist_P_AB[0]+V_dist_P_AB[1]*V_dist_P_AB[1]+V_dist_P_AB[2]*V_dist_P_AB[2])); if(dist_P_AB>=eps) return false;//to far from segment [segStart,segStop] if(AP_dot_AB<-eps || AP_dot_AB>1.+eps) @@ -646,22 +649,22 @@ namespace INTERP_KERNEL */ inline void quad_mapped_coords(const std::vector& n, const double *p, double *bc) { - double prec = 1.0e-14; + double const prec = 1.0e-14; enum { _XX=0, _YY, _ZZ }; if(n.size() != 4) throw INTERP_KERNEL::Exception("INTERP_KERNEL::quad_mapped_coords : unrecognized geometric type! Only QUAD4 supported."); - double A[2] = {n[1][_XX] - n[0][_XX], n[1][_YY] - n[0][_YY]}; - double B[2] = {n[2][_XX] - n[0][_XX], n[2][_YY] - n[0][_YY]}; - double C[2] = {n[3][_XX] - n[0][_XX], n[3][_YY] - n[0][_YY]}; - double N[2] = {B[_XX] - A[_XX] - C[_XX], B[_YY] - A[_YY] - C[_YY]}; - double P[2] = {p[_XX] - n[0][_XX], p[_YY] - n[0][_YY]}; + double const A[2] = {n[1][_XX] - n[0][_XX], n[1][_YY] - n[0][_YY]}; + double const B[2] = {n[2][_XX] - n[0][_XX], n[2][_YY] - n[0][_YY]}; + double const C[2] = {n[3][_XX] - n[0][_XX], n[3][_YY] - n[0][_YY]}; + double const N[2] = {B[_XX] - A[_XX] - C[_XX], B[_YY] - A[_YY] - C[_YY]}; + double const P[2] = {p[_XX] - n[0][_XX], p[_YY] - n[0][_YY]}; // degenerated case: a rectangle: if (fabs(N[0]) < prec && fabs(N[1]) < prec) { - double det = C[0]*A[1] -C[1]*A[0]; + double const det = C[0]*A[1] -C[1]*A[0]; if (fabs(det) < prec) throw INTERP_KERNEL::Exception("MappedBarycentric intersection type: quad_mapped_coords() has a degenerated 2x2 system!"); bc[0] = (P[0]*A[1]-P[1]*A[0])/det; @@ -683,7 +686,7 @@ namespace INTERP_KERNEL c = -P[0]*A[1] + P[1]*A[0]; cas1 = false; } - double delta = b*b - 4.0*a*c; + double const delta = b*b - 4.0*a*c; if (delta < 0.0) throw INTERP_KERNEL::Exception("MappedBarycentric intersection type: quad_mapped_coords(): imaginary solutions!"); bc[1] = 0.5*(-b+sqrt(delta))/a; @@ -693,7 +696,7 @@ namespace INTERP_KERNEL throw INTERP_KERNEL::Exception("MappedBarycentric intersection type: quad_mapped_coords(): point doesn't seem to be in quad4!"); if (cas1) { - double denom = C[0]+bc[1]*N[0]; + double const denom = C[0]+bc[1]*N[0]; if (fabs(denom) < prec) throw INTERP_KERNEL::Exception("MappedBarycentric intersection type: quad_mapped_coords(): point doesn't seem to be in quad4!"); bc[0] = (P[0]-bc[1]*A[0])/denom; @@ -703,7 +706,7 @@ namespace INTERP_KERNEL else { bc[0] = bc[1]; - double denom = A[1]+bc[0]*N[1]; + double const denom = A[1]+bc[0]*N[1]; if (fabs(denom) < prec) throw INTERP_KERNEL::Exception("MappedBarycentric intersection type: cuboid_mapped_coord(): point doesn't seem to be in quad4!"); bc[1] = (P[1]-bc[0]*C[1])/denom; @@ -733,7 +736,7 @@ namespace INTERP_KERNEL inline void cuboid_mapped_coords(const std::vector& n, const double *p, double *bc) { - double prec = 1.0e-14; + double const prec = 1.0e-14; enum { _XX=0, _YY }; if (n.size() != 8) throw INTERP_KERNEL::Exception("INTERP_KERNEL::cuboid_mapped_coords: unrecognized geometric type! Only HEXA8 supported."); @@ -766,7 +769,7 @@ namespace INTERP_KERNEL double Surface=0; for(unsigned long i=0; i<(Poly.size())/2-2; i++) { - double Surf=Surf_Tri( &Poly[0],&Poly[2*(i+1)],&Poly[2*(i+2)] ); + double const Surf=Surf_Tri( &Poly[0],&Poly[2*(i+1)],&Poly[2*(i+2)] ); Surface=Surface + Surf ; } return Surface ; @@ -784,9 +787,9 @@ namespace INTERP_KERNEL { bool A=false; - double det_1=mon_determinant(P_1,P_3,P_0); - double det_2=mon_determinant(P_3,P_2,P_0); - double det_3=mon_determinant(P_2,P_1,P_0); + double const det_1=mon_determinant(P_1,P_3,P_0); + double const det_2=mon_determinant(P_3,P_2,P_0); + double const det_3=mon_determinant(P_2,P_1,P_0); if( (det_1>=-eps && det_2>=-eps && det_3>=-eps) || (det_1<=eps && det_2<=eps && det_3<=eps) ) { A=true; @@ -802,7 +805,7 @@ namespace INTERP_KERNEL inline void verif_point_dans_vect(const double* P, std::vector& V, double absolute_precision ) { - std::size_t taille=V.size(); + std::size_t const taille=V.size(); bool isPresent=false; for(std::size_t i=0;i& V, double dim_caracteristic, double precision) { - double absolute_precision = precision*dim_caracteristic; - bool A_1=INTERP_KERNEL::point_dans_triangle(P_1,P_4,P_5,P_6,absolute_precision); + double const absolute_precision = precision*dim_caracteristic; + bool const A_1=INTERP_KERNEL::point_dans_triangle(P_1,P_4,P_5,P_6,absolute_precision); if(A_1) verif_point_dans_vect(P_1,V,absolute_precision); - bool A_2=INTERP_KERNEL::point_dans_triangle(P_2,P_4,P_5,P_6,absolute_precision); + bool const A_2=INTERP_KERNEL::point_dans_triangle(P_2,P_4,P_5,P_6,absolute_precision); if(A_2) verif_point_dans_vect(P_2,V,absolute_precision); - bool A_3=INTERP_KERNEL::point_dans_triangle(P_3,P_4,P_5,P_6,absolute_precision); + bool const A_3=INTERP_KERNEL::point_dans_triangle(P_3,P_4,P_5,P_6,absolute_precision); if(A_3) verif_point_dans_vect(P_3,V,absolute_precision); } @@ -856,17 +859,17 @@ namespace INTERP_KERNEL double dim_caracteristic, double precision) { // calcul du determinant de P_1P_2 et P_3P_4. - double det=(P_2[0]-P_1[0])*(P_4[1]-P_3[1])-(P_4[0]-P_3[0])*(P_2[1]-P_1[1]); + double const det=(P_2[0]-P_1[0])*(P_4[1]-P_3[1])-(P_4[0]-P_3[0])*(P_2[1]-P_1[1]); - double absolute_precision = dim_caracteristic*precision; + double const absolute_precision = dim_caracteristic*precision; if(fabs(det)>absolute_precision) { - double k_1=-((P_3[1]-P_4[1])*(P_3[0]-P_1[0])+(P_4[0]-P_3[0])*(P_3[1]-P_1[1]))/det; + double const k_1=-((P_3[1]-P_4[1])*(P_3[0]-P_1[0])+(P_4[0]-P_3[0])*(P_3[1]-P_1[1]))/det; if (k_1 >= -absolute_precision && k_1 <= 1+absolute_precision) //if( k_1 >= -precision && k_1 <= 1+precision) { - double k_2= ((P_1[1]-P_2[1])*(P_1[0]-P_3[0])+(P_2[0]-P_1[0])*(P_1[1]-P_3[1]))/det; + double const k_2= ((P_1[1]-P_2[1])*(P_1[0]-P_3[0])+(P_2[0]-P_1[0])*(P_1[1]-P_3[1]))/det; if (k_2 >= -absolute_precision && k_2 <= 1+absolute_precision) //if( k_2 >= -precision && k_2 <= 1+precision) @@ -912,7 +915,7 @@ namespace INTERP_KERNEL inline void verif_maill_dans_vect(int Num, std::vector& V) { - std::size_t taille=V.size(); + std::size_t const taille=V.size(); int A=0; for(std::size_t i=0;itheta1, std::pair theta2) const { - double norm1 = sqrt(theta1.first*theta1.first +theta1.second*theta1.second); - double norm2 = sqrt(theta2.first*theta2.first +theta2.second*theta2.second); + double const norm1 = sqrt(theta1.first*theta1.first +theta1.second*theta1.second); + double const norm2 = sqrt(theta2.first*theta2.first +theta2.second*theta2.second); - double epsilon = 1.e-12; + double const epsilon = 1.e-12; if( norm1 < epsilon || norm2 < epsilon ) std::cout << "Warning InterpolationUtils.hxx: AngleLess : Vector with zero norm, cannot define the angle !!!! " << std::endl; @@ -955,7 +958,7 @@ namespace INTERP_KERNEL inline std::vector reconstruct_polygon(const std::vector& V) { - int taille((int)V.size()); + int const taille((int)V.size()); //VB : why 6 ? @@ -963,8 +966,8 @@ namespace INTERP_KERNEL {return V;} else { - double *COS=new double[taille/2]; - double *SIN=new double[taille/2]; + auto *COS=new double[taille/2]; + auto *SIN=new double[taille/2]; //double *angle=new double[taille/2]; std::vector Bary=bary_poly(V); COS[0]=1.0; @@ -1001,7 +1004,7 @@ namespace INTERP_KERNEL // } for(micossin=CosSin.begin();micossin!=CosSin.end();micossin++) { - int j=(*micossin).second; + int const j=(*micossin).second; Pt_ordonne.push_back(V[2*j]); Pt_ordonne.push_back(V[2*j+1]); } @@ -1024,9 +1027,9 @@ namespace INTERP_KERNEL for (int i=0; ibb[1])?x:bb[1]; bb[2]=(y sw(3,false); double inpVect2[3]; std::transform(inpVect,inpVect + 3,inpVect2,[](double c){return fabs(c);}); - std::size_t posMin(std::distance(inpVect2,std::min_element(inpVect2,inpVect2+3))); + std::size_t const posMin(std::distance(inpVect2,std::min_element(inpVect2,inpVect2+3))); sw[posMin]=true; std::size_t posMax(std::distance(inpVect2,std::max_element(inpVect2,inpVect2+3))); if(posMax==posMin) { posMax=(posMin+1)%3; } sw[posMax]=true; - std::size_t posMid(std::distance(sw.begin(),std::find(sw.begin(),sw.end(),false))); + std::size_t const posMid(std::distance(sw.begin(),std::find(sw.begin(),sw.end(),false))); outVect[posMin]=0.; outVect[posMid]=1.; outVect[posMax]=-inpVect[posMid]/inpVect[posMax]; } @@ -1154,7 +1157,7 @@ namespace INTERP_KERNEL /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _*/ /* Computes the geometric angle (in [0,Pi]) between two non zero vectors AB and AC */ /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _*/ - template inline double angle(const double * A, const double * B, const double * C, double * n) + template inline double angle(const double * A, const double * B, const double * C, double * /*n*/) { double AB[dim]; double AC[dim]; @@ -1170,7 +1173,7 @@ namespace INTERP_KERNEL double AB_dot_AC=dotprod(AB,AC); for(int idim =0; idim(orthAB); return 2*atan2(numer,denom); @@ -1299,13 +1302,13 @@ namespace INTERP_KERNEL */ inline double TripleProduct(const double *A, const double *B, const double *C, const double *X) { - double XA[3]={ A[0]-X[0], A[1]-X[1], A[2]-X[2] }; - double XB[3]={ B[0]-X[0], B[1]-X[1], B[2]-X[2] }; - double XC[3]={ C[0]-X[0], C[1]-X[1], C[2]-X[2] }; + double const XA[3]={ A[0]-X[0], A[1]-X[1], A[2]-X[2] }; + double const XB[3]={ B[0]-X[0], B[1]-X[1], B[2]-X[2] }; + double const XC[3]={ C[0]-X[0], C[1]-X[1], C[2]-X[2] }; - double XA_cross_XB[3] = {XA[1]*XB[2]-XA[2]*XB[1], XA[2]*XB[0]-XA[0]*XB[2], XA[0]*XB[1]-XA[1]*XB[0]}; + double const XA_cross_XB[3] = {XA[1]*XB[2]-XA[2]*XB[1], XA[2]*XB[0]-XA[0]*XB[2], XA[0]*XB[1]-XA[1]*XB[0]}; // norm is equal to double the area of the triangle - double norm = std::sqrt(XA_cross_XB[0]*XA_cross_XB[0]+XA_cross_XB[1]*XA_cross_XB[1]+XA_cross_XB[2]*XA_cross_XB[2]); + double const norm = std::sqrt(XA_cross_XB[0]*XA_cross_XB[0]+XA_cross_XB[1]*XA_cross_XB[1]+XA_cross_XB[2]*XA_cross_XB[2]); return ( XA_cross_XB[0]*XC[0]+ XA_cross_XB[1]*XC[1] + XA_cross_XB[2]*XC[2] ) / norm; } diff --git a/src/INTERP_KERNEL/Intersector3D.hxx b/src/INTERP_KERNEL/Intersector3D.hxx index 760cab8f5..cb58f752a 100644 --- a/src/INTERP_KERNEL/Intersector3D.hxx +++ b/src/INTERP_KERNEL/Intersector3D.hxx @@ -21,7 +21,9 @@ #ifndef __INTERSECTOR3D_HXX__ #define __INTERSECTOR3D_HXX__ -#include "TargetIntersector.txx" +#include "TargetIntersector.hxx" +#include "NormalizedUnstructuredMesh.hxx" +#include namespace INTERP_KERNEL { @@ -31,7 +33,7 @@ namespace INTERP_KERNEL public: static const int SPACEDIM=MyMeshType::MY_SPACEDIM; static const int MESHDIM=MyMeshType::MY_MESHDIM; - typedef typename MyMeshType::MyConnType ConnType; + using ConnType = typename MyMeshType::MyConnType; static const NumberingPolicy numPol=MyMeshType::My_numPol; public: Intersector3D(const MyMeshType& targetMesh, const MyMeshType& srcMesh); diff --git a/src/INTERP_KERNEL/Intersector3D.txx b/src/INTERP_KERNEL/Intersector3D.txx index 2bd2f3fe5..34757cb8b 100644 --- a/src/INTERP_KERNEL/Intersector3D.txx +++ b/src/INTERP_KERNEL/Intersector3D.txx @@ -21,8 +21,10 @@ #define __INTERSECTOR3D_TXX__ #include "Intersector3D.hxx" +#include "InterpolationUtils.hxx" #include +#include namespace INTERP_KERNEL { @@ -39,7 +41,7 @@ namespace INTERP_KERNEL { ConnType nbNodesT=_target_mesh.getNumberOfNodesOfElement(icellT); coordsT.resize(SPACEDIM*nbNodesT); - std::vector::iterator iter=coordsT.begin(); + auto iter=coordsT.begin(); for (ConnType iT=0; iT::iterator iter=coordsS.begin(); + auto iter=coordsS.begin(); for (ConnType iS=0; iS namespace INTERP_KERNEL { diff --git a/src/INTERP_KERNEL/IntersectorCU.txx b/src/INTERP_KERNEL/IntersectorCU.txx index ffe962629..7bb1e864f 100644 --- a/src/INTERP_KERNEL/IntersectorCU.txx +++ b/src/INTERP_KERNEL/IntersectorCU.txx @@ -24,6 +24,9 @@ #define __IntersectorCU_TXX__ #include "IntersectorCU.hxx" +#include "InterpolationUtils.hxx" +#include +#include // convert index "From Mesh Index" #define _FMIU(i) OTT::ind2C((i)) @@ -74,8 +77,7 @@ namespace INTERP_KERNEL _CU_TEMPLATE _INTERSECTOR_CU_::~IntersectorCU() - { - } + = default; //================================================================================ /*! @@ -100,7 +102,7 @@ namespace INTERP_KERNEL const double* coord_node=_coordsU+SPACEDIM*(_FMCOO( _connectU[_FMCON (_connIndexU[_FMIU(icell)]+i)])); for(int idim=0; idimbb[2*idim+1])?x:bb[2*idim+1]; } diff --git a/src/INTERP_KERNEL/IntersectorCU1D.hxx b/src/INTERP_KERNEL/IntersectorCU1D.hxx index bf116b7eb..47dcbb592 100644 --- a/src/INTERP_KERNEL/IntersectorCU1D.hxx +++ b/src/INTERP_KERNEL/IntersectorCU1D.hxx @@ -25,6 +25,7 @@ #define __IntersectorCU1D_HXX__ #include "IntersectorCU.hxx" +#include namespace INTERP_KERNEL { @@ -32,8 +33,8 @@ namespace INTERP_KERNEL class IntersectorCU1D : public IntersectorCU > { public: - typedef typename MyUMeshType::MyConnType UConnType; - typedef typename MyCMeshType::MyConnType CConnType; + using UConnType = typename MyUMeshType::MyConnType; + using CConnType = typename MyCMeshType::MyConnType; public: IntersectorCU1D(const MyCMeshType& meshS, const MyUMeshType& meshT); ~IntersectorCU1D(); diff --git a/src/INTERP_KERNEL/IntersectorCU1D.txx b/src/INTERP_KERNEL/IntersectorCU1D.txx index 37cecba18..38a77306c 100644 --- a/src/INTERP_KERNEL/IntersectorCU1D.txx +++ b/src/INTERP_KERNEL/IntersectorCU1D.txx @@ -23,8 +23,12 @@ #ifndef __IntersectorCU1D_TXX__ #define __IntersectorCU1D_TXX__ +#include "IntersectorCU.hxx" #include "IntersectorCU1D.hxx" #include "IntersectorCU.txx" +#include "InterpKernelException.hxx" +#include +#include #define IntersectorCU1D_TEMPLATE template #define INTERSECTOR_CU1D IntersectorCU1D @@ -56,8 +60,7 @@ namespace INTERP_KERNEL IntersectorCU1D_TEMPLATE INTERSECTOR_CU1D::~IntersectorCU1D() - { - } + = default; //================================================================================ /*! @@ -75,7 +78,7 @@ namespace INTERP_KERNEL const double* coordsC = & _INTER_CU::_coordsC[0][ _FMIC(icellS[0]) ]; - double res = std::min( coordsU[1], coordsC[1] ) - std::max( coordsU[0], coordsC[0] ); + double const res = std::min( coordsU[1], coordsC[1] ) - std::max( coordsU[0], coordsC[0] ); return res; } } diff --git a/src/INTERP_KERNEL/IntersectorCU2D.hxx b/src/INTERP_KERNEL/IntersectorCU2D.hxx index 17f79c9d9..b58e44ee1 100644 --- a/src/INTERP_KERNEL/IntersectorCU2D.hxx +++ b/src/INTERP_KERNEL/IntersectorCU2D.hxx @@ -25,6 +25,9 @@ #define __IntersectorCU2D_HXX__ #include "IntersectorCU.hxx" +#include "PlanarIntersectorP0P0.hxx" +#include "TriangulationIntersector.hxx" +#include namespace INTERP_KERNEL { @@ -32,8 +35,8 @@ namespace INTERP_KERNEL class IntersectorCU2D : public IntersectorCU > { public: - typedef typename MyUMeshType::MyConnType UConnType; - typedef typename MyCMeshType::MyConnType CConnType; + using UConnType = typename MyUMeshType::MyConnType; + using CConnType = typename MyCMeshType::MyConnType; public: IntersectorCU2D(const MyCMeshType& meshS, const MyUMeshType& meshT); double intersectGeometry(UConnType icellT, const std::vector& icellC); diff --git a/src/INTERP_KERNEL/IntersectorCU2D.txx b/src/INTERP_KERNEL/IntersectorCU2D.txx index 90a0c06bd..eec35088e 100644 --- a/src/INTERP_KERNEL/IntersectorCU2D.txx +++ b/src/INTERP_KERNEL/IntersectorCU2D.txx @@ -23,8 +23,13 @@ #ifndef __IntersectorCU2D_TXX__ #define __IntersectorCU2D_TXX__ +#include "IntersectorCU.hxx" #include "IntersectorCU2D.hxx" #include "IntersectorCU.txx" +#include "InterpKernelException.hxx" +#include "CellModel.hxx" +#include "NormalizedGeometricTypes" +#include #define IntersectorCU2D_TEMPLATE template #define INTERSECTOR_CU2D IntersectorCU2D diff --git a/src/INTERP_KERNEL/IntersectorCU3D.hxx b/src/INTERP_KERNEL/IntersectorCU3D.hxx index 0b6259d3b..db5fc510f 100644 --- a/src/INTERP_KERNEL/IntersectorCU3D.hxx +++ b/src/INTERP_KERNEL/IntersectorCU3D.hxx @@ -26,6 +26,7 @@ #include "IntersectorCU.hxx" #include "SplitterTetra.hxx" +#include namespace INTERP_KERNEL { @@ -35,8 +36,8 @@ namespace INTERP_KERNEL class IntersectorCU3D : public IntersectorCU > { public: - typedef typename MyUMeshType::MyConnType UConnType; - typedef typename MyCMeshType::MyConnType CConnType; + using UConnType = typename MyUMeshType::MyConnType; + using CConnType = typename MyCMeshType::MyConnType; public: IntersectorCU3D(const MyCMeshType& meshS, const MyUMeshType& meshT, SplittingPolicy splitting_policy); ~IntersectorCU3D(); @@ -44,8 +45,8 @@ namespace INTERP_KERNEL private: - typedef SplitterTetra2 TSplitter; - typedef SplitterTetra <_Cartesian3D2UnstructHexMesh > TTetra; + using TSplitter = SplitterTetra2; + using TTetra = SplitterTetra<_Cartesian3D2UnstructHexMesh>; _Cartesian3D2UnstructHexMesh* _uHexMesh; TSplitter* _split; }; diff --git a/src/INTERP_KERNEL/IntersectorCU3D.txx b/src/INTERP_KERNEL/IntersectorCU3D.txx index ae8801905..22c00ac47 100644 --- a/src/INTERP_KERNEL/IntersectorCU3D.txx +++ b/src/INTERP_KERNEL/IntersectorCU3D.txx @@ -23,9 +23,14 @@ #ifndef __IntersectorCU3D_TXX__ #define __IntersectorCU3D_TXX__ +#include "IntersectorCU.hxx" #include "IntersectorCU3D.hxx" #include "IntersectorCU.txx" -#include "SplitterTetra.txx" +#include "MCIdType.hxx" +#include "NormalizedUnstructuredMesh.hxx" +#include "InterpKernelException.hxx" +#include "NormalizedGeometricTypes" +#include "BoundingBox.hxx" #define IntersectorCU3D_TEMPLATE template #define INTERSECTOR_CU3D IntersectorCU3D @@ -45,7 +50,7 @@ namespace INTERP_KERNEL public: static const int MY_SPACEDIM=3; static const int MY_MESHDIM=3; - typedef mcIdType MyConnType; + using MyConnType = mcIdType; static const NumberingPolicy My_numPol=ALL_C_MODE; _Cartesian3D2UnstructHexMesh(const double * coords[3]): _coordsC(coords) {} @@ -80,8 +85,8 @@ namespace INTERP_KERNEL boundingBox[BoundingBox::ZMIN] = _coordsU[2]; boundingBox[BoundingBox::ZMAX] = _coordsU[2+4*MY_SPACEDIM]; } - NormalizedCellType getTypeOfElement(mcIdType eltId) const { return NORM_HEXA8; } - mcIdType getNumberOfNodesOfElement(mcIdType eltId) const { return 8; } + NormalizedCellType getTypeOfElement(mcIdType /*eltId*/) const { return NORM_HEXA8; } + mcIdType getNumberOfNodesOfElement(mcIdType /*eltId*/) const { return 8; } mcIdType getNumberOfElements() const { return 1; } mcIdType getNumberOfNodes() const { return 8; } const double *getCoordinatesPtr() const { return _coordsU; } @@ -120,7 +125,7 @@ namespace INTERP_KERNEL IntersectorCU3D_TEMPLATE INTERSECTOR_CU3D::~IntersectorCU3D() { - delete _uHexMesh; _uHexMesh=0; + delete _uHexMesh; _uHexMesh=nullptr; delete _split; _split=0; } diff --git a/src/INTERP_KERNEL/LinearAlgebra/InterpKernelDenseMatrix.cxx b/src/INTERP_KERNEL/LinearAlgebra/InterpKernelDenseMatrix.cxx index 8c16a79c1..e0c8f7414 100644 --- a/src/INTERP_KERNEL/LinearAlgebra/InterpKernelDenseMatrix.cxx +++ b/src/INTERP_KERNEL/LinearAlgebra/InterpKernelDenseMatrix.cxx @@ -17,6 +17,7 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +#include "INTERPKERNELDefines.hxx" #include "InterpKernelDenseMatrix.txx" template class INTERPKERNEL_EXPORT INTERP_KERNEL::DenseMatrixT; diff --git a/src/INTERP_KERNEL/LinearAlgebra/InterpKernelLUDecomp.cxx b/src/INTERP_KERNEL/LinearAlgebra/InterpKernelLUDecomp.cxx index 9dd92e327..c357392d5 100644 --- a/src/INTERP_KERNEL/LinearAlgebra/InterpKernelLUDecomp.cxx +++ b/src/INTERP_KERNEL/LinearAlgebra/InterpKernelLUDecomp.cxx @@ -20,9 +20,12 @@ // Implementation coming from Numerical Recipes in C of 1994 (version 2.04) #include "InterpKernelLUDecomp.hxx" +#include "InterpKernelDenseMatrix.hxx" #include "InterpKernelException.hxx" +#include "MCIdType.hxx" #include +#include #include using namespace INTERP_KERNEL; diff --git a/src/INTERP_KERNEL/LinearAlgebra/InterpKernelLUDecomp.hxx b/src/INTERP_KERNEL/LinearAlgebra/InterpKernelLUDecomp.hxx index b5b4e3d2a..562a61475 100644 --- a/src/INTERP_KERNEL/LinearAlgebra/InterpKernelLUDecomp.hxx +++ b/src/INTERP_KERNEL/LinearAlgebra/InterpKernelLUDecomp.hxx @@ -19,7 +19,9 @@ #pragma once +#include "INTERPKERNELDefines.hxx" #include "InterpKernelDenseMatrix.hxx" +#include "MCIdType.hxx" #include namespace INTERP_KERNEL diff --git a/src/INTERP_KERNEL/LinearAlgebra/InterpKernelQRDecomp.cxx b/src/INTERP_KERNEL/LinearAlgebra/InterpKernelQRDecomp.cxx index 0e8b6be38..8ea8e8126 100644 --- a/src/INTERP_KERNEL/LinearAlgebra/InterpKernelQRDecomp.cxx +++ b/src/INTERP_KERNEL/LinearAlgebra/InterpKernelQRDecomp.cxx @@ -20,9 +20,13 @@ // Implementation coming from Numerical Recipes in C of 1994 (version 2.04) #include "InterpKernelQRDecomp.hxx" +#include "InterpKernelDenseMatrix.hxx" #include "InterpKernelException.hxx" +#include "MCIdType.hxx" #include +#include +#include using namespace INTERP_KERNEL; diff --git a/src/INTERP_KERNEL/LinearAlgebra/InterpKernelQRDecomp.hxx b/src/INTERP_KERNEL/LinearAlgebra/InterpKernelQRDecomp.hxx index b9963e990..f7a0849b3 100644 --- a/src/INTERP_KERNEL/LinearAlgebra/InterpKernelQRDecomp.hxx +++ b/src/INTERP_KERNEL/LinearAlgebra/InterpKernelQRDecomp.hxx @@ -22,6 +22,7 @@ #pragma once #include "InterpKernelDenseMatrix.hxx" +#include "MCIdType.hxx" #include namespace INTERP_KERNEL diff --git a/src/INTERP_KERNEL/MCIdType.hxx b/src/INTERP_KERNEL/MCIdType.hxx index 4d87d60b9..4cacee15d 100644 --- a/src/INTERP_KERNEL/MCIdType.hxx +++ b/src/INTERP_KERNEL/MCIdType.hxx @@ -32,14 +32,14 @@ typedef std::int32_t mcIdType; #else -typedef std::int64_t mcIdType; +using mcIdType = std::int64_t; #endif #ifdef WIN32 typedef long long mcPyPtrType; #else -typedef long mcPyPtrType; +using mcPyPtrType = long; #endif template inline std::size_t ToSizeT(T val) diff --git a/src/INTERP_KERNEL/MappedBarycentric2DIntersectorP1P1.hxx b/src/INTERP_KERNEL/MappedBarycentric2DIntersectorP1P1.hxx index 4a4737869..019fdb675 100644 --- a/src/INTERP_KERNEL/MappedBarycentric2DIntersectorP1P1.hxx +++ b/src/INTERP_KERNEL/MappedBarycentric2DIntersectorP1P1.hxx @@ -21,7 +21,9 @@ #ifndef __MappedBarycenter2DIntersectorP1P1_HXX__ #define __MappedBarycenter2DIntersectorP1P1_HXX__ +#include "NormalizedUnstructuredMesh.hxx" #include "PlanarIntersector.hxx" +#include namespace INTERP_KERNEL { @@ -31,7 +33,7 @@ namespace INTERP_KERNEL public: static const int SPACEDIM=MyMeshType::MY_SPACEDIM; static const int MESHDIM=MyMeshType::MY_MESHDIM; - typedef typename MyMeshType::MyConnType ConnType; + using ConnType = typename MyMeshType::MyConnType; static const NumberingPolicy numPol=MyMeshType::My_numPol; public: MappedBarycentric2DIntersectorP1P1(const MyMeshType& meshT, const MyMeshType& meshS, double dimCaracteristic, double md3DSurf, double minDot3DSurf, double medianPlane, double precision, int orientation); diff --git a/src/INTERP_KERNEL/MappedBarycentric2DIntersectorP1P1.txx b/src/INTERP_KERNEL/MappedBarycentric2DIntersectorP1P1.txx index 8dc1cc360..9be695bcc 100644 --- a/src/INTERP_KERNEL/MappedBarycentric2DIntersectorP1P1.txx +++ b/src/INTERP_KERNEL/MappedBarycentric2DIntersectorP1P1.txx @@ -21,12 +21,14 @@ #ifndef __MappedBarycentric2DIntersectorP1P1_TXX__ #define __MappedBarycentric2DIntersectorP1P1_TXX__ +#include "InterpolationUtils.hxx" #include "MappedBarycentric2DIntersectorP1P1.hxx" -#include "PlanarIntersector.txx" -#include "CellModel.hxx" +#include "PlanarIntersector.hxx" +#include "NormalizedGeometricTypes" +#include "InterpKernelUtilities.hxx" #include "PointLocatorAlgos.txx" -#include "MeshUtils.hxx" +#include namespace INTERP_KERNEL { diff --git a/src/INTERP_KERNEL/MappedBarycentric3DIntersectorP1P1.hxx b/src/INTERP_KERNEL/MappedBarycentric3DIntersectorP1P1.hxx index 77ac2fd77..9fb9a02ff 100644 --- a/src/INTERP_KERNEL/MappedBarycentric3DIntersectorP1P1.hxx +++ b/src/INTERP_KERNEL/MappedBarycentric3DIntersectorP1P1.hxx @@ -23,7 +23,7 @@ #include "Intersector3DP1P1.hxx" #include "NormalizedUnstructuredMesh.hxx" -#include "InterpKernelUtilities.hxx" +#include namespace INTERP_KERNEL { diff --git a/src/INTERP_KERNEL/MappedBarycentric3DIntersectorP1P1.txx b/src/INTERP_KERNEL/MappedBarycentric3DIntersectorP1P1.txx index cc8fd2e83..99a6bef68 100644 --- a/src/INTERP_KERNEL/MappedBarycentric3DIntersectorP1P1.txx +++ b/src/INTERP_KERNEL/MappedBarycentric3DIntersectorP1P1.txx @@ -21,9 +21,16 @@ #ifndef __MAPPEDBARYCENTRIC3DINTERSECTORP1P1_TXX__ #define __MAPPEDBARYCENTRIC3DINTERSECTORP1P1_TXX__ -#include "MappedBarycentric3DIntersectorP1P1.hxx" #include "Intersector3DP1P1.txx" -#include "MeshUtils.hxx" +#include "InterpolationUtils.hxx" +#include "InterpKernelUtilities.hxx" +#include "MappedBarycentric3DIntersectorP1P1.hxx" +#include "NormalizedGeometricTypes" +#include "CellModel.hxx" +#include "PointLocatorAlgos.txx" +#include +#include +#include namespace INTERP_KERNEL { @@ -42,8 +49,7 @@ namespace INTERP_KERNEL template MappedBarycentric3DIntersectorP1P1::~MappedBarycentric3DIntersectorP1P1() - { - } + = default; /** * @param targetCell in C mode. diff --git a/src/INTERP_KERNEL/MeshElement.cxx b/src/INTERP_KERNEL/MeshElement.cxx index 981b206ea..cc8883fd9 100644 --- a/src/INTERP_KERNEL/MeshElement.cxx +++ b/src/INTERP_KERNEL/MeshElement.cxx @@ -18,6 +18,7 @@ // #include "MeshElement.hxx" +#include "BoundingBox.hxx" namespace INTERP_KERNEL { diff --git a/src/INTERP_KERNEL/MeshElement.hxx b/src/INTERP_KERNEL/MeshElement.hxx index 200c59540..ba15d3422 100644 --- a/src/INTERP_KERNEL/MeshElement.hxx +++ b/src/INTERP_KERNEL/MeshElement.hxx @@ -46,7 +46,7 @@ namespace INTERP_KERNEL template void assign(const ConnType index, const MyMeshType& mesh); - ~MeshElement() { } + ~MeshElement() = default; nbnodesincelltype getNumberOfNodes() const { return _number; } @@ -56,7 +56,7 @@ namespace INTERP_KERNEL private: /// disallow copying - MeshElement(const MeshElement& elem); + MeshElement(const MeshElement& elem) = delete; nbnodesincelltype _number; diff --git a/src/INTERP_KERNEL/MeshElement.txx b/src/INTERP_KERNEL/MeshElement.txx old mode 100755 new mode 100644 index a83d3b5da..5f662e0a5 --- a/src/INTERP_KERNEL/MeshElement.txx +++ b/src/INTERP_KERNEL/MeshElement.txx @@ -19,16 +19,16 @@ #ifndef __MESHELEMENT_TXX__ #define __MESHELEMENT_TXX__ +#include "InterpolationUtils.hxx" +#include "InterpKernelException.hxx" #include "MeshElement.hxx" -#include "TetraAffineTransform.hxx" -#include "TransformedTriangle.hxx" #include "MeshUtils.hxx" #include "BoundingBox.hxx" #include -#include #include #include +#include namespace INTERP_KERNEL { diff --git a/src/INTERP_KERNEL/MeshRegion.hxx b/src/INTERP_KERNEL/MeshRegion.hxx index f00d767b0..944eb2c49 100644 --- a/src/INTERP_KERNEL/MeshRegion.hxx +++ b/src/INTERP_KERNEL/MeshRegion.hxx @@ -22,7 +22,6 @@ #include "MeshElement.hxx" #include "BoundingBox.hxx" -#include "NormalizedUnstructuredMesh.hxx" #include diff --git a/src/INTERP_KERNEL/MeshRegion.txx b/src/INTERP_KERNEL/MeshRegion.txx index 4496d91ed..f6de59a56 100644 --- a/src/INTERP_KERNEL/MeshRegion.txx +++ b/src/INTERP_KERNEL/MeshRegion.txx @@ -19,10 +19,13 @@ #ifndef __MESHREGION_TXX__ #define __MESHREGION_TXX__ +#include "MeshElement.hxx" +#include "InterpolationUtils.hxx" +#include "BoundingBox.hxx" #include "MeshRegion.hxx" -#include "MeshElement.txx" #include "MeshUtils.hxx" +#include namespace INTERP_KERNEL { @@ -32,7 +35,7 @@ namespace INTERP_KERNEL * */ template - MeshRegion::MeshRegion():_box(0) + MeshRegion::MeshRegion():_box(nullptr) { } @@ -63,9 +66,9 @@ namespace INTERP_KERNEL const unsigned char numNodes = element->getNumberOfNodes(); const ConnType elemIdx = element->getIndex(); - if(_box == 0) + if(_box == nullptr) { - const double** pts = new const double*[numNodes]; + const auto** pts = new const double*[numNodes]; // get coordinates of the nodes of the element for(unsigned char i = 0 ; i < numNodes ; ++i) diff --git a/src/INTERP_KERNEL/MeshUtils.hxx b/src/INTERP_KERNEL/MeshUtils.hxx index 072f0fcae..a7c877b2c 100644 --- a/src/INTERP_KERNEL/MeshUtils.hxx +++ b/src/INTERP_KERNEL/MeshUtils.hxx @@ -21,6 +21,9 @@ #define __MESHUTILS_HXX__ #include "InterpolationUtils.hxx" +#include "NormalizedGeometricTypes" +#include "NormalizedUnstructuredMesh.hxx" +#include namespace INTERP_KERNEL { diff --git a/src/INTERP_KERNEL/OrientationInverter.cxx b/src/INTERP_KERNEL/OrientationInverter.cxx index 8075c313c..aca70c2e4 100644 --- a/src/INTERP_KERNEL/OrientationInverter.cxx +++ b/src/INTERP_KERNEL/OrientationInverter.cxx @@ -21,7 +21,11 @@ #include "OrientationInverter.hxx" #include "InterpKernelException.hxx" #include "CellModel.hxx" +#include "NormalizedGeometricTypes" +#include "MCIdType.hxx" +#include +#include #include #include @@ -98,7 +102,7 @@ void OrientationInverter2DLinear::operateAndShutUp(mcIdType *beginPt) const void OrientationInverter2DQuadratic::operateAndShutUp(mcIdType *beginPt) const { - int nbNodes(getNbNodes()); + int const nbNodes(getNbNodes()); std::reverse(beginPt+1,beginPt+nbNodes/2); std::reverse(beginPt+nbNodes/2,beginPt+nbNodes); } @@ -110,7 +114,7 @@ void OrientationInverterPolygon::operate(mcIdType *beginPt, mcIdType *endPt) con void OrientationInverterQPolygon::operate(mcIdType *beginPt, mcIdType *endPt) const { - std::size_t sz(std::distance(beginPt,endPt)); + std::size_t const sz(std::distance(beginPt,endPt)); std::reverse(beginPt+1,beginPt+sz/2); std::reverse(beginPt+sz/2,endPt); } @@ -141,7 +145,7 @@ void OrientationInverterPyra13::operateAndShutUp(mcIdType *beginPt) const void OrientationInverter3DExtrusionLinear::operateAndShutUp(mcIdType *beginPt) const { - int nbNodes(getNbNodes()); + int const nbNodes(getNbNodes()); std::reverse(beginPt+1,beginPt+nbNodes/2); std::reverse(beginPt+nbNodes/2+1,beginPt+nbNodes); } diff --git a/src/INTERP_KERNEL/OrientationInverter.hxx b/src/INTERP_KERNEL/OrientationInverter.hxx index 570d2356b..868eea951 100644 --- a/src/INTERP_KERNEL/OrientationInverter.hxx +++ b/src/INTERP_KERNEL/OrientationInverter.hxx @@ -31,7 +31,7 @@ namespace INTERP_KERNEL { public: INTERPKERNEL_EXPORT static OrientationInverter *BuildInstanceFrom(NormalizedCellType gt); - INTERPKERNEL_EXPORT virtual ~OrientationInverter() { } + INTERPKERNEL_EXPORT virtual ~OrientationInverter() = default; INTERPKERNEL_EXPORT virtual void operate(mcIdType *beginPt, mcIdType *endPt) const = 0; }; @@ -39,7 +39,7 @@ namespace INTERP_KERNEL { public: OrientationInverterChecker(unsigned nbNodes):_nb_nodes(nbNodes) { } - void operate(mcIdType *beginPt, mcIdType *endPt) const { check(beginPt,endPt); operateAndShutUp(beginPt); } + void operate(mcIdType *beginPt, mcIdType *endPt) const override { check(beginPt,endPt); operateAndShutUp(beginPt); } virtual void operateAndShutUp(mcIdType *beginPt) const = 0; protected: unsigned getNbNodes() const { return _nb_nodes; } @@ -53,82 +53,82 @@ namespace INTERP_KERNEL { public: OrientationInverterSEG2():OrientationInverterChecker(2u) { } - void operateAndShutUp(mcIdType *beginPt) const; + void operateAndShutUp(mcIdType *beginPt) const override; }; class OrientationInverterSEG3 : public OrientationInverterChecker { public: OrientationInverterSEG3():OrientationInverterChecker(3u) { } - void operateAndShutUp(mcIdType *beginPt) const; + void operateAndShutUp(mcIdType *beginPt) const override; }; class OrientationInverter2DLinear : public OrientationInverterChecker { public: OrientationInverter2DLinear(unsigned nbNodes):OrientationInverterChecker(nbNodes) { } - void operateAndShutUp(mcIdType *beginPt) const; + void operateAndShutUp(mcIdType *beginPt) const override; }; class OrientationInverter2DQuadratic : public OrientationInverterChecker { public: OrientationInverter2DQuadratic(unsigned nbNodes):OrientationInverterChecker(nbNodes) { } - void operateAndShutUp(mcIdType *beginPt) const; + void operateAndShutUp(mcIdType *beginPt) const override; }; class OrientationInverterPolygon : public OrientationInverter { public: - void operate(mcIdType *beginPt, mcIdType *endPt) const; + void operate(mcIdType *beginPt, mcIdType *endPt) const override; }; class OrientationInverterQPolygon : public OrientationInverter { public: - void operate(mcIdType *beginPt, mcIdType *endPt) const; + void operate(mcIdType *beginPt, mcIdType *endPt) const override; }; class OrientationInverterTetra4 : public OrientationInverterChecker { public: OrientationInverterTetra4():OrientationInverterChecker(4u) { } - void operateAndShutUp(mcIdType *beginPt) const; + void operateAndShutUp(mcIdType *beginPt) const override; }; class OrientationInverterTetra10 : public OrientationInverterChecker { public: OrientationInverterTetra10():OrientationInverterChecker(10u) { } - void operateAndShutUp(mcIdType *beginPt) const; + void operateAndShutUp(mcIdType *beginPt) const override; }; class OrientationInverterPyra5 : public OrientationInverterChecker { public: OrientationInverterPyra5():OrientationInverterChecker(5u) { } - void operateAndShutUp(mcIdType *beginPt) const; + void operateAndShutUp(mcIdType *beginPt) const override; }; class OrientationInverterPyra13 : public OrientationInverterChecker { public: OrientationInverterPyra13():OrientationInverterChecker(13u) { } - void operateAndShutUp(mcIdType *beginPt) const; + void operateAndShutUp(mcIdType *beginPt) const override; }; class OrientationInverter3DExtrusionLinear : public OrientationInverterChecker { public: OrientationInverter3DExtrusionLinear(unsigned nbNodes):OrientationInverterChecker(nbNodes) { } - void operateAndShutUp(mcIdType *beginPt) const; + void operateAndShutUp(mcIdType *beginPt) const override; }; class OrientationInverter3DExtrusionQuadratic : public OrientationInverterChecker { public: OrientationInverter3DExtrusionQuadratic(unsigned nbNodes):OrientationInverterChecker(nbNodes) { } - void operateAndShutUp(mcIdType *beginPt) const; + void operateAndShutUp(mcIdType *beginPt) const override; }; } diff --git a/src/INTERP_KERNEL/Planar2D1DIntersectorP0P0.hxx b/src/INTERP_KERNEL/Planar2D1DIntersectorP0P0.hxx index 0ff8f2de0..5a59eea4e 100644 --- a/src/INTERP_KERNEL/Planar2D1DIntersectorP0P0.hxx +++ b/src/INTERP_KERNEL/Planar2D1DIntersectorP0P0.hxx @@ -21,7 +21,9 @@ #ifndef __PLANAR2D1DINTERSECTORP0P0_HXX__ #define __PLANAR2D1DINTERSECTORP0P0_HXX__ +#include "NormalizedUnstructuredMesh.hxx" #include "PlanarIntersector.hxx" +#include namespace INTERP_KERNEL { diff --git a/src/INTERP_KERNEL/Planar2D1DIntersectorP0P0.txx b/src/INTERP_KERNEL/Planar2D1DIntersectorP0P0.txx index 7b7162da9..df496b097 100644 --- a/src/INTERP_KERNEL/Planar2D1DIntersectorP0P0.txx +++ b/src/INTERP_KERNEL/Planar2D1DIntersectorP0P0.txx @@ -21,6 +21,10 @@ #define __PLANAR2D1DINTERSECTORP0P0_TXX__ #include "Planar2D1DIntersectorP0P0.hxx" +#include "PlanarIntersector.hxx" +#include "InterpolationUtils.hxx" +#include +#include namespace INTERP_KERNEL { diff --git a/src/INTERP_KERNEL/PlanarIntersector.hxx b/src/INTERP_KERNEL/PlanarIntersector.hxx index 273994eea..6cc8670c3 100644 --- a/src/INTERP_KERNEL/PlanarIntersector.hxx +++ b/src/INTERP_KERNEL/PlanarIntersector.hxx @@ -24,8 +24,10 @@ #include "TargetIntersector.txx" #include "NormalizedUnstructuredMesh.hxx" +#include #include #include +#include namespace INTERP_KERNEL { diff --git a/src/INTERP_KERNEL/PlanarIntersector.txx b/src/INTERP_KERNEL/PlanarIntersector.txx index f96f14ce1..fc411856f 100644 --- a/src/INTERP_KERNEL/PlanarIntersector.txx +++ b/src/INTERP_KERNEL/PlanarIntersector.txx @@ -24,8 +24,10 @@ #include "InterpolationUtils.hxx" #include "TranslationRotationMatrix.hxx" +#include #include #include +#include namespace INTERP_KERNEL { @@ -45,8 +47,7 @@ namespace INTERP_KERNEL template PlanarIntersector::~PlanarIntersector() - { - } + = default; /*! \brief creates the bounding boxes for all the cells of mesh \a mesh @@ -83,7 +84,7 @@ namespace INTERP_KERNEL const double* coord_node=coords+SPACEDIM*OTT::coo2C(conn[OTT::conn2C(conn_index[icell]+j)]); for(int idim=0; idimx)?bbox[ibox*2*SPACEDIM + 2*idim+1]:x; } @@ -114,7 +115,7 @@ namespace INTERP_KERNEL const double* coord_node=coords+SPACEDIM*(OTT::coo2C(conn[OTT::conn2C(conn_index[OTT::ind2C(iP)]+i)])); for(int idim=0; idimbb[2*idim+1])?x:bb[2*idim+1]; @@ -310,7 +311,7 @@ namespace INTERP_KERNEL prodvect[0]=G1[1]*G2[2]-G1[2]*G2[1]; prodvect[1]=G1[2]*G2[0]-G1[0]*G2[2]; prodvect[2]=G1[0]*G2[1]-G1[1]*G2[0]; - double prodscal=prodvect[0]*G3[0]+prodvect[1]*G3[1]+prodvect[2]*G3[2]; + double const prodscal=prodvect[0]*G3[0]+prodvect[1]*G3[1]+prodvect[2]*G3[2]; if(fabs(prodscal)>md3DSurf) return 0; } diff --git a/src/INTERP_KERNEL/PlanarIntersectorP0P0.hxx b/src/INTERP_KERNEL/PlanarIntersectorP0P0.hxx index 119507792..fc6883643 100644 --- a/src/INTERP_KERNEL/PlanarIntersectorP0P0.hxx +++ b/src/INTERP_KERNEL/PlanarIntersectorP0P0.hxx @@ -21,7 +21,9 @@ #ifndef __PLANARINTERSECTORP0P0_HXX__ #define __PLANARINTERSECTORP0P0_HXX__ +#include "NormalizedUnstructuredMesh.hxx" #include "PlanarIntersector.hxx" +#include namespace INTERP_KERNEL { @@ -31,7 +33,7 @@ namespace INTERP_KERNEL public: static const int SPACEDIM=MyMeshType::MY_SPACEDIM; static const int MESHDIM=MyMeshType::MY_MESHDIM; - typedef typename MyMeshType::MyConnType ConnType; + using ConnType = typename MyMeshType::MyConnType; static const NumberingPolicy numPol=MyMeshType::My_numPol; protected: PlanarIntersectorP0P0(const MyMeshType& meshT, const MyMeshType& meshS, double dimCaracteristic, double precision, double md3DSurf, double minDot3DSurf, double medianPlane, bool doRotate, int orientation, int printLevel); diff --git a/src/INTERP_KERNEL/PlanarIntersectorP0P0.txx b/src/INTERP_KERNEL/PlanarIntersectorP0P0.txx index efc35d027..312ce67fa 100644 --- a/src/INTERP_KERNEL/PlanarIntersectorP0P0.txx +++ b/src/INTERP_KERNEL/PlanarIntersectorP0P0.txx @@ -20,7 +20,9 @@ #ifndef __PLANARINTERSECTORP0P0_TXX__ #define __PLANARINTERSECTORP0P0_TXX__ +#include "PlanarIntersector.hxx" #include "PlanarIntersectorP0P0.hxx" +#include "InterpolationUtils.hxx" namespace INTERP_KERNEL { diff --git a/src/INTERP_KERNEL/PlanarIntersectorP0P1.hxx b/src/INTERP_KERNEL/PlanarIntersectorP0P1.hxx index 49cc7e947..7c2dedbd9 100644 --- a/src/INTERP_KERNEL/PlanarIntersectorP0P1.hxx +++ b/src/INTERP_KERNEL/PlanarIntersectorP0P1.hxx @@ -21,8 +21,9 @@ #ifndef __PLANARINTERSECTORP0P1_HXX__ #define __PLANARINTERSECTORP0P1_HXX__ +#include "NormalizedUnstructuredMesh.hxx" #include "PlanarIntersector.hxx" -#include "InterpKernelUtilities.hxx" +#include namespace INTERP_KERNEL { @@ -32,7 +33,7 @@ namespace INTERP_KERNEL public: static const int SPACEDIM=MyMeshType::MY_SPACEDIM; static const int MESHDIM=MyMeshType::MY_MESHDIM; - typedef typename MyMeshType::MyConnType ConnType; + using ConnType = typename MyMeshType::MyConnType; static const NumberingPolicy numPol=MyMeshType::My_numPol; protected: PlanarIntersectorP0P1(const MyMeshType& meshT, const MyMeshType& meshS, double dimCaracteristic, double precision, double md3DSurf, double minDot3DSurf, double medianPlane, bool doRotate, int orientation, int printLevel); diff --git a/src/INTERP_KERNEL/PlanarIntersectorP0P1.txx b/src/INTERP_KERNEL/PlanarIntersectorP0P1.txx index 4913a5295..66b6ca228 100644 --- a/src/INTERP_KERNEL/PlanarIntersectorP0P1.txx +++ b/src/INTERP_KERNEL/PlanarIntersectorP0P1.txx @@ -20,9 +20,13 @@ #ifndef __PLANARINTERSECTORP0P1_TXX__ #define __PLANARINTERSECTORP0P1_TXX__ +#include "PlanarIntersector.txx" +#include "InterpKernelUtilities.hxx" +#include "NormalizedGeometricTypes" #include "PlanarIntersectorP0P1.hxx" #include "InterpolationUtils.hxx" #include "CellModel.hxx" +#include namespace INTERP_KERNEL { diff --git a/src/INTERP_KERNEL/PlanarIntersectorP0P1Bary.hxx b/src/INTERP_KERNEL/PlanarIntersectorP0P1Bary.hxx index 70e8eb233..e79924ef0 100644 --- a/src/INTERP_KERNEL/PlanarIntersectorP0P1Bary.hxx +++ b/src/INTERP_KERNEL/PlanarIntersectorP0P1Bary.hxx @@ -21,7 +21,9 @@ #ifndef __PlanarIntersectorP0P1Bary_HXX__ #define __PlanarIntersectorP0P1Bary_HXX__ +#include "NormalizedUnstructuredMesh.hxx" #include "PlanarIntersector.hxx" +#include namespace INTERP_KERNEL { diff --git a/src/INTERP_KERNEL/PlanarIntersectorP0P1Bary.txx b/src/INTERP_KERNEL/PlanarIntersectorP0P1Bary.txx old mode 100755 new mode 100644 index 55b20556a..d1d4942c6 --- a/src/INTERP_KERNEL/PlanarIntersectorP0P1Bary.txx +++ b/src/INTERP_KERNEL/PlanarIntersectorP0P1Bary.txx @@ -21,8 +21,13 @@ #ifndef __PlanarIntersectorP0P1Bary_TXX__ #define __PlanarIntersectorP0P1Bary_TXX__ +#include "NormalizedGeometricTypes" +#include "PlanarIntersector.hxx" #include "PlanarIntersectorP0P1Bary.hxx" #include "InterpolationUtils.hxx" +#include "InterpKernelUtilities.hxx" +#include "CellModel.hxx" +#include namespace INTERP_KERNEL { diff --git a/src/INTERP_KERNEL/PlanarIntersectorP0P1PL.hxx b/src/INTERP_KERNEL/PlanarIntersectorP0P1PL.hxx index 0b81ba2a0..fad08eaf5 100644 --- a/src/INTERP_KERNEL/PlanarIntersectorP0P1PL.hxx +++ b/src/INTERP_KERNEL/PlanarIntersectorP0P1PL.hxx @@ -21,7 +21,9 @@ #ifndef __PLANARINTERSECTORP0P1PL_HXX__ #define __PLANARINTERSECTORP0P1PL_HXX__ +#include "NormalizedUnstructuredMesh.hxx" #include "PlanarIntersector.hxx" +#include namespace INTERP_KERNEL { diff --git a/src/INTERP_KERNEL/PlanarIntersectorP0P1PL.txx b/src/INTERP_KERNEL/PlanarIntersectorP0P1PL.txx index 0bf10fce4..8d370645e 100644 --- a/src/INTERP_KERNEL/PlanarIntersectorP0P1PL.txx +++ b/src/INTERP_KERNEL/PlanarIntersectorP0P1PL.txx @@ -20,11 +20,13 @@ #ifndef __PLANARINTERSECTORP0P1PL_TXX__ #define __PLANARINTERSECTORP0P1PL_TXX__ +#include "PlanarIntersector.hxx" +#include "InterpolationUtils.hxx" +#include "InterpKernelUtilities.hxx" #include "PlanarIntersectorP0P1PL.hxx" -#include "PlanarIntersector.txx" -#include "CellModel.hxx" #include "PointLocatorAlgos.txx" +#include namespace INTERP_KERNEL { diff --git a/src/INTERP_KERNEL/PlanarIntersectorP1P0.hxx b/src/INTERP_KERNEL/PlanarIntersectorP1P0.hxx index c73cac216..4b64bee3c 100644 --- a/src/INTERP_KERNEL/PlanarIntersectorP1P0.hxx +++ b/src/INTERP_KERNEL/PlanarIntersectorP1P0.hxx @@ -21,7 +21,9 @@ #ifndef __PLANARINTERSECTORP1P0_HXX__ #define __PLANARINTERSECTORP1P0_HXX__ +#include "NormalizedUnstructuredMesh.hxx" #include "PlanarIntersector.hxx" +#include namespace INTERP_KERNEL { diff --git a/src/INTERP_KERNEL/PlanarIntersectorP1P0.txx b/src/INTERP_KERNEL/PlanarIntersectorP1P0.txx index 8798ebedc..319c209bf 100644 --- a/src/INTERP_KERNEL/PlanarIntersectorP1P0.txx +++ b/src/INTERP_KERNEL/PlanarIntersectorP1P0.txx @@ -20,8 +20,13 @@ #ifndef __PLANARINTERSECTORP1P0_TXX__ #define __PLANARINTERSECTORP1P0_TXX__ +#include "NormalizedGeometricTypes" +#include "PlanarIntersector.txx" #include "PlanarIntersectorP1P0.hxx" #include "InterpolationUtils.hxx" +#include "InterpKernelUtilities.hxx" +#include "CellModel.hxx" +#include namespace INTERP_KERNEL { diff --git a/src/INTERP_KERNEL/PlanarIntersectorP1P0Bary.hxx b/src/INTERP_KERNEL/PlanarIntersectorP1P0Bary.hxx index c592b128d..43461984c 100644 --- a/src/INTERP_KERNEL/PlanarIntersectorP1P0Bary.hxx +++ b/src/INTERP_KERNEL/PlanarIntersectorP1P0Bary.hxx @@ -21,7 +21,9 @@ #ifndef __PlanarIntersectorP1P0Bary_HXX__ #define __PlanarIntersectorP1P0Bary_HXX__ +#include "NormalizedUnstructuredMesh.hxx" #include "PlanarIntersector.hxx" +#include namespace INTERP_KERNEL { @@ -31,7 +33,7 @@ namespace INTERP_KERNEL public: static const int SPACEDIM=MyMeshType::MY_SPACEDIM; static const int MESHDIM=MyMeshType::MY_MESHDIM; - typedef typename MyMeshType::MyConnType ConnType; + using ConnType = typename MyMeshType::MyConnType; static const NumberingPolicy numPol=MyMeshType::My_numPol; protected: PlanarIntersectorP1P0Bary(const MyMeshType& meshT, const MyMeshType& meshS, double dimCaracteristic, double precision, double md3DSurf, double minDot3DSurf, double medianPlane, bool doRotate, int orientation, int printLevel); diff --git a/src/INTERP_KERNEL/PlanarIntersectorP1P0Bary.txx b/src/INTERP_KERNEL/PlanarIntersectorP1P0Bary.txx old mode 100755 new mode 100644 index 8407cd2b1..2f6fd8c62 --- a/src/INTERP_KERNEL/PlanarIntersectorP1P0Bary.txx +++ b/src/INTERP_KERNEL/PlanarIntersectorP1P0Bary.txx @@ -20,8 +20,13 @@ #ifndef __PlanarIntersectorP1P0Bary_TXX__ #define __PlanarIntersectorP1P0Bary_TXX__ +#include "NormalizedGeometricTypes" +#include "PlanarIntersector.hxx" #include "PlanarIntersectorP1P0Bary.hxx" #include "InterpolationUtils.hxx" +#include "InterpKernelUtilities.hxx" +#include "CellModel.hxx" +#include #define PLAN_INTERSECTOR PlanarIntersectorP1P0Bary #define PLAN_INTER_TEMPLATE template diff --git a/src/INTERP_KERNEL/PlanarIntersectorP1P0PL.hxx b/src/INTERP_KERNEL/PlanarIntersectorP1P0PL.hxx index c40ceb92d..d21bee2eb 100644 --- a/src/INTERP_KERNEL/PlanarIntersectorP1P0PL.hxx +++ b/src/INTERP_KERNEL/PlanarIntersectorP1P0PL.hxx @@ -21,7 +21,9 @@ #ifndef __PLANARINTERSECTORP1P0PL_HXX__ #define __PLANARINTERSECTORP1P0PL_HXX__ +#include "NormalizedUnstructuredMesh.hxx" #include "PlanarIntersector.hxx" +#include namespace INTERP_KERNEL { @@ -31,7 +33,7 @@ namespace INTERP_KERNEL public: static const int SPACEDIM=MyMeshType::MY_SPACEDIM; static const int MESHDIM=MyMeshType::MY_MESHDIM; - typedef typename MyMeshType::MyConnType ConnType; + using ConnType = typename MyMeshType::MyConnType; static const NumberingPolicy numPol=MyMeshType::My_numPol; public: PlanarIntersectorP1P0PL(const MyMeshType& meshT, const MyMeshType& meshS, double dimCaracteristic, double md3DSurf, double minDot3DSurf, double medianPlane, double precision, int orientation); diff --git a/src/INTERP_KERNEL/PlanarIntersectorP1P0PL.txx b/src/INTERP_KERNEL/PlanarIntersectorP1P0PL.txx index 9cc39fa84..812282d71 100644 --- a/src/INTERP_KERNEL/PlanarIntersectorP1P0PL.txx +++ b/src/INTERP_KERNEL/PlanarIntersectorP1P0PL.txx @@ -20,13 +20,16 @@ #ifndef __PLANARINTERSECTORP1P0PL_TXX__ #define __PLANARINTERSECTORP1P0PL_TXX__ -#include "PlanarIntersectorP1P0PL.hxx" #include "PlanarIntersector.txx" -#include "CellModel.hxx" +#include "InterpolationUtils.hxx" +#include "NormalizedGeometricTypes" +#include "PlanarIntersectorP1P0PL.hxx" +#include "InterpKernelUtilities.hxx" +#include "VolSurfFormulae.hxx" #include "PointLocatorAlgos.txx" -#include "InterpKernelGeo2DQuadraticPolygon.hxx" -#include "MeshUtils.hxx" +#include +#include namespace INTERP_KERNEL { diff --git a/src/INTERP_KERNEL/PlanarIntersectorP1P1.hxx b/src/INTERP_KERNEL/PlanarIntersectorP1P1.hxx index 0ca0fb682..d7b4834fc 100644 --- a/src/INTERP_KERNEL/PlanarIntersectorP1P1.hxx +++ b/src/INTERP_KERNEL/PlanarIntersectorP1P1.hxx @@ -21,7 +21,9 @@ #ifndef __PLANARINTERSECTORP1P1_HXX__ #define __PLANARINTERSECTORP1P1_HXX__ +#include "NormalizedUnstructuredMesh.hxx" #include "PlanarIntersector.hxx" +#include namespace INTERP_KERNEL { diff --git a/src/INTERP_KERNEL/PlanarIntersectorP1P1.txx b/src/INTERP_KERNEL/PlanarIntersectorP1P1.txx index 83d159249..6445ad357 100644 --- a/src/INTERP_KERNEL/PlanarIntersectorP1P1.txx +++ b/src/INTERP_KERNEL/PlanarIntersectorP1P1.txx @@ -20,9 +20,11 @@ #ifndef __PLANARINTERSECTORP1P1_TXX__ #define __PLANARINTERSECTORP1P1_TXX__ +#include "PlanarIntersector.txx" #include "PlanarIntersectorP1P1.hxx" #include "InterpolationUtils.hxx" -#include "CellModel.hxx" +#include "InterpKernelUtilities.hxx" +#include namespace INTERP_KERNEL { diff --git a/src/INTERP_KERNEL/PlanarIntersectorP1P1PL.hxx b/src/INTERP_KERNEL/PlanarIntersectorP1P1PL.hxx index aa2b9ced2..1609a1bd5 100644 --- a/src/INTERP_KERNEL/PlanarIntersectorP1P1PL.hxx +++ b/src/INTERP_KERNEL/PlanarIntersectorP1P1PL.hxx @@ -21,7 +21,9 @@ #ifndef __PLANARINTERSECTORP1P1PL_HXX__ #define __PLANARINTERSECTORP1P1PL_HXX__ +#include "NormalizedUnstructuredMesh.hxx" #include "PlanarIntersector.hxx" +#include namespace INTERP_KERNEL { diff --git a/src/INTERP_KERNEL/PlanarIntersectorP1P1PL.txx b/src/INTERP_KERNEL/PlanarIntersectorP1P1PL.txx index 45692ac88..f57ac7739 100644 --- a/src/INTERP_KERNEL/PlanarIntersectorP1P1PL.txx +++ b/src/INTERP_KERNEL/PlanarIntersectorP1P1PL.txx @@ -20,12 +20,15 @@ #ifndef __PLANARINTERSECTORP1P1PL_TXX__ #define __PLANARINTERSECTORP1P1PL_TXX__ -#include "PlanarIntersectorP1P1PL.hxx" #include "PlanarIntersector.txx" -#include "CellModel.hxx" +#include "InterpolationUtils.hxx" +#include "NormalizedGeometricTypes" +#include "PlanarIntersectorP1P1PL.hxx" +#include "InterpKernelUtilities.hxx" #include "PointLocatorAlgos.txx" -#include "MeshUtils.hxx" +#include +#include namespace INTERP_KERNEL { diff --git a/src/INTERP_KERNEL/PointLocator2DIntersector.hxx b/src/INTERP_KERNEL/PointLocator2DIntersector.hxx index b6e2af5b4..ba3f44431 100644 --- a/src/INTERP_KERNEL/PointLocator2DIntersector.hxx +++ b/src/INTERP_KERNEL/PointLocator2DIntersector.hxx @@ -21,11 +21,9 @@ #ifndef __POINTLOCATORINTERSECTOR_HXX__ #define __POINTLOCATORINTERSECTOR_HXX__ -#include "PlanarIntersectorP0P0.hxx" -#include "PlanarIntersectorP0P1.hxx" -#include "PlanarIntersectorP1P0.hxx" -#include "PlanarIntersectorP1P1.hxx" -#include "PlanarIntersectorP1P0Bary.hxx" +#include "NormalizedUnstructuredMesh.hxx" +#include "NormalizedGeometricTypes" +#include namespace INTERP_KERNEL { diff --git a/src/INTERP_KERNEL/PointLocator2DIntersector.txx b/src/INTERP_KERNEL/PointLocator2DIntersector.txx index a1719a857..1ec0e01aa 100644 --- a/src/INTERP_KERNEL/PointLocator2DIntersector.txx +++ b/src/INTERP_KERNEL/PointLocator2DIntersector.txx @@ -21,15 +21,14 @@ #define __POINTLOCATORINTERSECTOR_TXX__ #include "PointLocator2DIntersector.hxx" -#include "PlanarIntersectorP0P0.txx" -#include "PlanarIntersectorP0P1.txx" -#include "PlanarIntersectorP1P0.txx" -#include "PlanarIntersectorP1P1.txx" -#include "PlanarIntersectorP1P0Bary.txx" +#include "PlanarIntersector.hxx" #include "CellModel.hxx" - -#include "InterpKernelGeo2DQuadraticPolygon.hxx" #include "PointLocatorAlgos.txx" +#include "NormalizedGeometricTypes" + +#include +#include + #define PTLOC2D_INTERSECTOR PointLocator2DIntersector #define INTERSECTOR_TEMPLATE template class InterpType> diff --git a/src/INTERP_KERNEL/PointLocator3DIntersectorP0P0.hxx b/src/INTERP_KERNEL/PointLocator3DIntersectorP0P0.hxx index 3d08e602d..e4cd815cd 100644 --- a/src/INTERP_KERNEL/PointLocator3DIntersectorP0P0.hxx +++ b/src/INTERP_KERNEL/PointLocator3DIntersectorP0P0.hxx @@ -23,7 +23,7 @@ #include "Intersector3DP0P0.hxx" #include "NormalizedUnstructuredMesh.hxx" -#include "InterpKernelUtilities.hxx" +#include namespace INTERP_KERNEL { diff --git a/src/INTERP_KERNEL/PointLocator3DIntersectorP0P0.txx b/src/INTERP_KERNEL/PointLocator3DIntersectorP0P0.txx index d3d3cdb4b..736cd0923 100644 --- a/src/INTERP_KERNEL/PointLocator3DIntersectorP0P0.txx +++ b/src/INTERP_KERNEL/PointLocator3DIntersectorP0P0.txx @@ -20,12 +20,16 @@ #ifndef __POINTLOCATOR3DINTERSECTORP0P0_TXX__ #define __POINTLOCATOR3DINTERSECTORP0P0_TXX__ -#include "PointLocator3DIntersectorP0P0.hxx" #include "Intersector3DP0P0.txx" -#include "MeshUtils.hxx" +#include "InterpolationUtils.hxx" +#include "InterpKernelUtilities.hxx" +#include "NormalizedGeometricTypes" +#include "CellModel.hxx" +#include "PointLocator3DIntersectorP0P0.hxx" +#include "VolSurfFormulae.hxx" -#include "SplitterTetra.txx" #include "PointLocatorAlgos.txx" +#include namespace INTERP_KERNEL { @@ -42,8 +46,7 @@ namespace INTERP_KERNEL template PointLocator3DIntersectorP0P0::~PointLocator3DIntersectorP0P0() - { - } + = default; /** * diff --git a/src/INTERP_KERNEL/PointLocator3DIntersectorP0P1.hxx b/src/INTERP_KERNEL/PointLocator3DIntersectorP0P1.hxx index f850f55c5..b98ff5e1a 100644 --- a/src/INTERP_KERNEL/PointLocator3DIntersectorP0P1.hxx +++ b/src/INTERP_KERNEL/PointLocator3DIntersectorP0P1.hxx @@ -23,7 +23,7 @@ #include "Intersector3DP0P1.hxx" #include "NormalizedUnstructuredMesh.hxx" -#include "InterpKernelUtilities.hxx" +#include namespace INTERP_KERNEL { diff --git a/src/INTERP_KERNEL/PointLocator3DIntersectorP0P1.txx b/src/INTERP_KERNEL/PointLocator3DIntersectorP0P1.txx index dde163aa9..eeb577186 100644 --- a/src/INTERP_KERNEL/PointLocator3DIntersectorP0P1.txx +++ b/src/INTERP_KERNEL/PointLocator3DIntersectorP0P1.txx @@ -20,9 +20,15 @@ #ifndef __POINTLOCATOR3DINTERSECTORP0P1_TXX__ #define __POINTLOCATOR3DINTERSECTORP0P1_TXX__ -#include "PointLocator3DIntersectorP0P1.hxx" #include "Intersector3DP0P1.txx" -#include "MeshUtils.hxx" +#include "InterpolationUtils.hxx" +#include "InterpKernelUtilities.hxx" +#include "NormalizedGeometricTypes" +#include "PointLocator3DIntersectorP0P1.hxx" +#include "PointLocatorAlgos.txx" +#include "CellModel.hxx" +#include +#include namespace INTERP_KERNEL { @@ -39,8 +45,7 @@ namespace INTERP_KERNEL template PointLocator3DIntersectorP0P1::~PointLocator3DIntersectorP0P1() - { - } + = default; /** * diff --git a/src/INTERP_KERNEL/PointLocator3DIntersectorP1P0.hxx b/src/INTERP_KERNEL/PointLocator3DIntersectorP1P0.hxx index a251ea2aa..7a7cedbdc 100644 --- a/src/INTERP_KERNEL/PointLocator3DIntersectorP1P0.hxx +++ b/src/INTERP_KERNEL/PointLocator3DIntersectorP1P0.hxx @@ -23,7 +23,7 @@ #include "Intersector3DP1P0.hxx" #include "NormalizedUnstructuredMesh.hxx" -#include "InterpKernelUtilities.hxx" +#include namespace INTERP_KERNEL { @@ -33,7 +33,7 @@ namespace INTERP_KERNEL public: static const int SPACEDIM=MyMeshType::MY_SPACEDIM; static const int MESHDIM=MyMeshType::MY_MESHDIM; - typedef typename MyMeshType::MyConnType ConnType; + using ConnType = typename MyMeshType::MyConnType; static const NumberingPolicy numPol=MyMeshType::My_numPol; public: PointLocator3DIntersectorP1P0(const MyMeshType& targetMesh, const MyMeshType& srcMesh, double precision); diff --git a/src/INTERP_KERNEL/PointLocator3DIntersectorP1P0.txx b/src/INTERP_KERNEL/PointLocator3DIntersectorP1P0.txx index 55598b2f8..58253b1be 100644 --- a/src/INTERP_KERNEL/PointLocator3DIntersectorP1P0.txx +++ b/src/INTERP_KERNEL/PointLocator3DIntersectorP1P0.txx @@ -20,9 +20,16 @@ #ifndef __POINTLOCATOR3DINTERSECTORP1P0_TXX__ #define __POINTLOCATOR3DINTERSECTORP1P0_TXX__ -#include "PointLocator3DIntersectorP1P0.hxx" #include "Intersector3DP1P0.txx" -#include "MeshUtils.hxx" +#include "InterpolationUtils.hxx" +#include "InterpKernelUtilities.hxx" +#include "NormalizedGeometricTypes" +#include "PointLocator3DIntersectorP1P0.hxx" +#include "CellModel.hxx" +#include "PointLocatorAlgos.txx" +#include "VolSurfFormulae.hxx" +#include +#include namespace INTERP_KERNEL { @@ -39,8 +46,7 @@ namespace INTERP_KERNEL template PointLocator3DIntersectorP1P0::~PointLocator3DIntersectorP1P0() - { - } + = default; /** * @param targetCell in C mode. diff --git a/src/INTERP_KERNEL/PointLocator3DIntersectorP1P1.hxx b/src/INTERP_KERNEL/PointLocator3DIntersectorP1P1.hxx index 653c93267..242818892 100644 --- a/src/INTERP_KERNEL/PointLocator3DIntersectorP1P1.hxx +++ b/src/INTERP_KERNEL/PointLocator3DIntersectorP1P1.hxx @@ -23,7 +23,7 @@ #include "Intersector3DP1P1.hxx" #include "NormalizedUnstructuredMesh.hxx" -#include "InterpKernelUtilities.hxx" +#include namespace INTERP_KERNEL { @@ -33,7 +33,7 @@ namespace INTERP_KERNEL public: static const int SPACEDIM=MyMeshType::MY_SPACEDIM; static const int MESHDIM=MyMeshType::MY_MESHDIM; - typedef typename MyMeshType::MyConnType ConnType; + using ConnType = typename MyMeshType::MyConnType; static const NumberingPolicy numPol=MyMeshType::My_numPol; public: PointLocator3DIntersectorP1P1(const MyMeshType& targetMesh, const MyMeshType& srcMesh, double precision); diff --git a/src/INTERP_KERNEL/PointLocator3DIntersectorP1P1.txx b/src/INTERP_KERNEL/PointLocator3DIntersectorP1P1.txx index ccd3eab13..8f8a8cba1 100644 --- a/src/INTERP_KERNEL/PointLocator3DIntersectorP1P1.txx +++ b/src/INTERP_KERNEL/PointLocator3DIntersectorP1P1.txx @@ -20,9 +20,16 @@ #ifndef __POINTLOCATOR3DINTERSECTORP1P1_TXX__ #define __POINTLOCATOR3DINTERSECTORP1P1_TXX__ -#include "PointLocator3DIntersectorP1P1.hxx" #include "Intersector3DP1P1.txx" -#include "MeshUtils.hxx" +#include "InterpolationUtils.hxx" +#include "InterpKernelUtilities.hxx" +#include "NormalizedGeometricTypes" +#include "PointLocator3DIntersectorP1P1.hxx" +#include "CellModel.hxx" +#include "PointLocatorAlgos.txx" +#include +#include +#include namespace INTERP_KERNEL { @@ -41,8 +48,7 @@ namespace INTERP_KERNEL template PointLocator3DIntersectorP1P1::~PointLocator3DIntersectorP1P1() - { - } + = default; /** * @param targetCell in C mode. diff --git a/src/INTERP_KERNEL/PointLocatorAlgos.txx b/src/INTERP_KERNEL/PointLocatorAlgos.txx index 95b616b33..00b02460c 100644 --- a/src/INTERP_KERNEL/PointLocatorAlgos.txx +++ b/src/INTERP_KERNEL/PointLocatorAlgos.txx @@ -20,6 +20,7 @@ #ifndef __POINTLOCATORALGOS_TXX__ #define __POINTLOCATORALGOS_TXX__ +#include "InterpKernelGeo2DPrecision.hxx" #include "InterpolationUtils.hxx" #include "CellModel.hxx" #include "BBTree.txx" @@ -27,7 +28,12 @@ #include "InterpKernelGeo2DNode.hxx" #include "InterpKernelGeo2DQuadraticPolygon.hxx" +#include "MCIdType.hxx" +#include "NormalizedUnstructuredMesh.hxx" +#include "NormalizedGeometricTypes" +#include +#include #include #include #include @@ -39,7 +45,7 @@ namespace INTERP_KERNEL class GenericPointLocatorAlgos { public: - virtual ~GenericPointLocatorAlgos() { } + virtual ~GenericPointLocatorAlgos() = default; virtual std::list locates(const double* x, double eps) = 0; }; @@ -84,7 +90,7 @@ namespace INTERP_KERNEL _tree=new BBTree(_bb,0,0,nelem); } - ~PointLocatorAlgos() + ~PointLocatorAlgos() override { delete[] _bb; delete _tree; @@ -92,7 +98,7 @@ namespace INTERP_KERNEL //returns the list of elements that contains //the point pointed to by x - std::list locates(const double* x, double eps) + std::list locates(const double* x, double eps) override { typedef typename MyMeshType::MyConnType ConnType; const NumberingPolicy numPol=MyMeshType::My_numPol; @@ -121,12 +127,12 @@ namespace INTERP_KERNEL here XA^XC and XC^XB have different signs*/ const int SPACEDIM=MyMeshType::MY_SPACEDIM; - std::unique_ptr sign( new char[nbEdges] ); + std::unique_ptr const sign( new char[nbEdges] ); for (mcIdType iedge=0; iedgeeps) @@ -141,7 +147,7 @@ namespace INTERP_KERNEL // Same as isElementContainsPointAlg2DSimple() with a different input format ... static bool isElementContainsPointAlgo2DSimple2(const double *ptToTest, NormalizedCellType type, const double *coords, const typename MyMeshType::MyConnType *conn_elem, - typename MyMeshType::MyConnType conn_elem_sz, double eps) + typename MyMeshType::MyConnType /*conn_elem_sz*/, double eps) { const int SPACEDIM=MyMeshType::MY_SPACEDIM; typedef typename MyMeshType::MyConnType ConnType; @@ -150,8 +156,8 @@ namespace INTERP_KERNEL const CellModel& cmType=CellModel::GetCellModel(type); bool ret=false; - int nbEdges=cmType.getNumberOfSons(); - double *pts = new double[nbEdges*SPACEDIM]; + int const nbEdges=cmType.getNumberOfSons(); + auto *pts = new double[nbEdges*SPACEDIM]; for (int iedge=0; iedge::ind2C(conn_elem[iedge])); @@ -167,14 +173,14 @@ namespace INTERP_KERNEL typename MyMeshType::MyConnType conn_elem_sz, double eps) { // Override precision for this method only: - INTERP_KERNEL::QuadraticPlanarPrecision prec(eps); + INTERP_KERNEL::QuadraticPlanarPrecision const prec(eps); const int SPACEDIM=MyMeshType::MY_SPACEDIM; typedef typename MyMeshType::MyConnType ConnType; const NumberingPolicy numPol=MyMeshType::My_numPol; std::vector nodes(conn_elem_sz); - INTERP_KERNEL::QuadraticPolygon *pol(0); + INTERP_KERNEL::QuadraticPolygon *pol(nullptr); for(mcIdType j=0;j::ind2C(conn_elem[j])); @@ -184,10 +190,10 @@ namespace INTERP_KERNEL pol=INTERP_KERNEL::QuadraticPolygon::BuildLinearPolygon(nodes); else pol=INTERP_KERNEL::QuadraticPolygon::BuildArcCirclePolygon(nodes); - INTERP_KERNEL::Node *n(new INTERP_KERNEL::Node(ptToTest[0],ptToTest[1])); + auto *n(new INTERP_KERNEL::Node(ptToTest[0],ptToTest[1])); double a(0.),b(0.),c(0.); a=pol->normalizeMe(b,c); n->applySimilarity(b,c,a); - bool ret=pol->isInOrOut2(n); + bool const ret=pol->isInOrOut2(n); delete pol; n->decrRef(); return ret; } @@ -199,9 +205,9 @@ namespace INTERP_KERNEL const NumberingPolicy numPol=MyMeshType::My_numPol; int nbfaces = cmType.getNumberOfSons2(conn_elem,conn_elem_sz); - std::unique_ptr sign( new char[nbfaces] ); + std::unique_ptr const sign( new char[nbfaces] ); std::unique_ptr connOfSon( new ConnType[conn_elem_sz] ); - std::unique_ptr ptsOfTetrahedrizedPolyhedron( new double[3*3*nbfaces] ); + std::unique_ptr const ptsOfTetrahedrizedPolyhedron( new double[3*3*nbfaces] ); for (int iface=0; iface::ind2C(conn_elem[0]))]; double p2=coords[(OTT::ind2C(conn_elem[1]))]; - double delta=fabs(p1-p2)+eps; - double val=*ptToTest-std::min(p1,p2); + double const delta=fabs(p1-p2)+eps; + double const val=*ptToTest-std::min(p1,p2); return val>-eps && val #include #include #include diff --git a/src/INTERP_KERNEL/PolygonAlgorithms.txx b/src/INTERP_KERNEL/PolygonAlgorithms.txx index aad88b083..b7fff36db 100644 --- a/src/INTERP_KERNEL/PolygonAlgorithms.txx +++ b/src/INTERP_KERNEL/PolygonAlgorithms.txx @@ -21,9 +21,14 @@ #include "PolygonAlgorithms.hxx" #include "InterpolationUtils.hxx" +#include +#include +#include #include #include #include +#include +#include namespace INTERP_KERNEL { @@ -170,7 +175,7 @@ namespace INTERP_KERNEL /* i is the local index of the current vertex */ /*************************************************************/ template - inline void PolygonAlgorithms::addNewVertex( int i, int i_glob, int i_next_glob, int i_prev_glob, + inline void PolygonAlgorithms::addNewVertex( int i, int i_glob, int i_next_glob, int /*i_prev_glob*/, const double * P) { /* Question:Should we add vertex i to the front or back ? */ @@ -244,8 +249,8 @@ namespace INTERP_KERNEL //fifth and sixth arguments are useless here { /* Updating _End_segments */ - std::pair< int,int > i_i_next = std::make_pair(i, i_next); - std::pair< int,int > j_j_next = std::make_pair(j, j_next); + std::pair< int,int > const i_i_next = std::make_pair(i, i_next); + std::pair< int,int > const j_j_next = std::make_pair(j, j_next); if( _End_segments[0] == i_i_next) { for(int idim=DIM-1;idim>-1;idim--) _Inter.push_front(ABCD[idim]); @@ -260,7 +265,7 @@ namespace INTERP_KERNEL /* Updating _Status */ _Status.insert(make_pair(i_next,std::make_pair(i, false))); - std::multimap< int, std::pair< int,bool> >::iterator mi =_Status.find(j_next); + auto mi =_Status.find(j_next); ((* mi).second).second= !((* mi).second).second; } else _Status.insert(std::make_pair(i_next,std::make_pair(i,true))); @@ -333,7 +338,7 @@ namespace INTERP_KERNEL int& j3, int& j3_glob, int& j4, int& j4_glob, int& i_glob, int& i_next_glob, int& i_prev_glob, const double * P_1, const double * P_2, - int N1, int N2, int sign) + int N1, int N2, int /*sign*/) { int N0, shift; if(i_glob < N1) @@ -343,7 +348,7 @@ namespace INTERP_KERNEL Poly1 = P_1; Poly2 = P_2; - std::multimap< int, std::pair< int,bool> >::reverse_iterator mi1=_Status.rbegin(); + auto mi1=_Status.rbegin(); j1_glob=((*mi1).second).first; j1=j1_glob-N1; j2_glob=(*mi1).first; @@ -361,7 +366,7 @@ namespace INTERP_KERNEL Poly1 = P_2; Poly2 = P_1; - std::multimap< int, std::pair< int,bool> >::iterator mi2= _Status.begin(); + auto mi2= _Status.begin(); j1_glob=((*mi2).second).first; j1=j1_glob; j2_glob=(*mi2).first; @@ -418,7 +423,7 @@ namespace INTERP_KERNEL /******** Treatment of the first vertex ********/ mi1=events.begin(); i_glob = (* mi1).second; - bool which_start = i_glob < N1; + bool const which_start = i_glob < N1; if(i_glob < N1){ i_next_glob = (i_glob +1)%N1; i_prev_glob = (i_glob -1+N1)%N1;} else{ i_next_glob = (i_glob-N1+1)%N2 + N1;i_prev_glob = (i_glob-N1-1+N2)%N2 + N1;} _Status.insert(std::make_pair(i_next_glob,std::make_pair(i_glob, false))); @@ -621,12 +626,12 @@ namespace INTERP_KERNEL which_is_inside[inside_j2] = std::make_pair(j1_glob,j2_glob); which_is_inside[inside_j4] = std::make_pair(j3_glob,j4_glob); - std::map >::iterator min = which_is_inside.begin(); - std::map >::iterator minext = min; + auto const min = which_is_inside.begin(); + auto minext = min; minext++; - std::map >::reverse_iterator max = which_is_inside.rbegin(); - std::multimap< int, std::pair< int,bool> >::iterator j2_in_status = _Status.find(((*min).second).second); - std::multimap< int, std::pair< int,bool> >::iterator j4_in_status = _Status.find(((*minext).second).second); + auto const max = which_is_inside.rbegin(); + auto j2_in_status = _Status.find(((*min).second).second); + auto j4_in_status = _Status.find(((*minext).second).second); if((*min).first < -_epsilon) //there is someone clearly inside { @@ -679,24 +684,24 @@ namespace INTERP_KERNEL /* in the end, subP contains only the elements belonging to the convex hull, and not_in_hull the others */ /**************************************************************************/ template - inline void PolygonAlgorithms::convHull(const double *P, int N, double * normal, + inline void PolygonAlgorithms::convHull(const double *P, int /*N*/, double * normal, std::map< int,int >& subP, std::map< int,int >& not_in_hull, int& NsubP, const double epsilon) { if(NsubP>3) { - std::map< int,int >::iterator mi_prev = subP.begin(); - std::map< int,int >::iterator mi = mi_prev; + auto mi_prev = subP.begin(); + auto mi = mi_prev; mi++; - std::map< int,int >::iterator mi_next = mi; + auto mi_next = mi; mi_next++; double directframe=0.; /* Check if the polygon subP is positively oriented */ - std::map< int,int >::iterator mi1=mi; + auto mi1=mi; while(mi1 != subP.end() && distance2(&P[DIM*(*subP.begin()).second],&P[DIM*(*mi1).second])< epsilon) mi1++; - std::map< int,int >::iterator mi2=mi1; + auto mi2=mi1; while(mi2 != subP.end() && fabs(directframe)(&P[DIM* (*mi1).second], diff --git a/src/INTERP_KERNEL/Polyhedron3D2DIntersectorP0P0.hxx b/src/INTERP_KERNEL/Polyhedron3D2DIntersectorP0P0.hxx index 9c826bd15..ea6332dc4 100644 --- a/src/INTERP_KERNEL/Polyhedron3D2DIntersectorP0P0.hxx +++ b/src/INTERP_KERNEL/Polyhedron3D2DIntersectorP0P0.hxx @@ -21,8 +21,12 @@ #define __POLYHEDRON3D2DINTERSECTORP0P0_HXX__ #include "Intersector3DP0P0.hxx" +#include "MCIdType.hxx" #include "SplitterTetra.hxx" #include "NormalizedUnstructuredMesh.hxx" +#include +#include +#include namespace INTERP_KERNEL { @@ -36,12 +40,12 @@ namespace INTERP_KERNEL template class Polyhedron3D2DIntersectorP0P0 : public Intersector3DP0P0 { - typedef typename std::map > DuplicateFacesType; + using DuplicateFacesType = typename std::map>; public: static const int SPACEDIM=MyMeshType::MY_SPACEDIM; static const int MESHDIM=MyMeshType::MY_MESHDIM; - typedef typename MyMeshType::MyConnType ConnType; + using ConnType = typename MyMeshType::MyConnType; static const NumberingPolicy numPol=MyMeshType::My_numPol; public: diff --git a/src/INTERP_KERNEL/Polyhedron3D2DIntersectorP0P0.txx b/src/INTERP_KERNEL/Polyhedron3D2DIntersectorP0P0.txx index a63fe24a2..2c4b4b556 100644 --- a/src/INTERP_KERNEL/Polyhedron3D2DIntersectorP0P0.txx +++ b/src/INTERP_KERNEL/Polyhedron3D2DIntersectorP0P0.txx @@ -19,11 +19,18 @@ #ifndef __POLYHEDRON3D2DINTERSECTORP0P0_TXX__ #define __POLYHEDRON3D2DINTERSECTORP0P0_TXX__ -#include "Polyhedron3D2DIntersectorP0P0.hxx" +#include "NormalizedGeometricTypes" #include "Intersector3DP0P0.txx" +#include "Intersector3D.hxx" +#include "InterpolationUtils.hxx" +#include "CellModel.hxx" +#include "MCIdType.hxx" +#include "Polyhedron3D2DIntersectorP0P0.hxx" #include "MeshUtils.hxx" - +#include #include "SplitterTetra.txx" +#include + namespace INTERP_KERNEL { @@ -104,8 +111,8 @@ namespace INTERP_KERNEL const CellModel& cellModelCell=CellModel::GetCellModel(normCellType); const MyMeshType& src_mesh = Intersector3D::_src_mesh; ConnType nbOfNodes4Type=cellModelCell.isDynamic() ? src_mesh.getNumberOfNodesOfElement(cellSrcIdx) : cellModelCell.getNumberOfNodes(); - mcIdType *polyNodes=new mcIdType[nbOfNodes4Type]; - double **polyCoords = new double*[nbOfNodes4Type]; + auto *polyNodes=new mcIdType[nbOfNodes4Type]; + auto **polyCoords = new double*[nbOfNodes4Type]; for(int i = 0;i<(int)nbOfNodes4Type;++i) { // we could store mapping local -> global numbers too, but not sure it is worth it @@ -146,7 +153,7 @@ namespace INTERP_KERNEL if (isSrcFaceColinearWithFaceOfTetraTargetCell) { - DuplicateFacesType::iterator intersectFacesIter = _intersect_faces.find(cellSrcIdx); + auto intersectFacesIter = _intersect_faces.find(cellSrcIdx); if (intersectFacesIter != _intersect_faces.end()) { intersectFacesIter->second.insert(targetCell); diff --git a/src/INTERP_KERNEL/PolyhedronIntersectorP0P0.hxx b/src/INTERP_KERNEL/PolyhedronIntersectorP0P0.hxx index 389256e26..3b4d6f798 100644 --- a/src/INTERP_KERNEL/PolyhedronIntersectorP0P0.hxx +++ b/src/INTERP_KERNEL/PolyhedronIntersectorP0P0.hxx @@ -24,6 +24,7 @@ #include "Intersector3DP0P0.hxx" #include "SplitterTetra.hxx" #include "NormalizedUnstructuredMesh.hxx" +#include namespace INTERP_KERNEL { @@ -40,7 +41,7 @@ namespace INTERP_KERNEL public: static const int SPACEDIM=MyMeshType::MY_SPACEDIM; static const int MESHDIM=MyMeshType::MY_MESHDIM; - typedef typename MyMeshType::MyConnType ConnType; + using ConnType = typename MyMeshType::MyConnType; static const NumberingPolicy numPol=MyMeshType::My_numPol; public: diff --git a/src/INTERP_KERNEL/PolyhedronIntersectorP0P0.txx b/src/INTERP_KERNEL/PolyhedronIntersectorP0P0.txx index 6e3cdda1a..8ab82512a 100644 --- a/src/INTERP_KERNEL/PolyhedronIntersectorP0P0.txx +++ b/src/INTERP_KERNEL/PolyhedronIntersectorP0P0.txx @@ -21,9 +21,12 @@ #define __POLYHEDRONINTERSECTORP0P0_TXX__ #include "PolyhedronIntersectorP0P0.hxx" -#include "Intersector3DP0P0.txx" -#include "MeshUtils.hxx" +#include + +#include "NormalizedGeometricTypes" +#include "Intersector3DP0P0.txx" +#include "InterpolationUtils.hxx" #include "SplitterTetra.txx" namespace INTERP_KERNEL diff --git a/src/INTERP_KERNEL/PolyhedronIntersectorP0P1.hxx b/src/INTERP_KERNEL/PolyhedronIntersectorP0P1.hxx index 666fe3bad..2734090e7 100644 --- a/src/INTERP_KERNEL/PolyhedronIntersectorP0P1.hxx +++ b/src/INTERP_KERNEL/PolyhedronIntersectorP0P1.hxx @@ -24,6 +24,7 @@ #include "Intersector3DP0P1.hxx" #include "SplitterTetra.hxx" #include "NormalizedUnstructuredMesh.hxx" +#include namespace INTERP_KERNEL { diff --git a/src/INTERP_KERNEL/PolyhedronIntersectorP0P1.txx b/src/INTERP_KERNEL/PolyhedronIntersectorP0P1.txx index a1fa4c494..f0c8106ee 100644 --- a/src/INTERP_KERNEL/PolyhedronIntersectorP0P1.txx +++ b/src/INTERP_KERNEL/PolyhedronIntersectorP0P1.txx @@ -20,11 +20,14 @@ #ifndef __POLYHEDRONINTERSECTORP0P1_TXX__ #define __POLYHEDRONINTERSECTORP0P1_TXX__ -#include "PolyhedronIntersectorP0P1.hxx" +#include "NormalizedGeometricTypes" #include "Intersector3DP0P1.txx" -#include "MeshUtils.hxx" +#include "InterpolationUtils.hxx" +#include "PolyhedronIntersectorP0P1.hxx" -#include "SplitterTetra.txx" +#include "SplitterTetra.hxx" +#include +#include namespace INTERP_KERNEL { @@ -85,9 +88,8 @@ namespace INTERP_KERNEL for(typename std::vector*>::iterator iter = _tetra.begin(); iter != _tetra.end(); ++iter) { (*iter)->splitIntoDualCells(subTetras); - for(int i=0;i<24;i++) + for(auto tmp : subTetras) { - SplitterTetra *tmp=subTetras[i]; double volume = tmp->intersectSourceCell(*iterCellS); if(volume!=0.) { diff --git a/src/INTERP_KERNEL/PolyhedronIntersectorP1P0.hxx b/src/INTERP_KERNEL/PolyhedronIntersectorP1P0.hxx index 5d1d6967d..8881b966a 100644 --- a/src/INTERP_KERNEL/PolyhedronIntersectorP1P0.hxx +++ b/src/INTERP_KERNEL/PolyhedronIntersectorP1P0.hxx @@ -24,6 +24,7 @@ #include "Intersector3DP1P0.hxx" #include "SplitterTetra.hxx" #include "NormalizedUnstructuredMesh.hxx" +#include namespace INTERP_KERNEL { @@ -40,7 +41,7 @@ namespace INTERP_KERNEL public: static const int SPACEDIM=MyMeshType::MY_SPACEDIM; static const int MESHDIM=MyMeshType::MY_MESHDIM; - typedef typename MyMeshType::MyConnType ConnType; + using ConnType = typename MyMeshType::MyConnType; static const NumberingPolicy numPol=MyMeshType::My_numPol; public: diff --git a/src/INTERP_KERNEL/PolyhedronIntersectorP1P0.txx b/src/INTERP_KERNEL/PolyhedronIntersectorP1P0.txx index 57c93bf15..f51bccf04 100644 --- a/src/INTERP_KERNEL/PolyhedronIntersectorP1P0.txx +++ b/src/INTERP_KERNEL/PolyhedronIntersectorP1P0.txx @@ -20,11 +20,15 @@ #ifndef __POLYHEDRONINTERSECTORP1P0_TXX__ #define __POLYHEDRONINTERSECTORP1P0_TXX__ -#include "PolyhedronIntersectorP1P0.hxx" +#include "NormalizedGeometricTypes" #include "Intersector3DP1P0.txx" -#include "MeshUtils.hxx" +#include "InterpKernelException.hxx" +#include "InterpolationUtils.hxx" +#include "Intersector3D.txx" +#include "PolyhedronIntersectorP1P0.hxx" #include "SplitterTetra.txx" +#include namespace INTERP_KERNEL { @@ -114,9 +118,8 @@ namespace INTERP_KERNEL { (*iter)->splitIntoDualCells(subTetras); double vol2 = 0.; - for(int i=0;i<24;i++) + for(auto tmp : subTetras) { - SplitterTetra *tmp=subTetras[i]; double volume = tmp->intersectSourceCell(targetCell); vol2 += volume; ConnType sourceNode=tmp->getId(0); diff --git a/src/INTERP_KERNEL/PolyhedronIntersectorP1P0Bary.hxx b/src/INTERP_KERNEL/PolyhedronIntersectorP1P0Bary.hxx index 7944b9715..7f2187e42 100644 --- a/src/INTERP_KERNEL/PolyhedronIntersectorP1P0Bary.hxx +++ b/src/INTERP_KERNEL/PolyhedronIntersectorP1P0Bary.hxx @@ -24,6 +24,7 @@ #include "Intersector3DP1P0Bary.hxx" #include "SplitterTetra.hxx" #include "NormalizedUnstructuredMesh.hxx" +#include namespace INTERP_KERNEL { @@ -40,7 +41,7 @@ namespace INTERP_KERNEL public: static const int SPACEDIM=MyMeshType::MY_SPACEDIM; static const int MESHDIM=MyMeshType::MY_MESHDIM; - typedef typename MyMeshType::MyConnType ConnType; + using ConnType = typename MyMeshType::MyConnType; static const NumberingPolicy numPol=MyMeshType::My_numPol; public: diff --git a/src/INTERP_KERNEL/PolyhedronIntersectorP1P0Bary.txx b/src/INTERP_KERNEL/PolyhedronIntersectorP1P0Bary.txx old mode 100755 new mode 100644 index b10fc9bfd..03d55d5d3 --- a/src/INTERP_KERNEL/PolyhedronIntersectorP1P0Bary.txx +++ b/src/INTERP_KERNEL/PolyhedronIntersectorP1P0Bary.txx @@ -20,11 +20,15 @@ #ifndef __PolyhedronIntersectorP1P0Bary_TXX__ #define __PolyhedronIntersectorP1P0Bary_TXX__ -#include "PolyhedronIntersectorP1P0Bary.hxx" +#include "NormalizedGeometricTypes" #include "Intersector3DP1P0Bary.txx" -#include "MeshUtils.hxx" +#include "InterpolationUtils.hxx" +#include "Intersector3D.txx" +#include "PolyhedronIntersectorP1P0Bary.hxx" +// #include "MeshUtils.hxx" #include "SplitterTetra.txx" +#include namespace INTERP_KERNEL { diff --git a/src/INTERP_KERNEL/PolyhedronIntersectorP1P1.hxx b/src/INTERP_KERNEL/PolyhedronIntersectorP1P1.hxx index 489093e0a..e1f4e36eb 100644 --- a/src/INTERP_KERNEL/PolyhedronIntersectorP1P1.hxx +++ b/src/INTERP_KERNEL/PolyhedronIntersectorP1P1.hxx @@ -22,8 +22,9 @@ #define __PolyhedronIntersectorP1P1_HXX__ #include "Intersector3DP1P1.hxx" -#include "SplitterTetra.hxx" #include "NormalizedUnstructuredMesh.hxx" +#include "NormalizedGeometricTypes" +#include namespace INTERP_KERNEL { @@ -40,7 +41,7 @@ namespace INTERP_KERNEL public: static const int SPACEDIM=MyMeshType::MY_SPACEDIM; static const int MESHDIM=MyMeshType::MY_MESHDIM; - typedef typename MyMeshType::MyConnType ConnType; + using ConnType = typename MyMeshType::MyConnType; static const NumberingPolicy numPol=MyMeshType::My_numPol; public: diff --git a/src/INTERP_KERNEL/PolyhedronIntersectorP1P1.txx b/src/INTERP_KERNEL/PolyhedronIntersectorP1P1.txx old mode 100755 new mode 100644 index 7420a06f8..b303c65e2 --- a/src/INTERP_KERNEL/PolyhedronIntersectorP1P1.txx +++ b/src/INTERP_KERNEL/PolyhedronIntersectorP1P1.txx @@ -21,10 +21,16 @@ #define __PolyhedronIntersectorP1P1_TXX__ #include "PolyhedronIntersectorP1P1.hxx" + +#include "NormalizedGeometricTypes" #include "Intersector3DP1P1.txx" -#include "MeshUtils.hxx" +#include "InterpolationUtils.hxx" +#include "Intersector3D.txx" +// #include "MeshUtils.hxx" #include "SplitterTetra.txx" +#include +#include namespace INTERP_KERNEL { @@ -37,7 +43,7 @@ namespace INTERP_KERNEL * @param policy splitting policy to be used */ template - PolyhedronIntersectorP1P1::PolyhedronIntersectorP1P1(const MyMeshType& targetMesh, const MyMeshType& srcMesh, SplittingPolicy policy):Intersector3DP1P1(targetMesh,srcMesh) + PolyhedronIntersectorP1P1::PolyhedronIntersectorP1P1(const MyMeshType& targetMesh, const MyMeshType& srcMesh, SplittingPolicy /*policy*/):Intersector3DP1P1(targetMesh,srcMesh) { // SPEC: // "Limitation. Concerning P1P1 3D improvement only tetrahedron will be supported. @@ -62,8 +68,7 @@ namespace INTERP_KERNEL */ template PolyhedronIntersectorP1P1::~PolyhedronIntersectorP1P1() - { - } + = default; /** * Calculates the volume of intersection of an element in the source mesh and the target element @@ -103,18 +108,17 @@ namespace INTERP_KERNEL srcTetra.splitIntoDualCells(subTetrasS); // intersect each target subTetra with each source one - for(int i=0;i<24;i++) + for(auto tmp : subTetrasS) { - SplitterTetra *tmp=subTetrasS[i]; ConnType sourceNode=OTT::indFC(tmp->getId(0)); - for(int j=0;j<24;j++) + for(auto & subTetraNode : subTetraNodes) { - const double* tetraNodes12 = &subTetraNodes[j].second[0]; + const double* tetraNodes12 = &subTetraNode.second[0]; const double* tetraNodesT[4]={ tetraNodes12, tetraNodes12+3, tetraNodes12+6, tetraNodes12+9 }; double volume = tmp->intersectTetra( tetraNodesT ); if(volume!=0.) { - ConnType tgtNode=subTetraNodes[j].first; + ConnType tgtNode=subTetraNode.first; typename MyMatrix::value_type& resRow = res[tgtNode]; typename MyMatrix::value_type::const_iterator iterRes=resRow.find( sourceNode ); if(iterRes!=resRow.end()) diff --git a/src/INTERP_KERNEL/RegionNode.hxx b/src/INTERP_KERNEL/RegionNode.hxx index 091ab4739..7ddb130a8 100644 --- a/src/INTERP_KERNEL/RegionNode.hxx +++ b/src/INTERP_KERNEL/RegionNode.hxx @@ -35,9 +35,9 @@ namespace INTERP_KERNEL { public: - RegionNode() { } + RegionNode() = default; - ~RegionNode() { } + ~RegionNode() = default; /** * Accessor to source region diff --git a/src/INTERP_KERNEL/SplitterTetra.cxx b/src/INTERP_KERNEL/SplitterTetra.cxx index 6fb3fe332..66ab579ab 100644 --- a/src/INTERP_KERNEL/SplitterTetra.cxx +++ b/src/INTERP_KERNEL/SplitterTetra.cxx @@ -19,6 +19,11 @@ // Author : Anthony Geay (CEA/DEN) #include "SplitterTetra.hxx" +#include "MCIdType.hxx" +#include "InterpKernelException.hxx" +#include +#include +#include namespace INTERP_KERNEL { @@ -66,7 +71,7 @@ namespace INTERP_KERNEL tmp2[0]=0.; tmp2[1]=0.; tmp2[2]=0.; for(int j=0;j<4;j++,conn+=4) { - mcIdType tmp3(nodalConnBg[GENERAL_24_SUB_NODES_WO[4*i+j]]); + mcIdType const tmp3(nodalConnBg[GENERAL_24_SUB_NODES_WO[4*i+j]]); tmp2[0]+=coords[3*tmp3+0]; tmp2[1]+=coords[3*tmp3+1]; tmp2[2]+=coords[3*tmp3+2]; @@ -126,7 +131,7 @@ namespace INTERP_KERNEL { case NORM_TETRA4: { - std::size_t sz(std::distance(nodalConnBg,nodalConnEnd)); + std::size_t const sz(std::distance(nodalConnBg,nodalConnEnd)); if(sz!=4) throw INTERP_KERNEL::Exception("SplitIntoTetras : input tetra do not have 4 nodes !"); tetrasNodalConn.insert(tetrasNodalConn.end(),nodalConnBg,nodalConnEnd); @@ -203,12 +208,12 @@ namespace INTERP_KERNEL conn[0]=work[j]; conn[1]=work[(j+1)%nbOfNodesOfFace]; conn[2]=-(i+1); conn[3]=ToIdType(-(nbOfFaces+1)); tmp[0]+=coords[3*work[j]+0]; tmp[1]+=coords[3*work[j]+1]; tmp[2]+=coords[3*work[j]+2]; } - double nbNF = (double)nbOfNodesOfFace; + auto const nbNF = (double)nbOfNodesOfFace; tmp[0]/=nbNF; tmp[1]/=nbNF; tmp[2]/=nbNF; tmp2[0]+=tmp[0]; tmp2[1]+=tmp[1]; tmp2[2]+=tmp[2]; work+=nbOfNodesOfFace+1; } - double nbF = (double)nbOfFaces; + auto const nbF = (double)nbOfFaces; tmp2[0]/=nbF; tmp2[1]/=nbF; tmp2[2]/=nbF; return ; } diff --git a/src/INTERP_KERNEL/SplitterTetra.hxx b/src/INTERP_KERNEL/SplitterTetra.hxx index 80f704873..806f4e4aa 100644 --- a/src/INTERP_KERNEL/SplitterTetra.hxx +++ b/src/INTERP_KERNEL/SplitterTetra.hxx @@ -21,18 +21,18 @@ #define __SPLITTERTETRA_HXX__ #include "INTERPKERNELDefines.hxx" +#include "InterpKernelHashFun.hxx" #include "TransformedTriangle.hxx" #include "TetraAffineTransform.hxx" -#include "InterpolationOptions.hxx" -#include "InterpKernelException.hxx" #include "InterpKernelHashMap.hxx" #include "VectorUtils.hxx" #include "MCIdType.hxx" +#include "NormalizedGeometricTypes" #include +#include #include #include -#include #include namespace INTERP_KERNEL @@ -362,7 +362,7 @@ namespace INTERP_KERNEL class SplitterTetra { public: - typedef typename MyMeshType::MyConnType ConnType; + using ConnType = typename MyMeshType::MyConnType; SplitterTetra(const MyMeshType& srcMesh, const double** tetraCorners, const typename MyMeshType::MyConnType *nodesId); @@ -370,7 +370,7 @@ namespace INTERP_KERNEL ~SplitterTetra(); - double intersectSourceCell(typename MyMeshType::MyConnType srcCell, double* baryCentre=0); + double intersectSourceCell(typename MyMeshType::MyConnType srcCell, double* baryCentre=nullptr); double intersectSourceFace(const NormalizedCellType polyType, const ConnType polyNodesNbr, const ConnType *const polyNodes, @@ -483,7 +483,7 @@ namespace INTERP_KERNEL inline void SplitterTetra::calculateNode(typename MyMeshType::MyConnType globalNodeNum) { const double* node = _src_mesh.getCoordinatesPtr()+MyMeshType::MY_SPACEDIM*globalNodeNum; - double* transformedNode = new double[MyMeshType::MY_SPACEDIM]; + auto* transformedNode = new double[MyMeshType::MY_SPACEDIM]; assert(transformedNode != 0); _t->apply(transformedNode, node); _nodes[globalNodeNum] = transformedNode; @@ -503,7 +503,7 @@ namespace INTERP_KERNEL template inline void SplitterTetra::calculateNode2(typename MyMeshType::MyConnType globalNodeNum, const double* node) { - double* transformedNode = new double[MyMeshType::MY_SPACEDIM]; + auto* transformedNode = new double[MyMeshType::MY_SPACEDIM]; assert(transformedNode != 0); _t->apply(transformedNode, node); _nodes[globalNodeNum] = transformedNode; diff --git a/src/INTERP_KERNEL/SplitterTetra.txx b/src/INTERP_KERNEL/SplitterTetra.txx index 9b631fd7b..ed9901e3e 100644 --- a/src/INTERP_KERNEL/SplitterTetra.txx +++ b/src/INTERP_KERNEL/SplitterTetra.txx @@ -19,6 +19,10 @@ #ifndef __SPLITTERTETRA_TXX__ #define __SPLITTERTETRA_TXX__ +#include "InterpKernelHashMap.hxx" +#include "NormalizedUnstructuredMesh.hxx" +#include "NormalizedGeometricTypes" +#include "InterpolationUtils.hxx" #include "SplitterTetra.hxx" #include "TetraAffineTransform.hxx" @@ -32,8 +36,10 @@ #include #include -#include -#include +#include +#include +#include +#include #include namespace INTERP_KERNEL @@ -74,7 +80,7 @@ namespace INTERP_KERNEL */ template SplitterTetra::SplitterTetra(const MyMeshType& srcMesh, const double** tetraCorners, const typename MyMeshType::MyConnType *nodesId) - : _t(0), _src_mesh(srcMesh) + : _t(nullptr), _src_mesh(srcMesh) { std::copy(nodesId,nodesId+4,_conn); _coords[0]=tetraCorners[0][0]; _coords[1]=tetraCorners[0][1]; _coords[2]=tetraCorners[0][2]; @@ -99,7 +105,7 @@ namespace INTERP_KERNEL * \param [in] tetraCorners array 4*3 doubles containing corners of input tetrahedron (P0X,P0Y,P0Y,P1X,P1Y,P1Z,P2X,P2Y,P2Z,P3X,P3Y,P3Z). */ template - SplitterTetra::SplitterTetra(const MyMeshType& srcMesh, const double tetraCorners[12], const ConnType *conn): _t(0),_src_mesh(srcMesh) + SplitterTetra::SplitterTetra(const MyMeshType& srcMesh, const double tetraCorners[12], const ConnType *conn): _t(nullptr),_src_mesh(srcMesh) { if(!conn) { _conn[0]=0; _conn[1]=1; _conn[2]=2; _conn[3]=3; } @@ -143,12 +149,12 @@ namespace INTERP_KERNEL void SplitterTetra::splitMySelfForDual(double* output, int i, typename MyMeshType::MyConnType& nodeId) { double *tmp[4]; - int offset=i/6; + int const offset=i/6; nodeId=_conn[offset]; tmp[0]=_coords+3*offset; tmp[1]=_coords+((offset+1)%4)*3; tmp[2]=_coords+((offset+2)%4)*3; tmp[3]=_coords+((offset+3)%4)*3; - int caseToTreat=i%6; - int case1=caseToTreat/2; - int case2=caseToTreat%2; + int const caseToTreat=i%6; + int const case1=caseToTreat/2; + int const case2=caseToTreat%2; const int tab[3][2]={{1,2},{3,2},{1,3}}; const int *curTab=tab[case1]; double pt0[3]; pt0[0]=(tmp[curTab[case2]][0]+tmp[0][0])/2.; pt0[1]=(tmp[curTab[case2]][1]+tmp[0][1])/2.; pt0[2]=(tmp[curTab[case2]][2]+tmp[0][2])/2.; @@ -197,7 +203,7 @@ namespace INTERP_KERNEL bool isTargetOutside = false; // calculate the coordinates of the nodes - ConnType *cellNodes=new ConnType[nbOfNodes4Type]; + auto *cellNodes=new ConnType[nbOfNodes4Type]; for(ConnType i = 0;i global numbers too, but not sure it is worth it @@ -215,8 +221,8 @@ namespace INTERP_KERNEL // halfspace filtering check // NB : might not be beneficial for caching of triangles - for(int i = 0; i < 8; ++i) - if(isOutside[i]) + for(bool const i : isOutside) + if(i) isTargetOutside = true; double totalVolume = 0.0; @@ -498,7 +504,7 @@ namespace INTERP_KERNEL // Map 2D intersections back to the 3D triangle space. if (maxNormal == 0) { - double invNX = ((double) 1.) / planeNormal[0]; + double const invNX = ((double) 1.) / planeNormal[0]; for (i = 0; i < nb_inter; i++) { inter3[3 * i + 1] = inter2[2 * i]; @@ -508,7 +514,7 @@ namespace INTERP_KERNEL } else if (maxNormal == 1) { - double invNY = ((double) 1.) / planeNormal[1]; + double const invNY = ((double) 1.) / planeNormal[1]; for (i = 0; i < nb_inter; i++) { inter3[3 * i] = inter2[2 * i]; @@ -518,7 +524,7 @@ namespace INTERP_KERNEL } else { - double invNZ = ((double) 1.) / planeNormal[2]; + double const invNZ = ((double) 1.) / planeNormal[2]; for (i = 0; i < nb_inter; i++) { inter3[3 * i] = inter2[2 * i]; @@ -648,9 +654,8 @@ namespace INTERP_KERNEL { 0, 3, 1 }, { 1, 2, 3 } }; double planeNormal[3]; - for (int iTetraFace = 0; iTetraFace < 4; ++iTetraFace) + for (auto tetraFaceNodesConn : tetraFacesNodesConn) { - const int * const tetraFaceNodesConn = tetraFacesNodesConn[iTetraFace]; TriangleFaceKey key = TriangleFaceKey(_conn[tetraFaceNodesConn[0]], _conn[tetraFaceNodesConn[1]], _conn[tetraFaceNodesConn[2]]); @@ -663,20 +668,20 @@ namespace INTERP_KERNEL const double normOfTetraTriNormal = norm(planeNormal); if (epsilonEqual(normOfTetraTriNormal, 0.)) { - for (int i = 0; i < 3; ++i) + for (double & i : planeNormal) { - planeNormal[i] = 0.; + i = 0.; } } else { const double invNormOfTetraTriNormal = 1. / normOfTetraTriNormal; - for (int i = 0; i < 3; ++i) + for (double & i : planeNormal) { - planeNormal[i] *= invNormOfTetraTriNormal; + i *= invNormOfTetraTriNormal; } } - double planeConstant = dot(planeNormal, coordsTetraTriNode1); + double const planeConstant = dot(planeNormal, coordsTetraTriNode1); if (IsFacesCoplanar(planeNormal, planeConstant, polyCoords, precision)) { ConnType nbrPolyTri = polyNodesNbr - 2; // split polygon into nbrPolyTri triangles @@ -848,9 +853,9 @@ namespace INTERP_KERNEL // halfspace filtering check // NB : might not be beneficial for caching of triangles - for(int i = 0; i < 8; ++i) + for(bool const i : isOutside) { - if(isOutside[i]) + if(i) { isTargetOutside = true; } @@ -868,7 +873,7 @@ namespace INTERP_KERNEL cellModelCell.fillSonCellNodalConnectivity(ii,cellNodes,faceNodes); TransformedTriangle tri(nodes[faceNodes[0]], nodes[faceNodes[1]], nodes[faceNodes[2]]); - double vol = tri.calculateIntersectionVolume(); + double const vol = tri.calculateIntersectionVolume(); LOG(1, "ii = " << ii << " Volume=" << vol) totalVolume += vol; } @@ -907,8 +912,8 @@ namespace INTERP_KERNEL // free potential sub-mesh nodes that have been allocated if(_nodes.size()>=/*8*/_node_ids.size()) { - typename MyMeshTypeT::MyConnType nbOfNodesT = static_cast(_node_ids.size()); - std::vector::iterator iter = _nodes.begin() + /*8*/nbOfNodesT; + auto nbOfNodesT = static_cast(_node_ids.size()); + auto iter = _nodes.begin() + /*8*/nbOfNodesT; while(iter != _nodes.end()) { delete[] *iter; @@ -983,7 +988,7 @@ namespace INTERP_KERNEL nodes[node]=getCoordsOfNode2(node, OTT::indFC(targetCell),_target_mesh,conn[node]); } std::copy(conn,conn+4,_node_ids.begin()); - SplitterTetra* t = new SplitterTetra(_src_mesh, nodes,conn); + auto* t = new SplitterTetra(_src_mesh, nodes,conn); tetra.push_back(t); return ; } @@ -1066,7 +1071,7 @@ namespace INTERP_KERNEL nodes[j] = getCoordsOfSubNode2(conn[j],realConn); conn[j] = realConn; } - SplitterTetra* t = new SplitterTetra(_src_mesh, nodes,conn); + auto* t = new SplitterTetra(_src_mesh, nodes,conn); tetra.push_back(t); } } @@ -1101,7 +1106,7 @@ namespace INTERP_KERNEL conn[j] = subZone[SPLIT_NODES_6[4*i+j]]; func(*this,conn[j],nodes[j]); } - SplitterTetra* t = new SplitterTetra(_src_mesh, nodes,conn); + auto* t = new SplitterTetra(_src_mesh, nodes,conn); tetra.push_back(t); } } @@ -1162,7 +1167,7 @@ namespace INTERP_KERNEL conn[2] = TETRA_EDGES_GENERAL_24[2*row]; conn[3] = TETRA_EDGES_GENERAL_24[2*row + 1]; func(*this,conn,nodes); - SplitterTetra* t = new SplitterTetra(_src_mesh, nodes, conn); + auto* t = new SplitterTetra(_src_mesh, nodes, conn); tetra.push_back(t); } } @@ -1206,11 +1211,11 @@ namespace INTERP_KERNEL // create tetrahedra const double* nodes[4]; typename MyMeshTypeS::MyConnType conn[4]; - for(int i = 0; i < 2; ++i) + for(auto i : SPLIT_PYPA5) { for(int j = 0; j < 4; ++j) - nodes[j] = getCoordsOfSubNode2(SPLIT_PYPA5[i][j],conn[j]); - SplitterTetra* t = new SplitterTetra(_src_mesh, nodes,conn); + nodes[j] = getCoordsOfSubNode2(i[j],conn[j]); + auto* t = new SplitterTetra(_src_mesh, nodes,conn); tetra.push_back(t); } } @@ -1260,7 +1265,7 @@ namespace INTERP_KERNEL if ( normCellType != NORM_POLYHED ) cellModelCell.fillSonCellNodalConnectivity(ii,&allNodeIndices[0],faceNodes); - int nbTetra = nbFaceNodes - 2; // split polygon into nbTetra triangles + int const nbTetra = nbFaceNodes - 2; // split polygon into nbTetra triangles // create tetrahedra for(int i = 0; i < nbTetra; ++i) @@ -1268,7 +1273,7 @@ namespace INTERP_KERNEL nodes[0] = getCoordsOfSubNode2( faceNodes[0], conn[0]); nodes[1] = getCoordsOfSubNode2( faceNodes[1+i],conn[1]); nodes[2] = getCoordsOfSubNode2( faceNodes[2+i],conn[2]); - SplitterTetra* t = new SplitterTetra(_src_mesh, nodes,conn); + auto* t = new SplitterTetra(_src_mesh, nodes,conn); tetra.push_back(t); } @@ -1292,7 +1297,7 @@ namespace INTERP_KERNEL { // retrieve real mesh nodes - typename MyMeshTypeT::MyConnType nbOfNodesT = static_cast(_node_ids.size());// Issue 0020634. _node_ids.resize(8); + auto nbOfNodesT = static_cast(_node_ids.size());// Issue 0020634. _node_ids.resize(8); for(int node = 0; node < nbOfNodesT ; ++node) { // calculate only normal nodes @@ -1310,7 +1315,7 @@ namespace INTERP_KERNEL { for(int i = 0; i < 7; ++i) { - double* barycenter = new double[3]; + auto* barycenter = new double[3]; calcBarycenter(4, barycenter, &GENERAL_24_SUB_NODES[4*i]); _nodes.push_back(barycenter); } @@ -1321,7 +1326,7 @@ namespace INTERP_KERNEL { for(int i = 0; i < 19; ++i) { - double* barycenter = new double[3]; + auto* barycenter = new double[3]; calcBarycenter(2, barycenter, &GENERAL_48_SUB_NODES[2*i]); _nodes.push_back(barycenter); } @@ -1341,7 +1346,7 @@ namespace INTERP_KERNEL // add barycenter of a cell std::vector allIndices(nbOfNodesT); for ( int i = 0; i < nbOfNodesT; ++i ) allIndices[i] = i; - double* barycenter = new double[3]; + auto* barycenter = new double[3]; calcBarycenter(nbOfNodesT, barycenter, &allIndices[0]); _nodes.push_back(barycenter); } diff --git a/src/INTERP_KERNEL/TargetIntersector.hxx b/src/INTERP_KERNEL/TargetIntersector.hxx index 49cf7f148..e2ccc2487 100644 --- a/src/INTERP_KERNEL/TargetIntersector.hxx +++ b/src/INTERP_KERNEL/TargetIntersector.hxx @@ -21,8 +21,8 @@ #ifndef __TARGETINTERSECTOR__HXX__ #define __TARGETINTERSECTOR__HXX__ -#include "INTERPKERNELDefines.hxx" +#include #include namespace INTERP_KERNEL @@ -37,7 +37,7 @@ namespace INTERP_KERNEL { public: static const int SPACEDIM=MyMeshType::MY_SPACEDIM; - typedef typename MyMeshType::MyConnType ConnType; + using ConnType = typename MyMeshType::MyConnType; public: /*! * Tool for cell intersection, result is always positive. @@ -50,7 +50,7 @@ namespace INTERP_KERNEL virtual ConnType getNumberOfRowsOfResMatrix() const = 0; virtual ConnType getNumberOfColsOfResMatrix() const = 0; - virtual ~TargetIntersector() { } + virtual ~TargetIntersector() = default; void adjustBoundingBoxes(std::vector& bbox, double adjustmentEps, double adjustmentEpsAbs); void adjustBoundingBoxes(double *bbox, std::size_t sz, double adjustmentEps, double adjustmentEpsAbs); }; diff --git a/src/INTERP_KERNEL/TargetIntersector.txx b/src/INTERP_KERNEL/TargetIntersector.txx index f9d55cdee..a9484c726 100644 --- a/src/INTERP_KERNEL/TargetIntersector.txx +++ b/src/INTERP_KERNEL/TargetIntersector.txx @@ -22,7 +22,9 @@ #define __TARGETINTERSECTOR__TXX__ #include "TargetIntersector.hxx" +#include #include +#include namespace INTERP_KERNEL { diff --git a/src/INTERP_KERNEL/TetraAffineTransform.cxx b/src/INTERP_KERNEL/TetraAffineTransform.cxx index 0d64ca9fc..9f28bf8c9 100644 --- a/src/INTERP_KERNEL/TetraAffineTransform.cxx +++ b/src/INTERP_KERNEL/TetraAffineTransform.cxx @@ -337,7 +337,7 @@ namespace INTERP_KERNEL } // swap rows in index vector - int tmp = idx[k]; + int const tmp = idx[k]; idx[k] = idx[row]; idx[row] = tmp; diff --git a/src/INTERP_KERNEL/TransformedTriangle.cxx b/src/INTERP_KERNEL/TransformedTriangle.cxx index ac83c338f..599028b8a 100644 --- a/src/INTERP_KERNEL/TransformedTriangle.cxx +++ b/src/INTERP_KERNEL/TransformedTriangle.cxx @@ -18,14 +18,14 @@ // #include "TransformedTriangle.hxx" +#include "Log.hxx" #include "VectorUtils.hxx" #include "TetraAffineTransform.hxx" +#include +#include #include -#include #include #include -#include -#include #include #include @@ -188,7 +188,7 @@ namespace INTERP_KERNEL // }; // double sign = uv_xy[0] * uv_xy[3] - uv_xy[1] * uv_xy[2]; - int sign = isTriangleInclinedToFacet( OXY ); + int const sign = isTriangleInclinedToFacet( OXY ); if(sign == 0 ) { @@ -314,13 +314,13 @@ namespace INTERP_KERNEL { if(testSurfaceEdgeIntersection(edge)) { - double* ptA = new double[3]; + auto* ptA = new double[3]; calcIntersectionPtSurfaceEdge(edge, ptA); _polygonA.push_back(ptA); LOG(3,"Surface-edge (edge " << strTE(edge) << "): " << vToStr(ptA) << " added to A "); if(edge >= XY) { - double* ptB = new double[3]; + auto* ptB = new double[3]; copyVector3(ptA, ptB); _polygonB.push_back(ptB); LOG(3,"Surface-edge (edge " << strTE(edge) << "): " << vToStr(ptB) << " added to B "); @@ -334,7 +334,7 @@ namespace INTERP_KERNEL { if(testSurfaceRayIntersection(corner)) { - double* ptB = new double[3]; + auto* ptB = new double[3]; copyVector3(&COORDS_TET_CORNER[3 * corner], ptB); _polygonB.push_back(ptB); LOG(3,"Surface-ray (corner " << strTC(corner) << "): " << vToStr(ptB) << " added to B"); @@ -362,13 +362,13 @@ namespace INTERP_KERNEL if(doTest && testSegmentFacetIntersection(seg, facet)) { - double* ptA = new double[3]; + auto* ptA = new double[3]; calcIntersectionPtSegmentFacet(seg, facet, ptA); _polygonA.push_back(ptA); LOG(3,"Segment-facet (facet " << strTF(facet) << ", seg " << strTriS(seg) << "): " << vToStr(ptA) << " added to A"); if(facet == XYZ) { - double* ptB = new double[3]; + auto* ptB = new double[3]; copyVector3(ptA, ptB); _polygonB.push_back(ptB); LOG(3,"Segment-facet (facet " << strTF(facet) << ", seg " << strTriS(seg) << "): " << vToStr(ptB) << " added to B"); @@ -380,17 +380,17 @@ namespace INTERP_KERNEL // segment - edge for(TetraEdge edge = OX ; edge <= ZX ; edge = TetraEdge(edge + 1)) { - const DoubleProduct edge_dp = DoubleProduct(edge); + const auto edge_dp = DoubleProduct(edge); if(isZero[edge_dp] && testSegmentEdgeIntersection(seg, edge)) { - double* ptA = new double[3]; + auto* ptA = new double[3]; calcIntersectionPtSegmentEdge(seg, edge, ptA); _polygonA.push_back(ptA); LOG(3,"Segment-edge (edge " << strTE(edge) << ", seg " << strTriS(seg) << "): " << vToStr(ptA) << " added to A"); if(edge >= XY) { - double* ptB = new double[3]; + auto* ptB = new double[3]; copyVector3(ptA, ptB); _polygonB.push_back(ptB); LOG(3,"Segment-edge (edge " << strTE(edge) << ", seg " << strTriS(seg) << "): " << vToStr(ptA) << " added to B"); @@ -408,13 +408,13 @@ namespace INTERP_KERNEL if(doTest && testSegmentCornerIntersection(seg, corner)) { - double* ptA = new double[3]; + auto* ptA = new double[3]; copyVector3(&COORDS_TET_CORNER[3 * corner], ptA); _polygonA.push_back(ptA); LOG(3,"Segment-corner (corner " << strTC(corner) << ", seg " << strTriS(seg) << "): " << vToStr(ptA) << " added to A"); if(corner != O) { - double* ptB = new double[3]; + auto* ptB = new double[3]; _polygonB.push_back(ptB); copyVector3(&COORDS_TET_CORNER[3 * corner], ptB); LOG(3,"Segment-corner (corner " << strTC(corner) << ", seg " << strTriS(seg) << "): " << vToStr(ptB) << " added to B"); @@ -427,7 +427,7 @@ namespace INTERP_KERNEL { if(isZero[DP_SEGMENT_RAY_INTERSECTION[7*(corner-1)]] && testSegmentRayIntersection(seg, corner)) { - double* ptB = new double[3]; + auto* ptB = new double[3]; copyVector3(&COORDS_TET_CORNER[3 * corner], ptB); _polygonB.push_back(ptB); LOG(3,"Segment-ray (corner " << strTC(corner) << ", seg " << strTriS(seg) << "): " << vToStr(ptB) << " added to B"); @@ -449,7 +449,7 @@ namespace INTERP_KERNEL #endif if(testSegmentHalfstripIntersection(seg, edge)) { - double* ptB = new double[3]; + auto* ptB = new double[3]; calcIntersectionPtSegmentHalfstrip(seg, edge, ptB); _polygonB.push_back(ptB); LOG(3,"Segment-halfstrip : " << vToStr(ptB) << " added to B"); @@ -464,7 +464,7 @@ namespace INTERP_KERNEL // tetrahedron if(testCornerInTetrahedron(corner)) { - double* ptA = new double[3]; + auto* ptA = new double[3]; copyVector3(&_coords[5*corner], ptA); _polygonA.push_back(ptA); LOG(3,"Inclusion tetrahedron (corner " << strTriC(corner) << "): " << vToStr(ptA) << " added to A"); @@ -473,7 +473,7 @@ namespace INTERP_KERNEL // XYZ - plane if(testCornerOnXYZFacet(corner)) { - double* ptB = new double[3]; + auto* ptB = new double[3]; copyVector3(&_coords[5*corner], ptB); _polygonB.push_back(ptB); LOG(3,"Inclusion XYZ-plane (corner " << strTriC(corner) << "): " << vToStr(ptB) << " added to B"); @@ -482,7 +482,7 @@ namespace INTERP_KERNEL // projection on XYZ - facet if(testCornerAboveXYZFacet(corner)) { - double* ptB = new double[3]; + auto* ptB = new double[3]; copyVector3(&_coords[5*corner], ptB); ptB[2] = 1 - ptB[0] - ptB[1]; // lower z to project on XYZ assert(epsilonEqual(ptB[0]+ptB[1]+ptB[2] - 1, 0.0)); @@ -513,7 +513,7 @@ namespace INTERP_KERNEL { if(testSurfaceEdgeIntersection(edge)) { - double* ptA = new double[3]; + auto* ptA = new double[3]; calcIntersectionPtSurfaceEdge(edge, ptA); _polygonA.push_back(ptA); LOG(3,"Surface-edge : " << vToStr(ptA) << " added to A "); @@ -542,7 +542,7 @@ namespace INTERP_KERNEL if(doTest && testSegmentFacetIntersection(seg, facet)) { - double* ptA = new double[3]; + auto* ptA = new double[3]; calcIntersectionPtSegmentFacet(seg, facet, ptA); _polygonA.push_back(ptA); LOG(3,"Segment-facet : " << vToStr(ptA) << " added to A"); @@ -552,11 +552,11 @@ namespace INTERP_KERNEL // segment - edge for(TetraEdge edge = OX ; edge <= ZX ; edge = TetraEdge(edge + 1)) { - const DoubleProduct edge_dp = DoubleProduct(edge); + const auto edge_dp = DoubleProduct(edge); if(isZero[edge_dp] && testSegmentEdgeIntersection(seg, edge)) { - double* ptA = new double[3]; + auto* ptA = new double[3]; calcIntersectionPtSegmentEdge(seg, edge, ptA); _polygonA.push_back(ptA); LOG(3,"Segment-edge : " << vToStr(ptA) << " added to A"); @@ -573,7 +573,7 @@ namespace INTERP_KERNEL if(doTest && testSegmentCornerIntersection(seg, corner)) { - double* ptA = new double[3]; + auto* ptA = new double[3]; copyVector3(&COORDS_TET_CORNER[3 * corner], ptA); _polygonA.push_back(ptA); LOG(3,"Segment-corner : " << vToStr(ptA) << " added to A"); @@ -589,7 +589,7 @@ namespace INTERP_KERNEL // tetrahedron if(testCornerInTetrahedron(corner)) { - double* ptA = new double[3]; + auto* ptA = new double[3]; copyVector3(&_coords[5*corner], ptA); _polygonA.push_back(ptA); LOG(3,"Inclusion tetrahedron : " << vToStr(ptA) << " added to A"); @@ -699,7 +699,7 @@ namespace INTERP_KERNEL } // create order object - SortOrder order(barycenter, type); + SortOrder const order(barycenter, type); // sort vector with this object // NB : do not change place of first object, with respect to which the order diff --git a/src/INTERP_KERNEL/TransformedTriangle.hxx b/src/INTERP_KERNEL/TransformedTriangle.hxx index 14d396597..17edca9b7 100644 --- a/src/INTERP_KERNEL/TransformedTriangle.hxx +++ b/src/INTERP_KERNEL/TransformedTriangle.hxx @@ -24,6 +24,9 @@ #include "VectorUtils.hxx" #include "assert.h" +#include +#include +#include #include // Levels : @@ -436,9 +439,9 @@ namespace INTERP_KERNEL _coords[5*corner + 3] // z }; - for(int i = 0 ; i < 4 ; ++i) + for(double const i : pt) { - if(pt[i] < 0.0 || pt[i] > 1.0) + if(i < 0.0 || i > 1.0) { return false; } diff --git a/src/INTERP_KERNEL/TransformedTriangleIntersect.cxx b/src/INTERP_KERNEL/TransformedTriangleIntersect.cxx index 36727ef26..c7805b819 100644 --- a/src/INTERP_KERNEL/TransformedTriangleIntersect.cxx +++ b/src/INTERP_KERNEL/TransformedTriangleIntersect.cxx @@ -17,12 +17,10 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +#include "Log.hxx" #include "TransformedTriangle.hxx" -#include -#include #include #include -#include "VectorUtils.hxx" namespace INTERP_KERNEL { diff --git a/src/INTERP_KERNEL/TransformedTriangleMath.cxx b/src/INTERP_KERNEL/TransformedTriangleMath.cxx index 7b3eba4e8..3e8ff13b3 100644 --- a/src/INTERP_KERNEL/TransformedTriangleMath.cxx +++ b/src/INTERP_KERNEL/TransformedTriangleMath.cxx @@ -17,13 +17,14 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +#include "Log.hxx" #include "TransformedTriangle.hxx" -#include -#include +#include #include #include #include #include +#include #include #include "VectorUtils.hxx" @@ -247,8 +248,8 @@ namespace INTERP_KERNEL double TransformedTriangle::calculateDistanceCornerSegment(const TetraCorner corner, const TriSegment seg) const { // NB uses fact that TriSegment <=> TriCorner that is first point of segment (PQ <=> P) - const TriCorner ptP_idx = TriCorner(seg); - const TriCorner ptQ_idx = TriCorner( (seg + 1) % 3); + const auto ptP_idx = TriCorner(seg); + const auto ptQ_idx = TriCorner( (seg + 1) % 3); const double ptP[3] = { _coords[5*ptP_idx], _coords[5*ptP_idx + 1], _coords[5*ptP_idx + 2] }; const double ptQ[3] = { _coords[5*ptQ_idx], _coords[5*ptQ_idx + 1], _coords[5*ptQ_idx + 2] }; @@ -304,7 +305,7 @@ namespace INTERP_KERNEL const DoubleProduct dp = DP_FOR_DETERMINANT_EXPANSION[3*corner + (row - 1)]; // get edge by using correspondence between Double Product and Edge - TetraEdge edge = TetraEdge(dp); + auto const edge = TetraEdge(dp); // use edge only if it is surrounded by the surface if( _triangleSurroundsEdgeCache[edge] ) diff --git a/src/INTERP_KERNEL/TranslationRotationMatrix.hxx b/src/INTERP_KERNEL/TranslationRotationMatrix.hxx index 648059251..a307de0ba 100644 --- a/src/INTERP_KERNEL/TranslationRotationMatrix.hxx +++ b/src/INTERP_KERNEL/TranslationRotationMatrix.hxx @@ -85,12 +85,12 @@ namespace INTERP_KERNEL void rotate_x (double* P) { _rotation_coeffs[0]=1.0; - double r_sqr = P[1]*P[1]+P[2]*P[2]; + double const r_sqr = P[1]*P[1]+P[2]*P[2]; if (r_sqr < EPS) {_rotation_coeffs[4]=1.0; _rotation_coeffs[8]=1.0; return;} - double r = sqrt(r_sqr); - double cos =P[1]/r; - double sin =P[2]/r; + double const r = sqrt(r_sqr); + double const cos =P[1]/r; + double const sin =P[2]/r; _rotation_coeffs[4]=cos; _rotation_coeffs[5]=sin; @@ -104,12 +104,12 @@ namespace INTERP_KERNEL void rotate_z (double* P) { _rotation_coeffs[8]=1.0; - double r_sqr = P[0]*P[0]+P[1]*P[1]; + double const r_sqr = P[0]*P[0]+P[1]*P[1]; if (r_sqr < EPS) {_rotation_coeffs[4]=1.0; _rotation_coeffs[0]=1.0; return;} - double r = sqrt(r_sqr); - double cos =P[0]/r; - double sin =P[1]/r; + double const r = sqrt(r_sqr); + double const cos =P[0]/r; + double const sin =P[1]/r; _rotation_coeffs[0]=cos; _rotation_coeffs[1]=sin; diff --git a/src/INTERP_KERNEL/TriangulationIntersector.hxx b/src/INTERP_KERNEL/TriangulationIntersector.hxx index 3b84a72a4..6afe43ffa 100644 --- a/src/INTERP_KERNEL/TriangulationIntersector.hxx +++ b/src/INTERP_KERNEL/TriangulationIntersector.hxx @@ -21,11 +21,8 @@ #ifndef __TRIANGULATIONINTERSECTOR_HXX__ #define __TRIANGULATIONINTERSECTOR_HXX__ -#include "PlanarIntersectorP0P0.hxx" -#include "PlanarIntersectorP0P1.hxx" -#include "PlanarIntersectorP1P0.hxx" -#include "PlanarIntersectorP1P1.hxx" -#include "PlanarIntersectorP1P0Bary.hxx" +#include "NormalizedUnstructuredMesh.hxx" +#include namespace INTERP_KERNEL { @@ -35,7 +32,7 @@ namespace INTERP_KERNEL public: static const int SPACEDIM=MyMeshType::MY_SPACEDIM; static const int MESHDIM=MyMeshType::MY_MESHDIM; - typedef typename MyMeshType::MyConnType ConnType; + using ConnType = typename MyMeshType::MyConnType; static const NumberingPolicy numPol=MyMeshType::My_numPol; public: TriangulationIntersector(const MyMeshType& meshT, const MyMeshType& meshS, diff --git a/src/INTERP_KERNEL/TriangulationIntersector.txx b/src/INTERP_KERNEL/TriangulationIntersector.txx index 985c20109..a15de1a0b 100644 --- a/src/INTERP_KERNEL/TriangulationIntersector.txx +++ b/src/INTERP_KERNEL/TriangulationIntersector.txx @@ -20,16 +20,15 @@ #ifndef __TRIANGULATIONINTERSECTOR_TXX__ #define __TRIANGULATIONINTERSECTOR_TXX__ +#include "InterpKernelUtilities.hxx" #include "TriangulationIntersector.hxx" -#include "PlanarIntersectorP0P0.txx" -#include "PlanarIntersectorP0P1.txx" -#include "PlanarIntersectorP1P0.txx" -#include "PlanarIntersectorP1P0Bary.txx" - -#include "InterpolationUtils.hxx" #include "PlanarIntersector.hxx" +#include "InterpolationUtils.hxx" #include +#include + + #define TRI_INTERSECTOR TriangulationIntersector #define TRI_INTER_TEMPLATE template +#include +#include +#include #define NB_TETRA_SIDES 4 #define NB_TETRA_NODES 4 @@ -103,7 +108,7 @@ namespace INTERP_KERNEL } // check if polygon orientation is same as the one of triangle - std::vector::const_iterator p = pPolygonA->begin(), pEnd = pPolygonA->end(); + auto p = pPolygonA->begin(), pEnd = pPolygonA->end(); #ifdef DMP_UNITTETRAINTERSECTIONBARY std::cout.precision(18); std::cout << "**** int polygon() " << std::endl; @@ -227,7 +232,7 @@ namespace INTERP_KERNEL baryCenter[0] = baryCenter[1] = baryCenter[2] = 0.; - std::list< std::vector< double* > >::iterator f = _faces.begin(), fEnd = _faces.end(); + auto f = _faces.begin(), fEnd = _faces.end(); double * PP = f->at(0); for ( ++f; f != fEnd; ++f ) @@ -237,7 +242,7 @@ namespace INTERP_KERNEL continue; bool pBelongsToPoly = false; - std::vector::iterator v = polygon.begin(), vEnd = polygon.end(); + auto v = polygon.begin(), vEnd = polygon.end(); for ( ; !pBelongsToPoly && v != vEnd; ++v ) pBelongsToPoly = samePoint( PP, *v ); if ( pBelongsToPoly ) @@ -310,14 +315,13 @@ namespace INTERP_KERNEL bool sideAdded[NB_TETRA_SIDES] = { false, false, false, false }; int nbAddedSides = 0; - std::list< std::vector< double* > >::iterator f = _faces.begin(), fEnd = _faces.end(); + auto f = _faces.begin(), fEnd = _faces.end(); for ( ; f != fEnd; ++f ) { - std::vector< double* >& polygon = *f; + std::vector< double* > const& polygon = *f; double coordSum[3] = {0,0,0}; - for ( int i = 0; i < (int)polygon.size(); ++i ) + for (auto p : polygon) { - double* p = polygon[i]; coordSum[0] += p[0]; coordSum[1] += p[1]; coordSum[2] += p[2]; @@ -338,12 +342,12 @@ namespace INTERP_KERNEL // Add segments of already added polygons to future polygonal faces on sides of tetra // --------------------------------------------------------------------------------- - std::size_t nbIntersectPolygs = _faces.size(); + std::size_t const nbIntersectPolygs = _faces.size(); std::vector< double* > * sideFaces[ 4 ]; // future polygons on sides of tetra for ( int i = 0; i < NB_TETRA_SIDES; ++i ) { - sideFaces[ i ]=0; + sideFaces[ i ]=nullptr; if ( !sideAdded[ i ] ) { _faces.push_back( std::vector< double* > () ); @@ -436,7 +440,7 @@ namespace INTERP_KERNEL if ( ic ) corner2Poly[ ic-1 ] -= 1.0; // _polyNormals are outside of a tetrahedron - double dot = dotprod<3>( corner2Poly, &_polyNormals[iF][0] ); + double const dot = dotprod<3>( corner2Poly, &_polyNormals[iF][0] ); if ( dot < -DEFAULT_ABS_TOL*DEFAULT_ABS_TOL ) { #ifdef DMP_UNITTETRAINTERSECTIONBARY @@ -454,7 +458,7 @@ namespace INTERP_KERNEL if ( !sideFaces[i] ) continue; std::vector< double* >& sideFace = *sideFaces[i]; - std::size_t nbPoints = sideFace.size(); + std::size_t const nbPoints = sideFace.size(); if ( nbPoints == 0 ) continue; // not intersected face at all - no cut off corners can be detected @@ -464,10 +468,10 @@ namespace INTERP_KERNEL bool isSegmentOnEdge=false; for ( std::size_t ip = 0; ip < nbPoints; ++ip ) { - std::size_t isSegmentEnd = ( ip % 2 ); + std::size_t const isSegmentEnd = ( ip % 2 ); double* p = sideFace[ ip ]; - double* p2 = isSegmentEnd ? 0 : sideFace[ip+1]; + double* p2 = isSegmentEnd ? nullptr : sideFace[ip+1]; if ( !isSegmentEnd ) isSegmentOnEdge = false; // initialize @@ -582,7 +586,7 @@ namespace INTERP_KERNEL if ( !sideFaces[ i ] ) continue; std::vector< double* >& sideFace = *sideFaces[i]; - int excludeCorner = (i + 1) % NB_TETRA_NODES; + int const excludeCorner = (i + 1) % NB_TETRA_NODES; for ( int ic = 0; ic < NB_TETRA_NODES; ++ic ) { if ( !cutOffCorners[ ic ] && ic != excludeCorner ) @@ -643,7 +647,7 @@ namespace INTERP_KERNEL sortIntersectionPolygon( A, _barycenterA ); } // exclude equal points - std::vector< double* >::iterator v = _polygonA.begin(), vEnd = _polygonA.end(); + auto v = _polygonA.begin(), vEnd = _polygonA.end(); face.push_back( *v ); *v = 0; for ( ++v; v != vEnd; ++v ) @@ -712,14 +716,14 @@ namespace INTERP_KERNEL void UnitTetraIntersectionBary::clearPolygons(bool andFaces) { - for(std::vector::iterator it = _polygonA.begin() ; it != _polygonA.end() ; ++it) - { delete[] *it; - *it = 0; + for(auto & it : _polygonA) + { delete[] it; + it = nullptr; } - for(std::vector::iterator it = _polygonB.begin() ; it != _polygonB.end() ; ++it) + for(auto & it : _polygonB) { - delete[] *it; - *it = 0; + delete[] it; + it = nullptr; } _polygonA.clear(); @@ -727,14 +731,14 @@ namespace INTERP_KERNEL if ( andFaces ) { - std::list< std::vector< double* > >::iterator f = this->_faces.begin(), fEnd = this->_faces.end(); + auto f = this->_faces.begin(), fEnd = this->_faces.end(); for ( ; f != fEnd; ++f ) { std::vector< double* >& polygon = *f; - for(std::vector::iterator it = polygon.begin() ; it != polygon.end() ; ++it) + for(auto & it : polygon) { - delete[] *it; - *it = 0; + delete[] it; + it = nullptr; } } this->_faces.clear(); diff --git a/src/INTERP_KERNEL/VTKNormalizedUnstructuredMesh.hxx b/src/INTERP_KERNEL/VTKNormalizedUnstructuredMesh.hxx index cf7e84ff8..1bf5b78f6 100644 --- a/src/INTERP_KERNEL/VTKNormalizedUnstructuredMesh.hxx +++ b/src/INTERP_KERNEL/VTKNormalizedUnstructuredMesh.hxx @@ -21,7 +21,6 @@ #ifndef __VTKNORMALIZEDUNSTRUCTUREDMESH_HXX__ #define __VTKNORMALIZEDUNSTRUCTUREDMESH_HXX__ -#include "NormalizedUnstructuredMesh.hxx" #include "vtkType.h" diff --git a/src/INTERP_KERNEL/VTKNormalizedUnstructuredMesh.txx b/src/INTERP_KERNEL/VTKNormalizedUnstructuredMesh.txx index 7e8fd1c16..571680a2b 100644 --- a/src/INTERP_KERNEL/VTKNormalizedUnstructuredMesh.txx +++ b/src/INTERP_KERNEL/VTKNormalizedUnstructuredMesh.txx @@ -20,7 +20,6 @@ #ifndef __VTKNORMALIZEDUNSTRUCTUREDMESH_TXX__ #define __VTKNORMALIZEDUNSTRUCTUREDMESH_TXX__ -#include "VTKNormalizedUnstructuredMesh.hxx" #include "vtkUnstructuredGrid.h" #include "vtkCellArray.h" diff --git a/src/INTERP_KERNEL/VectorUtils.hxx b/src/INTERP_KERNEL/VectorUtils.hxx index 4d626c334..446358ac7 100644 --- a/src/INTERP_KERNEL/VectorUtils.hxx +++ b/src/INTERP_KERNEL/VectorUtils.hxx @@ -21,12 +21,11 @@ #define __VECTORUTILS_HXX__ #include +#include #include #include -#include #include #include -#include namespace INTERP_KERNEL @@ -225,7 +224,7 @@ namespace INTERP_KERNEL */ inline double normInf(const double mat[9]) { - double ret(std::max(sumOfAbsoluteValues(mat),sumOfAbsoluteValues(mat+3))); + double const ret(std::max(sumOfAbsoluteValues(mat),sumOfAbsoluteValues(mat+3))); return std::max(ret,sumOfAbsoluteValues(mat+6)); } diff --git a/src/INTERP_KERNEL/VolSurfFormulae.hxx b/src/INTERP_KERNEL/VolSurfFormulae.hxx index 8d51d48f5..ad529a898 100644 --- a/src/INTERP_KERNEL/VolSurfFormulae.hxx +++ b/src/INTERP_KERNEL/VolSurfFormulae.hxx @@ -21,15 +21,18 @@ #ifndef __VOLSURFFORMULAE_HXX__ #define __VOLSURFFORMULAE_HXX__ +#include "InterpKernelGeo2DNode.hxx" #include "InterpolationUtils.hxx" #include "InterpKernelException.hxx" -#include "InterpKernelGeo2DEdgeLin.hxx" -#include "InterpKernelGeo2DEdgeArcCircle.hxx" #include "InterpKernelGeo2DQuadraticPolygon.hxx" #include "MCIdType.hxx" +#include "NormalizedUnstructuredMesh.hxx" +#include +#include #include #include +#include namespace INTERP_KERNEL { @@ -61,7 +64,7 @@ namespace INTERP_KERNEL if(spaceDim==2) { Edge *ed=Edge::BuildEdgeFrom3Points(begin,middle,end); - double ret=ed->getCurveLength(); ed->decrRef(); + double const ret=ed->getCurveLength(); ed->decrRef(); return ret; } else @@ -213,7 +216,7 @@ namespace INTERP_KERNEL calculateBarycenterDyn(coords,nbOfPtsInPolygs,spaceDim,coordOfBary); for ( mcIdType i=0; igetArea(); + double const ret=pol->getArea(); delete pol; return -ret; } @@ -298,19 +301,19 @@ namespace INTERP_KERNEL double f1 = (p1[0]-p3[0])/2.0, f2 = (p1[1]-p3[1])/2.0, f3 = (p1[2]-p3[2])/2.0; double h1 = (p4[0]-p6[0])/2.0, h2 = (p4[1]-p6[1])/2.0, h3 = (p4[2]-p6[2])/2.0; - double A = a1*c2*f3 - a1*c3*f2 - a2*c1*f3 + a2*c3*f1 + a3*c1*f2 - a3*c2*f1; - double B = b1*c2*h3 - b1*c3*h2 - b2*c1*h3 + b2*c3*h1 + b3*c1*h2 - b3*c2*h1; - double C = (a1*c2*h3 + b1*c2*f3) - (a1*c3*h2 + b1*c3*f2) + double const A = a1*c2*f3 - a1*c3*f2 - a2*c1*f3 + a2*c3*f1 + a3*c1*f2 - a3*c2*f1; + double const B = b1*c2*h3 - b1*c3*h2 - b2*c1*h3 + b2*c3*h1 + b3*c1*h2 - b3*c2*h1; + double const C = (a1*c2*h3 + b1*c2*f3) - (a1*c3*h2 + b1*c3*f2) - (a2*c1*h3 + b2*c1*f3) + (a2*c3*h1 + b2*c3*f1) + (a3*c1*h2 + b3*c1*f2) - (a3*c2*h1 + b3*c2*f1); - double D = a1*d2*f3 - a1*d3*f2 - a2*d1*f3 + a2*d3*f1 + a3*d1*f2 - a3*d2*f1; - double E = b1*d2*h3 - b1*d3*h2 - b2*d1*h3 + b2*d3*h1 + b3*d1*h2 - b3*d2*h1; - double F = (a1*d2*h3 + b1*d2*f3) - (a1*d3*h2 + b1*d3*f2) + double const D = a1*d2*f3 - a1*d3*f2 - a2*d1*f3 + a2*d3*f1 + a3*d1*f2 - a3*d2*f1; + double const E = b1*d2*h3 - b1*d3*h2 - b2*d1*h3 + b2*d3*h1 + b3*d1*h2 - b3*d2*h1; + double const F = (a1*d2*h3 + b1*d2*f3) - (a1*d3*h2 + b1*d3*f2) - (a2*d1*h3 + b2*d1*f3) + (a2*d3*h1 + b2*d3*f1) + (a3*d1*h2 + b3*d1*f2) - (a3*d2*h1 + b3*d2*f1); - double G = a1*e2*f3 - a1*e3*f2 - a2*e1*f3 + a2*e3*f1 + a3*e1*f2 - a3*e2*f1; - double H = b1*e2*h3 - b1*e3*h2 - b2*e1*h3 + b2*e3*h1 + b3*e1*h2 - b3*e2*h1; - double P = (a1*e2*h3 + b1*e2*f3) - (a1*e3*h2 + b1*e3*f2) + double const G = a1*e2*f3 - a1*e3*f2 - a2*e1*f3 + a2*e3*f1 + a3*e1*f2 - a3*e2*f1; + double const H = b1*e2*h3 - b1*e3*h2 - b2*e1*h3 + b2*e3*h1 + b3*e1*h2 - b3*e2*h1; + double const P = (a1*e2*h3 + b1*e2*f3) - (a1*e3*h2 + b1*e3*f2) - (a2*e1*h3 + b2*e1*f3) + (a2*e3*h1 + b2*e3*f1) + (a3*e1*h2 + b3*e1*f2) - (a3*e2*h1 + b3*e2*f1); @@ -338,87 +341,87 @@ namespace INTERP_KERNEL double s1=(pt2[0]-pt6[0])/8.0, s2=(pt2[1]-pt6[1])/8.0, s3=(pt2[2]-pt6[2])/8.0; double t1=(pt1[0]-pt5[0])/8.0, t2=(pt1[1]-pt5[1])/8.0, t3=(pt1[2]-pt5[2])/8.0; - double A = a1*e2*q3 - a1*e3*q2 - a2*e1*q3 + a2*e3*q1 + a3*e1*q2 - a3*e2*q1; - double B = c1*h2*q3 - c1*h3*q2 - c2*h1*q3 + c2*h3*q1 + c3*h1*q2 - c3*h2*q1; - double C = (a1*h2 + c1*e2)*q3 - (a1*h3 + c1*e3)*q2 + double const A = a1*e2*q3 - a1*e3*q2 - a2*e1*q3 + a2*e3*q1 + a3*e1*q2 - a3*e2*q1; + double const B = c1*h2*q3 - c1*h3*q2 - c2*h1*q3 + c2*h3*q1 + c3*h1*q2 - c3*h2*q1; + double const C = (a1*h2 + c1*e2)*q3 - (a1*h3 + c1*e3)*q2 - (a2*h1 + c2*e1)*q3 + (a2*h3 + c2*e3)*q1 + (a3*h1 + c3*e1)*q2 - (a3*h2 + c3*e2)*q1; - double D = b1*e2*s3 - b1*e3*s2 - b2*e1*s3 + b2*e3*s1 + b3*e1*s2 - b3*e2*s1; - double E = d1*h2*s3 - d1*h3*s2 - d2*h1*s3 + d2*h3*s1 + d3*h1*s2 - d3*h2*s1; - double F = (b1*h2 + d1*e2)*s3 - (b1*h3 + d1*e3)*s2 + double const D = b1*e2*s3 - b1*e3*s2 - b2*e1*s3 + b2*e3*s1 + b3*e1*s2 - b3*e2*s1; + double const E = d1*h2*s3 - d1*h3*s2 - d2*h1*s3 + d2*h3*s1 + d3*h1*s2 - d3*h2*s1; + double const F = (b1*h2 + d1*e2)*s3 - (b1*h3 + d1*e3)*s2 - (b2*h1 + d2*e1)*s3 + (b2*h3 + d2*e3)*s1 + (b3*h1 + d3*e1)*s2 - (b3*h2 + d3*e2)*s1; - double G = (a1*e2*s3 + b1*e2*q3) - (a1*e3*s2 + b1*e3*q2) + double const G = (a1*e2*s3 + b1*e2*q3) - (a1*e3*s2 + b1*e3*q2) - (a2*e1*s3 + b2*e1*q3) + (a2*e3*s1 + b2*e3*q1) + (a3*e1*s2 + b3*e1*q2) - (a3*e2*s1 + b3*e2*q1); - double H = (c1*h2*s3 + d1*h2*q3) - (c1*h3*s2 + d1*h3*q2) + double const H = (c1*h2*s3 + d1*h2*q3) - (c1*h3*s2 + d1*h3*q2) - (c2*h1*s3 + d2*h1*q3) + (c2*h3*s1 + d2*h3*q1) + (c3*h1*s2 + d3*h1*q2) - (c3*h2*s1 + d3*h2*q1); - double I = ((a1*h2 + c1*e2)*s3 + (b1*h2 + d1*e2)*q3) + double const I = ((a1*h2 + c1*e2)*s3 + (b1*h2 + d1*e2)*q3) - ((a1*h3 + c1*e3)*s2 + (b1*h3 + d1*e3)*q2) - ((a2*h1 + c2*e1)*s3 + (b2*h1 + d2*e1)*q3) + ((a2*h3 + c2*e3)*s1 + (b2*h3 + d2*e3)*q1) + ((a3*h1 + c3*e1)*s2 + (b3*h1 + d3*e1)*q2) - ((a3*h2 + c3*e2)*s1 + (b3*h2 + d3*e2)*q1); - double J = a1*f2*r3 - a1*f3*r2 - a2*f1*r3 + a2*f3*r1 + a3*f1*r2 - a3*f2*r1; - double K = c1*p2*r3 - c1*p3*r2 - c2*p1*r3 + c2*p3*r1 + c3*p1*r2 - c3*p2*r1; - double L = (a1*p2 + c1*f2)*r3 - (a1*p3 + c1*f3)*r2 + double const J = a1*f2*r3 - a1*f3*r2 - a2*f1*r3 + a2*f3*r1 + a3*f1*r2 - a3*f2*r1; + double const K = c1*p2*r3 - c1*p3*r2 - c2*p1*r3 + c2*p3*r1 + c3*p1*r2 - c3*p2*r1; + double const L = (a1*p2 + c1*f2)*r3 - (a1*p3 + c1*f3)*r2 - (a2*p1 + c2*f1)*r3 + (a2*p3 + c2*f3)*r1 + (a3*p1 + c3*f1)*r2 - (a3*p2 + c3*f2)*r1; - double M = b1*f2*t3 - b1*f3*t2 - b2*f1*t3 + b2*f3*t1 + b3*f1*t2 - b3*f2*t1; - double N = d1*p2*t3 - d1*p3*t2 - d2*p1*t3 + d2*p3*t1 + d3*p1*t2 - d3*p2*t1; - double O = (b1*p2 + d1*f2)*t3 - (b1*p3 + d1*f3)*t2 + double const M = b1*f2*t3 - b1*f3*t2 - b2*f1*t3 + b2*f3*t1 + b3*f1*t2 - b3*f2*t1; + double const N = d1*p2*t3 - d1*p3*t2 - d2*p1*t3 + d2*p3*t1 + d3*p1*t2 - d3*p2*t1; + double const O = (b1*p2 + d1*f2)*t3 - (b1*p3 + d1*f3)*t2 - (b2*p1 + d2*f1)*t3 + (b2*p3 + d2*f3)*t1 + (b3*p1 + d3*f1)*t2 - (b3*p2 + d3*f2)*t1; - double P = (a1*f2*t3 + b1*f2*r3) - (a1*f3*t2 + b1*f3*r2) + double const P = (a1*f2*t3 + b1*f2*r3) - (a1*f3*t2 + b1*f3*r2) - (a2*f1*t3 + b2*f1*r3) + (a2*f3*t1 + b2*f3*r1) + (a3*f1*t2 + b3*f1*r2) - (a3*f2*t1 + b3*f2*r1); - double Q = (c1*p2*t3 + d1*p2*r3) - (c1*p3*t2 + d1*p3*r2) + double const Q = (c1*p2*t3 + d1*p2*r3) - (c1*p3*t2 + d1*p3*r2) - (c2*p1*t3 + d2*p1*r3) + (c2*p3*t1 + d2*p3*r1) + (c3*p1*t2 + d3*p1*r2) - (c3*p2*t1 + d3*p2*r1); - double R = ((a1*p2 + c1*f2)*t3 + (b1*p2 + d1*f2)*r3) + double const R = ((a1*p2 + c1*f2)*t3 + (b1*p2 + d1*f2)*r3) - ((a1*p3 + c1*f3)*t2 + (b1*p3 + d1*f3)*r2) - ((a2*p1 + c2*f1)*t3 + (b2*p1 + d2*f1)*r3) + ((a2*p3 + c2*f3)*t1 + (b2*p3 + d2*f3)*r1) + ((a3*p1 + c3*f1)*t2 + (b3*p1 + d3*f1)*r2) - ((a3*p2 + c3*f2)*t1 + (b3*p2 + d3*f2)*r1); - double S = (a1*e2*r3 + a1*f2*q3) - (a1*e3*r2 + a1*f3*q2) + double const S = (a1*e2*r3 + a1*f2*q3) - (a1*e3*r2 + a1*f3*q2) - (a2*e1*r3 + a2*f1*q3) + (a2*e3*r1 + a2*f3*q1) + (a3*e1*r2 + a3*f1*q2) - (a3*e2*r1 + a3*f2*q1); - double T = (c1*h2*r3 + c1*p2*q3) - (c1*h3*r2 + c1*p3*q2) + double const T = (c1*h2*r3 + c1*p2*q3) - (c1*h3*r2 + c1*p3*q2) - (c2*h1*r3 + c2*p1*q3) + (c2*h3*r1 + c2*p3*q1) + (c3*h1*r2 + c3*p1*q2) - (c3*h2*r1 + c3*p2*q1); - double U = ((a1*h2 + c1*e2)*r3 + (a1*p2 + c1*f2)*q3) + double const U = ((a1*h2 + c1*e2)*r3 + (a1*p2 + c1*f2)*q3) - ((a1*h3 + c1*e3)*r2 + (a1*p3 + c1*f3)*q2) - ((a2*h1 + c2*e1)*r3 + (a2*p1 + c2*f1)*q3) + ((a2*h3 + c2*e3)*r1 + (a2*p3 + c2*f3)*q1) + ((a3*h1 + c3*e1)*r2 + (a3*p1 + c3*f1)*q2) - ((a3*h2 + c3*e2)*r1 + (a3*p2 + c3*f2)*q1); - double V = (b1*e2*t3 + b1*f2*s3) - (b1*e3*t2 + b1*f3*s2) + double const V = (b1*e2*t3 + b1*f2*s3) - (b1*e3*t2 + b1*f3*s2) - (b2*e1*t3 + b2*f1*s3) + (b2*e3*t1 + b2*f3*s1) + (b3*e1*t2 + b3*f1*s2) - (b3*e2*t1 + b3*f2*s1); - double W = (d1*h2*t3 + d1*p2*s3) - (d1*h3*t2 + d1*p3*s2) + double const W = (d1*h2*t3 + d1*p2*s3) - (d1*h3*t2 + d1*p3*s2) - (d2*h1*t3 + d2*p1*s3) + (d2*h3*t1 + d2*p3*s1) + (d3*h1*t2 + d3*p1*s2) - (d3*h2*t1 + d3*p2*s1); - double X = ((b1*h2 + d1*e2)*t3 + (b1*p2 + d1*f2)*s3) + double const X = ((b1*h2 + d1*e2)*t3 + (b1*p2 + d1*f2)*s3) - ((b1*h3 + d1*e3)*t2 + (b1*p3 + d1*f3)*s2) - ((b2*h1 + d2*e1)*t3 + (b2*p1 + d2*f1)*s3) + ((b2*h3 + d2*e3)*t1 + (b2*p3 + d2*f3)*s1) + ((b3*h1 + d3*e1)*t2 + (b3*p1 + d3*f1)*s2) - ((b3*h2 + d3*e2)*t1 + (b3*p2 + d3*f2)*s1); - double Y = (a1*e2*t3 + a1*f2*s3 + b1*e2*r3 + b1*f2*q3) + double const Y = (a1*e2*t3 + a1*f2*s3 + b1*e2*r3 + b1*f2*q3) - (a1*e3*t2 + a1*f3*s2 + b1*e3*r2 + b1*f3*q2) - (a2*e1*t3 + a2*f1*s3 + b2*e1*r3 + b2*f1*q3) + (a2*e3*t1 + a2*f3*s1 + b2*e3*r1 + b2*f3*q1) + (a3*e1*t2 + a3*f1*s2 + b3*e1*r2 + b3*f1*q2) - (a3*e2*t1 + a3*f2*s1 + b3*e2*r1 + b3*f2*q1); - double Z = (c1*h2*t3 + c1*p2*s3 + d1*h2*r3 + d1*p2*q3) + double const Z = (c1*h2*t3 + c1*p2*s3 + d1*h2*r3 + d1*p2*q3) - (c1*h3*t2 + c1*p3*s2 + d1*h3*r2 + d1*p3*q2) - (c2*h1*t3 + c2*p1*s3 + d2*h1*r3 + d2*p1*q3) + (c2*h3*t1 + c2*p3*s1 + d2*h3*r1 + d2*p3*q1) + (c3*h1*t2 + c3*p1*s2 + d3*h1*r2 + d3*p1*q2) - (c3*h2*t1 + c3*p2*s1 + d3*h2*r1 + d3*p2*q1); - double AA = ((a1*h2 + c1*e2)*t3 + (a1*p2 + c1*f2)*s3 + double const AA = ((a1*h2 + c1*e2)*t3 + (a1*p2 + c1*f2)*s3 +(b1*h2 + d1*e2)*r3 + (b1*p2 + d1*f2)*q3) - ((a1*h3 + c1*e3)*t2 + (a1*p3 + c1*f3)*s2 +(b1*h3 + d1*e3)*r2 + (b1*p3 + d1*f3)*q2) @@ -535,11 +538,11 @@ namespace INTERP_KERNEL coords[3*OTT::coo2C(connec[i+1])+2])/3.; ConnType tmpConn[3]={connec[0],connec[i],connec[i+1]}; areaVectorOfPolygon(tmpConn,3,coords,tmpArea); - double norm2=sqrt(tmpArea[0]*tmpArea[0]+tmpArea[1]*tmpArea[1]+tmpArea[2]*tmpArea[2]); + double const norm2=sqrt(tmpArea[0]*tmpArea[0]+tmpArea[1]*tmpArea[1]+tmpArea[2]*tmpArea[2]); if(norm2>1e-12) { tmpArea[0]/=norm2; tmpArea[1]/=norm2; tmpArea[2]/=norm2; - double signOfArea=area[0]*tmpArea[0]+area[1]*tmpArea[1]+area[2]*tmpArea[2]; + double const signOfArea=area[0]*tmpArea[0]+area[1]*tmpArea[1]+area[2]*tmpArea[2]; res[0]+=signOfArea*norm2*v[0]/norm; res[1]+=signOfArea*norm2*v[1]/norm; res[2]+=signOfArea*norm2*v[2]/norm; } } @@ -601,13 +604,13 @@ namespace INTERP_KERNEL // projection to (u,v) of each faces of polyh to compute integral(x^2/2) on each faces. double normal[3]; areaVectorOfPolygon(work,nbOfNodesOfCurFace,coords,normal); - double normOfNormal=sqrt(normal[0]*normal[0]+normal[1]*normal[1]+normal[2]*normal[2]); + double const normOfNormal=sqrt(normal[0]*normal[0]+normal[1]*normal[1]+normal[2]*normal[2]); if(normOfNormal::min()) continue; normal[0]/=normOfNormal; normal[1]/=normOfNormal; normal[2]/=normOfNormal; double u[2]={normal[1],-normal[0]}; - double s=sqrt(u[0]*u[0]+u[1]*u[1]); - double c=normal[2]; + double const s=sqrt(u[0]*u[0]+u[1]*u[1]); + double const c=normal[2]; if(fabs(s)>1e-12) { u[0]/=std::abs(s); u[1]/=std::abs(s); @@ -619,30 +622,30 @@ namespace INTERP_KERNEL normal[1]*coords[3*OTT::coo2C(work[0])+1]+ normal[2]*coords[3*OTT::coo2C(work[0])+2]; // A,B,D,F,G,H,L,M,N coeffs of rotation matrix defined by (u,c,s) - double A=u[0]*u[0]*(1-c)+c; - double B=u[0]*u[1]*(1-c); - double D=u[1]*s; - double F=B; - double G=u[1]*u[1]*(1-c)+c; - double H=-u[0]*s; - double L=-u[1]*s; - double M=u[0]*s; - double N=c; - double CX=-w*D; - double CY=-w*H; - double CZ=-w*N; + double const A=u[0]*u[0]*(1-c)+c; + double const B=u[0]*u[1]*(1-c); + double const D=u[1]*s; + double const F=B; + double const G=u[1]*u[1]*(1-c)+c; + double const H=-u[0]*s; + double const L=-u[1]*s; + double const M=u[0]*s; + double const N=c; + double const CX=-w*D; + double const CY=-w*H; + double const CZ=-w*N; for(int j=0;j::coo2C(work[j]); const double *p2=coords+3*OTT::coo2C(work[(j+1)%nbOfNodesOfCurFace]); - double u1=A*p1[0]+B*p1[1]+D*p1[2]; - double u2=A*p2[0]+B*p2[1]+D*p2[2]; - double v1=F*p1[0]+G*p1[1]+H*p1[2]; - double v2=F*p2[0]+G*p2[1]+H*p2[2]; + double const u1=A*p1[0]+B*p1[1]+D*p1[2]; + double const u2=A*p2[0]+B*p2[1]+D*p2[2]; + double const v1=F*p1[0]+G*p1[1]+H*p1[2]; + double const v2=F*p2[0]+G*p2[1]+H*p2[2]; // - double gx=integrationOverA3DLine(u1,v1,u2,v2,A,B,CX); - double gy=integrationOverA3DLine(u1,v1,u2,v2,F,G,CY); - double gz=integrationOverA3DLine(u1,v1,u2,v2,L,M,CZ); + double const gx=integrationOverA3DLine(u1,v1,u2,v2,A,B,CX); + double const gy=integrationOverA3DLine(u1,v1,u2,v2,F,G,CY); + double const gz=integrationOverA3DLine(u1,v1,u2,v2,L,M,CZ); res[0]+=gx*normal[0]; res[1]+=gy*normal[1]; res[2]+=gz*normal[2]; @@ -665,7 +668,7 @@ namespace INTERP_KERNEL int nbOfNodesOfCurFace=(int)std::distance(work,work2); double normal[3]; areaVectorOfPolygon(work,nbOfNodesOfCurFace,coords,normal); - double normOfNormal=sqrt(normal[0]*normal[0]+normal[1]*normal[1]+normal[2]*normal[2]); + double const normOfNormal=sqrt(normal[0]*normal[0]+normal[1]*normal[1]+normal[2]*normal[2]); if(normOfNormal::min()) continue; sum+=normOfNormal; @@ -790,7 +793,7 @@ namespace INTERP_KERNEL res[0]=0.; res[1]=0.; for(mcIdType i=0;i inline void computePolygonBarycenter2D(const ConnType *connec, mcIdType lgth, const double *coords, double *res) { - double **coords2=new double *[lgth]; + auto **coords2=new double *[lgth]; for(mcIdType i=0;i(coords+2*OTT::coo2C(connec[i])); computePolygonBarycenter2DEngine(coords2,lgth,res); diff --git a/src/INTERP_KERNEL/VolSurfUser.cxx b/src/INTERP_KERNEL/VolSurfUser.cxx index 52d594b04..5d7aaa170 100644 --- a/src/INTERP_KERNEL/VolSurfUser.cxx +++ b/src/INTERP_KERNEL/VolSurfUser.cxx @@ -21,9 +21,11 @@ #include "VolSurfUser.hxx" #include "InterpKernelAutoPtr.hxx" #include "InterpolationUtils.hxx" -#include "VectorUtils.hxx" +#include "MCIdType.hxx" #include +#include +#include #include #include #include @@ -35,29 +37,29 @@ namespace INTERP_KERNEL */ double OrthoDistanceFromPtToPlaneInSpaceDim3(const double *p, const double *p1, const double *p2, const double *p3) { - double prec = 1.0e-14; - double T[2][3] = {{p1[0] - p2[0], p1[1] - p2[1], p1[2] - p2[2]}, + double const prec = 1.0e-14; + double const T[2][3] = {{p1[0] - p2[0], p1[1] - p2[1], p1[2] - p2[2]}, {p3[0] - p2[0], p3[1] - p2[1], p3[2] - p2[2]}}; - double N[3] = {T[0][1]*T[1][2]-T[0][2]*T[1][1], + double const N[3] = {T[0][1]*T[1][2]-T[0][2]*T[1][1], T[0][2]*T[1][0]-T[0][0]*T[1][2], T[0][0]*T[1][1]-T[0][1]*T[1][0]}; - double norm2 = N[0]*N[0] + N[1]*N[1] + N[2]*N[2]; + double const norm2 = N[0]*N[0] + N[1]*N[1] + N[2]*N[2]; if (norm2 < prec) throw INTERP_KERNEL::Exception("OrthoDistanceFromPtToPlaneInSpaceDim3: degenerated normal vector!"); - double num = N[0]*(p[0]-p1[0]) + N[1]*(p[1]-p1[1]) + N[2]*(p[2]-p1[2]); + double const num = N[0]*(p[0]-p1[0]) + N[1]*(p[1]-p1[1]) + N[2]*(p[2]-p1[2]); return num/sqrt(norm2); } double SquareDistanceFromPtToSegInSpaceDim2(const double *pt, const double *pt0Seg2, const double *pt1Seg2, std::size_t &nbOfHint) { double dx=pt1Seg2[0]-pt0Seg2[0],dy=pt1Seg2[1]-pt0Seg2[1]; - double norm=sqrt(dx*dx+dy*dy); + double const norm=sqrt(dx*dx+dy*dy); if(norm==0.) return (pt[0]-pt0Seg2[0])*(pt[0]-pt0Seg2[0])+(pt[1]-pt0Seg2[1])*(pt[1]-pt0Seg2[1]);//return std::numeric_limits::max(); dx/=norm; dy/=norm; double dx2=pt[0]-pt0Seg2[0],dy2=pt[1]-pt0Seg2[1]; - double dotP=(dx2*dx+dy2*dy); + double const dotP=(dx2*dx+dy2*dy); if(dotP<0. || dotP>norm) return dotP<0.?(pt[0]-pt0Seg2[0])*(pt[0]-pt0Seg2[0])+(pt[1]-pt0Seg2[1])*(pt[1]-pt0Seg2[1]):(pt[0]-pt1Seg2[0])*(pt[0]-pt1Seg2[0])+(pt[1]-pt1Seg2[1])*(pt[1]-pt1Seg2[1]); nbOfHint++; @@ -76,17 +78,17 @@ namespace INTERP_KERNEL w[i] = pt[i] - pt0Seg2[i]; } - double c1 = dotprod<3>(w,v); + double const c1 = dotprod<3>(w,v); if ( c1 <= 0 ) return norm<3>(w); - double c2 = dotprod<3>(v,v); + double const c2 = dotprod<3>(v,v); if ( c2 <= c1 ) { for(int i=0; i < 3; i++) w[i] = pt[i] - pt1Seg2[i]; return norm<3>(w); } - double b = c1 / c2; + double const b = c1 / c2; for(int i=0; i < 3; i++) w[i] = pt0Seg2[i] + b * v[i] - pt[i]; return norm<3>(w); @@ -143,7 +145,7 @@ namespace INTERP_KERNEL double a00=dotprod<3>(edge0, edge0), a01=dotprod<3>(edge0,edge1), a11=dotprod<3>(edge1,edge1); double b0=dotprod<3>(diff, edge0), b1=dotprod<3>(diff, edge1), c=dotprod<3>(diff, diff); - double det = fabs(a00*a11 - a01*a01); + double const det = fabs(a00*a11 - a01*a01); double s = a01*b1 - a11*b0, t = a01*b0 - a00*b1; double sDist; @@ -171,13 +173,13 @@ namespace INTERP_KERNEL { // points are colinear (degenerated triangle) // => Compute distance between segments - double distance = std::min(DistanceFromPtToSegInSpaceDim3(pt, pt0Tri3, pt1Tri3), + double const distance = std::min(DistanceFromPtToSegInSpaceDim3(pt, pt0Tri3, pt1Tri3), DistanceFromPtToSegInSpaceDim3(pt, pt1Tri3, pt2Tri3)); return distance; } // else we can divide by non-zero - double invDet = 1 / det; + double const invDet = 1 / det; s *= invDet; t *= invDet; sDist = s*(a00*s + a01*t + 2*b0) + t*(a01*s + a11*t + 2*b1) + c; } @@ -191,11 +193,11 @@ namespace INTERP_KERNEL if (t < 0.0) // region 6 sDist = _HelperDistancePtToTri3D_2(a01, a11, a00, b1, b0, c); else { // region 1 - double numer = a11 + b1 - a01 - b0; + double const numer = a11 + b1 - a01 - b0; if (numer <= 0.0) sDist = a11 + 2*b1 + c; else { - double denom = a00 - 2*a01 + a11; + double const denom = a00 - 2*a01 + a11; if (numer >= denom) sDist = a00 + 2*b0 + c; else { @@ -215,7 +217,7 @@ namespace INTERP_KERNEL double DistanceFromPtToPolygonInSpaceDim3(const double *pt, const mcIdType *connOfPolygonBg, const mcIdType *connOfPolygonEnd, const double *coords) { - std::size_t nbOfEdges=std::distance(connOfPolygonBg,connOfPolygonEnd); + std::size_t const nbOfEdges=std::distance(connOfPolygonBg,connOfPolygonEnd); if(nbOfEdges<3) throw INTERP_KERNEL::Exception("DistanceFromPtToPolygonInSpaceDim3 : trying to compute a distance to a polygon containing less than 3 edges !"); double baryOfNodes[3]={0.,0.,0.}; @@ -233,12 +235,12 @@ namespace INTERP_KERNEL ptXY[2*i+1]=matrix[4]*coords[3*connOfPolygonBg[i]]+matrix[5]*coords[3*connOfPolygonBg[i]+1]+matrix[6]*coords[3*connOfPolygonBg[i]+2]+matrix[7]; } double xy[2]={matrix[0]*pt[0]+matrix[1]*pt[1]+matrix[2]*pt[2]+matrix[3],matrix[4]*pt[0]+matrix[5]*pt[1]+matrix[6]*pt[2]+matrix[7]}; - double z=matrix[8]*pt[0]+matrix[9]*pt[1]+matrix[10]*pt[2]+matrix[11]; + double const z=matrix[8]*pt[0]+matrix[9]*pt[1]+matrix[10]*pt[2]+matrix[11]; double ret=std::numeric_limits::max(); std::size_t nbOfHint=0; for(std::size_t i=0;i namespace INTERP_KERNEL { diff --git a/src/INTERP_KERNEL/VolSurfUser.txx b/src/INTERP_KERNEL/VolSurfUser.txx index 93a10c660..988a1db84 100644 --- a/src/INTERP_KERNEL/VolSurfUser.txx +++ b/src/INTERP_KERNEL/VolSurfUser.txx @@ -20,12 +20,18 @@ #ifndef __VOLSURFUSER_TXX__ #define __VOLSURFUSER_TXX__ +#include "NormalizedGeometricTypes" +#include "NormalizedUnstructuredMesh.hxx" +#include "MCIdType.hxx" +#include "InterpKernelGeo2DEdge.hxx" #include "VolSurfUser.hxx" #include "VolSurfFormulae.hxx" #include "InterpolationUtils.hxx" #include "VectorUtils.hxx" #include +#include +#include namespace INTERP_KERNEL { @@ -105,7 +111,7 @@ namespace INTERP_KERNEL break; case INTERP_KERNEL::NORM_POLYGON : { - const double **pts=new const double *[lgth]; + const auto **pts=new const double *[lgth]; for(int inod=0;inod::coo2C(connec[inod]); double val=INTERP_KERNEL::calculateAreaForPolyg(pts,lgth,SPACEDIM); @@ -115,7 +121,7 @@ namespace INTERP_KERNEL break; case INTERP_KERNEL::NORM_QPOLYG : { - const double **pts=new const double *[lgth]; + const auto **pts=new const double *[lgth]; for(int inod=0;inod::coo2C(connec[inod]); double val=INTERP_KERNEL::calculateAreaForQPolyg(pts,lgth,SPACEDIM); @@ -336,7 +342,7 @@ namespace INTERP_KERNEL { if(SPACEDIM==2) { - double **pts=new double *[lgth]; + auto **pts=new double *[lgth]; for(int i=0;i(coords+2*OTT::coo2C(connec[i])); computeQPolygonBarycenter2D(pts,lgth,2,res); @@ -443,8 +449,8 @@ namespace INTERP_KERNEL double AB = getDistanceBtw2Pts(PA,PB); double maxLength = AB; double BC = getDistanceBtw2Pts(PB,PC); if (BC > maxLength) maxLength = BC; double CA = getDistanceBtw2Pts(PC,PA); if (CA > maxLength) maxLength = CA; - double perim( (AB+BC+CA)*0.5 ); - double num( 2*sqrt(perim*(perim-AB)*(perim-BC)*(perim-CA)) ); + double const perim( (AB+BC+CA)*0.5 ); + double const num( 2*sqrt(perim*(perim-AB)*(perim-BC)*(perim-CA)) ); res[0] = num/AB; res[1] = num/BC; res[2] = num/CA; if (AB/maxLength <= EPS) res[0] = BC; diff --git a/src/INTERP_KERNELTest/BBTreeTest.cxx b/src/INTERP_KERNELTest/BBTreeTest.cxx index 0ef5bf90b..9bb30e3fc 100644 --- a/src/INTERP_KERNELTest/BBTreeTest.cxx +++ b/src/INTERP_KERNELTest/BBTreeTest.cxx @@ -18,8 +18,9 @@ // #include "BBTreeTest.hxx" -#include +#include #include +#include "BBTree.txx" #include "DirectedBoundingBox.hxx" namespace INTERP_TEST @@ -46,7 +47,7 @@ namespace INTERP_TEST void BBTreeTest::test_BBTree() { //bbox tree creation const int N=10; - double* bbox=new double[4*N*N]; + auto* bbox=new double[4*N*N]; for (int i=0; i tree(bbox,0,0,N*N); + BBTree<2> const tree(bbox,nullptr,0,N*N); std::vector elems; //box outside the tree @@ -129,10 +130,10 @@ namespace INTERP_TEST 0,-3,0, 2,-3,0, 2,-2,0, 0,-2,0, 10,-3,10, 12,-3,10, 12,-2,10, 10,-2,10 }; - INTERP_KERNEL::DirectedBoundingBox shiftedBB_x( shifted_x, nbP, dim); - INTERP_KERNEL::DirectedBoundingBox shiftedBB_X( shifted_X, nbP, dim); - INTERP_KERNEL::DirectedBoundingBox shiftedBB_y( shifted_y, nbP, dim); - INTERP_KERNEL::DirectedBoundingBox shiftedBB_Y( shifted_Y, nbP, dim); + INTERP_KERNEL::DirectedBoundingBox const shiftedBB_x( shifted_x, nbP, dim); + INTERP_KERNEL::DirectedBoundingBox const shiftedBB_X( shifted_X, nbP, dim); + INTERP_KERNEL::DirectedBoundingBox const shiftedBB_y( shifted_y, nbP, dim); + INTERP_KERNEL::DirectedBoundingBox const shiftedBB_Y( shifted_Y, nbP, dim); CPPUNIT_ASSERT( bb.isDisjointWith( shiftedBB_x )); CPPUNIT_ASSERT( bb.isDisjointWith( shiftedBB_X )); @@ -145,7 +146,7 @@ namespace INTERP_TEST 0,0,0, 2,0,0, 2,1,0, 0,1,0, 0,0,2, 2,0,2, 2,1,2, 0,1,2 }; - INTERP_KERNEL::DirectedBoundingBox ibb( inters_coords, nbP, dim); + INTERP_KERNEL::DirectedBoundingBox const ibb( inters_coords, nbP, dim); CPPUNIT_ASSERT( !bb.isDisjointWith( ibb )); // overlapping non-directed BB @@ -204,8 +205,8 @@ namespace INTERP_TEST -3,0, -1,0, 7,10, 9,10, }; - INTERP_KERNEL::DirectedBoundingBox shiftedBB_x( shifted_x, nbP, dim); - INTERP_KERNEL::DirectedBoundingBox shiftedBB_X( shifted_X, nbP, dim); + INTERP_KERNEL::DirectedBoundingBox const shiftedBB_x( shifted_x, nbP, dim); + INTERP_KERNEL::DirectedBoundingBox const shiftedBB_X( shifted_X, nbP, dim); CPPUNIT_ASSERT( bb.isDisjointWith( shiftedBB_x )); CPPUNIT_ASSERT( bb.isDisjointWith( shiftedBB_X )); @@ -216,7 +217,7 @@ namespace INTERP_TEST 0,0, 2,0, 0,2, 2,2 }; - INTERP_KERNEL::DirectedBoundingBox ibb( inters_coords, nbP, dim); + INTERP_KERNEL::DirectedBoundingBox const ibb( inters_coords, nbP, dim); CPPUNIT_ASSERT( !bb.isDisjointWith( ibb )); // overlapping non-directed BB @@ -270,8 +271,8 @@ namespace INTERP_TEST { -3.0, -0.001 }; - INTERP_KERNEL::DirectedBoundingBox shiftedBB_x( shifted_x, nbP, dim); - INTERP_KERNEL::DirectedBoundingBox shiftedBB_X( shifted_X, nbP, dim); + INTERP_KERNEL::DirectedBoundingBox const shiftedBB_x( shifted_x, nbP, dim); + INTERP_KERNEL::DirectedBoundingBox const shiftedBB_X( shifted_X, nbP, dim); CPPUNIT_ASSERT( bb.isDisjointWith( shiftedBB_x )); CPPUNIT_ASSERT( bb.isDisjointWith( shiftedBB_X )); @@ -281,7 +282,7 @@ namespace INTERP_TEST { -2,2 }; - INTERP_KERNEL::DirectedBoundingBox ibb( inters_coords, nbP, dim); + INTERP_KERNEL::DirectedBoundingBox const ibb( inters_coords, nbP, dim); CPPUNIT_ASSERT( !bb.isDisjointWith( ibb )); // overlapping non-directed BB diff --git a/src/INTERP_KERNELTest/BBTreeTest.hxx b/src/INTERP_KERNELTest/BBTreeTest.hxx index ff12e0191..341d109d1 100644 --- a/src/INTERP_KERNELTest/BBTreeTest.hxx +++ b/src/INTERP_KERNELTest/BBTreeTest.hxx @@ -20,10 +20,11 @@ #ifndef __TU_BB_TREE_HXX__ #define __TU_BB_TREE_HXX__ +#include #include -#include "InterpKernelTestExport.hxx" #include "BBTree.txx" +#include "InterpKernelTestExport.hxx" namespace INTERP_TEST { diff --git a/src/INTERP_KERNELTest/BasicMainTest.hxx b/src/INTERP_KERNELTest/BasicMainTest.hxx index 876f2f097..2ee9a7d70 100644 --- a/src/INTERP_KERNELTest/BasicMainTest.hxx +++ b/src/INTERP_KERNELTest/BasicMainTest.hxx @@ -21,13 +21,12 @@ #define _BASICMAINTEST_HXX_ #include +#include #include #include #include -#include #include #include -#include #include #include @@ -43,7 +42,7 @@ */ // ============================================================================ -int main(int argc, char* argv[]) +int main(int /*argc*/, char* /*argv*/[]) { #if !defined WIN32 && !defined __APPLE__ fpu_control_t cw = _FPU_DEFAULT & ~(_FPU_MASK_IM | _FPU_MASK_ZM | _FPU_MASK_OM); @@ -85,7 +84,7 @@ int main(int argc, char* argv[]) // --- Run the tests. - bool wasSucessful = result.wasSuccessful(); + bool const wasSucessful = result.wasSuccessful(); testFile.close(); // --- Return error code 1 if the one of test failed. diff --git a/src/INTERP_KERNELTest/CppUnitTest.cxx b/src/INTERP_KERNELTest/CppUnitTest.cxx index 8f2ec3987..616ae4cb0 100644 --- a/src/INTERP_KERNELTest/CppUnitTest.cxx +++ b/src/INTERP_KERNELTest/CppUnitTest.cxx @@ -17,4 +17,3 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -#include "CppUnitTest.hxx" diff --git a/src/INTERP_KERNELTest/CppUnitTest.hxx b/src/INTERP_KERNELTest/CppUnitTest.hxx index 23c4bd973..af297c132 100644 --- a/src/INTERP_KERNELTest/CppUnitTest.hxx +++ b/src/INTERP_KERNELTest/CppUnitTest.hxx @@ -20,6 +20,8 @@ #ifndef __TU_TEST_CPPUNIT_HXX__ #define __TU_TEST_CPPUNIT_HXX__ +#include +#include #include #include "InterpKernelTestExport.hxx" @@ -52,11 +54,11 @@ class INTERPKERNELTEST_EXPORT TestBogusClass : public CppUnit::TestFixture CPPUNIT_TEST_SUITE_END(); public: - void setUp() { + void setUp() override { obj = new BogusClass(3.14); } - void tearDown() { + void tearDown() override { delete obj; } diff --git a/src/INTERP_KERNELTest/ExprEvalInterpTest.cxx b/src/INTERP_KERNELTest/ExprEvalInterpTest.cxx index 875fe0e6f..dc74f82d4 100644 --- a/src/INTERP_KERNELTest/ExprEvalInterpTest.cxx +++ b/src/INTERP_KERNELTest/ExprEvalInterpTest.cxx @@ -19,10 +19,16 @@ // Author : Anthony Geay (CEA/DEN) #include "ExprEvalInterpTest.hxx" +#include "InterpKernelException.hxx" #include "InterpKernelExprParser.hxx" +#include "InterpKernelUnit.hxx" +#include +#include #include -#include +#include +#include +#include using namespace INTERP_TEST; @@ -351,35 +357,35 @@ void ExprEvalInterpTest::testInterpreterUnit0() void ExprEvalInterpTest::testInterpreterUnit1() { - INTERP_KERNEL::Unit unit1("m/s"); - INTERP_KERNEL::Unit unit2("km/h"); + INTERP_KERNEL::Unit const unit1("m/s"); + INTERP_KERNEL::Unit const unit2("km/h"); CPPUNIT_ASSERT(unit1.isCompatibleWith(unit2) && unit2.isCompatibleWith(unit1)); CPPUNIT_ASSERT_DOUBLES_EQUAL(360,unit1.convert(unit2,100.),1e-10); - INTERP_KERNEL::Unit unit3("J/s"); - INTERP_KERNEL::Unit unit4("kW"); + INTERP_KERNEL::Unit const unit3("J/s"); + INTERP_KERNEL::Unit const unit4("kW"); CPPUNIT_ASSERT(unit3.isCompatibleWith(unit4) && unit4.isCompatibleWith(unit3)); CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,unit3.convert(unit4,1000.),1e-10); CPPUNIT_ASSERT(unit4.getCoarseRepr()=="kW"); - INTERP_KERNEL::Unit unit5("kpT"); + INTERP_KERNEL::Unit const unit5("kpT"); CPPUNIT_ASSERT(!unit5.isInterpretationOK()); CPPUNIT_ASSERT(unit5.getCoarseRepr()=="kpT"); - INTERP_KERNEL::Unit unit6("m*kpT"); + INTERP_KERNEL::Unit const unit6("m*kpT"); CPPUNIT_ASSERT(!unit6.isInterpretationOK()); - INTERP_KERNEL::Unit unit7("m*s^-1"); + INTERP_KERNEL::Unit const unit7("m*s^-1"); CPPUNIT_ASSERT(unit7.isCompatibleWith(unit2) && unit2.isCompatibleWith(unit7)); CPPUNIT_ASSERT_DOUBLES_EQUAL(360,unit7.convert(unit2,100.),1e-10); const char unit8C[3]={-0x50,0x43,0x0}; - INTERP_KERNEL::Unit unit8(unit8C); - INTERP_KERNEL::Unit unit9("K"); + INTERP_KERNEL::Unit const unit8(unit8C); + INTERP_KERNEL::Unit const unit9("K"); CPPUNIT_ASSERT(unit9.isCompatibleWith(unit8) && unit8.isCompatibleWith(unit9)); CPPUNIT_ASSERT_DOUBLES_EQUAL(335.15,unit8.convert(unit9,62.),1e-10); CPPUNIT_ASSERT_DOUBLES_EQUAL(-16.37,unit9.convert(unit8,256.78),1e-10); - INTERP_KERNEL::Unit unit10("m"); - INTERP_KERNEL::Unit unit11("cm"); + INTERP_KERNEL::Unit const unit10("m"); + INTERP_KERNEL::Unit const unit11("cm"); CPPUNIT_ASSERT(unit10.isCompatibleWith(unit11) && unit11.isCompatibleWith(unit10)); CPPUNIT_ASSERT_DOUBLES_EQUAL(6200.,unit10.convert(unit11,62.),1e-8); CPPUNIT_ASSERT_DOUBLES_EQUAL(0.62,unit11.convert(unit10,62.),1e-15); - INTERP_KERNEL::Unit unit12("m-m"); + INTERP_KERNEL::Unit const unit12("m-m"); CPPUNIT_ASSERT(!unit12.isInterpretationOK()); } @@ -591,7 +597,7 @@ void ExprEvalInterpTest::testInterpreter6() INTERP_KERNEL::ExprParser expr5("x-2*cos(y/3.)"); expr5.parse(); expr5.prepareFastEvaluator(); - double *aa(new double[2]); + auto *aa(new double[2]); std::vector vv(2); vv[0]="x"; vv[1]="y"; expr5.prepareExprEvaluationDouble(vv,2,1,0,aa,aa+2); expr5.prepareFastEvaluator(); diff --git a/src/INTERP_KERNELTest/ExprEvalInterpTest.hxx b/src/INTERP_KERNELTest/ExprEvalInterpTest.hxx index 94478f852..f82a071e9 100644 --- a/src/INTERP_KERNELTest/ExprEvalInterpTest.hxx +++ b/src/INTERP_KERNELTest/ExprEvalInterpTest.hxx @@ -21,6 +21,7 @@ #ifndef _EXPREVALINTERPTEST_HXX_ #define _EXPREVALINTERPTEST_HXX_ +#include #include #include "InterpKernelTestExport.hxx" diff --git a/src/INTERP_KERNELTest/HexaTests.hxx b/src/INTERP_KERNELTest/HexaTests.hxx index d74580ae7..cb9d71030 100644 --- a/src/INTERP_KERNELTest/HexaTests.hxx +++ b/src/INTERP_KERNELTest/HexaTests.hxx @@ -21,6 +21,7 @@ #define __HEXA_TESTS_HXX_ #include "InterpolationTestSuite.hxx" +#include namespace INTERP_TEST { diff --git a/src/INTERP_KERNELTest/Interpolation3DTest.cxx b/src/INTERP_KERNELTest/Interpolation3DTest.cxx index d77c47cdd..2ffaa3a70 100644 --- a/src/INTERP_KERNELTest/Interpolation3DTest.cxx +++ b/src/INTERP_KERNELTest/Interpolation3DTest.cxx @@ -20,14 +20,20 @@ #include "Interpolation3DTest.hxx" #include "MEDFileMesh.hxx" +#include "MCAuto.hxx" #include "MEDCouplingUMesh.hxx" #include "MEDCouplingFieldDouble.hxx" +#include "MeshTestToolkit.hxx" -#include +#include +#include #include -#include +#include +#include #include #include +#include +#include #include "VectorUtils.hxx" diff --git a/src/INTERP_KERNELTest/Interpolation3DTest.hxx b/src/INTERP_KERNELTest/Interpolation3DTest.hxx index 9b80371bb..a04326a75 100644 --- a/src/INTERP_KERNELTest/Interpolation3DTest.hxx +++ b/src/INTERP_KERNELTest/Interpolation3DTest.hxx @@ -20,9 +20,11 @@ #ifndef __TU_INTERPOLATION_3D_TEST_HXX__ #define __TU_INTERPOLATION_3D_TEST_HXX__ -#include +#include "MeshTestToolkit.hxx" #include "Interpolation3D.hxx" +#include + #define ERR_TOL 1.0e-8 /// \brief OBSOLETE - renamed Interpolation3DTestSuite diff --git a/src/INTERP_KERNELTest/InterpolationOptionsTest.cxx b/src/INTERP_KERNELTest/InterpolationOptionsTest.cxx index 7e2268a57..9bcceed07 100644 --- a/src/INTERP_KERNELTest/InterpolationOptionsTest.cxx +++ b/src/INTERP_KERNELTest/InterpolationOptionsTest.cxx @@ -17,16 +17,18 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +#include "MEDCouplingUMesh.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include "MEDCouplingMemArray.hxx" +#include "MEDCouplingNormalizedUnstructuredMesh.txx" +#include "Interpolation2D.hxx" #include "MEDFileMesh.hxx" #include "MEDCouplingFieldDouble.hxx" #include "InterpolationOptionsTest.hxx" -#include "MEDCouplingNormalizedUnstructuredMesh.txx" -#include "Interpolation2D.txx" #include "TestInterpKernelUtils.hxx" -#include -#include +#include using namespace MEDCoupling; @@ -51,10 +53,10 @@ namespace INTERP_TEST */ void InterpolationOptionsTest::test_InterpolationOptions() { - std::string sourcename=INTERP_TEST::getResourceFile("square1.med"); + std::string const sourcename=INTERP_TEST::getResourceFile("square1.med"); MEDFileUMesh *source_mesh=MEDFileUMesh::New(sourcename.c_str(),"Mesh_2"); - std::string targetname=INTERP_TEST::getResourceFile("square2.med"); + std::string const targetname=INTERP_TEST::getResourceFile("square2.med"); MEDFileUMesh *target_mesh=MEDFileUMesh::New(targetname.c_str(),"Mesh_3"); MEDCouplingUMesh *source_mesh_mc=source_mesh->getMeshAtLevel(0); @@ -75,8 +77,8 @@ namespace INTERP_TEST targetvalue[i]=0.0; // Ok at this point we have our mesh in MED-Memory format. // Go to wrap med_source_mesh and med_target_mesh. - MEDCouplingNormalizedUnstructuredMesh<2,2> wrap_source_mesh(source_mesh_mc); - MEDCouplingNormalizedUnstructuredMesh<2,2> wrap_target_mesh(target_mesh_mc); + MEDCouplingNormalizedUnstructuredMesh<2,2> const wrap_source_mesh(source_mesh_mc); + MEDCouplingNormalizedUnstructuredMesh<2,2> const wrap_target_mesh(target_mesh_mc); // Go for interpolation... INTERP_KERNEL::Interpolation2D myInterpolator; //optional call to parametrize your interpolation. First precision, tracelevel, intersector wanted. diff --git a/src/INTERP_KERNELTest/InterpolationOptionsTest.hxx b/src/INTERP_KERNELTest/InterpolationOptionsTest.hxx index 9f2ff04b8..10474aa8d 100644 --- a/src/INTERP_KERNELTest/InterpolationOptionsTest.hxx +++ b/src/INTERP_KERNELTest/InterpolationOptionsTest.hxx @@ -20,6 +20,7 @@ #ifndef __TU_INTERPOLATIONOPTIONS_HXX__ #define __TU_INTERPOLATIONOPTIONS_HXX__ +#include #include #include "InterpKernelTestExport.hxx" diff --git a/src/INTERP_KERNELTest/InterpolationPlanarTestSuite.hxx b/src/INTERP_KERNELTest/InterpolationPlanarTestSuite.hxx index d6ae1d76a..2e2ab3f2f 100644 --- a/src/INTERP_KERNELTest/InterpolationPlanarTestSuite.hxx +++ b/src/INTERP_KERNELTest/InterpolationPlanarTestSuite.hxx @@ -20,10 +20,12 @@ #ifndef __TU_INTERPOLATION_PLANAR_TEST_SUITE_HXX__ #define __TU_INTERPOLATION_PLANAR_TEST_SUITE_HXX__ -#include +#include +#include #include #include #include +#include namespace INTERP_TEST { @@ -43,12 +45,12 @@ namespace INTERP_TEST * Sets up the test suite. * */ - void setUp() + void setUp() override { _Epsilon = 1.e-6; _Precision = 1.e-6; } - void tearDown() {} + void tearDown() override {} // bool checkDequesEqual(std::deque< double > deque1, std::deque< double > deque2, double epsilon); // bool checkVectorsEqual(std::vector< double > Vect1, std::vector< double > Vect2, double epsilon); @@ -59,8 +61,8 @@ namespace INTERP_TEST bool checkDequesEqual(std::deque< double > deque1, std::deque< double > deque2, double epsilon) { - std::size_t size1 = deque1.size(); - std::size_t size2 = deque2.size(); + std::size_t const size1 = deque1.size(); + std::size_t const size2 = deque2.size(); bool are_equal = size1 == size2; if(are_equal) @@ -72,8 +74,8 @@ namespace INTERP_TEST bool checkVectorsEqual(std::vector< double > vect1, std::vector< double > vect2, double epsilon) { - std::size_t size1 = vect1.size(); - std::size_t size2 = vect2.size(); + std::size_t const size1 = vect1.size(); + std::size_t const size2 = vect2.size(); bool are_equal = size1 == size2; if(are_equal) @@ -84,17 +86,17 @@ namespace INTERP_TEST } void dequePrintOut(std::deque< double > deque1) { - for(std::size_t i = 0; i< deque1.size(); i++) + for(double const i : deque1) { - std::cerr << deque1[i] << " "; + std::cerr << i << " "; } std::cerr<< std::endl; } void vectPrintOut(std::vector< double > vect) { - for(std::size_t i = 0; i< vect.size(); i++) + for(double const i : vect) { - std::cerr << vect[i] << " "; + std::cerr << i << " "; } std::cerr<< std::endl; } diff --git a/src/INTERP_KERNELTest/InterpolationTestSuite.hxx b/src/INTERP_KERNELTest/InterpolationTestSuite.hxx index 8f99cf3a6..7fccc193f 100644 --- a/src/INTERP_KERNELTest/InterpolationTestSuite.hxx +++ b/src/INTERP_KERNELTest/InterpolationTestSuite.hxx @@ -20,9 +20,10 @@ #ifndef __TU_INTERPOLATION_TEST_SUITE_HXX__ #define __TU_INTERPOLATION_TEST_SUITE_HXX__ +#include "MeshTestToolkit.hxx" #include "MeshTestToolkit.txx" -#include +#include namespace INTERP_TEST { diff --git a/src/INTERP_KERNELTest/MEDMeshMaker.cxx b/src/INTERP_KERNELTest/MEDMeshMaker.cxx index 70245d3f2..d7955eddd 100644 --- a/src/INTERP_KERNELTest/MEDMeshMaker.cxx +++ b/src/INTERP_KERNELTest/MEDMeshMaker.cxx @@ -19,6 +19,8 @@ #include "MCAuto.hxx" #include "MEDCouplingCMesh.hxx" +#include "MEDCouplingUMesh.hxx" +#include "MEDCouplingMemArray.hxx" #include "MEDMeshMaker.hxx" diff --git a/src/INTERP_KERNELTest/MeshTestToolkit.hxx b/src/INTERP_KERNELTest/MeshTestToolkit.hxx index 73a5c57de..e4a006b16 100644 --- a/src/INTERP_KERNELTest/MeshTestToolkit.hxx +++ b/src/INTERP_KERNELTest/MeshTestToolkit.hxx @@ -20,9 +20,8 @@ #ifndef __TU_MESH_TEST_TOOLKIT_HXX__ #define __TU_MESH_TEST_TOOLKIT_HXX__ -#include "Interpolation3D.hxx" -#include "Interpolation3D.txx" -#include "InterpolationPlanar.hxx" +#include "InterpolationOptions.hxx" +#include "MCIdType.hxx" #include #include @@ -53,12 +52,12 @@ namespace INTERP_TEST { public: - double _precision; - INTERP_KERNEL::IntersectionType _intersectionType;//Used only in the case MESHDIM==2 (planar intersections) + double _precision{1.e-6}; + INTERP_KERNEL::IntersectionType _intersectionType{INTERP_KERNEL::Triangulation};//Used only in the case MESHDIM==2 (planar intersections) - MeshTestToolkit():_precision(1.e-6),_intersectionType(INTERP_KERNEL::Triangulation) {} + MeshTestToolkit() = default; - ~MeshTestToolkit() {} + ~MeshTestToolkit() = default; void intersectMeshes(const char* mesh1, const char* mesh2, const double correctVol, const double prec = 1.0e-5, bool doubleTest = true) const; diff --git a/src/INTERP_KERNELTest/MeshTestToolkit.txx b/src/INTERP_KERNELTest/MeshTestToolkit.txx index 49097166a..4ccd830b6 100644 --- a/src/INTERP_KERNELTest/MeshTestToolkit.txx +++ b/src/INTERP_KERNELTest/MeshTestToolkit.txx @@ -16,26 +16,34 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -#include "TestInterpKernelUtils.hxx" +#ifndef __MESHTESTTOOLKI_TXX__ +#define __MESHTESTTOOLKI_TXX__ #include "MeshTestToolkit.hxx" +#include "MCAuto.hxx" +#include "MCIdType.hxx" +#include "Interpolation2D.hxx" + #include "MEDFileMesh.hxx" -#include "MEDCouplingNormalizedUnstructuredMesh.hxx" #include "MEDCouplingNormalizedUnstructuredMesh.txx" #include "MEDCouplingFieldDouble.hxx" #include "Interpolation3DSurf.hxx" #include "Interpolation2D.txx" #include "Interpolation3D.txx" +#include "TestInterpKernelUtils.hxx" -#include +#include #include -#include +#include +#include #include #include #include +#include +#include // levels : @@ -45,8 +53,8 @@ // 4 - empty // 5 - misc #include "Log.hxx" +#include "VectorUtils.hxx" -#include //#define VOL_PREC 1.0e-6 using namespace MEDCoupling; @@ -66,11 +74,11 @@ namespace INTERP_TEST double MeshTestToolkit::sumRow(const IntersectionMatrix& m, int i) const { double vol = 0.0; - for(IntersectionMatrix::const_iterator iter = m.begin() ; iter != m.end() ; ++iter) + for(const auto & iter : m) { - if(iter->count(i) != 0.0) + if(iter.count(i) != 0.0) { - std::map::const_iterator iter2 = iter->find(i); + auto iter2 = iter.find(i); vol += fabs(iter2->second); } } @@ -90,9 +98,9 @@ namespace INTERP_TEST { double vol = 0.0; const std::map& col = m[i]; - for(std::map::const_iterator iter = col.begin() ; iter != col.end() ; ++iter) + for(auto iter : col) { - vol += fabs(iter->second); + vol += fabs(iter.second); } return vol; } @@ -121,17 +129,17 @@ namespace INTERP_TEST double MeshTestToolkit::sumVolume(const IntersectionMatrix& m) const { std::vector volumes; - for(IntersectionMatrix::const_iterator iter = m.begin() ; iter != m.end() ; ++iter) + for(const auto & iter : m) { - for(std::map::const_iterator iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2) + for(const auto & iter2 : iter) { - volumes.push_back(fabs(iter2->second)); + volumes.push_back(fabs(iter2.second)); } } // sum in ascending order to avoid rounding errors - sort(volumes.begin(), volumes.end()); + std::sort(volumes.begin(), volumes.end()); const double vol = accumulate(volumes.begin(), volumes.end(), 0.0); return vol; @@ -155,7 +163,7 @@ namespace INTERP_TEST bool ok = true; // source elements - double* sVol = new double[sMesh.getNumberOfCells()]; + auto* sVol = new double[sMesh.getNumberOfCells()]; getVolumes(sMesh, sVol); for(int i = 0; i < sMesh.getNumberOfCells(); ++i) @@ -170,7 +178,7 @@ namespace INTERP_TEST } // target elements - double* tVol = new double[tMesh.getNumberOfCells()]; + auto* tVol = new double[tMesh.getNumberOfCells()]; getVolumes(tMesh, tVol); for(int i = 0; i < tMesh.getNumberOfCells(); ++i) { @@ -203,7 +211,7 @@ namespace INTERP_TEST int i = 0; for(IntersectionMatrix::const_iterator iter = m1.begin() ; iter != m1.end() ; ++iter) { - for(std::map::const_iterator iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2) + for(auto iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2) { mcIdType j = iter2->first; if(m2.at(j).count(i) == 0) @@ -245,7 +253,7 @@ namespace INTERP_TEST for(IntersectionMatrix::const_iterator iter = m1.begin() ; iter != m1.end() ; ++iter) { - for(std::map::const_iterator iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2) + for(auto iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2) { mcIdType j = iter2->first; const double v1 = fabs(iter2->second); @@ -287,9 +295,9 @@ namespace INTERP_TEST bool isDiagonal = true; for(IntersectionMatrix::const_iterator iter = m.begin() ; iter != m.end() ; ++iter) { - for(std::map::const_iterator iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2) + for(auto iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2) { - mcIdType j = iter2->first; + mcIdType const j = iter2->first; const double vol = iter2->second; if(vol != 0.0 && (i != j)) { @@ -480,3 +488,5 @@ namespace INTERP_TEST intersectMeshes(path1.c_str(), mesh1, path2.c_str(), mesh2, correctVol, prec, doubleTest); } } + +#endif diff --git a/src/INTERP_KERNELTest/MultiElement2DTests.hxx b/src/INTERP_KERNELTest/MultiElement2DTests.hxx index 799e23776..33f868400 100644 --- a/src/INTERP_KERNELTest/MultiElement2DTests.hxx +++ b/src/INTERP_KERNELTest/MultiElement2DTests.hxx @@ -22,6 +22,9 @@ #include "InterpolationTestSuite.hxx" +#include +#include "MeshTestToolkit.hxx" + namespace INTERP_TEST { /** diff --git a/src/INTERP_KERNELTest/MultiElement3DSurfTests.hxx b/src/INTERP_KERNELTest/MultiElement3DSurfTests.hxx index 4437a9815..9681f5f75 100644 --- a/src/INTERP_KERNELTest/MultiElement3DSurfTests.hxx +++ b/src/INTERP_KERNELTest/MultiElement3DSurfTests.hxx @@ -21,6 +21,9 @@ #define __MULTI_ELEMENT_3DSurf_TESTS_HXX_ #include "InterpolationTestSuite.hxx" +#include "InterpolationOptions.hxx" +#include +#include "MeshTestToolkit.hxx" namespace INTERP_TEST { @@ -32,7 +35,7 @@ namespace INTERP_TEST * different geometries : triangle, quadrilateral. * */ - class MultiElement2DTests : public InterpolationTestSuite<3,2> + class MultiElement3DSurfTests : public InterpolationTestSuite<3,2> { CPPUNIT_TEST_SUITE( MultiElement3DSurfTests ); diff --git a/src/INTERP_KERNELTest/MultiElementTetraTests.hxx b/src/INTERP_KERNELTest/MultiElementTetraTests.hxx index 401d37eb1..437ca855d 100644 --- a/src/INTERP_KERNELTest/MultiElementTetraTests.hxx +++ b/src/INTERP_KERNELTest/MultiElementTetraTests.hxx @@ -21,6 +21,7 @@ #define __MULTI_ELEMENT_TETRA_TESTS_HXX_ #include "InterpolationTestSuite.hxx" +#include namespace INTERP_TEST { diff --git a/src/INTERP_KERNELTest/PerfTest.cxx b/src/INTERP_KERNELTest/PerfTest.cxx index cd0c3b2bf..9b2c4a51f 100644 --- a/src/INTERP_KERNELTest/PerfTest.cxx +++ b/src/INTERP_KERNELTest/PerfTest.cxx @@ -19,15 +19,19 @@ #include "Interpolation3D.hxx" #include "Interpolation3D.txx" +#include "MeshTestToolkit.hxx" +#include "MCAuto.hxx" +#include "MEDFileMesh.hxx" +#include "MEDCouplingUMesh.hxx" #include "MeshTestToolkit.txx" #include "Log.hxx" #include "VectorUtils.hxx" -#include "TestInterpKernelUtils.hxx" -#include "MEDCouplingNormalizedUnstructuredMesh.hxx" +#include "MEDCouplingNormalizedUnstructuredMesh.txx" #include #include +#include /** * Test program which takes two meshes and calculates their intersection matrix. diff --git a/src/INTERP_KERNELTest/QuadraticPlanarInterpTest.cxx b/src/INTERP_KERNELTest/QuadraticPlanarInterpTest.cxx index 0a7fe104e..a22d060f1 100644 --- a/src/INTERP_KERNELTest/QuadraticPlanarInterpTest.cxx +++ b/src/INTERP_KERNELTest/QuadraticPlanarInterpTest.cxx @@ -19,6 +19,7 @@ // Author : Anthony Geay (CEA/DEN) #include "QuadraticPlanarInterpTest.hxx" +#include "InterpKernelGeo2DPrecision.hxx" #include "InterpKernelGeo2DQuadraticPolygon.hxx" #include "InterpKernelGeo2DEdgeArcCircle.hxx" #include "InterpKernelGeo2DElementaryEdge.hxx" @@ -26,8 +27,9 @@ #include "InterpKernelGeo2DEdgeLin.hxx" #include "TestInterpKernelUtils.hxx" +#include +#include #include -#include using namespace INTERP_KERNEL; @@ -52,7 +54,7 @@ void QuadraticPlanarInterpTest::ReadWriteInXfigElementary() { //Testing bounds calculation. For Seg2 std::istringstream stream("2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2\n3200 3400 4500 4700"); - EdgeLin *e1=new EdgeLin(stream); + auto *e1=new EdgeLin(stream); Bounds bound=e1->getBounds(); CPPUNIT_ASSERT_DOUBLES_EQUAL(0.32,bound[0],ADMISSIBLE_ERROR); CPPUNIT_ASSERT_DOUBLES_EQUAL(0.45,bound[1],ADMISSIBLE_ERROR); @@ -73,18 +75,18 @@ void QuadraticPlanarInterpTest::ReadWriteInXfigElementary() void QuadraticPlanarInterpTest::ReadWriteInXfigGlobal() { - QuadraticPolygon pol1(INTERP_TEST::getResourceFile("Pol1.fig").c_str()); + QuadraticPolygon const pol1(INTERP_TEST::getResourceFile("Pol1.fig").c_str()); pol1.dumpInXfigFile("Pol1_gen.fig"); - QuadraticPolygon pol2(INTERP_TEST::getResourceFile("Pol2.fig").c_str()); + QuadraticPolygon const pol2(INTERP_TEST::getResourceFile("Pol2.fig").c_str()); pol2.dumpInXfigFile("Pol2_gen.fig"); - QuadraticPolygon pol3(INTERP_TEST::getResourceFile("Pol3.fig").c_str()); + QuadraticPolygon const pol3(INTERP_TEST::getResourceFile("Pol3.fig").c_str()); pol3.dumpInXfigFile("Pol3_gen.fig"); - QuadraticPolygon pol4(INTERP_TEST::getResourceFile("Pol4.fig").c_str()); + QuadraticPolygon const pol4(INTERP_TEST::getResourceFile("Pol4.fig").c_str()); CPPUNIT_ASSERT_EQUAL(1,pol4.size()); - ElementaryEdge *edge1=dynamic_cast(pol4[0]); + auto *edge1=dynamic_cast(pol4[0]); CPPUNIT_ASSERT(edge1); Edge *edge2=edge1->getPtr(); - EdgeArcCircle *edge=dynamic_cast(edge2); + auto *edge=dynamic_cast(edge2); CPPUNIT_ASSERT(edge); CPPUNIT_ASSERT_DOUBLES_EQUAL(0.24375,edge->getRadius(),ADMISSIBLE_ERROR); CPPUNIT_ASSERT_DOUBLES_EQUAL(5.7857653289925404,edge->getAngle(),ADMISSIBLE_ERROR); @@ -104,7 +106,7 @@ void QuadraticPlanarInterpTest::ReadWriteInXfigGlobal() CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.49741997818704586,edge->getAngle(),ADMISSIBLE_ERROR);//5.7857653289925404 + 2*PI n1->decrRef(); //A half circle. - EdgeArcCircle *e=new EdgeArcCircle(0.84,0.54,0.78,0.6,0.84,0.66); + auto *e=new EdgeArcCircle(0.84,0.54,0.78,0.6,0.84,0.66); CPPUNIT_ASSERT_DOUBLES_EQUAL(0.06,e->getRadius(),ADMISSIBLE_ERROR); CPPUNIT_ASSERT_DOUBLES_EQUAL(-3.1415925921507317,e->getAngle(),1e-5); e->decrRef(); @@ -118,7 +120,7 @@ void QuadraticPlanarInterpTest::BasicGeometricTools() { Node *n1=new Node(1.,1.); Node *n2=new Node(4.,2.); - EdgeLin *e1=new EdgeLin(n1,n2); + auto *e1=new EdgeLin(n1,n2); double tmp[2]; e1->getNormalVector(tmp); CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.94868329805051377,tmp[1],ADMISSIBLE_ERROR); @@ -138,7 +140,7 @@ void QuadraticPlanarInterpTest::BasicGeometricTools() CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0158113883008418,e1->getDistanceToPoint(tmp),1e-12); tmp[0]=0.; tmp[1]=5.; CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,e1->getDistanceToPoint(tmp),1e-12); - EdgeArcCircle *e=new EdgeArcCircle(4.,3.,0.,5.,-5.,0.); + auto *e=new EdgeArcCircle(4.,3.,0.,5.,-5.,0.); tmp[0]=-4.; tmp[1]=3.; CPPUNIT_ASSERT(e->isNodeLyingOn(tmp)); CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,e->getDistanceToPoint(tmp),1e-12); @@ -156,9 +158,9 @@ void QuadraticPlanarInterpTest::IntersectionBasics() { //Testing intersection of Bounds. std::istringstream stream1("2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2\n3200 3400 4500 4800"); - EdgeLin *e1=new EdgeLin(stream1); + auto *e1=new EdgeLin(stream1); std::istringstream stream2("2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2\n3200 3400 4500 4800"); - EdgeLin *e2=new EdgeLin(stream2); + auto *e2=new EdgeLin(stream2); Bounds *bound=e1->getBounds().amIIntersectingWith(e2->getBounds()); CPPUNIT_ASSERT(bound); CPPUNIT_ASSERT_DOUBLES_EQUAL(0.32,(*bound)[0],ADMISSIBLE_ERROR); CPPUNIT_ASSERT_DOUBLES_EQUAL(0.45,(*bound)[1],ADMISSIBLE_ERROR); @@ -168,9 +170,9 @@ void QuadraticPlanarInterpTest::IntersectionBasics() e2->decrRef(); e1->decrRef(); // std::istringstream stream3("2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2\n3000 7200 6000 3700"); - EdgeLin *e3=new EdgeLin(stream3); + auto *e3=new EdgeLin(stream3); std::istringstream stream4("2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2\n4800 6600 7200 4200"); - EdgeLin *e4=new EdgeLin(stream4); + auto *e4=new EdgeLin(stream4); bound=e3->getBounds().amIIntersectingWith(e4->getBounds()); CPPUNIT_ASSERT(bound); CPPUNIT_ASSERT_DOUBLES_EQUAL(0.48,(*bound)[0],ADMISSIBLE_ERROR); CPPUNIT_ASSERT_DOUBLES_EQUAL(0.6,(*bound)[1],ADMISSIBLE_ERROR); @@ -182,7 +184,7 @@ void QuadraticPlanarInterpTest::IntersectionBasics() void QuadraticPlanarInterpTest::EdgeLinUnitary() { - EdgeLin *e1=new EdgeLin(0.5,0.5,3.7,4.1); + auto *e1=new EdgeLin(0.5,0.5,3.7,4.1); Node *n=new Node(2.1,2.3); CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getCharactValue(*n),0.5,1e-8); n->decrRef(); @@ -352,7 +354,7 @@ void QuadraticPlanarInterpTest::IntersectionEdgeOverlapUnitarySegSeg() v1.clear(); v2.clear(); v3.clear(); //Test 3bis - INSIDE - INSIDE - Bis | opp dir. double center[2]={0.,0.}; - double radius=1.; + double const radius=1.; e1=buildArcOfCircle(center,radius,-M_PI,0); e2=buildArcOfCircle(center,radius,-2*M_PI/3.+2*M_PI,-M_PI/3.); CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI,e1->getCurveLength(),1e-12); CPPUNIT_ASSERT_DOUBLES_EQUAL(5.*M_PI/3.,e2->getCurveLength(),1e-12);// To check that in the previous line +2.M_PI has done its job. CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); @@ -898,8 +900,8 @@ void QuadraticPlanarInterpTest::IntersectionEdgeOverlapUnitarySegSeg() void QuadraticPlanarInterpTest::IntersectionPointOnlyUnitarySegSeg() { // 0deg - classical - EdgeLin *e1=new EdgeLin(0.,0.,1.,0.); - EdgeLin *e2=new EdgeLin(0.3,0.3,0.5,-0.3); + auto *e1=new EdgeLin(0.,0.,1.,0.); + auto *e2=new EdgeLin(0.3,0.3,0.5,-0.3); ComposedEdge& v1=*(new ComposedEdge); ComposedEdge& v2=*(new ComposedEdge); MergePoints v3; CPPUNIT_ASSERT(e1->intersectWith(e2,v3,v1,v2)); diff --git a/src/INTERP_KERNELTest/QuadraticPlanarInterpTest.hxx b/src/INTERP_KERNELTest/QuadraticPlanarInterpTest.hxx index 4c2dd8d91..7d2e009ed 100644 --- a/src/INTERP_KERNELTest/QuadraticPlanarInterpTest.hxx +++ b/src/INTERP_KERNELTest/QuadraticPlanarInterpTest.hxx @@ -21,8 +21,10 @@ #ifndef _QUADRATICPLANARINTERPTEST_HXX_ #define _QUADRATICPLANARINTERPTEST_HXX_ +#include #include +#include "InterpKernelGeo2DNode.hxx" #include "InterpKernelTestExport.hxx" #include "InterpKernelGeo2DEdgeArcCircle.hxx" #include "InterpKernelGeo2DQuadraticPolygon.hxx" diff --git a/src/INTERP_KERNELTest/QuadraticPlanarInterpTest2.cxx b/src/INTERP_KERNELTest/QuadraticPlanarInterpTest2.cxx index 8bae77b74..d0bcc22ba 100644 --- a/src/INTERP_KERNELTest/QuadraticPlanarInterpTest2.cxx +++ b/src/INTERP_KERNELTest/QuadraticPlanarInterpTest2.cxx @@ -18,14 +18,18 @@ // // Author : Anthony Geay (CEA/DEN) +#include "InterpKernelGeo2DEdge.hxx" +#include "InterpKernelGeo2DNode.hxx" +#include "InterpKernelGeo2DPrecision.hxx" #include "QuadraticPlanarInterpTest.hxx" #include "InterpKernelGeo2DQuadraticPolygon.hxx" #include "InterpKernelGeo2DEdgeArcCircle.hxx" #include "InterpKernelGeo2DEdgeLin.hxx" #include -#include -#include +#include +#include +#include using namespace INTERP_KERNEL; @@ -37,7 +41,7 @@ static const double ADMISSIBLE_ERROR = 1.e-14; void QuadraticPlanarInterpTest::IntersectArcCircleBase() { double center[2]={0.5,0.5}; - double radius=0.3; + double const radius=0.3; EdgeArcCircle *e1=buildArcOfCircle(center,radius,M_PI/4.,M_PI/3.); CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[0],center[0]+radius*cos(M_PI/3),ADMISSIBLE_ERROR); CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getBounds()[1],center[0]+radius*cos(M_PI/4),ADMISSIBLE_ERROR); @@ -107,7 +111,7 @@ void QuadraticPlanarInterpTest::IntersectArcCircleBase() std::vector v4; MergePoints v3; EdgeArcCircle *e2; - ArcCArcCIntersector *intersector=0; + ArcCArcCIntersector *intersector=nullptr; for(unsigned k=0;k<8;k++) { e1=buildArcOfCircle(center,radius,M_PI/4.+k*M_PI/4.,M_PI/3.+k*M_PI/4.); @@ -168,8 +172,8 @@ void QuadraticPlanarInterpTest::IntersectArcCircleBase() CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[1]))),ADMISSIBLE_ERROR); CPPUNIT_ASSERT(!v4[0]->isEqual(*v4[1])); CPPUNIT_ASSERT_DOUBLES_EQUAL(btw2NodesAndACenter(*v4[0],*v4[1],e1->getCenter()),0.35587863972199624,1e-10); - for(std::vector::iterator iter=v4.begin();iter!=v4.end();iter++) - (*iter)->decrRef(); + for(auto & iter : v4) + iter->decrRef(); v4.clear(); v3.clear(); delete intersector; e2->decrRef(); e1->decrRef(); } @@ -193,8 +197,8 @@ void QuadraticPlanarInterpTest::IntersectArcCircleBase() CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[1]))),ADMISSIBLE_ERROR); CPPUNIT_ASSERT(!v4[0]->isEqual(*v4[1])); CPPUNIT_ASSERT_DOUBLES_EQUAL(btw2NodesAndACenter(*v4[0],*v4[1],e1->getCenter()),0.35587863972199624,1e-10); - for(std::vector::iterator iter=v4.begin();iter!=v4.end();iter++) - (*iter)->decrRef(); + for(auto & iter : v4) + iter->decrRef(); v4.clear(); v3.clear(); delete intersector; e2->decrRef(); e1->decrRef(); } @@ -218,8 +222,8 @@ void QuadraticPlanarInterpTest::IntersectArcCircleBase() CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[1]))),ADMISSIBLE_ERROR); CPPUNIT_ASSERT(!v4[0]->isEqual(*v4[1])); CPPUNIT_ASSERT_DOUBLES_EQUAL(btw2NodesAndACenter(*v4[0],*v4[1],e1->getCenter()),0.6793851523346941,1e-10); - for(std::vector::iterator iter=v4.begin();iter!=v4.end();iter++) - (*iter)->decrRef(); + for(auto & iter : v4) + iter->decrRef(); v4.clear(); v3.clear(); delete intersector; e2->decrRef(); e1->decrRef(); } @@ -243,8 +247,8 @@ void QuadraticPlanarInterpTest::IntersectArcCircleBase() CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[1]))),ADMISSIBLE_ERROR); CPPUNIT_ASSERT(!v4[0]->isEqual(*v4[1])); CPPUNIT_ASSERT_DOUBLES_EQUAL(btw2NodesAndACenter(*v4[0],*v4[1],e1->getCenter()),0.6793851523346941,1e-10); - for(std::vector::iterator iter=v4.begin();iter!=v4.end();iter++) - (*iter)->decrRef(); + for(auto & iter : v4) + iter->decrRef(); v4.clear(); v3.clear(); delete intersector; e2->decrRef(); e1->decrRef(); } @@ -268,8 +272,8 @@ void QuadraticPlanarInterpTest::IntersectArcCircleBase() CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[1]))),ADMISSIBLE_ERROR); CPPUNIT_ASSERT(!v4[0]->isEqual(*v4[1])); CPPUNIT_ASSERT_DOUBLES_EQUAL(1.1195732971845034,btw2NodesAndACenter(*v4[0],*v4[1],e1->getCenter()),1e-10); - for(std::vector::iterator iter=v4.begin();iter!=v4.end();iter++) - (*iter)->decrRef(); + for(auto & iter : v4) + iter->decrRef(); v4.clear(); v3.clear(); delete intersector; e2->decrRef(); e1->decrRef(); } @@ -293,8 +297,8 @@ void QuadraticPlanarInterpTest::IntersectArcCircleBase() CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[1]))),ADMISSIBLE_ERROR); CPPUNIT_ASSERT(!v4[0]->isEqual(*v4[1])); CPPUNIT_ASSERT_DOUBLES_EQUAL(-1.1195732971845034,btw2NodesAndACenter(*v4[0],*v4[1],e1->getCenter()),1e-10); - for(std::vector::iterator iter=v4.begin();iter!=v4.end();iter++) - (*iter)->decrRef(); + for(auto & iter : v4) + iter->decrRef(); v4.clear(); v3.clear(); delete intersector; e2->decrRef(); e1->decrRef(); } @@ -318,8 +322,8 @@ void QuadraticPlanarInterpTest::IntersectArcCircleBase() CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[1]))),ADMISSIBLE_ERROR); CPPUNIT_ASSERT(!v4[0]->isEqual(*v4[1])); CPPUNIT_ASSERT_DOUBLES_EQUAL(-3.0844420190512074,btw2NodesAndACenter(*v4[0],*v4[1],e1->getCenter()),1e-10); - for(std::vector::iterator iter=v4.begin();iter!=v4.end();iter++) - (*iter)->decrRef(); + for(auto & iter : v4) + iter->decrRef(); v4.clear(); v3.clear(); delete intersector; e2->decrRef(); e1->decrRef(); } @@ -343,8 +347,8 @@ void QuadraticPlanarInterpTest::IntersectArcCircleBase() CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[1]))),ADMISSIBLE_ERROR); CPPUNIT_ASSERT(!v4[0]->isEqual(*v4[1])); CPPUNIT_ASSERT_DOUBLES_EQUAL(-3.0844420190512074,btw2NodesAndACenter(*v4[0],*v4[1],e1->getCenter()),1e-10); - for(std::vector::iterator iter=v4.begin();iter!=v4.end();iter++) - (*iter)->decrRef(); + for(auto & iter : v4) + iter->decrRef(); v4.clear(); v3.clear(); delete intersector; e2->decrRef(); e1->decrRef(); } @@ -365,8 +369,8 @@ void QuadraticPlanarInterpTest::IntersectArcCircleBase() CPPUNIT_ASSERT_EQUAL(1,(int)v4.size()); CPPUNIT_ASSERT_EQUAL(0,(int)v3.getNumberOfAssociations()); CPPUNIT_ASSERT_DOUBLES_EQUAL(e1->getRadius(),Node::distanceBtw2Pt(e1->getCenter(),(*(v4[0]))),ADMISSIBLE_ERROR); CPPUNIT_ASSERT_DOUBLES_EQUAL(e2->getRadius(),Node::distanceBtw2Pt(e2->getCenter(),(*(v4[0]))),ADMISSIBLE_ERROR); - for(std::vector::iterator iter=v4.begin();iter!=v4.end();iter++) - (*iter)->decrRef(); + for(auto & iter : v4) + iter->decrRef(); v4.clear(); v4.clear(); delete intersector; e2->decrRef(); e1->decrRef(); } @@ -493,7 +497,7 @@ void QuadraticPlanarInterpTest::IntersectArcCircleBase() void QuadraticPlanarInterpTest::IntersectArcCircleFull() { - double center1[2]; center1[0]=0.; center1[1]=0.; double radius1=3.; + double center1[2]; center1[0]=0.; center1[1]=0.; double const radius1=3.; double center2[2]; center2[0]=0.75; center2[1]=-2.6; double radius2=1.; EdgeArcCircle *e1=buildArcOfCircle(center1,radius1,-M_PI/3.,4.*M_PI/3.); EdgeArcCircle *e2=buildArcOfCircle(center2,radius2,0.,M_PI/2.); @@ -605,7 +609,7 @@ void QuadraticPlanarInterpTest::IntersectArcCircleSegumentBase() { double center[2]={2.,2.}; EdgeArcCircle *e1=buildArcOfCircle(center,2.3,M_PI/4.,5.*M_PI/4.); - EdgeLin *e2=new EdgeLin(-1.3,1.,3.,5.3); + auto *e2=new EdgeLin(-1.3,1.,3.,5.3); EdgeIntersector *intersector=new ArcCSegIntersector(*e1,*e2); bool order; bool obvious,areOverlapped; @@ -651,7 +655,7 @@ QuadraticPolygon *QuadraticPlanarInterpTest::buildQuadraticPolygonCoarseInfo(con EdgeArcCircle *QuadraticPlanarInterpTest::buildArcOfCircle(const double *center, double radius, double alphaStart, double alphaEnd) { - double alphaM=(alphaStart+alphaEnd)/2; + double const alphaM=(alphaStart+alphaEnd)/2; return new EdgeArcCircle(center[0]+cos(alphaStart)*radius,center[1]+sin(alphaStart)*radius, center[0]+cos(alphaM)*radius,center[1]+sin(alphaM)*radius, center[0]+cos(alphaEnd)*radius,center[1]+sin(alphaEnd)*radius); @@ -664,8 +668,8 @@ double QuadraticPlanarInterpTest::btw2NodesAndACenter(const Node& n1, const Node double tmp1[2],tmp2[2]; tmp1[0]=n1Pt[0]-center[0]; tmp1[1]=n1Pt[1]-center[1]; tmp2[0]=n2Pt[0]-center[0]; tmp2[1]=n2Pt[1]-center[1]; - double distTmp1=sqrt(tmp1[0]*tmp1[0]+tmp1[1]*tmp1[1]); - double distTmp2=sqrt(tmp2[0]*tmp2[0]+tmp2[1]*tmp2[1]); + double const distTmp1=sqrt(tmp1[0]*tmp1[0]+tmp1[1]*tmp1[1]); + double const distTmp2=sqrt(tmp2[0]*tmp2[0]+tmp2[1]*tmp2[1]); double ret=acos((tmp1[0]*tmp2[0]+tmp1[1]*tmp2[1])/(distTmp1*distTmp2)); if(tmp1[0]*tmp2[1]-tmp1[1]*tmp2[0]<0) ret=-ret; diff --git a/src/INTERP_KERNELTest/QuadraticPlanarInterpTest3.cxx b/src/INTERP_KERNELTest/QuadraticPlanarInterpTest3.cxx index 2b5acaa25..444a642aa 100644 --- a/src/INTERP_KERNELTest/QuadraticPlanarInterpTest3.cxx +++ b/src/INTERP_KERNELTest/QuadraticPlanarInterpTest3.cxx @@ -18,15 +18,17 @@ // // Author : Anthony Geay (CEA/DEN) +#include "InterpKernelGeo2DNode.hxx" +#include "InterpKernelGeo2DComposedEdge.hxx" +#include "InterpKernelGeo2DAbstractEdge.hxx" +#include "InterpKernelGeo2DEdge.hxx" #include "QuadraticPlanarInterpTest.hxx" #include "InterpKernelGeo2DQuadraticPolygon.hxx" #include "InterpKernelGeo2DElementaryEdge.hxx" -#include "InterpKernelGeo2DEdgeArcCircle.hxx" #include "InterpKernelGeo2DEdgeLin.hxx" #include -#include -#include +#include using namespace INTERP_KERNEL; @@ -38,10 +40,10 @@ void QuadraticPlanarInterpTest::checkInOutDetection() Node *n1=new Node(0.,0.); Node *n2=new Node(1.,0.); Node *n3=new Node(0.5,1.); - EdgeLin *e1=new EdgeLin(n1,n2); - EdgeLin *e2=new EdgeLin(n2,n3); - EdgeLin *e3=new EdgeLin(n3,n1); - ComposedEdge *tri=new ComposedEdge; + auto *e1=new EdgeLin(n1,n2); + auto *e2=new EdgeLin(n2,n3); + auto *e3=new EdgeLin(n3,n1); + auto *tri=new ComposedEdge; tri->pushBack(e1); tri->pushBack(e2); tri->pushBack(e3); // Node *where=new Node(0.4,0.1); @@ -61,22 +63,22 @@ void QuadraticPlanarInterpTest::checkInOutDetection() void QuadraticPlanarInterpTest::checkAssemblingBases1() { Node *n1=new Node(0.,0.); - Node *n2=new Node(0.1,0.); EdgeLin *e1_2=new EdgeLin(n1,n2); - Node *n3=new Node(0.2,0.); EdgeLin *e2_3=new EdgeLin(n2,n3); - Node *n4=new Node(0.3,0.); EdgeLin *e3_4=new EdgeLin(n3,n4); - Node *n5=new Node(0.4,0.); EdgeLin *e4_5=new EdgeLin(n4,n5); - Node *n6=new Node(0.5,0.); EdgeLin *e5_6=new EdgeLin(n5,n6); - Node *n7=new Node(0.6,0.); EdgeLin *e6_7=new EdgeLin(n6,n7); - Node *n8=new Node(0.7,0.); EdgeLin *e7_8=new EdgeLin(n7,n8); - Node *n9=new Node(0.8,0.); EdgeLin *e8_9=new EdgeLin(n8,n9); - Node *n10=new Node(0.9,0.); EdgeLin *e9_10=new EdgeLin(n9,n10); - Node *n11=new Node(1.,0.); EdgeLin *e10_11=new EdgeLin(n10,n11); - Node *n12=new Node(0.5,1.); EdgeLin *e11_12=new EdgeLin(n11,n12); - EdgeLin *e12_1=new EdgeLin(n12,n1); + Node *n2=new Node(0.1,0.); auto *e1_2=new EdgeLin(n1,n2); + Node *n3=new Node(0.2,0.); auto *e2_3=new EdgeLin(n2,n3); + Node *n4=new Node(0.3,0.); auto *e3_4=new EdgeLin(n3,n4); + Node *n5=new Node(0.4,0.); auto *e4_5=new EdgeLin(n4,n5); + Node *n6=new Node(0.5,0.); auto *e5_6=new EdgeLin(n5,n6); + Node *n7=new Node(0.6,0.); auto *e6_7=new EdgeLin(n6,n7); + Node *n8=new Node(0.7,0.); auto *e7_8=new EdgeLin(n7,n8); + Node *n9=new Node(0.8,0.); auto *e8_9=new EdgeLin(n8,n9); + Node *n10=new Node(0.9,0.); auto *e9_10=new EdgeLin(n9,n10); + Node *n11=new Node(1.,0.); auto *e10_11=new EdgeLin(n10,n11); + Node *n12=new Node(0.5,1.); auto *e11_12=new EdgeLin(n11,n12); + auto *e12_1=new EdgeLin(n12,n1); //Only one level e1_2->incrRef(); e2_3->incrRef(); e3_4->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_7->incrRef(); e7_8->incrRef(); e8_9->incrRef(); e9_10->incrRef(); e10_11->incrRef(); e11_12->incrRef(); e12_1->incrRef(); - ComposedEdge *c=new ComposedEdge; + auto *c=new ComposedEdge; c->pushBack(e1_2); c->pushBack(e2_3); c->pushBack(e3_4); c->pushBack(e4_5); c->pushBack(e5_6); c->pushBack(e6_7); c->pushBack(e7_8); c->pushBack(e8_9); c->pushBack(e9_10); c->pushBack(e10_11); c->pushBack(e11_12); c->pushBack(e12_1); CPPUNIT_ASSERT_EQUAL(12,c->recursiveSize()); @@ -98,10 +100,10 @@ void QuadraticPlanarInterpTest::checkAssemblingBases1() //(e1_2, (e2_3,(e3_4, e4_5, e5_6, e6_7, (e7_8, e8_9 ), ( e9_10 , e10_11 ), e11_12 ),e12_1 ) ) e1_2->incrRef(); e2_3->incrRef(); e3_4->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_7->incrRef(); e7_8->incrRef(); e8_9->incrRef(); e9_10->incrRef(); e10_11->incrRef(); e11_12->incrRef(); e12_1->incrRef(); - ComposedEdge *c2_2_4=new ComposedEdge; c2_2_4->pushBack(e7_8); c2_2_4->pushBack(e8_9); - ComposedEdge *c2_2_5=new ComposedEdge; c2_2_5->pushBack(e9_10); c2_2_5->pushBack(e10_11); - ComposedEdge *c2_2=new ComposedEdge; c2_2->pushBack(e3_4); c2_2->pushBack(e4_5); c2_2->pushBack(e5_6); c2_2->pushBack(e6_7); c2_2->pushBack(c2_2_4); c2_2->pushBack(c2_2_5); c2_2->pushBack(e11_12); - ComposedEdge *c2=new ComposedEdge; c2->pushBack(e2_3); c2->pushBack(c2_2); c2->pushBack(e12_1); + auto *c2_2_4=new ComposedEdge; c2_2_4->pushBack(e7_8); c2_2_4->pushBack(e8_9); + auto *c2_2_5=new ComposedEdge; c2_2_5->pushBack(e9_10); c2_2_5->pushBack(e10_11); + auto *c2_2=new ComposedEdge; c2_2->pushBack(e3_4); c2_2->pushBack(e4_5); c2_2->pushBack(e5_6); c2_2->pushBack(e6_7); c2_2->pushBack(c2_2_4); c2_2->pushBack(c2_2_5); c2_2->pushBack(e11_12); + auto *c2=new ComposedEdge; c2->pushBack(e2_3); c2->pushBack(c2_2); c2->pushBack(e12_1); c=new ComposedEdge; c->pushBack(e1_2); c->pushBack(c2); CPPUNIT_ASSERT_EQUAL(12,c->recursiveSize()); IteratorOnComposedEdge it2(c); CPPUNIT_ASSERT(it2.current()->getPtr()==e1_2); @@ -183,14 +185,14 @@ void QuadraticPlanarInterpTest::checkAssemblingBases2() Node *n1=new Node(0.,0.); Node *n4=new Node(0.,-0.3); Node *n2=new Node(1.,0.); Node *n5=new Node(1.,-0.3); Node *n3=new Node(0.5,1.); Node *n6=new Node(0.5,0.7); - EdgeLin *e1_2=new EdgeLin(n1,n2); EdgeLin *e4_5=new EdgeLin(n4,n5); - EdgeLin *e2_3=new EdgeLin(n2,n3); EdgeLin *e5_6=new EdgeLin(n5,n6); - EdgeLin *e3_1=new EdgeLin(n3,n1); EdgeLin *e6_4=new EdgeLin(n6,n4); + auto *e1_2=new EdgeLin(n1,n2); auto *e4_5=new EdgeLin(n4,n5); + auto *e2_3=new EdgeLin(n2,n3); auto *e5_6=new EdgeLin(n5,n6); + auto *e3_1=new EdgeLin(n3,n1); auto *e6_4=new EdgeLin(n6,n4); // e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_4->incrRef(); QuadraticPolygon pol1; pol1.pushBack(e1_2); pol1.pushBack(e2_3); pol1.pushBack(e3_1); QuadraticPolygon pol2; pol2.pushBack(e4_5); pol2.pushBack(e5_6); pol2.pushBack(e6_4); - QuadraticPolygon cpyPol1(pol1); int nbOfSplits=0; + QuadraticPolygon const cpyPol1(pol1); int nbOfSplits=0; cpyPol1.SplitPolygonsEachOther(pol1,pol2,nbOfSplits); CPPUNIT_ASSERT_EQUAL(5,pol1.recursiveSize()); CPPUNIT_ASSERT_EQUAL(5,pol2.recursiveSize());CPPUNIT_ASSERT_EQUAL(15,nbOfSplits); @@ -200,7 +202,7 @@ void QuadraticPlanarInterpTest::checkAssemblingBases2() CPPUNIT_ASSERT(pol2[3]->getEndNode()==pol1[0]->getEndNode()); CPPUNIT_ASSERT(pol2[3]->getEndNode()->getLoc()==ON_1); cpyPol1.performLocatingOperation(pol2); - ElementaryEdge *tmp=dynamic_cast(pol2[0]); CPPUNIT_ASSERT(tmp); CPPUNIT_ASSERT(tmp->getPtr()==e4_5); + auto *tmp=dynamic_cast(pol2[0]); CPPUNIT_ASSERT(tmp); CPPUNIT_ASSERT(tmp->getPtr()==e4_5); CPPUNIT_ASSERT(tmp->getLoc()==FULL_OUT_1); CPPUNIT_ASSERT(tmp->getLoc()==FULL_OUT_1); tmp=dynamic_cast(pol2[1]); CPPUNIT_ASSERT(tmp); @@ -221,12 +223,12 @@ void QuadraticPlanarInterpTest::checkAssemblingBases2() n2=new Node(1.,0.); n5=new Node(0.5,0.); n3=new Node(0.5,1.); n6=new Node(0.75,0.5); Node *n7=new Node(2.,0.5); e1_2=new EdgeLin(n1,n2); e2_3=new EdgeLin(n2,n3); e3_1=new EdgeLin(n3,n1); - EdgeLin *e5_4=new EdgeLin(n5,n4); EdgeLin *e4_7=new EdgeLin(n4,n7); EdgeLin *e7_6=new EdgeLin(n7,n6); EdgeLin *e6_5=new EdgeLin(n6,n5); + auto *e5_4=new EdgeLin(n5,n4); auto *e4_7=new EdgeLin(n4,n7); auto *e7_6=new EdgeLin(n7,n6); auto *e6_5=new EdgeLin(n6,n5); // e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e5_4->incrRef(); e4_7->incrRef(); e7_6->incrRef(); e6_5->incrRef(); QuadraticPolygon pol3; pol3.pushBack(e1_2); pol3.pushBack(e2_3); pol3.pushBack(e3_1); QuadraticPolygon pol4; pol4.pushBack(e5_4); pol4.pushBack(e4_7); pol4.pushBack(e7_6); pol4.pushBack(e6_5); - QuadraticPolygon cpyPol3(pol3); nbOfSplits=0; + QuadraticPolygon const cpyPol3(pol3); nbOfSplits=0; cpyPol3.SplitPolygonsEachOther(pol3,pol4,nbOfSplits); CPPUNIT_ASSERT_EQUAL(5,pol3.recursiveSize()); CPPUNIT_ASSERT_EQUAL(4,pol4.recursiveSize());CPPUNIT_ASSERT_EQUAL(16,nbOfSplits); @@ -259,7 +261,7 @@ void QuadraticPlanarInterpTest::checkAssemblingBases2() e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_4->incrRef(); QuadraticPolygon pol5; pol5.pushBack(e1_2); pol5.pushBack(e2_3); pol5.pushBack(e3_1); QuadraticPolygon pol6; pol6.pushBack(e4_5); pol6.pushBack(e5_6); pol6.pushBack(e6_4); - QuadraticPolygon cpyPol5(pol5); nbOfSplits=0; + QuadraticPolygon const cpyPol5(pol5); nbOfSplits=0; cpyPol5.SplitPolygonsEachOther(pol5,pol6,nbOfSplits); CPPUNIT_ASSERT_EQUAL(4,pol5.recursiveSize()); CPPUNIT_ASSERT_EQUAL(4,pol6.recursiveSize()); CPPUNIT_ASSERT_EQUAL(13,nbOfSplits); @@ -291,7 +293,7 @@ void QuadraticPlanarInterpTest::checkAssemblingBases2() e1_2->incrRef(); e2_3->incrRef(); e3_1->incrRef(); e4_5->incrRef(); e5_6->incrRef(); e6_4->incrRef(); QuadraticPolygon pol7; pol7.pushBack(e1_2); pol7.pushBack(e2_3); pol7.pushBack(e3_1); QuadraticPolygon pol8; pol8.pushBack(e4_5); pol8.pushBack(e5_6); pol8.pushBack(e6_4); - QuadraticPolygon cpyPol7(pol7); nbOfSplits=0; + QuadraticPolygon const cpyPol7(pol7); nbOfSplits=0; cpyPol7.SplitPolygonsEachOther(pol7,pol8,nbOfSplits); tmp=dynamic_cast(pol8[0]); CPPUNIT_ASSERT(tmp); CPPUNIT_ASSERT(tmp->getPtr()==e1_2); CPPUNIT_ASSERT(tmp->getLoc()==FULL_ON_1); diff --git a/src/INTERP_KERNELTest/QuadraticPlanarInterpTest4.cxx b/src/INTERP_KERNELTest/QuadraticPlanarInterpTest4.cxx index 6259d42df..ba75c734c 100644 --- a/src/INTERP_KERNELTest/QuadraticPlanarInterpTest4.cxx +++ b/src/INTERP_KERNELTest/QuadraticPlanarInterpTest4.cxx @@ -18,16 +18,21 @@ // // Author : Anthony Geay (CEA/DEN) +#include "InterpKernelGeo2DNode.hxx" +#include "InterpKernelGeo2DPrecision.hxx" +#include "InterpKernelGeo2DBounds.hxx" #include "QuadraticPlanarInterpTest.hxx" #include "InterpKernelGeo2DQuadraticPolygon.hxx" #include "InterpKernelGeo2DElementaryEdge.hxx" #include "InterpKernelGeo2DEdgeArcCircle.hxx" #include "InterpKernelGeo2DEdgeLin.hxx" +#include #include -#include -#include -#include +#include +#include +#include +#include using namespace INTERP_KERNEL; @@ -40,9 +45,9 @@ void QuadraticPlanarInterpTest::checkPolygonsIntersection1() Node *n1=new Node(0.,0.); Node *n4=new Node(0.,-0.3); Node *n2=new Node(1.,0.); Node *n5=new Node(1.,-0.3); Node *n3=new Node(0.5,1.); Node *n6=new Node(0.5,0.7); - EdgeLin *e1_2=new EdgeLin(n1,n2); EdgeLin *e4_5=new EdgeLin(n4,n5); - EdgeLin *e2_3=new EdgeLin(n2,n3); EdgeLin *e5_6=new EdgeLin(n5,n6); - EdgeLin *e3_1=new EdgeLin(n3,n1); EdgeLin *e6_4=new EdgeLin(n6,n4); + auto *e1_2=new EdgeLin(n1,n2); auto *e4_5=new EdgeLin(n4,n5); + auto *e2_3=new EdgeLin(n2,n3); auto *e5_6=new EdgeLin(n5,n6); + auto *e3_1=new EdgeLin(n3,n1); auto *e6_4=new EdgeLin(n6,n4); // std::vector result; for(int k=0;k<2;k++) @@ -95,7 +100,7 @@ void QuadraticPlanarInterpTest::checkPolygonsIntersection1() n2=new Node(1.,0.); n5=new Node(0.5,0.); n3=new Node(0.5,1.); n6=new Node(0.75,0.5); Node *n7=new Node(2.,0.5); e1_2=new EdgeLin(n1,n2); e2_3=new EdgeLin(n2,n3); e3_1=new EdgeLin(n3,n1); - EdgeLin *e5_4=new EdgeLin(n5,n4); EdgeLin *e4_7=new EdgeLin(n4,n7); EdgeLin *e7_6=new EdgeLin(n7,n6); EdgeLin *e6_5=new EdgeLin(n6,n5); + auto *e5_4=new EdgeLin(n5,n4); auto *e4_7=new EdgeLin(n4,n7); auto *e7_6=new EdgeLin(n7,n6); auto *e6_5=new EdgeLin(n6,n5); // for(int k=0;k<2;k++) for(int i=0;i<3;i++) @@ -514,9 +519,9 @@ void QuadraticPlanarInterpTest::checkHighLevelFunctionTest1() QuadraticPolygon *pol=QuadraticPolygon::BuildArcCirclePolygon(nodes); CPPUNIT_ASSERT_DOUBLES_EQUAL(-1.04719755,pol->getArea(),1e-5); CPPUNIT_ASSERT_EQUAL(3,pol->size()); - ElementaryEdge *e0=dynamic_cast((*pol)[0]); - ElementaryEdge *e1=dynamic_cast((*pol)[1]); - ElementaryEdge *e2=dynamic_cast((*pol)[0]); + auto *e0=dynamic_cast((*pol)[0]); + auto *e1=dynamic_cast((*pol)[1]); + auto *e2=dynamic_cast((*pol)[0]); CPPUNIT_ASSERT(e0); CPPUNIT_ASSERT(e1); CPPUNIT_ASSERT(e2); CPPUNIT_ASSERT(dynamic_cast(e0->getPtr()));// <- testing detection of colinearity CPPUNIT_ASSERT(dynamic_cast(e1->getPtr())); @@ -592,7 +597,7 @@ void QuadraticPlanarInterpTest::check1DInterpLin() 0.1000 , 0.1500 , 0.2000 , 0.2500, 0.3000, 0.3500, 0.4000, 0.4500, 0.5000, 0.5500, 0.6000, 0.6500, 0.7000, 0.7194, 0.7388, 0.7581, 0.7775, 0.7969, 0.8163, 0.8356, 0.8550}; - std::vector zLev1(Z_VALS_1,Z_VALS_1+NB_OF_CELL_AXIAL_1+1); + std::vector const zLev1(Z_VALS_1,Z_VALS_1+NB_OF_CELL_AXIAL_1+1); const int NB_OF_CELL_AXIAL_2=46; static const double Z_VALS_2[NB_OF_CELL_AXIAL_2+1]= @@ -601,7 +606,7 @@ void QuadraticPlanarInterpTest::check1DInterpLin() , 0.20, 0.25, 0.30, 0.350 ,0.40 ,0.450 ,0.500 , 0.550, 0.600 ,0.650 ,0.700 , 0.7194 ,0.7388 ,0.7581 ,0.7775 ,0.7969 ,0.8163 ,0.8356, 0.8550 , 0.8738 ,0.8925 ,0.9113 ,0.9300 ,0.9488 ,0.9675 ,0.9863, 1.0050}; - std::vector zLev2(Z_VALS_2,Z_VALS_2+NB_OF_CELL_AXIAL_2+1); + std::vector const zLev2(Z_VALS_2,Z_VALS_2+NB_OF_CELL_AXIAL_2+1); std::map > m; Edge::Interpolate1DLin(zLev1,zLev2,m); CPPUNIT_ASSERT_EQUAL(30,(int)m.size()); @@ -619,7 +624,7 @@ void QuadraticPlanarInterpTest::check1DInterpLin() static const double Z_VALS_3[NB_OF_CELL_AXIAL_3+1]={ 0.,0.01,0.05,0.10,0.15,0.20,0.25,0.30, 0.35,0.40,0.45,0.50,0.55,0.60 }; - std::vector zLev3(Z_VALS_3,Z_VALS_3+NB_OF_CELL_AXIAL_3+1); + std::vector const zLev3(Z_VALS_3,Z_VALS_3+NB_OF_CELL_AXIAL_3+1); Edge::Interpolate1DLin(zLev3,zLev1,m); CPPUNIT_ASSERT_EQUAL(13,(int)m.size()); CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,m[0][8],1e-12); @@ -682,7 +687,7 @@ void QuadraticPlanarInterpTest::checkNonRegression1() const double radius1=2.902; const double angleS1=-0.49999999950907054; const double angleL1=-0.0942156629996692; const double center1[2]={13.66, -23.66}; - EdgeArcCircle *e1=new EdgeArcCircle(nS1,nE1,center1,radius1,angleS1,angleL1); + auto *e1=new EdgeArcCircle(nS1,nE1,center1,radius1,angleS1,angleL1); // const double coords2[]= { @@ -694,7 +699,7 @@ void QuadraticPlanarInterpTest::checkNonRegression1() const double radius2=2.4345; const double angleS2=-0.523598776190207; const double angleL2=0.5235987755846041; const double center2[]={ 13.933240960547204, -24.132999998525658 }; - EdgeArcCircle *e2=new EdgeArcCircle(nS2,nE2,center2,radius2,angleS2,angleL2); + auto *e2=new EdgeArcCircle(nS2,nE2,center2,radius2,angleS2,angleL2); MergePoints merge; QuadraticPolygon c1,c2; e1->intersectWith(e2,merge,c1,c2); @@ -773,7 +778,7 @@ void QuadraticPlanarInterpTest::checkNonRegression3() const double radius1=3.4304999897666599; const double angleS1=2.6179938783536514; const double angleL1=-0.52359877711901204; const double center1[2]={13.933240950441375, -24.132999992807399}; - EdgeArcCircle *e1=new EdgeArcCircle(nS1,nE1,center1,radius1,angleS1,angleL1); + auto *e1=new EdgeArcCircle(nS1,nE1,center1,radius1,angleS1,angleL1); // const double coords2[]= { @@ -782,14 +787,14 @@ void QuadraticPlanarInterpTest::checkNonRegression3() }; Node *nS2=new Node(coords2); Node *nE2=new Node(coords2+2); - EdgeLin *e2=new EdgeLin(nS2,nE2); + auto *e2=new EdgeLin(nS2,nE2); MergePoints merge; QuadraticPolygon c1,c2; CPPUNIT_ASSERT(e1->intersectWith(e2,merge,c1,c2)); CPPUNIT_ASSERT_EQUAL(2,c1.size()); CPPUNIT_ASSERT_EQUAL(2,c2.size()); - ElementaryEdge *tmp1=dynamic_cast(c1.front()); CPPUNIT_ASSERT(tmp1); - EdgeArcCircle *tmp2=dynamic_cast(tmp1->getPtr()); CPPUNIT_ASSERT(tmp2); + auto *tmp1=dynamic_cast(c1.front()); CPPUNIT_ASSERT(tmp1); + auto *tmp2=dynamic_cast(tmp1->getPtr()); CPPUNIT_ASSERT(tmp2); CPPUNIT_ASSERT_DOUBLES_EQUAL(2.6179938783536514,tmp2->getAngle0(),1e-14); //clean-up nS1->decrRef(); nE1->decrRef(); nS2->decrRef(); nE2->decrRef(); e1->decrRef(); e2->decrRef(); @@ -896,7 +901,7 @@ void QuadraticPlanarInterpTest::checkNonRegression5() nodes2.push_back(new Node(coords2+12)); nodes2.push_back(new Node(coords2+14)); QuadraticPolygon *pol2=QuadraticPolygon::BuildArcCirclePolygon(nodes2); - std::vector v=pol1->intersectMySelfWith(*pol2); + std::vector const v=pol1->intersectMySelfWith(*pol2); CPPUNIT_ASSERT_EQUAL(0,(int)v.size()); //CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00164773941455998,v[0]->getArea(),1e-7); //delete v[0]; @@ -1101,7 +1106,7 @@ void QuadraticPlanarInterpTest::checkNonRegression9() nodes2.push_back(new Node(coords2+12)); nodes2.push_back(new Node(coords2+14)); QuadraticPolygon *pol2=QuadraticPolygon::BuildArcCirclePolygon(nodes2); - std::vector v=pol1->intersectMySelfWith(*pol2); + std::vector const v=pol1->intersectMySelfWith(*pol2); CPPUNIT_ASSERT_EQUAL(0,(int)v.size()); delete pol1; delete pol2; @@ -1122,11 +1127,11 @@ void QuadraticPlanarInterpTest::checkNonRegression10() Node *n3_1=new Node(coords1+4); Node *n1_2=new Node(coords2); Node *n2_2=new Node(coords2+2); - EdgeArcCircle *e1=new EdgeArcCircle(n1_1,n3_1,n2_1); - EdgeLin *e2=new EdgeLin(n1_2,n2_2); + auto *e1=new EdgeArcCircle(n1_1,n3_1,n2_1); + auto *e2=new EdgeLin(n1_2,n2_2); MergePoints merge; - ComposedEdge *c1=new ComposedEdge; - ComposedEdge *c2=new ComposedEdge; + auto *c1=new ComposedEdge; + auto *c2=new ComposedEdge; CPPUNIT_ASSERT(e1->intersectWith(e2,merge,*c1,*c2)); CPPUNIT_ASSERT_EQUAL(2,c1->size()); CPPUNIT_ASSERT_EQUAL(2,c2->size()); @@ -1600,20 +1605,20 @@ void QuadraticPlanarInterpTest::checkNormalize() Node *n1=new Node(0.,0.); Node *n4=new Node(0.,-3.); Node *n2=new Node(10.,0.); Node *n5=new Node(10.,-3.); Node *n3=new Node(5.,10.); Node *n6=new Node(5.,7.); - EdgeLin *e1_2=new EdgeLin(n1,n2); EdgeLin *e4_5=new EdgeLin(n4,n5); - EdgeLin *e2_3=new EdgeLin(n2,n3); EdgeLin *e5_6=new EdgeLin(n5,n6); - EdgeLin *e3_1=new EdgeLin(n3,n1); EdgeLin *e6_4=new EdgeLin(n6,n4); + auto *e1_2=new EdgeLin(n1,n2); auto *e4_5=new EdgeLin(n4,n5); + auto *e2_3=new EdgeLin(n2,n3); auto *e5_6=new EdgeLin(n5,n6); + auto *e3_1=new EdgeLin(n3,n1); auto *e6_4=new EdgeLin(n6,n4); // QuadraticPolygon pol1; pol1.pushBack(e1_2); pol1.pushBack(e2_3); pol1.pushBack(e3_1); QuadraticPolygon pol2; pol2.pushBack(e4_5); pol2.pushBack(e5_6); pol2.pushBack(e6_4); n1->decrRef(); n2->decrRef(); n3->decrRef(); n4->decrRef(); n5->decrRef(); n6->decrRef(); - double area1Start=pol1.getArea(); + double const area1Start=pol1.getArea(); double xb,yb; - double fact=pol1.normalize(&pol2,xb,yb); - double area1End=pol1.getArea(); + double const fact=pol1.normalize(&pol2,xb,yb); + double const area1End=pol1.getArea(); CPPUNIT_ASSERT_DOUBLES_EQUAL(area1Start,area1End*fact*fact,1e-14); CPPUNIT_ASSERT_DOUBLES_EQUAL(13.,fact,1.e-14); - double area=pol1.intersectWith(pol2); + double const area=pol1.intersectWith(pol2); CPPUNIT_ASSERT_DOUBLES_EQUAL(24.5,area*fact*fact,1e-14); // n1=new Node(0.,0.); n4=new Node(0.,-3.); @@ -1628,7 +1633,7 @@ void QuadraticPlanarInterpTest::checkNormalize() CPPUNIT_ASSERT_DOUBLES_EQUAL(24.5,pol3.intersectWithAbs(pol4),1.e-14); // Ok testing EdgeArcCircle update. double center[2]={5.,5.}; - double radius=300.; + double const radius=300.; EdgeArcCircle *e1=buildArcOfCircle(center,radius,M_PI/4.,M_PI/3.); const Bounds& b=e1->getBounds(); double x,y,fact2; @@ -1652,11 +1657,11 @@ void QuadraticPlanarInterpTest::checkMakePartitionAbs1() Node *n1=new Node(0.,0.5); Node *n5=new Node(0.3,1.2); Node *n2=new Node(1.,0.5); Node *n6=new Node(1.1,1.3); Node *n3=new Node(1.,0.); Node *n7=new Node(-0.1,0.9); - EdgeLin *e0_1=new EdgeLin(n0,n1); - EdgeLin *e1_2=new EdgeLin(n1,n2); EdgeLin *e4_5=new EdgeLin(n4,n5); - EdgeLin *e2_3=new EdgeLin(n2,n3); EdgeLin *e5_6=new EdgeLin(n5,n6); - EdgeLin *e3_0=new EdgeLin(n3,n0); EdgeLin *e6_4=new EdgeLin(n6,n4); - EdgeLin *e4_7=new EdgeLin(n4,n7); EdgeLin *e7_5=new EdgeLin(n7,n5); + auto *e0_1=new EdgeLin(n0,n1); + auto *e1_2=new EdgeLin(n1,n2); auto *e4_5=new EdgeLin(n4,n5); + auto *e2_3=new EdgeLin(n2,n3); auto *e5_6=new EdgeLin(n5,n6); + auto *e3_0=new EdgeLin(n3,n0); auto *e6_4=new EdgeLin(n6,n4); + auto *e4_7=new EdgeLin(n4,n7); auto *e7_5=new EdgeLin(n7,n5); QuadraticPolygon pol1; pol1.pushBack(e0_1); pol1.pushBack(e1_2); pol1.pushBack(e2_3); pol1.pushBack(e3_0); QuadraticPolygon pol2; pol2.pushBack(e4_5); pol2.pushBack(e5_6); pol2.pushBack(e6_4); pol2.pushBack(e7_5); e4_5->incrRef(); pol2.pushBack(new ElementaryEdge(e4_5,false)); pol2.pushBack(e4_7); @@ -1670,7 +1675,7 @@ void QuadraticPlanarInterpTest::checkMakePartitionAbs1() */ void QuadraticPlanarInterpTest::checkArcArcIntersection1() { - double eps=1.0e-8; + double const eps=1.0e-8; INTERP_KERNEL::QuadraticPlanarPrecision::setPrecision(eps); Node *n0=new Node(6.37533,38.8928); Node *n3=new Node(6.29194,39.2789); @@ -1680,8 +1685,8 @@ void QuadraticPlanarInterpTest::checkArcArcIntersection1() Node *n6=new Node(6.2534549999999998, 38.861800000000002); // to have a linear edge e1 //EdgeArcCircle *e1=new EdgeArcCircle(n0, n2, n6, true); // to have a linear edge e1 - EdgeArcCircle *e1=new EdgeArcCircle(n0, n2, n1, true); - EdgeArcCircle *e2=new EdgeArcCircle(n3, n5, n4, true); + auto *e1=new EdgeArcCircle(n0, n2, n1, true); + auto *e2=new EdgeArcCircle(n3, n5, n4, true); MergePoints merge; QuadraticPolygon c1,c2; diff --git a/src/INTERP_KERNELTest/QuadraticPlanarInterpTest5.cxx b/src/INTERP_KERNELTest/QuadraticPlanarInterpTest5.cxx index 6e88fa78e..ecad06046 100644 --- a/src/INTERP_KERNELTest/QuadraticPlanarInterpTest5.cxx +++ b/src/INTERP_KERNELTest/QuadraticPlanarInterpTest5.cxx @@ -18,16 +18,16 @@ // // Author : Anthony Geay (CEA/DEN) +#include "InterpKernelGeo2DPrecision.hxx" +#include "InterpKernelGeo2DNode.hxx" #include "QuadraticPlanarInterpTest.hxx" #include "InterpKernelGeo2DQuadraticPolygon.hxx" -#include "InterpKernelGeo2DElementaryEdge.hxx" #include "InterpKernelGeo2DEdgeArcCircle.hxx" -#include "InterpKernelGeo2DEdgeLin.hxx" +#include #include -#include -#include -#include +#include +#include using namespace INTERP_KERNEL; @@ -1180,7 +1180,7 @@ void QuadraticPlanarInterpTest::checkGetMiddleOfPoints() Node * start = new Node(0.,0.); Node * end = new Node(0.,0.); // unused // start, end, center_x, center_y, radius, angle0, angle - EdgeArcCircle e(start, end, e_center, 1.2264175471673588, -0.9533904350433241, 0.95339043504332388); + EdgeArcCircle const e(start, end, e_center, 1.2264175471673588, -0.9533904350433241, 0.95339043504332388); e.getMiddleOfPoints(p1, p2, mid); CPPUNIT_ASSERT_DOUBLES_EQUAL(0.37969180470645592, mid[0], 1.e-7); @@ -1200,7 +1200,7 @@ void QuadraticPlanarInterpTest::checkGetMiddleOfPoints() Node * start = new Node(0.,0.); Node * end = new Node(0.,0.); // unused // start, end, center_x, center_y, radius, angle0, angle - EdgeArcCircle e(start, end, e_center, 6.0104076400856474, -0.69522150912422953, -0.18035330854643861); + EdgeArcCircle const e(start, end, e_center, 6.0104076400856474, -0.69522150912422953, -0.18035330854643861); e.getMiddleOfPoints(p1, p2, mid); CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.6, mid[0], 1.e-7); @@ -1220,7 +1220,7 @@ void QuadraticPlanarInterpTest::checkGetMiddleOfPoints() Node * start = new Node(0.,0.); Node * end = new Node(0.,0.); // unused // start, end, center_x, center_y, radius, angle0, angle - EdgeArcCircle e(start, end, e_center, 2.0977501175200861, 1.0829141821052615, -0.59503203741562627); + EdgeArcCircle const e(start, end, e_center, 2.0977501175200861, 1.0829141821052615, -0.59503203741562627); e.getMiddleOfPoints(p1, p2, mid); CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.5, mid[0], 1.e-7); @@ -1244,7 +1244,7 @@ void QuadraticPlanarInterpTest::checkGetMiddleOfPointsOriented() Node * start = new Node(0.,0.); Node * end = new Node(0.,0.); // unused // start, end, center_x, center_y, radius, angle0, angle - EdgeArcCircle e(start, end, e_center, 1.0, -0.7853981633974485, -1.5707963267948966); + EdgeArcCircle const e(start, end, e_center, 1.0, -0.7853981633974485, -1.5707963267948966); e.getMiddleOfPointsOriented(p1, p2, mid); CPPUNIT_ASSERT_DOUBLES_EQUAL(1., mid[0], 1.e-7); diff --git a/src/INTERP_KERNELTest/SingleElementPlanarTests.cxx b/src/INTERP_KERNELTest/SingleElementPlanarTests.cxx index a69906b72..51b6ea90f 100644 --- a/src/INTERP_KERNELTest/SingleElementPlanarTests.cxx +++ b/src/INTERP_KERNELTest/SingleElementPlanarTests.cxx @@ -19,10 +19,10 @@ #include "SingleElementPlanarTests.hxx" #include "InterpolationUtils.hxx" -#include "PolygonAlgorithms.hxx" #include "PolygonAlgorithms.txx" -#include "InterpolationPlanarTestSuite.hxx" +#include #include +#include using namespace INTERP_KERNEL; @@ -227,7 +227,7 @@ namespace INTERP_TEST // \brief Status : pass void SingleElementPlanarTests::identicalSquares() { - INTERP_KERNEL::PolygonAlgorithms<2> intersector (_Epsilon, _Precision);; + INTERP_KERNEL::PolygonAlgorithms<2> const intersector (_Epsilon, _Precision);; /* ////////////////// TEST DEACTIVATED by A. GEAY because memory fault : // conditional jump INTERP_KERNEL::PolygonAlgorithms<2>::intersectConvexPolygons(double const*, double const*, int, int) (PolygonAlgorithms.txx:629) diff --git a/src/INTERP_KERNELTest/SingleElementPlanarTests.hxx b/src/INTERP_KERNELTest/SingleElementPlanarTests.hxx index 9011e8530..699cbfa6e 100644 --- a/src/INTERP_KERNELTest/SingleElementPlanarTests.hxx +++ b/src/INTERP_KERNELTest/SingleElementPlanarTests.hxx @@ -22,6 +22,7 @@ #include "InterpKernelTestExport.hxx" #include "InterpolationPlanarTestSuite.hxx" +#include namespace INTERP_TEST { diff --git a/src/INTERP_KERNELTest/SingleElementTetraTests.hxx b/src/INTERP_KERNELTest/SingleElementTetraTests.hxx index 2d63a672a..b922fffa9 100644 --- a/src/INTERP_KERNELTest/SingleElementTetraTests.hxx +++ b/src/INTERP_KERNELTest/SingleElementTetraTests.hxx @@ -21,6 +21,7 @@ #define __SINGLE_ELEMENT_TETRA_TESTS_HXX_ #include "InterpolationTestSuite.hxx" +#include namespace INTERP_TEST { diff --git a/src/INTERP_KERNELTest/TestInterpKernel.cxx b/src/INTERP_KERNELTest/TestInterpKernel.cxx index 1a885ad51..da44d54cd 100644 --- a/src/INTERP_KERNELTest/TestInterpKernel.cxx +++ b/src/INTERP_KERNELTest/TestInterpKernel.cxx @@ -26,6 +26,8 @@ #include "TransformedTriangleTest.hxx" #include "UnitTetraIntersectionBaryTest.hxx" #include "UnitTetra3D2DIntersectionTest.hxx" +#include "MeshTestToolkit.txx" +#include #ifndef MEDCOUPLING_MICROMED #include "HexaTests.hxx" diff --git a/src/INTERP_KERNELTest/TestInterpKernelUtils.cxx b/src/INTERP_KERNELTest/TestInterpKernelUtils.cxx index b5649070e..1dd4e227b 100644 --- a/src/INTERP_KERNELTest/TestInterpKernelUtils.cxx +++ b/src/INTERP_KERNELTest/TestInterpKernelUtils.cxx @@ -21,6 +21,7 @@ #include "InterpKernelException.hxx" #include +#include #ifdef WIN32 #include #define getcwd _getcwd @@ -41,7 +42,7 @@ namespace INTERP_TEST resourceFile = getenv("MEDCOUPLING_ROOT_DIR"); resourceFile += "/share/resources/med/"; resourceFile += filename; - std::ifstream my_file(resourceFile.c_str()); + std::ifstream const my_file(resourceFile.c_str()); if (my_file.good()) return resourceFile; } @@ -51,12 +52,12 @@ namespace INTERP_TEST resourceFile.erase(std::remove(resourceFile.begin(), resourceFile.end(), ':'), resourceFile.end()); resourceFile += "/"; resourceFile += filename; - std::ifstream my_file(resourceFile.c_str()); + std::ifstream const my_file(resourceFile.c_str()); if (my_file.good()) return resourceFile; } // else - char * tmp_c = getcwd(NULL, 0); + char * tmp_c = getcwd(nullptr, 0); resourceFile = tmp_c; free(tmp_c); resourceFile += "/"; @@ -64,7 +65,7 @@ namespace INTERP_TEST resourceFile += "../"; resourceFile += "resources/"; resourceFile += filename; - std::ifstream my_file(resourceFile.c_str()); + std::ifstream const my_file(resourceFile.c_str()); if (!my_file.good()) { std::stringstream ss; diff --git a/src/INTERP_KERNELTest/ThreeDSurfProjectionTest.cxx b/src/INTERP_KERNELTest/ThreeDSurfProjectionTest.cxx index 5522adf27..c895da529 100644 --- a/src/INTERP_KERNELTest/ThreeDSurfProjectionTest.cxx +++ b/src/INTERP_KERNELTest/ThreeDSurfProjectionTest.cxx @@ -18,8 +18,11 @@ // #include "ThreeDSurfProjectionTest.hxx" +#include "NormalizedUnstructuredMesh.hxx" #include "PlanarIntersector.txx" #include "MCIdType.hxx" +#include +#include class MyMeshType { @@ -45,7 +48,7 @@ void INTERP_TEST::ThreeDSurfProjectionTest::test1() //MEDCouplingPointSet.Rotate3DAlg([0.,0.,0.],[2.,1.,3.],0.3,coo2) const double coo[9]={0.,0.,0.,0.96809749223257568,0.24332379388106262,-0.059839592782071335,-0.23056279077409292,0.95852673990234838,0.16753294721527912}; const double coo2[9]={9.8122602102980502e-08,-1.4839144255482456e-7,9.8404874611628791e-7,0.96809759035517784,0.24332364548962007,-0.059838608733325221,-0.23056269265149082,0.9585265915109058,0.16753393126402524}; - double *tmp0(new double[9]),*tmp1(new double[9]); + auto *tmp0(new double[9]),*tmp1(new double[9]); int ret; //eps=1e-2. eps is a tolerance to detect that two points are the same or not in a same polygon. // here the max 3D distance is 1e-5 > 1e-6 so 1 is expected @@ -90,7 +93,7 @@ void INTERP_TEST::ThreeDSurfProjectionTest::test2() // const double coo[9]={0.,0.,0.,0.96809749223257568,0.24332379388106262,-0.059839592782071335,-0.23056279077409292,0.95852673990234838,0.16753294721527912}; const double coo2[9]={7.2311562622637225e-07,6.8998795679738294e-07,3.1943866106249849e-08,0.72852072144314628,0.33125439126063028,0.5996079016637561,0.0090154262465889021,0.87059752249869415,-0.49191448334281612}; - double *tmp0(new double[9]),*tmp1(new double[9]); + auto *tmp0(new double[9]),*tmp1(new double[9]); int ret; //eps=1e-2. eps is a tolerance to detect that two points are the same or not in a same polygon. // here the max 3D distance is 1e-5 > 1e-6 so 1 is expected diff --git a/src/INTERP_KERNELTest/ThreeDSurfProjectionTest.hxx b/src/INTERP_KERNELTest/ThreeDSurfProjectionTest.hxx index 7f382612f..8e8ec781f 100644 --- a/src/INTERP_KERNELTest/ThreeDSurfProjectionTest.hxx +++ b/src/INTERP_KERNELTest/ThreeDSurfProjectionTest.hxx @@ -20,6 +20,7 @@ #ifndef __THREEDSURFPROJECTIONTEST_HXX__ #define __THREEDSURFPROJECTIONTEST_HXX__ +#include #include #include "InterpKernelTestExport.hxx" diff --git a/src/INTERP_KERNELTest/TransformedTriangleIntersectTest.cxx b/src/INTERP_KERNELTest/TransformedTriangleIntersectTest.cxx index 41c12e1c7..521b5c8ae 100644 --- a/src/INTERP_KERNELTest/TransformedTriangleIntersectTest.cxx +++ b/src/INTERP_KERNELTest/TransformedTriangleIntersectTest.cxx @@ -18,10 +18,11 @@ // #include "TransformedTriangleIntersectTest.hxx" -#include -#include +#include +#include #include "Log.hxx" +#include "TransformedTriangle.hxx" /// macro to test for zero double products outside the segment-edge intersection test method /// as is done in TransformedTriangle when OPTIMIZE is defined @@ -145,7 +146,7 @@ namespace INTERP_TEST 0.4, 2.5, 0.5 // R }; - TransformedTriangle* tri = new TransformedTriangle(&coords[0], &coords[3], &coords[6]); + auto* tri = new TransformedTriangle(&coords[0], &coords[3], &coords[6]); // run all intersection tests and ensure that the ones // listed with yes in the tables above return true and @@ -299,7 +300,7 @@ namespace INTERP_TEST 1.5, 0.5,-0.25, // Q -0.5,-1.5, 0.75 // R }; - TransformedTriangle* tri = new TransformedTriangle(&coords[0], &coords[3], &coords[6]); + auto* tri = new TransformedTriangle(&coords[0], &coords[3], &coords[6]); // run all intersection tests and ensure that the ones // listed with yes in the tables above return true and @@ -453,7 +454,7 @@ namespace INTERP_TEST -0.4, 0.3, 0.9 // R }; - TransformedTriangle* tri = new TransformedTriangle(&coords[0], &coords[3], &coords[6]); + auto* tri = new TransformedTriangle(&coords[0], &coords[3], &coords[6]); // run all intersection tests and ensure that the ones // listed with yes in the tables above return true and @@ -607,7 +608,7 @@ namespace INTERP_TEST 0.2, -1.3, -1.4 // R }; - TransformedTriangle* tri = new TransformedTriangle(&coords[0], &coords[3], &coords[6]); + auto* tri = new TransformedTriangle(&coords[0], &coords[3], &coords[6]); // run all intersection tests and ensure that the ones // listed with yes in the tables above return true and @@ -763,7 +764,7 @@ namespace INTERP_TEST 0.5, -2.6, 1.3 // R }; - TransformedTriangle* tri = new TransformedTriangle(&coords[0], &coords[3], &coords[6]); + auto* tri = new TransformedTriangle(&coords[0], &coords[3], &coords[6]); // run all intersection tests and ensure that the ones // listed with yes in the tables above return true and @@ -918,7 +919,7 @@ namespace INTERP_TEST -3.0, 3.0, -0.5 // R }; - TransformedTriangle* tri = new TransformedTriangle(&coords[0], &coords[3], &coords[6]); + auto* tri = new TransformedTriangle(&coords[0], &coords[3], &coords[6]); // run all intersection tests and ensure that the ones // listed with yes in the tables above return true and @@ -1073,7 +1074,7 @@ namespace INTERP_TEST 0.3, 0.4, 0.2 // R }; - TransformedTriangle* tri = new TransformedTriangle(&coords[0], &coords[3], &coords[6]); + auto* tri = new TransformedTriangle(&coords[0], &coords[3], &coords[6]); // run all intersection tests and ensure that the ones // listed with yes in the tables above return true and @@ -1228,7 +1229,7 @@ namespace INTERP_TEST -0.1, -0.4, 0.9 // R }; - TransformedTriangle* tri = new TransformedTriangle(&coords[0], &coords[3], &coords[6]); + auto* tri = new TransformedTriangle(&coords[0], &coords[3], &coords[6]); // run all intersection tests and ensure that the ones // listed with yes in the tables above return true and @@ -1382,7 +1383,7 @@ namespace INTERP_TEST 0.1, 0.2, 0.8 // R }; - TransformedTriangle* tri = new TransformedTriangle(&coords[0], &coords[3], &coords[6]); + auto* tri = new TransformedTriangle(&coords[0], &coords[3], &coords[6]); // run all intersection tests and ensure that the ones // listed with yes in the tables above return true and @@ -1537,7 +1538,7 @@ namespace INTERP_TEST 0.4, 0.3, 0.3 // R }; - TransformedTriangle* tri = new TransformedTriangle(&coords[0], &coords[3], &coords[6]); + auto* tri = new TransformedTriangle(&coords[0], &coords[3], &coords[6]); // run all intersection tests and ensure that the ones // listed with yes in the tables above return true and @@ -1691,7 +1692,7 @@ namespace INTERP_TEST 0.3, 0.3, 0.3 // R }; - TransformedTriangle* tri = new TransformedTriangle(&coords[0], &coords[3], &coords[6]); + auto* tri = new TransformedTriangle(&coords[0], &coords[3], &coords[6]); // run all intersection tests and ensure that the ones // listed with yes in the tables above return true and @@ -1846,7 +1847,7 @@ namespace INTERP_TEST 0.6, 0.6, -0.6 // R }; - TransformedTriangle* tri = new TransformedTriangle(&coords[0], &coords[3], &coords[6]); + auto* tri = new TransformedTriangle(&coords[0], &coords[3], &coords[6]); // run all intersection tests and ensure that the ones // listed with yes in the tables above return true and @@ -2000,7 +2001,7 @@ namespace INTERP_TEST -0.2, -0.1, 3.0 // R }; - TransformedTriangle* tri = new TransformedTriangle(&coords[0], &coords[3], &coords[6]); + auto* tri = new TransformedTriangle(&coords[0], &coords[3], &coords[6]); // run all intersection tests and ensure that the ones // listed with yes in the tables above return true and @@ -2138,7 +2139,7 @@ namespace INTERP_TEST 0.44117647058823506, 0, 0.55882352941176483, -0.89215686274509864, 1.3333333333333339, 0.55882352941176483}; - double refVol = 0.054383777732546296; + double const refVol = 0.054383777732546296; TransformedTriangle tri(&coords[0], &coords[3], &coords[6]); const double vol = tri.calculateIntersectionVolume(); @@ -2163,7 +2164,7 @@ namespace INTERP_TEST -0.55882352941176472, 0, 1.5588235294117649, -0.89215686274509864, 1.3333333333333339, 0.55882352941176483 }; - double refVol = -0.06869529818848; + double const refVol = -0.06869529818848; TransformedTriangle tri(&coords[0], &coords[3], &coords[6]); const double vol = tri.calculateIntersectionVolume(); @@ -2189,7 +2190,7 @@ namespace INTERP_TEST -1.2062474433365091, -0.037350951323461778, 2.1879983126221099, 0.49877186496532655, 0.59827776894780405, 0.79353793765518521 }; - double refVol = -0.051135429735185; + double const refVol = -0.051135429735185; TransformedTriangle tri(&coords[0], &coords[3], &coords[6]); const double vol = tri.calculateIntersectionVolume(); @@ -2214,7 +2215,7 @@ namespace INTERP_TEST 2.022774182629973, -1.020222639063029, -0.01375178680446254, 0.7495960843059706, 0.1125313911637846, 0.7430770879625861 }; - double refVol = -0.00060846166394417; + double const refVol = -0.00060846166394417; TransformedTriangle tri(&coords[0], &coords[3], &coords[6]); const double vol = tri.calculateIntersectionVolume(); @@ -2239,7 +2240,7 @@ namespace INTERP_TEST -3.552713678800501e-15, 0, 0.9999999999999982, 0, 1.000000000000004, -8.881784197001252e-16 }; - double refVol = -1/6.; + double const refVol = -1/6.; TransformedTriangle tri(&coords[0], &coords[3], &coords[6]); const double vol = tri.calculateIntersectionVolume(); @@ -2264,7 +2265,7 @@ namespace INTERP_TEST 1.000000000000004, 0, 0, 0, 0, 0.9999999999999929, 3.552713678800501e-15, 1, 0}; - double refVol = -1/6.; + double const refVol = -1/6.; TransformedTriangle tri(&coords[0], &coords[3], &coords[6]); const double vol = tri.calculateIntersectionVolume(); @@ -2291,7 +2292,7 @@ namespace INTERP_TEST 3.700743415417188e-17, 0.9999999999999999, 3.700743415417188e-17 }; - double refVol = -1/6.; + double const refVol = -1/6.; TransformedTriangle tri(&coords[0], &coords[3], &coords[6]); const double vol = tri.calculateIntersectionVolume(); @@ -2333,7 +2334,7 @@ namespace INTERP_TEST -7.105427357601002e-15, 1.000000000000014, -3.552713678800501e-15 }; - double refVol = -1/6.; + double const refVol = -1/6.; TransformedTriangle tri(&coords[0], &coords[3], &coords[6]); const double vol = tri.calculateIntersectionVolume(); diff --git a/src/INTERP_KERNELTest/TransformedTriangleIntersectTest.hxx b/src/INTERP_KERNELTest/TransformedTriangleIntersectTest.hxx index 8d7ef5e64..1c16c034e 100644 --- a/src/INTERP_KERNELTest/TransformedTriangleIntersectTest.hxx +++ b/src/INTERP_KERNELTest/TransformedTriangleIntersectTest.hxx @@ -20,6 +20,7 @@ #ifndef __TU_TRANSFORMED_TRIANGLE_INTERSECT_HXX__ #define __TU_TRANSFORMED_TRIANGLE_INTERSECT_HXX__ +#include #include #include "InterpKernelTestExport.hxx" diff --git a/src/INTERP_KERNELTest/TransformedTriangleTest.cxx b/src/INTERP_KERNELTest/TransformedTriangleTest.cxx index 856e06086..9de4ef357 100644 --- a/src/INTERP_KERNELTest/TransformedTriangleTest.cxx +++ b/src/INTERP_KERNELTest/TransformedTriangleTest.cxx @@ -18,8 +18,9 @@ // #include "TransformedTriangleTest.hxx" +#include "TransformedTriangle.hxx" -#include +#include using namespace INTERP_KERNEL; @@ -86,14 +87,14 @@ namespace INTERP_TEST void TransformedTriangleTest::test_constructor() { // test that _coords has correct values after constructor is called - double good_values1[15] = + double const good_values1[15] = { p1[0], p1[1], p1[2], hp1, Hp1, q1[0], q1[1], q1[2], hq1, Hq1, r1[0], r1[1], r1[2], hr1, Hr1 }; - double good_values2[15] = + double const good_values2[15] = { p2[0], p2[1], p2[2], hp2, Hp2, q2[0], q2[1], q2[2], hq2, Hq2, @@ -118,7 +119,7 @@ namespace INTERP_TEST // test that the correct c-values are calculated - double correct_c_vals[24] = + double const correct_c_vals[24] = { p1[0] * q1[1] - p1[1] * q1[0], p1[1] * q1[2] - p1[2] * q1[1], @@ -315,7 +316,7 @@ namespace INTERP_TEST for(int i = 0; i < 3 ; ++i) { - DoubleProduct dp = DOUBLE_PRODUCTS[3*min_corner + i]; + DoubleProduct const dp = DOUBLE_PRODUCTS[3*min_corner + i]; // std::cout << std::endl << "in test inconsistent (seg,dp) :(" << seg <<", " << dp << ")" << std::endl; CPPUNIT_ASSERT_EQUAL(0.0, tri2->calcStableC(seg, dp)); correct_c_vals[8*seg + dp] = 0.0; diff --git a/src/INTERP_KERNELTest/TransformedTriangleTest.hxx b/src/INTERP_KERNELTest/TransformedTriangleTest.hxx index c01d9be26..0f98006f9 100644 --- a/src/INTERP_KERNELTest/TransformedTriangleTest.hxx +++ b/src/INTERP_KERNELTest/TransformedTriangleTest.hxx @@ -20,6 +20,7 @@ #ifndef __TU_TRANSFORMED_TRIANGLE_HXX__ #define __TU_TRANSFORMED_TRIANGLE_HXX__ +#include #include #include "InterpKernelTestExport.hxx" @@ -45,8 +46,8 @@ namespace INTERP_TEST // CPPUNIT_TEST( test_calcStableC_Consistency ); CPPUNIT_TEST_SUITE_END(); - typedef INTERP_KERNEL::TransformedTriangle::TriSegment TriSegment; - typedef INTERP_KERNEL::TransformedTriangle::DoubleProduct DoubleProduct; + using TriSegment = INTERP_KERNEL::TransformedTriangle::TriSegment; + using DoubleProduct = INTERP_KERNEL::TransformedTriangle::DoubleProduct; public: void setUp(); diff --git a/src/INTERP_KERNELTest/UnitTetra3D2DIntersectionTest.cxx b/src/INTERP_KERNELTest/UnitTetra3D2DIntersectionTest.cxx index 28a91f427..8f7294914 100644 --- a/src/INTERP_KERNELTest/UnitTetra3D2DIntersectionTest.cxx +++ b/src/INTERP_KERNELTest/UnitTetra3D2DIntersectionTest.cxx @@ -19,12 +19,12 @@ #include "UnitTetra3D2DIntersectionTest.hxx" -#include "TetraAffineTransform.hxx" -#include "InterpolationUtils.hxx" #include "SplitterTetra.txx" +#include "NormalizedGeometricTypes" #include "MCIdType.hxx" -#include +#include +#include using namespace INTERP_KERNEL; @@ -32,7 +32,7 @@ namespace INTERP_TEST { struct __MESH_DUMMY { - typedef mcIdType MyConnType; + using MyConnType = mcIdType; static const int MY_SPACEDIM=3; }; @@ -47,7 +47,7 @@ namespace INTERP_TEST const double* tetraCoords[]={ targetCoords, targetCoords+3, targetCoords+6, targetCoords+9 }; - __MESH_DUMMY dummyMesh; + __MESH_DUMMY const dummyMesh; SplitterTetra<__MESH_DUMMY>* targetTetra = new SplitterTetra<__MESH_DUMMY>( dummyMesh, tetraCoords, conn ); return targetTetra; } @@ -80,13 +80,13 @@ namespace INTERP_TEST CPPUNIT_ASSERT_EQUAL(4,(int)listOfTetraFacesTreated.size()); std::multiset correctListOfTetraFacesTreated; - TriangleFaceKey key1 = TriangleFaceKey(0, 1, 2); + TriangleFaceKey const key1 = TriangleFaceKey(0, 1, 2); correctListOfTetraFacesTreated.insert(key1); - TriangleFaceKey key2 = TriangleFaceKey(0, 1, 3); + TriangleFaceKey const key2 = TriangleFaceKey(0, 1, 3); correctListOfTetraFacesTreated.insert(key2); - TriangleFaceKey key3 = TriangleFaceKey(0, 2, 3); + TriangleFaceKey const key3 = TriangleFaceKey(0, 2, 3); correctListOfTetraFacesTreated.insert(key3); - TriangleFaceKey key4 = TriangleFaceKey(1, 2, 3); + TriangleFaceKey const key4 = TriangleFaceKey(1, 2, 3); correctListOfTetraFacesTreated.insert(key4); CPPUNIT_ASSERT(correctListOfTetraFacesTreated == listOfTetraFacesTreated); @@ -126,13 +126,13 @@ namespace INTERP_TEST CPPUNIT_ASSERT_EQUAL(4,(int)listOfTetraFacesTreated.size()); std::multiset correctListOfTetraFacesTreated; - TriangleFaceKey key1 = TriangleFaceKey(0, 1, 2); + TriangleFaceKey const key1 = TriangleFaceKey(0, 1, 2); correctListOfTetraFacesTreated.insert(key1); - TriangleFaceKey key2 = TriangleFaceKey(0, 1, 3); + TriangleFaceKey const key2 = TriangleFaceKey(0, 1, 3); correctListOfTetraFacesTreated.insert(key2); - TriangleFaceKey key3 = TriangleFaceKey(0, 2, 3); + TriangleFaceKey const key3 = TriangleFaceKey(0, 2, 3); correctListOfTetraFacesTreated.insert(key3); - TriangleFaceKey key4 = TriangleFaceKey(1, 2, 3); + TriangleFaceKey const key4 = TriangleFaceKey(1, 2, 3); correctListOfTetraFacesTreated.insert(key4); CPPUNIT_ASSERT(correctListOfTetraFacesTreated == listOfTetraFacesTreated); diff --git a/src/INTERP_KERNELTest/UnitTetra3D2DIntersectionTest.hxx b/src/INTERP_KERNELTest/UnitTetra3D2DIntersectionTest.hxx index 6b69728ed..740155f31 100644 --- a/src/INTERP_KERNELTest/UnitTetra3D2DIntersectionTest.hxx +++ b/src/INTERP_KERNELTest/UnitTetra3D2DIntersectionTest.hxx @@ -20,6 +20,7 @@ #ifndef __UNITTETRA3D2DINTERSECTIONTEST_HXX__ #define __UNITTETRA3D2DINTERSECTIONTEST_HXX__ +#include #include #include "InterpKernelTestExport.hxx" diff --git a/src/INTERP_KERNELTest/UnitTetraIntersectionBaryTest.cxx b/src/INTERP_KERNELTest/UnitTetraIntersectionBaryTest.cxx index 991b93c76..308c3167e 100644 --- a/src/INTERP_KERNELTest/UnitTetraIntersectionBaryTest.cxx +++ b/src/INTERP_KERNELTest/UnitTetraIntersectionBaryTest.cxx @@ -23,13 +23,16 @@ // #include "UnitTetraIntersectionBaryTest.hxx" +#include "TransformedTriangle.hxx" +#include "SplitterTetra.txx" +#include "InterpKernelException.hxx" #include "UnitTetraIntersectionBary.hxx" #include "TetraAffineTransform.hxx" #include "InterpolationUtils.hxx" -#include "SplitterTetra.txx" #include "MCIdType.hxx" -#include +#include +#include using namespace INTERP_KERNEL; @@ -46,8 +49,7 @@ namespace INTERP_TEST // { 1, 2, 3 }, // { 3, 2, 0 } }; bary.init(true); - for ( int i = 0; i < 4; ++i ) { - int* faceNodes = faceConn[ i ]; + for (auto faceNodes : faceConn) { TransformedTriangle tri(nodes[faceNodes[0]], nodes[faceNodes[1]], nodes[faceNodes[2]]); tri.calculateIntersectionVolume(); bary.addSide( tri ); @@ -63,8 +65,8 @@ namespace INTERP_TEST UnitTetraIntersectionBary bary; fill_UnitTetraIntersectionBary(bary,nodes); double baryCenter[3]; - bool ok = bary.getBary( baryCenter ); - double vol = bary.getVolume(); + bool const ok = bary.getBary( baryCenter ); + double const vol = bary.getVolume(); CPPUNIT_ASSERT( ok ); CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.166667, vol, 1e-5); CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.25, baryCenter[0], 1e-5); @@ -81,8 +83,8 @@ namespace INTERP_TEST UnitTetraIntersectionBary bary; fill_UnitTetraIntersectionBary(bary,nodes); double baryCenter[3]; - bool ok = bary.getBary( baryCenter ); - double vol = bary.getVolume(); + bool const ok = bary.getBary( baryCenter ); + double const vol = bary.getVolume(); CPPUNIT_ASSERT( ok ); CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.166667, vol, 1e-5); CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.25, baryCenter[0], 1e-5); @@ -99,8 +101,8 @@ namespace INTERP_TEST UnitTetraIntersectionBary bary; fill_UnitTetraIntersectionBary(bary,nodes); double baryCenter[3]; - bool ok = bary.getBary( baryCenter ); - double vol = bary.getVolume(); + bool const ok = bary.getBary( baryCenter ); + double const vol = bary.getVolume(); CPPUNIT_ASSERT( ok ); CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.020833333333333332, vol, 1e-5); CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.125, baryCenter[0], 1e-5); @@ -117,8 +119,8 @@ namespace INTERP_TEST UnitTetraIntersectionBary bary; fill_UnitTetraIntersectionBary(bary,nodes); double baryCenter[3]; - bool ok = bary.getBary( baryCenter ); - double vol = bary.getVolume(); + bool const ok = bary.getBary( baryCenter ); + double const vol = bary.getVolume(); CPPUNIT_ASSERT( ok ); CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.020833333333333332, vol, 1e-5); CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.125, baryCenter[0], 1e-5); @@ -135,8 +137,8 @@ namespace INTERP_TEST UnitTetraIntersectionBary bary; fill_UnitTetraIntersectionBary(bary,nodes); double baryCenter[3]; - bool ok = bary.getBary( baryCenter ); - double vol = bary.getVolume(); + bool const ok = bary.getBary( baryCenter ); + double const vol = bary.getVolume(); CPPUNIT_ASSERT( ok ); CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.1215, vol, 1e-5); CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.225, baryCenter[0], 1e-5); @@ -153,8 +155,8 @@ namespace INTERP_TEST UnitTetraIntersectionBary bary; fill_UnitTetraIntersectionBary(bary,nodes); double baryCenter[3]; - bool ok = bary.getBary( baryCenter ); - double vol = bary.getVolume(); + bool const ok = bary.getBary( baryCenter ); + double const vol = bary.getVolume(); CPPUNIT_ASSERT( ok ); CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.000441855, vol, 1e-5); CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.353463 , baryCenter[0], 1e-5 ); @@ -171,8 +173,8 @@ namespace INTERP_TEST UnitTetraIntersectionBary bary; fill_UnitTetraIntersectionBary(bary,nodes); double baryCenter[3]; - bool ok = bary.getBary( baryCenter ); - double vol = bary.getVolume(); + bool const ok = bary.getBary( baryCenter ); + double const vol = bary.getVolume(); CPPUNIT_ASSERT( ok ); CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0103501, vol, 1e-5); CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.215578 , baryCenter[0], 1e-5 ); @@ -189,8 +191,8 @@ namespace INTERP_TEST UnitTetraIntersectionBary bary; fill_UnitTetraIntersectionBary(bary,nodes); double baryCenter[3]; - bool ok = bary.getBary( baryCenter ); - double vol = bary.getVolume(); + bool const ok = bary.getBary( baryCenter ); + double const vol = bary.getVolume(); CPPUNIT_ASSERT( ok ); CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0349217, vol, 1e-5); CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.332275 , baryCenter[0], 1e-2 ); @@ -207,8 +209,8 @@ namespace INTERP_TEST UnitTetraIntersectionBary bary; fill_UnitTetraIntersectionBary(bary,nodes); double baryCenter[3]; - bool ok = bary.getBary( baryCenter ); - double vol = bary.getVolume(); + bool const ok = bary.getBary( baryCenter ); + double const vol = bary.getVolume(); CPPUNIT_ASSERT( !ok ); CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, vol, 1e-15); CPPUNIT_ASSERT_DOUBLES_EQUAL( -1. , baryCenter[0], 1e-5 ); @@ -225,8 +227,8 @@ namespace INTERP_TEST UnitTetraIntersectionBary bary; fill_UnitTetraIntersectionBary(bary,nodes); double baryCenter[3]; - bool ok = bary.getBary( baryCenter ); - double vol = bary.getVolume(); + bool const ok = bary.getBary( baryCenter ); + double const vol = bary.getVolume(); CPPUNIT_ASSERT( ok ); CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.166667, vol, 1e-5); CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.25, baryCenter[0], 1e-5); @@ -243,8 +245,8 @@ namespace INTERP_TEST UnitTetraIntersectionBary bary; fill_UnitTetraIntersectionBary(bary,nodes); double baryCenter[3]; - bool ok = bary.getBary( baryCenter ); - double vol = bary.getVolume(); + bool const ok = bary.getBary( baryCenter ); + double const vol = bary.getVolume(); CPPUNIT_ASSERT( ok ); CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.15873 , vol, 1e-5); CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.250000, baryCenter[0], 1e-5); @@ -261,8 +263,8 @@ namespace INTERP_TEST UnitTetraIntersectionBary bary; fill_UnitTetraIntersectionBary(bary,nodes); double baryCenter[3]; - bool ok = bary.getBary( baryCenter ); - double vol = bary.getVolume(); + bool const ok = bary.getBary( baryCenter ); + double const vol = bary.getVolume(); CPPUNIT_ASSERT( ok ); CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.005208 , vol, 1e-5); CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.562500, baryCenter[0], 1e-5); @@ -272,7 +274,7 @@ namespace INTERP_TEST struct __MESH_DUMMY { - typedef mcIdType MyConnType; + using MyConnType = mcIdType; }; void UnitTetraIntersectionBaryTest::test_UnitTetraIntersectionBary_13() @@ -289,12 +291,12 @@ namespace INTERP_TEST 75,150,75, 100,100,100}; - mcIdType conn[4] = { 0,1,2,3 }; + mcIdType const conn[4] = { 0,1,2,3 }; const double* tnodes[4]={ T, T+3, T+6, T+9 }; const double* snodes[4]={ S, S+3, S+6, S+9 }; - __MESH_DUMMY dummyMesh; + __MESH_DUMMY const dummyMesh; SplitterTetra<__MESH_DUMMY> src( dummyMesh, snodes, conn ); double volume = src.intersectTetra( tnodes ); CPPUNIT_ASSERT_DOUBLES_EQUAL(6944.4444444444443,volume,1e-9); @@ -318,19 +320,19 @@ namespace INTERP_TEST 41.6666666666666714036, 120.0, 6.3333333333333348136, 25.0, 120.0, 17.6666666666666714036}; - mcIdType conn[4] = { 0,1,2,3 }; + mcIdType const conn[4] = { 0,1,2,3 }; const double* tnodes[4]={ T, T+3, T+6, T+9 }; const double* snodes[4]={ S, S+3, S+6, S+9 }; const double refVol = 48.6591695501729; - __MESH_DUMMY dummyMesh; + __MESH_DUMMY const dummyMesh; SplitterTetra<__MESH_DUMMY> src( dummyMesh, snodes, conn ); - double volume = src.intersectTetra( tnodes ); + double const volume = src.intersectTetra( tnodes ); CPPUNIT_ASSERT_DOUBLES_EQUAL(refVol,volume,1e-9); // Now the other way round: SplitterTetra<__MESH_DUMMY> tgt( dummyMesh, tnodes, conn ); - double volume2 = tgt.intersectTetra( snodes ); + double const volume2 = tgt.intersectTetra( snodes ); CPPUNIT_ASSERT_DOUBLES_EQUAL(refVol,volume2,1e-9); } @@ -344,7 +346,7 @@ namespace INTERP_TEST // double pSrc[3] = { -4.0, 9.0, 3.0 }; double pSrc[3] = { 40., -20., 100. }; double pDest[] = {1,1,1}; - TetraAffineTransform a(nodes); + TetraAffineTransform const a(nodes); a.apply( pDest, pSrc ); a.reverseApply( pDest, pDest ); CPPUNIT_ASSERT_DOUBLES_EQUAL( pSrc[0], pDest[0], 1e-12); @@ -355,7 +357,7 @@ namespace INTERP_TEST void UnitTetraIntersectionBaryTest::test_barycentric_coords() { // compute barycentric coordinates - double nodes[4][3] = { {11.0, 0.0, 2.0 }, + double const nodes[4][3] = { {11.0, 0.0, 2.0 }, {-4.0, 9.0, 3.0 }, { 0.0, 0.0, 0.0 }, { 6.0, 1.0,10.0 }}; @@ -404,9 +406,9 @@ namespace INTERP_TEST { 1.0, 2.0, 0.0 } }; // Translate cube: - for (int i=0; i < 8; ++i) - for (int j=0; j < 3; ++j) - nodes[i][j] += 15.0; + for (auto & node : nodes) + for (double & j : node) + j += 15.0; std::vector n (8); for (int i=0; i<8; i++) @@ -469,9 +471,9 @@ namespace INTERP_TEST { 1.0, 0.0 } }; // Translate quad4: - for (int i=0; i < 4; ++i) - for (int j=0; j < 2; ++j) - nodes[i][j] += 15.0; + for (auto & node : nodes) + for (double & j : node) + j += 15.0; std::vector n (4); for (int i=0; i<4; i++) diff --git a/src/INTERP_KERNELTest/UnitTetraIntersectionBaryTest.hxx b/src/INTERP_KERNELTest/UnitTetraIntersectionBaryTest.hxx index ab7dcecbd..ac706b774 100644 --- a/src/INTERP_KERNELTest/UnitTetraIntersectionBaryTest.hxx +++ b/src/INTERP_KERNELTest/UnitTetraIntersectionBaryTest.hxx @@ -24,6 +24,7 @@ #ifndef __UNITTETRAINTERSECTIONBARYTEST_HXX__ #define __UNITTETRAINTERSECTIONBARYTEST_HXX__ +#include #include #include "InterpKernelTestExport.hxx" diff --git a/src/MEDCoupling/MCAuto.hxx b/src/MEDCoupling/MCAuto.hxx index 75b4827ce..748e05335 100644 --- a/src/MEDCoupling/MCAuto.hxx +++ b/src/MEDCoupling/MCAuto.hxx @@ -20,9 +20,9 @@ #pragma once -#include "MEDCouplingRefCountObject.hxx" #include "InterpKernelException.hxx" +#include #include #include diff --git a/src/MEDCoupling/MCAuto.txx b/src/MEDCoupling/MCAuto.txx index 903431054..8b4e58141 100644 --- a/src/MEDCoupling/MCAuto.txx +++ b/src/MEDCoupling/MCAuto.txx @@ -23,6 +23,7 @@ #include "MCAuto.hxx" +#include #include namespace MEDCoupling diff --git a/src/MEDCoupling/MCType.hxx b/src/MEDCoupling/MCType.hxx index 0dfa1f0b0..5d2990aae 100644 --- a/src/MEDCoupling/MCType.hxx +++ b/src/MEDCoupling/MCType.hxx @@ -24,7 +24,6 @@ #include #include -#include namespace MEDCoupling { diff --git a/src/MEDCoupling/MEDCoupling1GTUMesh.cxx b/src/MEDCoupling/MEDCoupling1GTUMesh.cxx index cdcb07682..45b446c4b 100644 --- a/src/MEDCoupling/MEDCoupling1GTUMesh.cxx +++ b/src/MEDCoupling/MEDCoupling1GTUMesh.cxx @@ -18,22 +18,46 @@ // // Author : Anthony Geay (EDF R&D) +#include "CellModel.hxx" +#include "MEDCouplingPointSet.hxx" #include "MEDCoupling1GTUMesh.txx" +#include "MCAuto.hxx" +#include "MCIdType.hxx" +#include "MCType.hxx" +#include "MEDCouplingMemArray.hxx" +#include "MEDCouplingMesh.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include "InterpKernelHashMap.hxx" +#include "InterpKernelException.hxx" +#include "MEDCouplingStructuredMesh.hxx" #include "MEDCouplingUMesh.hxx" #include "MEDCouplingFieldDouble.hxx" #include "MEDCouplingCMesh.hxx" -#include "SplitterTetra.hxx" +#include "NormalizedGeometricTypes" +#include "SplitterTetra.txx" #include "DiameterCalculator.hxx" #include "OrientationInverter.hxx" #include "InterpKernelAutoPtr.hxx" #include "VolSurfUser.txx" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include using namespace MEDCoupling; const int MEDCoupling1SGTUMesh::HEXA8_FACE_PAIRS[6]={0,1,2,4,3,5}; -MEDCoupling1GTUMesh::MEDCoupling1GTUMesh():_cm(0) +MEDCoupling1GTUMesh::MEDCoupling1GTUMesh():_cm(nullptr) { } @@ -61,7 +85,7 @@ MEDCoupling1GTUMesh *MEDCoupling1GTUMesh::New(const MEDCouplingUMesh *m) { if(!m) throw INTERP_KERNEL::Exception("MEDCoupling1GTUMesh::New : input mesh is null !"); - std::set gts(m->getAllGeoTypes()); + std::set const gts(m->getAllGeoTypes()); if(gts.size()!=1) throw INTERP_KERNEL::Exception("MEDCoupling1GTUMesh::New : input mesh must have exactly one geometric type !"); const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*gts.begin()); @@ -211,7 +235,7 @@ void MEDCoupling1GTUMesh::splitProfilePerType(const DataArrayIdType *profile, st */ DataArrayIdType *MEDCoupling1GTUMesh::checkTypeConsistencyAndContig(const std::vector& code, const std::vector& idsPerType) const { - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbOfCells=getNumberOfCells(); if(code.size()!=3) throw INTERP_KERNEL::Exception("MEDCoupling1GTUMesh::checkTypeConsistencyAndContig : invalid input code should be exactly of size 3 !"); if(code[0]!=ToIdType(getCellModelEnum())) @@ -222,7 +246,7 @@ DataArrayIdType *MEDCoupling1GTUMesh::checkTypeConsistencyAndContig(const std::v if(code[2]==-1) { if(code[1]==nbOfCells) - return 0; + return nullptr; else { std::ostringstream oss; oss << "MEDCoupling1GTUMesh::checkTypeConsistencyAndContig : mismatch between the number of cells in this (" << nbOfCells << ") and the number of non profile (" << code[1] << ") !"; @@ -270,7 +294,7 @@ bool MEDCoupling1GTUMesh::isEqualIfNotWhy(const MEDCouplingMesh *other, double p return false; if(!other) throw INTERP_KERNEL::Exception("MEDCoupling1GTUMesh::isEqualIfNotWhy : input other pointer is null !"); - const MEDCoupling1GTUMesh *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) { reason="mesh given in input is not castable in MEDCouplingSGTUMesh !"; @@ -290,7 +314,7 @@ bool MEDCoupling1GTUMesh::isEqualWithoutConsideringStr(const MEDCouplingMesh *ot return false; if(!other) throw INTERP_KERNEL::Exception("MEDCoupling1GTUMesh::isEqualWithoutConsideringStr : input other pointer is null !"); - const MEDCoupling1GTUMesh *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) return false; if(_cm!=otherC->_cm) @@ -430,34 +454,34 @@ MEDCouplingUMesh *MEDCoupling1GTUMesh::AggregateOnSameCoordsToUMesh(const std::v if(!firstPart) throw INTERP_KERNEL::Exception("MEDCoupling1GTUMesh::AggregateOnSameCoordsToUMesh : the first instance in input parts is null !"); const DataArrayDouble *coords(firstPart->getCoords()); - int meshDim(firstPart->getMeshDimension()); + int const meshDim(firstPart->getMeshDimension()); MCAuto ret(MEDCouplingUMesh::New(firstPart->getName(),meshDim)); ret->setDescription(firstPart->getDescription()); ret->setCoords(coords); mcIdType nbOfCells(0),connSize(0); - for(std::vector< const MEDCoupling1GTUMesh *>::const_iterator it=parts.begin();it!=parts.end();it++) + for(auto part : parts) { - if(!(*it)) + if(!part) throw INTERP_KERNEL::Exception("MEDCoupling1GTUMesh::AggregateOnSameCoordsToUMesh : presence of null pointer in input vector !"); - if((*it)->getMeshDimension()!=meshDim) + if(part->getMeshDimension()!=meshDim) throw INTERP_KERNEL::Exception("MEDCoupling1GTUMesh::AggregateOnSameCoordsToUMesh : all the instances in input vector must have same mesh dimension !"); - if((*it)->getCoords()!=coords) + if(part->getCoords()!=coords) throw INTERP_KERNEL::Exception("MEDCoupling1GTUMesh::AggregateOnSameCoordsToUMesh : all the instances must share the same coordinates pointer !"); - nbOfCells+=(*it)->getNumberOfCells(); - connSize+=(*it)->getNodalConnectivityLength(); + nbOfCells+=part->getNumberOfCells(); + connSize+=part->getNodalConnectivityLength(); } MCAuto conn(DataArrayIdType::New()),connI(DataArrayIdType::New()); connI->alloc(nbOfCells+1,1); conn->alloc(connSize+nbOfCells,1); mcIdType *c(conn->getPointer()),*ci(connI->getPointer()); *ci=0; - for(std::vector< const MEDCoupling1GTUMesh *>::const_iterator it=parts.begin();it!=parts.end();it++) + for(auto part : parts) { - mcIdType curNbCells=(*it)->getNumberOfCells(); - mcIdType geoType(ToIdType((*it)->getCellModelEnum())); - const mcIdType *cinPtr((*it)->getNodalConnectivity()->begin()); - const MEDCoupling1SGTUMesh *ps(dynamic_cast(*it)); - const MEDCoupling1DGTUMesh *pd(dynamic_cast(*it)); + mcIdType const curNbCells=part->getNumberOfCells(); + mcIdType const geoType(ToIdType(part->getCellModelEnum())); + const mcIdType *cinPtr(part->getNodalConnectivity()->begin()); + const auto *ps(dynamic_cast(part)); + const auto *pd(dynamic_cast(part)); if(ps && !pd) { - mcIdType nNodesPerCell(ps->getNumberOfNodesPerCell()); + mcIdType const nNodesPerCell(ps->getNumberOfNodesPerCell()); for(int i=0;i gts(m->getAllGeoTypes()); + std::set const gts(m->getAllGeoTypes()); if(gts.size()!=1) throw INTERP_KERNEL::Exception("MEDCoupling1SGTUMesh::New : input mesh must have exactly one geometric type !"); - mcIdType geoType(ToIdType(*gts.begin())); + mcIdType const geoType(ToIdType(*gts.begin())); MCAuto ret(MEDCoupling1SGTUMesh::New(m->getName(),*gts.begin())); ret->setCoords(m->getCoords()); ret->setDescription(m->getDescription()); - mcIdType nbCells=m->getNumberOfCells(); - mcIdType nbOfNodesPerCell(ret->getNumberOfNodesPerCell()); + mcIdType const nbCells=m->getNumberOfCells(); + mcIdType const nbOfNodesPerCell(ret->getNumberOfNodesPerCell()); MCAuto conn(DataArrayIdType::New()); conn->alloc(nbCells*nbOfNodesPerCell,1); mcIdType *c(conn->getPointer()); const mcIdType *cin(m->getNodalConnectivity()->begin()),*ciin(m->getNodalConnectivityIndex()->begin()); @@ -585,7 +608,7 @@ void MEDCoupling1SGTUMesh::shallowCopyConnectivityFrom(const MEDCouplingPointSet { if(!other) throw INTERP_KERNEL::Exception("MEDCoupling1SGTUMesh::shallowCopyConnectivityFrom : input pointer is null !"); - const MEDCoupling1SGTUMesh *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("MEDCoupling1SGTUMesh::shallowCopyConnectivityFrom : input pointer is not an MEDCoupling1SGTUMesh instance !"); setNodalConnectivity(otherC->getNodalConnectivity()); @@ -621,7 +644,7 @@ bool MEDCoupling1SGTUMesh::isEqualIfNotWhy(const MEDCouplingMesh *other, double if(!other) throw INTERP_KERNEL::Exception("MEDCoupling1SGTUMesh::isEqualIfNotWhy : input other pointer is null !"); std::ostringstream oss; oss.precision(15); - const MEDCoupling1SGTUMesh *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) { reason="mesh given in input is not castable in MEDCoupling1SGTUMesh !"; @@ -649,7 +672,7 @@ bool MEDCoupling1SGTUMesh::isEqualWithoutConsideringStr(const MEDCouplingMesh *o { if(!other) throw INTERP_KERNEL::Exception("MEDCoupling1SGTUMesh::isEqualWithoutConsideringStr : input other pointer is null !"); - const MEDCoupling1SGTUMesh *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) return false; if(!MEDCoupling1GTUMesh::isEqualWithoutConsideringStr(other,prec)) @@ -685,19 +708,19 @@ void MEDCoupling1SGTUMesh::checkConsistencyLight() const checkConsistencyOfConnectivity(); } -void MEDCoupling1SGTUMesh::checkConsistency(double eps) const +void MEDCoupling1SGTUMesh::checkConsistency(double /*eps*/) const { checkConsistencyLight(); const DataArrayIdType *c1(_conn); - mcIdType nbOfTuples(c1->getNumberOfTuples()); - mcIdType nbOfNodesPerCell=_cm->getNumberOfNodes(); + mcIdType const nbOfTuples(c1->getNumberOfTuples()); + mcIdType const nbOfNodesPerCell=_cm->getNumberOfNodes(); if(nbOfTuples%nbOfNodesPerCell!=0) { std::ostringstream oss; oss << "MEDCoupling1SGTUMesh::checkConsistency : the nb of tuples in conn is " << nbOfTuples << " and number of nodes per cell is " << nbOfNodesPerCell << ". But " << nbOfTuples << "%" << nbOfNodesPerCell << " !=0 !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - mcIdType nbOfNodes=getNumberOfNodes(); - mcIdType nbOfCells=nbOfTuples/nbOfNodesPerCell; + mcIdType const nbOfNodes=getNumberOfNodes(); + mcIdType const nbOfCells=nbOfTuples/nbOfNodesPerCell; const mcIdType *w(c1->begin()); for(mcIdType i=0;i ret=DataArrayIdType::New(); - mcIdType nbCells=getNumberOfCells(); + mcIdType const nbCells=getNumberOfCells(); ret->alloc(nbCells,1); mcIdType *retPtr(ret->getPointer()); - mcIdType nbNodesPerCell(getNumberOfNodesPerCell()); + mcIdType const nbNodesPerCell(getNumberOfNodesPerCell()); const mcIdType *conn(_conn->begin()); for(mcIdType i=0;i s(conn,conn+nbNodesPerCell); + std::set const s(conn,conn+nbNodesPerCell); *retPtr=ToIdType(s.size()); } return ret.retn(); @@ -770,7 +793,7 @@ DataArrayIdType *MEDCoupling1SGTUMesh::computeEffectiveNbOfNodesPerCell() const void MEDCoupling1SGTUMesh::getNodeIdsOfCell(mcIdType cellId, std::vector& conn) const { - mcIdType sz=getNumberOfNodesPerCell(); + mcIdType const sz=getNumberOfNodesPerCell(); conn.resize(sz); if(cellIdbegin()+cellId*sz,_conn->begin()+(cellId+1)*sz,conn.begin()); @@ -799,11 +822,11 @@ std::string MEDCoupling1SGTUMesh::simpleRepr() const ret << "Single static geometic type (" << _cm->getRepr() << ") unstructured mesh with name : \"" << getName() << "\"\n"; ret << "Description of mesh : \"" << getDescription() << "\"\n"; int tmpp1,tmpp2; - double tt=getTime(tmpp1,tmpp2); + double const tt=getTime(tmpp1,tmpp2); ret << "Time attached to the mesh [unit] : " << tt << " [" << getTimeUnit() << "]\n"; ret << "Iteration : " << tmpp1 << " Order : " << tmpp2 << "\n"; ret << "Mesh dimension : " << getMeshDimension() << "\nSpace dimension : "; - if(_coords!=0) + if(_coords!=nullptr) { const int spaceDim=getSpaceDimension(); ret << spaceDim << "\nInfo attached on space dimension : "; @@ -814,7 +837,7 @@ std::string MEDCoupling1SGTUMesh::simpleRepr() const else ret << msg0 << "\n"; ret << "Number of nodes : "; - if(_coords!=0) + if(_coords!=nullptr) ret << getNumberOfNodes() << "\n"; else ret << msg0 << "\n"; @@ -854,8 +877,8 @@ std::string MEDCoupling1SGTUMesh::advancedRepr() const { if(_conn->getNumberOfComponents()==1) { - mcIdType nbOfCells=getNumberOfCells(); - mcIdType sz=getNumberOfNodesPerCell(); + mcIdType const nbOfCells=getNumberOfCells(); + mcIdType const sz=getNumberOfNodesPerCell(); const mcIdType *connPtr=_conn->begin(); for(mcIdType i=0;i ret=DataArrayDouble::New(); - int spaceDim=getSpaceDimension(); - mcIdType nbOfCells=getNumberOfCells();//checkConsistencyLight() - mcIdType nbOfNodes=getNumberOfNodes(); + int const spaceDim=getSpaceDimension(); + mcIdType const nbOfCells=getNumberOfCells();//checkConsistencyLight() + mcIdType const nbOfNodes=getNumberOfNodes(); ret->alloc(nbOfCells,spaceDim); double *ptToFill=ret->getPointer(); const double *coor=_coords->begin(); const mcIdType *nodal=_conn->begin(); - mcIdType sz=getNumberOfNodesPerCell(); - double coeff=1./FromIdType(sz); + mcIdType const sz=getNumberOfNodesPerCell(); + double const coeff=1./FromIdType(sz); for(mcIdType i=0;i o2n=DataArrayIdType::New(); o2n->useArray(old2NewBg,false,DeallocType::C_DEALLOC,nbCells,1); if(check) @@ -917,12 +940,12 @@ void MEDCoupling1SGTUMesh::renumberCells(const mcIdType *old2NewBg, bool check) MCAuto newConn=DataArrayIdType::New(); newConn->alloc(_conn->getNumberOfTuples(),1); newConn->copyStringInfoFrom(*_conn); - mcIdType sz=getNumberOfNodesPerCell(); + mcIdType const sz=getNumberOfNodesPerCell(); // mcIdType *newC=newConn->getPointer(); for(mcIdType i=0;i cellIdsKept=DataArrayIdType::New(); cellIdsKept->alloc(0,1); mcIdType tmp=-1; mcIdType sz=_conn->getMaxValue(tmp); sz=std::max(sz,ToIdType(0))+1; @@ -950,7 +973,7 @@ void MEDCoupling1SGTUMesh::fillCellIdsToKeepFromNodeIds(const mcIdType *begin, c if(*work>=0 && *workbegin(); - mcIdType nbNodesPerCell=getNumberOfNodesPerCell(); + mcIdType const nbNodesPerCell=getNumberOfNodesPerCell(); for(mcIdType i=0;igetType()!=SINGLE_STATIC_GEO_TYPE_UNSTRUCTURED) throw INTERP_KERNEL::Exception("Merge of umesh only available with umesh single static geo type each other !"); - const MEDCoupling1SGTUMesh *otherC=static_cast(other); + const auto *otherC=static_cast(other); return Merge1SGTUMeshes(this,otherC); } @@ -980,9 +1003,9 @@ MEDCouplingUMesh *MEDCoupling1SGTUMesh::buildUnstructured() const MCAuto ret=MEDCouplingUMesh::New(getName(),getMeshDimension()); ret->setCoords(getCoords()); const mcIdType *nodalConn=_conn->begin(); - mcIdType nbCells=getNumberOfCells(); - mcIdType nbNodesPerCell=getNumberOfNodesPerCell(); - mcIdType geoType=ToIdType(getCellModelEnum()); + mcIdType const nbCells=getNumberOfCells(); + mcIdType const nbNodesPerCell=getNumberOfNodesPerCell(); + mcIdType const geoType=ToIdType(getCellModelEnum()); MCAuto c=DataArrayIdType::New(); c->alloc(nbCells*(nbNodesPerCell+1),1); mcIdType *cPtr=c->getPointer(); for(mcIdType i=0;i fetchedNodes(nbNodes,false); computeNodeIdsAlg(fetchedNodes); - mcIdType sz(ToIdType(std::count(fetchedNodes.begin(),fetchedNodes.end(),true))); + mcIdType const sz(ToIdType(std::count(fetchedNodes.begin(),fetchedNodes.end(),true))); MCAuto ret(DataArrayIdType::New()); ret->alloc(sz,1); mcIdType *retPtr(ret->getPointer()); for(mcIdType i=0;i ret(DataArrayIdType::New()); ret->alloc(nbOfNodes,1); mcIdType *traducer=ret->getPointer(); std::fill(traducer,traducer+nbOfNodes,-1); const mcIdType *conn=_conn->begin(); - mcIdType nbNodesPerCell=getNumberOfNodesPerCell(); + mcIdType const nbNodesPerCell=getNumberOfNodesPerCell(); for(mcIdType i=0;i=0 && *conn& a) { - std::size_t sz=a.size(); + std::size_t const sz=a.size(); if(sz==0) return Merge1SGTUMeshesLL(a); for(std::size_t ii=0;ii::const_iterator it=a.begin(); mcIdType nbOfCells=(*it)->getNumberOfCells(); const INTERP_KERNEL::CellModel *cm=&((*it)->getCellModel()); - mcIdType nbNodesPerCell=(*it)->getNumberOfNodesPerCell(); + mcIdType const nbNodesPerCell=(*it)->getNumberOfNodesPerCell(); it++; for(;it!=a.end();it++) { @@ -1245,7 +1268,7 @@ MEDCoupling1SGTUMesh *MEDCoupling1SGTUMesh::Merge1SGTUMeshesLL(std::vectorgetNodalConnectivityLength(); + mcIdType const curConnLgth=(*it)->getNodalConnectivityLength(); const mcIdType *curC=(*it)->_conn->begin(); cPtr=std::transform(curC,curC+curConnLgth,cPtr,std::bind(std::plus(),std::placeholders::_1,offset)); offset+=(*it)->getNumberOfNodes(); @@ -1257,12 +1280,12 @@ MEDCoupling1SGTUMesh *MEDCoupling1SGTUMesh::Merge1SGTUMeshesLL(std::vector ret(new MEDCoupling1SGTUMesh(getName(),*_cm)); ret->setCoords(_coords); - std::size_t nbOfElemsRet=std::distance(begin,end); + std::size_t const nbOfElemsRet=std::distance(begin,end); const mcIdType *inConn=_conn->getConstPointer(); - mcIdType sz=getNumberOfNodesPerCell(); + mcIdType const sz=getNumberOfNodesPerCell(); MCAuto connRet=DataArrayIdType::New(); connRet->alloc(nbOfElemsRet*sz,1); mcIdType *connPtr=connRet->getPointer(); for(const mcIdType *work=begin;work!=end;work++,connPtr+=sz) @@ -1282,12 +1305,12 @@ MEDCouplingPointSet *MEDCoupling1SGTUMesh::buildPartOfMySelfKeepCoords(const mcI MEDCouplingPointSet *MEDCoupling1SGTUMesh::buildPartOfMySelfKeepCoordsSlice(mcIdType start, mcIdType end, mcIdType step) const { - mcIdType ncell=getNumberOfCells(); - mcIdType nbOfElemsRet=DataArray::GetNumberOfItemGivenBESRelative(start,end,step,"MEDCoupling1SGTUMesh::buildPartOfMySelfKeepCoordsSlice : "); + mcIdType const ncell=getNumberOfCells(); + mcIdType const nbOfElemsRet=DataArray::GetNumberOfItemGivenBESRelative(start,end,step,"MEDCoupling1SGTUMesh::buildPartOfMySelfKeepCoordsSlice : "); MCAuto ret(new MEDCoupling1SGTUMesh(getName(),*_cm)); ret->setCoords(_coords); const mcIdType *inConn=_conn->getConstPointer(); - mcIdType sz=getNumberOfNodesPerCell(); + mcIdType const sz=getNumberOfNodesPerCell(); MCAuto connRet=DataArrayIdType::New(); connRet->alloc(nbOfElemsRet*sz,1); mcIdType *connPtr=connRet->getPointer(); mcIdType curId=start; @@ -1308,7 +1331,7 @@ MEDCouplingPointSet *MEDCoupling1SGTUMesh::buildPartOfMySelfKeepCoordsSlice(mcId void MEDCoupling1SGTUMesh::computeNodeIdsAlg(std::vector& nodeIdsInUse) const { - mcIdType sz(ToIdType(nodeIdsInUse.size())); + mcIdType const sz(ToIdType(nodeIdsInUse.size())); for(const mcIdType *conn=_conn->begin();conn!=_conn->end();conn++) { if(*conn>=0 && *conn newConn=DataArrayIdType::New(); newConn->alloc(2*3*nbOfCells,1); @@ -1366,7 +1389,7 @@ DataArrayIdType *MEDCoupling1SGTUMesh::simplexizePol0() DataArrayIdType *MEDCoupling1SGTUMesh::simplexizePol1() { - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbOfCells=getNumberOfCells(); if(getCellModelEnum()!=INTERP_KERNEL::NORM_QUAD4) return DataArrayIdType::Range(0,nbOfCells,1); MCAuto newConn=DataArrayIdType::New(); newConn->alloc(2*3*nbOfCells,1); @@ -1387,7 +1410,7 @@ DataArrayIdType *MEDCoupling1SGTUMesh::simplexizePol1() DataArrayIdType *MEDCoupling1SGTUMesh::simplexizePlanarFace5() { - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbOfCells=getNumberOfCells(); if(getCellModelEnum()!=INTERP_KERNEL::NORM_HEXA8) return DataArrayIdType::Range(0,nbOfCells,1); MCAuto newConn=DataArrayIdType::New(); newConn->alloc(5*4*nbOfCells,1); @@ -1408,7 +1431,7 @@ DataArrayIdType *MEDCoupling1SGTUMesh::simplexizePlanarFace5() DataArrayIdType *MEDCoupling1SGTUMesh::simplexizePlanarFace6() { - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbOfCells=getNumberOfCells(); if(getCellModelEnum()!=INTERP_KERNEL::NORM_HEXA8) return DataArrayIdType::Range(0,nbOfCells,1); MCAuto newConn=DataArrayIdType::New(); newConn->alloc(6*4*nbOfCells,1); @@ -1461,7 +1484,7 @@ void MEDCoupling1SGTUMesh::checkFullyDefined() const /*! * First step of unserialization process. */ -bool MEDCoupling1SGTUMesh::isEmptyMesh(const std::vector& tinyInfo) const +bool MEDCoupling1SGTUMesh::isEmptyMesh(const std::vector& /*tinyInfo*/) const { throw INTERP_KERNEL::Exception("MEDCoupling1SGTUMesh::isEmptyMesh : not implemented yet !"); } @@ -1469,7 +1492,7 @@ bool MEDCoupling1SGTUMesh::isEmptyMesh(const std::vector& tinyInfo) co void MEDCoupling1SGTUMesh::getTinySerializationInformation(std::vector& tinyInfoD, std::vector& tinyInfo, std::vector& littleStrings) const { int it,order; - double time=getTime(it,order); + double const time=getTime(it,order); tinyInfo.clear(); tinyInfoD.clear(); littleStrings.clear(); // littleStrings.push_back(getName()); @@ -1501,10 +1524,10 @@ void MEDCoupling1SGTUMesh::getTinySerializationInformation(std::vector& tinyInfoD.push_back(time); } -void MEDCoupling1SGTUMesh::resizeForUnserialization(const std::vector& tinyInfo, DataArrayIdType *a1, DataArrayDouble *a2, std::vector& littleStrings) const +void MEDCoupling1SGTUMesh::resizeForUnserialization(const std::vector& tinyInfo, DataArrayIdType *a1, DataArrayDouble *a2, std::vector& /*littleStrings*/) const { - std::vector tinyInfo2(tinyInfo.begin()+7,tinyInfo.begin()+7+tinyInfo[5]); - std::vector tinyInfo1(tinyInfo.begin()+7+tinyInfo[5],tinyInfo.begin()+7+tinyInfo[5]+tinyInfo[6]); + std::vector const tinyInfo2(tinyInfo.begin()+7,tinyInfo.begin()+7+tinyInfo[5]); + std::vector const tinyInfo1(tinyInfo.begin()+7+tinyInfo[5],tinyInfo.begin()+7+tinyInfo[5]+tinyInfo[6]); a1->resizeForUnserialization(tinyInfo1); a2->resizeForUnserialization(tinyInfo2); } @@ -1532,7 +1555,7 @@ void MEDCoupling1SGTUMesh::serialize(DataArrayIdType *&a1, DataArrayDouble *&a2) void MEDCoupling1SGTUMesh::unserialization(const std::vector& tinyInfoD, const std::vector& tinyInfo, const DataArrayIdType *a1, DataArrayDouble *a2, const std::vector& littleStrings) { - INTERP_KERNEL::NormalizedCellType gt((INTERP_KERNEL::NormalizedCellType)tinyInfo[0]); + auto const gt((INTERP_KERNEL::NormalizedCellType)tinyInfo[0]); _cm=&INTERP_KERNEL::CellModel::GetCellModel(gt); setName(littleStrings[0]); setDescription(littleStrings[1]); @@ -1541,16 +1564,16 @@ void MEDCoupling1SGTUMesh::unserialization(const std::vector& tinyInfoD, mcIdType sz0(tinyInfo[3]),sz1(tinyInfo[4]),sz2(tinyInfo[5]),sz3(tinyInfo[6]); // _coords=DataArrayDouble::New(); - std::vector tinyInfo2(tinyInfo.begin()+7,tinyInfo.begin()+7+sz2); + std::vector const tinyInfo2(tinyInfo.begin()+7,tinyInfo.begin()+7+sz2); _coords->resizeForUnserialization(tinyInfo2); std::copy(a2->begin(),a2->end(),_coords->getPointer()); _conn=DataArrayIdType::New(); - std::vector tinyInfo3(tinyInfo.begin()+7+sz2,tinyInfo.begin()+7+sz2+sz3); + std::vector const tinyInfo3(tinyInfo.begin()+7+sz2,tinyInfo.begin()+7+sz2+sz3); _conn->resizeForUnserialization(tinyInfo3); std::copy(a1->begin(),a1->end(),_conn->getPointer()); - std::vector littleStrings2(littleStrings.begin()+3,littleStrings.begin()+3+sz0); + std::vector const littleStrings2(littleStrings.begin()+3,littleStrings.begin()+3+sz0); _coords->finishUnserialization(tinyInfo2,littleStrings2); - std::vector littleStrings3(littleStrings.begin()+3+sz0,littleStrings.begin()+3+sz0+sz1); + std::vector const littleStrings3(littleStrings.begin()+3+sz0,littleStrings.begin()+3+sz0+sz1); _conn->finishUnserialization(tinyInfo3,littleStrings3); } @@ -1567,7 +1590,7 @@ void MEDCoupling1SGTUMesh::unserialization(const std::vector& tinyInfoD, void MEDCoupling1SGTUMesh::checkFastEquivalWith(const MEDCouplingMesh *other, double prec) const { MEDCouplingPointSet::checkFastEquivalWith(other,prec); - const MEDCoupling1SGTUMesh *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("MEDCoupling1SGTUMesh::checkFastEquivalWith : Two meshes are not unstructured with single static geometric type !"); const DataArrayIdType *c1(_conn),*c2(otherC->_conn); @@ -1587,7 +1610,7 @@ MEDCouplingPointSet *MEDCoupling1SGTUMesh::mergeMyselfWithOnSameCoords(const MED { if(!other) throw INTERP_KERNEL::Exception("MEDCoupling1SGTUMesh::mergeMyselfWithOnSameCoords : input other is null !"); - const MEDCoupling1SGTUMesh *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("MEDCoupling1SGTUMesh::mergeMyselfWithOnSameCoords : the input other mesh is not of type single statuc geo type unstructured !"); std::vector ms(2); @@ -1599,14 +1622,14 @@ MEDCouplingPointSet *MEDCoupling1SGTUMesh::mergeMyselfWithOnSameCoords(const MED void MEDCoupling1SGTUMesh::getReverseNodalConnectivity(DataArrayIdType *revNodal, DataArrayIdType *revNodalIndx) const { checkFullyDefined(); - mcIdType nbOfNodes=getNumberOfNodes(); - mcIdType *revNodalIndxPtr=(mcIdType *)malloc((nbOfNodes+1)*sizeof(mcIdType)); + mcIdType const nbOfNodes=getNumberOfNodes(); + auto *revNodalIndxPtr=(mcIdType *)malloc((nbOfNodes+1)*sizeof(mcIdType)); revNodalIndx->useArray(revNodalIndxPtr,true,DeallocType::C_DEALLOC,nbOfNodes+1,1); std::fill(revNodalIndxPtr,revNodalIndxPtr+nbOfNodes+1,0); const mcIdType *conn=_conn->begin(); - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbOfCells=getNumberOfCells(); mcIdType nbOfEltsInRevNodal=0; - mcIdType nbOfNodesPerCell=getNumberOfNodesPerCell(); + mcIdType const nbOfNodesPerCell=getNumberOfNodesPerCell(); for(mcIdType eltId=0;eltId()); conn=_conn->begin(); - mcIdType *revNodalPtr=(mcIdType *)malloc(nbOfEltsInRevNodal*sizeof(mcIdType)); + auto *revNodalPtr=(mcIdType *)malloc(nbOfEltsInRevNodal*sizeof(mcIdType)); revNodal->useArray(revNodalPtr,true,DeallocType::C_DEALLOC,nbOfEltsInRevNodal,1); std::fill(revNodalPtr,revNodalPtr+nbOfEltsInRevNodal,-1); for(mcIdType eltId=0;eltIdbegin()); MCAuto ret(MEDCoupling1SGTUMesh::New(getName(),INTERP_KERNEL::NORM_QUAD4)); MCAuto c(DataArrayIdType::New()); c->alloc(nbHexa8*6*4,1); @@ -1768,7 +1791,7 @@ MCAuto MEDCoupling1SGTUMesh::computeTriangleHeight() const if(cm.getEnum()!=INTERP_KERNEL::NORM_TRI3) THROW_IK_EXCEPTION("MEDCoupling1SGTUMesh::computeTriangleHeight : this method can be applied only on TRI3 mesh !"); MCAuto ret(DataArrayDouble::New()); - mcIdType nbTri3( getNumberOfCells() ); + mcIdType const nbTri3( getNumberOfCells() ); const double *coordPtr( this->getCoords()->begin() ); const mcIdType *inConnPtr(getNodalConnectivity()->begin()); ret->alloc(nbTri3,3); @@ -1814,13 +1837,13 @@ MCAuto MEDCoupling1SGTUMesh::computeTriangleHeight() const MEDCouplingCMesh *MEDCoupling1SGTUMesh::structurizeMe(DataArrayIdType *& cellPerm, DataArrayIdType *& nodePerm, double eps) const { checkConsistencyLight(); - int spaceDim(getSpaceDimension()),meshDim(getMeshDimension()); mcIdType nbNodes(getNumberOfNodes()); + int spaceDim(getSpaceDimension()),meshDim(getMeshDimension()); mcIdType const nbNodes(getNumberOfNodes()); if(MEDCouplingStructuredMesh::GetGeoTypeGivenMeshDimension(meshDim)!=getCellModelEnum()) throw INTERP_KERNEL::Exception("MEDCoupling1SGTUMesh::structurizeMe : the unique geo type in this is not compatible with the geometric type regarding mesh dimension !"); MCAuto cm(MEDCouplingCMesh::New()); for(int i=0;i tmp(1,i); + std::vector const tmp(1,i); MCAuto elt(static_cast(getCoords()->keepSelectedComponents(tmp))); elt=elt->getDifferentValues(eps); elt->sort(true); @@ -1851,10 +1874,10 @@ bool UpdateHexa8Cell(int validAxis, mcIdType neighId, const mcIdType *validConnQ static const int TAB2[6]={0,0,3,3,3,3}; if(myNeighbours[validAxis]==neighId && allFacesNodalConn[4*validAxis+0]==validConnQuad4NeighSide[TAB2[validAxis]]) return true; - mcIdType oldAxis(ToIdType(std::distance(myNeighbours,std::find(myNeighbours,myNeighbours+6,neighId)))); - std::size_t pos(std::distance(MEDCoupling1SGTUMesh::HEXA8_FACE_PAIRS,std::find(MEDCoupling1SGTUMesh::HEXA8_FACE_PAIRS,MEDCoupling1SGTUMesh::HEXA8_FACE_PAIRS+6,oldAxis))); + mcIdType const oldAxis(ToIdType(std::distance(myNeighbours,std::find(myNeighbours,myNeighbours+6,neighId)))); + std::size_t const pos(std::distance(MEDCoupling1SGTUMesh::HEXA8_FACE_PAIRS,std::find(MEDCoupling1SGTUMesh::HEXA8_FACE_PAIRS,MEDCoupling1SGTUMesh::HEXA8_FACE_PAIRS+6,oldAxis))); std::size_t pos0(pos/2),pos1(pos%2); - int oldAxisOpp(MEDCoupling1SGTUMesh::HEXA8_FACE_PAIRS[2*pos0+(pos1+1)%2]); + int const oldAxisOpp(MEDCoupling1SGTUMesh::HEXA8_FACE_PAIRS[2*pos0+(pos1+1)%2]); mcIdType oldConn[8],myConn2[8]={-1,-1,-1,-1,-1,-1,-1,-1},myConn[8],edgeConn[2],allFacesTmp[24],neighTmp[6]; oldConn[0]=allFacesNodalConn[0]; oldConn[1]=allFacesNodalConn[1]; oldConn[2]=allFacesNodalConn[2]; oldConn[3]=allFacesNodalConn[3]; oldConn[4]=allFacesNodalConn[4]; oldConn[5]=allFacesNodalConn[7]; oldConn[6]=allFacesNodalConn[6]; oldConn[7]=allFacesNodalConn[5]; @@ -1863,7 +1886,7 @@ bool UpdateHexa8Cell(int validAxis, mcIdType neighId, const mcIdType *validConnQ myConn2[i]=validConnQuad4NeighSide[(4-i+TAB2[validAxis])%4]; for(int i=0;i<4;i++) { - mcIdType nodeId(myConn2[i]);//the node id for which the opposite one will be found + mcIdType const nodeId(myConn2[i]);//the node id for which the opposite one will be found bool found(false); INTERP_KERNEL::NormalizedCellType typeOfSon; for(int j=0;j<12 && !found;j++) @@ -1887,11 +1910,11 @@ bool UpdateHexa8Cell(int validAxis, mcIdType neighId, const mcIdType *validConnQ for(int i=0;i<6;i++) { cm.fillSonCellNodalConnectivity(i,myConn,allFacesTmp+4*i); - std::set s(allFacesTmp+4*i,allFacesTmp+4*i+4); + std::set const s(allFacesTmp+4*i,allFacesTmp+4*i+4); bool found(false); for(int j=0;j<6 && !found;j++) { - std::set s1(allFacesNodalConn+4*j,allFacesNodalConn+4*j+4); + std::set const s1(allFacesNodalConn+4*j,allFacesNodalConn+4*j+4); if(s==s1) { neighTmp[i]=myNeighbours[j]; @@ -1921,42 +1944,42 @@ bool UpdateHexa8Cell(int validAxis, mcIdType neighId, const mcIdType *validConnQ DataArrayIdType *MEDCoupling1SGTUMesh::sortHexa8EachOther() { MCAuto quads(explodeEachHexa8To6Quad4());//checks that only hexa8 - mcIdType nbHexa8=getNumberOfCells(); + mcIdType const nbHexa8=getNumberOfCells(); mcIdType *cQuads(quads->getNodalConnectivity()->getPointer()); MCAuto neighOfQuads(DataArrayIdType::New()); neighOfQuads->alloc(nbHexa8*6,1); neighOfQuads->fillWithValue(-1); mcIdType *ptNeigh(neighOfQuads->getPointer()); {//neighOfQuads tells for each face of each Quad8 which cell (if!=-1) is connected to this face. MCAuto quadsTmp(quads->buildUnstructured()); MCAuto ccSafe,cciSafe; - DataArrayIdType *cc(0),*cci(0); + DataArrayIdType *cc(nullptr),*cci(nullptr); quadsTmp->findCommonCells(3,0,cc,cci); ccSafe=cc; cciSafe=cci; const mcIdType *ccPtr(ccSafe->begin()); - mcIdType nbOfPair=cci->getNumberOfTuples()-1; + mcIdType const nbOfPair=cci->getNumberOfTuples()-1; for(mcIdType i=0;i ret(DataArrayIdType::New()); ret->alloc(0,1); std::vector fetched(nbHexa8,false); - std::vector::iterator it(std::find(fetched.begin(),fetched.end(),false)); + auto it(std::find(fetched.begin(),fetched.end(),false)); while(it!=fetched.end())//it will turns as time as number of connected zones { - mcIdType cellId(ToIdType(std::distance(fetched.begin(),it)));//it is the seed of the connected zone. + mcIdType const cellId(ToIdType(std::distance(fetched.begin(),it)));//it is the seed of the connected zone. std::set s; s.insert(cellId);//s contains already organized. while(!s.empty()) { std::set sNext; - for(std::set::const_iterator it0=s.begin();it0!=s.end();it0++) + for(long const it0 : s) { - fetched[*it0]=true; - mcIdType *myNeighb(ptNeigh+6*(*it0)); + fetched[it0]=true; + mcIdType *myNeighb(ptNeigh+6*it0); for(int i=0;i<6;i++) { if(myNeighb[i]!=-1 && !fetched[myNeighb[i]]) { - std::size_t pos(std::distance(HEXA8_FACE_PAIRS,std::find(HEXA8_FACE_PAIRS,HEXA8_FACE_PAIRS+6,i))); + std::size_t const pos(std::distance(HEXA8_FACE_PAIRS,std::find(HEXA8_FACE_PAIRS,HEXA8_FACE_PAIRS+6,i))); std::size_t pos0(pos/2),pos1(pos%2); - if(!UpdateHexa8Cell(HEXA8_FACE_PAIRS[2*pos0+(pos1+1)%2],*it0,cQuads+6*4*(*it0)+4*i,cQuads+6*4*myNeighb[i],ptNeigh+6*myNeighb[i])) + if(!UpdateHexa8Cell(HEXA8_FACE_PAIRS[2*pos0+(pos1+1)%2],it0,cQuads+6*4*it0+4*i,cQuads+6*4*myNeighb[i],ptNeigh+6*myNeighb[i])) ret->pushBackSilent(myNeighb[i]); fetched[myNeighb[i]]=true; sNext.insert(myNeighb[i]); @@ -1970,9 +1993,8 @@ DataArrayIdType *MEDCoupling1SGTUMesh::sortHexa8EachOther() if(!ret->empty()) { mcIdType *conn(getNodalConnectivity()->getPointer()); - for(const mcIdType *pt=ret->begin();pt!=ret->end();pt++) + for(long const cellId : *ret) { - mcIdType cellId(*pt); conn[8*cellId+0]=cQuads[24*cellId+0]; conn[8*cellId+1]=cQuads[24*cellId+1]; conn[8*cellId+2]=cQuads[24*cellId+2]; conn[8*cellId+3]=cQuads[24*cellId+3]; conn[8*cellId+4]=cQuads[24*cellId+4]; conn[8*cellId+5]=cQuads[24*cellId+7]; conn[8*cellId+6]=cQuads[24*cellId+6]; conn[8*cellId+7]=cQuads[24*cellId+5]; } @@ -2007,21 +2029,21 @@ MEDCoupling1DGTUMesh *MEDCoupling1SGTUMesh::computeDualMesh3D() const MCAuto edges(thisu->explode3DMeshTo1D(d1Arr,di1Arr,rd1Arr,rdi1Arr)); const mcIdType *d1(d1Arr->begin()); MCAuto d2Arr(DataArrayIdType::New()),di2Arr(DataArrayIdType::New()),rd2Arr(DataArrayIdType::New()),rdi2Arr(DataArrayIdType::New()); - MCAuto faces(thisu->buildDescendingConnectivity(d2Arr,di2Arr,rd2Arr,rdi2Arr)); thisu=0; + MCAuto faces(thisu->buildDescendingConnectivity(d2Arr,di2Arr,rd2Arr,rdi2Arr)); thisu=nullptr; const mcIdType *d2(d2Arr->begin()),*rdi2(rdi2Arr->begin()); MCAuto edgesBaryArr(edges->computeCellCenterOfMass()),facesBaryArr(faces->computeCellCenterOfMass()),baryArr(computeCellCenterOfMass()); const mcIdType nbOfNodes(getNumberOfNodes()); const mcIdType offset0=nbOfNodes+faces->getNumberOfCells(); const mcIdType offset1=offset0+edges->getNumberOfCells(); - edges=0; faces=0; + edges=nullptr; faces=nullptr; std::vector v(4); v[0]=getCoords(); v[1]=facesBaryArr; v[2]=edgesBaryArr; v[3]=baryArr; - MCAuto zeArr(DataArrayDouble::Aggregate(v)); baryArr=0; edgesBaryArr=0; facesBaryArr=0; + MCAuto zeArr(DataArrayDouble::Aggregate(v)); baryArr=nullptr; edgesBaryArr=nullptr; facesBaryArr=nullptr; std::string name("DualOf_"); name+=getName(); MCAuto ret(MEDCoupling1DGTUMesh::New(name,INTERP_KERNEL::NORM_POLYHED)); ret->setCoords(zeArr); MCAuto cArr(DataArrayIdType::New()),ciArr(DataArrayIdType::New()); ciArr->alloc(nbOfNodes+1,1); ciArr->setIJ(0,0,0); cArr->alloc(0,1); for(mcIdType i=0;ipushBackSilent(-1); mcIdType tmp[14]; // @@ -2081,19 +2103,19 @@ MEDCoupling1DGTUMesh *MEDCoupling1SGTUMesh::computeDualMesh2D() const thisu->getReverseNodalConnectivity(revNodArr,revNodIArr); const mcIdType *revNod(revNodArr->begin()),*revNodI(revNodIArr->begin()),*nodal(_conn->begin()); MCAuto d2Arr(DataArrayIdType::New()),di2Arr(DataArrayIdType::New()),rd2Arr(DataArrayIdType::New()),rdi2Arr(DataArrayIdType::New()); - MCAuto edges(thisu->buildDescendingConnectivity(d2Arr,di2Arr,rd2Arr,rdi2Arr)); thisu=0; + MCAuto edges(thisu->buildDescendingConnectivity(d2Arr,di2Arr,rd2Arr,rdi2Arr)); thisu=nullptr; const mcIdType *d2(d2Arr->begin()),*rdi2(rdi2Arr->begin()); MCAuto edgesBaryArr(edges->computeCellCenterOfMass()),baryArr(computeCellCenterOfMass()); const mcIdType nbOfNodes(getNumberOfNodes()),offset0(nbOfNodes+edges->getNumberOfCells()); - edges=0; + edges=nullptr; std::vector v(3); v[0]=getCoords(); v[1]=edgesBaryArr; v[2]=baryArr; - MCAuto zeArr(DataArrayDouble::Aggregate(v)); baryArr=0; edgesBaryArr=0; + MCAuto zeArr(DataArrayDouble::Aggregate(v)); baryArr=nullptr; edgesBaryArr=nullptr; std::string name("DualOf_"); name+=getName(); MCAuto ret(MEDCoupling1DGTUMesh::New(name,INTERP_KERNEL::NORM_POLYGON)); ret->setCoords(zeArr); MCAuto cArr(DataArrayIdType::New()),ciArr(DataArrayIdType::New()); ciArr->alloc(nbOfNodes+1,1); ciArr->setIJ(0,0,0); cArr->alloc(0,1); for(mcIdType i=0;i > polyg; for(int j=0;j locV(3); locV[0]=d2[3*curCellId+DUAL_TRI_0[2*nodePosInCurCell+0]]+nbOfNodes; locV[1]=curCellId+offset0; locV[2]=d2[3*curCellId+DUAL_TRI_0[2*nodePosInCurCell+1]]+nbOfNodes; polyg.push_back(locV); @@ -2117,7 +2139,7 @@ MEDCoupling1DGTUMesh *MEDCoupling1SGTUMesh::computeDualMesh2D() const if(rdi2[*edgeId+1]-rdi2[*edgeId]==1) { std::vector locV2(2); - int zeLocEdgeIdRel(DUAL_TRI_1[2*nodePosInCurCell+kk]); + int const zeLocEdgeIdRel(DUAL_TRI_1[2*nodePosInCurCell+kk]); if(zeLocEdgeIdRel>0) { locV2[0]=d2[3*curCellId+zeLocEdgeIdRel-3]+nbOfNodes; locV2[1]=i; } else @@ -2146,7 +2168,7 @@ MEDCoupling1DGTUMesh *MEDCoupling1SGTUMesh::computeDualMesh2D() const * \throw If \a this is not fully set (coordinates and connectivity). * \throw If a cell in \a this has no valid nodeId. */ -DataArrayDouble *MEDCoupling1SGTUMesh::getBoundingBoxForBBTree(double arcDetEps) const +DataArrayDouble *MEDCoupling1SGTUMesh::getBoundingBoxForBBTree(double /*arcDetEps*/) const { mcIdType spaceDim(getSpaceDimension()),nbOfCells(getNumberOfCells()),nbOfNodes(getNumberOfNodes()),nbOfNodesPerCell(getNumberOfNodesPerCell()); MCAuto ret(DataArrayDouble::New()); ret->alloc(nbOfCells,2*spaceDim); @@ -2163,7 +2185,7 @@ DataArrayDouble *MEDCoupling1SGTUMesh::getBoundingBoxForBBTree(double arcDetEps) int kk(0); for(int j=0;j=0 && nodeId ret(MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME)); - mcIdType nbCells=getNumberOfCells(); + mcIdType const nbCells=getNumberOfCells(); MCAuto arr(DataArrayDouble::New()); arr->alloc(nbCells,1); INTERP_KERNEL::AutoCppPtr dc(_cm->buildInstanceOfDiameterCalulator(getSpaceDimension())); @@ -2240,8 +2262,7 @@ MEDCoupling1DGTUMesh *MEDCoupling1DGTUMesh::New(const std::string& name, INTERP_ } MEDCoupling1DGTUMesh::MEDCoupling1DGTUMesh() -{ -} += default; MEDCoupling1DGTUMesh::MEDCoupling1DGTUMesh(const std::string& name, const INTERP_KERNEL::CellModel& cm):MEDCoupling1GTUMesh(name,cm) { @@ -2315,7 +2336,7 @@ bool MEDCoupling1DGTUMesh::isEqualIfNotWhy(const MEDCouplingMesh *other, double if(!other) throw INTERP_KERNEL::Exception("MEDCoupling1DGTUMesh::isEqualIfNotWhy : input other pointer is null !"); std::ostringstream oss; oss.precision(15); - const MEDCoupling1DGTUMesh *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) { reason="mesh given in input is not castable in MEDCoupling1DGTUMesh !"; @@ -2356,7 +2377,7 @@ bool MEDCoupling1DGTUMesh::isEqualWithoutConsideringStr(const MEDCouplingMesh *o { if(!other) throw INTERP_KERNEL::Exception("MEDCoupling1DGTUMesh::isEqualWithoutConsideringStr : input other pointer is null !"); - const MEDCoupling1DGTUMesh *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) return false; if(!MEDCoupling1GTUMesh::isEqualWithoutConsideringStr(other,prec)) @@ -2384,7 +2405,7 @@ bool MEDCoupling1DGTUMesh::isEqualWithoutConsideringStr(const MEDCouplingMesh *o void MEDCoupling1DGTUMesh::checkFastEquivalWith(const MEDCouplingMesh *other, double prec) const { MEDCouplingPointSet::checkFastEquivalWith(other,prec); - const MEDCoupling1DGTUMesh *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("MEDCoupling1DGTUMesh::checkFastEquivalWith : Two meshes are not unstructured with single dynamic geometric type !"); const DataArrayIdType *c1(_conn),*c2(otherC->_conn); @@ -2427,7 +2448,7 @@ void MEDCoupling1DGTUMesh::checkConsistencyOfConnectivity() const else throw INTERP_KERNEL::Exception("Nodal connectivity array not defined !"); // - mcIdType sz2(_conn->getNumberOfTuples()); + mcIdType const sz2(_conn->getNumberOfTuples()); c1=_conn_indx; if(c1) { @@ -2457,7 +2478,7 @@ void MEDCoupling1DGTUMesh::checkConsistencyOfConnectivity() const } else throw INTERP_KERNEL::Exception("Nodal connectivity index array not defined !"); - mcIdType szOfC1Exp=_conn_indx->back(); + mcIdType const szOfC1Exp=_conn_indx->back(); if(sz2getNumberOfTuples() << " !"; @@ -2476,15 +2497,15 @@ void MEDCoupling1DGTUMesh::checkConsistencyLight() const checkConsistencyOfConnectivity(); } -void MEDCoupling1DGTUMesh::checkConsistency(double eps) const +void MEDCoupling1DGTUMesh::checkConsistency(double /*eps*/) const { checkConsistencyLight(); const DataArrayIdType *c1(_conn),*c2(_conn_indx); if(!c2->isMonotonic(true)) throw INTERP_KERNEL::Exception("MEDCoupling1DGTUMesh::checkConsistency : the nodal connectivity index is expected to be increasing monotinic !"); // - mcIdType nbOfTuples(c1->getNumberOfTuples()); - mcIdType nbOfNodes=getNumberOfNodes(); + mcIdType const nbOfTuples(c1->getNumberOfTuples()); + mcIdType const nbOfNodes=getNumberOfNodes(); const mcIdType *w(c1->begin()); for(mcIdType i=0;ideltaShiftIndex(); // for polyhedrons - mcIdType nbOfCells=_conn_indx->getNumberOfTuples()-1; + mcIdType const nbOfCells=_conn_indx->getNumberOfTuples()-1; MCAuto ret=DataArrayIdType::New(); ret->alloc(nbOfCells,1); mcIdType *retPtr=ret->getPointer(); @@ -2547,7 +2568,7 @@ DataArrayIdType *MEDCoupling1DGTUMesh::computeNbOfFacesPerCell() const return ret.retn(); } // for polyhedrons - mcIdType nbOfCells=_conn_indx->getNumberOfTuples()-1; + mcIdType const nbOfCells=_conn_indx->getNumberOfTuples()-1; MCAuto ret=DataArrayIdType::New(); ret->alloc(nbOfCells,1); mcIdType *retPtr=ret->getPointer(); @@ -2568,7 +2589,7 @@ DataArrayIdType *MEDCoupling1DGTUMesh::computeEffectiveNbOfNodesPerCell() const { checkConsistencyLight(); _conn_indx->checkMonotonic(true); - mcIdType nbOfCells=_conn_indx->getNumberOfTuples()-1; + mcIdType const nbOfCells=_conn_indx->getNumberOfTuples()-1; MCAuto ret=DataArrayIdType::New(); ret->alloc(nbOfCells,1); mcIdType *retPtr(ret->getPointer()); @@ -2577,7 +2598,7 @@ DataArrayIdType *MEDCoupling1DGTUMesh::computeEffectiveNbOfNodesPerCell() const { for(mcIdType i=0;i s(c+ci[0],c+ci[1]); + std::set const s(c+ci[0],c+ci[1]); *retPtr=ToIdType(s.size()); } } @@ -2594,11 +2615,11 @@ DataArrayIdType *MEDCoupling1DGTUMesh::computeEffectiveNbOfNodesPerCell() const void MEDCoupling1DGTUMesh::getNodeIdsOfCell(mcIdType cellId, std::vector& conn) const { - mcIdType nbOfCells(getNumberOfCells());//performs checks + mcIdType const nbOfCells(getNumberOfCells());//performs checks if(cellIdgetIJ(cellId,0),stp=_conn_indx->getIJ(cellId+1,0); - mcIdType nbOfNodes=stp-strt; + mcIdType const nbOfNodes=stp-strt; if(nbOfNodes<0) throw INTERP_KERNEL::Exception("MEDCoupling1DGTUMesh::getNodeIdsOfCell : the index array is invalid ! Should be increasing monotonic !"); conn.resize(nbOfNodes); @@ -2613,7 +2634,7 @@ void MEDCoupling1DGTUMesh::getNodeIdsOfCell(mcIdType cellId, std::vector=0 && cellIdbegin()); @@ -2636,11 +2657,11 @@ std::string MEDCoupling1DGTUMesh::simpleRepr() const ret << "Single dynamic geometic type (" << _cm->getRepr() << ") unstructured mesh with name : \"" << getName() << "\"\n"; ret << "Description of mesh : \"" << getDescription() << "\"\n"; int tmpp1,tmpp2; - double tt=getTime(tmpp1,tmpp2); + double const tt=getTime(tmpp1,tmpp2); ret << "Time attached to the mesh [unit] : " << tt << " [" << getTimeUnit() << "]\n"; ret << "Iteration : " << tmpp1 << " Order : " << tmpp2 << "\n"; ret << "Mesh dimension : " << getMeshDimension() << "\nSpace dimension : "; - if(_coords!=0) + if(_coords!=nullptr) { const int spaceDim=getSpaceDimension(); ret << spaceDim << "\nInfo attached on space dimension : "; @@ -2651,7 +2672,7 @@ std::string MEDCoupling1DGTUMesh::simpleRepr() const else ret << msg0 << "\n"; ret << "Number of nodes : "; - if(_coords!=0) + if(_coords!=nullptr) ret << getNumberOfNodes() << "\n"; else ret << msg0 << "\n"; @@ -2687,7 +2708,7 @@ std::string MEDCoupling1DGTUMesh::advancedRepr() const } if(!isOK) return ret.str(); - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbOfCells=getNumberOfCells(); const mcIdType *ci=_conn_indx->begin(),*c=_conn->begin(); for(mcIdType i=0;i ret=DataArrayDouble::New(); - int spaceDim=getSpaceDimension(); - mcIdType nbOfCells=getNumberOfCells();//checkConsistencyLight() - mcIdType nbOfNodes=getNumberOfNodes(); + int const spaceDim=getSpaceDimension(); + mcIdType const nbOfCells=getNumberOfCells();//checkConsistencyLight() + mcIdType const nbOfNodes=getNumberOfNodes(); ret->alloc(nbOfCells,spaceDim); double *ptToFill=ret->getPointer(); const double *coor=_coords->begin(); @@ -2777,7 +2798,7 @@ DataArrayDouble *MEDCoupling1DGTUMesh::computeIsoBarycenterOfNodesPerCell() cons void MEDCoupling1DGTUMesh::renumberCells(const mcIdType *old2NewBg, bool check) { - mcIdType nbCells=getNumberOfCells(); + mcIdType const nbCells=getNumberOfCells(); MCAuto o2n=DataArrayIdType::New(); o2n->useArray(old2NewBg,false,DeallocType::C_DEALLOC,nbCells,1); if(check) @@ -2793,8 +2814,8 @@ void MEDCoupling1DGTUMesh::renumberCells(const mcIdType *old2NewBg, bool check) mcIdType *newC=newConn->getPointer(),*newCI=newConnI->getPointer(); for(mcIdType i=0;i=0) newCI[newPos]=sz; else @@ -2807,7 +2828,7 @@ void MEDCoupling1DGTUMesh::renumberCells(const mcIdType *old2NewBg, bool check) // for(mcIdType i=0;igetType()!=SINGLE_DYNAMIC_GEO_TYPE_UNSTRUCTURED) throw INTERP_KERNEL::Exception("Merge of umesh only available with umesh single dynamic geo type each other !"); - const MEDCoupling1DGTUMesh *otherC=static_cast(other); + const auto *otherC=static_cast(other); return Merge1DGTUMeshes(this,otherC); } @@ -2827,15 +2848,15 @@ MEDCouplingUMesh *MEDCoupling1DGTUMesh::buildUnstructured() const MCAuto ret=MEDCouplingUMesh::New(getName(),getMeshDimension()); ret->setCoords(getCoords()); const mcIdType *nodalConn=_conn->begin(),*nodalConnI=_conn_indx->begin(); - mcIdType nbCells=getNumberOfCells();//checkConsistencyLight - mcIdType geoType=ToIdType(getCellModelEnum()); + mcIdType const nbCells=getNumberOfCells();//checkConsistencyLight + mcIdType const geoType=ToIdType(getCellModelEnum()); MCAuto c=DataArrayIdType::New(); c->alloc(nbCells+_conn->getNumberOfTuples(),1); MCAuto cI=DataArrayIdType::New(); cI->alloc(nbCells+1); mcIdType *cPtr=c->getPointer(),*ciPtr=cI->getPointer(); ciPtr[0]=0; for(mcIdType i=0;i=0) { *cPtr++=geoType; @@ -2858,9 +2879,9 @@ MEDCouplingUMesh *MEDCoupling1DGTUMesh::buildUnstructured() const /*! * Do nothing for the moment, because there is no policy that allows to split polygons, polyhedrons ... into simplexes */ -DataArrayIdType *MEDCoupling1DGTUMesh::simplexize(int policy) +DataArrayIdType *MEDCoupling1DGTUMesh::simplexize(int /*policy*/) { - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbOfCells=getNumberOfCells(); MCAuto ret=DataArrayIdType::New(); ret->alloc(nbOfCells,1); ret->iota(0); @@ -2897,7 +2918,7 @@ void MEDCoupling1DGTUMesh::shallowCopyConnectivityFrom(const MEDCouplingPointSet { if(!other) throw INTERP_KERNEL::Exception("MEDCoupling1DGTUMesh::shallowCopyConnectivityFrom : input pointer is null !"); - const MEDCoupling1DGTUMesh *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("MEDCoupling1DGTUMesh::shallowCopyConnectivityFrom : input pointer is not an MEDCoupling1DGTUMesh instance !"); setNodalConnectivity(otherC->getNodalConnectivity(),otherC->getNodalConnectivityIndex()); @@ -2907,7 +2928,7 @@ MEDCouplingPointSet *MEDCoupling1DGTUMesh::mergeMyselfWithOnSameCoords(const MED { if(!other) throw INTERP_KERNEL::Exception("MEDCoupling1DGTUMesh::mergeMyselfWithOnSameCoords : input other is null !"); - const MEDCoupling1DGTUMesh *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("MEDCoupling1DGTUMesh::mergeMyselfWithOnSameCoords : the input other mesh is not of type single statuc geo type unstructured !"); std::vector ms(2); @@ -2921,7 +2942,7 @@ MEDCouplingPointSet *MEDCoupling1DGTUMesh::buildPartOfMySelfKeepCoords(const mcI checkConsistencyLight(); MCAuto ret(new MEDCoupling1DGTUMesh(getName(),*_cm)); ret->setCoords(_coords); - DataArrayIdType *c=0,*ci=0; + DataArrayIdType *c=nullptr,*ci=nullptr; DataArrayIdType::ExtractFromIndexedArrays(begin,end,_conn,_conn_indx,c,ci); MCAuto cSafe(c),ciSafe(ci); ret->setNodalConnectivity(c,ci); @@ -2933,7 +2954,7 @@ MEDCouplingPointSet *MEDCoupling1DGTUMesh::buildPartOfMySelfKeepCoordsSlice(mcId checkConsistencyLight(); MCAuto ret(new MEDCoupling1DGTUMesh(getName(),*_cm)); ret->setCoords(_coords); - DataArrayIdType *c=0,*ci=0; + DataArrayIdType *c=nullptr,*ci=nullptr; DataArrayIdType::ExtractFromIndexedArraysSlice(start,end,step,_conn,_conn_indx,c,ci); MCAuto cSafe(c),ciSafe(ci); ret->setNodalConnectivity(c,ci); @@ -2943,7 +2964,7 @@ MEDCouplingPointSet *MEDCoupling1DGTUMesh::buildPartOfMySelfKeepCoordsSlice(mcId void MEDCoupling1DGTUMesh::computeNodeIdsAlg(std::vector& nodeIdsInUse) const { checkConsistency(); - mcIdType sz(ToIdType(nodeIdsInUse.size())); + mcIdType const sz(ToIdType(nodeIdsInUse.size())); for(const mcIdType *conn=_conn->begin();conn!=_conn->end();conn++) { if(*conn>=0 && *conn& nodeIdsInUse) co void MEDCoupling1DGTUMesh::getReverseNodalConnectivity(DataArrayIdType *revNodal, DataArrayIdType *revNodalIndx) const { checkFullyDefined(); - mcIdType nbOfNodes=getNumberOfNodes(); - mcIdType *revNodalIndxPtr=(mcIdType *)malloc((nbOfNodes+1)*sizeof(mcIdType)); + mcIdType const nbOfNodes=getNumberOfNodes(); + auto *revNodalIndxPtr=(mcIdType *)malloc((nbOfNodes+1)*sizeof(mcIdType)); revNodalIndx->useArray(revNodalIndxPtr,true,DeallocType::C_DEALLOC,nbOfNodes+1,1); std::fill(revNodalIndxPtr,revNodalIndxPtr+nbOfNodes+1,0); const mcIdType *conn=_conn->begin(),*conni=_conn_indx->begin(); - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbOfCells=getNumberOfCells(); mcIdType nbOfEltsInRevNodal=0; for(mcIdType eltId=0;eltId=0) { for(mcIdType j=0;j=0 && nodeId()); conn=_conn->begin(); - mcIdType *revNodalPtr=(mcIdType *)malloc((nbOfEltsInRevNodal)*sizeof(mcIdType)); + auto *revNodalPtr=(mcIdType *)malloc((nbOfEltsInRevNodal)*sizeof(mcIdType)); revNodal->useArray(revNodalPtr,true,DeallocType::C_DEALLOC,nbOfEltsInRevNodal,1); std::fill(revNodalPtr,revNodalPtr+nbOfEltsInRevNodal,-1); for(mcIdType eltId=0;eltId(),std::placeholders::_1,-1))=eltId; } @@ -3019,7 +3040,7 @@ void MEDCoupling1DGTUMesh::checkFullyDefined() const throw INTERP_KERNEL::Exception("MEDCoupling1DGTUMesh::checkFullyDefined : part of this is not fully defined."); } -bool MEDCoupling1DGTUMesh::isEmptyMesh(const std::vector& tinyInfo) const +bool MEDCoupling1DGTUMesh::isEmptyMesh(const std::vector& /*tinyInfo*/) const { throw INTERP_KERNEL::Exception("MEDCoupling1DGTUMesh::isEmptyMesh : not implemented yet !"); } @@ -3027,7 +3048,7 @@ bool MEDCoupling1DGTUMesh::isEmptyMesh(const std::vector& tinyInfo) co void MEDCoupling1DGTUMesh::getTinySerializationInformation(std::vector& tinyInfoD, std::vector& tinyInfo, std::vector& littleStrings) const { int it,order; - double time=getTime(it,order); + double const time=getTime(it,order); tinyInfo.clear(); tinyInfoD.clear(); littleStrings.clear(); // littleStrings.push_back(getName()); @@ -3065,11 +3086,11 @@ void MEDCoupling1DGTUMesh::getTinySerializationInformation(std::vector& tinyInfoD.push_back(time); } -void MEDCoupling1DGTUMesh::resizeForUnserialization(const std::vector& tinyInfo, DataArrayIdType *a1, DataArrayDouble *a2, std::vector& littleStrings) const +void MEDCoupling1DGTUMesh::resizeForUnserialization(const std::vector& tinyInfo, DataArrayIdType *a1, DataArrayDouble *a2, std::vector& /*littleStrings*/) const { - std::vector tinyInfo2(tinyInfo.begin()+9,tinyInfo.begin()+9+tinyInfo[6]); - std::vector tinyInfo1(tinyInfo.begin()+9+tinyInfo[6],tinyInfo.begin()+9+tinyInfo[6]+tinyInfo[7]); - std::vector tinyInfo12(tinyInfo.begin()+9+tinyInfo[6]+tinyInfo[7],tinyInfo.begin()+9+tinyInfo[6]+tinyInfo[7]+tinyInfo[8]); + std::vector const tinyInfo2(tinyInfo.begin()+9,tinyInfo.begin()+9+tinyInfo[6]); + std::vector const tinyInfo1(tinyInfo.begin()+9+tinyInfo[6],tinyInfo.begin()+9+tinyInfo[6]+tinyInfo[7]); + std::vector const tinyInfo12(tinyInfo.begin()+9+tinyInfo[6]+tinyInfo[7],tinyInfo.begin()+9+tinyInfo[6]+tinyInfo[7]+tinyInfo[8]); MCAuto p1(DataArrayIdType::New()); p1->resizeForUnserialization(tinyInfo1); MCAuto p2(DataArrayIdType::New()); p2->resizeForUnserialization(tinyInfo12); std::vector v(2); v[0]=p1; v[1]=p2; @@ -3107,7 +3128,7 @@ void MEDCoupling1DGTUMesh::serialize(DataArrayIdType *&a1, DataArrayDouble *&a2) void MEDCoupling1DGTUMesh::unserialization(const std::vector& tinyInfoD, const std::vector& tinyInfo, const DataArrayIdType *a1, DataArrayDouble *a2, const std::vector& littleStrings) { - INTERP_KERNEL::NormalizedCellType gt((INTERP_KERNEL::NormalizedCellType)tinyInfo[0]); + auto gt((INTERP_KERNEL::NormalizedCellType)tinyInfo[0]); _cm=&INTERP_KERNEL::CellModel::GetCellModel(gt); setName(littleStrings[0]); setDescription(littleStrings[1]); @@ -3116,22 +3137,22 @@ void MEDCoupling1DGTUMesh::unserialization(const std::vector& tinyInfoD, mcIdType sz0(tinyInfo[3]),sz1(tinyInfo[4]),sz2(tinyInfo[5]),sz3(tinyInfo[6]),sz4(tinyInfo[7]),sz5(tinyInfo[8]); // _coords=DataArrayDouble::New(); - std::vector tinyInfo2(tinyInfo.begin()+9,tinyInfo.begin()+9+sz3); + std::vector const tinyInfo2(tinyInfo.begin()+9,tinyInfo.begin()+9+sz3); _coords->resizeForUnserialization(tinyInfo2); std::copy(a2->begin(),a2->end(),_coords->getPointer()); _conn=DataArrayIdType::New(); - std::vector tinyInfo3(tinyInfo.begin()+9+sz3,tinyInfo.begin()+9+sz3+sz4); + std::vector const tinyInfo3(tinyInfo.begin()+9+sz3,tinyInfo.begin()+9+sz3+sz4); _conn->resizeForUnserialization(tinyInfo3); std::copy(a1->begin(),a1->begin()+_conn->getNbOfElems(),_conn->getPointer()); _conn_indx=DataArrayIdType::New(); - std::vector tinyInfo4(tinyInfo.begin()+9+sz3+sz4,tinyInfo.begin()+9+sz3+sz4+sz5); + std::vector const tinyInfo4(tinyInfo.begin()+9+sz3+sz4,tinyInfo.begin()+9+sz3+sz4+sz5); _conn_indx->resizeForUnserialization(tinyInfo4); std::copy(a1->begin()+_conn->getNbOfElems(),a1->end(),_conn_indx->getPointer()); - std::vector littleStrings2(littleStrings.begin()+3,littleStrings.begin()+3+sz0); + std::vector const littleStrings2(littleStrings.begin()+3,littleStrings.begin()+3+sz0); _coords->finishUnserialization(tinyInfo2,littleStrings2); - std::vector littleStrings3(littleStrings.begin()+3+sz0,littleStrings.begin()+3+sz0+sz1); + std::vector const littleStrings3(littleStrings.begin()+3+sz0,littleStrings.begin()+3+sz0+sz1); _conn->finishUnserialization(tinyInfo3,littleStrings3); - std::vector littleStrings4(littleStrings.begin()+3+sz0+sz1,littleStrings.begin()+3+sz0+sz1+sz2); + std::vector const littleStrings4(littleStrings.begin()+3+sz0+sz1,littleStrings.begin()+3+sz0+sz1+sz2); _conn_indx->finishUnserialization(tinyInfo4,littleStrings4); } @@ -3151,10 +3172,10 @@ void MEDCoupling1DGTUMesh::unserialization(const std::vector& tinyInfoD, DataArrayIdType *MEDCoupling1DGTUMesh::computeFetchedNodeIds() const { checkConsistency(); - mcIdType nbNodes(getNumberOfNodes()); + mcIdType const nbNodes(getNumberOfNodes()); std::vector fetchedNodes(nbNodes,false); computeNodeIdsAlg(fetchedNodes); - mcIdType sz(ToIdType(std::count(fetchedNodes.begin(),fetchedNodes.end(),true))); + mcIdType const sz(ToIdType(std::count(fetchedNodes.begin(),fetchedNodes.end(),true))); MCAuto ret(DataArrayIdType::New()); ret->alloc(sz,1); mcIdType *retPtr(ret->getPointer()); for(mcIdType i=0;i ret=DataArrayIdType::New(); ret->alloc(nbOfNodes,1); mcIdType *traducer=ret->getPointer(); @@ -3189,10 +3210,10 @@ DataArrayIdType *MEDCoupling1DGTUMesh::getNodeIdsInUse(mcIdType& nbrOfNodesInUse const mcIdType *conn=_conn->begin(),*conni(_conn_indx->begin()); for(mcIdType i=0;i=0 && nodeIdgetNumberOfTuples()); + mcIdType const nbOfTuples(_conn->getNumberOfTuples()); mcIdType *pt(_conn->getPointer()); for(mcIdType i=0;i cellIdsKept=DataArrayIdType::New(); cellIdsKept->alloc(0,1); mcIdType tmp=-1; mcIdType sz=_conn->getMaxValue(tmp); sz=std::max(sz,ToIdType(0))+1; @@ -3307,12 +3328,12 @@ void MEDCoupling1DGTUMesh::fillCellIdsToKeepFromNodeIds(const mcIdType *begin, c for(mcIdType i=0;i=0) { for(mcIdType j=0;j=0) { ref++; @@ -3354,11 +3375,11 @@ void MEDCoupling1DGTUMesh::allocateCells(mcIdType nbOfCells) */ void MEDCoupling1DGTUMesh::insertNextCell(const mcIdType *nodalConnOfCellBg, const mcIdType *nodalConnOfCellEnd) { - std::size_t sz(std::distance(nodalConnOfCellBg,nodalConnOfCellEnd)); + std::size_t const sz(std::distance(nodalConnOfCellBg,nodalConnOfCellEnd)); DataArrayIdType *c(_conn),*c2(_conn_indx); if(c && c2) { - mcIdType pos=c2->back(); + mcIdType const pos=c2->back(); if(pos==c->getNumberOfTuples()) { c->pushBackValsSilent(nodalConnOfCellBg,nodalConnOfCellEnd); @@ -3419,7 +3440,7 @@ DataArrayIdType *MEDCoupling1DGTUMesh::getNodalConnectivityIndex() const MEDCoupling1DGTUMesh *MEDCoupling1DGTUMesh::copyWithNodalConnectivityPacked(bool& isShallowCpyOfNodalConnn) const { MCAuto ret(new MEDCoupling1DGTUMesh(getName(),*_cm)); - DataArrayIdType *nc=0,*nci=0; + DataArrayIdType *nc=nullptr,*nci=nullptr; isShallowCpyOfNodalConnn=retrievePackedNodalConnectivity(nc,nci); MCAuto ncs(nc),ncis(nci); ret->_conn=ncs; ret->_conn_indx=ncis; @@ -3488,7 +3509,7 @@ MEDCoupling1DGTUMesh *MEDCoupling1DGTUMesh::Merge1DGTUMeshes(const MEDCoupling1D MEDCoupling1DGTUMesh *MEDCoupling1DGTUMesh::Merge1DGTUMeshes(std::vector& a) { - std::size_t sz=a.size(); + std::size_t const sz=a.size(); if(sz==0) return Merge1DGTUMeshesLL(a); for(std::size_t ii=0;iigetConstPointer()),*connI(_conn_indx->getConstPointer()); for(mcIdType i=0;i=0 && nodeId oi(INTERP_KERNEL::OrientationInverter::BuildInstanceFrom(getCellModelEnum())); - mcIdType nbCells=getNumberOfCells(); + mcIdType const nbCells=getNumberOfCells(); const mcIdType *connI(_conn_indx->begin()); mcIdType *conn(_conn->getPointer()); for(mcIdType i=0;i::const_iterator it=nodalConns.begin();it!=nodalConns.end();it++) + for(auto nodalConn : nodalConns) { - if(!(*it)) + if(!nodalConn) throw INTERP_KERNEL::Exception("MEDCoupling1DGTUMesh::AggregateNodalConnAndShiftNodeIds : presence of null pointer in input vector !"); - if(!(*it)->isAllocated()) + if(!nodalConn->isAllocated()) throw INTERP_KERNEL::Exception("MEDCoupling1DGTUMesh::AggregateNodalConnAndShiftNodeIds : presence of non allocated array in input vector !"); - if((*it)->getNumberOfComponents()!=1) + if(nodalConn->getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("MEDCoupling1DGTUMesh::AggregateNodalConnAndShiftNodeIds : presence of array with not exactly one component !"); - nbOfTuples+=(*it)->getNumberOfTuples(); + nbOfTuples+=nodalConn->getNumberOfTuples(); } MCAuto ret=DataArrayIdType::New(); ret->alloc(nbOfTuples,1); mcIdType *pt=ret->getPointer(); mcIdType i=0; - for(std::vector::const_iterator it=nodalConns.begin();it!=nodalConns.end();it++,i++) + for(auto it=nodalConns.begin();it!=nodalConns.end();it++,i++) { - mcIdType curNbt=(*it)->getNumberOfTuples(); + mcIdType const curNbt=(*it)->getNumberOfTuples(); const mcIdType *inPt=(*it)->begin(); - mcIdType offset=offsetInNodeIdsPerElt[i]; + mcIdType const offset=offsetInNodeIdsPerElt[i]; for(mcIdType j=0;j gts(m->getAllGeoTypes()); + std::set const gts(m->getAllGeoTypes()); if(gts.size()!=1) throw INTERP_KERNEL::Exception("MEDCoupling1DGTUMesh::New : input mesh must have exactly one geometric type !"); - mcIdType geoType(ToIdType(*gts.begin())); + mcIdType const geoType(ToIdType(*gts.begin())); MCAuto ret(MEDCoupling1DGTUMesh::New(m->getName(),*gts.begin())); ret->setCoords(m->getCoords()); ret->setDescription(m->getDescription()); - mcIdType nbCells=m->getNumberOfCells(); + mcIdType const nbCells=m->getNumberOfCells(); MCAuto conn(DataArrayIdType::New()),connI(DataArrayIdType::New()); conn->alloc(m->getNodalConnectivityArrayLen()-nbCells,1); connI->alloc(nbCells+1,1); mcIdType *c(conn->getPointer()),*ci(connI->getPointer()); *ci=0; diff --git a/src/MEDCoupling/MEDCoupling1GTUMesh.hxx b/src/MEDCoupling/MEDCoupling1GTUMesh.hxx index 1e637c670..50845fb68 100644 --- a/src/MEDCoupling/MEDCoupling1GTUMesh.hxx +++ b/src/MEDCoupling/MEDCoupling1GTUMesh.hxx @@ -21,13 +21,23 @@ #ifndef __PARAMEDMEM_MEDCOUPLING1GTUMESH_HXX__ #define __PARAMEDMEM_MEDCOUPLING1GTUMESH_HXX__ +#include "InterpKernelHashMap.hxx" #include "MEDCoupling.hxx" #include "MCType.hxx" +#include "MEDCouplingMesh.hxx" #include "MEDCouplingPointSet.hxx" #include "MEDCouplingMemArray.hxx" #include "MCAuto.hxx" #include "CellModel.hxx" +#include +#include "NormalizedGeometricTypes" +#include +#include +#include +#include +#include "MEDCouplingRefCountObject.hxx" +#include namespace MEDCoupling { @@ -40,36 +50,36 @@ namespace MEDCoupling MEDCOUPLING_EXPORT static MEDCoupling1GTUMesh *New(const MEDCouplingUMesh *m); MEDCOUPLING_EXPORT const INTERP_KERNEL::CellModel& getCellModel() const; MEDCOUPLING_EXPORT INTERP_KERNEL::NormalizedCellType getCellModelEnum() const; - MEDCOUPLING_EXPORT int getMeshDimension() const; - MEDCOUPLING_EXPORT DataArrayIdType *giveCellsWithType(INTERP_KERNEL::NormalizedCellType type) const; - MEDCOUPLING_EXPORT mcIdType getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const; - MEDCOUPLING_EXPORT INTERP_KERNEL::NormalizedCellType getTypeOfCell(mcIdType cellId) const; - MEDCOUPLING_EXPORT std::set getAllGeoTypes() const; - MEDCOUPLING_EXPORT std::vector getDistributionOfTypes() const; - MEDCOUPLING_EXPORT void splitProfilePerType(const DataArrayIdType *profile, std::vector& code, std::vector& idsInPflPerType, std::vector& idsPerType, bool smartPflKiller=true) const; - MEDCOUPLING_EXPORT DataArrayIdType *checkTypeConsistencyAndContig(const std::vector& code, const std::vector& idsPerType) const; - MEDCOUPLING_EXPORT void writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData, DataArrayByte *byteData) const; - MEDCOUPLING_EXPORT std::string getVTKDataSetType() const; - MEDCOUPLING_EXPORT std::string getVTKFileExtension() const; + MEDCOUPLING_EXPORT int getMeshDimension() const override; + MEDCOUPLING_EXPORT DataArrayIdType *giveCellsWithType(INTERP_KERNEL::NormalizedCellType type) const override; + MEDCOUPLING_EXPORT mcIdType getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const override; + MEDCOUPLING_EXPORT INTERP_KERNEL::NormalizedCellType getTypeOfCell(mcIdType cellId) const override; + MEDCOUPLING_EXPORT std::set getAllGeoTypes() const override; + MEDCOUPLING_EXPORT std::vector getDistributionOfTypes() const override; + MEDCOUPLING_EXPORT void splitProfilePerType(const DataArrayIdType *profile, std::vector& code, std::vector& idsInPflPerType, std::vector& idsPerType, bool smartPflKiller=true) const override; + MEDCOUPLING_EXPORT DataArrayIdType *checkTypeConsistencyAndContig(const std::vector& code, const std::vector& idsPerType) const override; + MEDCOUPLING_EXPORT void writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData, DataArrayByte *byteData) const override; + MEDCOUPLING_EXPORT std::string getVTKDataSetType() const override; + MEDCOUPLING_EXPORT std::string getVTKFileExtension() const override; // - MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; + MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const override; MEDCOUPLING_EXPORT mcIdType getNodalConnectivityLength() const; - MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const; - MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const; - MEDCOUPLING_EXPORT void checkConsistencyLight() const; - MEDCOUPLING_EXPORT DataArrayDouble *computeCellCenterOfMass() const; - MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureField(bool isAbs) const; - MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureFieldOnNode(bool isAbs) const; - MEDCOUPLING_EXPORT mcIdType getCellContainingPoint(const double *pos, double eps) const; + MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const override; + MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const override; + MEDCOUPLING_EXPORT void checkConsistencyLight() const override; + MEDCOUPLING_EXPORT DataArrayDouble *computeCellCenterOfMass() const override; + MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureField(bool isAbs) const override; + MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureFieldOnNode(bool isAbs) const override; + MEDCOUPLING_EXPORT mcIdType getCellContainingPoint(const double *pos, double eps) const override; MEDCOUPLING_EXPORT void getCellsContainingPoint(const double *pos, double eps, std::vector& elts) const override; MEDCOUPLING_EXPORT void getCellsContainingPoints(const double *pos, mcIdType nbOfPoints, double eps, MCAuto& elts, MCAuto& eltsIndex) const override; - MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildOrthogonalField() const; - MEDCOUPLING_EXPORT DataArrayIdType *getCellsInBoundingBox(const double *bbox, double eps) const; - MEDCOUPLING_EXPORT DataArrayIdType *getCellsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bbox, double eps); - MEDCOUPLING_EXPORT MEDCouplingPointSet *buildFacePartOfMySelfNode(const mcIdType *start, const mcIdType *end, bool fullyIn) const; - MEDCOUPLING_EXPORT DataArrayIdType *findBoundaryNodes() const; - MEDCOUPLING_EXPORT MEDCouplingPointSet *buildBoundaryMesh(bool keepCoords) const; - MEDCOUPLING_EXPORT void findCommonCells(int compType, mcIdType startCellId, DataArrayIdType *& commonCellsArr, DataArrayIdType *& commonCellsIArr) const; + MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildOrthogonalField() const override; + MEDCOUPLING_EXPORT DataArrayIdType *getCellsInBoundingBox(const double *bbox, double eps) const override; + MEDCOUPLING_EXPORT DataArrayIdType *getCellsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bbox, double eps) override; + MEDCOUPLING_EXPORT MEDCouplingPointSet *buildFacePartOfMySelfNode(const mcIdType *start, const mcIdType *end, bool fullyIn) const override; + MEDCOUPLING_EXPORT DataArrayIdType *findBoundaryNodes() const override; + MEDCOUPLING_EXPORT MEDCouplingPointSet *buildBoundaryMesh(bool keepCoords) const override; + MEDCOUPLING_EXPORT void findCommonCells(int compType, mcIdType startCellId, DataArrayIdType *& commonCellsArr, DataArrayIdType *& commonCellsIArr) const override; MEDCOUPLING_EXPORT static MEDCouplingUMesh *AggregateOnSameCoordsToUMesh(const std::vector< const MEDCoupling1GTUMesh *>& parts); public: MEDCOUPLING_EXPORT virtual void allocateCells(mcIdType nbOfCells=0) = 0; @@ -96,61 +106,61 @@ namespace MEDCoupling MEDCOUPLING_EXPORT static MEDCoupling1SGTUMesh *New(); MEDCOUPLING_EXPORT std::string getClassName() const override { return std::string("MEDCoupling1SGTUMesh"); } // Copy methods - MEDCOUPLING_EXPORT MEDCoupling1SGTUMesh *clone(bool recDeepCpy) const; - MEDCOUPLING_EXPORT MEDCoupling1SGTUMesh *deepCopy() const; - MEDCOUPLING_EXPORT MEDCoupling1SGTUMesh *deepCopyConnectivityOnly() const; + MEDCOUPLING_EXPORT MEDCoupling1SGTUMesh *clone(bool recDeepCpy) const override; + MEDCOUPLING_EXPORT MEDCoupling1SGTUMesh *deepCopy() const override; + MEDCOUPLING_EXPORT MEDCoupling1SGTUMesh *deepCopyConnectivityOnly() const override; // overload of TimeLabel and RefCountObject - MEDCOUPLING_EXPORT void updateTime() const; - MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; - MEDCOUPLING_EXPORT std::vector getDirectChildrenWithNull() const; + MEDCOUPLING_EXPORT void updateTime() const override; + MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const override; + MEDCOUPLING_EXPORT std::vector getDirectChildrenWithNull() const override; // overload of MEDCouplingMesh - MEDCOUPLING_EXPORT MEDCouplingMeshType getType() const { return SINGLE_STATIC_GEO_TYPE_UNSTRUCTURED; } + MEDCOUPLING_EXPORT MEDCouplingMeshType getType() const override { return SINGLE_STATIC_GEO_TYPE_UNSTRUCTURED; } - MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const; - MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const; - MEDCOUPLING_EXPORT void checkFastEquivalWith(const MEDCouplingMesh *other, double prec) const; - MEDCOUPLING_EXPORT void checkConsistencyLight() const; - MEDCOUPLING_EXPORT void checkConsistency(double eps=1e-12) const; - MEDCOUPLING_EXPORT mcIdType getNumberOfCells() const; - MEDCOUPLING_EXPORT DataArrayIdType *computeNbOfNodesPerCell() const; - MEDCOUPLING_EXPORT DataArrayIdType *computeNbOfFacesPerCell() const; - MEDCOUPLING_EXPORT DataArrayIdType *computeEffectiveNbOfNodesPerCell() const; - MEDCOUPLING_EXPORT void getNodeIdsOfCell(mcIdType cellId, std::vector& conn) const; - MEDCOUPLING_EXPORT std::string simpleRepr() const; - MEDCOUPLING_EXPORT std::string advancedRepr() const; - MEDCOUPLING_EXPORT DataArrayDouble *computeIsoBarycenterOfNodesPerCell() const; - MEDCOUPLING_EXPORT void renumberCells(const mcIdType *old2NewBg, bool check=true); - MEDCOUPLING_EXPORT MEDCouplingMesh *mergeMyselfWith(const MEDCouplingMesh *other) const; - MEDCOUPLING_EXPORT MEDCouplingUMesh *buildUnstructured() const; - MEDCOUPLING_EXPORT DataArrayIdType *simplexize(int policy); - MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const; + MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const override; + MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const override; + MEDCOUPLING_EXPORT void checkFastEquivalWith(const MEDCouplingMesh *other, double prec) const override; + MEDCOUPLING_EXPORT void checkConsistencyLight() const override; + MEDCOUPLING_EXPORT void checkConsistency(double eps=1e-12) const override; + MEDCOUPLING_EXPORT mcIdType getNumberOfCells() const override; + MEDCOUPLING_EXPORT DataArrayIdType *computeNbOfNodesPerCell() const override; + MEDCOUPLING_EXPORT DataArrayIdType *computeNbOfFacesPerCell() const override; + MEDCOUPLING_EXPORT DataArrayIdType *computeEffectiveNbOfNodesPerCell() const override; + MEDCOUPLING_EXPORT void getNodeIdsOfCell(mcIdType cellId, std::vector& conn) const override; + MEDCOUPLING_EXPORT std::string simpleRepr() const override; + MEDCOUPLING_EXPORT std::string advancedRepr() const override; + MEDCOUPLING_EXPORT DataArrayDouble *computeIsoBarycenterOfNodesPerCell() const override; + MEDCOUPLING_EXPORT void renumberCells(const mcIdType *old2NewBg, bool check=true) override; + MEDCOUPLING_EXPORT MEDCouplingMesh *mergeMyselfWith(const MEDCouplingMesh *other) const override; + MEDCOUPLING_EXPORT MEDCouplingUMesh *buildUnstructured() const override; + MEDCOUPLING_EXPORT DataArrayIdType *simplexize(int policy) override; + MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const override; // overload of MEDCouplingPointSet - MEDCOUPLING_EXPORT void shallowCopyConnectivityFrom(const MEDCouplingPointSet *other); - MEDCOUPLING_EXPORT MEDCouplingPointSet *mergeMyselfWithOnSameCoords(const MEDCouplingPointSet *other) const; - MEDCOUPLING_EXPORT MEDCouplingPointSet *buildPartOfMySelfKeepCoords(const mcIdType *begin, const mcIdType *end) const; - MEDCOUPLING_EXPORT MEDCouplingPointSet *buildPartOfMySelfKeepCoordsSlice(mcIdType start, mcIdType end, mcIdType step) const; - MEDCOUPLING_EXPORT void computeNodeIdsAlg(std::vector& nodeIdsInUse) const; - MEDCOUPLING_EXPORT void getReverseNodalConnectivity(DataArrayIdType *revNodal, DataArrayIdType *revNodalIndx) const; - MEDCOUPLING_EXPORT void checkFullyDefined() const; - MEDCOUPLING_EXPORT bool isEmptyMesh(const std::vector& tinyInfo) const; - MEDCOUPLING_EXPORT DataArrayIdType *computeFetchedNodeIds() const; - MEDCOUPLING_EXPORT DataArrayIdType *getNodeIdsInUse(mcIdType& nbrOfNodesInUse) const; - MEDCOUPLING_EXPORT void renumberNodesWithOffsetInConn(mcIdType offset); - MEDCOUPLING_EXPORT void renumberNodesInConn(const INTERP_KERNEL::HashMap& newNodeNumbersO2N); + MEDCOUPLING_EXPORT void shallowCopyConnectivityFrom(const MEDCouplingPointSet *other) override; + MEDCOUPLING_EXPORT MEDCouplingPointSet *mergeMyselfWithOnSameCoords(const MEDCouplingPointSet *other) const override; + MEDCOUPLING_EXPORT MEDCouplingPointSet *buildPartOfMySelfKeepCoords(const mcIdType *begin, const mcIdType *end) const override; + MEDCOUPLING_EXPORT MEDCouplingPointSet *buildPartOfMySelfKeepCoordsSlice(mcIdType start, mcIdType end, mcIdType step) const override; + MEDCOUPLING_EXPORT void computeNodeIdsAlg(std::vector& nodeIdsInUse) const override; + MEDCOUPLING_EXPORT void getReverseNodalConnectivity(DataArrayIdType *revNodal, DataArrayIdType *revNodalIndx) const override; + MEDCOUPLING_EXPORT void checkFullyDefined() const override; + MEDCOUPLING_EXPORT bool isEmptyMesh(const std::vector& tinyInfo) const override; + MEDCOUPLING_EXPORT DataArrayIdType *computeFetchedNodeIds() const override; + MEDCOUPLING_EXPORT DataArrayIdType *getNodeIdsInUse(mcIdType& nbrOfNodesInUse) const override; + MEDCOUPLING_EXPORT void renumberNodesWithOffsetInConn(mcIdType offset) override; + MEDCOUPLING_EXPORT void renumberNodesInConn(const INTERP_KERNEL::HashMap& newNodeNumbersO2N) override; MEDCOUPLING_EXPORT void renumberNodesInConn(const std::map& newNodeNumbersO2N) override; - MEDCOUPLING_EXPORT void renumberNodesInConn(const mcIdType *newNodeNumbersO2N); - MEDCOUPLING_EXPORT void fillCellIdsToKeepFromNodeIds(const mcIdType *begin, const mcIdType *end, bool fullyIn, DataArrayIdType *&cellIdsKeptArr) const; - MEDCOUPLING_EXPORT mcIdType getNumberOfNodesInCell(mcIdType cellId) const; - MEDCOUPLING_EXPORT DataArrayDouble *getBoundingBoxForBBTree(double arcDetEps=1e-12) const; - MEDCOUPLING_EXPORT MEDCouplingFieldDouble *computeDiameterField() const; - MEDCOUPLING_EXPORT void invertOrientationOfAllCells(); + MEDCOUPLING_EXPORT void renumberNodesInConn(const mcIdType *newNodeNumbersO2N) override; + MEDCOUPLING_EXPORT void fillCellIdsToKeepFromNodeIds(const mcIdType *begin, const mcIdType *end, bool fullyIn, DataArrayIdType *&cellIdsKeptArr) const override; + MEDCOUPLING_EXPORT mcIdType getNumberOfNodesInCell(mcIdType cellId) const override; + MEDCOUPLING_EXPORT DataArrayDouble *getBoundingBoxForBBTree(double arcDetEps=1e-12) const override; + MEDCOUPLING_EXPORT MEDCouplingFieldDouble *computeDiameterField() const override; + MEDCOUPLING_EXPORT void invertOrientationOfAllCells() override; // overload of MEDCoupling1GTUMesh - MEDCOUPLING_EXPORT void checkConsistencyOfConnectivity() const; - MEDCOUPLING_EXPORT void allocateCells(mcIdType nbOfCells=0); - MEDCOUPLING_EXPORT void insertNextCell(const mcIdType *nodalConnOfCellBg, const mcIdType *nodalConnOfCellEnd); + MEDCOUPLING_EXPORT void checkConsistencyOfConnectivity() const override; + MEDCOUPLING_EXPORT void allocateCells(mcIdType nbOfCells=0) override; + MEDCOUPLING_EXPORT void insertNextCell(const mcIdType *nodalConnOfCellBg, const mcIdType *nodalConnOfCellEnd) override; public://specific MEDCOUPLING_EXPORT void setNodalConnectivity(DataArrayIdType *nodalConn); - MEDCOUPLING_EXPORT DataArrayIdType *getNodalConnectivity() const; + MEDCOUPLING_EXPORT DataArrayIdType *getNodalConnectivity() const override; MEDCOUPLING_EXPORT mcIdType getNumberOfNodesPerCell() const; MEDCOUPLING_EXPORT static MEDCoupling1SGTUMesh *Merge1SGTUMeshes(const MEDCoupling1SGTUMesh *mesh1, const MEDCoupling1SGTUMesh *mesh2); MEDCOUPLING_EXPORT static MEDCoupling1SGTUMesh *Merge1SGTUMeshes(std::vector& a); @@ -162,11 +172,11 @@ namespace MEDCoupling MEDCOUPLING_EXPORT MCAuto computeTriangleHeight() const; MEDCOUPLING_EXPORT MEDCouplingCMesh *structurizeMe(DataArrayIdType *& cellPerm, DataArrayIdType *& nodePerm, double eps=1e-12) const; public://serialization - MEDCOUPLING_EXPORT void getTinySerializationInformation(std::vector& tinyInfoD, std::vector& tinyInfo, std::vector& littleStrings) const; - MEDCOUPLING_EXPORT void resizeForUnserialization(const std::vector& tinyInfo, DataArrayIdType *a1, DataArrayDouble *a2, std::vector& littleStrings) const; - MEDCOUPLING_EXPORT void serialize(DataArrayIdType *&a1, DataArrayDouble *&a2) const; + MEDCOUPLING_EXPORT void getTinySerializationInformation(std::vector& tinyInfoD, std::vector& tinyInfo, std::vector& littleStrings) const override; + MEDCOUPLING_EXPORT void resizeForUnserialization(const std::vector& tinyInfo, DataArrayIdType *a1, DataArrayDouble *a2, std::vector& littleStrings) const override; + MEDCOUPLING_EXPORT void serialize(DataArrayIdType *&a1, DataArrayDouble *&a2) const override; MEDCOUPLING_EXPORT void unserialization(const std::vector& tinyInfoD, const std::vector& tinyInfo, const DataArrayIdType *a1, DataArrayDouble *a2, - const std::vector& littleStrings); + const std::vector& littleStrings) override; private: MEDCoupling1SGTUMesh(const std::string& name, const INTERP_KERNEL::CellModel& cm); MEDCoupling1SGTUMesh(const MEDCoupling1SGTUMesh& other, bool recDeepCpy); @@ -197,61 +207,61 @@ namespace MEDCoupling MEDCOUPLING_EXPORT static MEDCoupling1DGTUMesh *New(); MEDCOUPLING_EXPORT std::string getClassName() const override { return std::string("MEDCoupling1DGTUMesh"); } // Copy methods - MEDCOUPLING_EXPORT MEDCoupling1DGTUMesh *clone(bool recDeepCpy) const; - MEDCOUPLING_EXPORT MEDCoupling1DGTUMesh *deepCopy() const; - MEDCOUPLING_EXPORT MEDCoupling1DGTUMesh *deepCopyConnectivityOnly() const; + MEDCOUPLING_EXPORT MEDCoupling1DGTUMesh *clone(bool recDeepCpy) const override; + MEDCOUPLING_EXPORT MEDCoupling1DGTUMesh *deepCopy() const override; + MEDCOUPLING_EXPORT MEDCoupling1DGTUMesh *deepCopyConnectivityOnly() const override; // overload of TimeLabel and RefCountObject - MEDCOUPLING_EXPORT void updateTime() const; - MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; - MEDCOUPLING_EXPORT std::vector getDirectChildrenWithNull() const; + MEDCOUPLING_EXPORT void updateTime() const override; + MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const override; + MEDCOUPLING_EXPORT std::vector getDirectChildrenWithNull() const override; // overload of MEDCouplingMesh - MEDCOUPLING_EXPORT MEDCouplingMeshType getType() const { return SINGLE_DYNAMIC_GEO_TYPE_UNSTRUCTURED; } - MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const; - MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const; - MEDCOUPLING_EXPORT void checkFastEquivalWith(const MEDCouplingMesh *other, double prec) const; - MEDCOUPLING_EXPORT void checkConsistencyLight() const; - MEDCOUPLING_EXPORT void checkConsistency(double eps=1e-12) const; - MEDCOUPLING_EXPORT mcIdType getNumberOfCells() const; - MEDCOUPLING_EXPORT DataArrayIdType *computeNbOfNodesPerCell() const; - MEDCOUPLING_EXPORT DataArrayIdType *computeNbOfFacesPerCell() const; - MEDCOUPLING_EXPORT DataArrayIdType *computeEffectiveNbOfNodesPerCell() const; - MEDCOUPLING_EXPORT void getNodeIdsOfCell(mcIdType cellId, std::vector& conn) const; - MEDCOUPLING_EXPORT std::string simpleRepr() const; - MEDCOUPLING_EXPORT std::string advancedRepr() const; - MEDCOUPLING_EXPORT DataArrayDouble *computeIsoBarycenterOfNodesPerCell() const; - MEDCOUPLING_EXPORT void renumberCells(const mcIdType *old2NewBg, bool check=true); - MEDCOUPLING_EXPORT MEDCouplingMesh *mergeMyselfWith(const MEDCouplingMesh *other) const; - MEDCOUPLING_EXPORT MEDCouplingUMesh *buildUnstructured() const; - MEDCOUPLING_EXPORT DataArrayIdType *simplexize(int policy); - MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const; + MEDCOUPLING_EXPORT MEDCouplingMeshType getType() const override { return SINGLE_DYNAMIC_GEO_TYPE_UNSTRUCTURED; } + MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const override; + MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const override; + MEDCOUPLING_EXPORT void checkFastEquivalWith(const MEDCouplingMesh *other, double prec) const override; + MEDCOUPLING_EXPORT void checkConsistencyLight() const override; + MEDCOUPLING_EXPORT void checkConsistency(double eps=1e-12) const override; + MEDCOUPLING_EXPORT mcIdType getNumberOfCells() const override; + MEDCOUPLING_EXPORT DataArrayIdType *computeNbOfNodesPerCell() const override; + MEDCOUPLING_EXPORT DataArrayIdType *computeNbOfFacesPerCell() const override; + MEDCOUPLING_EXPORT DataArrayIdType *computeEffectiveNbOfNodesPerCell() const override; + MEDCOUPLING_EXPORT void getNodeIdsOfCell(mcIdType cellId, std::vector& conn) const override; + MEDCOUPLING_EXPORT std::string simpleRepr() const override; + MEDCOUPLING_EXPORT std::string advancedRepr() const override; + MEDCOUPLING_EXPORT DataArrayDouble *computeIsoBarycenterOfNodesPerCell() const override; + MEDCOUPLING_EXPORT void renumberCells(const mcIdType *old2NewBg, bool check=true) override; + MEDCOUPLING_EXPORT MEDCouplingMesh *mergeMyselfWith(const MEDCouplingMesh *other) const override; + MEDCOUPLING_EXPORT MEDCouplingUMesh *buildUnstructured() const override; + MEDCOUPLING_EXPORT DataArrayIdType *simplexize(int policy) override; + MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const override; // overload of MEDCouplingPointSet - MEDCOUPLING_EXPORT void shallowCopyConnectivityFrom(const MEDCouplingPointSet *other); - MEDCOUPLING_EXPORT MEDCouplingPointSet *mergeMyselfWithOnSameCoords(const MEDCouplingPointSet *other) const; - MEDCOUPLING_EXPORT MEDCouplingPointSet *buildPartOfMySelfKeepCoords(const mcIdType *begin, const mcIdType *end) const; - MEDCOUPLING_EXPORT MEDCouplingPointSet *buildPartOfMySelfKeepCoordsSlice(mcIdType start, mcIdType end, mcIdType step) const; - MEDCOUPLING_EXPORT void computeNodeIdsAlg(std::vector& nodeIdsInUse) const; - MEDCOUPLING_EXPORT void getReverseNodalConnectivity(DataArrayIdType *revNodal, DataArrayIdType *revNodalIndx) const; - MEDCOUPLING_EXPORT void checkFullyDefined() const; - MEDCOUPLING_EXPORT bool isEmptyMesh(const std::vector& tinyInfo) const; - MEDCOUPLING_EXPORT DataArrayIdType *computeFetchedNodeIds() const; - MEDCOUPLING_EXPORT DataArrayIdType *getNodeIdsInUse(mcIdType& nbrOfNodesInUse) const; - MEDCOUPLING_EXPORT void renumberNodesWithOffsetInConn(mcIdType offset); - MEDCOUPLING_EXPORT void renumberNodesInConn(const INTERP_KERNEL::HashMap& newNodeNumbersO2N); + MEDCOUPLING_EXPORT void shallowCopyConnectivityFrom(const MEDCouplingPointSet *other) override; + MEDCOUPLING_EXPORT MEDCouplingPointSet *mergeMyselfWithOnSameCoords(const MEDCouplingPointSet *other) const override; + MEDCOUPLING_EXPORT MEDCouplingPointSet *buildPartOfMySelfKeepCoords(const mcIdType *begin, const mcIdType *end) const override; + MEDCOUPLING_EXPORT MEDCouplingPointSet *buildPartOfMySelfKeepCoordsSlice(mcIdType start, mcIdType end, mcIdType step) const override; + MEDCOUPLING_EXPORT void computeNodeIdsAlg(std::vector& nodeIdsInUse) const override; + MEDCOUPLING_EXPORT void getReverseNodalConnectivity(DataArrayIdType *revNodal, DataArrayIdType *revNodalIndx) const override; + MEDCOUPLING_EXPORT void checkFullyDefined() const override; + MEDCOUPLING_EXPORT bool isEmptyMesh(const std::vector& tinyInfo) const override; + MEDCOUPLING_EXPORT DataArrayIdType *computeFetchedNodeIds() const override; + MEDCOUPLING_EXPORT DataArrayIdType *getNodeIdsInUse(mcIdType& nbrOfNodesInUse) const override; + MEDCOUPLING_EXPORT void renumberNodesWithOffsetInConn(mcIdType offset) override; + MEDCOUPLING_EXPORT void renumberNodesInConn(const INTERP_KERNEL::HashMap& newNodeNumbersO2N) override; MEDCOUPLING_EXPORT void renumberNodesInConn(const std::map& newNodeNumbersO2N) override; - MEDCOUPLING_EXPORT void renumberNodesInConn(const mcIdType *newNodeNumbersO2N); - MEDCOUPLING_EXPORT void fillCellIdsToKeepFromNodeIds(const mcIdType *begin, const mcIdType *end, bool fullyIn, DataArrayIdType *&cellIdsKeptArr) const; - MEDCOUPLING_EXPORT mcIdType getNumberOfNodesInCell(mcIdType cellId) const; - MEDCOUPLING_EXPORT DataArrayDouble *getBoundingBoxForBBTree(double arcDetEps=1e-12) const; - MEDCOUPLING_EXPORT MEDCouplingFieldDouble *computeDiameterField() const; - MEDCOUPLING_EXPORT void invertOrientationOfAllCells(); + MEDCOUPLING_EXPORT void renumberNodesInConn(const mcIdType *newNodeNumbersO2N) override; + MEDCOUPLING_EXPORT void fillCellIdsToKeepFromNodeIds(const mcIdType *begin, const mcIdType *end, bool fullyIn, DataArrayIdType *&cellIdsKeptArr) const override; + MEDCOUPLING_EXPORT mcIdType getNumberOfNodesInCell(mcIdType cellId) const override; + MEDCOUPLING_EXPORT DataArrayDouble *getBoundingBoxForBBTree(double arcDetEps=1e-12) const override; + MEDCOUPLING_EXPORT MEDCouplingFieldDouble *computeDiameterField() const override; + MEDCOUPLING_EXPORT void invertOrientationOfAllCells() override; // overload of MEDCoupling1GTUMesh - MEDCOUPLING_EXPORT void checkConsistencyOfConnectivity() const; - MEDCOUPLING_EXPORT void allocateCells(mcIdType nbOfCells=0); - MEDCOUPLING_EXPORT void insertNextCell(const mcIdType *nodalConnOfCellBg, const mcIdType *nodalConnOfCellEnd); + MEDCOUPLING_EXPORT void checkConsistencyOfConnectivity() const override; + MEDCOUPLING_EXPORT void allocateCells(mcIdType nbOfCells=0) override; + MEDCOUPLING_EXPORT void insertNextCell(const mcIdType *nodalConnOfCellBg, const mcIdType *nodalConnOfCellEnd) override; public://specific MEDCOUPLING_EXPORT void setNodalConnectivity(DataArrayIdType *nodalConn, DataArrayIdType *nodalConnIndex); - MEDCOUPLING_EXPORT DataArrayIdType *getNodalConnectivity() const; + MEDCOUPLING_EXPORT DataArrayIdType *getNodalConnectivity() const override; MEDCOUPLING_EXPORT DataArrayIdType *getNodalConnectivityIndex() const; MEDCOUPLING_EXPORT MEDCoupling1DGTUMesh *copyWithNodalConnectivityPacked(bool& isShallowCpyOfNodalConnn) const; MEDCOUPLING_EXPORT bool retrievePackedNodalConnectivity(DataArrayIdType *&nodalConn, DataArrayIdType *&nodalConnIndx) const; @@ -263,11 +273,11 @@ namespace MEDCoupling MEDCOUPLING_EXPORT static std::vector BuildAPolygonFromParts(const std::vector< std::vector >& parts); MEDCOUPLING_EXPORT MEDCoupling1DGTUMesh *buildSetInstanceFromThis(std::size_t spaceDim) const; public://serialization - MEDCOUPLING_EXPORT void getTinySerializationInformation(std::vector& tinyInfoD, std::vector& tinyInfo, std::vector& littleStrings) const; - MEDCOUPLING_EXPORT void resizeForUnserialization(const std::vector& tinyInfo, DataArrayIdType *a1, DataArrayDouble *a2, std::vector& littleStrings) const; - MEDCOUPLING_EXPORT void serialize(DataArrayIdType *&a1, DataArrayDouble *&a2) const; + MEDCOUPLING_EXPORT void getTinySerializationInformation(std::vector& tinyInfoD, std::vector& tinyInfo, std::vector& littleStrings) const override; + MEDCOUPLING_EXPORT void resizeForUnserialization(const std::vector& tinyInfo, DataArrayIdType *a1, DataArrayDouble *a2, std::vector& littleStrings) const override; + MEDCOUPLING_EXPORT void serialize(DataArrayIdType *&a1, DataArrayDouble *&a2) const override; MEDCOUPLING_EXPORT void unserialization(const std::vector& tinyInfoD, const std::vector& tinyInfo, const DataArrayIdType *a1, DataArrayDouble *a2, - const std::vector& littleStrings); + const std::vector& littleStrings) override; private: MEDCoupling1DGTUMesh(const std::string& name, const INTERP_KERNEL::CellModel& cm); MEDCoupling1DGTUMesh(const MEDCoupling1DGTUMesh& other, bool recDeepCpy); diff --git a/src/MEDCoupling/MEDCoupling1GTUMesh.txx b/src/MEDCoupling/MEDCoupling1GTUMesh.txx index e265cdf4d..afca389b0 100644 --- a/src/MEDCoupling/MEDCoupling1GTUMesh.txx +++ b/src/MEDCoupling/MEDCoupling1GTUMesh.txx @@ -19,8 +19,10 @@ // Author : Anthony Geay (EDF R&D) #pragma once +#include "MCType.hxx" #include "MEDCoupling1GTUMesh.hxx" +#include #include template @@ -28,7 +30,7 @@ void MEDCoupling::MEDCoupling1SGTUMesh::renumberNodesInConnT(const MAPCLS& newNo { getNumberOfCells();//only to check that all is well defined. mcIdType *begPtr(_conn->getPointer()); - mcIdType nbElt(_conn->getNumberOfTuples()); + mcIdType const nbElt(_conn->getNumberOfTuples()); mcIdType *endPtr(begPtr+nbElt); for(mcIdType *it=begPtr;it!=endPtr;it++) { @@ -51,7 +53,7 @@ void MEDCoupling::MEDCoupling1DGTUMesh::renumberNodesInConnT(const MAPCLS& newNo { getNumberOfCells();//only to check that all is well defined. // - mcIdType nbOfTuples(_conn->getNumberOfTuples()); + mcIdType const nbOfTuples(_conn->getNumberOfTuples()); mcIdType *pt(_conn->getPointer()); for(mcIdType i=0;i +#include +#include +#include +#include #include #include #include +#include +#include +#include using namespace MEDCoupling; @@ -42,21 +58,21 @@ DataArrayDoubleCollection *DataArrayDoubleCollection::deepCopy() const void DataArrayDoubleCollection::allocTuples(mcIdType nbOfTuples) { - std::size_t sz(_arrs.size()); + std::size_t const sz(_arrs.size()); for(std::size_t i=0;ireAlloc(nbOfTuples); } void DataArrayDoubleCollection::dellocTuples() { - std::size_t sz(_arrs.size()); + std::size_t const sz(_arrs.size()); for(std::size_t i=0;ireAlloc(0); } void DataArrayDoubleCollection::copyFrom(const DataArrayDoubleCollection& other) { - std::size_t sz(_arrs.size()); + std::size_t const sz(_arrs.size()); if(sz!=other._arrs.size()) throw INTERP_KERNEL::Exception("DataArrayDoubleCollection::copyFrom : size are not the same !"); for(std::size_t i=0;i >& compNames) { - std::size_t sz(_arrs.size()); + std::size_t const sz(_arrs.size()); if(sz!=compNames.size()) throw INTERP_KERNEL::Exception("DataArrayDoubleCollection::spillInfoOnComponents : first size of compNames has to be equal to the number of fields defined !"); for(std::size_t i=0;i& nfs) { - std::size_t sz(_arrs.size()); + std::size_t const sz(_arrs.size()); if(sz!=nfs.size()) throw INTERP_KERNEL::Exception("DataArrayDoubleCollection::spillNatures : first size of vector of NatureOfField has to be equal to the number of fields defined !"); for(std::size_t i=0;i& n std::vector< std::pair < std::string, std::vector > > DataArrayDoubleCollection::getInfoOnComponents() const { - std::size_t sz(_arrs.size()); + std::size_t const sz(_arrs.size()); std::vector< std::pair < std::string, std::vector > > ret(sz); for(std::size_t i=0;i > > DataArrayDoub std::vector DataArrayDoubleCollection::getNatures() const { - std::size_t sz(_arrs.size()); + std::size_t const sz(_arrs.size()); std::vector ret(sz); for(std::size_t i=0;i DataArrayDoubleCollection::getNatures() const std::vector DataArrayDoubleCollection::retrieveFields() const { - std::size_t sz(_arrs.size()); + std::size_t const sz(_arrs.size()); std::vector ret(sz); for(std::size_t i=0;i DataArrayDoubleCollection::retrieveFields() const const DataArrayDouble *DataArrayDoubleCollection::getFieldWithName(const std::string& name) const { std::vector vec; - for(std::vector< std::pair< MCAuto, NatureOfField > >::const_iterator it=_arrs.begin();it!=_arrs.end();it++) + for(const auto & _arr : _arrs) { - const DataArrayDouble *obj((*it).first); + const DataArrayDouble *obj(_arr.first); if(obj) { if(obj->getName()==name) @@ -152,9 +168,9 @@ const DataArrayDouble *DataArrayDoubleCollection::getFieldWithName(const std::st DataArrayDouble *DataArrayDoubleCollection::getFieldWithName(const std::string& name) { std::vector vec; - for(std::vector< std::pair< MCAuto, NatureOfField > >::iterator it=_arrs.begin();it!=_arrs.end();it++) + for(auto & _arr : _arrs) { - DataArrayDouble *obj((*it).first); + DataArrayDouble *obj(_arr.first); if(obj) { if(obj->getName()==name) @@ -191,7 +207,7 @@ void DataArrayDoubleCollection::SynchronizeFineToCoarse(mcIdType ghostLev, const { if(!fine || !coarse) throw INTERP_KERNEL::Exception("DataArrayDoubleCollection::SynchronizeFineToCoarse : the input DataArrayDouble collections must be non NULL !"); - std::size_t sz(coarse->_arrs.size()); + std::size_t const sz(coarse->_arrs.size()); if(fine->_arrs.size()!=sz) throw INTERP_KERNEL::Exception("DataArrayDoubleCollection::SynchronizeFineToCoarse : the input DataArrayDouble collection must have the same size !"); for(std::size_t i=0;i_arrs.size()); + std::size_t const sz(coarse->_arrs.size()); if(fine->_arrs.size()!=sz) throw INTERP_KERNEL::Exception("DataArrayDoubleCollection::SynchronizeCoarseToFine : the input DataArrayDouble collection must have the same size !"); for(std::size_t i=0;i_arrs.size()); + std::size_t const nbOfCall(fieldsOnFine[0]->_arrs.size()); for(std::size_t i=0;igetPatchIdFromChildMesh(children[i])!=ToIdType(i)) throw INTERP_KERNEL::Exception("DataArrayDoubleCollection::SynchronizeFineEachOther : internal error !"); @@ -247,14 +263,14 @@ void DataArrayDoubleCollection::SynchronizeGhostZoneOfOneUsingTwo(mcIdType ghost { if(!p1 || !p1dac || !p2 || !p2dac) throw INTERP_KERNEL::Exception("DataArrayDoubleCollection::SynchronizeGhostZoneOfOneUsingTwo : input pointer must be not NULL !"); - std::size_t sz(p1dac->_arrs.size()); + std::size_t const sz(p1dac->_arrs.size()); if(p2dac->_arrs.size()!=sz) throw INTERP_KERNEL::Exception("DataArrayDoubleCollection::SynchronizeGhostZoneOfOneUsingTwo : size of DataArrayDouble Collection must be the same !"); for(std::size_t i=0;i_arrs[i].first); DataArrayDoubleCollection::CheckSameNatures(p1dac->_arrs[i].second,p2dac->_arrs[i].second); - bool isConservative(DataArrayDoubleCollection::IsConservativeNature(p1dac->_arrs[i].second)); + bool const isConservative(DataArrayDoubleCollection::IsConservativeNature(p1dac->_arrs[i].second)); MEDCouplingCartesianAMRPatch::UpdateNeighborsOfOneWithTwoMixedLev(ghostLev,p1,p2,const_cast(zeArrWhichGhostsWillBeUpdated),p2dac->_arrs[i].first,isConservative); } } @@ -263,7 +279,7 @@ void DataArrayDoubleCollection::SynchronizeCoarseToFineOnlyInGhostZone(mcIdType { if(!fine || !coarse) throw INTERP_KERNEL::Exception("DataArrayDoubleCollection::SynchronizeCoarseToFineOnlyInGhostZone : the input DataArrayDouble collections must be non NULL !"); - std::size_t sz(coarse->_arrs.size()); + std::size_t const sz(coarse->_arrs.size()); if(fine->_arrs.size()!=sz) throw INTERP_KERNEL::Exception("DataArrayDoubleCollection::SynchronizeCoarseToFineOnlyInGhostZone : the input DataArrayDouble collection must have the same size !"); for(std::size_t i=0;i(this)); - std::size_t sz(_arrs.size()); + auto *thisNC(const_cast(this)); + std::size_t const sz(_arrs.size()); if(other._arrs.size()!=sz) throw INTERP_KERNEL::Exception("DataArrayDoubleCollection::synchronizeMyGhostZoneUsing : sizes of collections must match !"); for(std::size_t i=0;i(this)); - std::size_t sz(_arrs.size()); + auto *thisNC(const_cast(this)); + std::size_t const sz(_arrs.size()); if(other._arrs.size()!=sz) throw INTERP_KERNEL::Exception("DataArrayDoubleCollection::synchronizeMyGhostZoneUsingExt : sizes of collections must match !"); for(std::size_t i=0;i >& fieldNames):_arrs(fieldNames.size()) { - std::size_t sz(fieldNames.size()); + std::size_t const sz(fieldNames.size()); std::vector names(sz); for(std::size_t i=0;i DataArrayDoubleCollection::getDirectChildrenWithNull() const { std::vector ret; - for(std::vector< std::pair< MCAuto, NatureOfField > >::const_iterator it=_arrs.begin();it!=_arrs.end();it++) - ret.push_back((const DataArrayDouble *)(*it).first); + for(const auto & _arr : _arrs) + ret.push_back((const DataArrayDouble *)_arr.first); return ret; } void DataArrayDoubleCollection::updateTime() const { - for(std::vector< std::pair< MCAuto, NatureOfField > >::const_iterator it=_arrs.begin();it!=_arrs.end();it++) + for(const auto & _arr : _arrs) { - const DataArrayDouble *pt((*it).first); + const DataArrayDouble *pt(_arr.first); if(pt) updateTimeWith(*pt); } @@ -351,7 +367,7 @@ void DataArrayDoubleCollection::updateTime() const void DataArrayDoubleCollection::CheckDiscriminantNames(const std::vector& names) { - std::set s(names.begin(),names.end()); + std::set const s(names.begin(),names.end()); if(s.size()!=names.size()) throw INTERP_KERNEL::Exception("DataArrayDoubleCollection::CheckDiscriminantNames : The names of fields must be different each other ! It is not the case !"); } @@ -388,10 +404,10 @@ MEDCouplingGridCollection *MEDCouplingGridCollection::deepCopy(const MEDCoupling void MEDCouplingGridCollection::alloc(mcIdType ghostLev) { - for(std::vector< std::pair > >::iterator it=_map_of_dadc.begin();it!=_map_of_dadc.end();it++) + for(auto & it : _map_of_dadc) { - mcIdType nbTuples((*it).first->getNumberOfCellsAtCurrentLevelGhost(ghostLev)); - DataArrayDoubleCollection *dadc((*it).second); + mcIdType const nbTuples(it.first->getNumberOfCellsAtCurrentLevelGhost(ghostLev)); + DataArrayDoubleCollection *dadc(it.second); if(dadc) dadc->allocTuples(nbTuples); else @@ -401,9 +417,9 @@ void MEDCouplingGridCollection::alloc(mcIdType ghostLev) void MEDCouplingGridCollection::dealloc() { - for(std::vector< std::pair > >::iterator it=_map_of_dadc.begin();it!=_map_of_dadc.end();it++) + for(auto & it : _map_of_dadc) { - DataArrayDoubleCollection *dadc((*it).second); + DataArrayDoubleCollection *dadc(it.second); if(dadc) dadc->dellocTuples(); else @@ -413,14 +429,14 @@ void MEDCouplingGridCollection::dealloc() void MEDCouplingGridCollection::spillInfoOnComponents(const std::vector< std::vector >& compNames) { - for(std::vector< std::pair > >::iterator it=_map_of_dadc.begin();it!=_map_of_dadc.end();it++) - (*it).second->spillInfoOnComponents(compNames); + for(auto & it : _map_of_dadc) + it.second->spillInfoOnComponents(compNames); } void MEDCouplingGridCollection::spillNatures(const std::vector& nfs) { - for(std::vector< std::pair > >::iterator it=_map_of_dadc.begin();it!=_map_of_dadc.end();it++) - (*it).second->spillNatures(nfs); + for(auto & it : _map_of_dadc) + it.second->spillNatures(nfs); } std::vector< std::pair > > MEDCouplingGridCollection::getInfoOnComponents() const @@ -446,7 +462,7 @@ std::vector MEDCouplingGridCollection::getNatures() const bool MEDCouplingGridCollection::presenceOf(const MEDCouplingCartesianAMRMeshGen *m, mcIdType& pos) const { mcIdType ret(0); - for(std::vector< std::pair > >::const_iterator it=_map_of_dadc.begin();it!=_map_of_dadc.end();it++,ret++) + for(auto it=_map_of_dadc.begin();it!=_map_of_dadc.end();it++,ret++) { if((*it).first==m) { @@ -478,30 +494,30 @@ DataArrayDoubleCollection& MEDCouplingGridCollection::getFieldsAt(mcIdType pos) */ void MEDCouplingGridCollection::copyOverlappedZoneFrom(mcIdType ghostLev, const MEDCouplingGridCollection& other) { - for(std::vector< std::pair > >::iterator it=_map_of_dadc.begin();it!=_map_of_dadc.end();it++) + for(auto & it : _map_of_dadc) { std::vector deltaThis,deltaOther; - std::vector< std::pair > rgThis((*it).first->positionRelativeToGodFather(deltaThis)); - std::vector thisSt((*it).first->getImageMesh()->getCellGridStructure()); + std::vector< std::pair > const rgThis(it.first->positionRelativeToGodFather(deltaThis)); + std::vector thisSt(it.first->getImageMesh()->getCellGridStructure()); std::transform(thisSt.begin(),thisSt.end(),thisSt.begin(),std::bind(std::plus(),std::placeholders::_1,2*ghostLev)); - for(std::vector< std::pair > >::const_iterator it2=other._map_of_dadc.begin();it2!=other._map_of_dadc.end();it2++) + for(const auto & it2 : other._map_of_dadc) { - std::vector< std::pair > rgOther((*it2).first->positionRelativeToGodFather(deltaOther)); + std::vector< std::pair > const rgOther(it2.first->positionRelativeToGodFather(deltaOther)); if(MEDCouplingStructuredMesh::AreRangesIntersect(rgThis,rgOther)) { - std::vector< std::pair > isect(MEDCouplingStructuredMesh::IntersectRanges(rgThis,rgOther)); + std::vector< std::pair > const isect(MEDCouplingStructuredMesh::IntersectRanges(rgThis,rgOther)); std::vector< std::pair > pThis,pOther; MEDCouplingStructuredMesh::ChangeReferenceFromGlobalOfCompactFrmt(rgThis,isect,pThis,true); MEDCouplingStructuredMesh::ChangeReferenceFromGlobalOfCompactFrmt(rgOther,isect,pOther,true); - std::vector otherSt((*it2).first->getImageMesh()->getCellGridStructure()); + std::vector otherSt(it2.first->getImageMesh()->getCellGridStructure()); MEDCouplingStructuredMesh::ApplyGhostOnCompactFrmt(pThis,ghostLev); MEDCouplingStructuredMesh::ApplyGhostOnCompactFrmt(pOther,ghostLev); std::transform(otherSt.begin(),otherSt.end(),otherSt.begin(),std::bind(std::plus(),std::placeholders::_1,2*ghostLev)); - mcIdType sz((*it2).second->size()); + mcIdType const sz(it2.second->size()); for(mcIdType i=0;iat(i)); - DataArrayDouble *thisArr((*it).second->at(i)); + const DataArrayDouble *otherArr(it2.second->at(i)); + DataArrayDouble *thisArr(it.second->at(i)); MCAuto partOfOther(MEDCouplingStructuredMesh::ExtractFieldOfDoubleFrom(otherSt,otherArr,pOther)); MEDCouplingStructuredMesh::AssignPartOfFieldOfDoubleUsing(thisSt,thisArr,pThis,partOfOther); } @@ -516,20 +532,20 @@ void MEDCouplingGridCollection::SynchronizeFineToCoarse(mcIdType ghostLev, const throw INTERP_KERNEL::Exception("MEDCouplingGridCollection::SynchronizeFineToCoarse : one or more input pointer is NULL !"); const std::vector< std::pair > >& mf(fine->_map_of_dadc); const std::vector< std::pair > >& mc(coarse->_map_of_dadc); - for(std::vector< std::pair > >::const_iterator it=mf.begin();it!=mf.end();it++) + for(const auto & it : mf) { - const MEDCouplingCartesianAMRMeshGen *fineMesh((*it).first); + const MEDCouplingCartesianAMRMeshGen *fineMesh(it.first); const MEDCouplingCartesianAMRMeshGen *fatherOfFineMesh(fineMesh->getFather()); bool found(false); - for(std::vector< std::pair > >::const_iterator it0=mc.begin();it0!=mc.end() && !found;it0++) + for(auto it0=mc.begin();it0!=mc.end() && !found;it0++) { if((*it0).first==fatherOfFineMesh) { found=true; - mcIdType patchId(fatherOfFineMesh->getPatchIdFromChildMesh(fineMesh)); + mcIdType const patchId(fatherOfFineMesh->getPatchIdFromChildMesh(fineMesh)); const DataArrayDoubleCollection *coarseDaCol((*it0).second); - DataArrayDoubleCollection *coarseModified(const_cast(coarseDaCol));//coarse values in DataArrayDouble will be altered - DataArrayDoubleCollection::SynchronizeFineToCoarse(ghostLev,fatherOfFineMesh,patchId,(*it).second,coarseModified); + auto *coarseModified(const_cast(coarseDaCol));//coarse values in DataArrayDouble will be altered + DataArrayDoubleCollection::SynchronizeFineToCoarse(ghostLev,fatherOfFineMesh,patchId,it.second,coarseModified); } } if(!found) @@ -543,19 +559,19 @@ void MEDCouplingGridCollection::SynchronizeCoarseToFine(mcIdType ghostLev, const throw INTERP_KERNEL::Exception("MEDCouplingGridCollection::SynchronizeCoarseToFine : one or more input pointer is NULL !"); const std::vector< std::pair > >& mf(fine->_map_of_dadc); const std::vector< std::pair > >& mc(coarse->_map_of_dadc); - for(std::vector< std::pair > >::const_iterator it=mf.begin();it!=mf.end();it++) + for(const auto & it : mf) { - const MEDCouplingCartesianAMRMeshGen *fineMesh((*it).first); + const MEDCouplingCartesianAMRMeshGen *fineMesh(it.first); const MEDCouplingCartesianAMRMeshGen *fatherOfFineMesh(fineMesh->getFather()); bool found(false); - for(std::vector< std::pair > >::const_iterator it0=mc.begin();it0!=mc.end() && !found;it0++) + for(auto it0=mc.begin();it0!=mc.end() && !found;it0++) { if((*it0).first==fatherOfFineMesh) { found=true; - mcIdType patchId(fatherOfFineMesh->getPatchIdFromChildMesh(fineMesh)); - const DataArrayDoubleCollection *fineDaCol((*it).second); - DataArrayDoubleCollection *fineModified(const_cast(fineDaCol));//fine values in DataArrayDouble will be altered + mcIdType const patchId(fatherOfFineMesh->getPatchIdFromChildMesh(fineMesh)); + const DataArrayDoubleCollection *fineDaCol(it.second); + auto *fineModified(const_cast(fineDaCol));//fine values in DataArrayDouble will be altered DataArrayDoubleCollection::SynchronizeCoarseToFine(ghostLev,fatherOfFineMesh,patchId,(*it0).second,fineModified); } } @@ -571,16 +587,16 @@ void MEDCouplingGridCollection::SynchronizeCoarseToFine(mcIdType ghostLev, const */ void MEDCouplingGridCollection::synchronizeFineEachOther(mcIdType ghostLev, const std::vector< std::pair >& ps) const { - for(std::vector< std::pair >::const_iterator it=ps.begin();it!=ps.end();it++) + for(const auto & p : ps) { mcIdType p1,p2; - if(!presenceOf((*it).first->getMesh(),p1)) + if(!presenceOf(p.first->getMesh(),p1)) throw INTERP_KERNEL::Exception("MEDCouplingGridCollection::synchronizeFineEachOther : internal error #1 !"); - if(!presenceOf((*it).second->getMesh(),p2)) + if(!presenceOf(p.second->getMesh(),p2)) throw INTERP_KERNEL::Exception("MEDCouplingGridCollection::synchronizeFineEachOther : internal error #2 !"); const DataArrayDoubleCollection& col1(getFieldsAt(p1)); const DataArrayDoubleCollection& col2(getFieldsAt(p2)); - col1.synchronizeMyGhostZoneUsing(ghostLev,col2,(*it).first,(*it).second,(*it).first->getMesh()->getFather()); + col1.synchronizeMyGhostZoneUsing(ghostLev,col2,p.first,p.second,p.first->getMesh()->getFather()); } } @@ -591,16 +607,16 @@ void MEDCouplingGridCollection::synchronizeFineEachOther(mcIdType ghostLev, cons */ void MEDCouplingGridCollection::synchronizeFineEachOtherExt(mcIdType ghostLev, const std::vector< std::pair >& ps) const { - for(std::vector< std::pair >::const_iterator it=ps.begin();it!=ps.end();it++) + for(const auto & p : ps) { mcIdType p1,p2; - if(!presenceOf((*it).first->getMesh(),p1)) + if(!presenceOf(p.first->getMesh(),p1)) throw INTERP_KERNEL::Exception("MEDCouplingGridCollection::synchronizeFineEachOtherExt : internal error #1 !"); - if(!presenceOf((*it).second->getMesh(),p2)) + if(!presenceOf(p.second->getMesh(),p2)) throw INTERP_KERNEL::Exception("MEDCouplingGridCollection::synchronizeFineEachOtherExt : internal error #2 !"); const DataArrayDoubleCollection& col1(getFieldsAt(p1)); const DataArrayDoubleCollection& col2(getFieldsAt(p2)); - col1.synchronizeMyGhostZoneUsingExt(ghostLev,col2,(*it).first,(*it).second); + col1.synchronizeMyGhostZoneUsingExt(ghostLev,col2,p.first,p.second); } } @@ -611,22 +627,22 @@ std::vector< std::pair > ret; std::map > m; - for(std::vector< std::pair > >::const_iterator it=_map_of_dadc.begin();it!=_map_of_dadc.end();it++) + for(const auto & it : _map_of_dadc) { - const MEDCouplingCartesianAMRMeshGen *fineMesh((*it).first); + const MEDCouplingCartesianAMRMeshGen *fineMesh(it.first); const MEDCouplingCartesianAMRMeshGen *fatherOfFineMesh(fineMesh->getFather()); m[fatherOfFineMesh].push_back(fineMesh); } for(std::map >::const_iterator it0=m.begin();it0!=m.end();it0++) { - for(std::vector::const_iterator it1=(*it0).second.begin();it1!=(*it0).second.end();it1++) + for(auto it1=(*it0).second.begin();it1!=(*it0).second.end();it1++) { - mcIdType patchId((*it0).first->getPatchIdFromChildMesh(*it1)); - std::vector neighs((*it0).first->getPatchIdsInTheNeighborhoodOf(patchId,ghostLev)); + mcIdType const patchId((*it0).first->getPatchIdFromChildMesh(*it1)); + std::vector const neighs((*it0).first->getPatchIdsInTheNeighborhoodOf(patchId,ghostLev)); const MEDCouplingCartesianAMRPatch *pRef((*it0).first->getPatch(patchId)); - for(std::vector::const_iterator it2=neighs.begin();it2!=neighs.end();it2++) + for(long const neigh : neighs) { - const MEDCouplingCartesianAMRPatch *pLoc((*it0).first->getPatch(*it2)); + const MEDCouplingCartesianAMRPatch *pLoc((*it0).first->getPatch(neigh)); ret.push_back(std::pair(pRef,pLoc)); } } @@ -642,19 +658,19 @@ void MEDCouplingGridCollection::SynchronizeCoarseToFineOnlyInGhostZone(mcIdType throw INTERP_KERNEL::Exception("MEDCouplingGridCollection::SynchronizeCoarseToFineOnlyInGhostZone : one or more input pointer is NULL !"); const std::vector< std::pair > >& mf(fine->_map_of_dadc); const std::vector< std::pair > >& mc(coarse->_map_of_dadc); - for(std::vector< std::pair > >::const_iterator it=mf.begin();it!=mf.end();it++) + for(const auto & it : mf) { - const MEDCouplingCartesianAMRMeshGen *fineMesh((*it).first); + const MEDCouplingCartesianAMRMeshGen *fineMesh(it.first); const MEDCouplingCartesianAMRMeshGen *fatherOfFineMesh(fineMesh->getFather()); bool found(false); - for(std::vector< std::pair > >::const_iterator it0=mc.begin();it0!=mc.end() && !found;it0++) + for(auto it0=mc.begin();it0!=mc.end() && !found;it0++) { if((*it0).first==fatherOfFineMesh) { found=true; - mcIdType patchId(fatherOfFineMesh->getPatchIdFromChildMesh(fineMesh)); - const DataArrayDoubleCollection *fineDaCol((*it).second); - DataArrayDoubleCollection *fineModified(const_cast(fineDaCol));//fine values in DataArrayDouble will be altered + mcIdType const patchId(fatherOfFineMesh->getPatchIdFromChildMesh(fineMesh)); + const DataArrayDoubleCollection *fineDaCol(it.second); + auto *fineModified(const_cast(fineDaCol));//fine values in DataArrayDouble will be altered DataArrayDoubleCollection::SynchronizeCoarseToFineOnlyInGhostZone(ghostLev,fatherOfFineMesh,patchId,(*it0).second,fineModified); } } @@ -665,12 +681,12 @@ void MEDCouplingGridCollection::SynchronizeCoarseToFineOnlyInGhostZone(mcIdType void MEDCouplingGridCollection::fillIfInTheProgenyOf(const std::string& fieldName, const MEDCouplingCartesianAMRMeshGen *head, std::vector& recurseArrs) const { - for(std::vector< std::pair > >::const_iterator it=_map_of_dadc.begin();it!=_map_of_dadc.end();it++) + for(const auto & it : _map_of_dadc) { - const MEDCouplingCartesianAMRMeshGen *a((*it).first); + const MEDCouplingCartesianAMRMeshGen *a(it.first); if(head==a || head->isObjectInTheProgeny(a)) { - const DataArrayDoubleCollection *gc((*it).second); + const DataArrayDoubleCollection *gc(it.second); recurseArrs.push_back(gc->getFieldWithName(fieldName)); } } @@ -678,7 +694,7 @@ void MEDCouplingGridCollection::fillIfInTheProgenyOf(const std::string& fieldNam MEDCouplingGridCollection::MEDCouplingGridCollection(const std::vector& ms, const std::vector< std::pair >& fieldNames):_map_of_dadc(ms.size()) { - std::size_t sz(ms.size()); + std::size_t const sz(ms.size()); for(std::size_t i=0;i pos(other._map_of_dadc[i].first->getPositionRelativeTo(oldGf)); + std::vector const pos(other._map_of_dadc[i].first->getPositionRelativeTo(oldGf)); _map_of_dadc[i].first=newGf->getMeshAtPosition(pos); const DataArrayDoubleCollection *dac(other._map_of_dadc[i].second); if(dac) @@ -711,19 +727,19 @@ std::size_t MEDCouplingGridCollection::getHeapMemorySizeWithoutChildren() const std::vector MEDCouplingGridCollection::getDirectChildrenWithNull() const { std::vector ret; - for(std::vector< std::pair > >::const_iterator it=_map_of_dadc.begin();it!=_map_of_dadc.end();it++) - ret.push_back((const DataArrayDoubleCollection *)(*it).second); + for(const auto & it : _map_of_dadc) + ret.push_back((const DataArrayDoubleCollection *)it.second); return ret; } void MEDCouplingGridCollection::updateTime() const { - for(std::vector< std::pair > >::const_iterator it=_map_of_dadc.begin();it!=_map_of_dadc.end();it++) + for(const auto & it : _map_of_dadc) { - const MEDCouplingCartesianAMRMeshGen *a((*it).first); + const MEDCouplingCartesianAMRMeshGen *a(it.first); if(a) updateTimeWith(*a); - const DataArrayDoubleCollection *b((*it).second); + const DataArrayDoubleCollection *b(it.second); if(b) updateTimeWith(*b); } @@ -755,7 +771,7 @@ void MEDCouplingDataForGodFather::checkGodFatherFrozen() const bool MEDCouplingDataForGodFather::changeGodFather(MEDCouplingCartesianAMRMesh *gf) { - bool ret(_tlc.keepTrackOfNewTL(gf)); + bool const ret(_tlc.keepTrackOfNewTL(gf)); if(ret) { _gf=gf; @@ -772,7 +788,7 @@ MEDCouplingDataForGodFather::MEDCouplingDataForGodFather(const MEDCouplingDataFo { const MEDCouplingCartesianAMRMesh *gf(other._gf); if(gf) - _gf=gf->deepCopy(0); + _gf=gf->deepCopy(nullptr); _tlc.keepTrackOfNewTL(_gf); } } @@ -787,7 +803,7 @@ MEDCouplingAMRAttribute *MEDCouplingAMRAttribute::New(MEDCouplingCartesianAMRMes MEDCouplingAMRAttribute *MEDCouplingAMRAttribute::New(MEDCouplingCartesianAMRMesh *gf, const std::vector< std::pair > >& fieldNames, mcIdType ghostLev) { - std::size_t sz(fieldNames.size()); + std::size_t const sz(fieldNames.size()); std::vector< std::pair > fieldNames2(sz); std::vector< std::vector > compNames(sz); for(std::size_t i=0;i >& compNames) { _tlc.checkConst(); - for(std::vector< MCAuto >::iterator it=_levs.begin();it!=_levs.end();it++) - (*it)->spillInfoOnComponents(compNames); + for(auto & _lev : _levs) + _lev->spillInfoOnComponents(compNames); } /*! @@ -821,8 +837,8 @@ void MEDCouplingAMRAttribute::spillInfoOnComponents(const std::vector< std::vect void MEDCouplingAMRAttribute::spillNatures(const std::vector& nfs) { _tlc.checkConst(); - for(std::vector< MCAuto >::iterator it=_levs.begin();it!=_levs.end();it++) - (*it)->spillNatures(nfs); + for(auto & _lev : _levs) + _lev->spillNatures(nfs); } MEDCouplingAMRAttribute *MEDCouplingAMRAttribute::deepCopy() const @@ -854,12 +870,12 @@ mcIdType MEDCouplingAMRAttribute::getNumberOfLevels() const */ std::vector MEDCouplingAMRAttribute::retrieveFieldsOn(MEDCouplingCartesianAMRMeshGen *mesh) const { - for(std::vector< MCAuto >::const_iterator it=_levs.begin();it!=_levs.end();it++) + for(const auto & _lev : _levs) { mcIdType tmp(-1); - if((*it)->presenceOf(mesh,tmp)) + if(_lev->presenceOf(mesh,tmp)) { - const DataArrayDoubleCollection& ddc((*it)->getFieldsAt(tmp)); + const DataArrayDoubleCollection& ddc(_lev->getFieldsAt(tmp)); return ddc.retrieveFields(); } } @@ -871,12 +887,12 @@ std::vector MEDCouplingAMRAttribute::retrieveFieldsOn(MEDCoup */ const DataArrayDouble *MEDCouplingAMRAttribute::getFieldOn(MEDCouplingCartesianAMRMeshGen *mesh, const std::string& fieldName) const { - for(std::vector< MCAuto >::const_iterator it=_levs.begin();it!=_levs.end();it++) + for(const auto & _lev : _levs) { mcIdType tmp(-1); - if((*it)->presenceOf(mesh,tmp)) + if(_lev->presenceOf(mesh,tmp)) { - const DataArrayDoubleCollection& ddc((*it)->getFieldsAt(tmp)); + const DataArrayDoubleCollection& ddc(_lev->getFieldsAt(tmp)); return ddc.getFieldWithName(fieldName); } } @@ -885,12 +901,12 @@ const DataArrayDouble *MEDCouplingAMRAttribute::getFieldOn(MEDCouplingCartesianA DataArrayDouble *MEDCouplingAMRAttribute::getFieldOn(MEDCouplingCartesianAMRMeshGen *mesh, const std::string& fieldName) { - for(std::vector< MCAuto >::iterator it=_levs.begin();it!=_levs.end();it++) + for(auto & _lev : _levs) { mcIdType tmp(-1); - if((*it)->presenceOf(mesh,tmp)) + if(_lev->presenceOf(mesh,tmp)) { - DataArrayDoubleCollection& ddc((*it)->getFieldsAt(tmp)); + DataArrayDoubleCollection& ddc(_lev->getFieldsAt(tmp)); return ddc.getFieldWithName(fieldName); } } @@ -907,7 +923,7 @@ MEDCouplingFieldDouble *MEDCouplingAMRAttribute::buildCellFieldOnRecurseWithoutO { std::vector recurseArrs; std::size_t lev(0); - for(std::vector< MCAuto >::const_iterator it=_levs.begin();it!=_levs.end();it++,lev++) + for(auto it=_levs.begin();it!=_levs.end();it++,lev++) { mcIdType tmp(-1); if((*it)->presenceOf(mesh,tmp)) @@ -936,13 +952,13 @@ MEDCouplingFieldDouble *MEDCouplingAMRAttribute::buildCellFieldOnRecurseWithoutO */ MEDCouplingFieldDouble *MEDCouplingAMRAttribute::buildCellFieldOnWithGhost(MEDCouplingCartesianAMRMeshGen *mesh, const std::string& fieldName) const { - const DataArrayDouble *arr(0); - for(std::vector< MCAuto >::const_iterator it=_levs.begin();it!=_levs.end();it++) + const DataArrayDouble *arr(nullptr); + for(const auto & _lev : _levs) { mcIdType tmp(-1); - if((*it)->presenceOf(mesh,tmp)) + if(_lev->presenceOf(mesh,tmp)) { - const DataArrayDoubleCollection& ddc((*it)->getFieldsAt(tmp)); + const DataArrayDoubleCollection& ddc(_lev->getFieldsAt(tmp)); arr=ddc.getFieldWithName(fieldName); } } @@ -966,26 +982,26 @@ MEDCouplingFieldDouble *MEDCouplingAMRAttribute::buildCellFieldOnWithGhost(MEDCo */ MEDCouplingFieldDouble *MEDCouplingAMRAttribute::buildCellFieldOnWithoutGhost(MEDCouplingCartesianAMRMeshGen *mesh, const std::string& fieldName) const { - const DataArrayDouble *arr(0); - for(std::vector< MCAuto >::const_iterator it=_levs.begin();it!=_levs.end();it++) + const DataArrayDouble *arr(nullptr); + for(const auto & _lev : _levs) { mcIdType tmp(-1); - if((*it)->presenceOf(mesh,tmp)) + if(_lev->presenceOf(mesh,tmp)) { - const DataArrayDoubleCollection& ddc((*it)->getFieldsAt(tmp)); + const DataArrayDoubleCollection& ddc(_lev->getFieldsAt(tmp)); arr=ddc.getFieldWithName(fieldName); } } if(!arr) throw INTERP_KERNEL::Exception("MEDCouplingAMRAttribute::buildCellFieldOnWithoutGhost : the mesh specified is not in the progeny of this !"); // - MCAuto im(mesh->getImageMesh()->buildWithGhost(_ghost_lev)); + MCAuto const im(mesh->getImageMesh()->buildWithGhost(_ghost_lev)); std::vector cgs(mesh->getImageMesh()->getCellGridStructure()),cgsWG(im->getCellGridStructure()); MCAuto arr2(DataArrayDouble::New()); arr2->alloc(mesh->getImageMesh()->getNumberOfCells(),arr->getNumberOfComponents()); std::vector< std::pair > cgs2(MEDCouplingStructuredMesh::GetCompactFrmtFromDimensions(cgs)); MEDCouplingStructuredMesh::ApplyGhostOnCompactFrmt(cgs2,_ghost_lev); - std::vector fakeFactors(mesh->getImageMesh()->getSpaceDimension(),1); + std::vector const fakeFactors(mesh->getImageMesh()->getSpaceDimension(),1); MEDCouplingIMesh::SpreadCoarseToFine(arr,cgsWG,arr2,cgs2,fakeFactors); arr2->copyStringInfoFrom(*arr); // @@ -1014,7 +1030,7 @@ std::string MEDCouplingAMRAttribute::writeVTHB(const std::string& fileName) cons const MEDCouplingIMesh *gfm(gf->getImageMesh()); std::vector orig(gfm->getOrigin()); std::vector spacing(gfm->getDXYZ()); - mcIdType dim(ToIdType(orig.size())); + mcIdType const dim(ToIdType(orig.size())); std::copy(orig.begin(),orig.end(),std::ostream_iterator(ofs," ")); ofs << "\" grid_description=\""; for(mcIdType i=0;i patches(gf->retrieveGridsAt(i)); - std::size_t sz(patches.size()); + std::size_t const sz(patches.size()); std::vector< MCAuto > patchesSafe(sz); for(std::size_t j=0;j::const_iterator it=patches.begin();it!=patches.end();it++,jj++,kk++) { ofs << " (*it)); + const auto *patchCast(dynamic_cast(*it)); const MEDCouplingCartesianAMRMeshGen *mesh((*it)->getMesh()); if(patchCast) { @@ -1068,7 +1084,7 @@ std::string MEDCouplingAMRAttribute::writeVTHB(const std::string& fileName) cons { const DataArrayDoubleCollection& ddc(_levs[i]->getFieldsAt(tmp)); std::vector arrs(ddc.retrieveFields()); - std::size_t nbFields(arrs.size()); + std::size_t const nbFields(arrs.size()); std::vector< MCAuto > arrsSafe(nbFields),arrs2Safe(nbFields); std::vector< const MEDCouplingFieldDouble *> fields(nbFields); std::vector< MCAuto > fieldsSafe(nbFields); @@ -1076,13 +1092,13 @@ std::string MEDCouplingAMRAttribute::writeVTHB(const std::string& fileName) cons arrsSafe[pp]=arrs[pp]; for(std::size_t pp=0;pp im(mesh->getImageMesh()->buildWithGhost(_ghost_lev)); + MCAuto const im(mesh->getImageMesh()->buildWithGhost(_ghost_lev)); std::vector cgs(mesh->getImageMesh()->getCellGridStructure()),cgsWG(im->getCellGridStructure()); arrs2Safe[pp]=DataArrayDouble::New(); arrs2Safe[pp]->alloc(mesh->getImageMesh()->getNumberOfCells(),arrs[pp]->getNumberOfComponents()); std::vector< std::pair > cgs2(MEDCouplingStructuredMesh::GetCompactFrmtFromDimensions(cgs)); MEDCouplingStructuredMesh::ApplyGhostOnCompactFrmt(cgs2,_ghost_lev); - std::vector fakeFactors(mesh->getImageMesh()->getSpaceDimension(),1); + std::vector const fakeFactors(mesh->getImageMesh()->getSpaceDimension(),1); MEDCouplingIMesh::SpreadCoarseToFine(arrs[pp],cgsWG,arrs2Safe[pp],cgs2,fakeFactors); arrs2Safe[pp]->copyStringInfoFrom(*arrs[pp]); // @@ -1127,11 +1143,11 @@ MEDCouplingAMRAttribute *MEDCouplingAMRAttribute::projectTo(MEDCouplingCartesian const MEDCouplingGridCollection *lev0(_levs[0]); if(!lev0) throw INTERP_KERNEL::Exception("MEDCouplingAMRAttribute::projectTo : lev0 is NULL !"); - std::vector< std::pair < std::string, std::vector > > fieldNames(lev0->getInfoOnComponents()); + std::vector< std::pair < std::string, std::vector > > const fieldNames(lev0->getInfoOnComponents()); MCAuto ret(MEDCouplingAMRAttribute::New(targetGF,fieldNames,_ghost_lev)); ret->spillNatures(lev0->getNatures()); ret->alloc(); - mcIdType nbLevs(getNumberOfLevels()); + mcIdType const nbLevs(getNumberOfLevels()); if(targetGF->getMaxNumberOfLevelsRelativeToThis()!=nbLevs) throw INTERP_KERNEL::Exception("MEDCouplingAMRAttribute::projectTo : number of levels of this and targetGF must be the same !"); // first step copy level0 @@ -1187,7 +1203,7 @@ void MEDCouplingAMRAttribute::synchronizeFineToCoarse() */ void MEDCouplingAMRAttribute::synchronizeFineToCoarseBetween(mcIdType fromLev, mcIdType toLev) { - mcIdType nbl(getNumberOfLevels()); + mcIdType const nbl(getNumberOfLevels()); if(fromLev<0 || toLev<0 || fromLev>=nbl || toLev>=nbl) throw INTERP_KERNEL::Exception("MEDCouplingAMRAttribute::synchronizeFineToCoarseBetween : fromLev and toLev must be >= 0 and lower than number of levels in this !"); if(fromLev==toLev) @@ -1207,7 +1223,7 @@ void MEDCouplingAMRAttribute::synchronizeCoarseToFine() { if(_levs.empty()) throw INTERP_KERNEL::Exception("MEDCouplingAMRAttribute::synchronizeCoarseToFine : not any levels in this !"); - std::size_t sz(_levs.size()); + std::size_t const sz(_levs.size()); // for(std::size_t i=0;i=nbl || toLev>=nbl) throw INTERP_KERNEL::Exception("MEDCouplingAMRAttribute::synchronizeCoarseToFineBetween : fromLev and toLev must be >= 0 and lower than number of levels in this !"); if(fromLev==toLev) @@ -1249,7 +1265,7 @@ void MEDCouplingAMRAttribute::synchronizeCoarseToFineBetween(mcIdType fromLev, m */ void MEDCouplingAMRAttribute::synchronizeAllGhostZones() { - mcIdType sz(getNumberOfLevels()); + mcIdType const sz(getNumberOfLevels()); if(sz==0) throw INTERP_KERNEL::Exception("MEDCouplingAMRAttribute::synchronizeFineEachOther : not any levels in this !"); // 1st - synchronize from coarse to the finest all the patches (excepted the god father one) @@ -1267,10 +1283,10 @@ void MEDCouplingAMRAttribute::synchronizeAllGhostZones() curLev->synchronizeFineEachOther(_ghost_lev,_neighbors[i]); } // 3rd - mixed level - for(std::vector< std::pair >::const_iterator it=_mixed_lev_neighbors.begin();it!=_mixed_lev_neighbors.end();it++) + for(const auto & _mixed_lev_neighbor : _mixed_lev_neighbors) { - const DataArrayDoubleCollection *firstDAC(&findCollectionAttachedTo((*it).first->getMesh())),*secondDAC(&findCollectionAttachedTo((*it).second->getMesh())); - DataArrayDoubleCollection::SynchronizeGhostZoneOfOneUsingTwo(_ghost_lev,(*it).first,firstDAC,(*it).second,secondDAC); + const DataArrayDoubleCollection *firstDAC(&findCollectionAttachedTo(_mixed_lev_neighbor.first->getMesh())),*secondDAC(&findCollectionAttachedTo(_mixed_lev_neighbor.second->getMesh())); + DataArrayDoubleCollection::SynchronizeGhostZoneOfOneUsingTwo(_ghost_lev,_mixed_lev_neighbor.first,firstDAC,_mixed_lev_neighbor.second,secondDAC); } // 4th - same level but with far ancestor. for(mcIdType i=1;i >& itemsToFilter(_neighbors[level+1]); std::vector< std::pair > itemsToSync; itemsToSync.reserve(itemsToFilter.size()); - for(std::vector< std::pair >::const_iterator it=itemsToFilter.begin();it!=itemsToFilter.end();it++) + for(const auto & it : itemsToFilter) { - if((*it).first->getMesh()->getFather()==mesh && (*it).second->getMesh()->getFather()==mesh) - itemsToSync.push_back(std::pair((*it).first,(*it).second)); + if(it.first->getMesh()->getFather()==mesh && it.second->getMesh()->getFather()==mesh) + itemsToSync.push_back(std::pair(it.first,it.second)); } const MEDCouplingGridCollection *curLev(_levs[level+1]); if(!curLev) @@ -1315,7 +1331,7 @@ void MEDCouplingAMRAttribute::synchronizeAllGhostZonesOfDirectChidrenOf(const ME */ void MEDCouplingAMRAttribute::synchronizeAllGhostZonesAtASpecifiedLevel(mcIdType level) { - mcIdType maxLev(getNumberOfLevels()); + mcIdType const maxLev(getNumberOfLevels()); if(level<0 || level>=maxLev) throw INTERP_KERNEL::Exception("MEDCouplingAMRAttribute::synchronizeAllGhostZonesAtASpecifiedLevel : the specified level must be in [0,maxLevel) !"); if(level==0) @@ -1337,7 +1353,7 @@ void MEDCouplingAMRAttribute::synchronizeAllGhostZonesAtASpecifiedLevel(mcIdType */ void MEDCouplingAMRAttribute::synchronizeAllGhostZonesAtASpecifiedLevelUsingOnlyFather(mcIdType level) { - mcIdType maxLev(getNumberOfLevels()); + mcIdType const maxLev(getNumberOfLevels()); if(level<=0 || level>=maxLev) throw INTERP_KERNEL::Exception("MEDCouplingAMRAttribute::synchronizeAllGhostZonesAtASpecifiedLevelUsingOnlyFather : the specified level must be in (0,maxLevel) !"); const MEDCouplingGridCollection *fine(_levs[level]),*coarse(_levs[level-1]); @@ -1353,9 +1369,9 @@ void MEDCouplingAMRAttribute::synchronizeAllGhostZonesAtASpecifiedLevelUsingOnly void MEDCouplingAMRAttribute::alloc() { _tlc.resetState(); - for(std::vector< MCAuto >::iterator it=_levs.begin();it!=_levs.end();it++) + for(auto & _lev : _levs) { - MEDCouplingGridCollection *elt(*it); + MEDCouplingGridCollection *elt(_lev); if(elt) elt->alloc(_ghost_lev); else @@ -1370,9 +1386,9 @@ void MEDCouplingAMRAttribute::alloc() void MEDCouplingAMRAttribute::dealloc() { _tlc.checkConst(); - for(std::vector< MCAuto >::iterator it=_levs.begin();it!=_levs.end();it++) + for(auto & _lev : _levs) { - MEDCouplingGridCollection *elt(*it); + MEDCouplingGridCollection *elt(_lev); if(elt) elt->dealloc(); else @@ -1382,7 +1398,7 @@ void MEDCouplingAMRAttribute::dealloc() bool MEDCouplingAMRAttribute::changeGodFather(MEDCouplingCartesianAMRMesh *gf) { - bool ret(MEDCouplingDataForGodFather::changeGodFather(gf)); + bool const ret(MEDCouplingDataForGodFather::changeGodFather(gf)); return ret; } @@ -1396,8 +1412,8 @@ std::size_t MEDCouplingAMRAttribute::getHeapMemorySizeWithoutChildren() const std::vector MEDCouplingAMRAttribute::getDirectChildrenWithNull() const { std::vector ret; - for(std::vector< MCAuto >::const_iterator it=_levs.begin();it!=_levs.end();it++) - ret.push_back((const MEDCouplingGridCollection *)*it); + for(const auto & _lev : _levs) + ret.push_back((const MEDCouplingGridCollection *)_lev); return ret; } @@ -1408,12 +1424,12 @@ void MEDCouplingAMRAttribute::updateTime() const MEDCouplingAMRAttribute::MEDCouplingAMRAttribute(MEDCouplingCartesianAMRMesh *gf, const std::vector< std::pair >& fieldNames, mcIdType ghostLev):MEDCouplingDataForGodFather(gf),_ghost_lev(ghostLev) { //gf non empty, checked by constructor - mcIdType maxLev(gf->getMaxNumberOfLevelsRelativeToThis()); + mcIdType const maxLev(gf->getMaxNumberOfLevelsRelativeToThis()); _levs.resize(maxLev); for(mcIdType i=0;i patches(gf->retrieveGridsAt(i)); - std::size_t sz(patches.size()); + std::size_t const sz(patches.size()); std::vector< MCAuto > patchesSafe(patches.size()); for(std::size_t j=0;j > > neighs2(MEDCouplingCartesianAMRPatch::FindNeighborsOfSubPatchesOfSameLev(_ghost_lev,(*it).first,(*it).second)); - std::size_t fullLev(i+neighs2.size()); + std::size_t const fullLev(i+neighs2.size()); if(fullLev>=sz) throw INTERP_KERNEL::Exception("constructor of MEDCouplingAMRAttribute : internal error ! something is wrong in computation of cross level neighbors !"); std::size_t ii(i+1); @@ -1469,7 +1485,7 @@ MEDCouplingAMRAttribute::MEDCouplingAMRAttribute(const MEDCouplingAMRAttribute& for(std::size_t i=0;i >& neigh2(other._neighbors[i]); - std::size_t sz2(neigh2.size()); + std::size_t const sz2(neigh2.size()); std::vector< std::pair >& neigh3(_neighbors[i]); for(std::size_t j=0;j >& neigh2(other._cross_lev_neighbors[i]); - std::size_t sz2(neigh2.size()); + std::size_t const sz2(neigh2.size()); std::vector< std::pair >& neigh3(_cross_lev_neighbors[i]); for(std::size_t j=0;j >::const_iterator it=_levs.begin();it!=_levs.end();it++) + for(const auto & _lev : _levs) { - const MEDCouplingGridCollection *elt(*it); + const MEDCouplingGridCollection *elt(_lev); if(elt) { mcIdType tmp(-1); @@ -1524,7 +1540,7 @@ const DataArrayDoubleCollection& MEDCouplingAMRAttribute::findCollectionAttached void MEDCouplingAMRAttribute::synchronizeFineToCoarseByOneLevel(mcIdType level) { - mcIdType nbl(getNumberOfLevels()); + mcIdType const nbl(getNumberOfLevels()); if(level<=0 || level>=nbl) throw INTERP_KERNEL::Exception("MEDCouplingAMRAttribute::synchronizeFineToCoarseByOneLevel : the input level must be in ]0,nb_of_levels[ !"); const MEDCouplingGridCollection *fine(_levs[level]),*coarse(_levs[level-1]); @@ -1533,7 +1549,7 @@ void MEDCouplingAMRAttribute::synchronizeFineToCoarseByOneLevel(mcIdType level) void MEDCouplingAMRAttribute::synchronizeCoarseToFineByOneLevel(mcIdType level) { - mcIdType nbl(getNumberOfLevels()); + mcIdType const nbl(getNumberOfLevels()); if(level<0 || level>=nbl-1) throw INTERP_KERNEL::Exception("MEDCouplingAMRAttribute::synchronizeFineToCoarseByOneLevel : the input level must be in [0,nb_of_levels[ !"); const MEDCouplingGridCollection *fine(_levs[level+1]),*coarse(_levs[level]); diff --git a/src/MEDCoupling/MEDCouplingAMRAttribute.hxx b/src/MEDCoupling/MEDCouplingAMRAttribute.hxx index 416e1ac51..ec4edf384 100644 --- a/src/MEDCoupling/MEDCouplingAMRAttribute.hxx +++ b/src/MEDCoupling/MEDCouplingAMRAttribute.hxx @@ -21,9 +21,17 @@ #ifndef __MEDCOUPLINGAMRATTRIBUTE_HXX__ #define __MEDCOUPLINGAMRATTRIBUTE_HXX__ +#include "MCType.hxx" +#include "MCAuto.hxx" #include "MEDCoupling.hxx" #include "MEDCouplingNatureOfFieldEnum" #include "MEDCouplingCartesianAMRMesh.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include "MEDCouplingTimeLabel.hxx" +#include +#include +#include +#include namespace MEDCoupling { @@ -57,9 +65,9 @@ namespace MEDCoupling private: DataArrayDoubleCollection(const std::vector< std::pair >& fieldNames); DataArrayDoubleCollection(const DataArrayDoubleCollection& other); - std::size_t getHeapMemorySizeWithoutChildren() const; - std::vector getDirectChildrenWithNull() const; - void updateTime() const; + std::size_t getHeapMemorySizeWithoutChildren() const override; + std::vector getDirectChildrenWithNull() const override; + void updateTime() const override; static void CheckDiscriminantNames(const std::vector& names); static bool IsConservativeNature(NatureOfField n); static void CheckSameNatures(NatureOfField n1, NatureOfField n2); @@ -94,9 +102,9 @@ namespace MEDCoupling private: MEDCouplingGridCollection(const std::vector& ms, const std::vector< std::pair >& fieldNames); MEDCouplingGridCollection(const MEDCouplingGridCollection& other, const MEDCouplingCartesianAMRMeshGen *newGf, const MEDCouplingCartesianAMRMeshGen *oldGf); - std::size_t getHeapMemorySizeWithoutChildren() const; - std::vector getDirectChildrenWithNull() const; - void updateTime() const; + std::size_t getHeapMemorySizeWithoutChildren() const override; + std::vector getDirectChildrenWithNull() const override; + void updateTime() const override; private: std::vector< std::pair > > _map_of_dadc; }; @@ -152,22 +160,22 @@ namespace MEDCoupling // MEDCOUPLING_EXPORT MEDCouplingAMRAttribute *projectTo(MEDCouplingCartesianAMRMesh *targetGF) const; // - MEDCOUPLING_EXPORT void synchronizeFineToCoarse(); - MEDCOUPLING_EXPORT void synchronizeFineToCoarseBetween(mcIdType fromLev, mcIdType toLev); - MEDCOUPLING_EXPORT void synchronizeCoarseToFine(); - MEDCOUPLING_EXPORT void synchronizeCoarseToFineBetween(mcIdType fromLev, mcIdType toLev); - MEDCOUPLING_EXPORT void synchronizeAllGhostZones(); - MEDCOUPLING_EXPORT void synchronizeAllGhostZonesOfDirectChidrenOf(const MEDCouplingCartesianAMRMeshGen *mesh); - MEDCOUPLING_EXPORT void synchronizeAllGhostZonesAtASpecifiedLevel(mcIdType level); - MEDCOUPLING_EXPORT void synchronizeAllGhostZonesAtASpecifiedLevelUsingOnlyFather(mcIdType level); + MEDCOUPLING_EXPORT void synchronizeFineToCoarse() override; + MEDCOUPLING_EXPORT void synchronizeFineToCoarseBetween(mcIdType fromLev, mcIdType toLev) override; + MEDCOUPLING_EXPORT void synchronizeCoarseToFine() override; + MEDCOUPLING_EXPORT void synchronizeCoarseToFineBetween(mcIdType fromLev, mcIdType toLev) override; + MEDCOUPLING_EXPORT void synchronizeAllGhostZones() override; + MEDCOUPLING_EXPORT void synchronizeAllGhostZonesOfDirectChidrenOf(const MEDCouplingCartesianAMRMeshGen *mesh) override; + MEDCOUPLING_EXPORT void synchronizeAllGhostZonesAtASpecifiedLevel(mcIdType level) override; + MEDCOUPLING_EXPORT void synchronizeAllGhostZonesAtASpecifiedLevelUsingOnlyFather(mcIdType level) override; // - MEDCOUPLING_EXPORT void alloc(); - MEDCOUPLING_EXPORT void dealloc(); - MEDCOUPLING_EXPORT bool changeGodFather(MEDCouplingCartesianAMRMesh *gf); + MEDCOUPLING_EXPORT void alloc() override; + MEDCOUPLING_EXPORT void dealloc() override; + MEDCOUPLING_EXPORT bool changeGodFather(MEDCouplingCartesianAMRMesh *gf) override; // - MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; - MEDCOUPLING_EXPORT std::vector getDirectChildrenWithNull() const; - MEDCOUPLING_EXPORT void updateTime() const; + MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const override; + MEDCOUPLING_EXPORT std::vector getDirectChildrenWithNull() const override; + MEDCOUPLING_EXPORT void updateTime() const override; private: MEDCouplingAMRAttribute(MEDCouplingCartesianAMRMesh *gf, const std::vector< std::pair >& fieldNames, mcIdType ghostLev); MEDCouplingAMRAttribute(const MEDCouplingAMRAttribute& other, bool deepCpyGF); diff --git a/src/MEDCoupling/MEDCouplingCMesh.cxx b/src/MEDCoupling/MEDCouplingCMesh.cxx old mode 100755 new mode 100644 index d80b5a36a..02bd41b24 --- a/src/MEDCoupling/MEDCouplingCMesh.cxx +++ b/src/MEDCoupling/MEDCouplingCMesh.cxx @@ -19,20 +19,31 @@ // Author : Anthony Geay (CEA/DEN) #include "MEDCouplingCMesh.hxx" +#include "MCAuto.hxx" +#include "MCType.hxx" +#include "MCIdType.hxx" #include "MEDCouplingMemArray.hxx" #include "MEDCouplingFieldDouble.hxx" #include "MEDCouplingCurveLinearMesh.hxx" #include "InterpKernelAutoPtr.hxx" +#include "MEDCouplingStructuredMesh.hxx" +#include "MEDCouplingMesh.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include #include #include +#include +#include #include -#include +#include +#include +#include using namespace MEDCoupling; -MEDCouplingCMesh::MEDCouplingCMesh():_x_array(0),_y_array(0),_z_array(0) +MEDCouplingCMesh::MEDCouplingCMesh():_x_array(nullptr),_y_array(nullptr),_z_array(nullptr) { } @@ -43,15 +54,15 @@ MEDCouplingCMesh::MEDCouplingCMesh(const MEDCouplingCMesh& other, bool deepCpy): if(other._x_array) _x_array=other._x_array->deepCopy(); else - _x_array=0; + _x_array=nullptr; if(other._y_array) _y_array=other._y_array->deepCopy(); else - _y_array=0; + _y_array=nullptr; if(other._z_array) _z_array=other._z_array->deepCopy(); else - _z_array=0; + _z_array=nullptr; } else { @@ -84,7 +95,7 @@ MEDCouplingCMesh *MEDCouplingCMesh::New() MEDCouplingCMesh *MEDCouplingCMesh::New(const std::string& meshName) { - MEDCouplingCMesh *ret(new MEDCouplingCMesh); + auto *ret(new MEDCouplingCMesh); ret->setName(meshName); return ret; } @@ -107,7 +118,7 @@ const DataArrayDouble *MEDCouplingCMesh::getDirectAccessOfCoordsArrIfInStructure MEDCouplingCurveLinearMesh *MEDCouplingCMesh::buildCurveLinear() const { checkConsistencyLight(); - std::size_t dim(getSpaceDimension()); + std::size_t const dim(getSpaceDimension()); MCAuto ret(MEDCouplingCurveLinearMesh::New()); ret->MEDCouplingStructuredMesh::operator=(*this); INTERP_KERNEL::AutoPtr ngs(new mcIdType[dim]); @@ -149,7 +160,7 @@ std::vector MEDCouplingCMesh::getDirectChildrenWithNull void MEDCouplingCMesh::copyTinyStringsFrom(const MEDCouplingMesh *other) { MEDCouplingStructuredMesh::copyTinyStringsFrom(other); - const MEDCouplingCMesh *otherC(dynamic_cast(other)); + const auto *otherC(dynamic_cast(other)); if(!otherC) throw INTERP_KERNEL::Exception("MEDCouplingCMesh::copyTinyStringsFrom : meshes have not same type !"); if(_x_array && otherC->_x_array) @@ -164,7 +175,7 @@ bool MEDCouplingCMesh::isEqualIfNotWhy(const MEDCouplingMesh *other, double prec { if(!other) throw INTERP_KERNEL::Exception("MEDCouplingCMesh::isEqualIfNotWhy : input other pointer is null !"); - const MEDCouplingCMesh *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) { reason="mesh given in input is not castable in MEDCouplingCMesh !"; @@ -177,7 +188,7 @@ bool MEDCouplingCMesh::isEqualIfNotWhy(const MEDCouplingMesh *other, double prec std::ostringstream oss; oss.precision(15); for(int i=0;i<3;i++) { - if((thisArr[i]!=0 && otherArr[i]==0) || (thisArr[i]==0 && otherArr[i]!=0)) + if((thisArr[i]!=nullptr && otherArr[i]==nullptr) || (thisArr[i]==nullptr && otherArr[i]!=nullptr)) { oss << "Only one CMesh between the two this and other has its coordinates of rank" << i << " defined !"; reason=oss.str(); @@ -196,14 +207,14 @@ bool MEDCouplingCMesh::isEqualIfNotWhy(const MEDCouplingMesh *other, double prec bool MEDCouplingCMesh::isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const { - const MEDCouplingCMesh *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) return false; const DataArrayDouble *thisArr[3]={_x_array,_y_array,_z_array}; const DataArrayDouble *otherArr[3]={otherC->_x_array,otherC->_y_array,otherC->_z_array}; for(int i=0;i<3;i++) { - if((thisArr[i]!=0 && otherArr[i]==0) || (thisArr[i]==0 && otherArr[i]!=0)) + if((thisArr[i]!=nullptr && otherArr[i]==nullptr) || (thisArr[i]==nullptr && otherArr[i]!=nullptr)) return false; if(thisArr[i]) if(!thisArr[i]->isEqualWithoutConsideringStr(*otherArr[i],prec)) @@ -212,8 +223,8 @@ bool MEDCouplingCMesh::isEqualWithoutConsideringStr(const MEDCouplingMesh *other return true; } -void MEDCouplingCMesh::checkDeepEquivalWith(const MEDCouplingMesh *other, int cellCompPol, double prec, - DataArrayIdType *&cellCor, DataArrayIdType *&nodeCor) const +void MEDCouplingCMesh::checkDeepEquivalWith(const MEDCouplingMesh *other, int /*cellCompPol*/, double prec, + DataArrayIdType *& /*cellCor*/, DataArrayIdType *& /*nodeCor*/) const { if(!isEqualWithoutConsideringStr(other,prec)) throw INTERP_KERNEL::Exception("MEDCouplingCMesh::checkDeepEquivalWith : Meshes are not the same !"); @@ -223,8 +234,8 @@ void MEDCouplingCMesh::checkDeepEquivalWith(const MEDCouplingMesh *other, int ce * Nothing is done here (except to check that the other is a MEDCoupling::MEDCouplingCMesh instance too). * The user intend that the nodes are the same, so by construction of MEDCoupling::MEDCouplingCMesh, \a this and \a other are the same ! */ -void MEDCouplingCMesh::checkDeepEquivalOnSameNodesWith(const MEDCouplingMesh *other, int cellCompPol, double prec, - DataArrayIdType *&cellCor) const +void MEDCouplingCMesh::checkDeepEquivalOnSameNodesWith(const MEDCouplingMesh *other, int /*cellCompPol*/, double prec, + DataArrayIdType *& /*cellCor*/) const { if(!isEqualWithoutConsideringStr(other,prec)) throw INTERP_KERNEL::Exception("MEDCouplingCMesh::checkDeepEquivalOnSameNodesWith : Meshes are not the same !"); @@ -331,7 +342,7 @@ std::vector MEDCouplingCMesh::getNodeGridStructure() const MEDCouplingStructuredMesh *MEDCouplingCMesh::buildStructuredSubPart(const std::vector< std::pair >& cellPart) const { checkConsistencyLight(); - int dim(getSpaceDimension()); + int const dim(getSpaceDimension()); if(dim!=ToIdType(cellPart.size())) { std::ostringstream oss; oss << "MEDCouplingCMesh::buildStructuredSubPart : the space dimension is " << dim << " and cell part size is " << cellPart.size() << " !"; @@ -358,7 +369,7 @@ int MEDCouplingCMesh::getSpaceDimension() const void MEDCouplingCMesh::getCoordinatesOfNode(mcIdType nodeId, std::vector& coo) const { mcIdType tmp[3]; - int spaceDim=getSpaceDimension(); + int const spaceDim=getSpaceDimension(); getSplitNodeValues(tmp); const DataArrayDouble *tabs[3]={getCoordsAt(0),getCoordsAt(1),getCoordsAt(2)}; mcIdType tmp2[3]; @@ -374,7 +385,7 @@ std::string MEDCouplingCMesh::simpleRepr() const ret << "Cartesian mesh with name : \"" << getName() << "\"\n"; ret << "Description of mesh : \"" << getDescription() << "\"\n"; int tmpp1,tmpp2; - double tt=getTime(tmpp1,tmpp2); + double const tt=getTime(tmpp1,tmpp2); ret << "Time attached to the mesh [unit] : " << tt << " [" << getTimeUnit() << "]\n"; ret << "Iteration : " << tmpp1 << " Order : " << tmpp2 << "\n"; ret << "Space dimension : " << getSpaceDimension() << "\n\nArrays :\n________\n\n"; @@ -534,7 +545,7 @@ void MEDCouplingCMesh::setCoords(const DataArrayDouble *coordsX, const DataArray void MEDCouplingCMesh::getBoundingBox(double *bbox) const { - int dim=getSpaceDimension(); + int const dim=getSpaceDimension(); int j=0; for (int idim=0; idimgetConstPointer(); - mcIdType nb=ToIdType(c->getNbOfElems()); + mcIdType const nb=ToIdType(c->getNbOfElems()); bbox[2*j]=coords[0]; bbox[2*j+1]=coords[nb-1]; j++; @@ -561,11 +572,11 @@ void MEDCouplingCMesh::getBoundingBox(double *bbox) const * and one time . The caller is to delete this field using decrRef() as it is no * more needed. */ -MEDCouplingFieldDouble *MEDCouplingCMesh::getMeasureField(bool isAbs) const +MEDCouplingFieldDouble *MEDCouplingCMesh::getMeasureField(bool /*isAbs*/) const { std::string name="MeasureOfMesh_"; name+=getName(); - mcIdType nbelem=ToIdType(getNumberOfCells()); + mcIdType const nbelem=ToIdType(getNumberOfCells()); MEDCouplingFieldDouble *field=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME); field->setName(name); DataArrayDouble* array=DataArrayDouble::New(); @@ -577,8 +588,8 @@ MEDCouplingFieldDouble *MEDCouplingCMesh::getMeasureField(bool isAbs) const field->synchronizeTimeWithMesh(); mcIdType tmp[3]; getSplitCellValues(tmp); - int dim=getSpaceDimension(); - const double **thisArr=new const double *[dim]; + int const dim=getSpaceDimension(); + const auto **thisArr=new const double *[dim]; const DataArrayDouble *thisArr2[3]={_x_array,_y_array,_z_array}; for(int i=0;igetConstPointer(); @@ -597,7 +608,7 @@ MEDCouplingFieldDouble *MEDCouplingCMesh::getMeasureField(bool isAbs) const /*! * not implemented yet ! */ -MEDCouplingFieldDouble *MEDCouplingCMesh::getMeasureFieldOnNode(bool isAbs) const +MEDCouplingFieldDouble *MEDCouplingCMesh::getMeasureFieldOnNode(bool /*isAbs*/) const { throw INTERP_KERNEL::Exception("MEDCouplingCMesh::getMeasureFieldOnNode : not implemented yet !"); //return 0; @@ -605,14 +616,14 @@ MEDCouplingFieldDouble *MEDCouplingCMesh::getMeasureFieldOnNode(bool isAbs) cons mcIdType MEDCouplingCMesh::getCellContainingPoint(const double *pos, double eps) const { - int dim=getSpaceDimension(); + int const dim=getSpaceDimension(); mcIdType ret=0; mcIdType coeff=1; for(int i=0;igetConstPointer(); - mcIdType nbOfNodes=getCoordsAt(i)->getNbOfElems(); - double ref=pos[i]; + mcIdType const nbOfNodes=getCoordsAt(i)->getNbOfElems(); + double const ref=pos[i]; const double *w=std::find_if(d,d+nbOfNodes,std::bind(std::greater_equal(),std::placeholders::_1,ref)); mcIdType w2=ToIdType(std::distance(d,w)); if(w2& elts) const { - mcIdType ret(getCellContainingPoint(pos,eps)); + mcIdType const ret(getCellContainingPoint(pos,eps)); elts.push_back(ret); } -void MEDCouplingCMesh::rotate(const double *center, const double *vector, double angle) +void MEDCouplingCMesh::rotate(const double * /*center*/, const double * /*vector*/, double /*angle*/) { throw INTERP_KERNEL::Exception("No rotation available on CMesh : Traduce it to untructured mesh to apply it !"); } @@ -677,7 +688,7 @@ void MEDCouplingCMesh::scale(const double *point, double factor) if(c) { double *coords=c->getPointer(); - mcIdType lgth=ToIdType(c->getNbOfElems()); + mcIdType const lgth=ToIdType(c->getNbOfElems()); std::transform(coords,coords+lgth,coords,std::bind(std::minus(),std::placeholders::_1,point[i])); std::transform(coords,coords+lgth,coords,std::bind(std::multiplies(),std::placeholders::_1,factor)); std::transform(coords,coords+lgth,coords,std::bind(std::plus(),std::placeholders::_1,point[i])); @@ -687,10 +698,10 @@ void MEDCouplingCMesh::scale(const double *point, double factor) updateTime(); } -MEDCouplingMesh *MEDCouplingCMesh::mergeMyselfWith(const MEDCouplingMesh *other) const +MEDCouplingMesh *MEDCouplingCMesh::mergeMyselfWith(const MEDCouplingMesh * /*other*/) const { //not implemented yet ! - return 0; + return nullptr; } /*! @@ -703,8 +714,8 @@ MEDCouplingMesh *MEDCouplingCMesh::mergeMyselfWith(const MEDCouplingMesh *other) DataArrayDouble *MEDCouplingCMesh::getCoordinatesAndOwner() const { MCAuto ret(DataArrayDouble::New()); - int spaceDim(getSpaceDimension()); - mcIdType nbNodes(getNumberOfNodes()); + int const spaceDim(getSpaceDimension()); + mcIdType const nbNodes(getNumberOfNodes()); ret->alloc(nbNodes,spaceDim); double *pt(ret->getPointer()); mcIdType tmp[3]; @@ -737,8 +748,8 @@ DataArrayDouble *MEDCouplingCMesh::getCoordinatesAndOwner() const DataArrayDouble *MEDCouplingCMesh::computeCellCenterOfMass() const { DataArrayDouble *ret=DataArrayDouble::New(); - int spaceDim=getSpaceDimension(); - mcIdType nbCells=ToIdType(getNumberOfCells()); + int const spaceDim=getSpaceDimension(); + mcIdType const nbCells=ToIdType(getNumberOfCells()); ret->alloc(nbCells,spaceDim); double *pt=ret->getPointer(); mcIdType tmp[3]; @@ -747,7 +758,7 @@ DataArrayDouble *MEDCouplingCMesh::computeCellCenterOfMass() const std::vector tabsPtr[3]; for(int j=0;jgetNbOfElems()-1; + mcIdType const sz=tabs[j]->getNbOfElems()-1; ret->setInfoOnComponent(j,tabs[j]->getInfoOnComponent(0)); const double *srcPtr=tabs[j]->getConstPointer(); tabsPtr[j].insert(tabsPtr[j].end(),srcPtr,srcPtr+sz); @@ -769,7 +780,7 @@ DataArrayDouble *MEDCouplingCMesh::computeIsoBarycenterOfNodesPerCell() const return MEDCouplingCMesh::computeCellCenterOfMass(); } -void MEDCouplingCMesh::renumberCells(const mcIdType *old2NewBg, bool check) +void MEDCouplingCMesh::renumberCells(const mcIdType * /*old2NewBg*/, bool /*check*/) { throw INTERP_KERNEL::Exception("Functionality of renumbering cell not available for CMesh !"); } @@ -777,7 +788,7 @@ void MEDCouplingCMesh::renumberCells(const mcIdType *old2NewBg, bool check) void MEDCouplingCMesh::getTinySerializationInformation(std::vector& tinyInfoD, std::vector& tinyInfo, std::vector& littleStrings) const { int it,order; - double time=getTime(it,order); + double const time=getTime(it,order); tinyInfo.clear(); tinyInfoD.clear(); littleStrings.clear(); @@ -785,14 +796,14 @@ void MEDCouplingCMesh::getTinySerializationInformation(std::vector& tiny littleStrings.push_back(getDescription()); littleStrings.push_back(getTimeUnit()); const DataArrayDouble *thisArr[3]={_x_array,_y_array,_z_array}; - for(int i=0;i<3;i++) + for(auto & i : thisArr) { mcIdType val=-1; std::string st; - if(thisArr[i]) + if(i) { - val=thisArr[i]->getNumberOfTuples(); - st=thisArr[i]->getInfoOnComponent(0); + val=i->getNumberOfTuples(); + st=i->getInfoOnComponent(0); } tinyInfo.push_back(val); littleStrings.push_back(st); @@ -802,7 +813,7 @@ void MEDCouplingCMesh::getTinySerializationInformation(std::vector& tiny tinyInfoD.push_back(time); } -void MEDCouplingCMesh::resizeForUnserialization(const std::vector& tinyInfo, DataArrayIdType *a1, DataArrayDouble *a2, std::vector& littleStrings) const +void MEDCouplingCMesh::resizeForUnserialization(const std::vector& tinyInfo, DataArrayIdType *a1, DataArrayDouble *a2, std::vector& /*littleStrings*/) const { a1->alloc(0,1); mcIdType sum=0; @@ -818,20 +829,20 @@ void MEDCouplingCMesh::serialize(DataArrayIdType *&a1, DataArrayDouble *&a2) con a1->alloc(0,1); const DataArrayDouble *thisArr[3]={_x_array,_y_array,_z_array}; mcIdType sz=0; - for(int i=0;i<3;i++) + for(auto & i : thisArr) { - if(thisArr[i]) - sz+=thisArr[i]->getNumberOfTuples(); + if(i) + sz+=i->getNumberOfTuples(); } a2=DataArrayDouble::New(); a2->alloc(sz,1); double *a2Ptr=a2->getPointer(); - for(int i=0;i<3;i++) - if(thisArr[i]) - a2Ptr=std::copy(thisArr[i]->getConstPointer(),thisArr[i]->getConstPointer()+thisArr[i]->getNumberOfTuples(),a2Ptr); + for(auto & i : thisArr) + if(i) + a2Ptr=std::copy(i->getConstPointer(),i->getConstPointer()+i->getNumberOfTuples(),a2Ptr); } -void MEDCouplingCMesh::unserialization(const std::vector& tinyInfoD, const std::vector& tinyInfo, const DataArrayIdType *a1, DataArrayDouble *a2, +void MEDCouplingCMesh::unserialization(const std::vector& tinyInfoD, const std::vector& tinyInfo, const DataArrayIdType * /*a1*/, DataArrayDouble *a2, const std::vector& littleStrings) { setName(littleStrings[0]); @@ -857,10 +868,10 @@ void MEDCouplingCMesh::writeVTKLL(std::ostream& ofs, const std::string& cellData { std::ostringstream extent; DataArrayDouble *thisArr[3]={_x_array,_y_array,_z_array}; - for(int i=0;i<3;i++) + for(auto & i : thisArr) { - if(thisArr[i]) - { extent << "0 " << thisArr[i]->getNumberOfTuples()-1 << " "; } + if(i) + { extent << "0 " << i->getNumberOfTuples()-1 << " "; } else { extent << "0 0 "; } } @@ -871,10 +882,10 @@ void MEDCouplingCMesh::writeVTKLL(std::ostream& ofs, const std::string& cellData ofs << " \n" << cellData << std::endl; ofs << " \n"; ofs << " \n"; - for(int i=0;i<3;i++) + for(auto & i : thisArr) { - if(thisArr[i]) - thisArr[i]->writeVTK(ofs,8,"Array",byteData); + if(i) + i->writeVTK(ofs,8,"Array",byteData); else { MCAuto coo=DataArrayDouble::New(); coo->alloc(1,1); @@ -896,19 +907,19 @@ void MEDCouplingCMesh::reprQuickOverview(std::ostream& stream) const mcIdType nbOfCells=1,nbOfNodes=1; for(int i=0;i<3;i++) { - isDef[i]=thisArr[i]!=0; + isDef[i]=thisArr[i]!=nullptr; if(isDef[i]) { - char tmp=(char)((int)('X')+i); + char const tmp=(char)((int)('X')+i); stream2[i] << tmp << " positions array "; if(!thisArr[i]->isAllocated()) stream2[i] << "set but not allocated."; else { - std::size_t nbCompo=thisArr[i]->getNumberOfComponents(); + std::size_t const nbCompo=thisArr[i]->getNumberOfComponents(); if(nbCompo==1) { - mcIdType nbTuples=thisArr[i]->getNumberOfTuples(); + mcIdType const nbTuples=thisArr[i]->getNumberOfTuples(); if(nbTuples<1) { stream2[i] << "set and allocated - WARNING number of elements < 1 !"; nbOfCells=-1; nbOfNodes=-1; } else diff --git a/src/MEDCoupling/MEDCouplingCMesh.hxx b/src/MEDCoupling/MEDCouplingCMesh.hxx index 6272b3130..aee43cdb9 100644 --- a/src/MEDCoupling/MEDCouplingCMesh.hxx +++ b/src/MEDCoupling/MEDCouplingCMesh.hxx @@ -21,8 +21,16 @@ #ifndef __PARAMEDMEM_MEDCOUPLINGCMESH_HXX__ #define __PARAMEDMEM_MEDCOUPLINGCMESH_HXX__ +#include "MCType.hxx" #include "MEDCoupling.hxx" +#include "MEDCouplingMesh.hxx" +#include "MEDCouplingRefCountObject.hxx" #include "MEDCouplingStructuredMesh.hxx" +#include +#include +#include +#include +#include namespace MEDCoupling { @@ -34,65 +42,65 @@ namespace MEDCoupling MEDCOUPLING_EXPORT static MEDCouplingCMesh *New(); MEDCOUPLING_EXPORT static MEDCouplingCMesh *New(const std::string& meshName); MEDCOUPLING_EXPORT std::string getClassName() const override { return std::string("MEDCouplingCMesh"); } - MEDCOUPLING_EXPORT MEDCouplingCMesh *deepCopy() const; - MEDCOUPLING_EXPORT MEDCouplingCMesh *clone(bool recDeepCpy) const; - MEDCOUPLING_EXPORT const DataArrayDouble *getDirectAccessOfCoordsArrIfInStructure() const; + MEDCOUPLING_EXPORT MEDCouplingCMesh *deepCopy() const override; + MEDCOUPLING_EXPORT MEDCouplingCMesh *clone(bool recDeepCpy) const override; + MEDCOUPLING_EXPORT const DataArrayDouble *getDirectAccessOfCoordsArrIfInStructure() const override; MEDCOUPLING_EXPORT MEDCouplingCurveLinearMesh *buildCurveLinear() const; - MEDCOUPLING_EXPORT void updateTime() const; - MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; - MEDCOUPLING_EXPORT std::vector getDirectChildrenWithNull() const; - MEDCOUPLING_EXPORT MEDCouplingMeshType getType() const { return CARTESIAN; } - MEDCOUPLING_EXPORT void copyTinyStringsFrom(const MEDCouplingMesh *other); - MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const; - MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const; + MEDCOUPLING_EXPORT void updateTime() const override; + MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const override; + MEDCOUPLING_EXPORT std::vector getDirectChildrenWithNull() const override; + MEDCOUPLING_EXPORT MEDCouplingMeshType getType() const override { return CARTESIAN; } + MEDCOUPLING_EXPORT void copyTinyStringsFrom(const MEDCouplingMesh *other) override; + MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const override; + MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const override; MEDCOUPLING_EXPORT void checkDeepEquivalWith(const MEDCouplingMesh *other, int cellCompPol, double prec, - DataArrayIdType *&cellCor, DataArrayIdType *&nodeCor) const; + DataArrayIdType *&cellCor, DataArrayIdType *&nodeCor) const override; MEDCOUPLING_EXPORT void checkDeepEquivalOnSameNodesWith(const MEDCouplingMesh *other, int cellCompPol, double prec, - DataArrayIdType *&cellCor) const; - MEDCOUPLING_EXPORT void checkConsistencyLight() const; - MEDCOUPLING_EXPORT void checkConsistency(double eps=1e-12) const; - MEDCOUPLING_EXPORT int getSpaceDimension() const; - MEDCOUPLING_EXPORT void getCoordinatesOfNode(mcIdType nodeId, std::vector& coo) const; - MEDCOUPLING_EXPORT std::string simpleRepr() const; - MEDCOUPLING_EXPORT std::string advancedRepr() const; + DataArrayIdType *&cellCor) const override; + MEDCOUPLING_EXPORT void checkConsistencyLight() const override; + MEDCOUPLING_EXPORT void checkConsistency(double eps=1e-12) const override; + MEDCOUPLING_EXPORT int getSpaceDimension() const override; + MEDCOUPLING_EXPORT void getCoordinatesOfNode(mcIdType nodeId, std::vector& coo) const override; + MEDCOUPLING_EXPORT std::string simpleRepr() const override; + MEDCOUPLING_EXPORT std::string advancedRepr() const override; MEDCOUPLING_EXPORT const DataArrayDouble *getCoordsAt(int i) const; MEDCOUPLING_EXPORT DataArrayDouble *getCoordsAt(int i); MEDCOUPLING_EXPORT void setCoordsAt(int i, const DataArrayDouble *arr); MEDCOUPLING_EXPORT void setCoords(const DataArrayDouble *coordsX, - const DataArrayDouble *coordsY=0, - const DataArrayDouble *coordsZ=0); + const DataArrayDouble *coordsY=nullptr, + const DataArrayDouble *coordsZ=nullptr); // tools - MEDCOUPLING_EXPORT void getBoundingBox(double *bbox) const; - MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureField(bool isAbs) const; - MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureFieldOnNode(bool isAbs) const; - MEDCOUPLING_EXPORT mcIdType getCellContainingPoint(const double *pos, double eps) const; - MEDCOUPLING_EXPORT void getCellsContainingPoint(const double *pos, double eps, std::vector& elts) const; - MEDCOUPLING_EXPORT void rotate(const double *center, const double *vector, double angle); - MEDCOUPLING_EXPORT void translate(const double *vector); - MEDCOUPLING_EXPORT void scale(const double *point, double factor); - MEDCOUPLING_EXPORT MEDCouplingMesh *mergeMyselfWith(const MEDCouplingMesh *other) const; - MEDCOUPLING_EXPORT DataArrayDouble *getCoordinatesAndOwner() const; - MEDCOUPLING_EXPORT DataArrayDouble *computeCellCenterOfMass() const; - MEDCOUPLING_EXPORT DataArrayDouble *computeIsoBarycenterOfNodesPerCell() const; - MEDCOUPLING_EXPORT void renumberCells(const mcIdType *old2NewBg, bool check=true); + MEDCOUPLING_EXPORT void getBoundingBox(double *bbox) const override; + MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureField(bool isAbs) const override; + MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureFieldOnNode(bool isAbs) const override; + MEDCOUPLING_EXPORT mcIdType getCellContainingPoint(const double *pos, double eps) const override; + MEDCOUPLING_EXPORT void getCellsContainingPoint(const double *pos, double eps, std::vector& elts) const override; + MEDCOUPLING_EXPORT void rotate(const double *center, const double *vector, double angle) override; + MEDCOUPLING_EXPORT void translate(const double *vector) override; + MEDCOUPLING_EXPORT void scale(const double *point, double factor) override; + MEDCOUPLING_EXPORT MEDCouplingMesh *mergeMyselfWith(const MEDCouplingMesh *other) const override; + MEDCOUPLING_EXPORT DataArrayDouble *getCoordinatesAndOwner() const override; + MEDCOUPLING_EXPORT DataArrayDouble *computeCellCenterOfMass() const override; + MEDCOUPLING_EXPORT DataArrayDouble *computeIsoBarycenterOfNodesPerCell() const override; + MEDCOUPLING_EXPORT void renumberCells(const mcIdType *old2NewBg, bool check=true) override; //some useful methods - MEDCOUPLING_EXPORT void getNodeGridStructure(mcIdType *res) const; - MEDCOUPLING_EXPORT std::vector getNodeGridStructure() const; - MEDCouplingStructuredMesh *buildStructuredSubPart(const std::vector< std::pair >& cellPart) const; + MEDCOUPLING_EXPORT void getNodeGridStructure(mcIdType *res) const override; + MEDCOUPLING_EXPORT std::vector getNodeGridStructure() const override; + MEDCouplingStructuredMesh *buildStructuredSubPart(const std::vector< std::pair >& cellPart) const override; //serialisation-unserialization - MEDCOUPLING_EXPORT void getTinySerializationInformation(std::vector& tinyInfoD, std::vector& tinyInfo, std::vector& littleStrings) const; - MEDCOUPLING_EXPORT void resizeForUnserialization(const std::vector& tinyInfo, DataArrayIdType *a1, DataArrayDouble *a2, std::vector& littleStrings) const; - MEDCOUPLING_EXPORT void serialize(DataArrayIdType *&a1, DataArrayDouble *&a2) const; + MEDCOUPLING_EXPORT void getTinySerializationInformation(std::vector& tinyInfoD, std::vector& tinyInfo, std::vector& littleStrings) const override; + MEDCOUPLING_EXPORT void resizeForUnserialization(const std::vector& tinyInfo, DataArrayIdType *a1, DataArrayDouble *a2, std::vector& littleStrings) const override; + MEDCOUPLING_EXPORT void serialize(DataArrayIdType *&a1, DataArrayDouble *&a2) const override; MEDCOUPLING_EXPORT void unserialization(const std::vector& tinyInfoD, const std::vector& tinyInfo, const DataArrayIdType *a1, DataArrayDouble *a2, - const std::vector& littleStrings); - MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const; - MEDCOUPLING_EXPORT std::string getVTKFileExtension() const; + const std::vector& littleStrings) override; + MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const override; + MEDCOUPLING_EXPORT std::string getVTKFileExtension() const override; private: MEDCouplingCMesh(); MEDCouplingCMesh(const MEDCouplingCMesh& other, bool deepCpy); - ~MEDCouplingCMesh(); - void writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData, DataArrayByte *byteData) const; - std::string getVTKDataSetType() const; + ~MEDCouplingCMesh() override; + void writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData, DataArrayByte *byteData) const override; + std::string getVTKDataSetType() const override; private: DataArrayDouble *_x_array; DataArrayDouble *_y_array; diff --git a/src/MEDCoupling/MEDCouplingCartesianAMRMesh.cxx b/src/MEDCoupling/MEDCouplingCartesianAMRMesh.cxx old mode 100755 new mode 100644 index 36dfdb2ca..38ce2a790 --- a/src/MEDCoupling/MEDCouplingCartesianAMRMesh.cxx +++ b/src/MEDCoupling/MEDCouplingCartesianAMRMesh.cxx @@ -19,15 +19,31 @@ // Author : Anthony Geay #include "MEDCouplingCartesianAMRMesh.hxx" +#include "MCIdType.hxx" +#include "MCType.hxx" +#include "MCAuto.hxx" +#include "BoxSplittingOptions.hxx" #include "MEDCouplingAMRAttribute.hxx" #include "MEDCouplingFieldDouble.hxx" #include "MEDCoupling1GTUMesh.hxx" #include "MEDCouplingIMesh.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include "MEDCouplingMesh.hxx" +#include "MEDCouplingStructuredMesh.hxx" #include "MEDCouplingUMesh.hxx" +#include +#include +#include +#include +#include +#include #include +#include #include -#include +#include +#include +#include using namespace MEDCoupling; @@ -162,7 +178,7 @@ bool MEDCouplingCartesianAMRPatch::isInMyNeighborhoodExt(const MEDCouplingCartes const MEDCouplingCartesianAMRMeshGen *com(FindCommonAncestor(this,other,lev));//check that factors are OK if(lev==0) return isInMyNeighborhood(other,ghostLev); - std::vector offset(ComputeOffsetFromTwoToOne(com,lev,this,other)); + std::vector const offset(ComputeOffsetFromTwoToOne(com,lev,this,other)); const std::vector< std::pair >& thisp(getBLTRRange()); std::vector< std::pair > otherp(other->getBLTRRange()); otherp=MEDCouplingStructuredMesh::TranslateCompactFrmt(otherp,offset); @@ -202,7 +218,7 @@ std::vector< std::pair > MEDCouplingCartesianAMRPatch::getBLT if(!fath) throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRPatch::getBLTRRangeRelativeToGF : not valid 2 !"); std::vector factors(fath->getFactors()); - std::size_t sz(ret.size()); + std::size_t const sz(ret.size()); for(std::size_t ii=0;ii > MEDCouplingCartesianAMRPatch::getBLT fath=oldFather->getFather(); while(fath) { - mcIdType pos(fath->getPatchIdFromChildMesh(oldFather)); + mcIdType const pos(fath->getPatchIdFromChildMesh(oldFather)); const MEDCouplingCartesianAMRPatch *p(fath->getPatch(pos)); const std::vector< std::pair >& tmp(p->getBLTRRange()); const std::vector& factors2(fath->getFactors()); std::transform(factors.begin(),factors.end(),factors2.begin(),factors.begin(),std::multiplies()); for(std::size_t ii=0;ii MEDCouplingCartesianAMRPatch::computeCellGridSt() const bool MEDCouplingCartesianAMRPatch::IsInMyNeighborhood(mcIdType ghostLev, const std::vector< std::pair >& p1, const std::vector< std::pair >& p2) { - std::size_t thispsize(p1.size()); + std::size_t const thispsize(p1.size()); if(thispsize!=p2.size()) throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRPatch::isInMyNeighborhood : the dimensions must be the same !"); for(std::size_t i=0;i > retTmp; std::vector p1Work2,p2Work2; - for(std::vector::const_iterator it1=p1Work.begin();it1!=p1Work.end();it1++) + for(auto it1 : p1Work) { - for(std::vector::const_iterator it2=p2Work.begin();it2!=p2Work.end();it2++) + for(auto it2 : p2Work) { - if((*it1)->isInMyNeighborhoodExt(*it2,ghostLev>0?1:0))//1 not ghostLev ! It is not a bug ( I hope :) ) ! Because as \a this is a refinement of \a other ghostLev is supposed to be <= factors - retTmp.push_back(std::pair(*it1,*it2)); + if(it1->isInMyNeighborhoodExt(it2,ghostLev>0?1:0))//1 not ghostLev ! It is not a bug ( I hope :) ) ! Because as \a this is a refinement of \a other ghostLev is supposed to be <= factors + retTmp.push_back(std::pair(it1,it2)); } - std::vector tmp1((*it1)->getMesh()->getPatches()); + std::vector tmp1(it1->getMesh()->getPatches()); p1Work2.insert(p1Work2.end(),tmp1.begin(),tmp1.end()); } - for(std::vector::const_iterator it2=p2Work.begin();it2!=p2Work.end();it2++) + for(auto it2 : p2Work) { - std::vector tmp2((*it2)->getMesh()->getPatches()); + std::vector tmp2(it2->getMesh()->getPatches()); p2Work2.insert(p2Work2.end(),tmp2.begin(),tmp2.end()); } ret.push_back(retTmp); @@ -318,11 +334,11 @@ void MEDCouplingCartesianAMRPatch::FindNeighborsOfSubPatchesOf(mcIdType ghostLev while(!p1Work.empty()) { std::vector p1Work2; - for(std::vector::const_iterator it0=p1Work.begin();it0!=p1Work.end();it0++) + for(auto it0 : p1Work) { - if((*it0)->isInMyNeighborhoodDiffLev(p2,ghostLev)) - ret.push_back(std::pair(*it0,p2)); - std::vector tmp2((*it0)->getMesh()->getPatches()); + if(it0->isInMyNeighborhoodDiffLev(p2,ghostLev)) + ret.push_back(std::pair(it0,p2)); + std::vector tmp2(it0->getMesh()->getPatches()); p1Work2.insert(p1Work2.end(),tmp2.begin(),tmp2.end()); } p1Work=p1Work2; @@ -352,7 +368,7 @@ void MEDCouplingCartesianAMRPatch::UpdateNeighborsOfOneWithTwoExt(mcIdType ghost std::vector< std::pair > p2BLTR(p2->getBLTRRange());//p2BLTR=[(0,1),(0,5)] mcIdType lev(0); const MEDCouplingCartesianAMRMeshGen *ca(FindCommonAncestor(p1,p2,lev)); - std::vector offset(ComputeOffsetFromTwoToOne(ca,lev,p1,p2));//[12,4] + std::vector const offset(ComputeOffsetFromTwoToOne(ca,lev,p1,p2));//[12,4] p2BLTR=MEDCouplingStructuredMesh::TranslateCompactFrmt(p2BLTR,offset);//p2BLTR=[(12,13),(4,9)] UpdateNeighborsOfOneWithTwoInternal(ghostLev,p1->getMesh()->getFather()->getFactors(),p1BLTR,p2BLTR,dataOnP1,dataOnP2); } @@ -369,14 +385,14 @@ void MEDCouplingCartesianAMRPatch::UpdateNeighborsOfOneWithTwoMixedLev(mcIdType std::vector dimsP2NotRefined(p2->computeCellGridSt()); std::vector dimsP2Refined(dimsP2NotRefined); std::transform(dimsP2NotRefined.begin(),dimsP2NotRefined.end(),factors.begin(),dimsP2Refined.begin(),std::multiplies()); - std::vector< std::pair > p2RefinedAbs(MEDCouplingStructuredMesh::GetCompactFrmtFromDimensions(dimsP2NotRefined)); + std::vector< std::pair > const p2RefinedAbs(MEDCouplingStructuredMesh::GetCompactFrmtFromDimensions(dimsP2NotRefined)); std::vector dimsP2RefinedGhost(dimsP2Refined.size()); std::transform(dimsP2Refined.begin(),dimsP2Refined.end(),dimsP2RefinedGhost.begin(),std::bind(std::plus(),std::placeholders::_1,2*ghostLev)); MCAuto fineP2(DataArrayDouble::New()); fineP2->alloc(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(dimsP2RefinedGhost),dataOnP2->getNumberOfComponents()); MEDCouplingIMesh::SpreadCoarseToFineGhost(dataOnP2,dimsP2NotRefined,fineP2,p2RefinedAbs,factors,ghostLev); if(isConservative) { - mcIdType fact(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(factors)); + mcIdType const fact(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(factors)); std::transform(fineP2->begin(),fineP2->end(),fineP2->getPointer(),std::bind(std::multiplies(),std::placeholders::_1,1./((double)fact))); } // @@ -388,10 +404,10 @@ void MEDCouplingCartesianAMRPatch::UpdateNeighborsOfOneWithTwoMixedLev(mcIdType * This method has 3 outputs. 2 two first are the resp the position of \a p1 and \a p2 relative to \a p1. And \a factToApplyOn2 is the coeff of refinement to be applied on \a p2 to be virtually * on the same level as \a p1. */ -void MEDCouplingCartesianAMRPatch::ComputeZonesOfTwoRelativeToOneDiffLev(mcIdType ghostLev, const MEDCouplingCartesianAMRPatch *p1, const MEDCouplingCartesianAMRPatch *p2, std::vector< std::pair >& p1Zone, std::vector< std::pair >& p2Zone, std::vector& factToApplyOn2) +void MEDCouplingCartesianAMRPatch::ComputeZonesOfTwoRelativeToOneDiffLev(mcIdType /*ghostLev*/, const MEDCouplingCartesianAMRPatch *p1, const MEDCouplingCartesianAMRPatch *p2, std::vector< std::pair >& p1Zone, std::vector< std::pair >& p2Zone, std::vector& factToApplyOn2) { std::vector ancestorsOfThis; - const MEDCouplingCartesianAMRMeshGen *work(p1->getMesh()),*work2(0); + const MEDCouplingCartesianAMRMeshGen *work(p1->getMesh()),*work2(nullptr); ancestorsOfThis.push_back(work); while(work) { @@ -410,7 +426,7 @@ void MEDCouplingCartesianAMRPatch::ComputeZonesOfTwoRelativeToOneDiffLev(mcIdTyp if(work) { levOther++; - std::vector::iterator it(std::find(ancestorsOfThis.begin(),ancestorsOfThis.end(),work)); + auto const it(std::find(ancestorsOfThis.begin(),ancestorsOfThis.end(),work)); if(it!=ancestorsOfThis.end()) { levThis=std::distance(ancestorsOfThis.begin(),it); @@ -426,11 +442,11 @@ void MEDCouplingCartesianAMRPatch::ComputeZonesOfTwoRelativeToOneDiffLev(mcIdTyp const MEDCouplingCartesianAMRMeshGen *comAncestor(ancestorsOfThis[levThis]); mcIdType idThis(comAncestor->getPatchIdFromChildMesh(ancestorsOfThis[levThis-1])),idOther(comAncestor->getPatchIdFromChildMesh(work2)); const MEDCouplingCartesianAMRPatch *thisp(comAncestor->getPatch(idThis)),*otherp(comAncestor->getPatch(idOther)); - std::vector offset(ComputeOffsetFromTwoToOne(comAncestor,ToIdType(levOther),thisp,otherp)); + std::vector const offset(ComputeOffsetFromTwoToOne(comAncestor,ToIdType(levOther),thisp,otherp)); p1Zone=thisp->getBLTRRange(); p2Zone=MEDCouplingStructuredMesh::TranslateCompactFrmt(otherp->getBLTRRange(),offset); factToApplyOn2.resize(p1Zone.size()); std::fill(factToApplyOn2.begin(),factToApplyOn2.end(),1); // - std::size_t nbOfTurn(levThis-levOther); + std::size_t const nbOfTurn(levThis-levOther); for(std::size_t i=0;i > tmp0; @@ -441,7 +457,7 @@ void MEDCouplingCartesianAMRPatch::ComputeZonesOfTwoRelativeToOneDiffLev(mcIdTyp curAncestor=ancestorsOfThis[levThis-1-i]; const std::vector& factors(curAncestor->getFactors()); std::transform(factToApplyOn2.begin(),factToApplyOn2.end(),factors.begin(),factToApplyOn2.begin(),std::multiplies()); - mcIdType tmpId(curAncestor->getPatchIdFromChildMesh(ancestorsOfThis[levThis-2-i])); + mcIdType const tmpId(curAncestor->getPatchIdFromChildMesh(ancestorsOfThis[levThis-2-i])); p1Zone=curAncestor->getPatch(tmpId)->getBLTRRange(); } } @@ -457,7 +473,7 @@ const MEDCouplingCartesianAMRMeshGen *MEDCouplingCartesianAMRPatch::FindCommonAn { const MEDCouplingCartesianAMRMeshGen *f1(p1->_mesh),*f2(p2->_mesh); lev=0; - while(f1!=f2 || f1==0 || f2==0) + while(f1!=f2 || f1==nullptr || f2==nullptr) { f1=f1->getFather(); f2=f2->getFather(); if(f1->getFactors()!=f2->getFactors()) @@ -469,19 +485,19 @@ const MEDCouplingCartesianAMRMeshGen *MEDCouplingCartesianAMRPatch::FindCommonAn return f1; } -std::vector MEDCouplingCartesianAMRPatch::ComputeOffsetFromTwoToOne(const MEDCouplingCartesianAMRMeshGen *comAncestor, mcIdType lev, const MEDCouplingCartesianAMRPatch *p1, const MEDCouplingCartesianAMRPatch *p2) +std::vector MEDCouplingCartesianAMRPatch::ComputeOffsetFromTwoToOne(const MEDCouplingCartesianAMRMeshGen * /*comAncestor*/, mcIdType lev, const MEDCouplingCartesianAMRPatch *p1, const MEDCouplingCartesianAMRPatch *p2) { if(lev<=0) throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRPatch::ComputeOffsetFromTwoToOne : this method is useful only for lev > 0 !"); - mcIdType zeLev(lev-1); - mcIdType dim(p1->getMesh()->getSpaceDimension()); + mcIdType const zeLev(lev-1); + mcIdType const dim(p1->getMesh()->getSpaceDimension()); if(p2->getMesh()->getSpaceDimension()!=dim) throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRPatch::ComputeOffsetFromTwoToOne : dimension must be the same !"); std::vector< mcIdType > ret(dim,0); for(mcIdType i=0;i_mesh),*f2(p2->_mesh); - const MEDCouplingCartesianAMRPatch *p1h(0),*p2h(0); + const MEDCouplingCartesianAMRPatch *p1h(nullptr),*p2h(nullptr); for(mcIdType j=0;jgetFather()),*f2tmp(f2->getFather()); @@ -506,18 +522,18 @@ std::vector MEDCouplingCartesianAMRPatch::ComputeOffsetFromTwoToOne(co void MEDCouplingCartesianAMRPatch::UpdateNeighborsOfOneWithTwoInternal(mcIdType ghostLev, const std::vector& factors, const std::vector< std::pair >&p1 ,const std::vector< std::pair >&p2, DataArrayDouble *dataOnP1, const DataArrayDouble *dataOnP2) {//p1=[(1,4),(2,4)] p2=[(4,5),(3,4)] - mcIdType dim(ToIdType(factors.size())); + mcIdType const dim(ToIdType(factors.size())); std::vector dimsCoarse(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(p1));//[3,2] std::transform(dimsCoarse.begin(),dimsCoarse.end(),factors.begin(),dimsCoarse.begin(),std::multiplies());//[12,8] std::transform(dimsCoarse.begin(),dimsCoarse.end(),dimsCoarse.begin(),std::bind(std::plus(),std::placeholders::_1,2*ghostLev));//[14,10] - std::vector< std::pair > rangeCoarse(MEDCouplingStructuredMesh::GetCompactFrmtFromDimensions(dimsCoarse));//[(0,14),(0,10)] - std::vector fakeFactors(dim,1); + std::vector< std::pair > const rangeCoarse(MEDCouplingStructuredMesh::GetCompactFrmtFromDimensions(dimsCoarse));//[(0,14),(0,10)] + std::vector const fakeFactors(dim,1); // std::vector< std::pair > tmp0,tmp1,tmp2; MEDCouplingStructuredMesh::ChangeReferenceFromGlobalOfCompactFrmt(p1,p2,tmp0,false);//tmp0=[(3,4),(1,2)] ApplyFactorsOnCompactFrmt(tmp0,factors);//tmp0=[(12,16),(4,8)] MEDCouplingStructuredMesh::ApplyGhostOnCompactFrmt(tmp0,ghostLev);//tmp0=[(13,17),(5,9)] - std::vector< std::pair > interstRange(MEDCouplingStructuredMesh::IntersectRanges(tmp0,rangeCoarse));//interstRange=[(13,14),(5,9)] + std::vector< std::pair > const interstRange(MEDCouplingStructuredMesh::IntersectRanges(tmp0,rangeCoarse));//interstRange=[(13,14),(5,9)] MEDCouplingStructuredMesh::ChangeReferenceFromGlobalOfCompactFrmt(p2,p1,tmp1,false);//tmp1=[(-3,0),(-1,1)] ApplyFactorsOnCompactFrmt(tmp1,factors);//tmp1=[(-12,-4),(-4,0)] MEDCouplingStructuredMesh::ChangeReferenceToGlobalOfCompactFrmt(tmp1,interstRange,tmp2,false);//tmp2=[(1,2),(1,5)] @@ -540,7 +556,7 @@ MEDCouplingCartesianAMRPatch::MEDCouplingCartesianAMRPatch(const MEDCouplingCart */ void MEDCouplingCartesianAMRPatch::ApplyFactorsOnCompactFrmt(std::vector< std::pair >& partBeforeFact, const std::vector& factors) { - std::size_t sz(factors.size()); + std::size_t const sz(factors.size()); if(sz!=partBeforeFact.size()) throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRPatch::ApplyFactorsOnCompactFrmt : size of input vectors must be the same !"); for(std::size_t i=0;i= 0 !"); - std::size_t sz(partBeforeFact.size()); + std::size_t const sz(partBeforeFact.size()); for(std::size_t i=0;i& new mcIdType MEDCouplingCartesianAMRMeshGen::getMaxNumberOfLevelsRelativeToThis() const { mcIdType ret(1); - for(std::vector< MCAuto >::const_iterator it=_patches.begin();it!=_patches.end();it++) - ret=std::max(ret,(*it)->getMaxNumberOfLevelsRelativeToThis()+1); + for(const auto & _patche : _patches) + ret=std::max(ret,_patche->getMaxNumberOfLevelsRelativeToThis()+1); return ret; } @@ -648,9 +664,9 @@ mcIdType MEDCouplingCartesianAMRMeshGen::getNumberOfCellsAtCurrentLevelGhost(mcI mcIdType MEDCouplingCartesianAMRMeshGen::getNumberOfCellsRecursiveWithOverlap() const { mcIdType ret=_mesh->getNumberOfCells(); - for(std::vector< MCAuto >::const_iterator it=_patches.begin();it!=_patches.end();it++) + for(const auto & _patche : _patches) { - ret+=(*it)->getNumberOfCellsRecursiveWithOverlap(); + ret+=_patche->getNumberOfCellsRecursiveWithOverlap(); } return ret; } @@ -665,10 +681,10 @@ mcIdType MEDCouplingCartesianAMRMeshGen::getNumberOfCellsRecursiveWithOverlap() mcIdType MEDCouplingCartesianAMRMeshGen::getNumberOfCellsRecursiveWithoutOverlap() const { mcIdType ret=_mesh->getNumberOfCells(); - for(std::vector< MCAuto >::const_iterator it=_patches.begin();it!=_patches.end();it++) + for(const auto & _patche : _patches) { - ret-=(*it)->getNumberOfOverlapedCellsForFather(); - ret+=(*it)->getNumberOfCellsRecursiveWithoutOverlap(); + ret-=_patche->getNumberOfOverlapedCellsForFather(); + ret+=_patche->getNumberOfCellsRecursiveWithoutOverlap(); } return ret; } @@ -694,25 +710,25 @@ std::vector MEDCouplingCartesianAMRMeshGen::getPositionRelativeTo(cons */ const MEDCouplingCartesianAMRPatch *MEDCouplingCartesianAMRMeshGen::getPatchAtPosition(const std::vector& pos) const { - std::size_t sz(pos.size()); + std::size_t const sz(pos.size()); if(sz==0) throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRMeshGen::getPatchAtPosition : empty input -> no patch by definition !"); - mcIdType patchId(pos[0]); + mcIdType const patchId(pos[0]); const MEDCouplingCartesianAMRPatch *elt(getPatch(patchId)); if(sz==1) return elt; if(!elt || !elt->getMesh()) throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRMeshGen::getPatchAtPosition : NULL element found during walk !"); - std::vector pos2(pos.begin()+1,pos.end()); + std::vector const pos2(pos.begin()+1,pos.end()); return elt->getMesh()->getPatchAtPosition(pos2); } const MEDCouplingCartesianAMRMeshGen *MEDCouplingCartesianAMRMeshGen::getMeshAtPosition(const std::vector& pos) const { - std::size_t sz(pos.size()); + std::size_t const sz(pos.size()); if(sz==0) return this; - mcIdType patchId(pos[0]); + mcIdType const patchId(pos[0]); const MEDCouplingCartesianAMRPatch *elt(getPatch(patchId)); if(sz==1) { @@ -722,7 +738,7 @@ const MEDCouplingCartesianAMRMeshGen *MEDCouplingCartesianAMRMeshGen::getMeshAtP } if(!elt || !elt->getMesh()) throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRMeshGen::getPatchAtPosition : NULL element found during walk !"); - std::vector pos2(pos.begin()+1,pos.end()); + std::vector const pos2(pos.begin()+1,pos.end()); return elt->getMesh()->getMeshAtPosition(pos2); } @@ -749,7 +765,7 @@ void MEDCouplingCartesianAMRMeshGen::addPatch(const std::vector< std::pair mesh(static_cast(_mesh->buildStructuredSubPart(bottomLeftTopRight))); mesh->refineWithFactor(factors); MCAuto zeMesh(new MEDCouplingCartesianAMRMeshSub(this,mesh)); - MCAuto elt(new MEDCouplingCartesianAMRPatch(zeMesh,bottomLeftTopRight)); + MCAuto const elt(new MEDCouplingCartesianAMRPatch(zeMesh,bottomLeftTopRight)); _patches.push_back(elt); declareAsNew(); } @@ -759,7 +775,7 @@ void MEDCouplingCartesianAMRMeshGen::addPatch(const std::vector< std::pair extractPart(const std::vector< std::pair >&partInGlobal) const; MCAuto deepCopy() const; protected: - ~InternalPatch() { } + ~InternalPatch() override = default; private: - mutable mcIdType _nb_of_true; + mutable mcIdType _nb_of_true{0}; std::vector _crit; //! _part is global std::vector< std::pair > _part; @@ -788,10 +804,10 @@ private: void InternalPatch::zipToFitOnCriterion(mcIdType minPatchLgth) { - std::vector cgs(computeCGS()); + std::vector const cgs(computeCGS()); std::vector newCrit; std::vector< std::pair > newPart,newPart2; - mcIdType newNbOfTrue(MEDCouplingStructuredMesh::FindMinimalPartOf(minPatchLgth,cgs,_crit,newCrit,newPart)); + mcIdType const newNbOfTrue(MEDCouplingStructuredMesh::FindMinimalPartOf(minPatchLgth,cgs,_crit,newCrit,newPart)); MEDCouplingStructuredMesh::ChangeReferenceToGlobalOfCompactFrmt(_part,newPart,newPart2); if(newNbOfTrue!=_nb_of_true) throw INTERP_KERNEL::Exception("InternalPatch::zipToFitOnCrit : internal error !"); @@ -806,7 +822,7 @@ void InternalPatch::updateNumberOfTrue() const MCAuto InternalPatch::extractPart(const std::vector< std::pair >&partInGlobal) const { MCAuto ret(new InternalPatch); - std::vector cgs(computeCGS()); + std::vector const cgs(computeCGS()); std::vector< std::pair > newPart; MEDCouplingStructuredMesh::ChangeReferenceFromGlobalOfCompactFrmt(_part,partInGlobal,newPart); MEDCouplingStructuredMesh::ExtractFieldOfBoolFrom(cgs,_crit,newPart,ret->getCriterion()); @@ -824,7 +840,7 @@ MCAuto InternalPatch::deepCopy() const void DissectBigPatch(const INTERP_KERNEL::BoxSplittingOptions& bso, const InternalPatch *patchToBeSplit, mcIdType axisId, mcIdType largestLength, mcIdType& cutPlace) { - mcIdType minimumPatchLength(bso.getMinimumPatchLength()); + mcIdType const minimumPatchLength(bso.getMinimumPatchLength()); std::vector ratio(largestLength-minimumPatchLength,std::numeric_limits::max()); mcIdType index_min = -1; double minSemiEfficiencyRatio(std::numeric_limits::max()); @@ -860,15 +876,15 @@ void DissectBigPatch(const INTERP_KERNEL::BoxSplittingOptions& bso, const Intern bool FindHole(const INTERP_KERNEL::BoxSplittingOptions& bso, const InternalPatch *patchToBeSplit, mcIdType axisId, mcIdType& cutPlace) { cutPlace=-1; - mcIdType minimumPatchLength(bso.getMinimumPatchLength()); + mcIdType const minimumPatchLength(bso.getMinimumPatchLength()); const mcIdType dim(patchToBeSplit->getDimension()); std::vector< std::vector > signatures(patchToBeSplit->computeSignature()); for(mcIdType id=0;id& signature(signatures[id]); std::vector hole; - std::vector distance; - mcIdType len(ToIdType(signature.size())); + std::vector const distance; + mcIdType const len(ToIdType(signature.size())); for(mcIdType i=minimumPatchLength-1;igetConstPart()[axisId].first; @@ -935,18 +951,18 @@ bool FindInflection(const INTERP_KERNEL::BoxSplittingOptions& bso, const Interna } if ( zero_cross.size() > 0 ) { - mcIdType max_cross=*max_element(edge.begin(),edge.end()) ; + mcIdType const max_cross=*max_element(edge.begin(),edge.end()) ; for (std::size_t i=0;i(signature.size())/2.0); - for (std::size_t i=0;i(max_cross_list[i])+1-center)); + double const center(static_cast(signature.size())/2.0); + for (long const i : max_cross_list) + distance.push_back(fabs(FromIdType(i)+1-center)); - double distance_min=*min_element(distance.begin(),distance.end()) ; - mcIdType pos_distance_min=ToIdType(find(distance.begin(),distance.end(),distance_min)-distance.begin()); - mcIdType best_place = max_cross_list[pos_distance_min] + part[id].first ; + double const distance_min=*min_element(distance.begin(),distance.end()) ; + mcIdType const pos_distance_min=ToIdType(find(distance.begin(),distance.end(),distance_min)-distance.begin()); + mcIdType const best_place = max_cross_list[pos_distance_min] + part[id].first ; if ( max_cross >=0 ) { zeroCrossDims[id] = best_place ; @@ -967,8 +983,8 @@ bool FindInflection(const INTERP_KERNEL::BoxSplittingOptions& bso, const Interna if (zeroCrossVals[0]==max_cross_dims && zeroCrossVals[1]==max_cross_dims ) { - mcIdType nl_left(part[0].second-part[0].first); - mcIdType nc_left(part[1].second-part[1].first); + mcIdType const nl_left(part[0].second-part[0].first); + mcIdType const nc_left(part[1].second-part[1].first); if ( nl_left >= nc_left ) max_cross_dims = 0 ; else @@ -1016,7 +1032,7 @@ MCAuto DealWithNoCut(const InternalPatch *patch) void DealWithCut(double minPatchLgth, const InternalPatch *patchToBeSplit, int axisId, mcIdType cutPlace, std::vector >& listOfPatches) { MCAuto leftPart,rightPart; - std::vector< std::pair > rect(patchToBeSplit->getConstPart()); + std::vector< std::pair > const rect(patchToBeSplit->getConstPart()); std::vector< std::pair > leftRect(rect),rightRect(rect); leftRect[axisId].second=cutPlace+1; rightRect[axisId].first=cutPlace+1; @@ -1072,11 +1088,11 @@ mcIdType MEDCouplingCartesianAMRMeshGen::getNumberOfPatches() const */ void MEDCouplingCartesianAMRMeshGen::createPatchesFromCriterion(const INTERP_KERNEL::BoxSplittingOptions& bso, const std::vector& criterion, const std::vector& factors) { - mcIdType nbCells(getNumberOfCellsAtCurrentLevel()); + mcIdType const nbCells(getNumberOfCellsAtCurrentLevel()); if(nbCells!=ToIdType(criterion.size())) throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRMeshGen::createPatchesFromCriterion : the number of tuples of criterion array must be equal to the number of cells at the current level !"); _patches.clear(); - std::vector cgs(_mesh->getCellGridStructure()); + std::vector const cgs(_mesh->getCellGridStructure()); std::vector< MCAuto > listOfPatches,listOfPatchesOK; // MCAuto p(new InternalPatch); @@ -1086,31 +1102,31 @@ void MEDCouplingCartesianAMRMeshGen::createPatchesFromCriterion(const INTERP_KER while(!listOfPatches.empty()) { std::vector< MCAuto > listOfPatchesTmp; - for(std::vector< MCAuto >::iterator it=listOfPatches.begin();it!=listOfPatches.end();it++) + for(auto & listOfPatche : listOfPatches) { // int axisId; mcIdType largestLength,cutPlace; - MEDCouplingStructuredMesh::FindTheWidestAxisOfGivenRangeInCompactFrmt((*it)->getConstPart(),axisId,largestLength); - if((*it)->getEfficiency()>=bso.getEfficiencyThreshold() && ((*it)->getNumberOfCells()>bso.getMaximumNbOfCellsInPatch() || largestLength>bso.getMaximumPatchLength())) + MEDCouplingStructuredMesh::FindTheWidestAxisOfGivenRangeInCompactFrmt(listOfPatche->getConstPart(),axisId,largestLength); + if(listOfPatche->getEfficiency()>=bso.getEfficiencyThreshold() && (listOfPatche->getNumberOfCells()>bso.getMaximumNbOfCellsInPatch() || largestLength>bso.getMaximumPatchLength())) { - DissectBigPatch(bso,*it,axisId,largestLength,cutPlace); - DealWithCut(bso.getMinimumPatchLength(),*it,axisId,cutPlace,listOfPatchesTmp); + DissectBigPatch(bso,listOfPatche,axisId,largestLength,cutPlace); + DealWithCut(bso.getMinimumPatchLength(),listOfPatche,axisId,cutPlace,listOfPatchesTmp); continue; }//action 1 - if(FindHole(bso,*it,axisId,cutPlace))//axisId overwritten here if FindHole equal to true ! - { DealWithCut(bso.getMinimumPatchLength(),*it,axisId,cutPlace,listOfPatchesTmp); continue; }//action 2 - if(FindInflection(bso,*it,cutPlace,axisId))//axisId overwritten here if cutFound equal to true ! - { DealWithCut(bso.getMinimumPatchLength(),*it,axisId,cutPlace,listOfPatchesTmp); continue; }//action 3 - if(TryAction4(bso,*it,axisId,largestLength,cutPlace)) - { DealWithCut(bso.getMinimumPatchLength(),*it,axisId,cutPlace,listOfPatchesTmp); continue; }//action 4 + if(FindHole(bso,listOfPatche,axisId,cutPlace))//axisId overwritten here if FindHole equal to true ! + { DealWithCut(bso.getMinimumPatchLength(),listOfPatche,axisId,cutPlace,listOfPatchesTmp); continue; }//action 2 + if(FindInflection(bso,listOfPatche,cutPlace,axisId))//axisId overwritten here if cutFound equal to true ! + { DealWithCut(bso.getMinimumPatchLength(),listOfPatche,axisId,cutPlace,listOfPatchesTmp); continue; }//action 3 + if(TryAction4(bso,listOfPatche,axisId,largestLength,cutPlace)) + { DealWithCut(bso.getMinimumPatchLength(),listOfPatche,axisId,cutPlace,listOfPatchesTmp); continue; }//action 4 else - listOfPatchesOK.push_back(DealWithNoCut(*it)); + listOfPatchesOK.push_back(DealWithNoCut(listOfPatche)); } listOfPatches=listOfPatchesTmp; } - for(std::vector< MCAuto >::const_iterator it=listOfPatchesOK.begin();it!=listOfPatchesOK.end();it++) - addPatch((*it)->getConstPart(),factors); + for(const auto & it : listOfPatchesOK) + addPatch(it->getConstPart(),factors); declareAsNew(); } @@ -1122,7 +1138,7 @@ void MEDCouplingCartesianAMRMeshGen::createPatchesFromCriterion(const INTERP_KER { if(!criterion || !criterion->isAllocated()) throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRMeshGen::createPatchesFromCriterion : the criterion DataArrayByte instance must be allocated and not NULL !"); - std::vector crit(criterion->toVectorOfBool());//check that criterion has one component. + std::vector const crit(criterion->toVectorOfBool());//check that criterion has one component. createPatchesFromCriterion(bso,crit,factors); declareAsNew(); } @@ -1131,14 +1147,14 @@ void MEDCouplingCartesianAMRMeshGen::createPatchesFromCriterion(const INTERP_KER { if(!criterion) throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRMeshGen::createPatchesFromCriterion : null criterion pointer !"); - std::vector inp(criterion->toVectorOfBool(eps)); + std::vector const inp(criterion->toVectorOfBool(eps)); createPatchesFromCriterion(bso,inp,factors); } mcIdType MEDCouplingCartesianAMRMeshGen::getPatchIdFromChildMesh(const MEDCouplingCartesianAMRMeshGen *mesh) const { mcIdType ret(0); - for(std::vector< MCAuto >::const_iterator it=_patches.begin();it!=_patches.end();it++,ret++) + for(auto it=_patches.begin();it!=_patches.end();it++,ret++) { if((*it)->getMesh()==mesh) return ret; @@ -1148,7 +1164,7 @@ mcIdType MEDCouplingCartesianAMRMeshGen::getPatchIdFromChildMesh(const MEDCoupli std::vector< const MEDCouplingCartesianAMRPatch *> MEDCouplingCartesianAMRMeshGen::getPatches() const { - std::size_t sz(_patches.size()); + std::size_t const sz(_patches.size()); std::vector< const MEDCouplingCartesianAMRPatch *> ret(sz); for(std::size_t i=0;igetCellGridStructure(),cellFieldOnPatch,patch->getBLTRRange(),getFactors()); if(isConservative) { - mcIdType fact(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(getFactors())); + mcIdType const fact(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(getFactors())); std::transform(cellFieldOnPatch->begin(),cellFieldOnPatch->end(),cellFieldOnPatch->getPointer(),std::bind(std::multiplies(),std::placeholders::_1,1./((double)fact))); } } @@ -1238,7 +1254,7 @@ void MEDCouplingCartesianAMRMeshGen::fillCellFieldOnPatchGhost(mcIdType patchId, MEDCouplingIMesh::SpreadCoarseToFineGhost(cellFieldOnThis,_mesh->getCellGridStructure(),cellFieldOnPatch,patch->getBLTRRange(),getFactors(),ghostLev); if(isConservative) { - mcIdType fact(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(getFactors())); + mcIdType const fact(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(getFactors())); std::transform(cellFieldOnPatch->begin(),cellFieldOnPatch->end(),cellFieldOnPatch->getPointer(),std::bind(std::multiplies(),std::placeholders::_1,1./((double)fact))); } } @@ -1273,13 +1289,13 @@ void MEDCouplingCartesianAMRMeshGen::fillCellFieldOnPatchOnlyOnGhostZone(mcIdTyp */ void MEDCouplingCartesianAMRMeshGen::fillCellFieldOnPatchGhostAdv(mcIdType patchId, const DataArrayDouble *cellFieldOnThis, mcIdType ghostLev, const std::vector& arrsOnPatches, bool isConservative) const { - mcIdType nbp(getNumberOfPatches()); + mcIdType const nbp(getNumberOfPatches()); if(nbp!=ToIdType(arrsOnPatches.size())) { std::ostringstream oss; oss << "MEDCouplingCartesianAMRMesh::fillCellFieldOnPatchGhostAdv : there are " << nbp << " patches in this and " << arrsOnPatches.size() << " arrays in the last parameter !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - DataArrayDouble *theFieldToFill(const_cast(arrsOnPatches[patchId])); + auto *theFieldToFill(const_cast(arrsOnPatches[patchId])); // first, do as usual fillCellFieldOnPatchGhost(patchId,cellFieldOnThis,theFieldToFill,ghostLev,isConservative); fillCellFieldOnPatchOnlyGhostAdv(patchId,ghostLev,arrsOnPatches); @@ -1293,19 +1309,19 @@ void MEDCouplingCartesianAMRMeshGen::fillCellFieldOnPatchGhostAdv(mcIdType patch */ void MEDCouplingCartesianAMRMeshGen::fillCellFieldOnPatchOnlyGhostAdv(mcIdType patchId, mcIdType ghostLev, const std::vector& arrsOnPatches) const { - mcIdType nbp(getNumberOfPatches()); + mcIdType const nbp(getNumberOfPatches()); if(nbp!=ToIdType(arrsOnPatches.size())) { std::ostringstream oss; oss << "MEDCouplingCartesianAMRMesh::fillCellFieldOnPatchOnlyGhostAdv : there are " << nbp << " patches in this and " << arrsOnPatches.size() << " arrays in the last parameter !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } const MEDCouplingCartesianAMRPatch *refP(getPatch(patchId)); - DataArrayDouble *theFieldToFill(const_cast(arrsOnPatches[patchId])); - std::vector ids(getPatchIdsInTheNeighborhoodOf(patchId,ghostLev)); - for(std::vector::const_iterator it=ids.begin();it!=ids.end();it++) + auto *theFieldToFill(const_cast(arrsOnPatches[patchId])); + std::vector const ids(getPatchIdsInTheNeighborhoodOf(patchId,ghostLev)); + for(long const id : ids) { - const MEDCouplingCartesianAMRPatch *otherP(getPatch(*it)); - MEDCouplingCartesianAMRPatch::UpdateNeighborsOfOneWithTwo(ghostLev,_factors,refP,otherP,theFieldToFill,arrsOnPatches[*it]); + const MEDCouplingCartesianAMRPatch *otherP(getPatch(id)); + MEDCouplingCartesianAMRPatch::UpdateNeighborsOfOneWithTwo(ghostLev,_factors,refP,otherP,theFieldToFill,arrsOnPatches[id]); } } @@ -1334,7 +1350,7 @@ void MEDCouplingCartesianAMRMeshGen::fillCellFieldComingFromPatch(mcIdType patch MEDCouplingIMesh::CondenseFineToCoarse(_mesh->getCellGridStructure(),cellFieldOnPatch,patch->getBLTRRange(),getFactors(),cellFieldOnThis); if(!isConservative) { - mcIdType fact(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(getFactors())); + mcIdType const fact(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(getFactors())); MEDCouplingStructuredMesh::MultiplyPartOf(_mesh->getCellGridStructure(),patch->getBLTRRange(),1./((double)fact),cellFieldOnThis); } } @@ -1361,7 +1377,7 @@ void MEDCouplingCartesianAMRMeshGen::fillCellFieldComingFromPatchGhost(mcIdType MEDCouplingIMesh::CondenseFineToCoarseGhost(_mesh->getCellGridStructure(),cellFieldOnPatch,patch->getBLTRRange(),getFactors(),cellFieldOnThis,ghostLev); if(!isConservative) { - mcIdType fact(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(getFactors())); + mcIdType const fact(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(getFactors())); MEDCouplingStructuredMesh::MultiplyPartOfByGhost(_mesh->getCellGridStructure(),patch->getBLTRRange(),ghostLev,1./((double)fact),cellFieldOnThis); } } @@ -1376,7 +1392,7 @@ void MEDCouplingCartesianAMRMeshGen::fillCellFieldComingFromPatchGhost(mcIdType */ DataArrayIdType *MEDCouplingCartesianAMRMeshGen::findPatchesInTheNeighborhoodOf(mcIdType patchId, mcIdType ghostLev) const { - mcIdType nbp(getNumberOfPatches()); + mcIdType const nbp(getNumberOfPatches()); MCAuto ret(DataArrayIdType::New()); ret->alloc(0,1); for(mcIdType i=0;i part(_mesh->buildUnstructured()); std::vector bs(_mesh->getNumberOfCells(),false); - std::vector cgs(_mesh->getCellGridStructure()); + std::vector const cgs(_mesh->getCellGridStructure()); std::vector< MCAuto > msSafe(_patches.size()+1); std::size_t ii(0); - for(std::vector< MCAuto >::const_iterator it=_patches.begin();it!=_patches.end();it++,ii++) + for(auto it=_patches.begin();it!=_patches.end();it++,ii++) { MEDCouplingStructuredMesh::SwitchOnIdsFrom(cgs,(*it)->getBLTRRange(),bs); msSafe[ii+1]=(*it)->getMesh()->buildUnstructured(); @@ -1417,12 +1433,12 @@ MEDCoupling1SGTUMesh *MEDCouplingCartesianAMRMeshGen::buildMeshFromPatchEnvelop( { std::vector cells; std::vector< MCAuto > cellsSafe; - for(std::vector< MCAuto >::const_iterator it=_patches.begin();it!=_patches.end();it++) + for(const auto & _patche : _patches) { - const MEDCouplingCartesianAMRPatch *patch(*it); + const MEDCouplingCartesianAMRPatch *patch(_patche); if(patch) { - MCAuto cell(patch->getMesh()->getImageMesh()->asSingleCell()); + MCAuto const cell(patch->getMesh()->getImageMesh()->asSingleCell()); MCAuto cell1SGT(cell->build1SGTUnstructured()); cellsSafe.push_back(cell1SGT); cells.push_back(cell1SGT); } @@ -1434,9 +1450,9 @@ MEDCoupling1SGTUMesh *MEDCouplingCartesianAMRMeshGen::buildMeshOfDirectChildrenO { std::vector patches; std::vector< MCAuto > patchesSafe; - for(std::vector< MCAuto >::const_iterator it=_patches.begin();it!=_patches.end();it++) + for(const auto & _patche : _patches) { - const MEDCouplingCartesianAMRPatch *patch(*it); + const MEDCouplingCartesianAMRPatch *patch(_patche); if(patch) { MCAuto patchMesh(patch->getMesh()->getImageMesh()->build1SGTUnstructured()); @@ -1457,13 +1473,13 @@ MEDCouplingFieldDouble *MEDCouplingCartesianAMRMeshGen::buildCellFieldOnRecurseW throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRMeshGen::buildCellFieldOnRecurseWithoutOverlapWithoutGhost : array is empty ! Should never happen !"); // std::vector bs(_mesh->getNumberOfCells(),false); - std::vector cgs(_mesh->getCellGridStructure()); + std::vector const cgs(_mesh->getCellGridStructure()); std::vector< MCAuto > msSafe(_patches.size()+1); std::size_t ii(0); - for(std::vector< MCAuto >::const_iterator it=_patches.begin();it!=_patches.end();it++,ii++) + for(auto it=_patches.begin();it!=_patches.end();it++,ii++) { MEDCouplingStructuredMesh::SwitchOnIdsFrom(cgs,(*it)->getBLTRRange(),bs); - std::vector tmpArrs(extractSubTreeFromGlobalFlatten((*it)->getMesh(),recurseArrs)); + std::vector const tmpArrs(extractSubTreeFromGlobalFlatten((*it)->getMesh(),recurseArrs)); msSafe[ii+1]=(*it)->getMesh()->buildCellFieldOnRecurseWithoutOverlapWithoutGhost(ghostSz,tmpArrs); } MCAuto eltsOff(DataArrayIdType::BuildListOfSwitchedOff(bs)); @@ -1507,7 +1523,7 @@ DataArrayDouble *MEDCouplingCartesianAMRMeshGen::extractGhostFrom(mcIdType ghost std::vector MEDCouplingCartesianAMRMeshGen::getPatchIdsInTheNeighborhoodOf(mcIdType patchId, mcIdType ghostLev) const { std::vector ret; - mcIdType nbp(getNumberOfPatches()); + mcIdType const nbp(getNumberOfPatches()); // for(mcIdType i=0;i(mesh->deepCopy()); - std::size_t sz(other._patches.size()); + std::size_t const sz(other._patches.size()); for(std::size_t i=0;i=sz) { std::ostringstream oss; oss << "MEDCouplingCartesianAMRMeshGen::checkPatchId : invalid patchId (" << patchId << ") ! Must be in [0," << sz << ") !"; @@ -1596,27 +1612,27 @@ void MEDCouplingCartesianAMRMeshGen::retrieveGridsAtInternal(mcIdType lev, std:: { if(lev==0) { - const MEDCouplingCartesianAMRMesh *thisc(dynamic_cast(this));//tony + const auto *thisc(dynamic_cast(this));//tony MCAuto elt(new MEDCouplingCartesianAMRPatchGF(const_cast(thisc))); grids.push_back(DynamicCastSafe(elt)); } else if(lev==1) { - for(std::vector< MCAuto >::const_iterator it=_patches.begin();it!=_patches.end();it++) + for(const auto & _patche : _patches) { - const MEDCouplingCartesianAMRPatch *pt(*it); + const MEDCouplingCartesianAMRPatch *pt(_patche); if(pt) { - MCAuto tmp1(*it); + MCAuto tmp1(_patche); grids.push_back(DynamicCastSafe(tmp1)); } } } else { - for(std::vector< MCAuto >::const_iterator it=_patches.begin();it!=_patches.end();it++) + for(const auto & _patche : _patches) { - const MEDCouplingCartesianAMRPatch *pt(*it); + const MEDCouplingCartesianAMRPatch *pt(_patche); if(pt) pt->getMesh()->retrieveGridsAtInternal(lev-1,grids); } @@ -1635,8 +1651,8 @@ mcIdType MEDCouplingCartesianAMRMeshGen::GetGhostLevelInFineRef(mcIdType ghostLe else { ghostLevInPatchRef=(ghostLev-1)/factors[0]+1; - for(std::size_t i=0;i MEDCouplingCartesianAMRMeshGen::extractSubTreeFromGlobalFlatten(const MEDCouplingCartesianAMRMeshGen *head, const std::vector& all) const { - mcIdType maxLev(getMaxNumberOfLevelsRelativeToThis()); + mcIdType const maxLev(getMaxNumberOfLevelsRelativeToThis()); std::vector ret; std::vector meshes(1,this); std::size_t kk(0); for(mcIdType i=0;i meshesTmp; - for(std::vector::const_iterator it=meshes.begin();it!=meshes.end();it++) + for(auto meshe : meshes) { - if((*it)==head || head->isObjectInTheProgeny(*it)) + if(meshe==head || head->isObjectInTheProgeny(meshe)) ret.push_back(all[kk]); kk++; - std::vector< const MEDCouplingCartesianAMRPatch *> ps((*it)->getPatches()); - for(std::vector< const MEDCouplingCartesianAMRPatch *>::const_iterator it0=ps.begin();it0!=ps.end();it0++) + std::vector< const MEDCouplingCartesianAMRPatch *> const ps(meshe->getPatches()); + for(auto p : ps) { - const MEDCouplingCartesianAMRMeshGen *mesh((*it0)->getMesh()); + const MEDCouplingCartesianAMRMeshGen *mesh(p->getMesh()); meshesTmp.push_back(mesh); } } @@ -1676,14 +1692,14 @@ std::vector MEDCouplingCartesianAMRMeshGen::extractSubT void MEDCouplingCartesianAMRMeshGen::dumpPatchesOf(const std::string& varName, std::ostream& oss) const { std::size_t j(0); - for(std::vector< MCAuto >::const_iterator it=_patches.begin();it!=_patches.end();it++) + for(const auto & _patche : _patches) { - const MEDCouplingCartesianAMRPatch *patch(*it); + const MEDCouplingCartesianAMRPatch *patch(_patche); if(patch) { std::ostringstream oss2; oss2 << varName << ".addPatch(["; const std::vector< std::pair >& bltr(patch->getBLTRRange()); - std::size_t sz(bltr.size()); + std::size_t const sz(bltr.size()); for(std::size_t i=0;i MEDCouplingCartesianAMRMeshGen::getDirectCh { std::vector ret; ret.push_back((const MEDCouplingIMesh *)_mesh); - for(std::vector< MCAuto >::const_iterator it=_patches.begin();it!=_patches.end();it++) - ret.push_back((const MEDCouplingCartesianAMRPatch*)*it); + for(const auto & _patche : _patches) + ret.push_back((const MEDCouplingCartesianAMRPatch*)_patche); return ret; } @@ -1718,9 +1734,9 @@ void MEDCouplingCartesianAMRMeshGen::updateTime() const { if((const MEDCouplingIMesh *)_mesh) updateTimeWith(*_mesh); - for(std::vector< MCAuto >::const_iterator it=_patches.begin();it!=_patches.end();it++) + for(const auto & _patche : _patches) { - const MEDCouplingCartesianAMRPatch *elt(*it); + const MEDCouplingCartesianAMRPatch *elt(_patche); if(!elt) continue; const MEDCouplingCartesianAMRMeshGen *mesh(elt->getMesh()); @@ -1759,16 +1775,16 @@ mcIdType MEDCouplingCartesianAMRMeshSub::getAbsoluteLevel() const void MEDCouplingCartesianAMRMeshSub::detachFromFather() { - _father=0; + _father=nullptr; declareAsNew(); } std::vector< std::pair > MEDCouplingCartesianAMRMeshSub::positionRelativeToGodFather(std::vector& st) const { st=_father->getFactors(); - std::size_t dim(st.size()); + std::size_t const dim(st.size()); std::vector prev(st); - mcIdType id(_father->getPatchIdFromChildMesh(this)); + mcIdType const id(_father->getPatchIdFromChildMesh(this)); const MEDCouplingCartesianAMRPatch *p(_father->getPatch(id)); std::vector< std::pair > ret(p->getBLTRRange()); std::vector delta(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(ret)),start(dim); @@ -1779,8 +1795,8 @@ std::vector< std::pair > MEDCouplingCartesianAMRMeshSub::posi const MEDCouplingCartesianAMRMeshGen *it(_father); while(!dynamic_cast(it)) { - const MEDCouplingCartesianAMRMeshSub *itc(static_cast(it)); - mcIdType id2(itc->_father->getPatchIdFromChildMesh(itc)); + const auto *itc(static_cast(it)); + mcIdType const id2(itc->_father->getPatchIdFromChildMesh(itc)); const MEDCouplingCartesianAMRPatch *p2(itc->_father->getPatch(id2)); const std::vector< std::pair >& start2(p2->getBLTRRange()); std::vector tmp(dim); @@ -1805,7 +1821,7 @@ mcIdType MEDCouplingCartesianAMRMeshSub::getAbsoluteLevelRelativeTo(const MEDCou { if(this==ref) return 0; - if(_father==0) + if(_father==nullptr) throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRMeshSub::getAbsoluteLevelRelativeTo : ref is not in the progeny of this !"); else return _father->getAbsoluteLevelRelativeTo(ref)+1; @@ -1829,7 +1845,7 @@ void MEDCouplingCartesianAMRMeshSub::getPositionRelativeToInternal(const MEDCoup return ; if(!_father) throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRMeshSub::getPositionRelativeToInternal : ref is not in the progeny of this !"); - mcIdType myId(_father->getPatchIdFromChildMesh(this)); + mcIdType const myId(_father->getPatchIdFromChildMesh(this)); ret.push_back(myId); _father->getPositionRelativeToInternal(ref,ret); } @@ -1848,7 +1864,7 @@ MEDCouplingCartesianAMRMesh *MEDCouplingCartesianAMRMesh::New(MEDCouplingIMesh * const MEDCouplingCartesianAMRMeshGen *MEDCouplingCartesianAMRMesh::getFather() const { //I'm god father ! No father ! - return 0; + return nullptr; } const MEDCouplingCartesianAMRMeshGen *MEDCouplingCartesianAMRMesh::getGodFather() const @@ -1911,7 +1927,7 @@ MEDCouplingCartesianAMRMesh *MEDCouplingCartesianAMRMesh::deepCopy(MEDCouplingCa */ void MEDCouplingCartesianAMRMesh::createPatchesFromCriterionML(const std::vector& bso, const DataArrayDouble *criterion, const std::vector< std::vector >& factors, double eps) { - std::size_t nbOfLevs(bso.size()); + std::size_t const nbOfLevs(bso.size()); if(nbOfLevs!=factors.size()) throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRMesh::createPatchesFromCriterionML : size of vectors must be the same !"); if(nbOfLevs==0) @@ -1925,7 +1941,7 @@ void MEDCouplingCartesianAMRMesh::createPatchesFromCriterionML(const std::vector throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRMesh::createPatchesFromCriterionML : presence of a NULL BoxSplittingOptions in input vector !"); // std::vector elts(retrieveGridsAt(ToIdType((i)))); - std::size_t sz(elts.size()); + std::size_t const sz(elts.size()); std::vector< MCAuto > elts2(sz); std::vector< MCAuto > elts3(sz); for(std::size_t ii=0;ii > fieldNames(1); fieldNames[0].first=TMP_STR; fieldNames[0].second=1; MCAuto att(MEDCouplingAMRAttribute::New(this,fieldNames,0)); att->alloc(); - DataArrayDouble *tmpDa(const_cast(att->getFieldOn(this,TMP_STR))); + auto *tmpDa(const_cast(att->getFieldOn(this,TMP_STR))); tmpDa->deepCopyFrom(*criterion); att->synchronizeCoarseToFine(); for(std::size_t ii=0;iigetFieldOn(const_cast(elts[ii]->getMesh()),TMP_STR)); elts3[ii]=const_cast(critOnLeaf); elts3[ii]->incrRef(); } - att=0; + att=nullptr; for(std::size_t ii=0;ii(elts[ii]->getMesh())->createPatchesFromCriterion(*bso[i],elts3[ii],factors[i],eps); } @@ -1954,9 +1970,8 @@ void MEDCouplingCartesianAMRMesh::getPositionRelativeToInternal(const MEDCouplin } -MEDCouplingCartesianAMRMesh::MEDCouplingCartesianAMRMesh(const MEDCouplingCartesianAMRMesh& other):MEDCouplingCartesianAMRMeshGen(other) -{ -} +MEDCouplingCartesianAMRMesh::MEDCouplingCartesianAMRMesh(const MEDCouplingCartesianAMRMesh& other) += default; MEDCouplingCartesianAMRMesh::MEDCouplingCartesianAMRMesh(const std::string& meshName, int spaceDim, const mcIdType *nodeStrctStart, const mcIdType *nodeStrctStop, const double *originStart, const double *originStop, const double *dxyzStart, const double *dxyzStop):MEDCouplingCartesianAMRMeshGen(meshName,spaceDim,nodeStrctStart,nodeStrctStop,originStart,originStop,dxyzStart,dxyzStop) @@ -1974,5 +1989,4 @@ std::vector MEDCouplingCartesianAMRMesh::getDirectChild } MEDCouplingCartesianAMRMesh::~MEDCouplingCartesianAMRMesh() -{ -} += default; diff --git a/src/MEDCoupling/MEDCouplingCartesianAMRMesh.hxx b/src/MEDCoupling/MEDCouplingCartesianAMRMesh.hxx index 65384f182..e574f8780 100644 --- a/src/MEDCoupling/MEDCouplingCartesianAMRMesh.hxx +++ b/src/MEDCoupling/MEDCouplingCartesianAMRMesh.hxx @@ -28,7 +28,11 @@ #include "MCType.hxx" #include "BoxSplittingOptions.hxx" -#include "InterpKernelException.hxx" +#include +#include +#include +#include +#include namespace MEDCoupling { @@ -61,7 +65,7 @@ namespace MEDCoupling const MEDCouplingCartesianAMRMeshGen *getMeshSafe() const; MEDCouplingCartesianAMRMeshGen *getMeshSafe(); private: - std::vector getDirectChildrenWithNull() const; + std::vector getDirectChildrenWithNull() const override; protected: MCAuto _mesh; }; @@ -74,7 +78,7 @@ namespace MEDCoupling public: MEDCouplingCartesianAMRPatch(MEDCouplingCartesianAMRMeshGen *mesh, const std::vector< std::pair >& bottomLeftTopRight); std::string getClassName() const override { return std::string("MEDCouplingCartesianAMRPatch"); } - MEDCouplingCartesianAMRPatch *deepCopy(MEDCouplingCartesianAMRMeshGen *father) const; + MEDCouplingCartesianAMRPatch *deepCopy(MEDCouplingCartesianAMRMeshGen *father) const override; // direct forward to _mesh MEDCOUPLING_EXPORT void addPatch(const std::vector< std::pair >& bottomLeftTopRight, const std::vector& factors); // end of direct forward to _mesh @@ -96,7 +100,7 @@ namespace MEDCoupling private: static void ComputeZonesOfTwoRelativeToOneDiffLev(mcIdType ghostLev, const MEDCouplingCartesianAMRPatch *p1, const MEDCouplingCartesianAMRPatch *p2, std::vector< std::pair >& p1Zone, std::vector< std::pair >& p2Zone, std::vector& factToApplyOn2); private: - std::size_t getHeapMemorySizeWithoutChildren() const; + std::size_t getHeapMemorySizeWithoutChildren() const override; static const MEDCouplingCartesianAMRMeshGen *FindCommonAncestor(const MEDCouplingCartesianAMRPatch *p1, const MEDCouplingCartesianAMRPatch *p2, mcIdType& lev); static std::vector ComputeOffsetFromTwoToOne(const MEDCouplingCartesianAMRMeshGen *comAncestor, mcIdType lev, const MEDCouplingCartesianAMRPatch *p1, const MEDCouplingCartesianAMRPatch *p2); static void UpdateNeighborsOfOneWithTwoInternal(mcIdType ghostLev, const std::vector& factors, const std::vector< std::pair >&p1 ,const std::vector< std::pair >&p2, DataArrayDouble *dataOnP1, const DataArrayDouble *dataOnP2); @@ -118,9 +122,9 @@ namespace MEDCoupling public: MEDCouplingCartesianAMRPatchGF(MEDCouplingCartesianAMRMesh *mesh); std::string getClassName() const override { return std::string("MEDCouplingCartesianAMRPatchGF"); } - MEDCouplingCartesianAMRPatchGF *deepCopy(MEDCouplingCartesianAMRMeshGen *father) const; + MEDCouplingCartesianAMRPatchGF *deepCopy(MEDCouplingCartesianAMRMeshGen *father) const override; private: - std::size_t getHeapMemorySizeWithoutChildren() const; + std::size_t getHeapMemorySizeWithoutChildren() const override; private: MEDCouplingCartesianAMRPatchGF(const MEDCouplingCartesianAMRPatchGF& other, MEDCouplingCartesianAMRMeshGen *father); }; @@ -204,9 +208,9 @@ namespace MEDCoupling public: virtual void getPositionRelativeToInternal(const MEDCouplingCartesianAMRMeshGen *ref, std::vector& ret) const = 0; protected: - MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; - MEDCOUPLING_EXPORT std::vector getDirectChildrenWithNull() const; - MEDCOUPLING_EXPORT void updateTime() const; + MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const override; + MEDCOUPLING_EXPORT std::vector getDirectChildrenWithNull() const override; + MEDCOUPLING_EXPORT void updateTime() const override; protected: MCAuto _mesh; std::vector< MCAuto > _patches; @@ -218,16 +222,16 @@ namespace MEDCoupling public: MEDCouplingCartesianAMRMeshSub(MEDCouplingCartesianAMRMeshGen *father, MEDCouplingIMesh *mesh); MEDCOUPLING_EXPORT std::string getClassName() const override { return std::string("MEDCouplingCartesianAMRMeshSub"); } - MEDCOUPLING_EXPORT const MEDCouplingCartesianAMRMeshGen *getFather() const; - MEDCOUPLING_EXPORT const MEDCouplingCartesianAMRMeshGen *getGodFather() const; - MEDCOUPLING_EXPORT mcIdType getAbsoluteLevel() const; - MEDCOUPLING_EXPORT void detachFromFather(); - MEDCOUPLING_EXPORT std::vector< std::pair > positionRelativeToGodFather(std::vector& st) const; - MEDCOUPLING_EXPORT mcIdType getAbsoluteLevelRelativeTo(const MEDCouplingCartesianAMRMeshGen *ref) const; + MEDCOUPLING_EXPORT const MEDCouplingCartesianAMRMeshGen *getFather() const override; + MEDCOUPLING_EXPORT const MEDCouplingCartesianAMRMeshGen *getGodFather() const override; + MEDCOUPLING_EXPORT mcIdType getAbsoluteLevel() const override; + MEDCOUPLING_EXPORT void detachFromFather() override; + MEDCOUPLING_EXPORT std::vector< std::pair > positionRelativeToGodFather(std::vector& st) const override; + MEDCOUPLING_EXPORT mcIdType getAbsoluteLevelRelativeTo(const MEDCouplingCartesianAMRMeshGen *ref) const override; private: MEDCouplingCartesianAMRMeshSub(const MEDCouplingCartesianAMRMeshSub& other, MEDCouplingCartesianAMRMeshGen *father); - MEDCouplingCartesianAMRMeshSub *deepCopy(MEDCouplingCartesianAMRMeshGen *father) const; - void getPositionRelativeToInternal(const MEDCouplingCartesianAMRMeshGen *ref, std::vector& ret) const; + MEDCouplingCartesianAMRMeshSub *deepCopy(MEDCouplingCartesianAMRMeshGen *father) const override; + void getPositionRelativeToInternal(const MEDCouplingCartesianAMRMeshGen *ref, std::vector& ret) const override; protected: MEDCouplingCartesianAMRMeshGen *_father; }; @@ -239,23 +243,23 @@ namespace MEDCoupling const double *originStart, const double *originStop, const double *dxyzStart, const double *dxyzStop); MEDCOUPLING_EXPORT static MEDCouplingCartesianAMRMesh *New(MEDCouplingIMesh *mesh); MEDCOUPLING_EXPORT std::string getClassName() const override { return std::string("MEDCouplingCartesianAMRMesh"); } - MEDCOUPLING_EXPORT const MEDCouplingCartesianAMRMeshGen *getFather() const; - MEDCOUPLING_EXPORT const MEDCouplingCartesianAMRMeshGen *getGodFather() const; - MEDCOUPLING_EXPORT mcIdType getAbsoluteLevel() const; - MEDCOUPLING_EXPORT void detachFromFather(); - MEDCOUPLING_EXPORT std::vector< std::pair > positionRelativeToGodFather(std::vector& st) const; - MEDCOUPLING_EXPORT mcIdType getAbsoluteLevelRelativeTo(const MEDCouplingCartesianAMRMeshGen *ref) const; - MEDCOUPLING_EXPORT std::vector retrieveGridsAt(mcIdType absoluteLev) const; - MEDCouplingCartesianAMRMesh *deepCopy(MEDCouplingCartesianAMRMeshGen *father) const; + MEDCOUPLING_EXPORT const MEDCouplingCartesianAMRMeshGen *getFather() const override; + MEDCOUPLING_EXPORT const MEDCouplingCartesianAMRMeshGen *getGodFather() const override; + MEDCOUPLING_EXPORT mcIdType getAbsoluteLevel() const override; + MEDCOUPLING_EXPORT void detachFromFather() override; + MEDCOUPLING_EXPORT std::vector< std::pair > positionRelativeToGodFather(std::vector& st) const override; + MEDCOUPLING_EXPORT mcIdType getAbsoluteLevelRelativeTo(const MEDCouplingCartesianAMRMeshGen *ref) const override; + MEDCOUPLING_EXPORT std::vector retrieveGridsAt(mcIdType absoluteLev) const override; + MEDCouplingCartesianAMRMesh *deepCopy(MEDCouplingCartesianAMRMeshGen *father) const override; MEDCOUPLING_EXPORT void createPatchesFromCriterionML(const std::vector& bso, const DataArrayDouble *criterion, const std::vector< std::vector >& factors, double eps); private: - void getPositionRelativeToInternal(const MEDCouplingCartesianAMRMeshGen *ref, std::vector& ret) const; + void getPositionRelativeToInternal(const MEDCouplingCartesianAMRMeshGen *ref, std::vector& ret) const override; MEDCouplingCartesianAMRMesh(const MEDCouplingCartesianAMRMesh& other); MEDCouplingCartesianAMRMesh(const std::string& meshName, int spaceDim, const mcIdType *nodeStrctStart, const mcIdType *nodeStrctStop, const double *originStart, const double *originStop, const double *dxyzStart, const double *dxyzStop); MEDCouplingCartesianAMRMesh(MEDCouplingIMesh *mesh); - MEDCOUPLING_EXPORT std::vector getDirectChildrenWithNull() const; - ~MEDCouplingCartesianAMRMesh(); + MEDCOUPLING_EXPORT std::vector getDirectChildrenWithNull() const override; + ~MEDCouplingCartesianAMRMesh() override; }; } diff --git a/src/MEDCoupling/MEDCouplingCurveLinearMesh.cxx b/src/MEDCoupling/MEDCouplingCurveLinearMesh.cxx old mode 100755 new mode 100644 index 278313fc4..fbb392360 --- a/src/MEDCoupling/MEDCouplingCurveLinearMesh.cxx +++ b/src/MEDCoupling/MEDCouplingCurveLinearMesh.cxx @@ -19,21 +19,34 @@ // Author : Anthony Geay (EDF R&D) #include "MEDCouplingCurveLinearMesh.hxx" +#include "MCType.hxx" +#include "MEDCouplingMesh.hxx" +#include "MCIdType.hxx" +#include "MCAuto.hxx" #include "MEDCouplingPointSet.hxx" #include "MEDCouplingMemArray.hxx" #include "MEDCouplingFieldDouble.hxx" +#include "MEDCouplingStructuredMesh.hxx" +#include "NormalizedUnstructuredMesh.hxx" +#include "NormalizedGeometricTypes" +#include "MEDCouplingRefCountObject.hxx" #include "VolSurfUser.txx" #include "PointLocatorAlgos.txx" +#include #include #include +#include +#include #include -#include +#include +#include +#include using namespace MEDCoupling; -MEDCouplingCurveLinearMesh::MEDCouplingCurveLinearMesh():_coords(0),_structure(0) +MEDCouplingCurveLinearMesh::MEDCouplingCurveLinearMesh():_coords(nullptr),_structure(0) { } @@ -49,8 +62,7 @@ MEDCouplingCurveLinearMesh::MEDCouplingCurveLinearMesh(const MEDCouplingCurveLin } MEDCouplingCurveLinearMesh::~MEDCouplingCurveLinearMesh() -{ -} += default; MEDCouplingCurveLinearMesh *MEDCouplingCurveLinearMesh::New() { @@ -59,7 +71,7 @@ MEDCouplingCurveLinearMesh *MEDCouplingCurveLinearMesh::New() MEDCouplingCurveLinearMesh *MEDCouplingCurveLinearMesh::New(const std::string& meshName) { - MEDCouplingCurveLinearMesh *ret=new MEDCouplingCurveLinearMesh; + auto *ret=new MEDCouplingCurveLinearMesh; ret->setName(meshName); return ret; } @@ -100,7 +112,7 @@ std::vector MEDCouplingCurveLinearMesh::getDirectChildr */ void MEDCouplingCurveLinearMesh::copyTinyStringsFrom(const MEDCouplingMesh *other) { - const MEDCouplingCurveLinearMesh *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::copyTinyStringsFrom : meshes have not same type !"); MEDCouplingStructuredMesh::copyTinyStringsFrom(other); @@ -112,7 +124,7 @@ bool MEDCouplingCurveLinearMesh::isEqualIfNotWhy(const MEDCouplingMesh *other, d { if(!other) throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::isEqualIfNotWhy : input other pointer is null !"); - const MEDCouplingCurveLinearMesh *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) { reason="mesh given in input is not castable in MEDCouplingCurveLinearMesh !"; @@ -121,7 +133,7 @@ bool MEDCouplingCurveLinearMesh::isEqualIfNotWhy(const MEDCouplingMesh *other, d if(!MEDCouplingStructuredMesh::isEqualIfNotWhy(other,prec,reason)) return false; std::ostringstream oss; oss.precision(15); - if(((const DataArrayDouble *)_coords && ((const DataArrayDouble *)otherC->_coords)==0) || (((const DataArrayDouble *)_coords)==0 && (const DataArrayDouble *)otherC->_coords)) + if(((const DataArrayDouble *)_coords && ((const DataArrayDouble *)otherC->_coords)==nullptr) || (((const DataArrayDouble *)_coords)==nullptr && (const DataArrayDouble *)otherC->_coords)) { oss << "Only one CurveLinearMesh between the two this and other has its coordinates defined !"; reason=oss.str(); @@ -143,10 +155,10 @@ bool MEDCouplingCurveLinearMesh::isEqualIfNotWhy(const MEDCouplingMesh *other, d bool MEDCouplingCurveLinearMesh::isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const { - const MEDCouplingCurveLinearMesh *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) return false; - if(((const DataArrayDouble *)_coords && ((const DataArrayDouble *)otherC->_coords)==0) || (((const DataArrayDouble *)_coords)==0 && (const DataArrayDouble *)otherC->_coords)) + if(((const DataArrayDouble *)_coords && ((const DataArrayDouble *)otherC->_coords)==nullptr) || (((const DataArrayDouble *)_coords)==nullptr && (const DataArrayDouble *)otherC->_coords)) return false; if((const DataArrayDouble *)_coords) { @@ -158,8 +170,8 @@ bool MEDCouplingCurveLinearMesh::isEqualWithoutConsideringStr(const MEDCouplingM return true; } -void MEDCouplingCurveLinearMesh::checkDeepEquivalWith(const MEDCouplingMesh *other, int cellCompPol, double prec, - DataArrayIdType *&cellCor, DataArrayIdType *&nodeCor) const +void MEDCouplingCurveLinearMesh::checkDeepEquivalWith(const MEDCouplingMesh *other, int /*cellCompPol*/, double prec, + DataArrayIdType *& /*cellCor*/, DataArrayIdType *& /*nodeCor*/) const { if(!isEqualWithoutConsideringStr(other,prec)) throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::checkDeepEquivalWith : Meshes are not the same !"); @@ -169,8 +181,8 @@ void MEDCouplingCurveLinearMesh::checkDeepEquivalWith(const MEDCouplingMesh *oth * Nothing is done here (except to check that the other is a MEDCoupling::MEDCouplingCurveLinearMesh instance too). * The user intend that the nodes are the same, so by construction of MEDCoupling::MEDCouplingCurveLinearMesh, \a this and \a other are the same ! */ -void MEDCouplingCurveLinearMesh::checkDeepEquivalOnSameNodesWith(const MEDCouplingMesh *other, int cellCompPol, double prec, - DataArrayIdType *&cellCor) const +void MEDCouplingCurveLinearMesh::checkDeepEquivalOnSameNodesWith(const MEDCouplingMesh *other, int /*cellCompPol*/, double prec, + DataArrayIdType *& /*cellCor*/) const { if(!isEqualWithoutConsideringStr(other,prec)) throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::checkDeepEquivalOnSameNodesWith : Meshes are not the same !"); @@ -182,7 +194,7 @@ void MEDCouplingCurveLinearMesh::checkConsistencyLight() const mcIdType nbOfNodes=1; if(sz<1) throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::checkConsistencyLight : structure should have a lgth of size 1 at least !"); - for(std::vector::const_iterator it=_structure.begin();it!=_structure.end();it++,i++) + for(auto it=_structure.begin();it!=_structure.end();it++,i++) { if((*it)<1) { std::ostringstream oss; oss << "MEDCouplingCurveLinearMesh::checkConsistencyLight : At pos #" << i << " of structure value is " << *it << "should be >= 1 !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } @@ -201,7 +213,7 @@ void MEDCouplingCurveLinearMesh::checkConsistencyLight() const } } -void MEDCouplingCurveLinearMesh::checkConsistency(double eps) const +void MEDCouplingCurveLinearMesh::checkConsistency(double /*eps*/) const { checkConsistencyLight(); } @@ -240,7 +252,7 @@ void MEDCouplingCurveLinearMesh::getCoordinatesOfNode(mcIdType nodeId, std::vect { if(!((const DataArrayDouble *)_coords)) throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::getCoordinatesOfNode : Coordinates not set !"); - std::size_t nbOfCompo=_coords->getNumberOfComponents(); + std::size_t const nbOfCompo=_coords->getNumberOfComponents(); if(nodeId>=0 && nodeId<_coords->getNumberOfTuples()) coo.insert(coo.end(),_coords->begin()+nodeId*nbOfCompo,_coords->begin()+(nodeId+1)*nbOfCompo); else @@ -253,7 +265,7 @@ std::string MEDCouplingCurveLinearMesh::simpleRepr() const ret << "Curve linear mesh with name : \"" << getName() << "\"\n"; ret << "Description of mesh : \"" << getDescription() << "\"\n"; int tmpp1,tmpp2; - double tt=getTime(tmpp1,tmpp2); + double const tt=getTime(tmpp1,tmpp2); ret << "Time attached to the mesh [unit] : " << tt << " [" << getTimeUnit() << "]\n"; ret << "Iteration : " << tmpp1 << " Order : " << tmpp2 << "\n"; ret << "The nodal structure of curve linear mesh is : ["; @@ -299,7 +311,7 @@ void MEDCouplingCurveLinearMesh::setCoords(const DataArrayDouble *coords) void MEDCouplingCurveLinearMesh::setNodeGridStructure(const mcIdType *gridStructBg, const mcIdType *gridStructEnd) { - std::size_t sz=std::distance(gridStructBg,gridStructEnd); + std::size_t const sz=std::distance(gridStructBg,gridStructEnd); if(sz>=1 && sz<=3) { _structure.resize(0); @@ -320,7 +332,7 @@ std::vector MEDCouplingCurveLinearMesh::getNodeGridStructure() const MEDCouplingStructuredMesh *MEDCouplingCurveLinearMesh::buildStructuredSubPart(const std::vector< std::pair >& cellPart) const { checkConsistencyLight(); - int dim(getSpaceDimension()); + int const dim(getSpaceDimension()); std::vector dims(getMeshDimension()); if(dim!=ToIdType(cellPart.size())) { @@ -328,8 +340,8 @@ MEDCouplingStructuredMesh *MEDCouplingCurveLinearMesh::buildStructuredSubPart(co throw INTERP_KERNEL::Exception(oss.str().c_str()); } std::vector< std::pair > nodePartFormat(cellPart); - for(std::vector< std::pair >::iterator it=nodePartFormat.begin();it!=nodePartFormat.end();it++) - (*it).second++; + for(auto & it : nodePartFormat) + it.second++; MCAuto tmp1(BuildExplicitIdsFrom(getNodeGridStructure(),nodePartFormat)); MCAuto ret(dynamic_cast(deepCopy())); const DataArrayDouble *coo(ret->getCoords()); @@ -358,7 +370,7 @@ void MEDCouplingCurveLinearMesh::getBoundingBox(double *bbox) const MEDCouplingFieldDouble *MEDCouplingCurveLinearMesh::getMeasureField(bool isAbs) const { checkConsistencyLight(); - int meshDim=getMeshDimension(); + int const meshDim=getMeshDimension(); std::string name="MeasureOfMesh_"; name+=getName(); MCAuto field=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME); field->setName(name); field->setMesh(const_cast(this)); field->synchronizeTimeWithMesh(); @@ -382,8 +394,8 @@ MEDCouplingFieldDouble *MEDCouplingCurveLinearMesh::getMeasureField(bool isAbs) */ void MEDCouplingCurveLinearMesh::getMeasureFieldMeshDim1(bool isAbs, MEDCouplingFieldDouble *field) const { - mcIdType nbnodes=getNumberOfNodes(); - int spaceDim=getSpaceDimension(); + mcIdType const nbnodes=getNumberOfNodes(); + int const spaceDim=getSpaceDimension(); MCAuto arr=DataArrayDouble::New(); field->setArray(arr); if(nbnodes==0) { arr->alloc(0,1); return; } @@ -409,15 +421,15 @@ void MEDCouplingCurveLinearMesh::getMeasureFieldMeshDim1(bool isAbs, MEDCoupling */ void MEDCouplingCurveLinearMesh::getMeasureFieldMeshDim2(bool isAbs, MEDCouplingFieldDouble *field) const { - mcIdType nbcells=getNumberOfCells(); - int spaceDim=getSpaceDimension(); + mcIdType const nbcells=getNumberOfCells(); + int const spaceDim=getSpaceDimension(); if(spaceDim!=2 && spaceDim!=3) throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::getMeasureFieldMeshDim2 : with meshDim 2 only space dimension 2 and 3 are possible !"); MCAuto arr=DataArrayDouble::New(); field->setArray(arr); arr->alloc(nbcells,1); double *pt=arr->getPointer(); const double *coords=_coords->begin(); - mcIdType nX=_structure[0]-1; + mcIdType const nX=_structure[0]-1; mcIdType conn[4]; for(mcIdType i=0;i arr=DataArrayDouble::New(); field->setArray(arr); @@ -445,13 +457,13 @@ void MEDCouplingCurveLinearMesh::getMeasureFieldMeshDim3(bool isAbs, MEDCoupling double *pt=arr->getPointer(); const double *coords=_coords->begin(); mcIdType nX=_structure[0]-1,nY=(_structure[0]-1)*(_structure[1]-1); - mcIdType nY1=_structure[0]*_structure[1]; + mcIdType const nY1=_structure[0]*_structure[1]; mcIdType conn[8]; for(mcIdType i=0;i(INTERP_KERNEL::NORM_HEXA8,conn,8,coords,3); @@ -463,7 +475,7 @@ void MEDCouplingCurveLinearMesh::getMeasureFieldMeshDim3(bool isAbs, MEDCoupling /*! * not implemented yet ! */ -MEDCouplingFieldDouble *MEDCouplingCurveLinearMesh::getMeasureFieldOnNode(bool isAbs) const +MEDCouplingFieldDouble *MEDCouplingCurveLinearMesh::getMeasureFieldOnNode(bool /*isAbs*/) const { throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::getMeasureFieldOnNode : not implemented yet !"); } @@ -474,7 +486,7 @@ MEDCouplingFieldDouble *MEDCouplingCurveLinearMesh::buildOrthogonalField() const throw INTERP_KERNEL::Exception("Expected a cmesh with meshDim == 2 !"); MEDCouplingFieldDouble *ret=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME); DataArrayDouble *array=DataArrayDouble::New(); - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbOfCells=getNumberOfCells(); array->alloc(nbOfCells,3); double *vals=array->getPointer(); for(mcIdType i=0;igetConstPointer(); mcIdType nodeId=-1; _coords->distanceToTuple(pos,pos+spaceDim,nodeId); if(nodeId<0) throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::getCellContainingPoint : internal problem 1 !"); mcIdType conn[8]; - mcIdType nbOfNodes=getNumberOfNodes(); + mcIdType const nbOfNodes=getNumberOfNodes(); if(nbOfNodes==1) throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::getCellContainingPoint : No cells in this !"); switch(getMeshDimension()) @@ -575,8 +587,8 @@ mcIdType MEDCouplingCurveLinearMesh::getCellContainingPoint(const double *pos, d { if(spaceDim==3) { - mcIdType nY=_structure[0]*_structure[1]; - mcIdType nz=nodeId/_structure[1]; mcIdType ny=(nodeId-nz*nY)/_structure[0]; mcIdType nx=(nodeId-nz*nY)-_structure[0]*ny; + mcIdType const nY=_structure[0]*_structure[1]; + mcIdType const nz=nodeId/_structure[1]; mcIdType const ny=(nodeId-nz*nY)/_structure[0]; mcIdType const nx=(nodeId-nz*nY)-_structure[0]*ny; if(nx>0 && ny>0 && nz>0) { conn[0]=nx-1+_structure[0]*(ny-1)+nY*(nz-1); conn[1]=nx-1+_structure[2]*ny+nY*(nz-1); conn[2]=nx+_structure[2]*ny+nY*(nz-1); conn[3]=nx+_structure[0]*(ny-1)+nY*(nz-1); @@ -652,8 +664,8 @@ void MEDCouplingCurveLinearMesh::rotate(const double *center, const double *vect { if(!((DataArrayDouble *)_coords)) throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::rotate : no coordinates set !"); - int spaceDim=getSpaceDimension(); - mcIdType nbNodes(_coords->getNumberOfTuples()); + int const spaceDim=getSpaceDimension(); + mcIdType const nbNodes(_coords->getNumberOfTuples()); double *coords=_coords->getPointer(); if(spaceDim==3) DataArrayDouble::Rotate3DAlg(center,vector,angle,nbNodes,coords,coords); @@ -672,8 +684,8 @@ void MEDCouplingCurveLinearMesh::translate(const double *vector) if(!((DataArrayDouble *)_coords)) throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::translate : no coordinates set !"); double *coords=_coords->getPointer(); - mcIdType nbNodes=getNumberOfNodes(); - int dim=getSpaceDimension(); + mcIdType const nbNodes=getNumberOfNodes(); + int const dim=getSpaceDimension(); for(mcIdType i=0; igetPointer(); - mcIdType nbNodes(_coords->getNumberOfTuples()); - std::size_t dim(_coords->getNumberOfComponents()); + mcIdType const nbNodes(_coords->getNumberOfTuples()); + std::size_t const dim(_coords->getNumberOfComponents()); for(mcIdType i=0;i()); @@ -700,14 +712,14 @@ void MEDCouplingCurveLinearMesh::scale(const double *point, double factor) updateTime(); } -MEDCouplingMesh *MEDCouplingCurveLinearMesh::mergeMyselfWith(const MEDCouplingMesh *other) const +MEDCouplingMesh *MEDCouplingCurveLinearMesh::mergeMyselfWith(const MEDCouplingMesh * /*other*/) const { throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::mergeMyselfWith : not available for CurveLinear Mesh !"); } DataArrayDouble *MEDCouplingCurveLinearMesh::getCoordinatesAndOwner() const { - DataArrayDouble *ret=const_cast((const DataArrayDouble *)_coords); + auto *ret=const_cast((const DataArrayDouble *)_coords); if(ret) ret->incrRef(); return ret; @@ -717,9 +729,9 @@ DataArrayDouble *MEDCouplingCurveLinearMesh::computeCellCenterOfMass() const { checkConsistencyLight(); MCAuto ret=DataArrayDouble::New(); - int spaceDim=getSpaceDimension(); - int meshDim=getMeshDimension(); - mcIdType nbOfCells=getNumberOfCells(); + int const spaceDim=getSpaceDimension(); + int const meshDim=getMeshDimension(); + mcIdType const nbOfCells=getNumberOfCells(); ret->alloc(nbOfCells,spaceDim); ret->copyStringInfoFrom(*getCoords()); switch(meshDim) @@ -746,19 +758,19 @@ DataArrayDouble *MEDCouplingCurveLinearMesh::computeIsoBarycenterOfNodesPerCell( */ void MEDCouplingCurveLinearMesh::getBarycenterAndOwnerMeshDim3(DataArrayDouble *bary) const { - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbOfCells=getNumberOfCells(); double *ptToFill=bary->getPointer(); const double *coor=_coords->getConstPointer(); if(getSpaceDimension()!=3) throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::getBarycenterAndOwnerMeshDim3 : with meshDim 3 only space dimension 3 is possible !"); mcIdType nX=_structure[0]-1,nY=(_structure[0]-1)*(_structure[1]-1); - mcIdType nY1=_structure[0]*_structure[1]; + mcIdType const nY1=_structure[0]*_structure[1]; mcIdType conn[8]; for(mcIdType i=0;i(INTERP_KERNEL::NORM_HEXA8,conn,8,coor,3,ptToFill); @@ -772,13 +784,13 @@ void MEDCouplingCurveLinearMesh::getBarycenterAndOwnerMeshDim3(DataArrayDouble * */ void MEDCouplingCurveLinearMesh::getBarycenterAndOwnerMeshDim2(DataArrayDouble *bary) const { - mcIdType nbcells=getNumberOfCells(); - int spaceDim=getSpaceDimension(); + mcIdType const nbcells=getNumberOfCells(); + int const spaceDim=getSpaceDimension(); double *ptToFill=bary->getPointer(); const double *coor=_coords->getConstPointer(); if(spaceDim!=2 && spaceDim!=3) throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::getBarycenterAndOwnerMeshDim2 : with meshDim 2 only space dimension 2 and 3 are possible !"); - mcIdType nX=_structure[0]-1; + mcIdType const nX=_structure[0]-1; mcIdType conn[4]; for(mcIdType i=0;ibegin()+spaceDim,_coords->end(),_coords->begin(),bary->getPointer(),std::plus()); std::transform(bary->begin(),bary->end(),bary->getPointer(),std::bind(std::multiplies(),std::placeholders::_1,0.5)); } -void MEDCouplingCurveLinearMesh::renumberCells(const mcIdType *old2NewBg, bool check) +void MEDCouplingCurveLinearMesh::renumberCells(const mcIdType * /*old2NewBg*/, bool /*check*/) { throw INTERP_KERNEL::Exception("Functionality of renumbering cell not available for CurveLinear Mesh !"); } @@ -858,7 +870,7 @@ void MEDCouplingCurveLinearMesh::serialize(DataArrayIdType *&a1, DataArrayDouble std::copy(_coords->begin(),_coords->end(),a2->getPointer()); } -void MEDCouplingCurveLinearMesh::unserialization(const std::vector& tinyInfoD, const std::vector& tinyInfo, const DataArrayIdType *a1, DataArrayDouble *a2, +void MEDCouplingCurveLinearMesh::unserialization(const std::vector& tinyInfoD, const std::vector& tinyInfo, const DataArrayIdType * /*a1*/, DataArrayDouble *a2, const std::vector& littleStrings) { setName(littleStrings[0]); @@ -883,11 +895,11 @@ void MEDCouplingCurveLinearMesh::unserialization(const std::vector& tiny void MEDCouplingCurveLinearMesh::writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData, DataArrayByte *byteData) const { std::ostringstream extent; - std::size_t meshDim=_structure.size(); + std::size_t const meshDim=_structure.size(); if(meshDim==0 || meshDim>3) throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::writeVTKLL : meshDim invalid ! must be in [1,2,3] !"); for(std::size_t i=0;i<3;i++) - { mcIdType val=i\n"; ofs << " \n"; ofs << " \n" << pointData << std::endl; @@ -911,10 +923,10 @@ void MEDCouplingCurveLinearMesh::reprQuickOverview(std::ostream& stream) const { stream << "MEDCouplingCurveLinearMesh C++ instance at " << this << ". Name : \"" << getName() << "\"."; stream << " Nodal structure : ["; - std::size_t s_size=_structure.size(); + std::size_t const s_size=_structure.size(); for(std::size_t i=0;iisAllocated()) { stream << std::endl << "Coordinates set but not allocated !"; return ; } - std::size_t nbOfCompo(coo->getNumberOfComponents()); + std::size_t const nbOfCompo(coo->getNumberOfComponents()); std::size_t nbOfCompoExp(-1); try { diff --git a/src/MEDCoupling/MEDCouplingCurveLinearMesh.hxx b/src/MEDCoupling/MEDCouplingCurveLinearMesh.hxx index a987ac611..fbac8ac5a 100644 --- a/src/MEDCoupling/MEDCouplingCurveLinearMesh.hxx +++ b/src/MEDCoupling/MEDCouplingCurveLinearMesh.hxx @@ -21,9 +21,17 @@ #ifndef __PARAMEDMEM_MEDCOUPLINGCURVELINEARMESH_HXX__ #define __PARAMEDMEM_MEDCOUPLINGCURVELINEARMESH_HXX__ +#include "MCType.hxx" #include "MEDCoupling.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include "MEDCouplingMesh.hxx" #include "MEDCouplingStructuredMesh.hxx" #include "MCAuto.hxx" +#include +#include +#include +#include +#include namespace MEDCoupling { @@ -33,59 +41,59 @@ namespace MEDCoupling MEDCOUPLING_EXPORT static MEDCouplingCurveLinearMesh *New(); MEDCOUPLING_EXPORT static MEDCouplingCurveLinearMesh *New(const std::string& meshName); MEDCOUPLING_EXPORT std::string getClassName() const override { return std::string("MEDCouplingCurveLinearMesh"); } - MEDCOUPLING_EXPORT MEDCouplingCurveLinearMesh *deepCopy() const; - MEDCOUPLING_EXPORT MEDCouplingCurveLinearMesh *clone(bool recDeepCpy) const; - MEDCOUPLING_EXPORT void updateTime() const; - MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; - MEDCOUPLING_EXPORT std::vector getDirectChildrenWithNull() const; - MEDCOUPLING_EXPORT MEDCouplingMeshType getType() const { return CURVE_LINEAR; } - MEDCOUPLING_EXPORT void copyTinyStringsFrom(const MEDCouplingMesh *other); - MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const; - MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const; + MEDCOUPLING_EXPORT MEDCouplingCurveLinearMesh *deepCopy() const override; + MEDCOUPLING_EXPORT MEDCouplingCurveLinearMesh *clone(bool recDeepCpy) const override; + MEDCOUPLING_EXPORT void updateTime() const override; + MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const override; + MEDCOUPLING_EXPORT std::vector getDirectChildrenWithNull() const override; + MEDCOUPLING_EXPORT MEDCouplingMeshType getType() const override { return CURVE_LINEAR; } + MEDCOUPLING_EXPORT void copyTinyStringsFrom(const MEDCouplingMesh *other) override; + MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const override; + MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const override; MEDCOUPLING_EXPORT void checkDeepEquivalWith(const MEDCouplingMesh *other, int cellCompPol, double prec, - DataArrayIdType *&cellCor, DataArrayIdType *&nodeCor) const; + DataArrayIdType *&cellCor, DataArrayIdType *&nodeCor) const override; MEDCOUPLING_EXPORT void checkDeepEquivalOnSameNodesWith(const MEDCouplingMesh *other, int cellCompPol, double prec, - DataArrayIdType *&cellCor) const; - MEDCOUPLING_EXPORT void checkConsistencyLight() const; - MEDCOUPLING_EXPORT void checkConsistency(double eps=1e-12) const; - MEDCOUPLING_EXPORT mcIdType getNumberOfCells() const; - MEDCOUPLING_EXPORT mcIdType getNumberOfNodes() const; - MEDCOUPLING_EXPORT int getSpaceDimension() const; - MEDCOUPLING_EXPORT void getCoordinatesOfNode(mcIdType nodeId, std::vector& coo) const; - MEDCOUPLING_EXPORT std::string simpleRepr() const; - MEDCOUPLING_EXPORT std::string advancedRepr() const; - MEDCOUPLING_EXPORT const DataArrayDouble *getDirectAccessOfCoordsArrIfInStructure() const; + DataArrayIdType *&cellCor) const override; + MEDCOUPLING_EXPORT void checkConsistencyLight() const override; + MEDCOUPLING_EXPORT void checkConsistency(double eps=1e-12) const override; + MEDCOUPLING_EXPORT mcIdType getNumberOfCells() const override; + MEDCOUPLING_EXPORT mcIdType getNumberOfNodes() const override; + MEDCOUPLING_EXPORT int getSpaceDimension() const override; + MEDCOUPLING_EXPORT void getCoordinatesOfNode(mcIdType nodeId, std::vector& coo) const override; + MEDCOUPLING_EXPORT std::string simpleRepr() const override; + MEDCOUPLING_EXPORT std::string advancedRepr() const override; + MEDCOUPLING_EXPORT const DataArrayDouble *getDirectAccessOfCoordsArrIfInStructure() const override; MEDCOUPLING_EXPORT DataArrayDouble *getCoords(); MEDCOUPLING_EXPORT const DataArrayDouble *getCoords() const; MEDCOUPLING_EXPORT void setCoords(const DataArrayDouble *coords); MEDCOUPLING_EXPORT void setNodeGridStructure(const mcIdType *gridStructBg, const mcIdType *gridStructEnd); - MEDCOUPLING_EXPORT std::vector getNodeGridStructure() const; - MEDCOUPLING_EXPORT MEDCouplingStructuredMesh *buildStructuredSubPart(const std::vector< std::pair >& cellPart) const; + MEDCOUPLING_EXPORT std::vector getNodeGridStructure() const override; + MEDCOUPLING_EXPORT MEDCouplingStructuredMesh *buildStructuredSubPart(const std::vector< std::pair >& cellPart) const override; // tools - MEDCOUPLING_EXPORT void getBoundingBox(double *bbox) const; - MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureField(bool isAbs) const; - MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureFieldOnNode(bool isAbs) const; - MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildOrthogonalField() const; - MEDCOUPLING_EXPORT mcIdType getCellContainingPoint(const double *pos, double eps) const; - MEDCOUPLING_EXPORT void getCellsContainingPoint(const double *pos, double eps, std::vector& elts) const; - MEDCOUPLING_EXPORT void rotate(const double *center, const double *vector, double angle); - MEDCOUPLING_EXPORT void translate(const double *vector); - MEDCOUPLING_EXPORT void scale(const double *point, double factor); - MEDCOUPLING_EXPORT MEDCouplingMesh *mergeMyselfWith(const MEDCouplingMesh *other) const; - MEDCOUPLING_EXPORT DataArrayDouble *getCoordinatesAndOwner() const; - MEDCOUPLING_EXPORT DataArrayDouble *computeCellCenterOfMass() const; - MEDCOUPLING_EXPORT DataArrayDouble *computeIsoBarycenterOfNodesPerCell() const; - MEDCOUPLING_EXPORT void renumberCells(const mcIdType *old2NewBg, bool check=true); + MEDCOUPLING_EXPORT void getBoundingBox(double *bbox) const override; + MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureField(bool isAbs) const override; + MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureFieldOnNode(bool isAbs) const override; + MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildOrthogonalField() const override; + MEDCOUPLING_EXPORT mcIdType getCellContainingPoint(const double *pos, double eps) const override; + MEDCOUPLING_EXPORT void getCellsContainingPoint(const double *pos, double eps, std::vector& elts) const override; + MEDCOUPLING_EXPORT void rotate(const double *center, const double *vector, double angle) override; + MEDCOUPLING_EXPORT void translate(const double *vector) override; + MEDCOUPLING_EXPORT void scale(const double *point, double factor) override; + MEDCOUPLING_EXPORT MEDCouplingMesh *mergeMyselfWith(const MEDCouplingMesh *other) const override; + MEDCOUPLING_EXPORT DataArrayDouble *getCoordinatesAndOwner() const override; + MEDCOUPLING_EXPORT DataArrayDouble *computeCellCenterOfMass() const override; + MEDCOUPLING_EXPORT DataArrayDouble *computeIsoBarycenterOfNodesPerCell() const override; + MEDCOUPLING_EXPORT void renumberCells(const mcIdType *old2NewBg, bool check=true) override; //some useful methods - MEDCOUPLING_EXPORT void getNodeGridStructure(mcIdType *res) const; + MEDCOUPLING_EXPORT void getNodeGridStructure(mcIdType *res) const override; //serialisation-unserialization - MEDCOUPLING_EXPORT void getTinySerializationInformation(std::vector& tinyInfoD, std::vector& tinyInfo, std::vector& littleStrings) const; - MEDCOUPLING_EXPORT void resizeForUnserialization(const std::vector& tinyInfo, DataArrayIdType *a1, DataArrayDouble *a2, std::vector& littleStrings) const; - MEDCOUPLING_EXPORT void serialize(DataArrayIdType *&a1, DataArrayDouble *&a2) const; + MEDCOUPLING_EXPORT void getTinySerializationInformation(std::vector& tinyInfoD, std::vector& tinyInfo, std::vector& littleStrings) const override; + MEDCOUPLING_EXPORT void resizeForUnserialization(const std::vector& tinyInfo, DataArrayIdType *a1, DataArrayDouble *a2, std::vector& littleStrings) const override; + MEDCOUPLING_EXPORT void serialize(DataArrayIdType *&a1, DataArrayDouble *&a2) const override; MEDCOUPLING_EXPORT void unserialization(const std::vector& tinyInfoD, const std::vector& tinyInfo, const DataArrayIdType *a1, DataArrayDouble *a2, - const std::vector& littleStrings); - MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const; - MEDCOUPLING_EXPORT std::string getVTKFileExtension() const; + const std::vector& littleStrings) override; + MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const override; + MEDCOUPLING_EXPORT std::string getVTKFileExtension() const override; private: void getMeasureFieldMeshDim1(bool isAbs, MEDCouplingFieldDouble *field) const; void getMeasureFieldMeshDim2(bool isAbs, MEDCouplingFieldDouble *field) const; @@ -96,9 +104,9 @@ namespace MEDCoupling private: MEDCouplingCurveLinearMesh(); MEDCouplingCurveLinearMesh(const MEDCouplingCurveLinearMesh& other, bool deepCpy); - ~MEDCouplingCurveLinearMesh(); - void writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData, DataArrayByte *byteData) const; - std::string getVTKDataSetType() const; + ~MEDCouplingCurveLinearMesh() override; + void writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData, DataArrayByte *byteData) const override; + std::string getVTKDataSetType() const override; private: MCAuto _coords; std::vector _structure; diff --git a/src/MEDCoupling/MEDCouplingDefinitionTime.cxx b/src/MEDCoupling/MEDCouplingDefinitionTime.cxx index be3a764fe..0011aaca2 100644 --- a/src/MEDCoupling/MEDCouplingDefinitionTime.cxx +++ b/src/MEDCoupling/MEDCouplingDefinitionTime.cxx @@ -19,9 +19,15 @@ // Author : Anthony Geay (CEA/DEN) #include "MEDCouplingDefinitionTime.hxx" +#include "MCIdType.hxx" +#include "MCAuto.hxx" #include "MEDCouplingFieldDouble.hxx" +#include "MEDCouplingRefCountObject.hxx" #include +#include +#include +#include using namespace MEDCoupling; @@ -74,7 +80,7 @@ MEDCouplingDefinitionTimeSlice *MEDCouplingDefinitionTimeSlice::New(TypeOfTimeDi } } -bool MEDCouplingDefinitionTimeSlice::isEqual(const MEDCouplingDefinitionTimeSlice& other, double eps) const +bool MEDCouplingDefinitionTimeSlice::isEqual(const MEDCouplingDefinitionTimeSlice& other, double /*eps*/) const { if(_mesh_id!=other._mesh_id) return false; @@ -103,8 +109,8 @@ void MEDCouplingDefinitionTimeSlice::appendRepr(std::ostream& stream) const MEDCouplingDefinitionTimeSlice::MEDCouplingDefinitionTimeSlice(const MEDCouplingFieldDouble *f, int meshId, int arrId, int fieldId):_mesh_id(meshId),_array_id(arrId),_field_id(fieldId) { int tmp1,tmp2; - double t1=f->getStartTime(tmp1,tmp2); - double t2=f->getEndTime(tmp1,tmp2); + double const t1=f->getStartTime(tmp1,tmp2); + double const t2=f->getEndTime(tmp1,tmp2); if(t2 MEDCouplingDefinitionTimeSlice::getDirectCh bool MEDCouplingDefinitionTimeSlice::isFullyIncludedInMe(const MEDCouplingDefinitionTimeSlice *other, double eps) const { - double t1=getStartTime(); - double t2=getEndTime(); - double o1=other->getStartTime(); - double o2=other->getEndTime(); + double const t1=getStartTime(); + double const t2=getEndTime(); + double const o1=other->getStartTime(); + double const o2=other->getEndTime(); return o1>t1-eps && o2getStartTime(); - double o2=other->getEndTime(); + double const t1=getStartTime(); + double const t2=getEndTime(); + double const o1=other->getStartTime(); + double const o2=other->getEndTime(); return (o1t2-eps && o2>t2-eps); } bool MEDCouplingDefinitionTimeSlice::isAfterMe(const MEDCouplingDefinitionTimeSlice *other, double eps) const { - double t2=getEndTime(); - double o1=other->getStartTime(); - double o2=other->getEndTime(); + double const t2=getEndTime(); + double const o1=other->getStartTime(); + double const o2=other->getEndTime(); return (o1>t2-eps && o2>t2-eps); } bool MEDCouplingDefinitionTimeSlice::isBeforeMe(const MEDCouplingDefinitionTimeSlice *other, double eps) const { - double t1=getStartTime(); - double o1=other->getStartTime(); - double o2=other->getEndTime(); + double const t1=getStartTime(); + double const o1=other->getStartTime(); + double const o2=other->getEndTime(); return (o1& tiI, const std::vector& tiD) { - MEDCouplingDefinitionTimeSliceInst *ret=new MEDCouplingDefinitionTimeSliceInst; + auto *ret=new MEDCouplingDefinitionTimeSliceInst; ret->unserialize(tiI,tiD); return ret; } @@ -188,7 +194,7 @@ bool MEDCouplingDefinitionTimeSliceInst::isEqual(const MEDCouplingDefinitionTime { if(!MEDCouplingDefinitionTimeSlice::isEqual(other,eps)) return false; - const MEDCouplingDefinitionTimeSliceInst *otherC=dynamic_cast(&other); + const auto *otherC=dynamic_cast(&other); if(!otherC) return false; return fabs(otherC->_instant-_instant)& re ret[0]=_instant; } -void MEDCouplingDefinitionTimeSliceInst::getIdsOnTime(double tm, double eps, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const +void MEDCouplingDefinitionTimeSliceInst::getIdsOnTime(double /*tm*/, double /*eps*/, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const { meshId=_mesh_id; arrId=_array_id; @@ -232,9 +238,9 @@ double MEDCouplingDefinitionTimeSliceInst::getEndTime() const MEDCouplingDefinitionTimeSliceInst::MEDCouplingDefinitionTimeSliceInst(const MEDCouplingFieldDouble *f, int meshId, int arrId, int fieldId):MEDCouplingDefinitionTimeSlice(f,meshId,arrId,fieldId) { int tmp1,tmp2; - double t1=f->getStartTime(tmp1,tmp2); - double t2=f->getEndTime(tmp1,tmp2); - double eps=f->getTimeTolerance(); + double const t1=f->getStartTime(tmp1,tmp2); + double const t2=f->getEndTime(tmp1,tmp2); + double const eps=f->getTimeTolerance(); if(fabs(t1-t2)>eps) throw INTERP_KERNEL::Exception("MEDCouplingDefinitionTimeSliceInst : times differs in this"); _instant=t1; @@ -242,7 +248,7 @@ MEDCouplingDefinitionTimeSliceInst::MEDCouplingDefinitionTimeSliceInst(const MED MEDCouplingDefinitionTimeSliceCstOnTI *MEDCouplingDefinitionTimeSliceCstOnTI::New(const std::vector& tiI, const std::vector& tiD) { - MEDCouplingDefinitionTimeSliceCstOnTI *ret=new MEDCouplingDefinitionTimeSliceCstOnTI; + auto *ret=new MEDCouplingDefinitionTimeSliceCstOnTI; ret->unserialize(tiI,tiD); return ret; } @@ -256,7 +262,7 @@ bool MEDCouplingDefinitionTimeSliceCstOnTI::isEqual(const MEDCouplingDefinitionT { if(!MEDCouplingDefinitionTimeSlice::isEqual(other,eps)) return false; - const MEDCouplingDefinitionTimeSliceCstOnTI *otherC=dynamic_cast(&other); + const auto *otherC=dynamic_cast(&other); if(!otherC) return false; if(fabs(otherC->_start-_start)>eps) @@ -270,7 +276,7 @@ void MEDCouplingDefinitionTimeSliceCstOnTI::getHotSpotsTime(std::vector& ret[0]=(_start+_end)/2.; } -void MEDCouplingDefinitionTimeSliceCstOnTI::getIdsOnTime(double tm, double eps, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const +void MEDCouplingDefinitionTimeSliceCstOnTI::getIdsOnTime(double /*tm*/, double /*eps*/, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const { meshId=_mesh_id; arrId=_array_id; @@ -321,15 +327,15 @@ TypeOfTimeDiscretization MEDCouplingDefinitionTimeSliceCstOnTI::getTimeType() co MEDCouplingDefinitionTimeSliceCstOnTI::MEDCouplingDefinitionTimeSliceCstOnTI(const MEDCouplingFieldDouble *f, int meshId, int arrId, int fieldId):MEDCouplingDefinitionTimeSlice(f,meshId,arrId,fieldId) { int tmp1,tmp2; - double t1=f->getStartTime(tmp1,tmp2); - double t2=f->getEndTime(tmp1,tmp2); + double const t1=f->getStartTime(tmp1,tmp2); + double const t2=f->getEndTime(tmp1,tmp2); _start=t1; _end=t2; } MEDCouplingDefinitionTimeSliceLT *MEDCouplingDefinitionTimeSliceLT::New(const std::vector& tiI, const std::vector& tiD) { - MEDCouplingDefinitionTimeSliceLT *ret=new MEDCouplingDefinitionTimeSliceLT; + auto *ret=new MEDCouplingDefinitionTimeSliceLT; ret->unserialize(tiI,tiD); return ret; } @@ -343,7 +349,7 @@ bool MEDCouplingDefinitionTimeSliceLT::isEqual(const MEDCouplingDefinitionTimeSl { if(!MEDCouplingDefinitionTimeSlice::isEqual(other,eps)) return false; - const MEDCouplingDefinitionTimeSliceLT *otherC=dynamic_cast(&other); + const auto *otherC=dynamic_cast(&other); if(!otherC) return false; if(_array_id_end!=otherC->_array_id_end) @@ -430,8 +436,8 @@ TypeOfTimeDiscretization MEDCouplingDefinitionTimeSliceLT::getTimeType() const MEDCouplingDefinitionTimeSliceLT::MEDCouplingDefinitionTimeSliceLT(const MEDCouplingFieldDouble *f, int meshId, int arrId, int arr2Id, int fieldId):MEDCouplingDefinitionTimeSlice(f,meshId,arrId,fieldId),_array_id_end(arr2Id) { int tmp1,tmp2; - double t1=f->getStartTime(tmp1,tmp2); - double t2=f->getEndTime(tmp1,tmp2); + double const t1=f->getStartTime(tmp1,tmp2); + double const t2=f->getEndTime(tmp1,tmp2); _start=t1; _end=t2; } @@ -442,7 +448,7 @@ MEDCouplingDefinitionTime::MEDCouplingDefinitionTime():_eps(EPS_DFT) MEDCouplingDefinitionTime::MEDCouplingDefinitionTime(const std::vector& fs, const std::vector& meshRefs, const std::vector >& arrRefs) { - std::size_t sz=fs.size(); + std::size_t const sz=fs.size(); if(sz!=arrRefs.size()) throw INTERP_KERNEL::Exception("MEDCouplingDefinitionTime constructor : internal error ! should never happen !"); _slices.resize(sz); @@ -481,7 +487,7 @@ std::vector MEDCouplingDefinitionTime::getDirectChildre void MEDCouplingDefinitionTime::assign(const MEDCouplingDefinitionTime& other) { - std::size_t sz=other._slices.size(); + std::size_t const sz=other._slices.size(); _slices.resize(sz); for(std::size_t i=0;icopy(); @@ -489,7 +495,7 @@ void MEDCouplingDefinitionTime::assign(const MEDCouplingDefinitionTime& other) bool MEDCouplingDefinitionTime::isEqual(const MEDCouplingDefinitionTime& other) const { - std::size_t sz=_slices.size(); + std::size_t const sz=_slices.size(); if(sz!=other._slices.size()) return false; for(std::size_t i=0;i& meshId { std::vector ids; int id=0; - for(std::vector< MCAuto >::const_iterator it=_slices.begin();it!=_slices.end();it++,id++) + for(auto it=_slices.begin();it!=_slices.end();it++,id++) if((*it)->isContaining(tm,_eps)) ids.push_back(id); if(ids.empty()) throw INTERP_KERNEL::Exception("MEDCouplingDefinitionTime::getIdsOnTime : No matching slice for such time !"); - std::size_t sz=ids.size(); + std::size_t const sz=ids.size(); if(sz>2) throw INTERP_KERNEL::Exception("MEDCouplingDefinitionTime::getIdsOnTime : Too many slices match this time !"); // @@ -548,10 +554,10 @@ void MEDCouplingDefinitionTime::getIdsOnTime(double tm, std::vector& meshId std::vector MEDCouplingDefinitionTime::getHotSpotsTime() const { std::vector ret; - for(std::vector< MCAuto >::const_iterator it=_slices.begin();it!=_slices.end();it++) + for(const auto & _slice : _slices) { std::vector tmp; - (*it)->getHotSpotsTime(tmp); + _slice->getHotSpotsTime(tmp); if(!ret.empty()) { if(fabs(ret.back()-tmp.front())>_eps) @@ -568,17 +574,17 @@ std::vector MEDCouplingDefinitionTime::getHotSpotsTime() const void MEDCouplingDefinitionTime::appendRepr(std::ostream& stream) const { stream << "Time definition :\n"; - for(std::vector< MCAuto >::const_iterator it=_slices.begin();it!=_slices.end();it++) + for(const auto & _slice : _slices) { stream << " - "; - (*it)->appendRepr(stream); + _slice->appendRepr(stream); stream << std::endl; } } void MEDCouplingDefinitionTime::getTinySerializationInformation(std::vector& tinyInfoI, std::vector& tinyInfoD) const { - int sz=(int)_slices.size(); + int const sz=(int)_slices.size(); tinyInfoD.resize(1); tinyInfoD[0]=_eps; tinyInfoI.resize(3*sz+2); @@ -601,18 +607,18 @@ void MEDCouplingDefinitionTime::getTinySerializationInformation(std::vector void MEDCouplingDefinitionTime::unserialize(const std::vector& tinyInfoI, const std::vector& tinyInfoD) { - int sz=tinyInfoI[0]; + int const sz=tinyInfoI[0]; _slices.resize(sz); _eps=tinyInfoD[0]; int offset1=0; int offset2=1; for(int i=0;i tmp1(tinyInfoI.begin()+3*sz+2+offset1,tinyInfoI.begin()+3*sz+2+offset1+sz1); - std::vector tmp2(tinyInfoD.begin()+offset2,tinyInfoD.begin()+offset2+sz2); + auto const ty=(TypeOfTimeDiscretization) tinyInfoI[i+2]; + int const sz1=tinyInfoI[i+sz+2]; + int const sz2=tinyInfoI[i+2*sz+2]; + std::vector const tmp1(tinyInfoI.begin()+3*sz+2+offset1,tinyInfoI.begin()+3*sz+2+offset1+sz1); + std::vector const tmp2(tinyInfoD.begin()+offset2,tinyInfoD.begin()+offset2+sz2); MEDCouplingDefinitionTimeSlice *pt=MEDCouplingDefinitionTimeSlice::New(ty,tmp1,tmp2); _slices[i]=pt; offset1+=sz1; diff --git a/src/MEDCoupling/MEDCouplingDefinitionTime.hxx b/src/MEDCoupling/MEDCouplingDefinitionTime.hxx index 4ef21dd7c..2c757ae6f 100644 --- a/src/MEDCoupling/MEDCouplingDefinitionTime.hxx +++ b/src/MEDCoupling/MEDCouplingDefinitionTime.hxx @@ -21,13 +21,15 @@ #ifndef __PARAMEDMEM_MEDCOUPLINGDEFINITIONTIME_HXX__ #define __PARAMEDMEM_MEDCOUPLINGDEFINITIONTIME_HXX__ +#include "MEDCoupling.hxx" #include "MEDCouplingRefCountObject.hxx" #include "MCAuto.hxx" -#include "InterpKernelException.hxx" +#include +#include +#include #include -#include namespace MEDCoupling { @@ -51,8 +53,8 @@ namespace MEDCoupling MEDCOUPLING_EXPORT virtual double getEndTime() const = 0; MEDCOUPLING_EXPORT virtual void getTinySerializationInformation(std::vector& tiI, std::vector& tiD) const = 0; MEDCOUPLING_EXPORT virtual TypeOfTimeDiscretization getTimeType() const = 0; - MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; - MEDCOUPLING_EXPORT std::vector getDirectChildrenWithNull() const; + MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const override; + MEDCOUPLING_EXPORT std::vector getDirectChildrenWithNull() const override; MEDCOUPLING_EXPORT bool isFullyIncludedInMe(const MEDCouplingDefinitionTimeSlice *other, double eps) const; MEDCOUPLING_EXPORT bool isOverllapingWithMe(const MEDCouplingDefinitionTimeSlice *other, double eps) const; MEDCOUPLING_EXPORT bool isAfterMe(const MEDCouplingDefinitionTimeSlice *other, double eps) const; @@ -71,17 +73,17 @@ namespace MEDCoupling public: static MEDCouplingDefinitionTimeSliceInst *New(const std::vector& tiI, const std::vector& tiD); MEDCOUPLING_EXPORT std::string getClassName() const override { return std::string("MEDCouplingDefinitionTimeSliceInst"); } - MEDCouplingDefinitionTimeSlice *copy() const; - bool isEqual(const MEDCouplingDefinitionTimeSlice& other, double eps) const; - void getHotSpotsTime(std::vector& ret) const; - void getIdsOnTime(double tm, double eps, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const; - bool isContaining(double tmp, double eps) const; - void appendRepr(std::ostream& stream) const; - double getStartTime() const; - double getEndTime() const; - void getTinySerializationInformation(std::vector& tiI, std::vector& tiD) const; + MEDCouplingDefinitionTimeSlice *copy() const override; + bool isEqual(const MEDCouplingDefinitionTimeSlice& other, double eps) const override; + void getHotSpotsTime(std::vector& ret) const override; + void getIdsOnTime(double tm, double eps, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const override; + bool isContaining(double tmp, double eps) const override; + void appendRepr(std::ostream& stream) const override; + double getStartTime() const override; + double getEndTime() const override; + void getTinySerializationInformation(std::vector& tiI, std::vector& tiD) const override; void unserialize(const std::vector& tiI, const std::vector& tiD); - TypeOfTimeDiscretization getTimeType() const; + TypeOfTimeDiscretization getTimeType() const override; public: MEDCouplingDefinitionTimeSliceInst(const MEDCouplingFieldDouble *f, int meshId, int arrId, int fieldId); protected: @@ -95,17 +97,17 @@ namespace MEDCoupling public: static MEDCouplingDefinitionTimeSliceCstOnTI *New(const std::vector& tiI, const std::vector& tiD); MEDCOUPLING_EXPORT std::string getClassName() const override { return std::string("MEDCouplingDefinitionTimeSliceCstOnTI"); } - MEDCouplingDefinitionTimeSlice *copy() const; - bool isEqual(const MEDCouplingDefinitionTimeSlice& other, double eps) const; - void getHotSpotsTime(std::vector& ret) const; - void getIdsOnTime(double tm, double eps, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const; - bool isContaining(double tmp, double eps) const; - void appendRepr(std::ostream& stream) const; - double getStartTime() const; - double getEndTime() const; - void getTinySerializationInformation(std::vector& tiI, std::vector& tiD) const; + MEDCouplingDefinitionTimeSlice *copy() const override; + bool isEqual(const MEDCouplingDefinitionTimeSlice& other, double eps) const override; + void getHotSpotsTime(std::vector& ret) const override; + void getIdsOnTime(double tm, double eps, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const override; + bool isContaining(double tmp, double eps) const override; + void appendRepr(std::ostream& stream) const override; + double getStartTime() const override; + double getEndTime() const override; + void getTinySerializationInformation(std::vector& tiI, std::vector& tiD) const override; void unserialize(const std::vector& tiI, const std::vector& tiD); - TypeOfTimeDiscretization getTimeType() const; + TypeOfTimeDiscretization getTimeType() const override; public: MEDCouplingDefinitionTimeSliceCstOnTI(const MEDCouplingFieldDouble *f, int meshId, int arrId, int fieldId); protected: @@ -120,18 +122,18 @@ namespace MEDCoupling public: static MEDCouplingDefinitionTimeSliceLT *New(const std::vector& tiI, const std::vector& tiD); std::string getClassName() const override { return std::string("MEDCouplingDefinitionTimeSliceLT"); } - MEDCouplingDefinitionTimeSlice *copy() const; - bool isEqual(const MEDCouplingDefinitionTimeSlice& other, double eps) const; - void getHotSpotsTime(std::vector& ret) const; - void getIdsOnTime(double tm, double eps, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const; - bool isContaining(double tmp, double eps) const; - void appendRepr(std::ostream& stream) const; - double getStartTime() const; - double getEndTime() const; - int getEndId() const; - void getTinySerializationInformation(std::vector& tiI, std::vector& tiD) const; + MEDCouplingDefinitionTimeSlice *copy() const override; + bool isEqual(const MEDCouplingDefinitionTimeSlice& other, double eps) const override; + void getHotSpotsTime(std::vector& ret) const override; + void getIdsOnTime(double tm, double eps, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const override; + bool isContaining(double tmp, double eps) const override; + void appendRepr(std::ostream& stream) const override; + double getStartTime() const override; + double getEndTime() const override; + int getEndId() const override; + void getTinySerializationInformation(std::vector& tiI, std::vector& tiD) const override; void unserialize(const std::vector& tiI, const std::vector& tiD); - TypeOfTimeDiscretization getTimeType() const; + TypeOfTimeDiscretization getTimeType() const override; public: MEDCouplingDefinitionTimeSliceLT(const MEDCouplingFieldDouble *f, int meshId, int arrId, int arr2Id, int fieldId); protected: diff --git a/src/MEDCoupling/MEDCouplingField.cxx b/src/MEDCoupling/MEDCouplingField.cxx index 4ecfc5419..8dd250117 100644 --- a/src/MEDCoupling/MEDCouplingField.cxx +++ b/src/MEDCoupling/MEDCouplingField.cxx @@ -19,10 +19,20 @@ // Author : Anthony Geay (CEA/DEN) #include "MEDCouplingField.hxx" +#include "MCType.hxx" +#include "MCIdType.hxx" #include "MEDCouplingMesh.hxx" #include "MEDCouplingFieldDiscretization.hxx" +#include "MEDCouplingNatureOfField.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include "MEDCouplingNatureOfFieldEnum" +#include "NormalizedGeometricTypes" +#include +#include #include +#include +#include using namespace MEDCoupling; @@ -62,16 +72,16 @@ bool MEDCouplingField::isEqualIfNotWhyProtected(const MEDCouplingField *other, d reason.insert(0,"Spatial discretizations differ :"); return false; } - if(_mesh==0 && other->_mesh==0) + if(_mesh==nullptr && other->_mesh==nullptr) return true; - if(_mesh==0 || other->_mesh==0) + if(_mesh==nullptr || other->_mesh==nullptr) { reason="Only one field between the two this and other has its underlying mesh defined !"; return false; } if(_mesh==other->_mesh) return true; - bool ret=_mesh->isEqualIfNotWhy(other->_mesh,meshPrec,reason); + bool const ret=_mesh->isEqualIfNotWhy(other->_mesh,meshPrec,reason); if(!ret) reason.insert(0,"Underlying meshes of fields differ for the following reason : "); return ret; @@ -96,9 +106,9 @@ bool MEDCouplingField::isEqualWithoutConsideringStrProtected(const MEDCouplingFi return false; if(_nature!=other->_nature) return false; - if(_mesh==0 && other->_mesh==0) + if(_mesh==nullptr && other->_mesh==nullptr) return true; - if(_mesh==0 || other->_mesh==0) + if(_mesh==nullptr || other->_mesh==nullptr) return false; if(_mesh==other->_mesh) return true; @@ -476,16 +486,16 @@ MEDCouplingField::~MEDCouplingField() _mesh->decrRef(); } -MEDCouplingField::MEDCouplingField(MEDCouplingFieldDiscretization *type, NatureOfField nature):_nature(nature),_mesh(0),_type(type) +MEDCouplingField::MEDCouplingField(MEDCouplingFieldDiscretization *type, NatureOfField nature):_nature(nature),_mesh(nullptr),_type(type) { } -MEDCouplingField::MEDCouplingField(TypeOfField type):_nature(NoNature),_mesh(0),_type(MEDCouplingFieldDiscretization::New(type)) +MEDCouplingField::MEDCouplingField(TypeOfField type):_nature(NoNature),_mesh(nullptr),_type(MEDCouplingFieldDiscretization::New(type)) { } MEDCouplingField::MEDCouplingField(const MEDCouplingField& other, bool deepCopy):RefCountObject(other),_name(other._name),_desc(other._desc),_nature(other._nature), - _mesh(0),_type(0) + _mesh(nullptr),_type(nullptr) { if(other._mesh) { @@ -569,7 +579,7 @@ mcIdType MEDCouplingField::getNumberOfTuplesExpected() const void MEDCouplingField::setDiscretization(MEDCouplingFieldDiscretization *newDisc) { - bool needUpdate=(const MEDCouplingFieldDiscretization *)_type!=newDisc; + bool const needUpdate=(const MEDCouplingFieldDiscretization *)_type!=newDisc; _type=newDisc; if(newDisc) newDisc->incrRef(); diff --git a/src/MEDCoupling/MEDCouplingField.hxx b/src/MEDCoupling/MEDCouplingField.hxx index 0b1539af5..948ac7934 100644 --- a/src/MEDCoupling/MEDCouplingField.hxx +++ b/src/MEDCoupling/MEDCouplingField.hxx @@ -21,15 +21,18 @@ #ifndef __PARAMEDMEM_MEDCOUPLINGFIELD_HXX__ #define __PARAMEDMEM_MEDCOUPLINGFIELD_HXX__ +#include "MCType.hxx" #include "MEDCoupling.hxx" +#include "MEDCouplingNatureOfFieldEnum" #include "MEDCouplingTimeLabel.hxx" -#include "MEDCouplingNatureOfField.hxx" #include "MEDCouplingRefCountObject.hxx" -#include "NormalizedUnstructuredMesh.hxx" #include "MCAuto.hxx" #include "MEDCouplingFieldDiscretization.hxx" -#include "InterpKernelException.hxx" +#include "NormalizedGeometricTypes" +#include +#include +#include #include #include @@ -82,9 +85,9 @@ namespace MEDCoupling MEDCOUPLING_EXPORT mcIdType getGaussLocalizationIdOfOneCell(mcIdType cellId) const; MEDCOUPLING_EXPORT void getCellIdsHavingGaussLocalization(int locId, std::vector& cellIds) const; MEDCOUPLING_EXPORT const MEDCouplingGaussLocalization& getGaussLocalization(int locId) const; - MEDCOUPLING_EXPORT void updateTime() const; - MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; - MEDCOUPLING_EXPORT std::vector getDirectChildrenWithNull() const; + MEDCOUPLING_EXPORT void updateTime() const override; + MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const override; + MEDCOUPLING_EXPORT std::vector getDirectChildrenWithNull() const override; // for MED file RW MEDCOUPLING_EXPORT mcIdType getNumberOfTuplesExpectedRegardingCode(const std::vector& code, const std::vector& idsPerType) const; MEDCOUPLING_EXPORT virtual void reprQuickOverview(std::ostream& stream) const = 0; @@ -92,7 +95,7 @@ namespace MEDCoupling MEDCOUPLING_EXPORT MEDCouplingField(TypeOfField type); MEDCOUPLING_EXPORT MEDCouplingField(const MEDCouplingField& other, bool deepCopy=true); MEDCOUPLING_EXPORT MEDCouplingField(MEDCouplingFieldDiscretization *type, NatureOfField nature=NoNature); - MEDCOUPLING_EXPORT virtual ~MEDCouplingField(); + MEDCOUPLING_EXPORT ~MEDCouplingField() override; MEDCOUPLING_EXPORT bool isEqualIfNotWhyProtected(const MEDCouplingField *other, double meshPrec, std::string& reason) const; MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStrProtected(const MEDCouplingField *other, double meshPrec) const; protected: diff --git a/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx b/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx old mode 100755 new mode 100644 index 1e5021283..ba6e740e4 --- a/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx +++ b/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx @@ -19,8 +19,13 @@ // Author : Anthony Geay (EDF R&D) #include "MEDCouplingFieldDiscretization.hxx" +#include "MCIdType.hxx" +#include "MCType.hxx" #include "MEDCouplingFieldDiscretizationOnNodesFE.hxx" #include "MEDCouplingCMesh.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include "MEDCouplingGaussLocalization.hxx" +#include "MEDCouplingNatureOfFieldEnum" #include "MEDCouplingUMesh.hxx" #include "MEDCouplingFieldDouble.hxx" #include "MCAuto.hxx" @@ -31,14 +36,21 @@ #include "InterpKernelGaussCoords.hxx" #include "InterpKernelMatrixTools.hxx" #include "InterpKernelDenseMatrix.hxx" +#include "NormalizedGeometricTypes" -#include -#include +#include +#include +#include +#include +#include #include +#include #include #include #include #include +#include +#include using namespace MEDCoupling; @@ -202,7 +214,7 @@ MEDCouplingFieldDiscretization *MEDCouplingFieldDiscretization::deepCopy() const /*! * For all field discretization excepted GaussPts the [ \a startCellIds, \a endCellIds ) has no impact on the cloned instance. */ -MEDCouplingFieldDiscretization *MEDCouplingFieldDiscretization::clonePart(const mcIdType *startCellIds, const mcIdType *endCellIds) const +MEDCouplingFieldDiscretization *MEDCouplingFieldDiscretization::clonePart(const mcIdType * /*startCellIds*/, const mcIdType * /*endCellIds*/) const { return clone(); } @@ -210,7 +222,7 @@ MEDCouplingFieldDiscretization *MEDCouplingFieldDiscretization::clonePart(const /*! * For all field discretization excepted GaussPts the slice( \a beginCellId, \a endCellIds, \a stepCellId ) has no impact on the cloned instance. */ -MEDCouplingFieldDiscretization *MEDCouplingFieldDiscretization::clonePartRange(mcIdType beginCellIds, mcIdType endCellIds, mcIdType stepCellIds) const +MEDCouplingFieldDiscretization *MEDCouplingFieldDiscretization::clonePartRange(mcIdType /*beginCellIds*/, mcIdType /*endCellIds*/, mcIdType /*stepCellIds*/) const { return clone(); } @@ -240,15 +252,15 @@ std::vector MEDCouplingFieldDiscretization::getDirectCh void MEDCouplingFieldDiscretization::normL1(const MEDCouplingMesh *mesh, const DataArrayDouble *arr, double *res) const { MCAuto vol=getMeasureField(mesh,true); - std::size_t nbOfCompo=arr->getNumberOfComponents(); - mcIdType nbOfElems=getNumberOfTuples(mesh); + std::size_t const nbOfCompo=arr->getNumberOfComponents(); + mcIdType const nbOfElems=getNumberOfTuples(mesh); std::fill(res,res+nbOfCompo,0.); const double *arrPtr=arr->getConstPointer(); const double *volPtr=vol->getArray()->getConstPointer(); double deno=0.; for(mcIdType i=0;i vol=getMeasureField(mesh,true); - std::size_t nbOfCompo=arr->getNumberOfComponents(); - mcIdType nbOfElems=getNumberOfTuples(mesh); + std::size_t const nbOfCompo=arr->getNumberOfComponents(); + mcIdType const nbOfElems=getNumberOfTuples(mesh); std::fill(res,res+nbOfCompo,0.); const double *arrPtr=arr->getConstPointer(); const double *volPtr=vol->getArray()->getConstPointer(); double deno=0.; for(mcIdType i=0;i vol=getMeasureField(mesh,isWAbs); - std::size_t nbOfCompo(arr->getNumberOfComponents()); - mcIdType nbOfElems(getNumberOfTuples(mesh)); + std::size_t const nbOfCompo(arr->getNumberOfComponents()); + mcIdType const nbOfElems(getNumberOfTuples(mesh)); if(nbOfElems!=arr->getNumberOfTuples()) { std::ostringstream oss; oss << "MEDCouplingFieldDiscretization::integral : field is not correct ! number of tuples in array is " << arr->getNumberOfTuples(); @@ -321,7 +333,7 @@ void MEDCouplingFieldDiscretization::integral(const MEDCouplingMesh *mesh, const * * \sa MEDCouplingFieldDiscretization::buildSubMeshData */ -MEDCouplingMesh *MEDCouplingFieldDiscretization::buildSubMeshDataRange(const MEDCouplingMesh *mesh, mcIdType beginCellIds, mcIdType endCellIds, mcIdType stepCellIds, mcIdType& beginOut, mcIdType& endOut, mcIdType& stepOut, DataArrayIdType *&di) const +MEDCouplingMesh *MEDCouplingFieldDiscretization::buildSubMeshDataRange(const MEDCouplingMesh *mesh, mcIdType beginCellIds, mcIdType endCellIds, mcIdType stepCellIds, mcIdType& /*beginOut*/, mcIdType& /*endOut*/, mcIdType& /*stepOut*/, DataArrayIdType *&di) const { MCAuto da=DataArrayIdType::Range(beginCellIds,endCellIds,stepCellIds); return buildSubMeshData(mesh,da->begin(),da->end(),di); @@ -329,7 +341,7 @@ MEDCouplingMesh *MEDCouplingFieldDiscretization::buildSubMeshDataRange(const MED void MEDCouplingFieldDiscretization::getSerializationIntArray(DataArrayIdType *& arr) const { - arr=0; + arr=nullptr; } /*! @@ -346,9 +358,9 @@ void MEDCouplingFieldDiscretization::getTinySerializationDbleInformation(std::ve { } -void MEDCouplingFieldDiscretization::resizeForUnserialization(const std::vector& tinyInfo, DataArrayIdType *& arr) +void MEDCouplingFieldDiscretization::resizeForUnserialization(const std::vector& /*tinyInfo*/, DataArrayIdType *& arr) { - arr=0; + arr=nullptr; } /*! @@ -373,19 +385,19 @@ void MEDCouplingFieldDiscretization::renumberCells(const mcIdType *old2NewBg, bo { } -double MEDCouplingFieldDiscretization::getIJK(const MEDCouplingMesh *mesh, const DataArrayDouble *da, mcIdType cellId, mcIdType nodeIdInCell, int compoId) const +double MEDCouplingFieldDiscretization::getIJK(const MEDCouplingMesh * /*mesh*/, const DataArrayDouble * /*da*/, mcIdType /*cellId*/, mcIdType /*nodeIdInCell*/, int /*compoId*/) const { throw INTERP_KERNEL::Exception("getIJK Invalid ! only for GaussPoint and GaussNE discretizations !"); } -void MEDCouplingFieldDiscretization::setGaussLocalizationOnType(const MEDCouplingMesh *m, INTERP_KERNEL::NormalizedCellType type, const std::vector& refCoo, - const std::vector& gsCoo, const std::vector& wg) +void MEDCouplingFieldDiscretization::setGaussLocalizationOnType(const MEDCouplingMesh * /*m*/, INTERP_KERNEL::NormalizedCellType /*type*/, const std::vector& /*refCoo*/, + const std::vector& /*gsCoo*/, const std::vector& /*wg*/) { throw INTERP_KERNEL::Exception("Invalid method for the corresponding field discretization : available only for GaussPoint discretization !"); } -void MEDCouplingFieldDiscretization::setGaussLocalizationOnCells(const MEDCouplingMesh *m, const mcIdType *begin, const mcIdType *end, const std::vector& refCoo, - const std::vector& gsCoo, const std::vector& wg) +void MEDCouplingFieldDiscretization::setGaussLocalizationOnCells(const MEDCouplingMesh * /*m*/, const mcIdType * /*begin*/, const mcIdType * /*end*/, const std::vector& /*refCoo*/, + const std::vector& /*gsCoo*/, const std::vector& /*wg*/) { throw INTERP_KERNEL::Exception("Invalid method for the corresponding field discretization : available only for GaussPoint discretization !"); } @@ -395,12 +407,12 @@ void MEDCouplingFieldDiscretization::clearGaussLocalizations() throw INTERP_KERNEL::Exception("Invalid method for the corresponding field discretization : available only for GaussPoint discretization !"); } -MEDCouplingGaussLocalization& MEDCouplingFieldDiscretization::getGaussLocalization(mcIdType locId) +MEDCouplingGaussLocalization& MEDCouplingFieldDiscretization::getGaussLocalization(mcIdType /*locId*/) { throw INTERP_KERNEL::Exception("Invalid method for the corresponding field discretization : available only for GaussPoint discretization !"); } -const MEDCouplingGaussLocalization& MEDCouplingFieldDiscretization::getGaussLocalization(mcIdType locId) const +const MEDCouplingGaussLocalization& MEDCouplingFieldDiscretization::getGaussLocalization(mcIdType /*locId*/) const { throw INTERP_KERNEL::Exception("Invalid method for the corresponding field discretization : available only for GaussPoint discretization !"); } @@ -410,22 +422,22 @@ mcIdType MEDCouplingFieldDiscretization::getNbOfGaussLocalization() const throw INTERP_KERNEL::Exception("Invalid method for the corresponding field discretization : available only for GaussPoint discretization !"); } -mcIdType MEDCouplingFieldDiscretization::getGaussLocalizationIdOfOneCell(mcIdType cellId) const +mcIdType MEDCouplingFieldDiscretization::getGaussLocalizationIdOfOneCell(mcIdType /*cellId*/) const { throw INTERP_KERNEL::Exception("Invalid method for the corresponding field discretization : available only for GaussPoint discretization !"); } -mcIdType MEDCouplingFieldDiscretization::getGaussLocalizationIdOfOneType(INTERP_KERNEL::NormalizedCellType type) const +mcIdType MEDCouplingFieldDiscretization::getGaussLocalizationIdOfOneType(INTERP_KERNEL::NormalizedCellType /*type*/) const { throw INTERP_KERNEL::Exception("Invalid method for the corresponding field discretization : available only for GaussPoint discretization !"); } -std::set MEDCouplingFieldDiscretization::getGaussLocalizationIdsOfOneType(INTERP_KERNEL::NormalizedCellType type) const +std::set MEDCouplingFieldDiscretization::getGaussLocalizationIdsOfOneType(INTERP_KERNEL::NormalizedCellType /*type*/) const { throw INTERP_KERNEL::Exception("Invalid method for the corresponding field discretization : available only for GaussPoint discretization !"); } -void MEDCouplingFieldDiscretization::getCellIdsHavingGaussLocalization(mcIdType locId, std::vector& cellIds) const +void MEDCouplingFieldDiscretization::getCellIdsHavingGaussLocalization(mcIdType /*locId*/, std::vector& /*cellIds*/) const { throw INTERP_KERNEL::Exception("Invalid method for the corresponding field discretization : available only for GaussPoint discretization !"); } @@ -434,9 +446,9 @@ void MEDCouplingFieldDiscretization::RenumberEntitiesFromO2NArr(double eps, cons { if(!arr) throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretization::RenumberEntitiesFromO2NArr : input array is NULL !"); - mcIdType oldNbOfElems=arr->getNumberOfTuples(); - std::size_t nbOfComp=arr->getNumberOfComponents(); - mcIdType newNbOfTuples=newNbOfEntity; + mcIdType const oldNbOfElems=arr->getNumberOfTuples(); + std::size_t const nbOfComp=arr->getNumberOfComponents(); + mcIdType const newNbOfTuples=newNbOfEntity; MCAuto arrCpy=arr->deepCopy(); const double *ptSrc=arrCpy->getConstPointer(); arr->reAlloc(newNbOfTuples); @@ -445,7 +457,7 @@ void MEDCouplingFieldDiscretization::RenumberEntitiesFromO2NArr(double eps, cons INTERP_KERNEL::AutoPtr tmp=new double[nbOfComp]; for(mcIdType i=0;i=0)//if newNb<0 the node is considered as out. { if(std::find_if(ptToFill+newNb*nbOfComp,ptToFill+(newNb+1)*nbOfComp,std::bind(std::not_equal_to(),std::placeholders::_1,std::numeric_limits::max())) @@ -468,23 +480,22 @@ void MEDCouplingFieldDiscretization::RenumberEntitiesFromO2NArr(double eps, cons } } -void MEDCouplingFieldDiscretization::RenumberEntitiesFromN2OArr(const mcIdType *new2OldPtr, mcIdType new2OldSz, DataArrayDouble *arr, const std::string& msg) +void MEDCouplingFieldDiscretization::RenumberEntitiesFromN2OArr(const mcIdType *new2OldPtr, mcIdType new2OldSz, DataArrayDouble *arr, const std::string& /*msg*/) { - std::size_t nbOfComp=arr->getNumberOfComponents(); + std::size_t const nbOfComp=arr->getNumberOfComponents(); MCAuto arrCpy=arr->deepCopy(); const double *ptSrc=arrCpy->getConstPointer(); arr->reAlloc(new2OldSz); double *ptToFill=arr->getPointer(); for(mcIdType i=0;i(other); - bool ret=otherC!=0; + const auto *otherC=dynamic_cast(other); + bool const ret=otherC!=nullptr; if(!ret) reason="Spatial discrtization of this is ON_CELLS, which is not the case of other."; return ret; @@ -542,15 +553,15 @@ mcIdType MEDCouplingFieldDiscretizationP0::getNumberOfTuplesExpectedRegardingCod { if(code.size()%3!=0) throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationP0::getNumberOfTuplesExpectedRegardingCode : invalid input code !"); - mcIdType nbOfSplit=ToIdType(idsPerType.size()); - mcIdType nbOfTypes=ToIdType(code.size()/3); + mcIdType const nbOfSplit=ToIdType(idsPerType.size()); + mcIdType const nbOfTypes=ToIdType(code.size()/3); mcIdType ret=0; for(mcIdType i=0;i=nbOfSplit) @@ -581,7 +592,7 @@ DataArrayIdType *MEDCouplingFieldDiscretizationP0::getOffsetArr(const MEDCouplin { if(!mesh) throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationP0::getOffsetArr : NULL input mesh !"); - std::size_t nbOfTuples=mesh->getNumberOfCells(); + std::size_t const nbOfTuples=mesh->getNumberOfCells(); DataArrayIdType *ret=DataArrayIdType::New(); ret->alloc(nbOfTuples+1,1); ret->iota(0); @@ -596,10 +607,10 @@ void MEDCouplingFieldDiscretizationP0::renumberArraysForCell(const MEDCouplingMe const mcIdType *array=old2NewBg; if(check) array=DataArrayIdType::CheckAndPreparePermutation(old2NewBg,old2NewBg+mesh->getNumberOfCells()); - for(std::vector::const_iterator it=arrays.begin();it!=arrays.end();it++) + for(auto it : arrays) { - if(*it) - (*it)->renumberInPlace(array); + if(it) + it->renumberInPlace(array); } if(check) free(const_cast(array)); @@ -658,7 +669,7 @@ void MEDCouplingFieldDiscretizationP0::getValueOn(const DataArrayDouble *arr, co { if(!mesh) throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationP0::getValueOn : NULL input mesh !"); - mcIdType id=mesh->getCellContainingPoint(loc,_precision); + mcIdType const id=mesh->getCellContainingPoint(loc,_precision); if(id==-1) throw INTERP_KERNEL::Exception("Specified point is detected outside of mesh : unable to apply P0::getValueOn !"); arr->getTuple(id,res); @@ -666,10 +677,10 @@ void MEDCouplingFieldDiscretizationP0::getValueOn(const DataArrayDouble *arr, co void MEDCouplingFieldDiscretizationP0::getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, mcIdType i, mcIdType j, mcIdType k, double *res) const { - const MEDCouplingCMesh *meshC=dynamic_cast(mesh); + const auto *meshC=dynamic_cast(mesh); if(!meshC) throw INTERP_KERNEL::Exception("P0::getValueOnPos is only accessible for structured meshes !"); - mcIdType id=meshC->getCellIdFromPos(i,j,k); + mcIdType const id=meshC->getCellIdFromPos(i,j,k); arr->getTuple(id,res); } @@ -680,8 +691,8 @@ DataArrayDouble *MEDCouplingFieldDiscretizationP0::getValueOnMulti(const DataArr MCAuto eltsArr,eltsIndexArr; mesh->getCellsContainingPoints(loc,nbOfPoints,_precision,eltsArr,eltsIndexArr); const mcIdType *elts(eltsArr->begin()),*eltsIndex(eltsIndexArr->begin()); - int spaceDim=mesh->getSpaceDimension(); - std::size_t nbOfComponents=arr->getNumberOfComponents(); + int const spaceDim=mesh->getSpaceDimension(); + std::size_t const nbOfComponents=arr->getNumberOfComponents(); MCAuto ret=DataArrayDouble::New(); ret->alloc(nbOfPoints,nbOfComponents); double *ptToFill=ret->getPointer(); @@ -705,12 +716,12 @@ void MEDCouplingFieldDiscretizationP0::renumberValuesOnNodes(double , const mcId { } -void MEDCouplingFieldDiscretizationP0::renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const mcIdType *old2New, mcIdType newSz, DataArrayDouble *arr) const +void MEDCouplingFieldDiscretizationP0::renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh * /*mesh*/, const mcIdType *old2New, mcIdType newSz, DataArrayDouble *arr) const { RenumberEntitiesFromO2NArr(epsOnVals,old2New,newSz,arr,"Cell"); } -void MEDCouplingFieldDiscretizationP0::renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const mcIdType *new2old, mcIdType newSz, DataArrayDouble *arr) const +void MEDCouplingFieldDiscretizationP0::renumberValuesOnCellsR(const MEDCouplingMesh * /*mesh*/, const mcIdType *new2old, mcIdType newSz, DataArrayDouble *arr) const { RenumberEntitiesFromN2OArr(new2old,newSz,arr,"Cell"); } @@ -723,7 +734,7 @@ void MEDCouplingFieldDiscretizationP0::renumberValuesOnCellsR(const MEDCouplingM * \return a newly allocated array containing ids to select into the DataArrayDouble of the field. * */ -DataArrayIdType *MEDCouplingFieldDiscretizationP0::computeTupleIdsToSelectFromCellIds(const MEDCouplingMesh *mesh, const mcIdType *startCellIds, const mcIdType *endCellIds) const +DataArrayIdType *MEDCouplingFieldDiscretizationP0::computeTupleIdsToSelectFromCellIds(const MEDCouplingMesh * /*mesh*/, const mcIdType *startCellIds, const mcIdType *endCellIds) const { MCAuto ret=DataArrayIdType::New(); ret->alloc(std::distance(startCellIds,endCellIds),1); @@ -765,7 +776,7 @@ MEDCouplingMesh *MEDCouplingFieldDiscretizationP0::buildSubMeshDataRange(const M if(!mesh) throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationP0::buildSubMeshDataRange : NULL input mesh !"); MCAuto ret=mesh->buildPartRange(beginCellIds,endCellIds,stepCellIds); - di=0; beginOut=beginCellIds; endOut=endCellIds; stepOut=stepCellIds; + di=nullptr; beginOut=beginCellIds; endOut=endCellIds; stepOut=stepCellIds; return ret.retn(); } @@ -791,15 +802,15 @@ mcIdType MEDCouplingFieldDiscretizationOnNodes::getNumberOfTuplesExpectedRegardi { if(code.size()%3!=0) throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationOnNodes::getNumberOfTuplesExpectedRegardingCode : invalid input code !"); - mcIdType nbOfSplit=ToIdType(idsPerType.size()); - mcIdType nbOfTypes=ToIdType(code.size()/3); + mcIdType const nbOfSplit=ToIdType(idsPerType.size()); + mcIdType const nbOfTypes=ToIdType(code.size()/3); mcIdType ret=0; for(mcIdType i=0;i=nbOfSplit) @@ -838,7 +849,7 @@ DataArrayIdType *MEDCouplingFieldDiscretizationOnNodes::getOffsetArr(const MEDCo { if(!mesh) throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationNodes::getOffsetArr : NULL input mesh !"); - mcIdType nbOfTuples=mesh->getNumberOfNodes(); + mcIdType const nbOfTuples=mesh->getNumberOfNodes(); DataArrayIdType *ret=DataArrayIdType::New(); ret->alloc(nbOfTuples+1,1); ret->iota(0); @@ -858,7 +869,7 @@ void MEDCouplingFieldDiscretizationOnNodes::computeMeshRestrictionFromTupleIds(c if(!mesh) throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationOnNodes::computeMeshRestrictionFromTupleIds : NULL input mesh !"); MCAuto ret1=mesh->getCellIdsFullyIncludedInNodeIds(tupleIdsBg,tupleIdsEnd); - const MEDCouplingUMesh *meshc=dynamic_cast(mesh); + const auto *meshc=dynamic_cast(mesh); if(!meshc) throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationOnNodes::computeMeshRestrictionFromTupleIds : trying to subpart field on nodes by node ids ! Your mesh has to be unstructured !"); MCAuto meshPart=static_cast(meshc->buildPartOfMySelf(ret1->begin(),ret1->end(),true)); @@ -889,7 +900,7 @@ MEDCouplingMesh *MEDCouplingFieldDiscretizationOnNodes::buildSubMeshData(const M { if(!mesh) throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationNodes::buildSubMeshData : NULL input mesh !"); - DataArrayIdType *diTmp=0; + DataArrayIdType *diTmp=nullptr; MCAuto ret=mesh->buildPartAndReduceNodes(start,end,diTmp); MCAuto diTmpSafe(diTmp); MCAuto di2=diTmpSafe->invertArrayO2N2N2O(ret->getNumberOfNodes()); @@ -911,7 +922,7 @@ MEDCouplingMesh *MEDCouplingFieldDiscretizationOnNodes::buildSubMeshDataRange(co { if(!mesh) throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationOnNodes::buildSubMeshDataRange : NULL input mesh !"); - DataArrayIdType *diTmp=0; + DataArrayIdType *diTmp=nullptr; MCAuto ret=mesh->buildPartRangeAndReduceNodes(beginCellIds,endCellIds,stepCellIds,beginOut,endOut,stepOut,diTmp); if(diTmp) { @@ -960,10 +971,10 @@ void MEDCouplingFieldDiscretizationOnNodes::renumberValuesOnCellsR(const MEDCoup void MEDCouplingFieldDiscretizationOnNodes::getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, mcIdType i, mcIdType j, mcIdType k, double *res) const { - const MEDCouplingCMesh *meshC=dynamic_cast(mesh); + const auto *meshC=dynamic_cast(mesh); if(!meshC) throw INTERP_KERNEL::Exception("OnNodes::getValueOnPos(i,j,k) is only accessible for structured meshes !"); - mcIdType id=meshC->getNodeIdFromPos(i,j,k); + mcIdType const id=meshC->getNodeIdFromPos(i,j,k); arr->getTuple(id,res); } @@ -992,15 +1003,15 @@ const char *MEDCouplingFieldDiscretizationP1::getRepr() const return REPR; } -bool MEDCouplingFieldDiscretizationP1::isEqualIfNotWhy(const MEDCouplingFieldDiscretization *other, double eps, std::string& reason) const +bool MEDCouplingFieldDiscretizationP1::isEqualIfNotWhy(const MEDCouplingFieldDiscretization *other, double /*eps*/, std::string& reason) const { if(!other) { reason="other spatial discretization is NULL, and this spatial discretization (P1) is defined."; return false; } - const MEDCouplingFieldDiscretizationP1 *otherC=dynamic_cast(other); - bool ret=otherC!=0; + const auto *otherC=dynamic_cast(other); + bool const ret=otherC!=nullptr; if(!ret) reason="Spatial discrtization of this is ON_NODES, which is not the case of other."; return ret; @@ -1023,10 +1034,10 @@ void MEDCouplingFieldDiscretizationP1::getValueOn(const DataArrayDouble *arr, co { if(!mesh) throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationP1::getValueOn : NULL input mesh !"); - mcIdType id=mesh->getCellContainingPoint(loc,_precision); + mcIdType const id=mesh->getCellContainingPoint(loc,_precision); if(id==-1) throw INTERP_KERNEL::Exception("Specified point is detected outside of mesh : unable to apply P1::getValueOn !"); - INTERP_KERNEL::NormalizedCellType type=mesh->getTypeOfCell(id); + INTERP_KERNEL::NormalizedCellType const type=mesh->getTypeOfCell(id); if(type!=INTERP_KERNEL::NORM_SEG2 && type!=INTERP_KERNEL::NORM_TRI3 && type!=INTERP_KERNEL::NORM_TETRA4) throw INTERP_KERNEL::Exception("P1 getValueOn is not specified for not simplex cells !"); getValueInCell(mesh,id,arr,loc,res); @@ -1043,17 +1054,17 @@ void MEDCouplingFieldDiscretizationP1::getValueInCell(const MEDCouplingMesh *mes std::vector conn; std::vector coo; mesh->getNodeIdsOfCell(cellId,conn); - for(std::vector::const_iterator iter=conn.begin();iter!=conn.end();iter++) - mesh->getCoordinatesOfNode(*iter,coo); - int spaceDim=mesh->getSpaceDimension(); - std::size_t nbOfNodes=conn.size(); + for(long const iter : conn) + mesh->getCoordinatesOfNode(iter,coo); + int const spaceDim=mesh->getSpaceDimension(); + std::size_t const nbOfNodes=conn.size(); std::vector vec(nbOfNodes); for(std::size_t i=0;i tmp=new double[nbOfNodes]; - INTERP_KERNEL::NormalizedCellType ct(mesh->getTypeOfCell(cellId)); + INTERP_KERNEL::NormalizedCellType const ct(mesh->getTypeOfCell(cellId)); INTERP_KERNEL::barycentric_coords(ct,vec,loc,tmp); - std::size_t sz=arr->getNumberOfComponents(); + std::size_t const sz=arr->getNumberOfComponents(); INTERP_KERNEL::AutoPtr tmp2=new double[sz]; std::fill(res,res+sz,0.); for(std::size_t i=0;i eltsArr,eltsIndexArr; mesh->getCellsContainingPoints(loc,nbOfPoints,_precision,eltsArr,eltsIndexArr); const mcIdType *elts(eltsArr->begin()),*eltsIndex(eltsIndexArr->begin()); - int spaceDim=mesh->getSpaceDimension(); - std::size_t nbOfComponents=arr->getNumberOfComponents(); + int const spaceDim=mesh->getSpaceDimension(); + std::size_t const nbOfComponents=arr->getNumberOfComponents(); MCAuto ret=DataArrayDouble::New(); ret->alloc(nbOfPoints,nbOfComponents); double *ptToFill=ret->getPointer(); @@ -1099,7 +1110,7 @@ MCAuto MEDCouplingFieldDiscretizationP1::aggrega return EasyAggregate(fds); } -MEDCouplingFieldDiscretizationPerCell::MEDCouplingFieldDiscretizationPerCell():_discr_per_cell(0) +MEDCouplingFieldDiscretizationPerCell::MEDCouplingFieldDiscretizationPerCell():_discr_per_cell(nullptr) { } @@ -1112,19 +1123,19 @@ MEDCouplingFieldDiscretizationPerCell::~MEDCouplingFieldDiscretizationPerCell() /*! * This constructor deep copies MEDCoupling::DataArrayIdType instance from other (if any). */ -MEDCouplingFieldDiscretizationPerCell::MEDCouplingFieldDiscretizationPerCell(const MEDCouplingFieldDiscretizationPerCell& other, const mcIdType *startCellIds, const mcIdType *endCellIds):_discr_per_cell(0) +MEDCouplingFieldDiscretizationPerCell::MEDCouplingFieldDiscretizationPerCell(const MEDCouplingFieldDiscretizationPerCell& other, const mcIdType *startCellIds, const mcIdType *endCellIds):_discr_per_cell(nullptr) { DataArrayIdType *arr=other._discr_per_cell; if(arr) { - if(startCellIds==0 && endCellIds==0) + if(startCellIds==nullptr && endCellIds==nullptr) _discr_per_cell=arr->deepCopy(); else _discr_per_cell=arr->selectByTupleIdSafe(startCellIds,endCellIds); } } -MEDCouplingFieldDiscretizationPerCell::MEDCouplingFieldDiscretizationPerCell(const MEDCouplingFieldDiscretizationPerCell& other, mcIdType beginCellIds, mcIdType endCellIds, mcIdType stepCellIds):_discr_per_cell(0) +MEDCouplingFieldDiscretizationPerCell::MEDCouplingFieldDiscretizationPerCell(const MEDCouplingFieldDiscretizationPerCell& other, mcIdType beginCellIds, mcIdType endCellIds, mcIdType stepCellIds):_discr_per_cell(nullptr) { DataArrayIdType *arr=other._discr_per_cell; if(arr) @@ -1147,7 +1158,7 @@ void MEDCouplingFieldDiscretizationPerCell::updateTime() const std::size_t MEDCouplingFieldDiscretizationPerCell::getHeapMemorySizeWithoutChildren() const { - std::size_t ret(MEDCouplingFieldDiscretization::getHeapMemorySizeWithoutChildren()); + std::size_t const ret(MEDCouplingFieldDiscretization::getHeapMemorySizeWithoutChildren()); return ret; } @@ -1158,48 +1169,48 @@ std::vector MEDCouplingFieldDiscretizationPerCell::getD return ret; } -void MEDCouplingFieldDiscretizationPerCell::checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArray *da) const +void MEDCouplingFieldDiscretizationPerCell::checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArray * /*da*/) const { if(!_discr_per_cell) throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationPerCell has no discretization per cell !"); if(!mesh) throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationPerCell::checkCoherencyBetween : NULL input mesh or DataArray !"); - mcIdType nbOfTuples(_discr_per_cell->getNumberOfTuples()); + mcIdType const nbOfTuples(_discr_per_cell->getNumberOfTuples()); if(nbOfTuples!=mesh->getNumberOfCells()) throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationPerCell has a discretization per cell but it's not matching the underlying mesh !"); } -bool MEDCouplingFieldDiscretizationPerCell::isEqualIfNotWhy(const MEDCouplingFieldDiscretization *other, double eps, std::string& reason) const +bool MEDCouplingFieldDiscretizationPerCell::isEqualIfNotWhy(const MEDCouplingFieldDiscretization *other, double /*eps*/, std::string& reason) const { if(!other) { reason="other spatial discretization is NULL, and this spatial discretization (PerCell) is defined."; return false; } - const MEDCouplingFieldDiscretizationPerCell *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) { reason="Spatial discretization of this is ON_GAUSS, which is not the case of other."; return false; } - if(_discr_per_cell==0) - return otherC->_discr_per_cell==0; - if(otherC->_discr_per_cell==0) + if(_discr_per_cell==nullptr) + return otherC->_discr_per_cell==nullptr; + if(otherC->_discr_per_cell==nullptr) return false; - bool ret=_discr_per_cell->isEqualIfNotWhy(*otherC->_discr_per_cell,reason); + bool const ret=_discr_per_cell->isEqualIfNotWhy(*otherC->_discr_per_cell,reason); if(!ret) reason.insert(0,"Field discretization per cell DataArrayIdType given the discid per cell :"); return ret; } -bool MEDCouplingFieldDiscretizationPerCell::isEqualWithoutConsideringStr(const MEDCouplingFieldDiscretization *other, double eps) const +bool MEDCouplingFieldDiscretizationPerCell::isEqualWithoutConsideringStr(const MEDCouplingFieldDiscretization *other, double /*eps*/) const { - const MEDCouplingFieldDiscretizationPerCell *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) return false; - if(_discr_per_cell==0) - return otherC->_discr_per_cell==0; - if(otherC->_discr_per_cell==0) + if(_discr_per_cell==nullptr) + return otherC->_discr_per_cell==nullptr; + if(otherC->_discr_per_cell==nullptr) return false; return _discr_per_cell->isEqualWithoutConsideringStr(*otherC->_discr_per_cell); } @@ -1210,7 +1221,7 @@ bool MEDCouplingFieldDiscretizationPerCell::isEqualWithoutConsideringStr(const M */ void MEDCouplingFieldDiscretizationPerCell::renumberCells(const mcIdType *old2NewBg, bool check) { - mcIdType nbCells=_discr_per_cell->getNumberOfTuples(); + mcIdType const nbCells=_discr_per_cell->getNumberOfTuples(); const mcIdType *array=old2NewBg; if(check) array=DataArrayIdType::CheckAndPreparePermutation(old2NewBg,old2NewBg+nbCells); @@ -1230,7 +1241,7 @@ void MEDCouplingFieldDiscretizationPerCell::buildDiscrPerCellIfNecessary(const M if(!_discr_per_cell) { _discr_per_cell=DataArrayIdType::New(); - mcIdType nbTuples=mesh->getNumberOfCells(); + mcIdType const nbTuples=mesh->getNumberOfCells(); _discr_per_cell->alloc(nbTuples,1); mcIdType *ptr=_discr_per_cell->getPointer(); std::fill(ptr,ptr+nbTuples,DFT_INVALID_LOCID_VALUE); @@ -1282,8 +1293,7 @@ void MEDCouplingFieldDiscretizationPerCell::setArrayOfDiscIds(const DataArrayIdT } MEDCouplingFieldDiscretizationGauss::MEDCouplingFieldDiscretizationGauss() -{ -} += default; MEDCouplingFieldDiscretizationGauss::MEDCouplingFieldDiscretizationGauss(const MEDCouplingFieldDiscretizationGauss& other, const mcIdType *startCellIds, const mcIdType *endCellIds):MEDCouplingFieldDiscretizationPerCell(other,startCellIds,endCellIds),_loc(other._loc) { @@ -1305,7 +1315,7 @@ bool MEDCouplingFieldDiscretizationGauss::isEqualIfNotWhy(const MEDCouplingField reason="other spatial discretization is NULL, and this spatial discretization (Gauss) is defined."; return false; } - const MEDCouplingFieldDiscretizationGauss *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) { reason="Spatial discrtization of this is ON_GAUSS, which is not the case of other."; @@ -1318,7 +1328,7 @@ bool MEDCouplingFieldDiscretizationGauss::isEqualIfNotWhy(const MEDCouplingField reason="Gauss spatial discretization : localization sizes differ"; return false; } - std::size_t sz=_loc.size(); + std::size_t const sz=_loc.size(); for(std::size_t i=0;i_loc[i],eps)) { @@ -1331,14 +1341,14 @@ bool MEDCouplingFieldDiscretizationGauss::isEqualIfNotWhy(const MEDCouplingField bool MEDCouplingFieldDiscretizationGauss::isEqualWithoutConsideringStr(const MEDCouplingFieldDiscretization *other, double eps) const { - const MEDCouplingFieldDiscretizationGauss *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) return false; if(!MEDCouplingFieldDiscretizationPerCell::isEqualWithoutConsideringStr(other,eps)) return false; if(_loc.size()!=otherC->_loc.size()) return false; - std::size_t sz=_loc.size(); + std::size_t const sz=_loc.size(); for(std::size_t i=0;i_loc[i],eps)) return false; @@ -1379,7 +1389,7 @@ std::string MEDCouplingFieldDiscretizationGauss::getStringRepr() const } oss << "Presence of " << _loc.size() << " localizations." << std::endl; int i=0; - for(std::vector::const_iterator it=_loc.begin();it!=_loc.end();it++,i++) + for(auto it=_loc.begin();it!=_loc.end();it++,i++) { oss << "+++++ Localization #" << i << " +++++" << std::endl; oss << (*it).getStringRepr(); @@ -1392,8 +1402,8 @@ std::size_t MEDCouplingFieldDiscretizationGauss::getHeapMemorySizeWithoutChildre { std::size_t ret(MEDCouplingFieldDiscretizationPerCell::getHeapMemorySizeWithoutChildren()); ret+=_loc.capacity()*sizeof(MEDCouplingGaussLocalization); - for(std::vector::const_iterator it=_loc.begin();it!=_loc.end();it++) - ret+=(*it).getMemorySize(); + for(const auto & it : _loc) + ret+=it.getMemorySize(); return ret; } @@ -1414,15 +1424,15 @@ mcIdType MEDCouplingFieldDiscretizationGauss::getNumberOfTuplesExpectedRegarding throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGauss::getNumberOfTuplesExpectedRegardingCode"); if(code.size()%3!=0) throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGauss::getNumberOfTuplesExpectedRegardingCode : invalid input code !"); - mcIdType nbOfSplit=ToIdType(idsPerType.size()); - mcIdType nbOfTypes=ToIdType(code.size()/3); + mcIdType const nbOfSplit=ToIdType(idsPerType.size()); + mcIdType const nbOfTypes=ToIdType(code.size()/3); mcIdType ret(0); for(mcIdType i=0;i=nbOfSplit) @@ -1444,17 +1454,17 @@ mcIdType MEDCouplingFieldDiscretizationGauss::getNumberOfTuplesExpectedRegarding std::ostringstream oss; oss << "MEDCouplingFieldDiscretizationGauss::getNumberOfTuplesExpectedRegardingCode : input code points to " << ret << " cells whereas discretization percell array lgth is " << _discr_per_cell->getNumberOfTuples() << " !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - return getNumberOfTuples(0);//0 is not an error ! It is to be sure that input mesh is not used + return getNumberOfTuples(nullptr);//0 is not an error ! It is to be sure that input mesh is not used } mcIdType MEDCouplingFieldDiscretizationGauss::getNumberOfTuples(const MEDCouplingMesh *) const { mcIdType ret=0; - if (_discr_per_cell == 0) + if (_discr_per_cell == nullptr) throw INTERP_KERNEL::Exception("Discretization is not initialized!"); const mcIdType *dcPtr=_discr_per_cell->getConstPointer(); - mcIdType nbOfTuples=_discr_per_cell->getNumberOfTuples(); - mcIdType maxSz=ToIdType(_loc.size()); + mcIdType const nbOfTuples=_discr_per_cell->getNumberOfTuples(); + mcIdType const maxSz=ToIdType(_loc.size()); for(const mcIdType *w=dcPtr;w!=dcPtr+nbOfTuples;w++) { if(*w>=0 && *wgetNumberOfCells(); + mcIdType const nbOfTuples=mesh->getNumberOfCells(); MCAuto ret=DataArrayIdType::New(); ret->alloc(nbOfTuples+1,1); mcIdType *retPtr(ret->getPointer()); const mcIdType *start(_discr_per_cell->begin()); if(_discr_per_cell->getNumberOfTuples()!=nbOfTuples) throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGauss::getOffsetArr : mismatch between the mesh and the discretization ids array length !"); - mcIdType maxPossible=ToIdType(_loc.size()); + mcIdType const maxPossible=ToIdType(_loc.size()); retPtr[0]=0; for(mcIdType i=0;igetNumberOfCells()); - mcIdType nbOfCells=_discr_per_cell->getNumberOfTuples(); - mcIdType nbOfTuples=getNumberOfTuples(0); + mcIdType const nbOfCells=_discr_per_cell->getNumberOfTuples(); + mcIdType const nbOfTuples=getNumberOfTuples(nullptr); const mcIdType *dcPtr=_discr_per_cell->getConstPointer(); - mcIdType *array2=new mcIdType[nbOfTuples];//stores the final conversion array old2New to give to arrays in renumberInPlace. - mcIdType *array3=new mcIdType[nbOfCells];//store for each cell in present dcp array (already renumbered) the offset needed by each cell in new numbering. + auto *array2=new mcIdType[nbOfTuples];//stores the final conversion array old2New to give to arrays in renumberInPlace. + auto *array3=new mcIdType[nbOfCells];//store for each cell in present dcp array (already renumbered) the offset needed by each cell in new numbering. array3[0]=0; for(mcIdType i=1;i::const_iterator it=arrays.begin();it!=arrays.end();it++) - if(*it) - (*it)->renumberInPlace(array2); + for(auto array : arrays) + if(array) + array->renumberInPlace(array2); delete [] array2; if(check) free(const_cast(array)); @@ -1543,9 +1553,9 @@ DataArrayDouble *MEDCouplingFieldDiscretizationGauss::getLocalizationOfDiscValue throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGauss::getLocalizationOfDiscValues : NULL input mesh !"); checkNoOrphanCells(); MCAuto umesh=mesh->buildUnstructured();//in general do nothing - mcIdType nbOfTuples=getNumberOfTuples(mesh); + mcIdType const nbOfTuples=getNumberOfTuples(mesh); MCAuto ret=DataArrayDouble::New(); - int spaceDim=mesh->getSpaceDimension(); + int const spaceDim=mesh->getSpaceDimension(); ret->alloc(nbOfTuples,spaceDim); std::vector< mcIdType > locIds; std::vector parts=splitIntoSingleGaussDicrPerCellType(locIds); @@ -1563,14 +1573,14 @@ DataArrayDouble *MEDCouplingFieldDiscretizationGauss::getLocalizationOfDiscValue INTERP_KERNEL::GaussCoords calculator; // const MEDCouplingGaussLocalization& cli(_loc[locIds[i]]);//curLocInfo - INTERP_KERNEL::NormalizedCellType typ(cli.getType()); + INTERP_KERNEL::NormalizedCellType const typ(cli.getType()); const std::vector& wg(cli.getWeights()); calculator.addGaussInfo(typ,INTERP_KERNEL::CellModel::GetCellModel(typ).getDimension(), &cli.getGaussCoords()[0],ToIdType(wg.size()),&cli.getRefCoords()[0], INTERP_KERNEL::CellModel::GetCellModel(typ).getNumberOfNodes()); // - for(const mcIdType *w=parts2[i]->begin();w!=parts2[i]->end();w++) - calculator.calculateCoords(cli.getType(),coords,spaceDim,conn+connI[*w]+1,valsToFill+spaceDim*(ptrOffsets[*w])); + for(long const w : *parts2[i]) + calculator.calculateCoords(cli.getType(),coords,spaceDim,conn+connI[w]+1,valsToFill+spaceDim*(ptrOffsets[w])); } ret->copyStringInfoFrom(*umesh->getCoords()); return ret.retn(); @@ -1608,33 +1618,33 @@ void MEDCouplingFieldDiscretizationGauss::getTinySerializationIntInformation(std tinyInfo.push_back(-1); else tinyInfo.push_back(_loc[0].getDimension()); - for(std::vector::const_iterator iter=_loc.begin();iter!=_loc.end();iter++) - (*iter).pushTinySerializationIntInfo(tinyInfo); + for(const auto & iter : _loc) + iter.pushTinySerializationIntInfo(tinyInfo); } void MEDCouplingFieldDiscretizationGauss::getTinySerializationDbleInformation(std::vector& tinyInfo) const { - for(std::vector::const_iterator iter=_loc.begin();iter!=_loc.end();iter++) - (*iter).pushTinySerializationDblInfo(tinyInfo); + for(const auto & iter : _loc) + iter.pushTinySerializationDblInfo(tinyInfo); } void MEDCouplingFieldDiscretizationGauss::getSerializationIntArray(DataArrayIdType *& arr) const { - arr=0; + arr=nullptr; if(_discr_per_cell) arr=_discr_per_cell; } void MEDCouplingFieldDiscretizationGauss::resizeForUnserialization(const std::vector& tinyInfo, DataArrayIdType *& arr) { - mcIdType val=tinyInfo[0]; + mcIdType const val=tinyInfo[0]; if(val>=0) { _discr_per_cell=DataArrayIdType::New(); _discr_per_cell->alloc(val,1); } else - _discr_per_cell=0; + _discr_per_cell=nullptr; arr=_discr_per_cell; commonUnserialization(tinyInfo); } @@ -1642,7 +1652,7 @@ void MEDCouplingFieldDiscretizationGauss::resizeForUnserialization(const std::ve void MEDCouplingFieldDiscretizationGauss::checkForUnserialization(const std::vector& tinyInfo, const DataArrayIdType *arr) { static const char MSG[]="MEDCouplingFieldDiscretizationGauss::checkForUnserialization : expect to have one not null DataArrayIdType !"; - mcIdType val=tinyInfo[0]; + mcIdType const val=tinyInfo[0]; if(val>=0) { if(!arr) @@ -1652,23 +1662,23 @@ void MEDCouplingFieldDiscretizationGauss::checkForUnserialization(const std::vec _discr_per_cell->incrRef(); } else - _discr_per_cell=0; + _discr_per_cell=nullptr; commonUnserialization(tinyInfo); } void MEDCouplingFieldDiscretizationGauss::finishUnserialization(const std::vector& tinyInfo) { - double *tmp=new double[tinyInfo.size()]; + auto *tmp=new double[tinyInfo.size()]; std::copy(tinyInfo.begin(),tinyInfo.end(),tmp); const double *work=tmp; - for(std::vector::iterator iter=_loc.begin();iter!=_loc.end();iter++) - work=(*iter).fillWithValues(work); + for(auto & iter : _loc) + work=iter.fillWithValues(work); delete [] tmp; } -double MEDCouplingFieldDiscretizationGauss::getIJK(const MEDCouplingMesh *mesh, const DataArrayDouble *da, mcIdType cellId, mcIdType nodeIdInCell, int compoId) const +double MEDCouplingFieldDiscretizationGauss::getIJK(const MEDCouplingMesh * /*mesh*/, const DataArrayDouble *da, mcIdType cellId, mcIdType nodeIdInCell, int compoId) const { - mcIdType offset=getOffsetOfCell(cellId); + mcIdType const offset=getOffsetOfCell(cellId); return da->getIJ(offset+nodeIdInCell,compoId); } @@ -1677,10 +1687,10 @@ void MEDCouplingFieldDiscretizationGauss::checkCoherencyBetween(const MEDCouplin if(!mesh || !da) throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGauss::checkCoherencyBetween : NULL input mesh or DataArray !"); MEDCouplingFieldDiscretizationPerCell::checkCoherencyBetween(mesh,da); - for(std::vector::const_iterator iter=_loc.begin();iter!=_loc.end();iter++) - (*iter).checkConsistencyLight(); - mcIdType nbOfDesc=ToIdType(_loc.size()); - mcIdType nbOfCells=mesh->getNumberOfCells(); + for(const auto & iter : _loc) + iter.checkConsistencyLight(); + mcIdType const nbOfDesc=ToIdType(_loc.size()); + mcIdType const nbOfCells=mesh->getNumberOfCells(); const mcIdType *dc=_discr_per_cell->getConstPointer(); for(mcIdType i=0;igetNumberOfTuples()) { std::ostringstream oss; oss << "Invalid number of tuples in the array : expecting " << nbOfTuples << " having " << da->getNumberOfTuples() << " !"; @@ -1708,7 +1718,7 @@ void MEDCouplingFieldDiscretizationGauss::checkCoherencyBetween(const MEDCouplin } } -MEDCouplingFieldDouble *MEDCouplingFieldDiscretizationGauss::getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const +MEDCouplingFieldDouble *MEDCouplingFieldDiscretizationGauss::getMeasureField(const MEDCouplingMesh *mesh, bool /*isAbs*/) const { if(!mesh) throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGauss::getMeasureField : mesh instance specified is NULL !"); @@ -1731,26 +1741,26 @@ MEDCouplingFieldDouble *MEDCouplingFieldDiscretizationGauss::getMeasureField(con ret->setArray(arr); double *arrPtr=arr->getPointer(); const mcIdType *offsetPtr=offset->getConstPointer(); - mcIdType maxGaussLoc=ToIdType(_loc.size()); + mcIdType const maxGaussLoc=ToIdType(_loc.size()); std::vector locIds; std::vector ids=splitIntoSingleGaussDicrPerCellType(locIds); std::vector< MCAuto > ids2(ids.size()); std::copy(ids.begin(),ids.end(),ids2.begin()); for(std::size_t i=0;i=0 && locId weights=new double[nbOfGaussPt]; - for(const mcIdType *cellId=curIds->begin();cellId!=curIds->end();cellId++) + mcIdType const nbOfGaussPt=loc.getNumberOfGaussPt(); + INTERP_KERNEL::AutoPtr const weights=new double[nbOfGaussPt]; + for(long const curId : *curIds) { std::vector conn; - umesh->getNodeIdsOfCell(*cellId,conn); + umesh->getNodeIdsOfCell(curId,conn); std::vector ptsInCell; ptsInCell.reserve(conn.size()*loc.getDimension()); std::for_each( conn.cbegin(), conn.cend(), [spaceDim,coordsOfMesh,&ptsInCell](mcIdType c) { ptsInCell.insert(ptsInCell.end(),coordsOfMesh+c*spaceDim,coordsOfMesh+(c+1)*spaceDim); } ); - std::size_t nbPtsInCell(ptsInCell.size()/spaceDim); + std::size_t const nbPtsInCell(ptsInCell.size()/spaceDim); INTERP_KERNEL::DenseMatrix jacobian(spaceDim,meshDim); MCAuto shapeFunc = loc.getDerivativeOfShapeFunctionValues(); for(mcIdType iGPt = 0 ; iGPt < nbOfGaussPt ; ++iGPt) @@ -1763,7 +1773,7 @@ MEDCouplingFieldDouble *MEDCouplingFieldDiscretizationGauss::getMeasureField(con res += ptsInCell[spaceDim*k+i] * shapeFunc->getIJ(iGPt,meshDim*k+j); jacobian[ i ][ j ] = res; } - arrPtr[offsetPtr[*cellId]+iGPt]=std::abs( jacobian.toJacobian() )*loc.getWeight(FromIdType(iGPt)); + arrPtr[offsetPtr[curId]+iGPt]=std::abs( jacobian.toJacobian() )*loc.getWeight(FromIdType(iGPt)); } } } @@ -1777,17 +1787,17 @@ MEDCouplingFieldDouble *MEDCouplingFieldDiscretizationGauss::getMeasureField(con return ret.retn(); } -void MEDCouplingFieldDiscretizationGauss::getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const +void MEDCouplingFieldDiscretizationGauss::getValueOn(const DataArrayDouble * /*arr*/, const MEDCouplingMesh * /*mesh*/, const double * /*loc*/, double * /*res*/) const { throw INTERP_KERNEL::Exception("Not implemented yet !"); } -void MEDCouplingFieldDiscretizationGauss::getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, mcIdType i, mcIdType j, mcIdType k, double *res) const +void MEDCouplingFieldDiscretizationGauss::getValueOnPos(const DataArrayDouble * /*arr*/, const MEDCouplingMesh * /*mesh*/, mcIdType /*i*/, mcIdType /*j*/, mcIdType /*k*/, double * /*res*/) const { throw INTERP_KERNEL::Exception("getValueOnPos(i,j,k) : Not applicable for Gauss points !"); } -DataArrayDouble *MEDCouplingFieldDiscretizationGauss::getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, mcIdType nbOfPoints) const +DataArrayDouble *MEDCouplingFieldDiscretizationGauss::getValueOnMulti(const DataArrayDouble * /*arr*/, const MEDCouplingMesh * /*mesh*/, const double * /*loc*/, mcIdType /*nbOfPoints*/) const { throw INTERP_KERNEL::Exception("getValueOnMulti : Not implemented yet for gauss points !"); } @@ -1820,18 +1830,18 @@ MEDCouplingMesh *MEDCouplingFieldDiscretizationGauss::buildSubMeshDataRange(cons throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGauss::buildSubMeshDataRange : NULL input mesh !"); if(!_discr_per_cell) throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGauss::buildSubMeshDataRange : no discretization array set !"); - di=0; beginOut=0; endOut=0; stepOut=stepCellIds; + di=nullptr; beginOut=0; endOut=0; stepOut=stepCellIds; const char msg[]="MEDCouplingFieldDiscretizationGauss::buildSubMeshDataRange : cell #"; - mcIdType nbOfTuples=_discr_per_cell->getNumberOfTuples(); + mcIdType const nbOfTuples=_discr_per_cell->getNumberOfTuples(); const mcIdType *w=_discr_per_cell->begin(); - mcIdType nbMaxOfLocId=ToIdType(_loc.size()); + mcIdType const nbMaxOfLocId=ToIdType(_loc.size()); for(mcIdType i=0;i=0 && *w nbOfNodesPerCell=buildNbOfGaussPointPerCellField();//check of _discr_per_cell not NULL pointer - mcIdType nbOfCells(mesh->getNumberOfCells()); + mcIdType const nbOfCells(mesh->getNumberOfCells()); if(_discr_per_cell->getNumberOfTuples()!=nbOfCells) throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGauss::computeTupleIdsToSelectFromCellIds : mismatch of nb of tuples of cell ids array and number of cells !"); nbOfNodesPerCell->computeOffsetsFull(); @@ -1875,12 +1885,12 @@ void MEDCouplingFieldDiscretizationGauss::renumberValuesOnNodes(double , const m { } -void MEDCouplingFieldDiscretizationGauss::renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const mcIdType *old2New, mcIdType newSz, DataArrayDouble *arr) const +void MEDCouplingFieldDiscretizationGauss::renumberValuesOnCells(double /*epsOnVals*/, const MEDCouplingMesh * /*mesh*/, const mcIdType * /*old2New*/, mcIdType /*newSz*/, DataArrayDouble * /*arr*/) const { throw INTERP_KERNEL::Exception("Not implemented yet !"); } -void MEDCouplingFieldDiscretizationGauss::renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const mcIdType *new2old, mcIdType newSz, DataArrayDouble *arr) const +void MEDCouplingFieldDiscretizationGauss::renumberValuesOnCellsR(const MEDCouplingMesh * /*mesh*/, const mcIdType * /*new2old*/, mcIdType /*newSz*/, DataArrayDouble * /*arr*/) const { throw INTERP_KERNEL::Exception("Number of cells has changed and becomes higher with some cells that have been split ! Unable to conserve the Gauss field !"); } @@ -1894,7 +1904,7 @@ MCAuto MEDCouplingFieldDiscretizationGauss::aggr std::size_t i(0); for(auto it=fds.begin();it!=fds.end();++it,++i) { - const MEDCouplingFieldDiscretizationGauss *itc(dynamic_cast(*it)); + const auto *itc(dynamic_cast(*it)); if(!itc) throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGauss::aggregate : same field discretization expected for all input discretizations !"); // @@ -1942,11 +1952,11 @@ void MEDCouplingFieldDiscretizationGauss::setGaussLocalizationOnType(const MEDCo throw INTERP_KERNEL::Exception(oss.str().c_str()); } buildDiscrPerCellIfNecessary(mesh); - mcIdType id=ToIdType(_loc.size()); - MEDCouplingGaussLocalization elt(type,refCoo,gsCoo,wg); + mcIdType const id=ToIdType(_loc.size()); + MEDCouplingGaussLocalization const elt(type,refCoo,gsCoo,wg); _loc.push_back(elt); mcIdType *ptr=_discr_per_cell->getPointer(); - mcIdType nbCells=mesh->getNumberOfCells(); + mcIdType const nbCells=mesh->getNumberOfCells(); for(mcIdType i=0;igetTypeOfCell(i)==type) ptr[i]=id; @@ -1961,9 +1971,9 @@ void MEDCouplingFieldDiscretizationGauss::setGaussLocalizationOnCells(const MEDC buildDiscrPerCellIfNecessary(mesh); if(std::distance(begin,end)<1) throw INTERP_KERNEL::Exception("Size of [begin,end) must be equal or greater than 1 !"); - INTERP_KERNEL::NormalizedCellType type=mesh->getTypeOfCell(*begin); - MEDCouplingGaussLocalization elt(type,refCoo,gsCoo,wg); - mcIdType id=ToIdType(_loc.size()); + INTERP_KERNEL::NormalizedCellType const type=mesh->getTypeOfCell(*begin); + MEDCouplingGaussLocalization const elt(type,refCoo,gsCoo,wg); + mcIdType const id=ToIdType(_loc.size()); mcIdType *ptr=_discr_per_cell->getPointer(); for(const mcIdType *w=begin+1;w!=end;w++) { @@ -1986,7 +1996,7 @@ void MEDCouplingFieldDiscretizationGauss::clearGaussLocalizations() if(_discr_per_cell) { _discr_per_cell->decrRef(); - _discr_per_cell=0; + _discr_per_cell=nullptr; } _loc.clear(); } @@ -1995,8 +2005,8 @@ void MEDCouplingFieldDiscretizationGauss::setGaussLocalization(mcIdType locId, c { if(locId<0) throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGauss::setGaussLocalization : localization id has to be >=0 !"); - mcIdType sz=ToIdType(_loc.size()); - MEDCouplingGaussLocalization gLoc(INTERP_KERNEL::NORM_ERROR); + mcIdType const sz=ToIdType(_loc.size()); + MEDCouplingGaussLocalization const gLoc(INTERP_KERNEL::NORM_ERROR); if(locId>=sz) _loc.resize(locId+1,gLoc); _loc[locId]=loc; @@ -2006,7 +2016,7 @@ void MEDCouplingFieldDiscretizationGauss::resizeLocalizationVector(mcIdType newS { if(newSz<0) throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGauss::resizeLocalizationVector : new size has to be >=0 !"); - MEDCouplingGaussLocalization gLoc(INTERP_KERNEL::NORM_ERROR); + MEDCouplingGaussLocalization const gLoc(INTERP_KERNEL::NORM_ERROR); _loc.resize(newSz,gLoc); } @@ -2025,7 +2035,7 @@ mcIdType MEDCouplingFieldDiscretizationGauss::getGaussLocalizationIdOfOneCell(mc { if(!_discr_per_cell) throw INTERP_KERNEL::Exception("No Gauss localization still set !"); - mcIdType locId=_discr_per_cell->begin()[cellId]; + mcIdType const locId=_discr_per_cell->begin()[cellId]; if(locId<0) throw INTERP_KERNEL::Exception("No Gauss localization set for the specified cell !"); return locId; @@ -2033,7 +2043,7 @@ mcIdType MEDCouplingFieldDiscretizationGauss::getGaussLocalizationIdOfOneCell(mc mcIdType MEDCouplingFieldDiscretizationGauss::getGaussLocalizationIdOfOneType(INTERP_KERNEL::NormalizedCellType type) const { - std::set ret=getGaussLocalizationIdsOfOneType(type); + std::set const ret=getGaussLocalizationIdsOfOneType(type); if(ret.empty()) throw INTERP_KERNEL::Exception("No gauss discretization found for the specified type !"); if(ret.size()>1) @@ -2047,7 +2057,7 @@ std::set MEDCouplingFieldDiscretizationGauss::getGaussLocalizationIdsO throw INTERP_KERNEL::Exception("No Gauss localization still set !"); std::set ret; mcIdType id=0; - for(std::vector::const_iterator iter=_loc.begin();iter!=_loc.end();iter++,id++) + for(auto iter=_loc.begin();iter!=_loc.end();iter++,id++) if((*iter).getType()==type) ret.insert(id); return ret; @@ -2057,7 +2067,7 @@ void MEDCouplingFieldDiscretizationGauss::getCellIdsHavingGaussLocalization(mcId { if(locId<0 || locId>=ToIdType(_loc.size())) throw INTERP_KERNEL::Exception("Invalid locId given : must be in range [0:getNbOfGaussLocalization()) !"); - mcIdType nbOfTuples=_discr_per_cell->getNumberOfTuples(); + mcIdType const nbOfTuples=_discr_per_cell->getNumberOfTuples(); const mcIdType *ptr=_discr_per_cell->getConstPointer(); for(mcIdType i=0;igetNumberOfTuples(); + mcIdType const nbOfTuples=_discr_per_cell->getNumberOfTuples(); MCAuto ret=DataArrayIdType::New(); const mcIdType *w=_discr_per_cell->begin(); ret->alloc(nbOfTuples,1); mcIdType *valsToFill=ret->getPointer(); - mcIdType nbMaxOfLocId=ToIdType(_loc.size()); + mcIdType const nbMaxOfLocId=ToIdType(_loc.size()); for(mcIdType i=0;ibegin(); - mcIdType nbOfTuples=_discr_per_cell->getNumberOfTuples(); + mcIdType const nbOfTuples=_discr_per_cell->getNumberOfTuples(); INTERP_KERNEL::AutoPtr tmp=new mcIdType[_loc.size()]; std::fill((mcIdType *)tmp,(mcIdType *)tmp+_loc.size(),-2); for(const mcIdType *w=start;w!=start+nbOfTuples;w++) @@ -2159,23 +2169,22 @@ void MEDCouplingFieldDiscretizationGauss::zipGaussLocalizations() void MEDCouplingFieldDiscretizationGauss::commonUnserialization(const std::vector& tinyInfo) { - mcIdType nbOfLoc=tinyInfo[1]; + mcIdType const nbOfLoc=tinyInfo[1]; _loc.clear(); - mcIdType dim=tinyInfo[2]; + mcIdType const dim=tinyInfo[2]; mcIdType delta=-1; if(nbOfLoc>0) delta=(ToIdType(tinyInfo.size())-3)/nbOfLoc; for(mcIdType i=0;i tmp(tinyInfo.begin()+3+i*delta,tinyInfo.begin()+3+(i+1)*delta); - MEDCouplingGaussLocalization elt=MEDCouplingGaussLocalization::BuildNewInstanceFromTinyInfo(dim,tmp); + std::vector const tmp(tinyInfo.begin()+3+i*delta,tinyInfo.begin()+3+(i+1)*delta); + MEDCouplingGaussLocalization const elt=MEDCouplingGaussLocalization::BuildNewInstanceFromTinyInfo(dim,tmp); _loc.push_back(elt); } } MEDCouplingFieldDiscretizationGaussNE::MEDCouplingFieldDiscretizationGaussNE() -{ -} += default; TypeOfField MEDCouplingFieldDiscretizationGaussNE::getEnum() const { @@ -2202,15 +2211,15 @@ const char *MEDCouplingFieldDiscretizationGaussNE::getRepr() const return REPR; } -bool MEDCouplingFieldDiscretizationGaussNE::isEqualIfNotWhy(const MEDCouplingFieldDiscretization *other, double eps, std::string& reason) const +bool MEDCouplingFieldDiscretizationGaussNE::isEqualIfNotWhy(const MEDCouplingFieldDiscretization *other, double /*eps*/, std::string& reason) const { if(!other) { reason="other spatial discretization is NULL, and this spatial discretization (GaussNE) is defined."; return false; } - const MEDCouplingFieldDiscretizationGaussNE *otherC=dynamic_cast(other); - bool ret=otherC!=0; + const auto *otherC=dynamic_cast(other); + bool const ret=otherC!=nullptr; if(!ret) reason="Spatial discrtization of this is ON_GAUSS_NE, which is not the case of other."; return ret; @@ -2226,8 +2235,8 @@ mcIdType MEDCouplingFieldDiscretizationGaussNE::getNumberOfTuplesExpectedRegardi { if(code.size()%3!=0) throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGaussNE::getNumberOfTuplesExpectedRegardingCode : invalid input code !"); - mcIdType nbOfSplit=ToIdType(idsPerType.size()); - mcIdType nbOfTypes=ToIdType(code.size()/3); + mcIdType const nbOfSplit=ToIdType(idsPerType.size()); + mcIdType const nbOfTypes=ToIdType(code.size()/3); mcIdType ret(0); for(mcIdType i=0;i=nbOfSplit) @@ -2265,10 +2274,10 @@ mcIdType MEDCouplingFieldDiscretizationGaussNE::getNumberOfTuples(const MEDCoupl if(!mesh) throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGaussNE::getNumberOfTuples : NULL input mesh !"); mcIdType ret=0; - mcIdType nbOfCells=mesh->getNumberOfCells(); + mcIdType const nbOfCells=mesh->getNumberOfCells(); for(mcIdType i=0;igetTypeOfCell(i); + INTERP_KERNEL::NormalizedCellType const type=mesh->getTypeOfCell(i); const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(type); if(cm.isDynamic()) throw INTERP_KERNEL::Exception("Not implemented yet Gauss node on elements for polygons and polyedrons !"); @@ -2288,14 +2297,14 @@ DataArrayIdType *MEDCouplingFieldDiscretizationGaussNE::getOffsetArr(const MEDCo { if(!mesh) throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGaussNE::getOffsetArr : NULL input mesh !"); - mcIdType nbOfTuples=mesh->getNumberOfCells(); + mcIdType const nbOfTuples=mesh->getNumberOfCells(); DataArrayIdType *ret=DataArrayIdType::New(); ret->alloc(nbOfTuples+1,1); mcIdType *retPtr=ret->getPointer(); retPtr[0]=0; for(mcIdType i=0;igetTypeOfCell(i); + INTERP_KERNEL::NormalizedCellType const type=mesh->getTypeOfCell(i); const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(type); if(cm.isDynamic()) throw INTERP_KERNEL::Exception("Not implemented yet Gauss node on elements for polygons and polyedrons !"); @@ -2312,29 +2321,29 @@ void MEDCouplingFieldDiscretizationGaussNE::renumberArraysForCell(const MEDCoupl const mcIdType *array=old2NewBg; if(check) array=DataArrayIdType::CheckAndPreparePermutation(old2NewBg,old2NewBg+mesh->getNumberOfCells()); - mcIdType nbOfCells=mesh->getNumberOfCells(); - mcIdType nbOfTuples=getNumberOfTuples(mesh); - mcIdType *array2=new mcIdType[nbOfTuples];//stores the final conversion array old2New to give to arrays in renumberInPlace. - mcIdType *array3=new mcIdType[nbOfCells];//store for each cell in after renumbering the offset needed by each cell in new numbering. + mcIdType const nbOfCells=mesh->getNumberOfCells(); + mcIdType const nbOfTuples=getNumberOfTuples(mesh); + auto *array2=new mcIdType[nbOfTuples];//stores the final conversion array old2New to give to arrays in renumberInPlace. + auto *array3=new mcIdType[nbOfCells];//store for each cell in after renumbering the offset needed by each cell in new numbering. array3[0]=0; for(mcIdType i=1;igetTypeOfCell(ToIdType(std::distance(array,std::find(array,array+nbOfCells,i-1)))); + INTERP_KERNEL::NormalizedCellType const type=mesh->getTypeOfCell(ToIdType(std::distance(array,std::find(array,array+nbOfCells,i-1)))); const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(type); array3[i]=array3[i-1]+cm.getNumberOfNodes(); } mcIdType j=0; for(mcIdType i=0;igetTypeOfCell(i); + INTERP_KERNEL::NormalizedCellType const type=mesh->getTypeOfCell(i); const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(type); for(mcIdType k=0;k::const_iterator it=arrays.begin();it!=arrays.end();it++) - if(*it) - (*it)->renumberInPlace(array2); + for(auto array : arrays) + if(array) + array->renumberInPlace(array2); delete [] array2; if(check) free(const_cast(array)); @@ -2346,13 +2355,13 @@ DataArrayDouble *MEDCouplingFieldDiscretizationGaussNE::getLocalizationOfDiscVal throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGaussNE::getLocalizationOfDiscValues : NULL input mesh !"); MCAuto ret=DataArrayDouble::New(); MCAuto umesh=mesh->buildUnstructured();//in general do nothing - mcIdType nbOfTuples=getNumberOfTuples(umesh); - int spaceDim=mesh->getSpaceDimension(); + mcIdType const nbOfTuples=getNumberOfTuples(umesh); + int const spaceDim=mesh->getSpaceDimension(); ret->alloc(nbOfTuples,spaceDim); const double *coords=umesh->getCoords()->begin(); const mcIdType *connI=umesh->getNodalConnectivityIndex()->getConstPointer(); const mcIdType *conn=umesh->getNodalConnectivity()->getConstPointer(); - mcIdType nbCells=umesh->getNumberOfCells(); + mcIdType const nbCells=umesh->getNumberOfCells(); double *retPtr=ret->getPointer(); for(mcIdType i=0;igetNumberOfComponents(); + std::size_t const nbOfCompo=arr->getNumberOfComponents(); std::fill(res,res+nbOfCompo,0.); // MCAuto vol=mesh->getMeasureField(isWAbs); - std::set types=mesh->getAllGeoTypes(); + std::set const types=mesh->getAllGeoTypes(); MCAuto nbOfNodesPerCell=mesh->computeNbOfNodesPerCell(); nbOfNodesPerCell->computeOffsetsFull(); const double *arrPtr=arr->begin(),*volPtr=vol->getArray()->begin(); - for(std::set::const_iterator it=types.begin();it!=types.end();it++) + for(auto type : types) { std::size_t wArrSz=-1; - const double *wArr=GetWeightArrayFromGeometricType(*it,wArrSz); + const double *wArr=GetWeightArrayFromGeometricType(type,wArrSz); INTERP_KERNEL::AutoPtr wArr2=new double[wArrSz]; - double sum=std::accumulate(wArr,wArr+wArrSz,0.); + double const sum=std::accumulate(wArr,wArr+wArrSz,0.); std::transform(wArr,wArr+wArrSz,(double *)wArr2,std::bind(std::multiplies(),std::placeholders::_1,1./sum)); - MCAuto ids=mesh->giveCellsWithType(*it); + MCAuto ids=mesh->giveCellsWithType(type); MCAuto ids2=ids->buildExplicitArrByRanges(nbOfNodesPerCell); const mcIdType *ptIds2=ids2->begin(),*ptIds=ids->begin(); - mcIdType nbOfCellsWithCurGeoType=ids->getNumberOfTuples(); + mcIdType const nbOfCellsWithCurGeoType=ids->getNumberOfTuples(); for(mcIdType i=0;igetTypeOfCell(i); + INTERP_KERNEL::NormalizedCellType const type=mesh->getTypeOfCell(i); const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(type); offset+=cm.getNumberOfNodes(); } @@ -2681,7 +2690,7 @@ double MEDCouplingFieldDiscretizationGaussNE::getIJK(const MEDCouplingMesh *mesh void MEDCouplingFieldDiscretizationGaussNE::checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArray *da) const { - mcIdType nbOfTuples(getNumberOfTuples(mesh)); + mcIdType const nbOfTuples(getNumberOfTuples(mesh)); if(nbOfTuples!=da->getNumberOfTuples()) { std::ostringstream oss; oss << "Invalid number of tuples in the array : expecting " << nbOfTuples << " !"; @@ -2698,24 +2707,24 @@ MEDCouplingFieldDouble *MEDCouplingFieldDiscretizationGaussNE::getMeasureField(c MCAuto ret=MEDCouplingFieldDouble::New(ON_GAUSS_NE); ret->setMesh(mesh); // - std::set types=mesh->getAllGeoTypes(); + std::set const types=mesh->getAllGeoTypes(); MCAuto nbOfNodesPerCell=mesh->computeNbOfNodesPerCell(); - mcIdType nbTuples=nbOfNodesPerCell->accumulate((std::size_t)0); + mcIdType const nbTuples=nbOfNodesPerCell->accumulate((std::size_t)0); nbOfNodesPerCell->computeOffsetsFull(); MCAuto arr=DataArrayDouble::New(); arr->alloc(nbTuples,1); ret->setArray(arr); double *arrPtr=arr->getPointer(); - for(std::set::const_iterator it=types.begin();it!=types.end();it++) + for(auto type : types) { std::size_t wArrSz=-1; - const double *wArr=GetWeightArrayFromGeometricType(*it,wArrSz); + const double *wArr=GetWeightArrayFromGeometricType(type,wArrSz); INTERP_KERNEL::AutoPtr wArr2=new double[wArrSz]; - double sum=std::accumulate(wArr,wArr+wArrSz,0.); + double const sum=std::accumulate(wArr,wArr+wArrSz,0.); std::transform(wArr,wArr+wArrSz,(double *)wArr2,std::bind(std::multiplies(),std::placeholders::_1,1./sum)); - MCAuto ids=mesh->giveCellsWithType(*it); + MCAuto ids=mesh->giveCellsWithType(type); MCAuto ids2=ids->buildExplicitArrByRanges(nbOfNodesPerCell); const mcIdType *ptIds2=ids2->begin(),*ptIds=ids->begin(); - mcIdType nbOfCellsWithCurGeoType=ids->getNumberOfTuples(); + mcIdType const nbOfCellsWithCurGeoType=ids->getNumberOfTuples(); for(mcIdType i=0;igetNumberOfCells(); - di=0; beginOut=0; endOut=0; stepOut=stepCellIds; + mcIdType const nbOfCells=mesh->getNumberOfCells(); + di=nullptr; beginOut=0; endOut=0; stepOut=stepCellIds; const char msg[]="MEDCouplingFieldDiscretizationGaussNE::buildSubMeshDataRange : cell #"; for(mcIdType i=0;igetTypeOfCell(i); + INTERP_KERNEL::NormalizedCellType const type=mesh->getTypeOfCell(i); const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(type); if(cm.isDynamic()) { std::ostringstream oss; oss << msg << i << " presence of dynamic cell (polygons and polyedrons) ! Not implemented !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - mcIdType delta=cm.getNumberOfNodes(); + mcIdType const delta=cm.getNumberOfNodes(); if(i MEDCouplingFieldDiscretizationGaussNE::ag return EasyAggregate(fds); } -void MEDCouplingFieldDiscretizationGaussNE::renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const mcIdType *new2old, mcIdType newSz, DataArrayDouble *arr) const +void MEDCouplingFieldDiscretizationGaussNE::renumberValuesOnCellsR(const MEDCouplingMesh * /*mesh*/, const mcIdType * /*new2old*/, mcIdType /*newSz*/, DataArrayDouble * /*arr*/) const { throw INTERP_KERNEL::Exception("Not implemented yet !"); } @@ -2830,9 +2839,8 @@ void MEDCouplingFieldDiscretizationGaussNE::reprQuickOverview(std::ostream& stre stream << "Gauss points on nodes per element spatial discretization."; } -MEDCouplingFieldDiscretizationGaussNE::MEDCouplingFieldDiscretizationGaussNE(const MEDCouplingFieldDiscretizationGaussNE& other):MEDCouplingFieldDiscretization(other) -{ -} +MEDCouplingFieldDiscretizationGaussNE::MEDCouplingFieldDiscretizationGaussNE(const MEDCouplingFieldDiscretizationGaussNE& other) += default; TypeOfField MEDCouplingFieldDiscretizationKriging::getEnum() const { @@ -2865,21 +2873,21 @@ void MEDCouplingFieldDiscretizationKriging::checkCompatibilityWithNature(NatureO throw INTERP_KERNEL::Exception("Invalid nature for Kriging field : expected IntensiveMaximum !"); } -bool MEDCouplingFieldDiscretizationKriging::isEqualIfNotWhy(const MEDCouplingFieldDiscretization *other, double eps, std::string& reason) const +bool MEDCouplingFieldDiscretizationKriging::isEqualIfNotWhy(const MEDCouplingFieldDiscretization *other, double /*eps*/, std::string& reason) const { if(!other) { reason="other spatial discretization is NULL, and this spatial discretization (Kriginig) is defined."; return false; } - const MEDCouplingFieldDiscretizationKriging *otherC=dynamic_cast(other); - bool ret=otherC!=0; + const auto *otherC=dynamic_cast(other); + bool const ret=otherC!=nullptr; if(!ret) reason="Spatial discrtization of this is ON_NODES_KR, which is not the case of other."; return ret; } -MEDCouplingFieldDouble *MEDCouplingFieldDiscretizationKriging::getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const +MEDCouplingFieldDouble *MEDCouplingFieldDiscretizationKriging::getMeasureField(const MEDCouplingMesh *mesh, bool /*isAbs*/) const { if(!mesh) throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationKriging::getMeasureField : mesh instance specified is NULL !"); @@ -2896,14 +2904,14 @@ DataArrayDouble *MEDCouplingFieldDiscretizationKriging::getValueOnMulti(const Da { if(!arr || !arr->isAllocated()) throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationKriging::getValueOnMulti : input array is null or not allocated !"); - mcIdType nbOfRows=getNumberOfMeshPlaces(mesh); + mcIdType const nbOfRows=getNumberOfMeshPlaces(mesh); if(arr->getNumberOfTuples()!=nbOfRows) { std::ostringstream oss; oss << "MEDCouplingFieldDiscretizationKriging::getValueOnMulti : input array does not have correct number of tuples ! Excepted " << nbOfRows << " having " << arr->getNumberOfTuples() << " !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } mcIdType nbCols(-1); - std::size_t nbCompo=arr->getNumberOfComponents(); + std::size_t const nbCompo=arr->getNumberOfComponents(); MCAuto m(computeEvaluationMatrixOnGivenPts(mesh,loc,nbOfTargetPoints,nbCols)); MCAuto ret(DataArrayDouble::New()); ret->alloc(nbOfTargetPoints,nbCompo); @@ -2932,8 +2940,8 @@ DataArrayDouble *MEDCouplingFieldDiscretizationKriging::computeEvaluationMatrixO MCAuto matrixInv(computeInverseMatrix(mesh,isDrift,nbRows)); // MCAuto coords=getLocalizationOfDiscValues(mesh); - mcIdType nbOfPts(coords->getNumberOfTuples()); - std::size_t dimension(coords->getNumberOfComponents()); + mcIdType const nbOfPts(coords->getNumberOfTuples()); + std::size_t const dimension(coords->getNumberOfComponents()); MCAuto locArr=DataArrayDouble::New(); locArr->useArray(loc,false,DeallocType::CPP_DEALLOC,nbOfTargetPoints,dimension); nbCols=nbOfPts; @@ -2992,7 +3000,7 @@ DataArrayDouble *MEDCouplingFieldDiscretizationKriging::computeMatrix(const MEDC if(!mesh) throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationKriging::computeMatrix : NULL input mesh !"); MCAuto coords(getLocalizationOfDiscValues(mesh)); - mcIdType nbOfPts(coords->getNumberOfTuples()); + mcIdType const nbOfPts(coords->getNumberOfTuples()); MCAuto matrix(coords->buildEuclidianDistanceDenseMatrix()); operateOnDenseMatrix(mesh->getSpaceDimension(),nbOfPts*nbOfPts,matrix->getPointer()); // Drift @@ -3057,7 +3065,7 @@ void MEDCouplingFieldDiscretizationKriging::OperateOnDenseMatrixH3(mcIdType nbOf { for(mcIdType i=0;iisAllocated()) throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationKriging::PerformDriftRect : invalid input array of coordiantes ! Must be allocated and not NULL !"); - std::size_t spaceDimension(arr->getNumberOfComponents()); + std::size_t const spaceDimension(arr->getNumberOfComponents()); mcIdType nbOfPts(arr->getNumberOfTuples()),nbOfEltInMatrx(matr->getNumberOfTuples()); delta=ToIdType(spaceDimension)+1; - mcIdType nbOfCols(nbOfEltInMatrx/nbOfPts); + mcIdType const nbOfCols(nbOfEltInMatrx/nbOfPts); if(nbOfEltInMatrx%nbOfPts!=0) throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationKriging::PerformDriftRect : size of input dense matrix and input arrays mismatch ! NbOfElems in matrix % nb of tuples in array must be equal to 0 !"); MCAuto ret(DataArrayDouble::New()); ret->alloc(nbOfPts*(nbOfCols+delta)); @@ -3134,9 +3142,9 @@ DataArrayDouble *MEDCouplingFieldDiscretizationKriging::PerformDriftOfVec(const */ DataArrayDouble *MEDCouplingFieldDiscretizationKriging::performDrift(const DataArrayDouble *matr, const DataArrayDouble *arr, mcIdType& delta) const { - std::size_t spaceDimension(arr->getNumberOfComponents()); + std::size_t const spaceDimension(arr->getNumberOfComponents()); delta=ToIdType(spaceDimension)+1; - mcIdType szOfMatrix(arr->getNumberOfTuples()); + mcIdType const szOfMatrix(arr->getNumberOfTuples()); if(szOfMatrix*szOfMatrix!=matr->getNumberOfTuples()) throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationKriging::performDrift : invalid size"); MCAuto ret=DataArrayDouble::New(); diff --git a/src/MEDCoupling/MEDCouplingFieldDiscretization.hxx b/src/MEDCoupling/MEDCouplingFieldDiscretization.hxx index c15020adb..5f644d24a 100644 --- a/src/MEDCoupling/MEDCouplingFieldDiscretization.hxx +++ b/src/MEDCoupling/MEDCouplingFieldDiscretization.hxx @@ -21,15 +21,20 @@ #ifndef __PARAMEDMEM_MEDCOUPLINGFIELDDISCRETIZATION_HXX__ #define __PARAMEDMEM_MEDCOUPLINGFIELDDISCRETIZATION_HXX__ +#include "MCType.hxx" #include "MEDCoupling.hxx" +#include "MEDCouplingNatureOfFieldEnum" #include "MEDCouplingRefCountObject.hxx" #include "InterpKernelException.hxx" #include "MEDCouplingTimeLabel.hxx" -#include "MEDCouplingNatureOfField.hxx" #include "MEDCouplingGaussLocalization.hxx" #include "MCAuto.hxx" +#include "NormalizedGeometricTypes" +#include +#include #include +#include #include namespace MEDCoupling @@ -46,9 +51,9 @@ namespace MEDCoupling MEDCOUPLING_EXPORT static MEDCouplingFieldDiscretization *New(TypeOfField type); MEDCOUPLING_EXPORT double getPrecision() const { return _precision; } MEDCOUPLING_EXPORT void setPrecision(double val) { _precision=val; } - MEDCOUPLING_EXPORT void updateTime() const; - MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; - MEDCOUPLING_EXPORT std::vector getDirectChildrenWithNull() const; + MEDCOUPLING_EXPORT void updateTime() const override; + MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const override; + MEDCOUPLING_EXPORT std::vector getDirectChildrenWithNull() const override; MEDCOUPLING_EXPORT static TypeOfField GetTypeOfFieldFromStringRepr(const std::string& repr); MEDCOUPLING_EXPORT static std::string GetTypeOfFieldRepr(TypeOfField type); MEDCOUPLING_EXPORT virtual TypeOfField getEnum() const = 0; @@ -107,7 +112,7 @@ namespace MEDCoupling MEDCOUPLING_EXPORT virtual void getCellIdsHavingGaussLocalization(mcIdType locId, std::vector& cellIds) const; MEDCOUPLING_EXPORT virtual const MEDCouplingGaussLocalization& getGaussLocalization(mcIdType locId) const; MEDCOUPLING_EXPORT virtual void reprQuickOverview(std::ostream& stream) const = 0; - MEDCOUPLING_EXPORT virtual ~MEDCouplingFieldDiscretization(); + MEDCOUPLING_EXPORT ~MEDCouplingFieldDiscretization() override; protected: MEDCOUPLING_EXPORT MEDCouplingFieldDiscretization(); MEDCOUPLING_EXPORT static void RenumberEntitiesFromO2NArr(double epsOnVals, const mcIdType *old2NewPtr, mcIdType newNbOfEntity, DataArrayDouble *arr, const std::string& msg); @@ -122,35 +127,35 @@ namespace MEDCoupling class MEDCouplingFieldDiscretizationP0 : public MEDCouplingFieldDiscretization { public: - MEDCOUPLING_EXPORT TypeOfField getEnum() const; + MEDCOUPLING_EXPORT TypeOfField getEnum() const override; MEDCOUPLING_EXPORT std::string getClassName() const override { return std::string("MEDCouplingFieldDiscretizationP0"); } MEDCOUPLING_EXPORT MEDCouplingFieldDiscretization *clone() const override; - MEDCOUPLING_EXPORT std::string getStringRepr() const; - MEDCOUPLING_EXPORT const char *getRepr() const; + MEDCOUPLING_EXPORT std::string getStringRepr() const override; + MEDCOUPLING_EXPORT const char *getRepr() const override; MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingFieldDiscretization *other, double eps, std::string& reason) const override; - MEDCOUPLING_EXPORT mcIdType getNumberOfTuplesExpectedRegardingCode(const std::vector& code, const std::vector& idsPerType) const; - MEDCOUPLING_EXPORT mcIdType getNumberOfTuples(const MEDCouplingMesh *mesh) const; - MEDCOUPLING_EXPORT mcIdType getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const; - MEDCOUPLING_EXPORT DataArrayIdType *getOffsetArr(const MEDCouplingMesh *mesh) const; + MEDCOUPLING_EXPORT mcIdType getNumberOfTuplesExpectedRegardingCode(const std::vector& code, const std::vector& idsPerType) const override; + MEDCOUPLING_EXPORT mcIdType getNumberOfTuples(const MEDCouplingMesh *mesh) const override; + MEDCOUPLING_EXPORT mcIdType getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const override; + MEDCOUPLING_EXPORT DataArrayIdType *getOffsetArr(const MEDCouplingMesh *mesh) const override; MEDCOUPLING_EXPORT void renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector& arrays, - const mcIdType *old2NewBg, bool check); - MEDCOUPLING_EXPORT DataArrayDouble *getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const; + const mcIdType *old2NewBg, bool check) override; + MEDCOUPLING_EXPORT DataArrayDouble *getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const override; MEDCOUPLING_EXPORT void checkCompatibilityWithNature(NatureOfField nat) const override; MEDCOUPLING_EXPORT void computeMeshRestrictionFromTupleIds(const MEDCouplingMesh *mesh, const mcIdType *tupleIdsBg, const mcIdType *tupleIdsEnd, - DataArrayIdType *&cellRestriction, DataArrayIdType *&trueTupleRestriction) const; - MEDCOUPLING_EXPORT void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArray *da) const; + DataArrayIdType *&cellRestriction, DataArrayIdType *&trueTupleRestriction) const override; + MEDCOUPLING_EXPORT void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArray *da) const override; MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const override; MEDCOUPLING_EXPORT void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const override; - MEDCOUPLING_EXPORT void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, mcIdType i, mcIdType j, mcIdType k, double *res) const; + MEDCOUPLING_EXPORT void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, mcIdType i, mcIdType j, mcIdType k, double *res) const override; MEDCOUPLING_EXPORT DataArrayDouble *getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, mcIdType nbOfPoints) const override; - MEDCOUPLING_EXPORT void renumberValuesOnNodes(double epsOnVals, const mcIdType *old2New, mcIdType newNbOfNodes, DataArrayDouble *arr) const; - MEDCOUPLING_EXPORT void renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const mcIdType *old2New, mcIdType newSz, DataArrayDouble *arr) const; - MEDCOUPLING_EXPORT void renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const mcIdType *new2old, mcIdType newSz, DataArrayDouble *arr) const; + MEDCOUPLING_EXPORT void renumberValuesOnNodes(double epsOnVals, const mcIdType *old2New, mcIdType newNbOfNodes, DataArrayDouble *arr) const override; + MEDCOUPLING_EXPORT void renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const mcIdType *old2New, mcIdType newSz, DataArrayDouble *arr) const override; + MEDCOUPLING_EXPORT void renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const mcIdType *new2old, mcIdType newSz, DataArrayDouble *arr) const override; MEDCOUPLING_EXPORT MCAuto aggregate(std::vector& fds) const override; - MEDCOUPLING_EXPORT MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const mcIdType *start, const mcIdType *end, DataArrayIdType *&di) const; - MEDCOUPLING_EXPORT MEDCouplingMesh *buildSubMeshDataRange(const MEDCouplingMesh *mesh, mcIdType beginCellIds, mcIdType endCellIds, mcIdType stepCellIds, mcIdType& beginOut, mcIdType& endOut, mcIdType& stepOut, DataArrayIdType *&di) const; - MEDCOUPLING_EXPORT DataArrayIdType *computeTupleIdsToSelectFromCellIds(const MEDCouplingMesh *mesh, const mcIdType *startCellIds, const mcIdType *endCellIds) const; - MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const; + MEDCOUPLING_EXPORT MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const mcIdType *start, const mcIdType *end, DataArrayIdType *&di) const override; + MEDCOUPLING_EXPORT MEDCouplingMesh *buildSubMeshDataRange(const MEDCouplingMesh *mesh, mcIdType beginCellIds, mcIdType endCellIds, mcIdType stepCellIds, mcIdType& beginOut, mcIdType& endOut, mcIdType& stepOut, DataArrayIdType *&di) const override; + MEDCOUPLING_EXPORT DataArrayIdType *computeTupleIdsToSelectFromCellIds(const MEDCouplingMesh *mesh, const mcIdType *startCellIds, const mcIdType *endCellIds) const override; + MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const override; public: static const char REPR[]; static constexpr TypeOfField TYPE = ON_CELLS; @@ -159,40 +164,40 @@ namespace MEDCoupling class MEDCouplingFieldDiscretizationOnNodes : public MEDCouplingFieldDiscretization { public: - MEDCOUPLING_EXPORT mcIdType getNumberOfTuples(const MEDCouplingMesh *mesh) const; - MEDCOUPLING_EXPORT mcIdType getNumberOfTuplesExpectedRegardingCode(const std::vector& code, const std::vector& idsPerType) const; - MEDCOUPLING_EXPORT mcIdType getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const; - MEDCOUPLING_EXPORT DataArrayIdType *getOffsetArr(const MEDCouplingMesh *mesh) const; + MEDCOUPLING_EXPORT mcIdType getNumberOfTuples(const MEDCouplingMesh *mesh) const override; + MEDCOUPLING_EXPORT mcIdType getNumberOfTuplesExpectedRegardingCode(const std::vector& code, const std::vector& idsPerType) const override; + MEDCOUPLING_EXPORT mcIdType getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const override; + MEDCOUPLING_EXPORT DataArrayIdType *getOffsetArr(const MEDCouplingMesh *mesh) const override; MEDCOUPLING_EXPORT void renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector& arrays, - const mcIdType *old2NewBg, bool check); - MEDCOUPLING_EXPORT DataArrayDouble *getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const; + const mcIdType *old2NewBg, bool check) override; + MEDCOUPLING_EXPORT DataArrayDouble *getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const override; MEDCOUPLING_EXPORT void computeMeshRestrictionFromTupleIds(const MEDCouplingMesh *mesh, const mcIdType *tupleIdsBg, const mcIdType *tupleIdsEnd, - DataArrayIdType *&cellRestriction, DataArrayIdType *&trueTupleRestriction) const; - MEDCOUPLING_EXPORT void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArray *da) const; - MEDCOUPLING_EXPORT MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const mcIdType *start, const mcIdType *end, DataArrayIdType *&di) const; - MEDCOUPLING_EXPORT MEDCouplingMesh *buildSubMeshDataRange(const MEDCouplingMesh *mesh, mcIdType beginCellIds, mcIdType endCellIds, mcIdType stepCellIds, mcIdType& beginOut, mcIdType& endOut, mcIdType& stepOut, DataArrayIdType *&di) const; - MEDCOUPLING_EXPORT DataArrayIdType *computeTupleIdsToSelectFromCellIds(const MEDCouplingMesh *mesh, const mcIdType *startCellIds, const mcIdType *endCellIds) const; - MEDCOUPLING_EXPORT void renumberValuesOnNodes(double epsOnVals, const mcIdType *old2New, mcIdType newNbOfNodes, DataArrayDouble *arr) const; - MEDCOUPLING_EXPORT void renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const mcIdType *old2New, mcIdType newSz, DataArrayDouble *arr) const; - MEDCOUPLING_EXPORT void renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const mcIdType *new2old, mcIdType newSz, DataArrayDouble *arr) const; + DataArrayIdType *&cellRestriction, DataArrayIdType *&trueTupleRestriction) const override; + MEDCOUPLING_EXPORT void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArray *da) const override; + MEDCOUPLING_EXPORT MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const mcIdType *start, const mcIdType *end, DataArrayIdType *&di) const override; + MEDCOUPLING_EXPORT MEDCouplingMesh *buildSubMeshDataRange(const MEDCouplingMesh *mesh, mcIdType beginCellIds, mcIdType endCellIds, mcIdType stepCellIds, mcIdType& beginOut, mcIdType& endOut, mcIdType& stepOut, DataArrayIdType *&di) const override; + MEDCOUPLING_EXPORT DataArrayIdType *computeTupleIdsToSelectFromCellIds(const MEDCouplingMesh *mesh, const mcIdType *startCellIds, const mcIdType *endCellIds) const override; + MEDCOUPLING_EXPORT void renumberValuesOnNodes(double epsOnVals, const mcIdType *old2New, mcIdType newNbOfNodes, DataArrayDouble *arr) const override; + MEDCOUPLING_EXPORT void renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const mcIdType *old2New, mcIdType newSz, DataArrayDouble *arr) const override; + MEDCOUPLING_EXPORT void renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const mcIdType *new2old, mcIdType newSz, DataArrayDouble *arr) const override; public: - MEDCOUPLING_EXPORT void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, mcIdType i, mcIdType j, mcIdType k, double *res) const; + MEDCOUPLING_EXPORT void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, mcIdType i, mcIdType j, mcIdType k, double *res) const override; }; class MEDCouplingFieldDiscretizationP1 : public MEDCouplingFieldDiscretizationOnNodes { public: - MEDCOUPLING_EXPORT TypeOfField getEnum() const; + MEDCOUPLING_EXPORT TypeOfField getEnum() const override; MEDCOUPLING_EXPORT std::string getClassName() const override { return std::string("MEDCouplingFieldDiscretizationP1"); } MEDCOUPLING_EXPORT MEDCouplingFieldDiscretization *clone() const override; - MEDCOUPLING_EXPORT std::string getStringRepr() const; - MEDCOUPLING_EXPORT const char *getRepr() const; + MEDCOUPLING_EXPORT std::string getStringRepr() const override; + MEDCOUPLING_EXPORT const char *getRepr() const override; MEDCOUPLING_EXPORT void checkCompatibilityWithNature(NatureOfField nat) const override; MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingFieldDiscretization *other, double eps, std::string& reason) const override; MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const override; MEDCOUPLING_EXPORT void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const override; MEDCOUPLING_EXPORT DataArrayDouble *getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, mcIdType nbOfPoints) const override; - MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const; + MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const override; MEDCOUPLING_EXPORT MCAuto aggregate(std::vector& fds) const override; public: static const char REPR[]; @@ -217,14 +222,14 @@ namespace MEDCoupling MEDCouplingFieldDiscretizationPerCell(const MEDCouplingFieldDiscretizationPerCell& other, const mcIdType *startCellIds, const mcIdType *endCellIds); MEDCouplingFieldDiscretizationPerCell(const MEDCouplingFieldDiscretizationPerCell& other, mcIdType beginCellIds, mcIdType endCellIds, mcIdType stepCellIds); MEDCouplingFieldDiscretizationPerCell(DataArrayIdType *dpc); - ~MEDCouplingFieldDiscretizationPerCell(); - void updateTime() const; - std::size_t getHeapMemorySizeWithoutChildren() const; - std::vector getDirectChildrenWithNull() const; - void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArray *da) const; + ~MEDCouplingFieldDiscretizationPerCell() override; + void updateTime() const override; + std::size_t getHeapMemorySizeWithoutChildren() const override; + std::vector getDirectChildrenWithNull() const override; + void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArray *da) const override; bool isEqualIfNotWhy(const MEDCouplingFieldDiscretization *other, double eps, std::string& reason) const override; - bool isEqualWithoutConsideringStr(const MEDCouplingFieldDiscretization *other, double eps) const; - void renumberCells(const mcIdType *old2NewBg, bool check); + bool isEqualWithoutConsideringStr(const MEDCouplingFieldDiscretization *other, double eps) const override; + void renumberCells(const mcIdType *old2NewBg, bool check) override; protected: void buildDiscrPerCellIfNecessary(const MEDCouplingMesh *mesh); protected: @@ -236,63 +241,63 @@ namespace MEDCoupling { public: MEDCOUPLING_EXPORT MEDCouplingFieldDiscretizationGauss(); - MEDCOUPLING_EXPORT TypeOfField getEnum() const; + MEDCOUPLING_EXPORT TypeOfField getEnum() const override; MEDCOUPLING_EXPORT std::string getClassName() const override { return std::string("MEDCouplingFieldDiscretizationGauss"); } MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingFieldDiscretization *other, double eps, std::string& reason) const override; - MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingFieldDiscretization *other, double eps) const; + MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingFieldDiscretization *other, double eps) const override; MEDCOUPLING_EXPORT MEDCouplingFieldDiscretization *clone() const override; - MEDCOUPLING_EXPORT MEDCouplingFieldDiscretization *clonePart(const mcIdType *startCellIds, const mcIdType *endCellIds) const; - MEDCOUPLING_EXPORT MEDCouplingFieldDiscretization *clonePartRange(mcIdType beginCellIds, mcIdType endCellIds, mcIdType stepCellIds) const; - MEDCOUPLING_EXPORT std::string getStringRepr() const; - MEDCOUPLING_EXPORT const char *getRepr() const; - MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; - MEDCOUPLING_EXPORT mcIdType getNumberOfTuplesExpectedRegardingCode(const std::vector& code, const std::vector& idsPerType) const; - MEDCOUPLING_EXPORT mcIdType getNumberOfTuples(const MEDCouplingMesh *mesh) const; - MEDCOUPLING_EXPORT mcIdType getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const; - MEDCOUPLING_EXPORT DataArrayIdType *getOffsetArr(const MEDCouplingMesh *mesh) const; + MEDCOUPLING_EXPORT MEDCouplingFieldDiscretization *clonePart(const mcIdType *startCellIds, const mcIdType *endCellIds) const override; + MEDCOUPLING_EXPORT MEDCouplingFieldDiscretization *clonePartRange(mcIdType beginCellIds, mcIdType endCellIds, mcIdType stepCellIds) const override; + MEDCOUPLING_EXPORT std::string getStringRepr() const override; + MEDCOUPLING_EXPORT const char *getRepr() const override; + MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const override; + MEDCOUPLING_EXPORT mcIdType getNumberOfTuplesExpectedRegardingCode(const std::vector& code, const std::vector& idsPerType) const override; + MEDCOUPLING_EXPORT mcIdType getNumberOfTuples(const MEDCouplingMesh *mesh) const override; + MEDCOUPLING_EXPORT mcIdType getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const override; + MEDCOUPLING_EXPORT DataArrayIdType *getOffsetArr(const MEDCouplingMesh *mesh) const override; MEDCOUPLING_EXPORT void renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector& arrays, - const mcIdType *old2NewBg, bool check); - MEDCOUPLING_EXPORT DataArrayDouble *getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const; + const mcIdType *old2NewBg, bool check) override; + MEDCOUPLING_EXPORT DataArrayDouble *getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const override; MEDCOUPLING_EXPORT void computeMeshRestrictionFromTupleIds(const MEDCouplingMesh *mesh, const mcIdType *tupleIdsBg, const mcIdType *tupleIdsEnd, - DataArrayIdType *&cellRestriction, DataArrayIdType *&trueTupleRestriction) const; + DataArrayIdType *&cellRestriction, DataArrayIdType *&trueTupleRestriction) const override; MEDCOUPLING_EXPORT void checkCompatibilityWithNature(NatureOfField nat) const override; - MEDCOUPLING_EXPORT void getTinySerializationIntInformation(std::vector& tinyInfo) const; - MEDCOUPLING_EXPORT void getTinySerializationDbleInformation(std::vector& tinyInfo) const; - MEDCOUPLING_EXPORT void finishUnserialization(const std::vector& tinyInfo); - MEDCOUPLING_EXPORT void getSerializationIntArray(DataArrayIdType *& arr) const; - MEDCOUPLING_EXPORT void resizeForUnserialization(const std::vector& tinyInfo, DataArrayIdType *& arr); - MEDCOUPLING_EXPORT void checkForUnserialization(const std::vector& tinyInfo, const DataArrayIdType *arr); - MEDCOUPLING_EXPORT double getIJK(const MEDCouplingMesh *mesh, const DataArrayDouble *da, mcIdType cellId, mcIdType nodeIdInCell, int compoId) const; - MEDCOUPLING_EXPORT void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArray *da) const; + MEDCOUPLING_EXPORT void getTinySerializationIntInformation(std::vector& tinyInfo) const override; + MEDCOUPLING_EXPORT void getTinySerializationDbleInformation(std::vector& tinyInfo) const override; + MEDCOUPLING_EXPORT void finishUnserialization(const std::vector& tinyInfo) override; + MEDCOUPLING_EXPORT void getSerializationIntArray(DataArrayIdType *& arr) const override; + MEDCOUPLING_EXPORT void resizeForUnserialization(const std::vector& tinyInfo, DataArrayIdType *& arr) override; + MEDCOUPLING_EXPORT void checkForUnserialization(const std::vector& tinyInfo, const DataArrayIdType *arr) override; + MEDCOUPLING_EXPORT double getIJK(const MEDCouplingMesh *mesh, const DataArrayDouble *da, mcIdType cellId, mcIdType nodeIdInCell, int compoId) const override; + MEDCOUPLING_EXPORT void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArray *da) const override; MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const override; MEDCOUPLING_EXPORT void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const override; - MEDCOUPLING_EXPORT void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, mcIdType i, mcIdType j, mcIdType k, double *res) const; + MEDCOUPLING_EXPORT void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, mcIdType i, mcIdType j, mcIdType k, double *res) const override; MEDCOUPLING_EXPORT DataArrayDouble *getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, mcIdType nbOfPoints) const override; - MEDCOUPLING_EXPORT MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const mcIdType *start, const mcIdType *end, DataArrayIdType *&di) const; - MEDCOUPLING_EXPORT MEDCouplingMesh *buildSubMeshDataRange(const MEDCouplingMesh *mesh, mcIdType beginCellIds, mcIdType endCellIds, mcIdType stepCellIds, mcIdType& beginOut, mcIdType& endOut, mcIdType& stepOut, DataArrayIdType *&di) const; - MEDCOUPLING_EXPORT DataArrayIdType *computeTupleIdsToSelectFromCellIds(const MEDCouplingMesh *mesh, const mcIdType *startCellIds, const mcIdType *endCellIds) const; - MEDCOUPLING_EXPORT void renumberValuesOnNodes(double epsOnVals, const mcIdType *old2New, mcIdType newNbOfNodes, DataArrayDouble *arr) const; - MEDCOUPLING_EXPORT void renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const mcIdType *old2New, mcIdType newSz, DataArrayDouble *arr) const; - MEDCOUPLING_EXPORT void renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const mcIdType *new2old, mcIdType newSz, DataArrayDouble *arr) const; + MEDCOUPLING_EXPORT MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const mcIdType *start, const mcIdType *end, DataArrayIdType *&di) const override; + MEDCOUPLING_EXPORT MEDCouplingMesh *buildSubMeshDataRange(const MEDCouplingMesh *mesh, mcIdType beginCellIds, mcIdType endCellIds, mcIdType stepCellIds, mcIdType& beginOut, mcIdType& endOut, mcIdType& stepOut, DataArrayIdType *&di) const override; + MEDCOUPLING_EXPORT DataArrayIdType *computeTupleIdsToSelectFromCellIds(const MEDCouplingMesh *mesh, const mcIdType *startCellIds, const mcIdType *endCellIds) const override; + MEDCOUPLING_EXPORT void renumberValuesOnNodes(double epsOnVals, const mcIdType *old2New, mcIdType newNbOfNodes, DataArrayDouble *arr) const override; + MEDCOUPLING_EXPORT void renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const mcIdType *old2New, mcIdType newSz, DataArrayDouble *arr) const override; + MEDCOUPLING_EXPORT void renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const mcIdType *new2old, mcIdType newSz, DataArrayDouble *arr) const override; MEDCOUPLING_EXPORT MCAuto aggregate(std::vector& fds) const override; MEDCOUPLING_EXPORT void setGaussLocalizationOnType(const MEDCouplingMesh *mesh, INTERP_KERNEL::NormalizedCellType type, const std::vector& refCoo, - const std::vector& gsCoo, const std::vector& wg); + const std::vector& gsCoo, const std::vector& wg) override; MEDCOUPLING_EXPORT void setGaussLocalizationOnCells(const MEDCouplingMesh *mesh, const mcIdType *begin, const mcIdType *end, const std::vector& refCoo, - const std::vector& gsCoo, const std::vector& wg); - MEDCOUPLING_EXPORT void clearGaussLocalizations(); + const std::vector& gsCoo, const std::vector& wg) override; + MEDCOUPLING_EXPORT void clearGaussLocalizations() override; MEDCOUPLING_EXPORT void setGaussLocalization(mcIdType locId, const MEDCouplingGaussLocalization& loc); MEDCOUPLING_EXPORT void resizeLocalizationVector(mcIdType newSz); - MEDCOUPLING_EXPORT MEDCouplingGaussLocalization& getGaussLocalization(mcIdType locId); - MEDCOUPLING_EXPORT mcIdType getNbOfGaussLocalization() const; - MEDCOUPLING_EXPORT mcIdType getGaussLocalizationIdOfOneCell(mcIdType cellId) const; - MEDCOUPLING_EXPORT mcIdType getGaussLocalizationIdOfOneType(INTERP_KERNEL::NormalizedCellType type) const; - MEDCOUPLING_EXPORT std::set getGaussLocalizationIdsOfOneType(INTERP_KERNEL::NormalizedCellType type) const; - MEDCOUPLING_EXPORT void getCellIdsHavingGaussLocalization(mcIdType locId, std::vector& cellIds) const; - MEDCOUPLING_EXPORT const MEDCouplingGaussLocalization& getGaussLocalization(mcIdType locId) const; + MEDCOUPLING_EXPORT MEDCouplingGaussLocalization& getGaussLocalization(mcIdType locId) override; + MEDCOUPLING_EXPORT mcIdType getNbOfGaussLocalization() const override; + MEDCOUPLING_EXPORT mcIdType getGaussLocalizationIdOfOneCell(mcIdType cellId) const override; + MEDCOUPLING_EXPORT mcIdType getGaussLocalizationIdOfOneType(INTERP_KERNEL::NormalizedCellType type) const override; + MEDCOUPLING_EXPORT std::set getGaussLocalizationIdsOfOneType(INTERP_KERNEL::NormalizedCellType type) const override; + MEDCOUPLING_EXPORT void getCellIdsHavingGaussLocalization(mcIdType locId, std::vector& cellIds) const override; + MEDCOUPLING_EXPORT const MEDCouplingGaussLocalization& getGaussLocalization(mcIdType locId) const override; MEDCOUPLING_EXPORT DataArrayIdType *buildNbOfGaussPointPerCellField() const; - MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const; + MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const override; protected: - MEDCouplingFieldDiscretizationGauss(const MEDCouplingFieldDiscretizationGauss& other, const mcIdType *startCellIds=0, const mcIdType *endCellIds=0); + MEDCouplingFieldDiscretizationGauss(const MEDCouplingFieldDiscretizationGauss& other, const mcIdType *startCellIds=nullptr, const mcIdType *endCellIds=nullptr); MEDCouplingFieldDiscretizationGauss(const MEDCouplingFieldDiscretizationGauss& other, mcIdType beginCellIds, mcIdType endCellIds, mcIdType stepCellIds); MEDCouplingFieldDiscretizationGauss(DataArrayIdType *dpc, const std::vector& loc):MEDCouplingFieldDiscretizationPerCell(dpc),_loc(loc) { } void zipGaussLocalizations(); @@ -313,37 +318,37 @@ namespace MEDCoupling { public: MEDCOUPLING_EXPORT MEDCouplingFieldDiscretizationGaussNE(); - MEDCOUPLING_EXPORT TypeOfField getEnum() const; + MEDCOUPLING_EXPORT TypeOfField getEnum() const override; MEDCOUPLING_EXPORT std::string getClassName() const override { return std::string("MEDCouplingFieldDiscretizationGaussNE"); } MEDCOUPLING_EXPORT MEDCouplingFieldDiscretization *clone() const override; - MEDCOUPLING_EXPORT std::string getStringRepr() const; - MEDCOUPLING_EXPORT const char *getRepr() const; + MEDCOUPLING_EXPORT std::string getStringRepr() const override; + MEDCOUPLING_EXPORT const char *getRepr() const override; MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingFieldDiscretization *other, double eps, std::string& reason) const override; - MEDCOUPLING_EXPORT mcIdType getNumberOfTuplesExpectedRegardingCode(const std::vector& code, const std::vector& idsPerType) const; - MEDCOUPLING_EXPORT mcIdType getNumberOfTuples(const MEDCouplingMesh *mesh) const; - MEDCOUPLING_EXPORT mcIdType getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const; - MEDCOUPLING_EXPORT DataArrayIdType *getOffsetArr(const MEDCouplingMesh *mesh) const; + MEDCOUPLING_EXPORT mcIdType getNumberOfTuplesExpectedRegardingCode(const std::vector& code, const std::vector& idsPerType) const override; + MEDCOUPLING_EXPORT mcIdType getNumberOfTuples(const MEDCouplingMesh *mesh) const override; + MEDCOUPLING_EXPORT mcIdType getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const override; + MEDCOUPLING_EXPORT DataArrayIdType *getOffsetArr(const MEDCouplingMesh *mesh) const override; MEDCOUPLING_EXPORT void renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector& arrays, - const mcIdType *old2NewBg, bool check); - MEDCOUPLING_EXPORT DataArrayDouble *getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const; - MEDCOUPLING_EXPORT void integral(const MEDCouplingMesh *mesh, const DataArrayDouble *arr, bool isWAbs, double *res) const; + const mcIdType *old2NewBg, bool check) override; + MEDCOUPLING_EXPORT DataArrayDouble *getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const override; + MEDCOUPLING_EXPORT void integral(const MEDCouplingMesh *mesh, const DataArrayDouble *arr, bool isWAbs, double *res) const override; MEDCOUPLING_EXPORT void computeMeshRestrictionFromTupleIds(const MEDCouplingMesh *mesh, const mcIdType *tupleIdsBg, const mcIdType *tupleIdsEnd, - DataArrayIdType *&cellRestriction, DataArrayIdType *&trueTupleRestriction) const; + DataArrayIdType *&cellRestriction, DataArrayIdType *&trueTupleRestriction) const override; MEDCOUPLING_EXPORT void checkCompatibilityWithNature(NatureOfField nat) const override; - MEDCOUPLING_EXPORT double getIJK(const MEDCouplingMesh *mesh, const DataArrayDouble *da, mcIdType cellId, mcIdType nodeIdInCell, int compoId) const; - MEDCOUPLING_EXPORT void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArray *da) const; + MEDCOUPLING_EXPORT double getIJK(const MEDCouplingMesh *mesh, const DataArrayDouble *da, mcIdType cellId, mcIdType nodeIdInCell, int compoId) const override; + MEDCOUPLING_EXPORT void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArray *da) const override; MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const override; MEDCOUPLING_EXPORT void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const override; - MEDCOUPLING_EXPORT void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, mcIdType i, mcIdType j, mcIdType k, double *res) const; + MEDCOUPLING_EXPORT void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, mcIdType i, mcIdType j, mcIdType k, double *res) const override; MEDCOUPLING_EXPORT DataArrayDouble *getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, mcIdType nbOfPoints) const override; - MEDCOUPLING_EXPORT MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const mcIdType *start, const mcIdType *end, DataArrayIdType *&di) const; - MEDCOUPLING_EXPORT MEDCouplingMesh *buildSubMeshDataRange(const MEDCouplingMesh *mesh, mcIdType beginCellIds, mcIdType endCellIds, mcIdType stepCellIds, mcIdType& beginOut, mcIdType& endOut, mcIdType& stepOut, DataArrayIdType *&di) const; - MEDCOUPLING_EXPORT DataArrayIdType *computeTupleIdsToSelectFromCellIds(const MEDCouplingMesh *mesh, const mcIdType *startCellIds, const mcIdType *endCellIds) const; - MEDCOUPLING_EXPORT void renumberValuesOnNodes(double epsOnVals, const mcIdType *old2New, mcIdType newNbOfNodes, DataArrayDouble *arr) const; - MEDCOUPLING_EXPORT void renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const mcIdType *old2New, mcIdType newSz, DataArrayDouble *arr) const; - MEDCOUPLING_EXPORT void renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const mcIdType *new2old, mcIdType newSz, DataArrayDouble *arr) const; + MEDCOUPLING_EXPORT MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const mcIdType *start, const mcIdType *end, DataArrayIdType *&di) const override; + MEDCOUPLING_EXPORT MEDCouplingMesh *buildSubMeshDataRange(const MEDCouplingMesh *mesh, mcIdType beginCellIds, mcIdType endCellIds, mcIdType stepCellIds, mcIdType& beginOut, mcIdType& endOut, mcIdType& stepOut, DataArrayIdType *&di) const override; + MEDCOUPLING_EXPORT DataArrayIdType *computeTupleIdsToSelectFromCellIds(const MEDCouplingMesh *mesh, const mcIdType *startCellIds, const mcIdType *endCellIds) const override; + MEDCOUPLING_EXPORT void renumberValuesOnNodes(double epsOnVals, const mcIdType *old2New, mcIdType newNbOfNodes, DataArrayDouble *arr) const override; + MEDCOUPLING_EXPORT void renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const mcIdType *old2New, mcIdType newSz, DataArrayDouble *arr) const override; + MEDCOUPLING_EXPORT void renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const mcIdType *new2old, mcIdType newSz, DataArrayDouble *arr) const override; MEDCOUPLING_EXPORT MCAuto aggregate(std::vector& fds) const override; - MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const; + MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const override; MEDCOUPLING_EXPORT static const double *GetWeightArrayFromGeometricType(INTERP_KERNEL::NormalizedCellType geoType, std::size_t& lgth); MEDCOUPLING_EXPORT static const double *GetRefCoordsFromGeometricType(INTERP_KERNEL::NormalizedCellType geoType, std::size_t& lgth); MEDCOUPLING_EXPORT static const double *GetLocsFromGeometricType(INTERP_KERNEL::NormalizedCellType geoType, std::size_t& lgth); @@ -415,17 +420,17 @@ namespace MEDCoupling class MEDCouplingFieldDiscretizationKriging : public MEDCouplingFieldDiscretizationOnNodes { public: - MEDCOUPLING_EXPORT TypeOfField getEnum() const; + MEDCOUPLING_EXPORT TypeOfField getEnum() const override; MEDCOUPLING_EXPORT std::string getClassName() const override { return std::string("MEDCouplingFieldDiscretizationKriging"); } - MEDCOUPLING_EXPORT const char *getRepr() const; + MEDCOUPLING_EXPORT const char *getRepr() const override; MEDCOUPLING_EXPORT MEDCouplingFieldDiscretization *clone() const override; - MEDCOUPLING_EXPORT std::string getStringRepr() const; + MEDCOUPLING_EXPORT std::string getStringRepr() const override; MEDCOUPLING_EXPORT void checkCompatibilityWithNature(NatureOfField nat) const override; MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingFieldDiscretization *other, double eps, std::string& reason) const override; MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const override; MEDCOUPLING_EXPORT void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const override; MEDCOUPLING_EXPORT DataArrayDouble *getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, mcIdType nbOfPoints) const override; - MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const; + MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const override; MEDCOUPLING_EXPORT MCAuto aggregate(std::vector& fds) const override; public://specific part MEDCOUPLING_EXPORT DataArrayDouble *computeEvaluationMatrixOnGivenPts(const MEDCouplingMesh *mesh, const double *loc, mcIdType nbOfTargetPoints, mcIdType& nbCols) const; diff --git a/src/MEDCoupling/MEDCouplingFieldDiscretizationOnNodesFE.cxx b/src/MEDCoupling/MEDCouplingFieldDiscretizationOnNodesFE.cxx old mode 100755 new mode 100644 index d56bc6d56..89fbd91cd --- a/src/MEDCoupling/MEDCouplingFieldDiscretizationOnNodesFE.cxx +++ b/src/MEDCoupling/MEDCouplingFieldDiscretizationOnNodesFE.cxx @@ -19,14 +19,30 @@ // Author : Anthony Geay (EDF R&D) #include "MEDCouplingFieldDiscretizationOnNodesFE.hxx" +#include "MCAuto.hxx" +#include "MEDCouplingFieldDiscretization.hxx" +#include "MEDCouplingNatureOfFieldEnum" +#include "MEDCouplingMesh.hxx" +#include "MEDCouplingGaussLocalization.hxx" +#include "MEDCouplingMemArray.hxx" +#include "MCType.hxx" #include "MEDCouplingNormalizedUnstructuredMesh.txx" +#include "BBTreeStandAlone.txx" +#include "InterpKernelException.hxx" #include "InterpKernelDenseMatrix.hxx" #include "InterpKernelRootsMultiDim.hxx" #include "MEDCouplingUMesh.hxx" -#include "InterpolationHelper.txx" #include "InterpKernelGaussCoords.hxx" +#include "NormalizedGeometricTypes" +#include "InterpolationHelper.txx" -#include +#include +#include +#include +#include +#include +#include +#include using namespace MEDCoupling; @@ -47,15 +63,15 @@ MCAuto MEDCouplingFieldDiscretizationOnNodesFE:: return EasyAggregate(fds); } -bool MEDCouplingFieldDiscretizationOnNodesFE::isEqualIfNotWhy(const MEDCouplingFieldDiscretization *other, double eps, std::string& reason) const +bool MEDCouplingFieldDiscretizationOnNodesFE::isEqualIfNotWhy(const MEDCouplingFieldDiscretization *other, double /*eps*/, std::string& reason) const { if(!other) { reason="other spatial discretization is NULL, and this spatial discretization (Node FE) is defined."; return false; } - const MEDCouplingFieldDiscretizationOnNodesFE *otherC=dynamic_cast(other); - bool ret=otherC!=0; + const auto *otherC=dynamic_cast(other); + bool const ret=otherC!=nullptr; if(!ret) reason="Spatial discrtization of this is ON_NODES_FE, which is not the case of other."; return ret; @@ -77,7 +93,7 @@ void MEDCouplingFieldDiscretizationOnNodesFE::checkCompatibilityWithNature(Natur throw INTERP_KERNEL::Exception("Invalid nature for NodeFE field : expected IntensiveMaximum !"); } -MEDCouplingFieldDouble *MEDCouplingFieldDiscretizationOnNodesFE::getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const +MEDCouplingFieldDouble *MEDCouplingFieldDiscretizationOnNodesFE::getMeasureField(const MEDCouplingMesh *mesh, bool /*isAbs*/) const { if(!mesh) throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationOnNodesFE::getMeasureField : mesh instance specified is NULL !"); @@ -96,7 +112,7 @@ public: _pts_in_cell(ptsInCell),_point(point) { } std::vector operator()(const std::vector& x) { - MEDCouplingGaussLocalization gl(_gl->getType(),_gl->getRefCoords(),x,{1.0}); + MEDCouplingGaussLocalization const gl(_gl->getType(),_gl->getRefCoords(),x,{1.0}); MCAuto shapeFunc = gl.getShapeFunctionValues(); const double *shapeFuncPtr( shapeFunc->begin() ); std::vector ret(3,0); @@ -113,15 +129,15 @@ public: bool IsInside3D(const MEDCouplingGaussLocalization& gl, const std::vector& ptsInCell, const double locInReal[3], double locInRef[3]) { constexpr double EPS_IN_OUT = 1e-12; - std::size_t nbPtsInCell(ptsInCell.size()/3); + std::size_t const nbPtsInCell(ptsInCell.size()/3); bool ret(false); const double *refCoo(gl.getRefCoords().data()); - INTERP_KERNEL::NormalizedCellType ct(gl.getType()); + INTERP_KERNEL::NormalizedCellType const ct(gl.getType()); Functor func(gl,nbPtsInCell,ptsInCell.data(),locInReal); auto myJacobian = [&gl,nbPtsInCell,ptsInCell](const std::vector& x, const std::vector&, INTERP_KERNEL::DenseMatrix& jacobian) { - MEDCouplingGaussLocalization mygl(gl.getType(),gl.getRefCoords(),x,{1.0}); + MEDCouplingGaussLocalization const mygl(gl.getType(),gl.getRefCoords(),x,{1.0}); MCAuto shapeFunc = mygl.getDerivativeOfShapeFunctionValues(); for(std::size_t i = 0 ; i < 3 ; ++i) for(std::size_t j = 0 ; j < 3 ; ++j) @@ -173,8 +189,8 @@ void MEDCouplingFieldDiscretizationOnNodesFE::GetRefCoordOfListOf3DPtsIn3D(const std::function&)> customFunc) { const double *coordsOfMesh( umesh->getCoords()->begin() ); - MEDCouplingNormalizedUnstructuredMesh<3,3> mesh_wrapper(umesh); - BBTreeStandAlone<3,mcIdType> tree( INTERP_KERNEL::BuildBBTree( mesh_wrapper ) ); + MEDCouplingNormalizedUnstructuredMesh<3,3> const mesh_wrapper(umesh); + BBTreeStandAlone<3,mcIdType> tree( (INTERP_KERNEL::BuildBBTree( mesh_wrapper )) ); for(mcIdType iPt = 0 ; iPt < nbOfPts ; ++iPt) { std::vector elems; @@ -182,11 +198,11 @@ void MEDCouplingFieldDiscretizationOnNodesFE::GetRefCoordOfListOf3DPtsIn3D(const bool found(false); for(auto cellId = elems.cbegin() ; cellId != elems.cend() && !found ; ++cellId) { - INTERP_KERNEL::NormalizedCellType gt( umesh->getTypeOfCell(*cellId) ); + INTERP_KERNEL::NormalizedCellType const gt( umesh->getTypeOfCell(*cellId) ); std::vector conn; umesh->getNodeIdsOfCell(*cellId,conn); MCAuto refCoo( MEDCouplingGaussLocalization::GetDefaultReferenceCoordinatesOf(gt) ); - std::vector refCooCpp(refCoo->begin(),refCoo->end()); + std::vector const refCooCpp(refCoo->begin(),refCoo->end()); std::vector gsCoo(ptsCoo + iPt*3,ptsCoo + (iPt+1)*3); MEDCouplingGaussLocalization gl(gt,refCooCpp,{0,0,0},{1.}); std::vector ptsInCell; ptsInCell.reserve(conn.size()*gl.getDimension()); @@ -206,7 +222,7 @@ void MEDCouplingFieldDiscretizationOnNodesFE::GetRefCoordOfListOf3DPtsIn3D(const const MEDCouplingUMesh *MEDCouplingFieldDiscretizationOnNodesFE::checkConfig3D(const MEDCouplingMesh *mesh) const { - const MEDCouplingUMesh *umesh( dynamic_cast(mesh) ); + const auto *umesh( dynamic_cast(mesh) ); if( !umesh ) THROW_IK_EXCEPTION("getValueOn : not implemented yet for type != MEDCouplingUMesh !"); if(umesh->getSpaceDimension() != 3 || umesh->getMeshDimension() != 3) @@ -219,13 +235,13 @@ DataArrayDouble *MEDCouplingFieldDiscretizationOnNodesFE::getValueOnMulti(const { if(!arr || !arr->isAllocated()) throw INTERP_KERNEL::Exception("getValueOnMulti : input array is null or not allocated !"); - mcIdType nbOfRows=getNumberOfMeshPlaces(mesh); + mcIdType const nbOfRows=getNumberOfMeshPlaces(mesh); if(arr->getNumberOfTuples()!=nbOfRows) { THROW_IK_EXCEPTION( "getValueOnMulti : input array does not have correct number of tuples ! Excepted " << nbOfRows << " having " << arr->getNumberOfTuples() << " !") } const MEDCouplingUMesh *umesh = checkConfig3D(mesh); - std::size_t nbCompo( arr->getNumberOfComponents() ); + std::size_t const nbCompo( arr->getNumberOfComponents() ); MCAuto ret(DataArrayDouble::New()); ret->alloc(nbOfTargetPoints,nbCompo); double *res( ret->getPointer() ); @@ -260,7 +276,7 @@ MCAuto MEDCouplingFieldDiscretizationOnNodesFE::getCooInRefElem ret->alloc(nbOfPoints,3); double *retPtr(ret->getPointer() ); - auto arrayFeeder = [&retPtr](const MEDCouplingGaussLocalization& gl, const std::vector& conn) + auto arrayFeeder = [&retPtr](const MEDCouplingGaussLocalization& gl, const std::vector& /*conn*/) { std::vector resVector( gl.getGaussCoords() ); { diff --git a/src/MEDCoupling/MEDCouplingFieldDiscretizationOnNodesFE.hxx b/src/MEDCoupling/MEDCouplingFieldDiscretizationOnNodesFE.hxx index 2fe400268..276be7c69 100644 --- a/src/MEDCoupling/MEDCouplingFieldDiscretizationOnNodesFE.hxx +++ b/src/MEDCoupling/MEDCouplingFieldDiscretizationOnNodesFE.hxx @@ -20,9 +20,18 @@ #pragma once +#include "MEDCoupling.hxx" +#include "MCAuto.hxx" +#include "MCType.hxx" #include "MEDCouplingFieldDiscretization.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include "MEDCouplingNatureOfFieldEnum" +#include "MEDCouplingGaussLocalization.hxx" #include +#include +#include +#include namespace MEDCoupling { diff --git a/src/MEDCoupling/MEDCouplingFieldDouble.cxx b/src/MEDCoupling/MEDCouplingFieldDouble.cxx old mode 100755 new mode 100644 index c9bbb950f..18f246d45 --- a/src/MEDCoupling/MEDCouplingFieldDouble.cxx +++ b/src/MEDCoupling/MEDCouplingFieldDouble.cxx @@ -19,26 +19,40 @@ // Author : Anthony Geay (EDF R&D) #include "MEDCouplingFieldDouble.hxx" -#include "MEDCouplingFieldTemplate.hxx" #include "MEDCouplingFieldT.txx" +#include "MCAuto.hxx" +#include "MCType.hxx" +#include "MEDCouplingField.hxx" +#include "MCIdType.hxx" +#include "CellModel.hxx" +#include "MEDCouplingFieldTemplate.hxx" #include "MEDCouplingFieldInt32.hxx" #include "MEDCouplingFieldInt64.hxx" #include "MEDCouplingFieldFloat.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include "MEDCouplingPointSet.hxx" +#include "MEDCouplingTraits.hxx" +#include "MEDCouplingNatureOfFieldEnum" +#include "MEDCouplingGaussLocalization.hxx" +#include "MEDCouplingMemArray.hxx" #include "MEDCouplingUMesh.hxx" #include "MEDCouplingTimeDiscretization.hxx" #include "MEDCouplingFieldDiscretization.hxx" -#include "MCAuto.txx" #include "MEDCouplingVoronoi.hxx" -#include "MEDCouplingNatureOfField.hxx" -#include "MEDCouplingMemArray.txx" +#include "MCAuto.txx" #include "InterpKernelAutoPtr.hxx" #include "InterpKernelGaussCoords.hxx" +#include "NormalizedGeometricTypes" +#include +#include #include #include #include #include +#include +#include using namespace MEDCoupling; @@ -206,20 +220,20 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::buildNewTimeReprFromThis(TypeOfT MEDCouplingFieldDouble *MEDCouplingFieldDouble::nodeToCellDiscretization() const { checkConsistencyLight(); - TypeOfField tf(getTypeOfField()); + TypeOfField const tf(getTypeOfField()); if(tf!=ON_NODES) throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::nodeToCellDiscretization : this field is expected to be on ON_NODES !"); MCAuto ret(clone(false)); MCAuto nsp(new MEDCouplingFieldDiscretizationP0); ret->setDiscretization(nsp); const MEDCouplingMesh *m(getMesh());//m is non empty thanks to checkConsistencyLight call - mcIdType nbCells=ToIdType(m->getNumberOfCells()); + mcIdType const nbCells=ToIdType(m->getNumberOfCells()); std::vector arrs(getArrays()); - std::size_t sz(arrs.size()); + std::size_t const sz(arrs.size()); std::vector< MCAuto > outArrsSafe(sz); std::vector outArrs(sz); for(std::size_t j=0;jgetNumberOfComponents()); + std::size_t const nbCompo(arrs[j]->getNumberOfComponents()); outArrsSafe[j]=DataArrayDouble::New(); outArrsSafe[j]->alloc(nbCells,nbCompo); outArrsSafe[j]->copyStringInfoFrom(*arrs[j]); outArrs[j]=outArrsSafe[j]; @@ -230,7 +244,7 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::nodeToCellDiscretization() const std::vector nodeIds; m->getNodeIdsOfCell(i,nodeIds); std::fill(pt,pt+nbCompo,0.); - std::size_t nbNodesInCell(nodeIds.size()); + std::size_t const nbNodesInCell(nodeIds.size()); for(std::size_t k=0;k()); if(nbNodesInCell!=0) @@ -262,7 +276,7 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::nodeToCellDiscretization() const MEDCouplingFieldDouble *MEDCouplingFieldDouble::cellToNodeDiscretization() const { checkConsistencyLight(); - TypeOfField tf(getTypeOfField()); + TypeOfField const tf(getTypeOfField()); if(tf!=ON_CELLS) throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::cellToNodeDiscretization : this field is expected to be on ON_CELLS !"); MCAuto ret(clone(false)); @@ -272,14 +286,14 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::cellToNodeDiscretization() const MCAuto rn(DataArrayIdType::New()),rni(DataArrayIdType::New()); m->getReverseNodalConnectivity(rn,rni); MCAuto rni2(rni->deltaShiftIndex()); - MCAuto rni3(rni2->convertToDblArr()); rni2=0; + MCAuto rni3(rni2->convertToDblArr()); rni2=nullptr; std::vector arrs(getArrays()); - std::size_t sz(arrs.size()); + std::size_t const sz(arrs.size()); std::vector< MCAuto > outArrsSafe(sz); std::vector outArrs(sz); for(std::size_t j=0;j tmp(arrs[j]->selectByTupleIdSafe(rn->begin(),rn->end())); - outArrsSafe[j]=(tmp->accumulatePerChunck(rni->begin(),rni->end())); tmp=0; + outArrsSafe[j]=(tmp->accumulatePerChunck(rni->begin(),rni->end())); tmp=nullptr; outArrsSafe[j]->divideEqual(rni3); outArrsSafe[j]->copyStringInfoFrom(*arrs[j]); outArrs[j]=outArrsSafe[j]; @@ -336,7 +350,7 @@ std::string MEDCouplingFieldDouble::advancedRepr() const std::string MEDCouplingFieldDouble::writeVTK(const std::string& fileName, bool isBinary) const { - std::vector fs(1,this); + std::vector const fs(1,this); return MEDCouplingFieldDouble::WriteVTK(fileName,fs,isBinary); } @@ -349,7 +363,7 @@ bool MEDCouplingFieldDouble::areCompatibleForMerge(const MEDCouplingField *other { if(!MEDCouplingField::areCompatibleForMerge(other)) return false; - const MEDCouplingFieldDouble *otherC(dynamic_cast(other)); + const auto *otherC(dynamic_cast(other)); if(!otherC) return false; if(!timeDiscr()->areCompatible(otherC->timeDiscr())) @@ -391,12 +405,12 @@ bool MEDCouplingFieldDouble::areCompatibleForMeld(const MEDCouplingFieldDouble * */ void MEDCouplingFieldDouble::renumberNodes(const mcIdType *old2NewBg, double eps) { - const MEDCouplingPointSet *meshC=dynamic_cast(_mesh); + const auto *meshC=dynamic_cast(_mesh); if(!meshC) throw INTERP_KERNEL::Exception("Invalid mesh to apply renumberNodes on it !"); - mcIdType nbOfNodes=meshC->getNumberOfNodes(); + mcIdType const nbOfNodes=meshC->getNumberOfNodes(); MCAuto meshC2((MEDCouplingPointSet *)meshC->deepCopy()); - mcIdType newNbOfNodes=*std::max_element(old2NewBg,old2NewBg+nbOfNodes)+1; + mcIdType const newNbOfNodes=*std::max_element(old2NewBg,old2NewBg+nbOfNodes)+1; renumberNodesWithoutMesh(old2NewBg,newNbOfNodes,eps); meshC2->renumberNodes(old2NewBg,newNbOfNodes); setMesh(meshC2); @@ -430,9 +444,9 @@ void MEDCouplingFieldDouble::renumberNodesWithoutMesh(const mcIdType *old2NewBg, throw INTERP_KERNEL::Exception("Expecting a spatial discretization to be able to operate a renumbering !"); std::vector arrays; timeDiscr()->getArrays(arrays); - for(std::vector::const_iterator iter=arrays.begin();iter!=arrays.end();iter++) - if(*iter) - _type->renumberValuesOnNodes(eps,old2NewBg,newNbOfNodes,*iter); + for(auto array : arrays) + if(array) + _type->renumberValuesOnNodes(eps,old2NewBg,newNbOfNodes,array); } /*! @@ -450,7 +464,7 @@ void MEDCouplingFieldDouble::renumberNodesWithoutMesh(const mcIdType *old2NewBg, */ DataArrayIdType *MEDCouplingFieldDouble::findIdsInRange(double vmin, double vmax) const { - if(getArray()==0) + if(getArray()==nullptr) throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::findIdsInRange : no default array set !"); return getArray()->findIdsInRange(vmin,vmax); } @@ -460,7 +474,7 @@ typename Traits::FieldType *ConvertToUField(const MEDCouplingFieldDouble *sel { MCAuto tmp(MEDCouplingFieldTemplate::New(*self)); int t1,t2; - double t0(self->getTime(t1,t2)); + double const t0(self->getTime(t1,t2)); MCAuto::FieldType > ret(Traits::FieldType::New(*tmp,self->getTimeDiscretization())); ret->setTime(t0,t1,t2); if(self->getArray()) @@ -513,7 +527,7 @@ MEDCouplingFieldDouble::MEDCouplingFieldDouble(NatureOfField n, MEDCouplingTimeD */ double MEDCouplingFieldDouble::accumulate(int compId) const { - if(getArray()==0) + if(getArray()==nullptr) throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::accumulate : no default array defined !"); return getArray()->accumulate(compId); } @@ -527,7 +541,7 @@ double MEDCouplingFieldDouble::accumulate(int compId) const */ void MEDCouplingFieldDouble::accumulate(double *res) const { - if(getArray()==0) + if(getArray()==nullptr) throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::accumulate : no default array defined !"); getArray()->accumulate(res); } @@ -546,13 +560,13 @@ double MEDCouplingFieldDouble::getMaxValue() const timeDiscr()->getArrays(arrays); double ret(-std::numeric_limits::max()); bool isExistingArr=false; - for(std::vector::const_iterator iter=arrays.begin();iter!=arrays.end();iter++) + for(auto array : arrays) { - if(*iter) + if(array) { isExistingArr=true; mcIdType loc; - ret=std::max(ret,(*iter)->getMaxValue(loc)); + ret=std::max(ret,array->getMaxValue(loc)); } } if(!isExistingArr) @@ -576,16 +590,16 @@ double MEDCouplingFieldDouble::getMaxValue2(DataArrayIdType*& tupleIds) const timeDiscr()->getArrays(arrays); double ret(-std::numeric_limits::max()); bool isExistingArr=false; - tupleIds=0; + tupleIds=nullptr; MCAuto ret1; - for(std::vector::const_iterator iter=arrays.begin();iter!=arrays.end();iter++) + for(auto array : arrays) { - if(*iter) + if(array) { isExistingArr=true; DataArrayIdType *tmp; - ret=std::max(ret,(*iter)->getMaxValue2(tmp)); - MCAuto tmpSafe(tmp); + ret=std::max(ret,array->getMaxValue2(tmp)); + MCAuto const tmpSafe(tmp); if(!((const DataArrayIdType *)ret1)) ret1=tmpSafe; } @@ -610,13 +624,13 @@ double MEDCouplingFieldDouble::getMinValue() const timeDiscr()->getArrays(arrays); double ret(std::numeric_limits::max()); bool isExistingArr=false; - for(std::vector::const_iterator iter=arrays.begin();iter!=arrays.end();iter++) + for(auto array : arrays) { - if(*iter) + if(array) { isExistingArr=true; mcIdType loc; - ret=std::min(ret,(*iter)->getMinValue(loc)); + ret=std::min(ret,array->getMinValue(loc)); } } if(!isExistingArr) @@ -640,16 +654,16 @@ double MEDCouplingFieldDouble::getMinValue2(DataArrayIdType*& tupleIds) const timeDiscr()->getArrays(arrays); double ret(-std::numeric_limits::max()); bool isExistingArr=false; - tupleIds=0; + tupleIds=nullptr; MCAuto ret1; - for(std::vector::const_iterator iter=arrays.begin();iter!=arrays.end();iter++) + for(auto array : arrays) { - if(*iter) + if(array) { isExistingArr=true; DataArrayIdType *tmp; - ret=std::max(ret,(*iter)->getMinValue2(tmp)); - MCAuto tmpSafe(tmp); + ret=std::max(ret,array->getMinValue2(tmp)); + MCAuto const tmpSafe(tmp); if(!((const DataArrayIdType *)ret1)) ret1=tmpSafe; } @@ -668,7 +682,7 @@ double MEDCouplingFieldDouble::getMinValue2(DataArrayIdType*& tupleIds) const */ double MEDCouplingFieldDouble::getAverageValue() const { - if(getArray()==0) + if(getArray()==nullptr) throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::getAverageValue : no default array defined !"); return getArray()->getAverageValue(); } @@ -682,7 +696,7 @@ double MEDCouplingFieldDouble::getAverageValue() const */ double MEDCouplingFieldDouble::norm2() const { - if(getArray()==0) + if(getArray()==nullptr) throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::norm2 : no default array defined !"); return getArray()->norm2(); } @@ -702,14 +716,14 @@ double MEDCouplingFieldDouble::norm2() const */ void MEDCouplingFieldDouble::getWeightedAverageValue(double *res, bool isWAbs) const { - if(getArray()==0) + if(getArray()==nullptr) throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::getWeightedAverageValue : no default array defined !"); MCAuto w=buildMeasureField(isWAbs); - double deno=w->getArray()->accumulate((std::size_t)0); + double const deno=w->getArray()->accumulate((std::size_t)0); MCAuto arr=getArray()->deepCopy(); arr->multiplyEqual(w->getArray()); arr->accumulate(res); - std::size_t nCompo = getArray()->getNumberOfComponents(); + std::size_t const nCompo = getArray()->getNumberOfComponents(); std::transform(res,res+nCompo,res,std::bind(std::multiplies(),std::placeholders::_1,1./deno)); } @@ -728,7 +742,7 @@ void MEDCouplingFieldDouble::getWeightedAverageValue(double *res, bool isWAbs) c */ double MEDCouplingFieldDouble::getWeightedAverageValue(int compId, bool isWAbs) const { - std::size_t nbComps=getArray()->getNumberOfComponents(); + std::size_t const nbComps=getArray()->getNumberOfComponents(); if(compId<0 || compId>=ToIdType(nbComps)) { std::ostringstream oss; oss << "MEDCouplingFieldDouble::getWeightedAverageValue : Invalid compId specified : No such nb of components ! Should be in [0," << nbComps << ") !"; @@ -756,7 +770,7 @@ double MEDCouplingFieldDouble::normL1(int compId) const throw INTERP_KERNEL::Exception("No mesh underlying this field to perform normL1 !"); if(_type.isNull()) throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform normL1 !"); - std::size_t nbComps=getArray()->getNumberOfComponents(); + std::size_t const nbComps=getArray()->getNumberOfComponents(); if(compId<0 || compId>=ToIdType(nbComps)) { std::ostringstream oss; oss << "MEDCouplingFieldDouble::normL1 : Invalid compId specified : No such nb of components ! Should be in [0," << nbComps << ") !"; @@ -803,7 +817,7 @@ double MEDCouplingFieldDouble::normL2(int compId) const throw INTERP_KERNEL::Exception("No mesh underlying this field to perform normL2"); if(_type.isNull()) throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform normL2 !"); - std::size_t nbComps=getArray()->getNumberOfComponents(); + std::size_t const nbComps=getArray()->getNumberOfComponents(); if(compId<0 || compId>=ToIdType(nbComps)) { std::ostringstream oss; oss << "MEDCouplingFieldDouble::normL2 : Invalid compId specified : No such nb of components ! Should be in [0," << nbComps << ") !"; @@ -845,9 +859,9 @@ void MEDCouplingFieldDouble::normL2(double *res) const */ double MEDCouplingFieldDouble::normMax(int compId) const { - if(getArray()==0) + if(getArray()==nullptr) throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::normMax : no default array defined !"); - std::size_t nbComps=getArray()->getNumberOfComponents(); + std::size_t const nbComps=getArray()->getNumberOfComponents(); if(compId<0 || compId>=ToIdType(nbComps)) { std::ostringstream oss; oss << "MEDCouplingFieldDouble::normMax : Invalid compId specified : No such nb of components ! Should be in [0," << nbComps << ") !"; @@ -870,7 +884,7 @@ double MEDCouplingFieldDouble::normMax(int compId) const */ void MEDCouplingFieldDouble::normMax(double *res) const { - if(getArray()==0) + if(getArray()==nullptr) throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::normMax : no default array defined !"); getArray()->normMaxPerComponent(res); } @@ -895,7 +909,7 @@ double MEDCouplingFieldDouble::integral(int compId, bool isWAbs) const throw INTERP_KERNEL::Exception("No mesh underlying this field to perform integral"); if(_type.isNull()) throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform integral !"); - std::size_t nbComps=getArray()->getNumberOfComponents(); + std::size_t const nbComps=getArray()->getNumberOfComponents(); if(compId<0 || compId>=ToIdType(nbComps)) { std::ostringstream oss; oss << "MEDCouplingFieldDouble::integral : Invalid compId specified : No such nb of components ! Should be in [0," << nbComps << ") !"; @@ -1030,17 +1044,17 @@ DataArrayDouble *MEDCouplingFieldDouble::getValueOnMulti(const double *spaceLoc, */ void MEDCouplingFieldDouble::getValueOn(const double *spaceLoc, double time, double *res) const { - std::vector< const DataArrayDouble *> arrs=timeDiscr()->getArraysForTime(time); + std::vector< const DataArrayDouble *> const arrs=timeDiscr()->getArraysForTime(time); if(!_mesh) throw INTERP_KERNEL::Exception("No mesh underlying this field to perform getValueOn"); if(_type.isNull()) throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform getValueOn !"); std::vector res2; - for(std::vector< const DataArrayDouble *>::const_iterator iter=arrs.begin();iter!=arrs.end();iter++) + for(auto arr : arrs) { - std::size_t sz=res2.size(); - res2.resize(sz+(*iter)->getNumberOfComponents()); - _type->getValueOn(*iter,_mesh,spaceLoc,&res2[sz]); + std::size_t const sz=res2.size(); + res2.resize(sz+arr->getNumberOfComponents()); + _type->getValueOn(arr,_mesh,spaceLoc,&res2[sz]); } timeDiscr()->getValueForTime(time,res2,res); } @@ -1081,7 +1095,7 @@ MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator=(double value) throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::operator= : no mesh defined !"); if(_type.isNull()) throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform operator = !"); - mcIdType nbOfTuple=_type->getNumberOfTuples(_mesh); + mcIdType const nbOfTuple=_type->getNumberOfTuples(_mesh); timeDiscr()->setOrCreateUniformValueOnAllComponents(nbOfTuple,value); return *this; } @@ -1292,7 +1306,7 @@ void MEDCouplingFieldDouble::applyFunc(int nbOfComp, double val) throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::applyFunc : no mesh defined !"); if(_type.isNull()) throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform applyFunc !"); - mcIdType nbOfTuple=_type->getNumberOfTuples(_mesh); + mcIdType const nbOfTuple=_type->getNumberOfTuples(_mesh); timeDiscr()->setUniformValue(nbOfTuple,nbOfComp,val); } @@ -1472,7 +1486,7 @@ void MEDCouplingFieldDouble::applyFuncFast64(const std::string& func) */ std::size_t MEDCouplingFieldDouble::getNumberOfComponents() const { - if(getArray()==0) + if(getArray()==nullptr) throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::getNumberOfComponents : No array specified !"); return getArray()->getNumberOfComponents(); } @@ -1519,7 +1533,7 @@ mcIdType MEDCouplingFieldDouble::getNumberOfTuples() const */ mcIdType MEDCouplingFieldDouble::getNumberOfValues() const { - if(getArray()==0) + if(getArray()==nullptr) throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::getNumberOfValues : No array specified !"); return getArray()->getNbOfElems(); } @@ -1629,9 +1643,9 @@ double MEDCouplingFieldDouble::getIJK(mcIdType cellId, int nodeIdInCell, int com */ void MEDCouplingFieldDouble::changeUnderlyingMesh(const MEDCouplingMesh *other, int levOfCheck, double precOnMesh, double eps) { - if(_mesh==0 || other==0) + if(_mesh==nullptr || other==nullptr) throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::changeUnderlyingMesh : is expected to operate on not null meshes !"); - DataArrayIdType *cellCor=0,*nodeCor=0; + DataArrayIdType *cellCor=nullptr,*nodeCor=nullptr; other->checkGeoEquivalWith(_mesh,levOfCheck,precOnMesh,cellCor,nodeCor); MCAuto cellCor2(cellCor),nodeCor2(nodeCor); if(cellCor) @@ -1705,7 +1719,7 @@ void MEDCouplingFieldDouble::substractInPlaceDM(const MEDCouplingFieldDouble *f, */ bool MEDCouplingFieldDouble::mergeNodes(double eps, double epsOnVals) { - const MEDCouplingPointSet *meshC=dynamic_cast(_mesh); + const auto *meshC=dynamic_cast(_mesh); if(!meshC) throw INTERP_KERNEL::Exception("Invalid support mesh to apply mergeNodes on it : must be a MEDCouplingPointSet one !"); if(_type.isNull()) @@ -1718,9 +1732,9 @@ bool MEDCouplingFieldDouble::mergeNodes(double eps, double epsOnVals) return ret; std::vector arrays; timeDiscr()->getArrays(arrays); - for(std::vector::const_iterator iter=arrays.begin();iter!=arrays.end();iter++) - if(*iter) - _type->renumberValuesOnNodes(epsOnVals,arr->getConstPointer(),meshC2->getNumberOfNodes(),*iter); + for(auto array : arrays) + if(array) + _type->renumberValuesOnNodes(epsOnVals,arr->getConstPointer(),meshC2->getNumberOfNodes(),array); setMesh(meshC2); return true; } @@ -1744,7 +1758,7 @@ bool MEDCouplingFieldDouble::mergeNodes(double eps, double epsOnVals) */ bool MEDCouplingFieldDouble::mergeNodesCenter(double eps, double epsOnVals) { - const MEDCouplingPointSet *meshC=dynamic_cast(_mesh); + const auto *meshC=dynamic_cast(_mesh); if(!meshC) throw INTERP_KERNEL::Exception("Invalid support mesh to apply mergeNodes on it : must be a MEDCouplingPointSet one !"); if(_type.isNull()) @@ -1757,9 +1771,9 @@ bool MEDCouplingFieldDouble::mergeNodesCenter(double eps, double epsOnVals) return ret; std::vector arrays; timeDiscr()->getArrays(arrays); - for(std::vector::const_iterator iter=arrays.begin();iter!=arrays.end();iter++) - if(*iter) - _type->renumberValuesOnNodes(epsOnVals,arr->getConstPointer(),meshC2->getNumberOfNodes(),*iter); + for(auto array : arrays) + if(array) + _type->renumberValuesOnNodes(epsOnVals,arr->getConstPointer(),meshC2->getNumberOfNodes(),array); setMesh(meshC2); return true; } @@ -1781,21 +1795,21 @@ bool MEDCouplingFieldDouble::mergeNodesCenter(double eps, double epsOnVals) */ bool MEDCouplingFieldDouble::zipCoords(double epsOnVals) { - const MEDCouplingPointSet *meshC=dynamic_cast(_mesh); + const auto *meshC=dynamic_cast(_mesh); if(!meshC) throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::zipCoords : Invalid support mesh to apply zipCoords on it : must be a MEDCouplingPointSet one !"); if(_type.isNull()) throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform zipCoords !"); MCAuto meshC2((MEDCouplingPointSet *)meshC->deepCopy()); - mcIdType oldNbOfNodes=meshC2->getNumberOfNodes(); + mcIdType const oldNbOfNodes=meshC2->getNumberOfNodes(); MCAuto arr=meshC2->zipCoordsTraducer(); if(meshC2->getNumberOfNodes()!=oldNbOfNodes) { std::vector arrays; timeDiscr()->getArrays(arrays); - for(std::vector::const_iterator iter=arrays.begin();iter!=arrays.end();iter++) - if(*iter) - _type->renumberValuesOnNodes(epsOnVals,arr->getConstPointer(),meshC2->getNumberOfNodes(),*iter); + for(auto array : arrays) + if(array) + _type->renumberValuesOnNodes(epsOnVals,arr->getConstPointer(),meshC2->getNumberOfNodes(),array); setMesh(meshC2); return true; } @@ -1822,21 +1836,21 @@ bool MEDCouplingFieldDouble::zipCoords(double epsOnVals) */ bool MEDCouplingFieldDouble::zipConnectivity(int compType, double epsOnVals) { - const MEDCouplingUMesh *meshC=dynamic_cast(_mesh); + const auto *meshC=dynamic_cast(_mesh); if(!meshC) throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::zipConnectivity : Invalid support mesh to apply zipCoords on it : must be a MEDCouplingPointSet one !"); if(_type.isNull()) throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform zipConnectivity !"); MCAuto meshC2((MEDCouplingUMesh *)meshC->deepCopy()); - mcIdType oldNbOfCells(meshC2->getNumberOfCells()); + mcIdType const oldNbOfCells(meshC2->getNumberOfCells()); MCAuto arr=meshC2->zipConnectivityTraducer(compType); if(meshC2->getNumberOfCells()!=oldNbOfCells) { std::vector arrays; timeDiscr()->getArrays(arrays); - for(std::vector::const_iterator iter=arrays.begin();iter!=arrays.end();iter++) - if(*iter) - _type->renumberValuesOnCells(epsOnVals,meshC,arr->getConstPointer(),ToIdType(meshC2->getNumberOfCells()),*iter); + for(auto array : arrays) + if(array) + _type->renumberValuesOnCells(epsOnVals,meshC,arr->getConstPointer(),ToIdType(meshC2->getNumberOfCells()),array); setMesh(meshC2); return true; } @@ -1859,11 +1873,11 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::extractSlice3D(const double *ori const MCAuto umesh(mesh->buildUnstructured()); MCAuto ret(clone(false)); ret->setMesh(umesh); - DataArrayIdType *cellIds=0; + DataArrayIdType *cellIds=nullptr; MCAuto mesh2=umesh->buildSlice3D(origin,vec,eps,cellIds); - MCAuto cellIds2=cellIds; + MCAuto const cellIds2=cellIds; ret->setMesh(mesh2); - MCAuto tupleIds=computeTupleIdsToSelectFromCellIds(cellIds->begin(),cellIds->end()); + MCAuto const tupleIds=computeTupleIdsToSelectFromCellIds(cellIds->begin(),cellIds->end()); std::vector arrays; timeDiscr()->getArrays(arrays); int i=0; @@ -1902,17 +1916,17 @@ bool MEDCouplingFieldDouble::simplexize(int policy) throw INTERP_KERNEL::Exception("No underlying mesh on this field to perform simplexize !"); if(_type.isNull()) throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform simplexize !"); - std::size_t oldNbOfCells=_mesh->getNumberOfCells(); + std::size_t const oldNbOfCells=_mesh->getNumberOfCells(); MCAuto meshC2(_mesh->deepCopy()); MCAuto arr=meshC2->simplexize(policy); - std::size_t newNbOfCells=meshC2->getNumberOfCells(); + std::size_t const newNbOfCells=meshC2->getNumberOfCells(); if(oldNbOfCells==newNbOfCells) return false; std::vector arrays; timeDiscr()->getArrays(arrays); - for(std::vector::const_iterator iter=arrays.begin();iter!=arrays.end();iter++) - if(*iter) - _type->renumberValuesOnCellsR(_mesh,arr->getConstPointer(),ToIdType(arr->getNbOfElems()),*iter); + for(auto array : arrays) + if(array) + _type->renumberValuesOnCellsR(_mesh,arr->getConstPointer(),ToIdType(arr->getNbOfElems()),array); setMesh(meshC2); return true; } @@ -1984,25 +1998,25 @@ MCAuto MEDCouplingFieldDouble::convertQuadraticCellsToLi if(!mesh) throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::convertQuadraticCellsToLinear : null mesh !"); MCAuto umesh(mesh->buildUnstructured()); - std::set gt(umesh->getAllGeoTypes()); + std::set const gt(umesh->getAllGeoTypes()); MCAuto ret(MEDCouplingFieldDouble::New(ON_GAUSS_PT)); // const MEDCouplingFieldDiscretization *disc(getDiscretization()); - const MEDCouplingFieldDiscretizationGauss *disc2(dynamic_cast(disc)); + const auto *disc2(dynamic_cast(disc)); if(!disc2) throw INTERP_KERNEL::Exception("convertQuadraticCellsToLinear : Not a ON_GAUSS_PT field"); - std::set gt2(umesh->getAllGeoTypes()); + std::set const gt2(umesh->getAllGeoTypes()); std::vector< MCAuto > cellIdsV; std::vector< MCAuto > meshesV; std::vector< MEDCouplingGaussLocalization > glV; bool isZipReq(false); - for(std::set::const_iterator it=gt.begin();it!=gt.end();it++) + for(auto it : gt) { - const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(*it)); - MCAuto cellIds(umesh->giveCellsWithType(*it)); + const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(it)); + MCAuto cellIds(umesh->giveCellsWithType(it)); cellIdsV.push_back(cellIds); MCAuto part(umesh->buildPartOfMySelf(cellIds->begin(),cellIds->end())); - mcIdType id(disc2->getGaussLocalizationIdOfOneType(*it)); + mcIdType const id(disc2->getGaussLocalizationIdOfOneType(it)); const MEDCouplingGaussLocalization& gl(disc2->getGaussLocalization(id)); if(!cm.isQuadratic()) { @@ -2012,9 +2026,9 @@ MCAuto MEDCouplingFieldDouble::convertQuadraticCellsToLi { isZipReq=true; part->convertQuadraticCellsToLinear(); - INTERP_KERNEL::GaussInfo gi(*it,gl.getGaussCoords(),gl.getNumberOfGaussPt(),gl.getRefCoords(),gl.getNumberOfPtsInRefCell()); - INTERP_KERNEL::GaussInfo gi2(gi.convertToLinear()); - MEDCouplingGaussLocalization gl2(gi2.getGeoType(),gi2.getRefCoords(),gi2.getGaussCoords(),gl.getWeights()); + INTERP_KERNEL::GaussInfo const gi(it,gl.getGaussCoords(),gl.getNumberOfGaussPt(),gl.getRefCoords(),gl.getNumberOfPtsInRefCell()); + INTERP_KERNEL::GaussInfo const gi2(gi.convertToLinear()); + MEDCouplingGaussLocalization const gl2(gi2.getGeoType(),gi2.getRefCoords(),gi2.getGaussCoords(),gl.getWeights()); glV.push_back(gl2); } meshesV.push_back(part); @@ -2033,8 +2047,8 @@ MCAuto MEDCouplingFieldDouble::convertQuadraticCellsToLi umesh->zipCoords(); ret->setArray(const_cast(getArray())); ret->setMesh(umesh); - for(std::vector< MEDCouplingGaussLocalization >::const_iterator it=glV.begin();it!=glV.end();it++) - ret->setGaussLocalizationOnType((*it).getType(),(*it).getRefCoords(),(*it).getGaussCoords(),(*it).getWeights()); + for(const auto & it : glV) + ret->setGaussLocalizationOnType(it.getType(),it.getRefCoords(),it.getGaussCoords(),it.getWeights()); ret->copyAllTinyAttrFrom(this); ret->checkConsistencyLight(); return ret; @@ -2395,7 +2409,7 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::MergeFields(const std::vector > ms(a.size()); std::vector< const MEDCouplingUMesh *> ms2(a.size()); std::vector< const MEDCouplingTimeDiscretization *> tds(a.size()); - std::vector< const MEDCouplingFieldDouble *>::const_iterator it=a.begin(); + auto it=a.begin(); std::vector fds(a.size()); const MEDCouplingFieldDouble *ref((*it++)); if(!ref) @@ -2412,7 +2426,7 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::MergeFields(const std::vectorgetMesh()) { ms[i]=a[i]->getMesh()->buildUnstructured(); ms2[i]=ms[i]; } else - { ms[i]=0; ms2[i]=0; } + { ms[i]=nullptr; ms2[i]=nullptr; } tds[i]=a[i]->timeDiscr(); fds[i]=a[i]->getDiscretization(); } @@ -2481,7 +2495,7 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::DotFields(const MEDCouplingField throw INTERP_KERNEL::Exception("Fields are not compatible. Unable to apply DotFields on them! Check support mesh, and spatial and time discretisation."); MEDCouplingTimeDiscretization *td(f1->timeDiscr()->dot(f2->timeDiscr())); td->copyTinyAttrFrom(*f1->timeDiscr()); - MEDCouplingFieldDouble *ret(new MEDCouplingFieldDouble(NoNature,td,f1->_type->clone())); + auto *ret(new MEDCouplingFieldDouble(NoNature,td,f1->_type->clone())); ret->setMesh(f1->getMesh()); return ret; } @@ -2864,7 +2878,7 @@ std::string MEDCouplingFieldDouble::WriteVTK(const std::string& fileName, const { if(fs.empty()) return std::string(); - std::size_t nfs=fs.size(); + std::size_t const nfs=fs.size(); if(!fs[0]) throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::WriteVTK : 1st instance of field is NULL !"); const MEDCouplingMesh *m=fs[0]->getMesh(); @@ -2883,13 +2897,13 @@ std::string MEDCouplingFieldDouble::WriteVTK(const std::string& fileName, const for(std::size_t i=0;igetName()); + std::string const name(cur->getName()); if(name.empty()) { std::ostringstream oss; oss << "MEDCouplingFieldDouble::WriteVTK : Field in pos #" << i << " has no name !"; throw INTERP_KERNEL::Exception(oss.str()); } - TypeOfField typ=cur->getTypeOfField(); + TypeOfField const typ=cur->getTypeOfField(); if(typ==ON_CELLS) cur->getArray()->writeVTK(coss,8,cur->getName(),byteArr); else if(typ==ON_NODES) @@ -2909,7 +2923,7 @@ MCAuto MEDCouplingFieldDouble::voronoizeGen(const Voroni MCAuto fieldToWO; const MEDCouplingMesh *inpMeshBase(getMesh()); MCAuto inpMesh(inpMeshBase->buildUnstructured()); - std::string meshName(inpMesh->getName()); + std::string const meshName(inpMesh->getName()); if(!inpMesh->isPresenceOfQuadratic()) fieldToWO=clone(false); else @@ -2918,12 +2932,12 @@ MCAuto MEDCouplingFieldDouble::voronoizeGen(const Voroni inpMeshBase=fieldToWO->getMesh(); inpMesh=inpMeshBase->buildUnstructured(); } - mcIdType nbCells(inpMesh->getNumberOfCells()); + mcIdType const nbCells(inpMesh->getNumberOfCells()); const MEDCouplingFieldDiscretization *disc(fieldToWO->getDiscretization()); - const MEDCouplingFieldDiscretizationGauss *disc2(dynamic_cast(disc)); + const auto *disc2(dynamic_cast(disc)); if(!disc2) throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::voronoize2D : Not a ON_GAUSS_PT field"); - mcIdType nbLocs(disc2->getNbOfGaussLocalization()); + mcIdType const nbLocs(disc2->getNbOfGaussLocalization()); std::vector< MCAuto > cells(nbCells); for(mcIdType i=0;i MEDCouplingFieldDouble::voronoizeGen(const Voroni MCAuto coo2(DataArrayDouble::NewFromStdVector(coo)); coo2->rearrange(vor->getDimension()); // - MCAuto coo3(MEDCouplingUMesh::Build0DMeshFromCoords(coo2)); + MCAuto const coo3(MEDCouplingUMesh::Build0DMeshFromCoords(coo2)); // MCAuto vorCellsForCurDisc(vor->doIt(mesh,coo2,eps)); std::vector ids; @@ -2945,7 +2959,7 @@ MCAuto MEDCouplingFieldDouble::voronoizeGen(const Voroni MCAuto subMesh(inpMesh->buildPartOfMySelf(&ids[0],&ids[0]+ids.size())); ptsInReal=gl.localizePtsInRefCooForEachCell(vorCellsForCurDisc->getCoords(),subMesh); } - mcIdType nbPtsPerCell(vorCellsForCurDisc->getNumberOfNodes()); + mcIdType const nbPtsPerCell(vorCellsForCurDisc->getNumberOfNodes()); for(mcIdType j=0;j elt(vorCellsForCurDisc->clone(false)); @@ -2966,7 +2980,7 @@ MCAuto MEDCouplingFieldDouble::voronoizeGen(const Voroni onCells->setTimeUnit(getTimeUnit()); { int b,c; - double a(getTime(b,c)); + double const a(getTime(b,c)); onCells->setTime(a,b,c); } onCells->setName(getName()); @@ -2977,8 +2991,8 @@ MEDCouplingTimeDiscretization *MEDCouplingFieldDouble::timeDiscr() { MEDCouplingTimeDiscretizationTemplate *ret(_time_discr); if(!ret) - return 0; - MEDCouplingTimeDiscretization *retc(dynamic_cast(ret)); + return nullptr; + auto *retc(dynamic_cast(ret)); if(!retc) throw INTERP_KERNEL::Exception("Field Double Null invalid type of time discr !"); return retc; @@ -2988,8 +3002,8 @@ const MEDCouplingTimeDiscretization *MEDCouplingFieldDouble::timeDiscr() const { const MEDCouplingTimeDiscretizationTemplate *ret(_time_discr); if(!ret) - return 0; - const MEDCouplingTimeDiscretization *retc(dynamic_cast(ret)); + return nullptr; + const auto *retc(dynamic_cast(ret)); if(!retc) throw INTERP_KERNEL::Exception("Field Double Null invalid type of time discr !"); return retc; diff --git a/src/MEDCoupling/MEDCouplingFieldDouble.hxx b/src/MEDCoupling/MEDCouplingFieldDouble.hxx index 4905b8ee7..335f677a5 100644 --- a/src/MEDCoupling/MEDCouplingFieldDouble.hxx +++ b/src/MEDCoupling/MEDCouplingFieldDouble.hxx @@ -21,9 +21,20 @@ #ifndef __MEDCOUPLINGFIELDDOUBLE_HXX__ #define __MEDCOUPLINGFIELDDOUBLE_HXX__ +#include "MCType.hxx" +#include "MCAuto.hxx" #include "MEDCoupling.hxx" +#include "MEDCouplingField.hxx" +#include "MEDCouplingFieldDiscretization.hxx" #include "MEDCouplingFieldT.hxx" #include "MEDCouplingMemArray.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include +#include "MEDCouplingTraits.hxx" +#include +#include +#include "MEDCouplingTimeDiscretization.hxx" +#include "MEDCouplingNatureOfFieldEnum" namespace MEDCoupling { @@ -39,13 +50,13 @@ namespace MEDCoupling MEDCOUPLING_EXPORT void synchronizeTimeWithSupport(); MEDCOUPLING_EXPORT std::string advancedRepr() const; MEDCOUPLING_EXPORT std::string writeVTK(const std::string& fileName, bool isBinary=true) const; - MEDCOUPLING_EXPORT bool areCompatibleForMerge(const MEDCouplingField *other) const; + MEDCOUPLING_EXPORT bool areCompatibleForMerge(const MEDCouplingField *other) const override; MEDCOUPLING_EXPORT bool areCompatibleForMeld(const MEDCouplingFieldDouble *other) const; MEDCOUPLING_EXPORT void renumberNodes(const mcIdType *old2NewBg, double eps=1e-15); MEDCOUPLING_EXPORT void renumberNodesWithoutMesh(const mcIdType *old2NewBg, mcIdType newNbOfNodes, double eps=1e-15); MEDCOUPLING_EXPORT DataArrayIdType *findIdsInRange(double vmin, double vmax) const; MEDCOUPLING_EXPORT MEDCouplingFieldDouble *deepCopy() const; - MEDCOUPLING_EXPORT MEDCouplingFieldDouble *clone(bool recDeepCpy) const; + MEDCOUPLING_EXPORT MEDCouplingFieldDouble *clone(bool recDeepCpy) const override; MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildNewTimeReprFromThis(TypeOfTimeDiscretization td, bool deepCpy) const; MEDCOUPLING_EXPORT MEDCouplingFieldDouble *nodeToCellDiscretization() const; MEDCOUPLING_EXPORT MEDCouplingFieldDouble *cellToNodeDiscretization() const; @@ -93,9 +104,9 @@ namespace MEDCoupling MEDCOUPLING_EXPORT std::size_t getNumberOfComponents() const; MEDCOUPLING_EXPORT mcIdType getNumberOfTuples() const; MEDCOUPLING_EXPORT mcIdType getNumberOfValues() const; - MEDCOUPLING_EXPORT void updateTime() const; - MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; - MEDCOUPLING_EXPORT std::vector getDirectChildrenWithNull() const; + MEDCOUPLING_EXPORT void updateTime() const override; + MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const override; + MEDCOUPLING_EXPORT std::vector getDirectChildrenWithNull() const override; // MEDCOUPLING_EXPORT void changeUnderlyingMesh(const MEDCouplingMesh *other, int levOfCheck, double precOnMesh, double eps=1e-15); MEDCOUPLING_EXPORT void substractInPlaceDM(const MEDCouplingFieldDouble *f, int levOfCheck, double precOnMesh, double eps=1e-15); @@ -154,7 +165,7 @@ namespace MEDCoupling MEDCOUPLING_EXPORT const MEDCouplingTimeDiscretization *getTimeDiscretizationUnderGround() const { return timeDiscr(); } MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *getTimeDiscretizationUnderGround() { return timeDiscr(); } protected: - ~MEDCouplingFieldDouble() { } + ~MEDCouplingFieldDouble() override = default; private: MEDCOUPLING_EXPORT MEDCouplingFieldDouble(TypeOfField type, TypeOfTimeDiscretization td); MEDCOUPLING_EXPORT MEDCouplingFieldDouble(const MEDCouplingFieldTemplate& ft, TypeOfTimeDiscretization td); diff --git a/src/MEDCoupling/MEDCouplingFieldFloat.cxx b/src/MEDCoupling/MEDCouplingFieldFloat.cxx index a66119060..0702daff5 100644 --- a/src/MEDCoupling/MEDCouplingFieldFloat.cxx +++ b/src/MEDCoupling/MEDCouplingFieldFloat.cxx @@ -20,12 +20,18 @@ #include "MEDCouplingFieldFloat.hxx" #include "MEDCouplingFieldT.txx" +#include "MEDCouplingFieldDiscretization.hxx" +#include "MCAuto.hxx" +#include "MCType.hxx" #include "MEDCouplingFieldDouble.hxx" -#include "MEDCouplingFieldInt.hxx" +#include "MEDCouplingFieldInt32.hxx" #include "MEDCouplingFieldInt64.hxx" #include "MEDCouplingFieldTemplate.hxx" #include "MEDCouplingMesh.hxx" -#include "MEDCouplingMemArray.txx" +#include "MEDCouplingRefCountObject.hxx" +#include "MEDCouplingTimeDiscretization.hxx" +#include "MEDCouplingNatureOfFieldEnum" +#include "MEDCouplingTraits.hxx" using namespace MEDCoupling; diff --git a/src/MEDCoupling/MEDCouplingFieldFloat.hxx b/src/MEDCoupling/MEDCouplingFieldFloat.hxx index bd2f29ee6..8b3bcc77f 100644 --- a/src/MEDCoupling/MEDCouplingFieldFloat.hxx +++ b/src/MEDCoupling/MEDCouplingFieldFloat.hxx @@ -22,8 +22,12 @@ #define __MEDCOUPLINGFIELDFLOAT_HXX__ #include "MEDCoupling.hxx" +#include "MEDCouplingFieldDiscretization.hxx" #include "MEDCouplingFieldT.hxx" -#include "MEDCouplingMemArray.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include "MEDCouplingTraits.hxx" +#include "MEDCouplingNatureOfFieldEnum" +#include "MEDCouplingTimeDiscretization.hxx" #include @@ -38,7 +42,7 @@ namespace MEDCoupling MEDCOUPLING_EXPORT static MEDCouplingFieldFloat *New(TypeOfField type, TypeOfTimeDiscretization td=ONE_TIME); MEDCOUPLING_EXPORT static MEDCouplingFieldFloat *New(const MEDCouplingFieldTemplate& ft, TypeOfTimeDiscretization td=ONE_TIME); MEDCOUPLING_EXPORT MEDCouplingFieldFloat *deepCopy() const; - MEDCOUPLING_EXPORT MEDCouplingFieldFloat *clone(bool recDeepCpy) const; + MEDCOUPLING_EXPORT MEDCouplingFieldFloat *clone(bool recDeepCpy) const override; MEDCOUPLING_EXPORT MEDCouplingFieldDouble *convertToDblField() const; MEDCOUPLING_EXPORT MEDCouplingFieldInt32 *convertToIntField() const; MEDCOUPLING_EXPORT MEDCouplingFieldInt64 *convertToInt64Field() const; @@ -48,7 +52,7 @@ namespace MEDCoupling MEDCouplingFieldFloat(const MEDCouplingFieldFloat& other, bool deepCpy); MEDCouplingFieldFloat(NatureOfField n, MEDCouplingTimeDiscretizationFloat *td, MEDCouplingFieldDiscretization *type); MEDCouplingFieldFloat(const MEDCouplingFieldTemplate& ft, TypeOfTimeDiscretization td); - ~MEDCouplingFieldFloat() { } + ~MEDCouplingFieldFloat() override = default; }; } diff --git a/src/MEDCoupling/MEDCouplingFieldInt32.cxx b/src/MEDCoupling/MEDCouplingFieldInt32.cxx index edea743c2..363a25636 100644 --- a/src/MEDCoupling/MEDCouplingFieldInt32.cxx +++ b/src/MEDCoupling/MEDCouplingFieldInt32.cxx @@ -19,13 +19,19 @@ // Author : Yann Pora (EDF R&D) #include "MEDCouplingFieldInt32.hxx" +#include "MCType.hxx" +#include "MEDCouplingFieldDiscretization.hxx" +#include "MCAuto.hxx" #include "MEDCouplingFieldInt64.hxx" #include "MEDCouplingFieldT.txx" #include "MEDCouplingFieldDouble.hxx" #include "MEDCouplingFieldFloat.hxx" #include "MEDCouplingFieldTemplate.hxx" #include "MEDCouplingMesh.hxx" -#include "MEDCouplingMemArray.txx" +#include "MEDCouplingRefCountObject.hxx" +#include "MEDCouplingTimeDiscretization.hxx" +#include "MEDCouplingNatureOfFieldEnum" +#include "MEDCouplingTraits.hxx" using namespace MEDCoupling; @@ -75,7 +81,7 @@ typename Traits::FieldType *ConvertToUField(const MEDCouplingFieldInt32 *self { MCAuto tmp(MEDCouplingFieldTemplate::New(*self)); int t1,t2; - double t0(self->getTime(t1,t2)); + double const t0(self->getTime(t1,t2)); MCAuto::FieldType > ret(Traits::FieldType::New(*tmp,self->getTimeDiscretization())); ret->setTime(t0,t1,t2); if(self->getArray()) @@ -99,4 +105,4 @@ MEDCouplingFieldInt64 *MEDCouplingFieldInt32::convertToInt64Field() const MEDCouplingFieldFloat *MEDCouplingFieldInt32::convertToFloatField() const { return ConvertToUField(this); -} \ No newline at end of file +} diff --git a/src/MEDCoupling/MEDCouplingFieldInt32.hxx b/src/MEDCoupling/MEDCouplingFieldInt32.hxx index b664ffe36..4b55cb264 100644 --- a/src/MEDCoupling/MEDCouplingFieldInt32.hxx +++ b/src/MEDCoupling/MEDCouplingFieldInt32.hxx @@ -20,9 +20,14 @@ #pragma once +#include "MCType.hxx" #include "MEDCoupling.hxx" +#include "MEDCouplingFieldDiscretization.hxx" #include "MEDCouplingFieldT.hxx" -#include "MEDCouplingMemArray.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include "MEDCouplingTraits.hxx" +#include "MEDCouplingNatureOfFieldEnum" +#include "MEDCouplingTimeDiscretization.hxx" #include @@ -37,7 +42,7 @@ namespace MEDCoupling MEDCOUPLING_EXPORT static MEDCouplingFieldInt32 *New(TypeOfField type, TypeOfTimeDiscretization td=ONE_TIME); MEDCOUPLING_EXPORT static MEDCouplingFieldInt32 *New(const MEDCouplingFieldTemplate& ft, TypeOfTimeDiscretization td=ONE_TIME); MEDCOUPLING_EXPORT MEDCouplingFieldInt32 *deepCopy() const; - MEDCOUPLING_EXPORT MEDCouplingFieldInt32 *clone(bool recDeepCpy) const; + MEDCOUPLING_EXPORT MEDCouplingFieldInt32 *clone(bool recDeepCpy) const override; MEDCOUPLING_EXPORT MEDCouplingFieldDouble *convertToDblField() const; MEDCOUPLING_EXPORT MEDCouplingFieldFloat *convertToFloatField() const; MEDCOUPLING_EXPORT MEDCouplingFieldInt64 *convertToInt64Field() const; @@ -47,6 +52,6 @@ namespace MEDCoupling MEDCouplingFieldInt32(const MEDCouplingFieldInt32& other, bool deepCopy); MEDCouplingFieldInt32(NatureOfField n, MEDCouplingTimeDiscretizationInt32 *td, MEDCouplingFieldDiscretization *type); MEDCouplingFieldInt32(const MEDCouplingFieldTemplate& ft, TypeOfTimeDiscretization td); - ~MEDCouplingFieldInt32() { } + ~MEDCouplingFieldInt32() override = default; }; } diff --git a/src/MEDCoupling/MEDCouplingFieldInt64.cxx b/src/MEDCoupling/MEDCouplingFieldInt64.cxx index cf26a258f..96f086008 100644 --- a/src/MEDCoupling/MEDCouplingFieldInt64.cxx +++ b/src/MEDCoupling/MEDCouplingFieldInt64.cxx @@ -20,10 +20,15 @@ #include "MEDCouplingFieldInt64.hxx" #include "MEDCouplingFieldT.txx" +#include "MCType.hxx" +#include "MEDCouplingFieldDiscretization.hxx" +#include "MCAuto.hxx" #include "MEDCouplingFieldDouble.hxx" #include "MEDCouplingFieldTemplate.hxx" #include "MEDCouplingMesh.hxx" -#include "MEDCouplingMemArray.txx" +#include "MEDCouplingRefCountObject.hxx" +#include "MEDCouplingTimeDiscretization.hxx" +#include "MEDCouplingNatureOfFieldEnum" using namespace MEDCoupling; @@ -72,7 +77,7 @@ MEDCouplingFieldDouble *MEDCouplingFieldInt64::convertToDblField() const { MCAuto tmp(MEDCouplingFieldTemplate::New(*this)); int t1,t2; - double t0(getTime(t1,t2)); + double const t0(getTime(t1,t2)); MCAuto ret(MEDCouplingFieldDouble::New(*tmp,getTimeDiscretization())); ret->setTime(t0,t1,t2); if(getArray()) diff --git a/src/MEDCoupling/MEDCouplingFieldInt64.hxx b/src/MEDCoupling/MEDCouplingFieldInt64.hxx index 242b6bcc2..e754354a3 100644 --- a/src/MEDCoupling/MEDCouplingFieldInt64.hxx +++ b/src/MEDCoupling/MEDCouplingFieldInt64.hxx @@ -20,9 +20,13 @@ #pragma once +#include "MCType.hxx" #include "MEDCoupling.hxx" +#include "MEDCouplingFieldDiscretization.hxx" #include "MEDCouplingFieldT.hxx" -#include "MEDCouplingMemArray.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include "MEDCouplingNatureOfFieldEnum" +#include "MEDCouplingTimeDiscretization.hxx" #include @@ -37,7 +41,7 @@ namespace MEDCoupling MEDCOUPLING_EXPORT static MEDCouplingFieldInt64 *New(TypeOfField type, TypeOfTimeDiscretization td=ONE_TIME); MEDCOUPLING_EXPORT static MEDCouplingFieldInt64 *New(const MEDCouplingFieldTemplate& ft, TypeOfTimeDiscretization td=ONE_TIME); MEDCOUPLING_EXPORT MEDCouplingFieldInt64 *deepCopy() const; - MEDCOUPLING_EXPORT MEDCouplingFieldInt64 *clone(bool recDeepCpy) const; + MEDCOUPLING_EXPORT MEDCouplingFieldInt64 *clone(bool recDeepCpy) const override; MEDCOUPLING_EXPORT MEDCouplingFieldDouble *convertToDblField() const; MEDCOUPLING_EXPORT std::string getClassName() const override { return std::string("MEDCouplingFieldInt64"); } protected: @@ -45,6 +49,6 @@ namespace MEDCoupling MEDCouplingFieldInt64(const MEDCouplingFieldInt64& other, bool deepCopy); MEDCouplingFieldInt64(NatureOfField n, MEDCouplingTimeDiscretizationInt64 *td, MEDCouplingFieldDiscretization *type); MEDCouplingFieldInt64(const MEDCouplingFieldTemplate& ft, TypeOfTimeDiscretization td); - ~MEDCouplingFieldInt64() { } + ~MEDCouplingFieldInt64() override = default; }; } diff --git a/src/MEDCoupling/MEDCouplingFieldOverTime.cxx b/src/MEDCoupling/MEDCouplingFieldOverTime.cxx index 20d61cbc4..0598c5989 100644 --- a/src/MEDCoupling/MEDCouplingFieldOverTime.cxx +++ b/src/MEDCoupling/MEDCouplingFieldOverTime.cxx @@ -19,9 +19,17 @@ // Author : Anthony Geay (CEA/DEN) #include "MEDCouplingFieldOverTime.hxx" +#include "MCAuto.hxx" +#include "MEDCouplingDefinitionTime.hxx" #include "MEDCouplingMesh.hxx" +#include "MEDCouplingMultiFields.hxx" +#include "MEDCouplingRefCountObject.hxx" #include +#include +#include +#include +#include using namespace MEDCoupling; @@ -32,11 +40,11 @@ MEDCouplingFieldOverTime *MEDCouplingFieldOverTime::New(const std::vector >::const_iterator it=_fs.begin(); + auto it=_fs.begin(); if(_fs.empty()) throw INTERP_KERNEL::Exception("MEDCouplingFieldOverTime::getTimeTolerance : empty set !"); for(;it!=_fs.end();it++) - if((const MEDCouplingFieldDouble *)(*it)!=0) + if((const MEDCouplingFieldDouble *)(*it)!=nullptr) return (*it)->getTimeTolerance(); throw INTERP_KERNEL::Exception("MEDCouplingFieldOverTime::getTimeTolerance : only empty fields in this !"); } @@ -44,7 +52,7 @@ double MEDCouplingFieldOverTime::getTimeTolerance() const void MEDCouplingFieldOverTime::checkConsistencyLight() const { MEDCouplingMultiFields::checkConsistencyLight(); - std::vector< MCAuto >::const_iterator it=_fs.begin(); + auto it=_fs.begin(); for(;it!=_fs.end();it++) if((*it)->getTimeDiscretization()==NO_TIME) { @@ -57,7 +65,7 @@ void MEDCouplingFieldOverTime::checkConsistencyLight() const const MEDCouplingFieldDouble& ref=*(*(it++)); int tt1,tt2; double reft=ref.getEndTime(tt1,tt2); - double eps=getTimeTolerance(); + double const eps=getTimeTolerance(); int id=1; for(;it!=_fs.end();it++,id++) { @@ -66,7 +74,7 @@ void MEDCouplingFieldOverTime::checkConsistencyLight() const std::ostringstream oss; oss << "Field slice at rank #" << id << " is not compatible with the first !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - double curt=(*it)->getStartTime(tt1,tt2); + double const curt=(*it)->getStartTime(tt1,tt2); if(curtgetEndTime(tt1,tt2); @@ -91,7 +99,7 @@ std::string MEDCouplingFieldOverTime::simpleRepr() const { ret << "Current instance is INVALID !\n"; } try { - MEDCouplingDefinitionTime dt=getDefinitionTimeZone(); + MEDCouplingDefinitionTime const dt=getDefinitionTimeZone(); dt.appendRepr(ret); } catch(INTERP_KERNEL::Exception& /*e*/) @@ -103,7 +111,7 @@ bool MEDCouplingFieldOverTime::isEqual(const MEDCouplingMultiFields *other, doub { if(!MEDCouplingMultiFields::isEqual(other,meshPrec,valsPrec)) return false; - const MEDCouplingFieldOverTime *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) return false; // to implement @@ -114,7 +122,7 @@ bool MEDCouplingFieldOverTime::isEqualWithoutConsideringStr(const MEDCouplingMul { if(!MEDCouplingMultiFields::isEqualWithoutConsideringStr(other,meshPrec,valsPrec)) return false; - const MEDCouplingFieldOverTime *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) return false; // to implement @@ -149,7 +157,7 @@ MEDCouplingDefinitionTime MEDCouplingFieldOverTime::getDefinitionTimeZone() cons { std::vector< std::vector > tmp; getDifferentArrays(tmp); - std::vector tmp2(_fs.begin(),_fs.end()); + std::vector const tmp2(_fs.begin(),_fs.end()); std::vector tmp3; getDifferentMeshes(tmp3); return MEDCouplingDefinitionTime(tmp2,tmp3,tmp); @@ -161,5 +169,4 @@ MEDCouplingFieldOverTime::MEDCouplingFieldOverTime(const std::vector #include namespace MEDCoupling @@ -33,18 +35,18 @@ namespace MEDCoupling { public: MEDCOUPLING_EXPORT static MEDCouplingFieldOverTime *New(const std::vector& fs); - MEDCOUPLING_EXPORT void checkConsistencyLight() const; + MEDCOUPLING_EXPORT void checkConsistencyLight() const override; MEDCOUPLING_EXPORT double getTimeTolerance() const; - MEDCOUPLING_EXPORT std::string simpleRepr() const; - MEDCOUPLING_EXPORT bool isEqual(const MEDCouplingMultiFields *other, double meshPrec, double valsPrec) const; - MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingMultiFields *other, double meshPrec, double valsPrec) const; + MEDCOUPLING_EXPORT std::string simpleRepr() const override; + MEDCOUPLING_EXPORT bool isEqual(const MEDCouplingMultiFields *other, double meshPrec, double valsPrec) const override; + MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingMultiFields *other, double meshPrec, double valsPrec) const override; //void getIdsToFetch(double time, int& fieldId, int& arrId, int& meshId) const; //void setFieldOnId(int fieldId, MEDCouplingFieldDouble *f); //void dispatchPointers(); - MEDCOUPLING_EXPORT std::vector getMeshes() const; - MEDCOUPLING_EXPORT std::vector getDifferentMeshes(std::vector& refs) const; - MEDCOUPLING_EXPORT std::vector getArrays() const; - MEDCOUPLING_EXPORT std::vector getDifferentArrays(std::vector< std::vector >& refs) const; + MEDCOUPLING_EXPORT std::vector getMeshes() const override; + MEDCOUPLING_EXPORT std::vector getDifferentMeshes(std::vector& refs) const override; + MEDCOUPLING_EXPORT std::vector getArrays() const override; + MEDCOUPLING_EXPORT std::vector getDifferentArrays(std::vector< std::vector >& refs) const override; MEDCOUPLING_EXPORT MEDCouplingDefinitionTime getDefinitionTimeZone() const; protected: MEDCOUPLING_EXPORT MEDCouplingFieldOverTime(); diff --git a/src/MEDCoupling/MEDCouplingFieldT.hxx b/src/MEDCoupling/MEDCouplingFieldT.hxx index 25b6bf7a0..bf72c6025 100644 --- a/src/MEDCoupling/MEDCouplingFieldT.hxx +++ b/src/MEDCoupling/MEDCouplingFieldT.hxx @@ -20,11 +20,19 @@ #pragma once +#include "MEDCoupling.hxx" +#include "MCType.hxx" #include "MEDCouplingField.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include "MEDCouplingFieldDiscretization.hxx" +#include "MEDCouplingNatureOfFieldEnum" #include "MEDCouplingTraits.hxx" #include "MEDCouplingTimeDiscretization.hxx" -#include +#include +#include +#include +#include namespace MEDCoupling { @@ -39,11 +47,11 @@ namespace MEDCoupling MEDCouplingFieldT(const MEDCouplingField& other, MEDCouplingTimeDiscretizationTemplate *timeDiscr, bool deepCopy=true); MEDCouplingFieldT(TypeOfField type, MEDCouplingTimeDiscretizationTemplate *timeDiscr); MEDCouplingFieldT(MEDCouplingFieldDiscretization *type, NatureOfField n, MEDCouplingTimeDiscretizationTemplate *timeDiscr); - ~MEDCouplingFieldT(); + ~MEDCouplingFieldT() override; public: MEDCOUPLING_EXPORT TypeOfTimeDiscretization getTimeDiscretization() const; MEDCOUPLING_EXPORT virtual typename Traits::FieldType *clone(bool recDeepCpy) const = 0; - MEDCOUPLING_EXPORT void checkConsistencyLight() const; + MEDCOUPLING_EXPORT void checkConsistencyLight() const override; MEDCOUPLING_EXPORT typename Traits::FieldType *cloneWithMesh(bool recDeepCpy) const; MEDCOUPLING_EXPORT typename Traits::FieldType *buildSubPart(const DataArrayIdType *part) const; MEDCOUPLING_EXPORT typename Traits::FieldType *buildSubPart(const mcIdType *partBg, const mcIdType *partEnd) const; @@ -77,11 +85,11 @@ namespace MEDCoupling MEDCOUPLING_EXPORT virtual bool isEqual(const MEDCouplingFieldT *other, double meshPrec, T valsPrec) const; MEDCOUPLING_EXPORT virtual bool isEqualIfNotWhy(const MEDCouplingFieldT *other, double meshPrec, T valsPrec, std::string& reason) const; MEDCOUPLING_EXPORT virtual bool isEqualWithoutConsideringStr(const MEDCouplingFieldT *other, double meshPrec, T valsPrec) const; - MEDCOUPLING_EXPORT void copyTinyStringsFrom(const MEDCouplingField *other); - MEDCOUPLING_EXPORT bool areStrictlyCompatible(const MEDCouplingField *other) const; - MEDCOUPLING_EXPORT bool areStrictlyCompatibleForMulDiv(const MEDCouplingField *other) const; + MEDCOUPLING_EXPORT void copyTinyStringsFrom(const MEDCouplingField *other) override; + MEDCOUPLING_EXPORT bool areStrictlyCompatible(const MEDCouplingField *other) const override; + MEDCOUPLING_EXPORT bool areStrictlyCompatibleForMulDiv(const MEDCouplingField *other) const override; MEDCOUPLING_EXPORT std::string simpleRepr() const; - MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const; + MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const override; // specific MEDCOUPLING_EXPORT bool areCompatibleForMul(const MEDCouplingField *other) const; MEDCOUPLING_EXPORT bool areCompatibleForDiv(const MEDCouplingField *other) const; diff --git a/src/MEDCoupling/MEDCouplingFieldT.txx b/src/MEDCoupling/MEDCouplingFieldT.txx index d2c1903c4..28b6eb0e1 100644 --- a/src/MEDCoupling/MEDCouplingFieldT.txx +++ b/src/MEDCoupling/MEDCouplingFieldT.txx @@ -21,11 +21,27 @@ #ifndef __MEDCOUPLINGFIELDT_TXX__ #define __MEDCOUPLINGFIELDT_TXX__ -#include "MEDCouplingTimeDiscretization.hxx" +#include "MCAuto.hxx" +#include "InterpKernelException.hxx" +#include "MEDCouplingFieldT.hxx" #include "MEDCouplingMesh.hxx" +#include "MCType.hxx" +#include "MEDCouplingNatureOfField.hxx" +#include "MEDCouplingNatureOfFieldEnum" +#include "MEDCouplingField.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include "MEDCouplingTraits.hxx" + +#include +#include +#include +#include +#include namespace MEDCoupling { + class DataArray; + template MEDCouplingFieldT::MEDCouplingFieldT(const MEDCouplingFieldT& other, bool deepCopy):MEDCouplingField(other,deepCopy),_time_discr(other._time_discr->performCopyOrIncrRef(deepCopy)) { diff --git a/src/MEDCoupling/MEDCouplingFieldTemplate.cxx b/src/MEDCoupling/MEDCouplingFieldTemplate.cxx index 78bc9651e..6b6956fd2 100644 --- a/src/MEDCoupling/MEDCouplingFieldTemplate.cxx +++ b/src/MEDCoupling/MEDCouplingFieldTemplate.cxx @@ -19,14 +19,24 @@ // Author : Anthony Geay (EDF R&D) #include "MEDCouplingFieldTemplate.hxx" +#include "MCIdType.hxx" +#include "MCAuto.hxx" +#include "MEDCouplingField.hxx" +#include "MCType.hxx" #include "MEDCouplingMesh.hxx" #include "MEDCouplingFieldInt32.hxx" #include "MEDCouplingFieldInt64.hxx" #include "MEDCouplingFieldFloat.hxx" #include "MEDCouplingFieldDouble.hxx" #include "MEDCouplingFieldDiscretization.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include "MEDCouplingNatureOfField.hxx" +#include "MEDCouplingNatureOfFieldEnum" +#include #include +#include +#include using namespace MEDCoupling; @@ -132,7 +142,7 @@ MEDCouplingFieldTemplate::MEDCouplingFieldTemplate(const MEDCouplingFieldTemplat void MEDCouplingFieldTemplate::checkConsistencyLight() const { - if(_mesh==0) + if(_mesh==nullptr) throw INTERP_KERNEL::Exception("MEDCouplingFieldTemplate::checkConsistencyLight : Empty mesh !"); } @@ -190,8 +200,8 @@ void MEDCouplingFieldTemplate::resizeForUnserialization(const std::vector tinyInfoITmp(tinyInfoI.begin()+2,tinyInfoI.end()); + dataInt=nullptr; + std::vector const tinyInfoITmp(tinyInfoI.begin()+2,tinyInfoI.end()); _type->resizeForUnserialization(tinyInfoITmp,dataInt); } @@ -213,7 +223,7 @@ void MEDCouplingFieldTemplate::serialize(DataArrayIdType *&dataInt) const void MEDCouplingFieldTemplate::reprQuickOverview(std::ostream& stream) const { stream << "MEDCouplingFieldTemplate C++ instance at " << this << ". Name : \"" << _name << "\"." << std::endl; - const char *nat=0; + const char *nat=nullptr; try { nat=MEDCouplingNatureOfField::GetRepr(_nature); @@ -233,13 +243,13 @@ void MEDCouplingFieldTemplate::reprQuickOverview(std::ostream& stream) const { std::ostringstream oss; _mesh->reprQuickOverview(oss); - std::string tmp(oss.str()); + std::string const tmp(oss.str()); stream << "\nMesh info : " << tmp.substr(0,tmp.find('\n')); } } MCAuto MEDCouplingFieldTemplate::clone(bool recDeepCpy) const { - MCAuto ret(new MEDCouplingFieldTemplate(*this,recDeepCpy)); + MCAuto const ret(new MEDCouplingFieldTemplate(*this,recDeepCpy)); return ret; } diff --git a/src/MEDCoupling/MEDCouplingFieldTemplate.hxx b/src/MEDCoupling/MEDCouplingFieldTemplate.hxx index f9e32107c..ab4f320f4 100644 --- a/src/MEDCoupling/MEDCouplingFieldTemplate.hxx +++ b/src/MEDCoupling/MEDCouplingFieldTemplate.hxx @@ -20,7 +20,14 @@ #pragma once +#include "MEDCoupling.hxx" +#include "MCAuto.hxx" +#include "MCType.hxx" #include "MEDCouplingField.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include +#include +#include namespace MEDCoupling { @@ -56,7 +63,7 @@ namespace MEDCoupling MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingFieldTemplate *other, double meshPrec) const; MEDCOUPLING_EXPORT std::string simpleRepr() const; MEDCOUPLING_EXPORT std::string advancedRepr() const; - MEDCOUPLING_EXPORT void checkConsistencyLight() const; + MEDCOUPLING_EXPORT void checkConsistencyLight() const override; MEDCOUPLING_EXPORT MCAuto clone(bool recDeepCpy) const; // MEDCOUPLING_EXPORT void getTinySerializationIntInformation(std::vector& tinyInfo) const; @@ -66,7 +73,7 @@ namespace MEDCoupling MEDCOUPLING_EXPORT void finishUnserialization(const std::vector& tinyInfoI, const std::vector& tinyInfoD, const std::vector& tinyInfoS); MEDCOUPLING_EXPORT void serialize(DataArrayIdType *&dataInt) const; // - MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const; + MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const override; private: MEDCouplingFieldTemplate(const MEDCouplingFieldDouble& f, bool isChecked=true); MEDCouplingFieldTemplate(const MEDCouplingFieldFloat& f, bool isChecked=true); diff --git a/src/MEDCoupling/MEDCouplingGaussLocalization.cxx b/src/MEDCoupling/MEDCouplingGaussLocalization.cxx index ec2daf562..76a587d72 100644 --- a/src/MEDCoupling/MEDCouplingGaussLocalization.cxx +++ b/src/MEDCoupling/MEDCouplingGaussLocalization.cxx @@ -19,16 +19,26 @@ // Author : Anthony Geay (CEA/DEN) #include "MEDCouplingGaussLocalization.hxx" +#include "InterpKernelException.hxx" #include "InterpKernelGaussCoords.hxx" +#include "MCAuto.hxx" +#include "MCIdType.hxx" +#include "MCType.hxx" #include "MEDCoupling1GTUMesh.hxx" +#include "MEDCouplingMemArray.hxx" #include "MEDCouplingUMesh.hxx" #include "CellModel.hxx" +#include "NormalizedGeometricTypes" #include -#include -#include +#include +#include #include +#include +#include #include +#include +#include using namespace MEDCoupling; @@ -56,8 +66,8 @@ void MEDCouplingGaussLocalization::setType(INTERP_KERNEL::NormalizedCellType typ void MEDCouplingGaussLocalization::checkConsistencyLight() const { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_type); - int nbNodes=cm.getNumberOfNodes(); - int dim=cm.getDimension(); + int const nbNodes=cm.getNumberOfNodes(); + int const dim=cm.getDimension(); if(!cm.isDynamic()) { if(ToIdType(_ref_coord.size())!=nbNodes*dim) @@ -89,7 +99,7 @@ int MEDCouplingGaussLocalization::getNumberOfPtsInRefCell() const const INTERP_KERNEL::CellModel& cm = INTERP_KERNEL::CellModel::GetCellModel(_type); return ((int)_ref_coord.size()) / ((int)cm.getDimension()); } - int dim( getDimension() ); + int const dim( getDimension() ); return (int)_ref_coord.size()/dim; } @@ -128,8 +138,8 @@ bool MEDCouplingGaussLocalization::isEqual(const MEDCouplingGaussLocalization& o double MEDCouplingGaussLocalization::getRefCoord(int ptIdInCell, int comp) const { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_type); - int nbNodes=cm.getNumberOfNodes(); - int dim=cm.getDimension(); + int const nbNodes=cm.getNumberOfNodes(); + int const dim=cm.getDimension(); if(ptIdInCell<0 || ptIdInCell>=nbNodes) throw INTERP_KERNEL::Exception("ptIdInCell specified is invalid : must be in [0;nbNodesPerCell) !"); if(comp<0 || comp>=dim) @@ -139,7 +149,7 @@ double MEDCouplingGaussLocalization::getRefCoord(int ptIdInCell, int comp) const double MEDCouplingGaussLocalization::getGaussCoord(int gaussPtIdInCell, int comp) const { - int dim=checkCoherencyOfRequest(gaussPtIdInCell,comp); + int const dim=checkCoherencyOfRequest(gaussPtIdInCell,comp); return _gauss_coord[gaussPtIdInCell*dim+comp]; } @@ -206,12 +216,12 @@ MCAuto MEDCouplingGaussLocalization::localizePtsInRefCooForEach ptsInRefCoo->checkAllocated(); mesh->checkConsistencyLight(); // - mcIdType nbCells=mesh->getNumberOfCells(); + mcIdType const nbCells=mesh->getNumberOfCells(); const double *coords(mesh->getCoords()->begin()); const mcIdType *connI(mesh->getNodalConnectivityIndex()->begin()),*conn(mesh->getNodalConnectivity()->begin()); // - mcIdType nbPts(ptsInRefCoo->getNumberOfTuples()); - INTERP_KERNEL::NormalizedCellType typ(getType()); + mcIdType const nbPts(ptsInRefCoo->getNumberOfTuples()); + INTERP_KERNEL::NormalizedCellType const typ(getType()); int dim(INTERP_KERNEL::CellModel::GetCellModel(typ).getDimension()),outDim(mesh->getSpaceDimension()); MCAuto ret(DataArrayDouble::New()); ret->alloc(nbPts*nbCells,outDim); @@ -258,7 +268,7 @@ MCAuto MEDCouplingGaussLocalization::getShapeFunctionValues() c double *retPtr(ret->getPointer()); for(int iGaussPt = 0 ; iGaussPt < nbGaussPt ; ++iGaussPt) { - std::vector curGaussPt(_gauss_coord.begin()+iGaussPt*dim,_gauss_coord.begin()+(iGaussPt+1)*dim); + std::vector const curGaussPt(_gauss_coord.begin()+iGaussPt*dim,_gauss_coord.begin()+(iGaussPt+1)*dim); INTERP_KERNEL::GaussInfo gi(_type,curGaussPt,1,_ref_coord,nbPtsRefCell); gi.initLocalInfo(); const double *funcVal( gi.getFunctionValues(0) ); @@ -276,7 +286,7 @@ MCAuto MEDCouplingGaussLocalization::getDerivativeOfShapeFuncti double *retPtr(ret->getPointer()); for(int iGaussPt = 0 ; iGaussPt < nbGaussPt ; ++iGaussPt) { - std::vector curGaussPt(_gauss_coord.begin()+iGaussPt*dim,_gauss_coord.begin()+(iGaussPt+1)*dim); + std::vector const curGaussPt(_gauss_coord.begin()+iGaussPt*dim,_gauss_coord.begin()+(iGaussPt+1)*dim); INTERP_KERNEL::GaussInfo gi(_type,curGaussPt,1,_ref_coord,nbPtsRefCell); gi.initLocalInfo(); const double *devOfFuncVal( gi.getDerivativeOfShapeFunctionAt(0) ); @@ -293,8 +303,8 @@ MCAuto MEDCouplingGaussLocalization::getDerivativeOfShapeFuncti void MEDCouplingGaussLocalization::setRefCoord(int ptIdInCell, int comp, double newVal) { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_type); - int nbNodes=cm.getNumberOfNodes(); - int dim=cm.getDimension(); + int const nbNodes=cm.getNumberOfNodes(); + int const dim=cm.getDimension(); if(ptIdInCell<0 || ptIdInCell>=nbNodes) throw INTERP_KERNEL::Exception("ptIdInCell specified is invalid : must be in [0;nbNodesPerCell) !"); if(comp<0 || comp>=dim) @@ -304,7 +314,7 @@ void MEDCouplingGaussLocalization::setRefCoord(int ptIdInCell, int comp, double void MEDCouplingGaussLocalization::setGaussCoord(int gaussPtIdInCell, int comp, double newVal) { - int dim=checkCoherencyOfRequest(gaussPtIdInCell,comp); + int const dim=checkCoherencyOfRequest(gaussPtIdInCell,comp); _gauss_coord[gaussPtIdInCell*dim+comp]=newVal; } @@ -341,8 +351,8 @@ MEDCouplingGaussLocalization MEDCouplingGaussLocalization::BuildNewInstanceFromT int MEDCouplingGaussLocalization::checkCoherencyOfRequest(mcIdType gaussPtIdInCell, int comp) const { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_type); - int dim=cm.getDimension(); - mcIdType nbGsPts=getNumberOfGaussPt(); + int const dim=cm.getDimension(); + mcIdType const nbGsPts=getNumberOfGaussPt(); if(gaussPtIdInCell<0 || gaussPtIdInCell>=nbGsPts) throw INTERP_KERNEL::Exception("gaussPtIdInCell specified is invalid : must be in [0:nbGsPts) !"); if(comp<0 || comp>=dim) @@ -352,7 +362,7 @@ int MEDCouplingGaussLocalization::checkCoherencyOfRequest(mcIdType gaussPtIdInCe bool MEDCouplingGaussLocalization::AreAlmostEqual(const std::vector& v1, const std::vector& v2, double eps) { - std::size_t sz=v1.size(); + std::size_t const sz=v1.size(); if(sz!=v2.size()) return false; std::vector tmp(sz); @@ -366,7 +376,7 @@ MCAuto MEDCouplingGaussLocalization::GetDefaultReferenceCoordin std::vector retCpp(INTERP_KERNEL::GaussInfo::GetDefaultReferenceCoordinatesOf(type)); const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(type); auto nbDim(cm.getDimension()); - std::size_t sz(retCpp.size()); + std::size_t const sz(retCpp.size()); MCAuto ret(DataArrayDouble::New()); if( sz%std::size_t(nbDim) != 0 ) THROW_IK_EXCEPTION("GetDefaultReferenceCoordinatesOf : unexpected size of defaut array : " << sz << " % " << nbDim << " != 0 !"); diff --git a/src/MEDCoupling/MEDCouplingGaussLocalization.hxx b/src/MEDCoupling/MEDCouplingGaussLocalization.hxx index 29d617231..67935ade9 100644 --- a/src/MEDCoupling/MEDCouplingGaussLocalization.hxx +++ b/src/MEDCoupling/MEDCouplingGaussLocalization.hxx @@ -21,11 +21,14 @@ #ifndef __PARAMEDMEM_MEDCOUPLINGGAUSSLOCALIZATION_HXX__ #define __PARAMEDMEM_MEDCOUPLINGGAUSSLOCALIZATION_HXX__ +#include "MCType.hxx" +#include "MCAuto.hxx" #include "MEDCoupling.hxx" -#include "NormalizedUnstructuredMesh.hxx" #include "MEDCouplingMemArray.hxx" -#include "InterpKernelException.hxx" +#include "NormalizedGeometricTypes" +#include +#include #include namespace MEDCoupling diff --git a/src/MEDCoupling/MEDCouplingIMesh.cxx b/src/MEDCoupling/MEDCouplingIMesh.cxx old mode 100755 new mode 100644 index faa588c2a..7e4462c02 --- a/src/MEDCoupling/MEDCouplingIMesh.cxx +++ b/src/MEDCoupling/MEDCouplingIMesh.cxx @@ -19,14 +19,26 @@ // Author : Anthony Geay (EDF R&D) #include "MEDCouplingIMesh.hxx" +#include "MCType.hxx" +#include "MCAuto.hxx" +#include "MCIdType.hxx" #include "MEDCouplingCMesh.hxx" -#include "MEDCouplingMemArray.hxx" +#include "MEDCouplingMemArray.txx" #include "MEDCouplingFieldDouble.hxx" +#include "MEDCouplingStructuredMesh.hxx" +#include "MEDCouplingMesh.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include +#include #include #include +#include +#include #include #include +#include +#include using namespace MEDCoupling; @@ -45,8 +57,7 @@ MEDCouplingIMesh::MEDCouplingIMesh(const MEDCouplingIMesh& other, bool deepCpy): } MEDCouplingIMesh::~MEDCouplingIMesh() -{ -} += default; MEDCouplingIMesh *MEDCouplingIMesh::New() { @@ -93,7 +104,7 @@ MEDCouplingIMesh *MEDCouplingIMesh::buildWithGhost(mcIdType ghostLev) const if(ghostLev<0) throw INTERP_KERNEL::Exception("MEDCouplingIMesh::buildWithGhost : the ghostLev must be >= 0 !"); checkConsistencyLight(); - int spaceDim(getSpaceDimension()); + int const spaceDim(getSpaceDimension()); double origin[3],dxyz[3]; mcIdType structure[3]; for(int i=0;i MEDCouplingIMesh::getNodeStruct() const void MEDCouplingIMesh::setOrigin(const double *originStart, const double *originStop) { checkSpaceDimension(); - mcIdType sz(ToIdType(std::distance(originStart,originStop))); + mcIdType const sz(ToIdType(std::distance(originStart,originStop))); if(sz!=_space_dim) throw INTERP_KERNEL::Exception("MEDCouplingIMesh::setOrigin : input vector of origin vector has not the right size ! Or change space dimension before calling it !"); std::copy(originStart,originStop,_origin); @@ -142,7 +153,7 @@ std::vector MEDCouplingIMesh::getOrigin() const void MEDCouplingIMesh::setDXYZ(const double *dxyzStart, const double *dxyzStop) { checkSpaceDimension(); - mcIdType sz(ToIdType(std::distance(dxyzStart,dxyzStop))); + mcIdType const sz(ToIdType(std::distance(dxyzStart,dxyzStop))); if(sz!=_space_dim) throw INTERP_KERNEL::Exception("MEDCouplingIMesh::setDXYZ : input vector of dxyz vector has not the right size ! Or change space dimension before calling it !"); std::copy(dxyzStart,dxyzStop,_dxyz); @@ -176,7 +187,7 @@ std::string MEDCouplingIMesh::getAxisUnit() const double MEDCouplingIMesh::getMeasureOfAnyCell() const { checkConsistencyLight(); - int dim(getSpaceDimension()); + int const dim(getSpaceDimension()); double ret(1.); for(int i=0;icopyTinyInfoFrom(this); } catch(INTERP_KERNEL::Exception& ) { } - int spaceDim(getSpaceDimension()); + int const spaceDim(getSpaceDimension()); std::vector infos(buildInfoOnComponents()); for(int i=0;i& factors) std::ostringstream oss; oss << "MEDCouplingIMesh::refineWithFactor : factor for axis #" << i << " (" << factors[i] << ")is invalid ! Must be > 0 !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - mcIdType factAbs(std::abs(factors[i])); - double fact2(1./(double)factors[i]); + mcIdType const factAbs(std::abs(factors[i])); + double const fact2(1./(double)factors[i]); structure[i]=(_structure[i]-1)*factAbs+1; dxyz[i]=fact2*_dxyz[i]; } @@ -287,9 +298,9 @@ void MEDCouplingIMesh::CondenseFineToCoarse(const std::vector& coarseS throw INTERP_KERNEL::Exception("MEDCouplingIMesh::CondenseFineToCoarse : All input vectors (dimension) must have the same size !"); if(!coarseDA || !coarseDA->isAllocated() || !fineDA || !fineDA->isAllocated()) throw INTERP_KERNEL::Exception("MEDCouplingIMesh::CondenseFineToCoarse : the parameters 1 or 3 are NULL or not allocated !"); - std::size_t meshDim(coarseSt.size()); + std::size_t const meshDim(coarseSt.size()); mcIdType nbOfTuplesInCoarseExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(coarseSt)),nbOfTuplesInFineExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenRangeInCompactFrmt(fineLocInCoarse)); - std::size_t nbCompo=fineDA->getNumberOfComponents(); + std::size_t const nbCompo=fineDA->getNumberOfComponents(); if(coarseDA->getNumberOfComponents()!=nbCompo) throw INTERP_KERNEL::Exception("MEDCouplingIMesh::CondenseFineToCoarse : the number of components of fine DA and coarse one mismatches !"); if(meshDim!=fineLocInCoarse.size() || meshDim!=facts.size()) @@ -299,7 +310,7 @@ void MEDCouplingIMesh::CondenseFineToCoarse(const std::vector& coarseS std::ostringstream oss; oss << "MEDCouplingIMesh::CondenseFineToCoarse : Expecting " << nbOfTuplesInCoarseExp << " tuples having " << coarseDA->getNumberOfTuples() << " !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - mcIdType nbTuplesFine(fineDA->getNumberOfTuples()); + mcIdType const nbTuplesFine(fineDA->getNumberOfTuples()); if(nbOfTuplesInFineExp==0) { if(nbTuplesFine==0) @@ -309,7 +320,7 @@ void MEDCouplingIMesh::CondenseFineToCoarse(const std::vector& coarseS } if(nbTuplesFine%nbOfTuplesInFineExp!=0) throw INTERP_KERNEL::Exception("MEDCouplingIMesh::CondenseFineToCoarse : Invalid nb of tuples in fine DataArray regarding its structure !"); - mcIdType fact(std::accumulate(facts.begin(),facts.end(),1,std::multiplies())); + mcIdType const fact(std::accumulate(facts.begin(),facts.end(),1,std::multiplies())); if(nbTuplesFine!=fact*nbOfTuplesInFineExp) { std::ostringstream oss; oss << "MEDCouplingIMesh::CondenseFineToCoarse : Invalid number of tuples (" << nbTuplesFine << ") of fine dataarray is invalid ! Must be " << fact*nbOfTuplesInFineExp << "!"; @@ -418,9 +429,9 @@ void MEDCouplingIMesh::CondenseFineToCoarseGhost(const std::vector& co if(!coarseDA || !coarseDA->isAllocated() || !fineDA || !fineDA->isAllocated()) throw INTERP_KERNEL::Exception("MEDCouplingIMesh::CondenseFineToCoarseGhost : the parameters 1 or 3 are NULL or not allocated !"); std::vector coarseStG(coarseSt.size()); std::transform(coarseSt.begin(),coarseSt.end(),coarseStG.begin(),std::bind(std::plus(),std::placeholders::_1,2*ghostSize)); - std::size_t meshDim(coarseSt.size()); - mcIdType nbOfTuplesInCoarseExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(coarseStG)); - std::size_t nbCompo(fineDA->getNumberOfComponents()); + std::size_t const meshDim(coarseSt.size()); + mcIdType const nbOfTuplesInCoarseExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(coarseStG)); + std::size_t const nbCompo(fineDA->getNumberOfComponents()); if(coarseDA->getNumberOfComponents()!=nbCompo) throw INTERP_KERNEL::Exception("MEDCouplingIMesh::CondenseFineToCoarseGhost : the number of components of fine DA and coarse one mismatches !"); if(meshDim!=fineLocInCoarse.size() || meshDim!=facts.size()) @@ -466,7 +477,7 @@ void MEDCouplingIMesh::CondenseFineToCoarseGhost(const std::vector& co } case 2: { - mcIdType nxwg(coarseSt[0]+2*ghostSize); + mcIdType const nxwg(coarseSt[0]+2*ghostSize); mcIdType kk(fineLocInCoarse[0].first+ghostSize+nxwg*(fineLocInCoarse[1].first+ghostSize)),fact1(facts[1]),fact0(facts[0]); inPtr+=(dims[0]*fact0+2*ghostSize)*ghostSize*nbCompo; for(int j=0;j& co inPtr+=ghostSize*(dims[0]*fact0+2*ghostSize)*nbCompo; for(int j=0;jisAllocated() || !fineDA || !fineDA->isAllocated()) throw INTERP_KERNEL::Exception("MEDCouplingIMesh::SpreadCoarseToFine : the parameters 1 or 3 are NULL or not allocated !"); - std::size_t meshDim(coarseSt.size()); + std::size_t const meshDim(coarseSt.size()); mcIdType nbOfTuplesInCoarseExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(coarseSt)),nbOfTuplesInFineExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenRangeInCompactFrmt(fineLocInCoarse)); - std::size_t nbCompo=fineDA->getNumberOfComponents(); + std::size_t const nbCompo=fineDA->getNumberOfComponents(); if(coarseDA->getNumberOfComponents()!=nbCompo) throw INTERP_KERNEL::Exception("MEDCouplingIMesh::SpreadCoarseToFine : the number of components of fine DA and coarse one mismatches !"); if(meshDim!=fineLocInCoarse.size() || meshDim!=facts.size()) @@ -560,10 +571,10 @@ void MEDCouplingIMesh::SpreadCoarseToFine(const DataArrayDouble *coarseDA, const std::ostringstream oss; oss << "MEDCouplingIMesh::SpreadCoarseToFine : Expecting " << nbOfTuplesInCoarseExp << " tuples having " << coarseDA->getNumberOfTuples() << " !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - mcIdType nbTuplesFine(fineDA->getNumberOfTuples()); + mcIdType const nbTuplesFine(fineDA->getNumberOfTuples()); if(nbTuplesFine%nbOfTuplesInFineExp!=0) throw INTERP_KERNEL::Exception("MEDCouplingIMesh::SpreadCoarseToFine : Invalid nb of tuples in fine DataArray regarding its structure !"); - mcIdType fact(std::accumulate(facts.begin(),facts.end(),1,std::multiplies())); + mcIdType const fact(std::accumulate(facts.begin(),facts.end(),1,std::multiplies())); if(nbTuplesFine!=fact*nbOfTuplesInFineExp) { std::ostringstream oss; oss << "MEDCouplingIMesh::SpreadCoarseToFine : Invalid number of tuples (" << nbTuplesFine << ") of fine dataarray is invalid ! Must be " << fact*nbOfTuplesInFineExp << "!"; @@ -655,9 +666,9 @@ void MEDCouplingIMesh::SpreadCoarseToFineGhost(const DataArrayDouble *coarseDA, if(!coarseDA || !coarseDA->isAllocated() || !fineDA || !fineDA->isAllocated()) throw INTERP_KERNEL::Exception("MEDCouplingIMesh::SpreadCoarseToFineGhost : the parameters 1 or 3 are NULL or not allocated !"); std::vector coarseStG(coarseSt.size()); std::transform(coarseSt.begin(),coarseSt.end(),coarseStG.begin(),std::bind(std::plus(),std::placeholders::_1,2*ghostSize)); - std::size_t meshDim(coarseSt.size()); - mcIdType nbOfTuplesInCoarseExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(coarseStG)); - std::size_t nbCompo=fineDA->getNumberOfComponents(); + std::size_t const meshDim(coarseSt.size()); + mcIdType const nbOfTuplesInCoarseExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(coarseStG)); + std::size_t const nbCompo=fineDA->getNumberOfComponents(); if(coarseDA->getNumberOfComponents()!=nbCompo) throw INTERP_KERNEL::Exception("MEDCouplingIMesh::SpreadCoarseToFineGhost : the number of components of fine DA and coarse one mismatches !"); if(meshDim!=fineLocInCoarse.size() || meshDim!=facts.size()) @@ -748,9 +759,9 @@ void MEDCouplingIMesh::SpreadCoarseToFineGhostZone(const DataArrayDouble *coarse if(!coarseDA || !coarseDA->isAllocated() || !fineDA || !fineDA->isAllocated()) throw INTERP_KERNEL::Exception("MEDCouplingIMesh::SpreadCoarseToFineGhostZone : the parameters 1 or 3 are NULL or not allocated !"); std::vector coarseStG(coarseSt.size()); std::transform(coarseSt.begin(),coarseSt.end(),coarseStG.begin(),std::bind(std::plus(),std::placeholders::_1,2*ghostSize)); - std::size_t meshDim(coarseSt.size()); - mcIdType nbOfTuplesInCoarseExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(coarseStG)); - std::size_t nbCompo=fineDA->getNumberOfComponents(); + std::size_t const meshDim(coarseSt.size()); + mcIdType const nbOfTuplesInCoarseExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(coarseStG)); + std::size_t const nbCompo=fineDA->getNumberOfComponents(); if(coarseDA->getNumberOfComponents()!=nbCompo) throw INTERP_KERNEL::Exception("MEDCouplingIMesh::SpreadCoarseToFineGhostZone : the number of components of fine DA and coarse one mismatches !"); if(meshDim!=fineLocInCoarse.size() || meshDim!=facts.size()) @@ -842,7 +853,7 @@ std::vector MEDCouplingIMesh::getDirectChildrenWithNull */ void MEDCouplingIMesh::copyTinyStringsFrom(const MEDCouplingMesh *other) { - const MEDCouplingIMesh *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("MEDCouplingIMesh::copyTinyStringsFrom : meshes have not same type !"); MEDCouplingStructuredMesh::copyTinyStringsFrom(other); @@ -853,7 +864,7 @@ bool MEDCouplingIMesh::isEqualIfNotWhy(const MEDCouplingMesh *other, double prec { if(!other) throw INTERP_KERNEL::Exception("MEDCouplingIMesh::isEqualIfNotWhy : input other pointer is null !"); - const MEDCouplingIMesh *otherC(dynamic_cast(other)); + const auto *otherC(dynamic_cast(other)); if(!otherC) { reason="mesh given in input is not castable in MEDCouplingIMesh !"; @@ -873,7 +884,7 @@ bool MEDCouplingIMesh::isEqualIfNotWhy(const MEDCouplingMesh *other, double prec bool MEDCouplingIMesh::isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const { - const MEDCouplingIMesh *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) return false; std::string tmp; @@ -882,7 +893,7 @@ bool MEDCouplingIMesh::isEqualWithoutConsideringStr(const MEDCouplingMesh *other bool MEDCouplingIMesh::isEqualWithoutConsideringStrInternal(const MEDCouplingMesh *other, double prec, std::string& reason) const { - const MEDCouplingIMesh *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) return false; if(_space_dim!=otherC->_space_dim) @@ -925,8 +936,8 @@ bool MEDCouplingIMesh::isEqualWithoutConsideringStrInternal(const MEDCouplingMes return true; } -void MEDCouplingIMesh::checkDeepEquivalWith(const MEDCouplingMesh *other, int cellCompPol, double prec, - DataArrayIdType *&cellCor, DataArrayIdType *&nodeCor) const +void MEDCouplingIMesh::checkDeepEquivalWith(const MEDCouplingMesh *other, int /*cellCompPol*/, double prec, + DataArrayIdType *& /*cellCor*/, DataArrayIdType *& /*nodeCor*/) const { if(!isEqualWithoutConsideringStr(other,prec)) throw INTERP_KERNEL::Exception("MEDCouplingIMesh::checkDeepEquivalWith : Meshes are not the same !"); @@ -936,8 +947,8 @@ void MEDCouplingIMesh::checkDeepEquivalWith(const MEDCouplingMesh *other, int ce * Nothing is done here (except to check that the other is a MEDCoupling::MEDCouplingIMesh instance too). * The user intend that the nodes are the same, so by construction of MEDCoupling::MEDCouplingIMesh, \a this and \a other are the same ! */ -void MEDCouplingIMesh::checkDeepEquivalOnSameNodesWith(const MEDCouplingMesh *other, int cellCompPol, double prec, - DataArrayIdType *&cellCor) const +void MEDCouplingIMesh::checkDeepEquivalOnSameNodesWith(const MEDCouplingMesh *other, int /*cellCompPol*/, double prec, + DataArrayIdType *& /*cellCor*/) const { if(!isEqualWithoutConsideringStr(other,prec)) throw INTERP_KERNEL::Exception("MEDCouplingIMesh::checkDeepEquivalOnSameNodesWith : Meshes are not the same !"); @@ -954,7 +965,7 @@ void MEDCouplingIMesh::checkConsistencyLight() const } } -void MEDCouplingIMesh::checkConsistency(double eps) const +void MEDCouplingIMesh::checkConsistency(double /*eps*/) const { checkConsistencyLight(); } @@ -975,7 +986,7 @@ std::vector MEDCouplingIMesh::getNodeGridStructure() const MEDCouplingStructuredMesh *MEDCouplingIMesh::buildStructuredSubPart(const std::vector< std::pair >& cellPart) const { checkConsistencyLight(); - int dim(getSpaceDimension()); + int const dim(getSpaceDimension()); if(dim!=ToIdType(cellPart.size())) { std::ostringstream oss; oss << "MEDCouplingIMesh::buildStructuredSubPart : the space dimension is " << dim << " and cell part size is " << cellPart.size() << " !"; @@ -987,7 +998,7 @@ MEDCouplingStructuredMesh *MEDCouplingIMesh::buildStructuredSubPart(const std::v for(int i=0;i=_structure[i]) { std::ostringstream oss; oss << "MEDCouplingIMesh::buildStructuredSubPart : At dimension #" << i << " the start node id is " << startNode << " it should be in [0," << _structure[i] << ") !"; @@ -1018,7 +1029,7 @@ int MEDCouplingIMesh::getSpaceDimension() const void MEDCouplingIMesh::getCoordinatesOfNode(mcIdType nodeId, std::vector& coo) const { mcIdType tmp[3]; - int spaceDim(getSpaceDimension()); + int const spaceDim(getSpaceDimension()); getSplitNodeValues(tmp); mcIdType tmp2[3]; GetPosFromId(nodeId,spaceDim,tmp,tmp2); @@ -1032,8 +1043,8 @@ std::string MEDCouplingIMesh::simpleRepr() const ret << "Image grid with name : \"" << getName() << "\"\n"; ret << "Description of mesh : \"" << getDescription() << "\"\n"; int tmpp1,tmpp2; - double tt(getTime(tmpp1,tmpp2)); - int spaceDim(_space_dim); + double const tt(getTime(tmpp1,tmpp2)); + int const spaceDim(_space_dim); ret << "Time attached to the mesh [unit] : " << tt << " [" << getTimeUnit() << "]\n"; ret << "Iteration : " << tmpp1 << " Order : " << tmpp2 << "\n"; ret << "Space dimension : " << spaceDim << "\n"; @@ -1055,7 +1066,7 @@ std::string MEDCouplingIMesh::advancedRepr() const void MEDCouplingIMesh::getBoundingBox(double *bbox) const { checkConsistencyLight(); - int dim(getSpaceDimension()); + int const dim(getSpaceDimension()); for(int idim=0; idimsetName(name); DataArrayDouble* array(DataArrayDouble::New()); @@ -1103,20 +1114,20 @@ MEDCouplingFieldDouble *MEDCouplingIMesh::getMeasureField(bool isAbs) const /*! * not implemented yet ! */ -MEDCouplingFieldDouble *MEDCouplingIMesh::getMeasureFieldOnNode(bool isAbs) const +MEDCouplingFieldDouble *MEDCouplingIMesh::getMeasureFieldOnNode(bool /*isAbs*/) const { throw INTERP_KERNEL::Exception("MEDCouplingIMesh::getMeasureFieldOnNode : not implemented yet !"); //return 0; } -mcIdType MEDCouplingIMesh::getCellContainingPoint(const double *pos, double eps) const +mcIdType MEDCouplingIMesh::getCellContainingPoint(const double *pos, double /*eps*/) const { mcIdType dim(getSpaceDimension()),ret(0),coeff(1); for(mcIdType i=0;i=0 && tmp& elts) const { - mcIdType ret(getCellContainingPoint(pos,eps)); + mcIdType const ret(getCellContainingPoint(pos,eps)); elts.push_back(ret); } -void MEDCouplingIMesh::rotate(const double *center, const double *vector, double angle) +void MEDCouplingIMesh::rotate(const double * /*center*/, const double * /*vector*/, double /*angle*/) { throw INTERP_KERNEL::Exception("No rotation available on IMesh : Traduce it to unstructured mesh to apply it !"); } @@ -1148,7 +1159,7 @@ void MEDCouplingIMesh::rotate(const double *center, const double *vector, double void MEDCouplingIMesh::translate(const double *vector) { checkSpaceDimension(); - int dim(getSpaceDimension()); + int const dim(getSpaceDimension()); std::transform(_origin,_origin+dim,vector,_origin,std::plus()); declareAsNew(); } @@ -1162,7 +1173,7 @@ void MEDCouplingIMesh::translate(const double *vector) void MEDCouplingIMesh::scale(const double *point, double factor) { checkSpaceDimension(); - int dim(getSpaceDimension()); + int const dim(getSpaceDimension()); std::transform(_origin,_origin+dim,point,_origin,std::minus()); std::transform(_origin,_origin+dim,_origin,std::bind(std::multiplies(),std::placeholders::_1,factor)); std::transform(_dxyz,_dxyz+dim,_dxyz,std::bind(std::multiplies(),std::placeholders::_1,factor)); @@ -1170,10 +1181,10 @@ void MEDCouplingIMesh::scale(const double *point, double factor) declareAsNew(); } -MEDCouplingMesh *MEDCouplingIMesh::mergeMyselfWith(const MEDCouplingMesh *other) const +MEDCouplingMesh *MEDCouplingIMesh::mergeMyselfWith(const MEDCouplingMesh * /*other*/) const { //not implemented yet ! - return 0; + return nullptr; } /*! @@ -1187,8 +1198,8 @@ DataArrayDouble *MEDCouplingIMesh::getCoordinatesAndOwner() const { checkConsistencyLight(); MCAuto ret(DataArrayDouble::New()); - int spaceDim(getSpaceDimension()); - mcIdType nbNodes(getNumberOfNodes()); + int const spaceDim(getSpaceDimension()); + mcIdType const nbNodes(getNumberOfNodes()); ret->alloc(nbNodes,spaceDim); double *pt(ret->getPointer()); ret->setInfoOnComponents(buildInfoOnComponents()); @@ -1215,7 +1226,7 @@ DataArrayDouble *MEDCouplingIMesh::computeCellCenterOfMass() const { checkConsistencyLight(); MCAuto ret(DataArrayDouble::New()); - int spaceDim(getSpaceDimension()); + int const spaceDim(getSpaceDimension()); mcIdType nbCells(ToIdType(getNumberOfCells())),tmp[3],tmp2[3]; ret->alloc(nbCells,spaceDim); double *pt(ret->getPointer()),shiftOrigin[3]; @@ -1237,7 +1248,7 @@ DataArrayDouble *MEDCouplingIMesh::computeIsoBarycenterOfNodesPerCell() const return MEDCouplingIMesh::computeCellCenterOfMass(); } -void MEDCouplingIMesh::renumberCells(const mcIdType *old2NewBg, bool check) +void MEDCouplingIMesh::renumberCells(const mcIdType * /*old2NewBg*/, bool /*check*/) { throw INTERP_KERNEL::Exception("Functionality of renumbering cell not available for IMesh !"); } @@ -1245,7 +1256,7 @@ void MEDCouplingIMesh::renumberCells(const mcIdType *old2NewBg, bool check) void MEDCouplingIMesh::getTinySerializationInformation(std::vector& tinyInfoD, std::vector& tinyInfo, std::vector& littleStrings) const { int it,order; - double time(getTime(it,order)); + double const time(getTime(it,order)); tinyInfo.clear(); tinyInfoD.clear(); littleStrings.clear(); @@ -1262,7 +1273,7 @@ void MEDCouplingIMesh::getTinySerializationInformation(std::vector& tiny tinyInfoD.insert(tinyInfoD.end(),_origin,_origin+3); } -void MEDCouplingIMesh::resizeForUnserialization(const std::vector& tinyInfo, DataArrayIdType *a1, DataArrayDouble *a2, std::vector& littleStrings) const +void MEDCouplingIMesh::resizeForUnserialization(const std::vector& /*tinyInfo*/, DataArrayIdType *a1, DataArrayDouble *a2, std::vector& /*littleStrings*/) const { a1->alloc(0,1); a2->alloc(0,1); @@ -1276,7 +1287,7 @@ void MEDCouplingIMesh::serialize(DataArrayIdType *&a1, DataArrayDouble *&a2) con a2->alloc(0,1); } -void MEDCouplingIMesh::unserialization(const std::vector& tinyInfoD, const std::vector& tinyInfo, const DataArrayIdType *a1, DataArrayDouble *a2, +void MEDCouplingIMesh::unserialization(const std::vector& tinyInfoD, const std::vector& tinyInfo, const DataArrayIdType * /*a1*/, DataArrayDouble * /*a2*/, const std::vector& littleStrings) { setName(littleStrings[0]); @@ -1291,7 +1302,7 @@ void MEDCouplingIMesh::unserialization(const std::vector& tinyInfoD, con declareAsNew(); } -void MEDCouplingIMesh::writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData, DataArrayByte *byteData) const +void MEDCouplingIMesh::writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData, DataArrayByte * /*byteData*/) const { checkConsistencyLight(); std::ostringstream extent,origin,spacing; @@ -1325,8 +1336,8 @@ void MEDCouplingIMesh::reprQuickOverview(std::ostream& stream) const bool isPb(false); for(int i=0;i<_space_dim;i++) { - char tmp=(char)((int)('X')+i); - mcIdType tmpNodes(_structure[i]); + char const tmp=(char)((int)('X')+i); + mcIdType const tmpNodes(_structure[i]); stream1 << "- Axis " << tmp << " : " << tmpNodes << " nodes (orig=" << _origin[i] << ", inter=" << _dxyz[i] << ")."; if(i!=_space_dim-1) stream1 << std::endl; @@ -1360,12 +1371,12 @@ std::string MEDCouplingIMesh::getVTKDataSetType() const std::vector MEDCouplingIMesh::buildInfoOnComponents() const { checkSpaceDimension(); - int dim(getSpaceDimension()); + int const dim(getSpaceDimension()); std::vector ret(dim); for(int i=0;i= ghostlev + mcIdType const kk0(kk+1+dims[0]);//1 not ghost. We make the hypothesis that factors is >= ghostlev outPtr2+=fact0*nbCompo*dims[0]; for(mcIdType ig=0;ig +#include +#include +#include +#include namespace MEDCoupling { @@ -55,59 +63,59 @@ namespace MEDCoupling MEDCOUPLING_EXPORT static void SpreadCoarseToFineGhost(const DataArrayDouble *coarseDA, const std::vector& coarseSt, DataArrayDouble *fineDA, const std::vector< std::pair >& fineLocInCoarse, const std::vector& facts, mcIdType ghostSize); MEDCOUPLING_EXPORT static void SpreadCoarseToFineGhostZone(const DataArrayDouble *coarseDA, const std::vector& coarseSt, DataArrayDouble *fineDA, const std::vector< std::pair >& fineLocInCoarse, const std::vector& facts, mcIdType ghostSize); // - MEDCOUPLING_EXPORT MEDCouplingIMesh *deepCopy() const; - MEDCOUPLING_EXPORT MEDCouplingIMesh *clone(bool recDeepCpy) const; - MEDCOUPLING_EXPORT const DataArrayDouble *getDirectAccessOfCoordsArrIfInStructure() const; + MEDCOUPLING_EXPORT MEDCouplingIMesh *deepCopy() const override; + MEDCOUPLING_EXPORT MEDCouplingIMesh *clone(bool recDeepCpy) const override; + MEDCOUPLING_EXPORT const DataArrayDouble *getDirectAccessOfCoordsArrIfInStructure() const override; MEDCOUPLING_EXPORT MEDCouplingIMesh *buildWithGhost(mcIdType ghostLev) const; - MEDCOUPLING_EXPORT void updateTime() const; - MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; - MEDCOUPLING_EXPORT std::vector getDirectChildrenWithNull() const; - MEDCOUPLING_EXPORT MEDCouplingMeshType getType() const { return IMAGE_GRID; } - MEDCOUPLING_EXPORT void copyTinyStringsFrom(const MEDCouplingMesh *other); - MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const; - MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const; + MEDCOUPLING_EXPORT void updateTime() const override; + MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const override; + MEDCOUPLING_EXPORT std::vector getDirectChildrenWithNull() const override; + MEDCOUPLING_EXPORT MEDCouplingMeshType getType() const override { return IMAGE_GRID; } + MEDCOUPLING_EXPORT void copyTinyStringsFrom(const MEDCouplingMesh *other) override; + MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const override; + MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const override; MEDCOUPLING_EXPORT void checkDeepEquivalWith(const MEDCouplingMesh *other, int cellCompPol, double prec, - DataArrayIdType *&cellCor, DataArrayIdType *&nodeCor) const; + DataArrayIdType *&cellCor, DataArrayIdType *&nodeCor) const override; MEDCOUPLING_EXPORT void checkDeepEquivalOnSameNodesWith(const MEDCouplingMesh *other, int cellCompPol, double prec, - DataArrayIdType *&cellCor) const; - MEDCOUPLING_EXPORT void checkConsistencyLight() const; - MEDCOUPLING_EXPORT void checkConsistency(double eps=1e-12) const; - MEDCOUPLING_EXPORT int getSpaceDimension() const; - MEDCOUPLING_EXPORT void getCoordinatesOfNode(mcIdType nodeId, std::vector& coo) const; - MEDCOUPLING_EXPORT std::string simpleRepr() const; - MEDCOUPLING_EXPORT std::string advancedRepr() const; + DataArrayIdType *&cellCor) const override; + MEDCOUPLING_EXPORT void checkConsistencyLight() const override; + MEDCOUPLING_EXPORT void checkConsistency(double eps=1e-12) const override; + MEDCOUPLING_EXPORT int getSpaceDimension() const override; + MEDCOUPLING_EXPORT void getCoordinatesOfNode(mcIdType nodeId, std::vector& coo) const override; + MEDCOUPLING_EXPORT std::string simpleRepr() const override; + MEDCOUPLING_EXPORT std::string advancedRepr() const override; // tools - MEDCOUPLING_EXPORT void getBoundingBox(double *bbox) const; - MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureField(bool isAbs) const; - MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureFieldOnNode(bool isAbs) const; - MEDCOUPLING_EXPORT mcIdType getCellContainingPoint(const double *pos, double eps) const; - MEDCOUPLING_EXPORT void getCellsContainingPoint(const double *pos, double eps, std::vector& elts) const; - MEDCOUPLING_EXPORT void rotate(const double *center, const double *vector, double angle); - MEDCOUPLING_EXPORT void translate(const double *vector); - MEDCOUPLING_EXPORT void scale(const double *point, double factor); - MEDCOUPLING_EXPORT MEDCouplingMesh *mergeMyselfWith(const MEDCouplingMesh *other) const; - MEDCOUPLING_EXPORT DataArrayDouble *getCoordinatesAndOwner() const; - MEDCOUPLING_EXPORT DataArrayDouble *computeCellCenterOfMass() const; - MEDCOUPLING_EXPORT DataArrayDouble *computeIsoBarycenterOfNodesPerCell() const; - MEDCOUPLING_EXPORT void renumberCells(const mcIdType *old2NewBg, bool check=true); + MEDCOUPLING_EXPORT void getBoundingBox(double *bbox) const override; + MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureField(bool isAbs) const override; + MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureFieldOnNode(bool isAbs) const override; + MEDCOUPLING_EXPORT mcIdType getCellContainingPoint(const double *pos, double eps) const override; + MEDCOUPLING_EXPORT void getCellsContainingPoint(const double *pos, double eps, std::vector& elts) const override; + MEDCOUPLING_EXPORT void rotate(const double *center, const double *vector, double angle) override; + MEDCOUPLING_EXPORT void translate(const double *vector) override; + MEDCOUPLING_EXPORT void scale(const double *point, double factor) override; + MEDCOUPLING_EXPORT MEDCouplingMesh *mergeMyselfWith(const MEDCouplingMesh *other) const override; + MEDCOUPLING_EXPORT DataArrayDouble *getCoordinatesAndOwner() const override; + MEDCOUPLING_EXPORT DataArrayDouble *computeCellCenterOfMass() const override; + MEDCOUPLING_EXPORT DataArrayDouble *computeIsoBarycenterOfNodesPerCell() const override; + MEDCOUPLING_EXPORT void renumberCells(const mcIdType *old2NewBg, bool check=true) override; //some useful methods - MEDCOUPLING_EXPORT void getNodeGridStructure(mcIdType *res) const; - MEDCOUPLING_EXPORT std::vector getNodeGridStructure() const; - MEDCouplingStructuredMesh *buildStructuredSubPart(const std::vector< std::pair >& cellPart) const; + MEDCOUPLING_EXPORT void getNodeGridStructure(mcIdType *res) const override; + MEDCOUPLING_EXPORT std::vector getNodeGridStructure() const override; + MEDCouplingStructuredMesh *buildStructuredSubPart(const std::vector< std::pair >& cellPart) const override; //serialisation-unserialization - MEDCOUPLING_EXPORT void getTinySerializationInformation(std::vector& tinyInfoD, std::vector& tinyInfo, std::vector& littleStrings) const; - MEDCOUPLING_EXPORT void resizeForUnserialization(const std::vector& tinyInfo, DataArrayIdType *a1, DataArrayDouble *a2, std::vector& littleStrings) const; - MEDCOUPLING_EXPORT void serialize(DataArrayIdType *&a1, DataArrayDouble *&a2) const; + MEDCOUPLING_EXPORT void getTinySerializationInformation(std::vector& tinyInfoD, std::vector& tinyInfo, std::vector& littleStrings) const override; + MEDCOUPLING_EXPORT void resizeForUnserialization(const std::vector& tinyInfo, DataArrayIdType *a1, DataArrayDouble *a2, std::vector& littleStrings) const override; + MEDCOUPLING_EXPORT void serialize(DataArrayIdType *&a1, DataArrayDouble *&a2) const override; MEDCOUPLING_EXPORT void unserialization(const std::vector& tinyInfoD, const std::vector& tinyInfo, const DataArrayIdType *a1, DataArrayDouble *a2, - const std::vector& littleStrings); - MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const; - MEDCOUPLING_EXPORT std::string getVTKFileExtension() const; + const std::vector& littleStrings) override; + MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const override; + MEDCOUPLING_EXPORT std::string getVTKFileExtension() const override; private: MEDCouplingIMesh(); MEDCouplingIMesh(const MEDCouplingIMesh& other, bool deepCopy); - ~MEDCouplingIMesh(); - void writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData, DataArrayByte *byteData) const; - std::string getVTKDataSetType() const; + ~MEDCouplingIMesh() override; + void writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData, DataArrayByte *byteData) const override; + std::string getVTKDataSetType() const override; bool isEqualWithoutConsideringStrInternal(const MEDCouplingMesh *other, double prec, std::string& reason) const; std::vector buildInfoOnComponents() const; void checkSpaceDimension() const; diff --git a/src/MEDCoupling/MEDCouplingMap.cxx b/src/MEDCoupling/MEDCouplingMap.cxx index df00a68be..7ef340dbe 100644 --- a/src/MEDCoupling/MEDCouplingMap.cxx +++ b/src/MEDCoupling/MEDCouplingMap.cxx @@ -19,6 +19,7 @@ // Author : Anthony Geay (EDF R&D) #include "MEDCouplingMap.txx" +#include "MCIdType.hxx" using namespace MEDCoupling; diff --git a/src/MEDCoupling/MEDCouplingMap.hxx b/src/MEDCoupling/MEDCouplingMap.hxx index 2bfc5a07d..29d597f83 100644 --- a/src/MEDCoupling/MEDCouplingMap.hxx +++ b/src/MEDCoupling/MEDCouplingMap.hxx @@ -21,14 +21,15 @@ #ifndef __MEDCOUPLING_MEDCOUPLINGMAP_HXX__ #define __MEDCOUPLING_MEDCOUPLINGMAP_HXX__ -#include "MEDCoupling.hxx" #include "MCAuto.hxx" #include "MCType.hxx" #include "MEDCouplingTimeLabel.hxx" #include "MEDCouplingRefCountObject.hxx" -#include "InterpKernelException.hxx" +#include #include +#include +#include namespace MEDCoupling { @@ -40,12 +41,12 @@ namespace MEDCoupling std::string getClassName() const override { return std::string("MapKeyVal"); } std::map& data() { return _m; } const std::map& data() const { return _m; } - std::size_t getHeapMemorySizeWithoutChildren() const; - std::vector getDirectChildrenWithNull() const; - void updateTime() const { } + std::size_t getHeapMemorySizeWithoutChildren() const override; + std::vector getDirectChildrenWithNull() const override; + void updateTime() const override { } private: MapKeyVal() { } - ~MapKeyVal() { } + ~MapKeyVal() override = default; private: std::map _m; }; diff --git a/src/MEDCoupling/MEDCouplingMap.txx b/src/MEDCoupling/MEDCouplingMap.txx index 54bdcab2c..bf78a9c31 100644 --- a/src/MEDCoupling/MEDCouplingMap.txx +++ b/src/MEDCoupling/MEDCouplingMap.txx @@ -21,7 +21,12 @@ #ifndef __MEDCOUPLING_MEDCOUPLINGMAP_TXX__ #define __MEDCOUPLING_MEDCOUPLINGMAP_TXX__ +#include "MCAuto.hxx" #include "MEDCouplingMap.hxx" +#include +#include +#include +#include "MEDCouplingRefCountObject.hxx" namespace MEDCoupling { diff --git a/src/MEDCoupling/MEDCouplingMappedExtrudedMesh.cxx b/src/MEDCoupling/MEDCouplingMappedExtrudedMesh.cxx index e709a49a4..249718563 100644 --- a/src/MEDCoupling/MEDCouplingMappedExtrudedMesh.cxx +++ b/src/MEDCoupling/MEDCouplingMappedExtrudedMesh.cxx @@ -19,6 +19,10 @@ // Author : Anthony Geay (CEA/DEN) #include "MEDCouplingMappedExtrudedMesh.hxx" +#include "MCType.hxx" +#include "MEDCouplingMesh.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include "MCIdType.hxx" #include "MEDCouplingUMesh.hxx" #include "MEDCouplingCMesh.hxx" #include "MEDCouplingMemArray.hxx" @@ -27,15 +31,20 @@ #include "CellModel.hxx" #include "InterpolationUtils.hxx" +#include "NormalizedGeometricTypes" +#include #include +#include #include #include #include +#include #include #include -#include #include +#include +#include using namespace MEDCoupling; @@ -90,7 +99,7 @@ std::vector MEDCouplingMappedExtrudedMesh::getDirectChi */ void MEDCouplingMappedExtrudedMesh::copyTinyStringsFrom(const MEDCouplingMesh *other) { - const MEDCouplingMappedExtrudedMesh *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("MEDCouplingMappedExtrudedMesh::copyTinyStringsFrom : meshes have not same type !"); MEDCouplingMesh::copyTinyStringsFrom(other); @@ -99,7 +108,7 @@ void MEDCouplingMappedExtrudedMesh::copyTinyStringsFrom(const MEDCouplingMesh *o } MEDCouplingMappedExtrudedMesh::MEDCouplingMappedExtrudedMesh(const MEDCouplingUMesh *mesh3D, const MEDCouplingUMesh *mesh2D, mcIdType cell2DId) -try:_mesh2D(const_cast(mesh2D)),_mesh1D(MEDCouplingUMesh::New()),_mesh3D_ids(0),_cell_2D_id(cell2DId) +try:_mesh2D(const_cast(mesh2D)),_mesh1D(MEDCouplingUMesh::New()),_mesh3D_ids(nullptr),_cell_2D_id(cell2DId) { if(_mesh2D.isNotNull()) _mesh2D->incrRef(); @@ -111,7 +120,7 @@ catch(INTERP_KERNEL::Exception& e) throw e; } -MEDCouplingMappedExtrudedMesh::MEDCouplingMappedExtrudedMesh(const MEDCouplingCMesh *mesh3D):_mesh1D(MEDCouplingUMesh::New()),_mesh3D_ids(0),_cell_2D_id(0) +MEDCouplingMappedExtrudedMesh::MEDCouplingMappedExtrudedMesh(const MEDCouplingCMesh *mesh3D):_mesh1D(MEDCouplingUMesh::New()),_mesh3D_ids(nullptr),_cell_2D_id(0) { if(!mesh3D) throw INTERP_KERNEL::Exception("MEDCouplingMappedExtrudedMesh contrct : null input pointer !"); @@ -126,7 +135,7 @@ MEDCouplingMappedExtrudedMesh::MEDCouplingMappedExtrudedMesh(const MEDCouplingCM setName(mesh3D->getName()); setDescription(mesh3D->getDescription()); } -MEDCouplingMappedExtrudedMesh::MEDCouplingMappedExtrudedMesh():_mesh2D(0),_mesh1D(0),_mesh3D_ids(0),_cell_2D_id(-1) +MEDCouplingMappedExtrudedMesh::MEDCouplingMappedExtrudedMesh():_mesh2D(nullptr),_mesh1D(nullptr),_mesh3D_ids(nullptr),_cell_2D_id(-1) { } @@ -185,7 +194,7 @@ bool MEDCouplingMappedExtrudedMesh::isEqualIfNotWhy(const MEDCouplingMesh *other { if(!other) throw INTERP_KERNEL::Exception("MEDCouplingMappedExtrudedMesh::isEqualIfNotWhy : input other pointer is null !"); - const MEDCouplingMappedExtrudedMesh *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); std::ostringstream oss; if(!otherC) { @@ -220,7 +229,7 @@ bool MEDCouplingMappedExtrudedMesh::isEqualIfNotWhy(const MEDCouplingMesh *other bool MEDCouplingMappedExtrudedMesh::isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const { - const MEDCouplingMappedExtrudedMesh *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) return false; if(!_mesh2D->isEqualWithoutConsideringStr(otherC->_mesh2D,prec)) @@ -234,14 +243,14 @@ bool MEDCouplingMappedExtrudedMesh::isEqualWithoutConsideringStr(const MEDCoupli return true; } -void MEDCouplingMappedExtrudedMesh::checkDeepEquivalWith(const MEDCouplingMesh *other, int cellCompPol, double prec, - DataArrayIdType *&cellCor, DataArrayIdType *&nodeCor) const +void MEDCouplingMappedExtrudedMesh::checkDeepEquivalWith(const MEDCouplingMesh * /*other*/, int /*cellCompPol*/, double /*prec*/, + DataArrayIdType *& /*cellCor*/, DataArrayIdType *& /*nodeCor*/) const { throw INTERP_KERNEL::Exception("MEDCouplingMappedExtrudedMesh::checkDeepEquivalWith : not implemented yet !"); } -void MEDCouplingMappedExtrudedMesh::checkDeepEquivalOnSameNodesWith(const MEDCouplingMesh *other, int cellCompPol, double prec, - DataArrayIdType *&cellCor) const +void MEDCouplingMappedExtrudedMesh::checkDeepEquivalOnSameNodesWith(const MEDCouplingMesh * /*other*/, int /*cellCompPol*/, double /*prec*/, + DataArrayIdType *& /*cellCor*/) const { throw INTERP_KERNEL::Exception("MEDCouplingMappedExtrudedMesh::checkDeepEquivalOnSameNodesWith : not implemented yet !"); } @@ -249,29 +258,29 @@ void MEDCouplingMappedExtrudedMesh::checkDeepEquivalOnSameNodesWith(const MEDCou INTERP_KERNEL::NormalizedCellType MEDCouplingMappedExtrudedMesh::getTypeOfCell(mcIdType cellId) const { const mcIdType *ids(_mesh3D_ids->begin()); - std::size_t nbOf3DCells(_mesh3D_ids->getNumberOfTuples()); + std::size_t const nbOf3DCells(_mesh3D_ids->getNumberOfTuples()); const mcIdType *where(std::find(ids,ids+nbOf3DCells,cellId)); if(where==ids+nbOf3DCells) throw INTERP_KERNEL::Exception("Invalid cellId specified >= getNumberOfCells() !"); - std::size_t nbOfCells2D(_mesh2D->getNumberOfCells()); - std::size_t locId((std::distance(ids,where))%nbOfCells2D); - INTERP_KERNEL::NormalizedCellType tmp(_mesh2D->getTypeOfCell(ToIdType(locId))); + std::size_t const nbOfCells2D(_mesh2D->getNumberOfCells()); + std::size_t const locId((std::distance(ids,where))%nbOfCells2D); + INTERP_KERNEL::NormalizedCellType const tmp(_mesh2D->getTypeOfCell(ToIdType(locId))); return INTERP_KERNEL::CellModel::GetCellModel(tmp).getExtrudedType(); } std::set MEDCouplingMappedExtrudedMesh::getAllGeoTypes() const { - std::set ret2D(_mesh2D->getAllGeoTypes()); + std::set const ret2D(_mesh2D->getAllGeoTypes()); std::set ret; - for(std::set::const_iterator it=ret2D.begin();it!=ret2D.end();it++) - ret.insert(INTERP_KERNEL::CellModel::GetCellModel(*it).getExtrudedType()); + for(auto it : ret2D) + ret.insert(INTERP_KERNEL::CellModel::GetCellModel(it).getExtrudedType()); return ret; } DataArrayIdType *MEDCouplingMappedExtrudedMesh::giveCellsWithType(INTERP_KERNEL::NormalizedCellType type) const { const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(type)); - INTERP_KERNEL::NormalizedCellType revExtTyp(cm.getReverseExtrudedType()); + INTERP_KERNEL::NormalizedCellType const revExtTyp(cm.getReverseExtrudedType()); MCAuto ret(DataArrayIdType::New()); if(revExtTyp==INTERP_KERNEL::NORM_ERROR) { @@ -279,9 +288,9 @@ DataArrayIdType *MEDCouplingMappedExtrudedMesh::giveCellsWithType(INTERP_KERNEL: return ret.retn(); } MCAuto tmp(_mesh2D->giveCellsWithType(revExtTyp)); - mcIdType nbOfLevs=_mesh1D->getNumberOfCells(); - mcIdType nbOfCells2D=_mesh2D->getNumberOfCells(); - mcIdType nbOfTuples(tmp->getNumberOfTuples()); + mcIdType const nbOfLevs=_mesh1D->getNumberOfCells(); + mcIdType const nbOfCells2D=_mesh2D->getNumberOfCells(); + mcIdType const nbOfTuples(tmp->getNumberOfTuples()); ret->alloc(nbOfLevs*nbOfTuples,1); mcIdType *pt(ret->getPointer()); for(int i=0;i ret2D(_mesh2D->computeNbOfNodesPerCell()); - mcIdType nbOfLevs=_mesh1D->getNumberOfCells(); - mcIdType nbOfCells2D=_mesh2D->getNumberOfCells(); + mcIdType const nbOfLevs=_mesh1D->getNumberOfCells(); + mcIdType const nbOfCells2D=_mesh2D->getNumberOfCells(); MCAuto ret3D(DataArrayIdType::New()); ret3D->alloc(nbOfLevs*nbOfCells2D,1); mcIdType *pt(ret3D->getPointer()); for(int i=0;i ret2D(_mesh2D->computeNbOfNodesPerCell()); - mcIdType nbOfLevs=_mesh1D->getNumberOfCells(); - mcIdType nbOfCells2D=_mesh2D->getNumberOfCells(); + mcIdType const nbOfLevs=_mesh1D->getNumberOfCells(); + mcIdType const nbOfCells2D=_mesh2D->getNumberOfCells(); MCAuto ret3D(DataArrayIdType::New()); ret3D->alloc(nbOfLevs*nbOfCells2D,1); mcIdType *pt(ret3D->getPointer()); for(int i=0;igetNumberOfCells()); + mcIdType const nbOfCells2D(_mesh2D->getNumberOfCells()); for(mcIdType i=0;igetTypeOfCell(i)); + INTERP_KERNEL::NormalizedCellType const t(_mesh2D->getTypeOfCell(i)); if(INTERP_KERNEL::CellModel::GetCellModel(t).getExtrudedType()==type) ret++; } @@ -337,10 +346,10 @@ mcIdType MEDCouplingMappedExtrudedMesh::getNumberOfCellsWithType(INTERP_KERNEL:: void MEDCouplingMappedExtrudedMesh::getNodeIdsOfCell(mcIdType cellId, std::vector& conn) const { - mcIdType nbOfCells2D(_mesh2D->getNumberOfCells()); - mcIdType nbOfNodes2D(_mesh2D->getNumberOfNodes()); - mcIdType locId(cellId%nbOfCells2D); - mcIdType lev(cellId/nbOfCells2D); + mcIdType const nbOfCells2D(_mesh2D->getNumberOfCells()); + mcIdType const nbOfNodes2D(_mesh2D->getNumberOfNodes()); + mcIdType const locId(cellId%nbOfCells2D); + mcIdType const lev(cellId/nbOfCells2D); std::vector tmp,tmp2; _mesh2D->getNodeIdsOfCell(locId,tmp); tmp2=tmp; @@ -352,13 +361,13 @@ void MEDCouplingMappedExtrudedMesh::getNodeIdsOfCell(mcIdType cellId, std::vecto void MEDCouplingMappedExtrudedMesh::getCoordinatesOfNode(mcIdType nodeId, std::vector& coo) const { - mcIdType nbOfNodes2D(_mesh2D->getNumberOfNodes()); - mcIdType locId(nodeId%nbOfNodes2D); - mcIdType lev(nodeId/nbOfNodes2D); + mcIdType const nbOfNodes2D(_mesh2D->getNumberOfNodes()); + mcIdType const locId(nodeId%nbOfNodes2D); + mcIdType const lev(nodeId/nbOfNodes2D); std::vector tmp,tmp2; _mesh2D->getCoordinatesOfNode(locId,tmp); tmp2=tmp; - int spaceDim(_mesh1D->getSpaceDimension()); + int const spaceDim(_mesh1D->getSpaceDimension()); const double *z(_mesh1D->getCoords()->begin()); std::transform(tmp.begin(),tmp.end(),z+lev*spaceDim,tmp.begin(),std::plus()); std::transform(tmp2.begin(),tmp2.end(),z+(lev+1)*spaceDim,tmp2.begin(),std::plus()); @@ -372,7 +381,7 @@ std::string MEDCouplingMappedExtrudedMesh::simpleRepr() const ret << "3D Extruded mesh from a 2D Surf Mesh with name : \"" << getName() << "\"\n"; ret << "Description of mesh : \"" << getDescription() << "\"\n"; int tmpp1,tmpp2; - double tt=getTime(tmpp1,tmpp2); + double const tt=getTime(tmpp1,tmpp2); ret << "Time attached to the mesh [unit] : " << tt << " [" << getTimeUnit() << "]\n"; ret << "Iteration : " << tmpp1 << " Order : " << tmpp2 << "\n"; ret << "Cell id where 1D mesh has been deduced : " << _cell_2D_id << "\n"; @@ -389,7 +398,7 @@ std::string MEDCouplingMappedExtrudedMesh::advancedRepr() const ret << "3D Extruded mesh from a 2D Surf Mesh with name : \"" << getName() << "\"\n"; ret << "Description of mesh : \"" << getDescription() << "\"\n"; int tmpp1,tmpp2; - double tt=getTime(tmpp1,tmpp2); + double const tt=getTime(tmpp1,tmpp2); ret << "Time attached to the mesh (unit) : " << tt << " (" << getTimeUnit() << ")\n"; ret << "Iteration : " << tmpp1 << " Order : " << tmpp2 << "\n"; ret << "Cell id where 1D mesh has been deduced : " << _cell_2D_id << "\n"; @@ -405,7 +414,7 @@ void MEDCouplingMappedExtrudedMesh::checkConsistencyLight() const { } -void MEDCouplingMappedExtrudedMesh::checkConsistency(double eps) const +void MEDCouplingMappedExtrudedMesh::checkConsistency(double /*eps*/) const { checkConsistencyLight(); } @@ -415,7 +424,7 @@ void MEDCouplingMappedExtrudedMesh::getBoundingBox(double *bbox) const double bbox2D[6]; _mesh2D->getBoundingBox(bbox2D); const double *nodes1D(_mesh1D->getCoords()->begin()); - mcIdType nbOfNodes1D(_mesh1D->getNumberOfNodes()); + mcIdType const nbOfNodes1D(_mesh1D->getNumberOfNodes()); double bbox1DMin[3],bbox1DMax[3],tmp[3]; std::fill(bbox1DMin,bbox1DMin+3,std::numeric_limits::max()); std::fill(bbox1DMax,bbox1DMax+3,-(std::numeric_limits::max())); @@ -425,7 +434,7 @@ void MEDCouplingMappedExtrudedMesh::getBoundingBox(double *bbox) const std::transform(nodes1D+3*i,nodes1D+3*(i+1),bbox1DMax,bbox1DMax,static_cast(std::max)); } std::transform(bbox1DMax,bbox1DMax+3,bbox1DMin,tmp,std::minus()); - mcIdType id=ToIdType(std::distance(tmp,std::max_element(tmp,tmp+3))); + mcIdType const id=ToIdType(std::distance(tmp,std::max_element(tmp,tmp+3))); bbox[0]=bbox1DMin[0]; bbox[1]=bbox1DMax[0]; bbox[2]=bbox1DMin[1]; bbox[3]=bbox1DMax[1]; bbox[4]=bbox1DMin[2]; bbox[5]=bbox1DMax[2]; @@ -440,7 +449,7 @@ void MEDCouplingMappedExtrudedMesh::updateTime() const updateTimeWith(*_mesh1D); } -void MEDCouplingMappedExtrudedMesh::renumberCells(const mcIdType *old2NewBg, bool check) +void MEDCouplingMappedExtrudedMesh::renumberCells(const mcIdType * /*old2NewBg*/, bool /*check*/) { throw INTERP_KERNEL::Exception("Functionality of renumbering cells unavailable for ExtrudedMesh"); } @@ -493,10 +502,10 @@ MEDCouplingFieldDouble *MEDCouplingMappedExtrudedMesh::getMeasureField(bool) con return ret.retn(); } -MEDCouplingFieldDouble *MEDCouplingMappedExtrudedMesh::getMeasureFieldOnNode(bool isAbs) const +MEDCouplingFieldDouble *MEDCouplingMappedExtrudedMesh::getMeasureFieldOnNode(bool /*isAbs*/) const { //not implemented yet - return 0; + return nullptr; } MEDCouplingFieldDouble *MEDCouplingMappedExtrudedMesh::buildOrthogonalField() const @@ -504,26 +513,25 @@ MEDCouplingFieldDouble *MEDCouplingMappedExtrudedMesh::buildOrthogonalField() co throw INTERP_KERNEL::Exception("MEDCouplingMappedExtrudedMesh::buildOrthogonalField : This method has no sense for MEDCouplingMappedExtrudedMesh that is 3D !"); } -mcIdType MEDCouplingMappedExtrudedMesh::getCellContainingPoint(const double *pos, double eps) const +mcIdType MEDCouplingMappedExtrudedMesh::getCellContainingPoint(const double * /*pos*/, double /*eps*/) const { throw INTERP_KERNEL::Exception("MEDCouplingMappedExtrudedMesh::getCellContainingPoint : not implemented yet !"); } -void MEDCouplingMappedExtrudedMesh::getCellsContainingPoint(const double *pos, double eps, std::vector& elts) const +void MEDCouplingMappedExtrudedMesh::getCellsContainingPoint(const double * /*pos*/, double /*eps*/, std::vector& /*elts*/) const { throw INTERP_KERNEL::Exception("MEDCouplingMappedExtrudedMesh::getCellsContainingPoint : not implemented yet !"); } MEDCouplingMappedExtrudedMesh::~MEDCouplingMappedExtrudedMesh() -{ -} += default; void MEDCouplingMappedExtrudedMesh::computeExtrusion(const MEDCouplingUMesh *mesh3D) { const char errMsg1[]="2D mesh is empty unable to compute extrusion !"; const char errMsg2[]="Coords between 2D and 3D meshes are not the same ! Try MEDCouplingPointSet::tryToShareSameCoords method"; const char errMsg3[]="No chance to find extrusion pattern in mesh3D,mesh2D couple because nbCells3D%nbCells2D!=0 !"; - if(_mesh2D.isNull() || mesh3D==0) + if(_mesh2D.isNull() || mesh3D==nullptr) throw INTERP_KERNEL::Exception(errMsg1); if(_mesh2D->getCoords()!=mesh3D->getCoords()) throw INTERP_KERNEL::Exception(errMsg2); @@ -541,7 +549,7 @@ void MEDCouplingMappedExtrudedMesh::build1DExtrusion(mcIdType idIn3DDesc, mcIdTy const mcIdType *revDesc3D, const mcIdType *revDescIndx3D, bool computeMesh1D) { - mcIdType nbOf2DCells=_mesh2D->getNumberOfCells(); + mcIdType const nbOf2DCells=_mesh2D->getNumberOfCells(); mcIdType start(revDescIndx3D[idIn3DDesc]); mcIdType end(revDescIndx3D[idIn3DDesc+1]); if(end-start!=1) @@ -596,9 +604,9 @@ mcIdType MEDCouplingMappedExtrudedMesh::findOppositeFaceOf(mcIdType current2DCel const mcIdType *desc3D, const mcIdType *descIndx3D, const mcIdType *conn2D, const mcIdType *conn2DIndx) { - mcIdType start(descIndx3D[current3DCell]); - mcIdType end(descIndx3D[current3DCell+1]); - bool found=false; + mcIdType const start(descIndx3D[current3DCell]); + mcIdType const end(descIndx3D[current3DCell+1]); + bool const found=false; for(const mcIdType *candidate2D=desc3D+start;candidate2D!=desc3D+end && !found;candidate2D++) { if(*candidate2D!=current2DCell) @@ -622,19 +630,19 @@ void MEDCouplingMappedExtrudedMesh::computeBaryCenterOfFace(const std::vectorgetCoords()->getPointer()+lev1DId*3); std::fill(zoneToUpdate,zoneToUpdate+3,0.); const double *coords(_mesh2D->getCoords()->begin()); - for(std::vector::const_iterator iter=nodalConnec.begin();iter!=nodalConnec.end();iter++) - std::transform(zoneToUpdate,zoneToUpdate+3,coords+3*(*iter),zoneToUpdate,std::plus()); + for(long const iter : nodalConnec) + std::transform(zoneToUpdate,zoneToUpdate+3,coords+3*iter,zoneToUpdate,std::plus()); std::transform(zoneToUpdate,zoneToUpdate+3,zoneToUpdate,std::bind(std::multiplies(),std::placeholders::_1,(1./(double)nodalConnec.size()))); } mcIdType MEDCouplingMappedExtrudedMesh::FindCorrespCellByNodalConn(const std::vector& nodalConnec, const mcIdType *revNodalPtr, const mcIdType *revNodalIndxPtr) { - std::vector::const_iterator iter=nodalConnec.begin(); + auto iter=nodalConnec.begin(); std::set s1(revNodalPtr+revNodalIndxPtr[*iter],revNodalPtr+revNodalIndxPtr[*iter+1]); iter++; for(;iter!=nodalConnec.end();iter++) { - std::set s2(revNodalPtr+revNodalIndxPtr[*iter],revNodalPtr+revNodalIndxPtr[*iter+1]); + std::set const s2(revNodalPtr+revNodalIndxPtr[*iter],revNodalPtr+revNodalIndxPtr[*iter+1]); std::set s3; std::set_intersection(s1.begin(),s1.end(),s2.begin(),s2.end(),std::insert_iterator< std::set >(s3,s3.end())); s1=s3; @@ -676,7 +684,7 @@ void MEDCouplingMappedExtrudedMesh::Project1DMeshes(const MEDCouplingUMesh *m1, m1->getCoordinatesOfNode(c[0],ref); m1->getCoordinatesOfNode(c[1],ref2); std::transform(ref2.begin(),ref2.end(),ref.begin(),v,std::minus()); - double n=INTERP_KERNEL::norm<3>(v); + double const n=INTERP_KERNEL::norm<3>(v); std::transform(v,v+3,v,std::bind(std::multiplies(),std::placeholders::_1,1/n)); m1->project1D(&ref[0],v,eps,m1r->getCoords()->getPointer()); m2->project1D(&ref[0],v,eps,m2r->getCoords()->getPointer()); @@ -705,37 +713,37 @@ std::vector MEDCouplingMappedExtrudedMesh::getDistributionOfTypes() co throw INTERP_KERNEL::Exception("Not implemented yet !"); } -DataArrayIdType *MEDCouplingMappedExtrudedMesh::checkTypeConsistencyAndContig(const std::vector& code, const std::vector& idsPerType) const +DataArrayIdType *MEDCouplingMappedExtrudedMesh::checkTypeConsistencyAndContig(const std::vector& /*code*/, const std::vector& /*idsPerType*/) const { throw INTERP_KERNEL::Exception("Not implemented yet !"); } -void MEDCouplingMappedExtrudedMesh::splitProfilePerType(const DataArrayIdType *profile, std::vector& code, std::vector& idsInPflPerType, std::vector& idsPerType, bool smartPflKiller) const +void MEDCouplingMappedExtrudedMesh::splitProfilePerType(const DataArrayIdType * /*profile*/, std::vector& /*code*/, std::vector& /*idsInPflPerType*/, std::vector& /*idsPerType*/, bool /*smartPflKiller*/) const { throw INTERP_KERNEL::Exception("Not implemented yet !"); } -MEDCouplingMesh *MEDCouplingMappedExtrudedMesh::buildPart(const mcIdType *start, const mcIdType *end) const +MEDCouplingMesh *MEDCouplingMappedExtrudedMesh::buildPart(const mcIdType * /*start*/, const mcIdType * /*end*/) const { // not implemented yet ! - return 0; + return nullptr; } -MEDCouplingMesh *MEDCouplingMappedExtrudedMesh::buildPartAndReduceNodes(const mcIdType *start, const mcIdType *end, DataArrayIdType*& arr) const +MEDCouplingMesh *MEDCouplingMappedExtrudedMesh::buildPartAndReduceNodes(const mcIdType * /*start*/, const mcIdType * /*end*/, DataArrayIdType*& /*arr*/) const { // not implemented yet ! - return 0; + return nullptr; } -DataArrayIdType *MEDCouplingMappedExtrudedMesh::simplexize(int policy) +DataArrayIdType *MEDCouplingMappedExtrudedMesh::simplexize(int /*policy*/) { throw INTERP_KERNEL::Exception("MEDCouplingMappedExtrudedMesh::simplexize : unavailable for such a type of mesh : Extruded !"); } -MEDCouplingMesh *MEDCouplingMappedExtrudedMesh::mergeMyselfWith(const MEDCouplingMesh *other) const +MEDCouplingMesh *MEDCouplingMappedExtrudedMesh::mergeMyselfWith(const MEDCouplingMesh * /*other*/) const { // not implemented yet ! - return 0; + return nullptr; } DataArrayDouble *MEDCouplingMappedExtrudedMesh::getCoordinatesAndOwner() const @@ -744,8 +752,8 @@ DataArrayDouble *MEDCouplingMappedExtrudedMesh::getCoordinatesAndOwner() const const DataArrayDouble *arr1D(_mesh1D->getCoords()); MCAuto ret(DataArrayDouble::New()); ret->alloc(getNumberOfNodes(),3); - mcIdType nbOf1DLev(_mesh1D->getNumberOfNodes()); - mcIdType nbOf2DNodes(_mesh2D->getNumberOfNodes()); + mcIdType const nbOf1DLev(_mesh1D->getNumberOfNodes()); + mcIdType const nbOf2DNodes(_mesh2D->getNumberOfNodes()); const double *ptSrc(arr2D->begin()); double *pt(ret->getPointer()); std::copy(ptSrc,ptSrc+3*nbOf2DNodes,pt); @@ -780,7 +788,7 @@ void MEDCouplingMappedExtrudedMesh::getReverseNodalConnectivity(DataArrayIdType void MEDCouplingMappedExtrudedMesh::computeExtrusionAlg(const MEDCouplingUMesh *mesh3D) { _mesh3D_ids->alloc(mesh3D->getNumberOfCells(),1); - mcIdType nbOf1DLev=mesh3D->getNumberOfCells()/_mesh2D->getNumberOfCells(); + mcIdType const nbOf1DLev=mesh3D->getNumberOfCells()/_mesh2D->getNumberOfCells(); _mesh1D->setMeshDimension(1); _mesh1D->allocateCells(nbOf1DLev); mcIdType tmpConn[2]; @@ -805,11 +813,11 @@ void MEDCouplingMappedExtrudedMesh::computeExtrusionAlg(const MEDCouplingUMesh * const mcIdType *revNodalIndx2DPtr(revNodalIndx2D->begin()); const mcIdType *descP(desc->begin()),*descIndxP(descIndx->begin()),*revDescP(revDesc->begin()),*revDescIndxP(revDescIndx->begin()); // - mcIdType nbOf2DCells=_mesh2D->getNumberOfCells(); + mcIdType const nbOf2DCells=_mesh2D->getNumberOfCells(); for(mcIdType i=0;i nodalConnec(nodal2D+nodal2DIndx[i]+1,nodal2D+nodal2DIndx[i+1]); + std::vector const nodalConnec(nodal2D+nodal2DIndx[i]+1,nodal2D+nodal2DIndx[i+1]); try { idInSubMesh=FindCorrespCellByNodalConn(nodalConnec,revNodal2DPtr,revNodalIndx2DPtr); @@ -824,7 +832,7 @@ void MEDCouplingMappedExtrudedMesh::computeExtrusionAlg(const MEDCouplingUMesh * } } -void MEDCouplingMappedExtrudedMesh::getTinySerializationInformation(std::vector& tinyInfoD, std::vector& tinyInfo, std::vector& littleStrings) const +void MEDCouplingMappedExtrudedMesh::getTinySerializationInformation(std::vector& /*tinyInfoD*/, std::vector& tinyInfo, std::vector& littleStrings) const { std::vector tinyInfo1; std::vector ls1; @@ -848,10 +856,10 @@ void MEDCouplingMappedExtrudedMesh::getTinySerializationInformation(std::vector< void MEDCouplingMappedExtrudedMesh::resizeForUnserialization(const std::vector& tinyInfo, DataArrayIdType *a1, DataArrayDouble *a2, std::vector& littleStrings) const { - std::size_t sz=tinyInfo.size(); - mcIdType sz1=tinyInfo[sz-2]; - std::vector ti1(tinyInfo.begin(),tinyInfo.begin()+sz1); - std::vector ti2(tinyInfo.begin()+sz1,tinyInfo.end()-3); + std::size_t const sz=tinyInfo.size(); + mcIdType const sz1=tinyInfo[sz-2]; + std::vector const ti1(tinyInfo.begin(),tinyInfo.begin()+sz1); + std::vector const ti2(tinyInfo.begin()+sz1,tinyInfo.end()-3); MEDCouplingUMesh *um=MEDCouplingUMesh::New(); DataArrayIdType *a1tmp=DataArrayIdType::New(); DataArrayDouble *a2tmp=DataArrayDouble::New(); @@ -874,8 +882,8 @@ void MEDCouplingMappedExtrudedMesh::resizeForUnserialization(const std::vectorserialize(a1_1,a2_1); _mesh1D->serialize(a1_2,a2_2); a1->alloc(a1_1->getNbOfElems()+a1_2->getNbOfElems()+_mesh3D_ids->getNbOfElems(),1); @@ -893,15 +901,15 @@ void MEDCouplingMappedExtrudedMesh::serialize(DataArrayIdType *&a1, DataArrayDou a2_2->decrRef(); } -void MEDCouplingMappedExtrudedMesh::unserialization(const std::vector& tinyInfoD, const std::vector& tinyInfo, const DataArrayIdType *a1, DataArrayDouble *a2, const std::vector& littleStrings) +void MEDCouplingMappedExtrudedMesh::unserialization(const std::vector& /*tinyInfoD*/, const std::vector& tinyInfo, const DataArrayIdType *a1, DataArrayDouble *a2, const std::vector& littleStrings) { setName(littleStrings[littleStrings.size()-2]); setDescription(littleStrings.back()); - std::size_t sz=tinyInfo.size(); - mcIdType sz1=tinyInfo[sz-2]; + std::size_t const sz=tinyInfo.size(); + mcIdType const sz1=tinyInfo[sz-2]; _cell_2D_id=tinyInfo[sz-3]; - std::vector ti1(tinyInfo.begin(),tinyInfo.begin()+sz1); - std::vector ti2(tinyInfo.begin()+sz1,tinyInfo.end()-3); + std::vector const ti1(tinyInfo.begin(),tinyInfo.begin()+sz1); + std::vector const ti2(tinyInfo.begin()+sz1,tinyInfo.end()-3); DataArrayIdType *a1tmp=DataArrayIdType::New(); DataArrayDouble *a2tmp=DataArrayDouble::New(); const mcIdType *a1Ptr=a1->begin(); @@ -914,7 +922,7 @@ void MEDCouplingMappedExtrudedMesh::unserialization(const std::vector& t a2Ptr+=a2tmp->getNbOfElems(); a1Ptr+=a1tmp->getNbOfElems(); ls2.insert(ls2.end(),littleStrings.begin(),littleStrings.begin()+ls1.size()); - std::vector d1(1); + std::vector const d1(1); _mesh2D->unserialization(d1,ti1,a1tmp,a2tmp,ls2); a1tmp->decrRef(); a2tmp->decrRef(); // @@ -930,7 +938,7 @@ void MEDCouplingMappedExtrudedMesh::unserialization(const std::vector& t a1tmp->decrRef(); a2tmp->decrRef(); // _mesh3D_ids=DataArrayIdType::New(); - mcIdType szIds=ToIdType(std::distance(a1Ptr,a1->begin()))+a1->getNbOfElems(); + mcIdType const szIds=ToIdType(std::distance(a1Ptr,a1->begin()))+a1->getNbOfElems(); _mesh3D_ids->alloc(szIds,1); std::copy(a1Ptr,a1Ptr+szIds,_mesh3D_ids->getPointer()); } diff --git a/src/MEDCoupling/MEDCouplingMappedExtrudedMesh.hxx b/src/MEDCoupling/MEDCouplingMappedExtrudedMesh.hxx index 1725e8540..cbf9fac1c 100644 --- a/src/MEDCoupling/MEDCouplingMappedExtrudedMesh.hxx +++ b/src/MEDCoupling/MEDCouplingMappedExtrudedMesh.hxx @@ -21,9 +21,17 @@ #ifndef __PARAMEDMEM_MEDCOUPLINGEXTRUDEDMESH_HXX__ #define __PARAMEDMEM_MEDCOUPLINGEXTRUDEDMESH_HXX__ +#include "MCType.hxx" +#include "MCAuto.hxx" #include "MEDCoupling.hxx" #include "MEDCouplingMesh.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include "NormalizedGeometricTypes" +#include +#include +#include +#include #include namespace MEDCoupling @@ -41,75 +49,75 @@ namespace MEDCoupling MEDCOUPLING_EXPORT static MEDCouplingMappedExtrudedMesh *New(const MEDCouplingCMesh *mesh3D); MEDCOUPLING_EXPORT static MEDCouplingMappedExtrudedMesh *New(); MEDCOUPLING_EXPORT std::string getClassName() const override { return std::string("MEDCouplingMappedExtrudedMesh"); } - MEDCOUPLING_EXPORT MEDCouplingMeshType getType() const; - MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; - MEDCOUPLING_EXPORT std::vector getDirectChildrenWithNull() const; - MEDCOUPLING_EXPORT void copyTinyStringsFrom(const MEDCouplingMesh *other); - MEDCOUPLING_EXPORT mcIdType getNumberOfCells() const; - MEDCOUPLING_EXPORT mcIdType getNumberOfNodes() const; - MEDCOUPLING_EXPORT int getSpaceDimension() const; - MEDCOUPLING_EXPORT int getMeshDimension() const; - MEDCOUPLING_EXPORT MEDCouplingMappedExtrudedMesh *deepCopy() const; - MEDCOUPLING_EXPORT MEDCouplingMappedExtrudedMesh *clone(bool recDeepCpy) const; - MEDCOUPLING_EXPORT const DataArrayDouble *getDirectAccessOfCoordsArrIfInStructure() const; - MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const; - MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const; + MEDCOUPLING_EXPORT MEDCouplingMeshType getType() const override; + MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const override; + MEDCOUPLING_EXPORT std::vector getDirectChildrenWithNull() const override; + MEDCOUPLING_EXPORT void copyTinyStringsFrom(const MEDCouplingMesh *other) override; + MEDCOUPLING_EXPORT mcIdType getNumberOfCells() const override; + MEDCOUPLING_EXPORT mcIdType getNumberOfNodes() const override; + MEDCOUPLING_EXPORT int getSpaceDimension() const override; + MEDCOUPLING_EXPORT int getMeshDimension() const override; + MEDCOUPLING_EXPORT MEDCouplingMappedExtrudedMesh *deepCopy() const override; + MEDCOUPLING_EXPORT MEDCouplingMappedExtrudedMesh *clone(bool recDeepCpy) const override; + MEDCOUPLING_EXPORT const DataArrayDouble *getDirectAccessOfCoordsArrIfInStructure() const override; + MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const override; + MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const override; MEDCOUPLING_EXPORT void checkDeepEquivalWith(const MEDCouplingMesh *other, int cellCompPol, double prec, - DataArrayIdType *&cellCor, DataArrayIdType *&nodeCor) const; + DataArrayIdType *&cellCor, DataArrayIdType *&nodeCor) const override; MEDCOUPLING_EXPORT void checkDeepEquivalOnSameNodesWith(const MEDCouplingMesh *other, int cellCompPol, double prec, - DataArrayIdType *&cellCor) const; - MEDCOUPLING_EXPORT INTERP_KERNEL::NormalizedCellType getTypeOfCell(mcIdType cellId) const; - MEDCOUPLING_EXPORT std::set getAllGeoTypes() const; - MEDCOUPLING_EXPORT DataArrayIdType *giveCellsWithType(INTERP_KERNEL::NormalizedCellType type) const; - MEDCOUPLING_EXPORT DataArrayIdType *computeNbOfNodesPerCell() const; - MEDCOUPLING_EXPORT DataArrayIdType *computeNbOfFacesPerCell() const; - MEDCOUPLING_EXPORT DataArrayIdType *computeEffectiveNbOfNodesPerCell() const; - MEDCOUPLING_EXPORT mcIdType getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const; - MEDCOUPLING_EXPORT void getNodeIdsOfCell(mcIdType cellId, std::vector& conn) const; - MEDCOUPLING_EXPORT void getCoordinatesOfNode(mcIdType nodeId, std::vector& coo) const; - MEDCOUPLING_EXPORT std::string simpleRepr() const; - MEDCOUPLING_EXPORT std::string advancedRepr() const; - MEDCOUPLING_EXPORT void checkConsistencyLight() const; - MEDCOUPLING_EXPORT void checkConsistency(double eps=1e-12) const; - MEDCOUPLING_EXPORT void getBoundingBox(double *bbox) const; - MEDCOUPLING_EXPORT void updateTime() const; - MEDCOUPLING_EXPORT void renumberCells(const mcIdType *old2NewBg, bool check=true); + DataArrayIdType *&cellCor) const override; + MEDCOUPLING_EXPORT INTERP_KERNEL::NormalizedCellType getTypeOfCell(mcIdType cellId) const override; + MEDCOUPLING_EXPORT std::set getAllGeoTypes() const override; + MEDCOUPLING_EXPORT DataArrayIdType *giveCellsWithType(INTERP_KERNEL::NormalizedCellType type) const override; + MEDCOUPLING_EXPORT DataArrayIdType *computeNbOfNodesPerCell() const override; + MEDCOUPLING_EXPORT DataArrayIdType *computeNbOfFacesPerCell() const override; + MEDCOUPLING_EXPORT DataArrayIdType *computeEffectiveNbOfNodesPerCell() const override; + MEDCOUPLING_EXPORT mcIdType getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const override; + MEDCOUPLING_EXPORT void getNodeIdsOfCell(mcIdType cellId, std::vector& conn) const override; + MEDCOUPLING_EXPORT void getCoordinatesOfNode(mcIdType nodeId, std::vector& coo) const override; + MEDCOUPLING_EXPORT std::string simpleRepr() const override; + MEDCOUPLING_EXPORT std::string advancedRepr() const override; + MEDCOUPLING_EXPORT void checkConsistencyLight() const override; + MEDCOUPLING_EXPORT void checkConsistency(double eps=1e-12) const override; + MEDCOUPLING_EXPORT void getBoundingBox(double *bbox) const override; + MEDCOUPLING_EXPORT void updateTime() const override; + MEDCOUPLING_EXPORT void renumberCells(const mcIdType *old2NewBg, bool check=true) override; MEDCOUPLING_EXPORT MEDCouplingUMesh *getMesh2D() const { return _mesh2D.iAmATrollConstCast(); } MEDCOUPLING_EXPORT MEDCouplingUMesh *getMesh1D() const { return _mesh1D.iAmATrollConstCast(); } MEDCOUPLING_EXPORT DataArrayIdType *getMesh3DIds() const { return _mesh3D_ids.iAmATrollConstCast(); } MEDCOUPLING_EXPORT MEDCouplingUMesh *build3DUnstructuredMesh() const; - MEDCOUPLING_EXPORT MEDCouplingUMesh *buildUnstructured() const; - MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureField(bool) const; - MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureFieldOnNode(bool) const; - MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildOrthogonalField() const; - MEDCOUPLING_EXPORT mcIdType getCellContainingPoint(const double *pos, double eps) const; - MEDCOUPLING_EXPORT void getCellsContainingPoint(const double *pos, double eps, std::vector& elts) const; + MEDCOUPLING_EXPORT MEDCouplingUMesh *buildUnstructured() const override; + MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureField(bool) const override; + MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureFieldOnNode(bool) const override; + MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildOrthogonalField() const override; + MEDCOUPLING_EXPORT mcIdType getCellContainingPoint(const double *pos, double eps) const override; + MEDCOUPLING_EXPORT void getCellsContainingPoint(const double *pos, double eps, std::vector& elts) const override; MEDCOUPLING_EXPORT static mcIdType FindCorrespCellByNodalConn(const std::vector& nodalConnec, const mcIdType *revNodalPtr, const mcIdType *revNodalIndxPtr); MEDCOUPLING_EXPORT static void Project1DMeshes(const MEDCouplingUMesh *m1, const MEDCouplingUMesh *m2, double eps, MEDCouplingUMesh *&m1r, MEDCouplingUMesh *&m2r, double *v); - MEDCOUPLING_EXPORT void rotate(const double *center, const double *vector, double angle); - MEDCOUPLING_EXPORT void translate(const double *vector); - MEDCOUPLING_EXPORT void scale(const double *point, double factor); - MEDCOUPLING_EXPORT std::vector getDistributionOfTypes() const; - MEDCOUPLING_EXPORT DataArrayIdType *checkTypeConsistencyAndContig(const std::vector& code, const std::vector& idsPerType) const; - MEDCOUPLING_EXPORT void splitProfilePerType(const DataArrayIdType *profile, std::vector& code, std::vector& idsInPflPerType, std::vector& idsPerType, bool smartPflKiller=true) const; - MEDCOUPLING_EXPORT MEDCouplingMesh *buildPart(const mcIdType *start, const mcIdType *end) const; - MEDCOUPLING_EXPORT MEDCouplingMesh *buildPartAndReduceNodes(const mcIdType *start, const mcIdType *end, DataArrayIdType*& arr) const; - MEDCOUPLING_EXPORT DataArrayIdType *simplexize(int policy); - MEDCOUPLING_EXPORT MEDCouplingMesh *mergeMyselfWith(const MEDCouplingMesh *other) const; - MEDCOUPLING_EXPORT DataArrayDouble *getCoordinatesAndOwner() const; - MEDCOUPLING_EXPORT DataArrayDouble *computeCellCenterOfMass() const; - MEDCOUPLING_EXPORT DataArrayDouble *computeIsoBarycenterOfNodesPerCell() const; - MEDCOUPLING_EXPORT void getReverseNodalConnectivity(DataArrayIdType *revNodal, DataArrayIdType *revNodalIndx) const; + MEDCOUPLING_EXPORT void rotate(const double *center, const double *vector, double angle) override; + MEDCOUPLING_EXPORT void translate(const double *vector) override; + MEDCOUPLING_EXPORT void scale(const double *point, double factor) override; + MEDCOUPLING_EXPORT std::vector getDistributionOfTypes() const override; + MEDCOUPLING_EXPORT DataArrayIdType *checkTypeConsistencyAndContig(const std::vector& code, const std::vector& idsPerType) const override; + MEDCOUPLING_EXPORT void splitProfilePerType(const DataArrayIdType *profile, std::vector& code, std::vector& idsInPflPerType, std::vector& idsPerType, bool smartPflKiller=true) const override; + MEDCOUPLING_EXPORT MEDCouplingMesh *buildPart(const mcIdType *start, const mcIdType *end) const override; + MEDCOUPLING_EXPORT MEDCouplingMesh *buildPartAndReduceNodes(const mcIdType *start, const mcIdType *end, DataArrayIdType*& arr) const override; + MEDCOUPLING_EXPORT DataArrayIdType *simplexize(int policy) override; + MEDCOUPLING_EXPORT MEDCouplingMesh *mergeMyselfWith(const MEDCouplingMesh *other) const override; + MEDCOUPLING_EXPORT DataArrayDouble *getCoordinatesAndOwner() const override; + MEDCOUPLING_EXPORT DataArrayDouble *computeCellCenterOfMass() const override; + MEDCOUPLING_EXPORT DataArrayDouble *computeIsoBarycenterOfNodesPerCell() const override; + MEDCOUPLING_EXPORT void getReverseNodalConnectivity(DataArrayIdType *revNodal, DataArrayIdType *revNodalIndx) const override; //Serialization unserialisation - MEDCOUPLING_EXPORT void getTinySerializationInformation(std::vector& tinyInfoD, std::vector& tinyInfo, std::vector& littleStrings) const; - MEDCOUPLING_EXPORT void resizeForUnserialization(const std::vector& tinyInfo, DataArrayIdType *a1, DataArrayDouble *a2, std::vector& littleStrings) const; - MEDCOUPLING_EXPORT void serialize(DataArrayIdType *&a1, DataArrayDouble *&a2) const; + MEDCOUPLING_EXPORT void getTinySerializationInformation(std::vector& tinyInfoD, std::vector& tinyInfo, std::vector& littleStrings) const override; + MEDCOUPLING_EXPORT void resizeForUnserialization(const std::vector& tinyInfo, DataArrayIdType *a1, DataArrayDouble *a2, std::vector& littleStrings) const override; + MEDCOUPLING_EXPORT void serialize(DataArrayIdType *&a1, DataArrayDouble *&a2) const override; MEDCOUPLING_EXPORT void unserialization(const std::vector& tinyInfoD, const std::vector& tinyInfo, const DataArrayIdType *a1, DataArrayDouble *a2, - const std::vector& littleStrings); - MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const; - MEDCOUPLING_EXPORT std::string getVTKFileExtension() const; + const std::vector& littleStrings) override; + MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const override; + MEDCOUPLING_EXPORT std::string getVTKFileExtension() const override; MEDCOUPLING_EXPORT mcIdType get2DCellIdForExtrusion() const { return _cell_2D_id; } private: MEDCouplingMappedExtrudedMesh(const MEDCouplingUMesh *mesh3D, const MEDCouplingUMesh *mesh2D, mcIdType cell2DId); @@ -126,9 +134,9 @@ namespace MEDCoupling const mcIdType *desc3D, const mcIdType *descIndx3D, const mcIdType *conn2D, const mcIdType *conn2DIndx); void computeBaryCenterOfFace(const std::vector& nodalConnec, mcIdType lev1DId); - ~MEDCouplingMappedExtrudedMesh(); - void writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData, DataArrayByte *byteData) const; - std::string getVTKDataSetType() const; + ~MEDCouplingMappedExtrudedMesh() override; + void writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData, DataArrayByte *byteData) const override; + std::string getVTKDataSetType() const override; private: MCAuto _mesh2D; MCAuto _mesh1D; diff --git a/src/MEDCoupling/MEDCouplingMatrix.cxx b/src/MEDCoupling/MEDCouplingMatrix.cxx old mode 100755 new mode 100644 index bdec49e2a..625ca871e --- a/src/MEDCoupling/MEDCouplingMatrix.cxx +++ b/src/MEDCoupling/MEDCouplingMatrix.cxx @@ -21,8 +21,19 @@ #include "MEDCouplingMatrix.hxx" #include "InterpKernelMatrixTools.hxx" - +#include "MCType.hxx" +#include "MEDCouplingMemArray.hxx" +#include "MCAuto.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include "MCIdType.hxx" + +#include +#include +#include #include +#include +#include +#include using namespace MEDCoupling; @@ -243,14 +254,13 @@ DenseMatrix *DenseMatrix::Multiply(const DenseMatrix *a1, const DataArrayDouble } DenseMatrix::~DenseMatrix() -{ -} += default; DenseMatrix::DenseMatrix(mcIdType nbRows, mcIdType nbCols):_nb_rows(nbRows),_nb_cols(nbCols),_data(DataArrayDouble::New()) { if(_nb_rows<0 || _nb_cols<0) throw INTERP_KERNEL::Exception("constructor of DenseMatrix : number of rows and number of cols must be > 0 both !"); - mcIdType nbOfTuples(_nb_rows*_nb_cols); + mcIdType const nbOfTuples(_nb_rows*_nb_cols); _data->alloc(nbOfTuples,1); } diff --git a/src/MEDCoupling/MEDCouplingMatrix.hxx b/src/MEDCoupling/MEDCouplingMatrix.hxx index 66eeaeb6f..a9125a7d2 100644 --- a/src/MEDCoupling/MEDCouplingMatrix.hxx +++ b/src/MEDCoupling/MEDCouplingMatrix.hxx @@ -21,13 +21,16 @@ #ifndef __PARAMEDMEM_MEDCOUPLINGMATRIX_HXX__ #define __PARAMEDMEM_MEDCOUPLINGMATRIX_HXX__ +#include "MCType.hxx" #include "MEDCoupling.hxx" #include "MEDCouplingTimeLabel.hxx" #include "MEDCouplingRefCountObject.hxx" #include "MEDCouplingMemArray.hxx" #include "MCAuto.hxx" -#include "InterpKernelException.hxx" +#include +#include +#include namespace MEDCoupling { @@ -43,9 +46,9 @@ namespace MEDCoupling MEDCOUPLING_EXPORT std::string getClassName() const override { return std::string("DenseMatrix"); } MEDCOUPLING_EXPORT DenseMatrix *deepCopy() const; MEDCOUPLING_EXPORT DenseMatrix *shallowCpy() const; - MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; - MEDCOUPLING_EXPORT std::vector getDirectChildrenWithNull() const; - MEDCOUPLING_EXPORT void updateTime() const; + MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const override; + MEDCOUPLING_EXPORT std::vector getDirectChildrenWithNull() const override; + MEDCOUPLING_EXPORT void updateTime() const override; // MEDCOUPLING_EXPORT mcIdType getNumberOfRows() const { return _nb_rows; } MEDCOUPLING_EXPORT mcIdType getNumberOfCols() const { return _nb_cols; } @@ -68,7 +71,7 @@ namespace MEDCoupling MEDCOUPLING_EXPORT const DataArrayDouble *getData() const { return _data; } MEDCOUPLING_EXPORT DataArrayDouble *getData() { return _data; } private: - ~DenseMatrix(); + ~DenseMatrix() override; DenseMatrix(mcIdType nbRows, mcIdType nbCols); DenseMatrix(DataArrayDouble *array, mcIdType nbRows, mcIdType nbCols); mcIdType getNumberOfRowsExt(mcIdType nbRows) const; diff --git a/src/MEDCoupling/MEDCouplingMemArray.cxx b/src/MEDCoupling/MEDCouplingMemArray.cxx old mode 100755 new mode 100644 index 84deb1ef3..c9d533df1 --- a/src/MEDCoupling/MEDCouplingMemArray.cxx +++ b/src/MEDCoupling/MEDCouplingMemArray.cxx @@ -21,24 +21,38 @@ #include "MEDCouplingMemArray.txx" #include "BBTree.txx" +#include "BBTreePts.txx" #include "GenMathFormulae.hxx" #include "InterpKernelAutoPtr.hxx" +#include "InterpKernelException.hxx" #include "InterpKernelExprParser.hxx" -#include "InterpKernelAutoPtr.hxx" #include "InterpKernelGeo2DEdgeArcCircle.hxx" -#include "InterpKernelAutoPtr.hxx" #include "InterpKernelGeo2DNode.hxx" #include "InterpKernelGeo2DEdgeLin.hxx" - +#include "MEDCoupling.hxx" +#include "MCIdType.hxx" +#include "MCType.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include "MCAuto.hxx" +#include "InterpKernelGeo2DPrecision.hxx" +#include "InterpolationUtils.hxx" + +#include +#include +#include +#include #include #include #include #include #include #include +#include +#include +#include -typedef double (*MYFUNCPTR)(double); +using MYFUNCPTR = double (*)(double); using namespace MEDCoupling; @@ -71,7 +85,7 @@ template void DataArrayDouble::findCommonTuplesAlg(const double *bbox, mcIdType nbNodes, mcIdType limitNodeId, double prec, DataArrayIdType *c, DataArrayIdType *cI) const { const double *coordsPtr=getConstPointer(); - BBTreePts myTree(bbox,0,0,nbNodes,prec); + BBTreePts const myTree(bbox,nullptr,0,nbNodes,prec); std::vector isDone(nbNodes); for(mcIdType i=0;i1) { std::vector commonNodes; - for(std::vector::const_iterator it=intersectingElems.begin();it!=intersectingElems.end();it++) - if(*it!=i) - if(*it>=limitNodeId) + for(long const intersectingElem : intersectingElems) + if(intersectingElem!=i) + if(intersectingElem>=limitNodeId) { - commonNodes.push_back(*it); - isDone[*it]=true; + commonNodes.push_back(intersectingElem); + isDone[intersectingElem]=true; } if(!commonNodes.empty()) { @@ -101,7 +115,7 @@ void DataArrayDouble::findCommonTuplesAlg(const double *bbox, mcIdType nbNodes, } template -void DataArrayDouble::FindTupleIdsNearTuplesAlg(const BBTreePts& myTree, const double *pos, mcIdType nbOfTuples, double eps, +void DataArrayDouble::FindTupleIdsNearTuplesAlg(const BBTreePts& myTree, const double *pos, mcIdType nbOfTuples, double /*eps*/, DataArrayIdType *c, DataArrayIdType *cI) { for(mcIdType i=0;i intersectingElems; myTree.getElementsAroundPoint(pos+i*SPACEDIM,intersectingElems); std::vector commonNodes; - for(std::vector::const_iterator it=intersectingElems.begin();it!=intersectingElems.end();it++) - commonNodes.push_back(*it); + for(long const intersectingElem : intersectingElems) + commonNodes.push_back(intersectingElem); cI->pushBackSilent(cI->back()+ToIdType(commonNodes.size())); c->insertAtTheEnd(commonNodes.begin(),commonNodes.end()); } } template -void DataArrayDouble::FindClosestTupleIdAlg(const BBTreePts& myTree, double dist, const double *pos, mcIdType nbOfTuples, const double *thisPt, mcIdType thisNbOfTuples, mcIdType *res) +void DataArrayDouble::FindClosestTupleIdAlg(const BBTreePts& myTree, double dist, const double *pos, mcIdType nbOfTuples, const double * /*thisPt*/, mcIdType /*thisNbOfTuples*/, mcIdType *res) { double distOpt = std::max(dist, std::numeric_limits::epsilon()); const double *p(pos); @@ -127,7 +141,7 @@ void DataArrayDouble::FindClosestTupleIdAlg(const BBTreePts& while(true) { mcIdType elem=-1; - double ret=myTree.getElementsAroundPoint2(p,distOpt,elem); + double const ret=myTree.getElementsAroundPoint2(p,distOpt,elem); if(ret!=std::numeric_limits::max()) { distOpt=std::max(ret,1e-4); @@ -158,11 +172,11 @@ mcIdType DataArray::EffectiveCircPerm(mcIdType nbOfShift, mcIdType nbOfTuples) std::size_t DataArray::getHeapMemorySizeWithoutChildren() const { - std::size_t sz1=_name.capacity(); - std::size_t sz2=_info_on_compo.capacity(); + std::size_t const sz1=_name.capacity(); + std::size_t const sz2=_info_on_compo.capacity(); std::size_t sz3=0; - for(std::vector::const_iterator it=_info_on_compo.begin();it!=_info_on_compo.end();it++) - sz3+=(*it).capacity(); + for(const auto & it : _info_on_compo) + sz3+=it.capacity(); return sz1+sz2+sz3; } @@ -201,8 +215,8 @@ void DataArray::copyStringInfoFrom(const DataArray& other) void DataArray::copyPartOfStringInfoFrom(const DataArray& other, const std::vector& compoIds) { - std::size_t nbOfCompoOth=other.getNumberOfComponents(); - std::size_t newNbOfCompo=compoIds.size(); + std::size_t const nbOfCompoOth=other.getNumberOfComponents(); + std::size_t const newNbOfCompo=compoIds.size(); for(std::size_t i=0;i=nbOfCompoOth) { @@ -217,8 +231,8 @@ void DataArray::copyPartOfStringInfoFrom2(const std::vector& compoI { if(compoIds.size()!=other.getNumberOfComponents()) throw INTERP_KERNEL::Exception("Given compoIds has not the same size as number of components of given array !"); - std::size_t partOfCompoToSet=compoIds.size(); - std::size_t nbOfCompo=getNumberOfComponents(); + std::size_t const partOfCompoToSet=compoIds.size(); + std::size_t const nbOfCompo=getNumberOfComponents(); for(std::size_t i=0;i=nbOfCompo) { @@ -241,11 +255,11 @@ bool DataArray::areInfoEqualsIfNotWhy(const DataArray& other, std::string& reaso if(_info_on_compo!=other._info_on_compo) { oss << "Components DataArray mismatch : \nThis components="; - for(std::vector::const_iterator it=_info_on_compo.begin();it!=_info_on_compo.end();it++) - oss << "\"" << *it << "\","; + for(const auto & it : _info_on_compo) + oss << "\"" << it << "\","; oss << "\nOther components="; - for(std::vector::const_iterator it=other._info_on_compo.begin();it!=other._info_on_compo.end();it++) - oss << "\"" << *it << "\","; + for(const auto & it : other._info_on_compo) + oss << "\"" << it << "\","; reason=oss.str(); return false; } @@ -272,8 +286,8 @@ void DataArray::reprWithoutNameStream(std::ostream& stream) const { stream << "Number of components : "<< getNumberOfComponents() << "\n"; stream << "Info of these components : "; - for(std::vector::const_iterator iter=_info_on_compo.begin();iter!=_info_on_compo.end();iter++) - stream << "\"" << *iter << "\" "; + for(const auto & iter : _info_on_compo) + stream << "\"" << iter << "\" "; stream << "\n"; } @@ -312,12 +326,12 @@ void DataArray::setPartOfValuesBase3(const DataArray *aBase, const mcIdType *bgT { if(!aBase) throw INTERP_KERNEL::Exception("DataArray::setPartOfValuesBase3 : input aBase object is NULL !"); - DataArrayDouble *this1(dynamic_cast(this)); - DataArrayIdType *this2(dynamic_cast(this)); - DataArrayChar *this3(dynamic_cast(this)); - const DataArrayDouble *a1(dynamic_cast(aBase)); - const DataArrayIdType *a2(dynamic_cast(aBase)); - const DataArrayChar *a3(dynamic_cast(aBase)); + auto *this1(dynamic_cast(this)); + auto *this2(dynamic_cast(this)); + auto *this3(dynamic_cast(this)); + const auto *a1(dynamic_cast(aBase)); + const auto *a2(dynamic_cast(aBase)); + const auto *a3(dynamic_cast(aBase)); if(this1 && a1) { this1->setPartOfValues3(a1,bgTuples,endTuples,bgComp,endComp,stepComp,strictCompoCompare); @@ -338,7 +352,7 @@ void DataArray::setPartOfValuesBase3(const DataArray *aBase, const mcIdType *bgT std::vector DataArray::getVarsOnComponent() const { - std::size_t nbOfCompo=_info_on_compo.size(); + std::size_t const nbOfCompo=_info_on_compo.size(); std::vector ret(nbOfCompo); for(std::size_t i=0;i DataArray::getVarsOnComponent() const std::vector DataArray::getUnitsOnComponent() const { - std::size_t nbOfCompo=_info_on_compo.size(); + std::size_t const nbOfCompo=_info_on_compo.size(); std::vector ret(nbOfCompo); for(std::size_t i=0;i DataArray::SplitStringInChuncks(const std::string st, std::size_t sz) { - std::size_t len = st.length(); - std::size_t nbOfCompo(len/sz); + std::size_t const len = st.length(); + std::size_t const nbOfCompo(len/sz); if( nbOfCompo*sz != len) { THROW_IK_EXCEPTION("DataArray::SplitStringInChuncks : Length of input string (" << len << ") is not equal to " << nbOfCompo << "*" << sz << " !"); @@ -439,7 +453,7 @@ std::vector DataArray::SplitStringInChuncks(const std::string st, s for(std::size_t i = 0 ; i < nbOfCompo ; ++i) { std::string part = st.substr(i*sz,sz); - std::size_t p3=part.find_last_not_of(" \t"); + std::size_t const p3=part.find_last_not_of(" \t"); part = part.substr(0,p3+1); ret[i] = part; } @@ -458,15 +472,15 @@ std::vector DataArray::SplitStringInChuncks(const std::string st, s */ std::string DataArray::GetVarNameFromInfo(const std::string& info) { - std::size_t p1=info.find_last_of('['); - std::size_t p2=info.find_last_of(']'); + std::size_t const p1=info.find_last_of('['); + std::size_t const p2=info.find_last_of(']'); if(p1==std::string::npos || p2==std::string::npos) return info; if(p1>p2) return info; if(p1==0) return std::string(); - std::size_t p3=info.find_last_not_of(' ',p1-1); + std::size_t const p3=info.find_last_not_of(' ',p1-1); return info.substr(0,p3+1); } @@ -482,8 +496,8 @@ std::string DataArray::GetVarNameFromInfo(const std::string& info) */ std::string DataArray::GetUnitFromInfo(const std::string& info) { - std::size_t p1=info.find_last_of('['); - std::size_t p2=info.find_last_of(']'); + std::size_t const p1=info.find_last_of('['); + std::size_t const p2=info.find_last_of(']'); if(p1==std::string::npos || p2==std::string::npos) return std::string(); if(p1>p2) @@ -535,23 +549,23 @@ std::string DataArray::GetAxisTypeRepr(MEDCouplingAxisType at) DataArray *DataArray::Aggregate(const std::vector& arrs) { std::vector arr2; - for(std::vector::const_iterator it=arrs.begin();it!=arrs.end();it++) - if(*it) - arr2.push_back(*it); + for(auto arr : arrs) + if(arr) + arr2.push_back(arr); if(arr2.empty()) throw INTERP_KERNEL::Exception("DataArray::Aggregate : only null instance in input vector !"); std::vector arrd; std::vector arri; std::vector arrc; - for(std::vector::const_iterator it=arr2.begin();it!=arr2.end();it++) + for(auto it : arr2) { - const DataArrayDouble *a=dynamic_cast(*it); + const auto *a=dynamic_cast(it); if(a) { arrd.push_back(a); continue; } - const DataArrayIdType *b=dynamic_cast(*it); + const auto *b=dynamic_cast(it); if(b) { arri.push_back(b); continue; } - const DataArrayChar *c=dynamic_cast(*it); + const auto *c=dynamic_cast(it); if(c) { arrc.push_back(c); continue; } throw INTERP_KERNEL::Exception("DataArray::Aggregate : presence of not null instance in inuput that is not in [DataArrayDouble, DataArrayInt, DataArrayChar] !"); @@ -818,12 +832,12 @@ bool DataArrayDouble::isMonotonic(bool increasing, double eps) const checkAllocated(); if(getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("DataArrayDouble::isMonotonic : only supported with 'this' array with ONE component !"); - mcIdType nbOfElements(getNumberOfTuples()); + mcIdType const nbOfElements(getNumberOfTuples()); const double *ptr=getConstPointer(); if(nbOfElements==0) return true; double ref=ptr[0]; - double absEps=fabs(eps); + double const absEps=fabs(eps); if(increasing) { for(mcIdType i=1;i::const_iterator it=_info_on_compo.begin();it!=_info_on_compo.end();it++) - if(!(*it).empty()) + for(const auto & it : _info_on_compo) + if(!it.empty()) areAllEmpty=false; if(!areAllEmpty) for(std::size_t i=0;i<_info_on_compo.size();i++) @@ -871,7 +885,7 @@ void DataArrayDouble::writeVTK(std::ostream& ofs, mcIdType indent, const std::st for(const double *src=begin();src!=end();src++,pt++) *pt=float(*src); const char *data(reinterpret_cast((float *)tmp)); - std::size_t sz(getNbOfElems()*sizeof(float)); + std::size_t const sz(getNbOfElems()*sizeof(float)); byteArr->insertAtTheEnd(data,data+sz); byteArr->insertAtTheEnd(SPACE,SPACE+4); } @@ -885,8 +899,8 @@ void DataArrayDouble::writeVTK(std::ostream& ofs, mcIdType indent, const std::st void DataArrayDouble::reprCppStream(const std::string& varName, std::ostream& stream) const { - mcIdType nbTuples=getNumberOfTuples(); - std::size_t nbComp=getNumberOfComponents(); + mcIdType const nbTuples=getNumberOfTuples(); + std::size_t const nbComp=getNumberOfComponents(); const double *data(getConstPointer()); stream.precision(17); stream << "DataArrayDouble *" << varName << "=DataArrayDouble::New();" << std::endl; @@ -911,10 +925,10 @@ void DataArrayDouble::reprQuickOverview(std::ostream& stream) const stream << "DataArrayDouble C++ instance at " << this << ". "; if(isAllocated()) { - std::size_t nbOfCompo(_info_on_compo.size()); + std::size_t const nbOfCompo(_info_on_compo.size()); if(nbOfCompo>=1) { - mcIdType nbOfTuples(getNumberOfTuples()); + mcIdType const nbOfTuples(getNumberOfTuples()); stream << "Number of tuples : " << nbOfTuples << ". Number of components : " << nbOfCompo << "." << std::endl; reprQuickOverviewData(stream,MAX_NB_OF_BYTE_IN_REPR); } @@ -928,8 +942,8 @@ void DataArrayDouble::reprQuickOverview(std::ostream& stream) const void DataArrayDouble::reprQuickOverviewData(std::ostream& stream, std::size_t maxNbOfByteInRepr) const { const double *data=begin(); - mcIdType nbOfTuples(getNumberOfTuples()); - std::size_t nbOfCompo(_info_on_compo.size()); + mcIdType const nbOfTuples(getNumberOfTuples()); + std::size_t const nbOfCompo(_info_on_compo.size()); std::ostringstream oss2; oss2 << "["; oss2.precision(17); std::string oss2Str(oss2.str()); @@ -949,7 +963,7 @@ void DataArrayDouble::reprQuickOverviewData(std::ostream& stream, std::size_t ma else oss2 << *data++; if(i!=nbOfTuples-1) oss2 << ", "; - std::string oss3Str(oss2.str()); + std::string const oss3Str(oss2.str()); if(oss3Str.length()getNumberOfComponents()) throw INTERP_KERNEL::Exception("DataArrayDouble::areIncludedInMe : the number of components does not match !"); MCAuto a=DataArrayDouble::Aggregate(this,other); - DataArrayIdType *c=0,*ci=0; + DataArrayIdType *c=nullptr,*ci=nullptr; a->findCommonTuples(prec,getNumberOfTuples(),c,ci); MCAuto cSafe(c),ciSafe(ci); mcIdType newNbOfTuples=-1; @@ -1066,11 +1080,11 @@ bool DataArrayDouble::areIncludedInMe(const DataArrayDouble *other, double prec, void DataArrayDouble::findCommonTuples(double prec, mcIdType limitTupleId, DataArrayIdType *&comm, DataArrayIdType *&commIndex) const { checkAllocated(); - std::size_t nbOfCompo=getNumberOfComponents(); + std::size_t const nbOfCompo=getNumberOfComponents(); if ((nbOfCompo<1) || (nbOfCompo>4)) //test before work throw INTERP_KERNEL::Exception("DataArrayDouble::findCommonTuples : Unexpected spacedim of coords. Must be 1, 2, 3 or 4."); - mcIdType nbOfTuples(getNumberOfTuples()); + mcIdType const nbOfTuples(getNumberOfTuples()); // MCAuto c(DataArrayIdType::New()),cI(DataArrayIdType::New()); c->alloc(0,1); cI->pushBackSilent(0); switch(nbOfCompo) @@ -1107,8 +1121,8 @@ void DataArrayDouble::findCommonTuples(double prec, mcIdType limitTupleId, DataA double DataArrayDouble::minimalDistanceTo(const DataArrayDouble *other, mcIdType& thisTupleId, mcIdType& otherTupleId) const { MCAuto part1=findClosestTupleId(other); - std::size_t nbOfCompo=getNumberOfComponents(); - mcIdType otherNbTuples=other->getNumberOfTuples(); + std::size_t const nbOfCompo=getNumberOfComponents(); + mcIdType const otherNbTuples=other->getNumberOfTuples(); const double *thisPt(begin()),*otherPt(other->begin()); const mcIdType *part1Pt(part1->begin()); double ret=std::numeric_limits::max(); @@ -1136,15 +1150,15 @@ DataArrayIdType *DataArrayDouble::findClosestTupleId(const DataArrayDouble *othe if(!other) throw INTERP_KERNEL::Exception("DataArrayDouble::findClosestTupleId : other instance is NULL !"); checkAllocated(); other->checkAllocated(); - std::size_t nbOfCompo(getNumberOfComponents()); + std::size_t const nbOfCompo(getNumberOfComponents()); if(nbOfCompo!=other->getNumberOfComponents()) { std::ostringstream oss; oss << "DataArrayDouble::findClosestTupleId : number of components in this is " << nbOfCompo; oss << ", whereas number of components in other is " << other->getNumberOfComponents() << "! Should be equal !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - mcIdType nbOfTuples(other->getNumberOfTuples()); - mcIdType thisNbOfTuples(getNumberOfTuples()); + mcIdType const nbOfTuples(other->getNumberOfTuples()); + mcIdType const thisNbOfTuples(getNumberOfTuples()); MCAuto ret=DataArrayIdType::New(); ret->alloc(nbOfTuples,1); double bounds[6]; getMinMaxPerComponent(bounds); @@ -1154,24 +1168,24 @@ DataArrayIdType *DataArrayDouble::findClosestTupleId(const DataArrayDouble *othe { double xDelta(fabs(bounds[1]-bounds[0])),yDelta(fabs(bounds[3]-bounds[2])),zDelta(fabs(bounds[5]-bounds[4])); double delta=std::max(xDelta,yDelta); delta=std::max(delta,zDelta); - double characSize=pow((delta*delta*delta)/((double)thisNbOfTuples),1./3.); - BBTreePts<3,mcIdType> myTree(begin(),0,0,getNumberOfTuples(),characSize*1e-12); + double const characSize=pow((delta*delta*delta)/((double)thisNbOfTuples),1./3.); + BBTreePts<3,mcIdType> const myTree(begin(),nullptr,0,getNumberOfTuples(),characSize*1e-12); FindClosestTupleIdAlg<3>(myTree,3.*characSize*characSize,other->begin(),nbOfTuples,begin(),thisNbOfTuples,ret->getPointer()); break; } case 2: { double xDelta(fabs(bounds[1]-bounds[0])),yDelta(fabs(bounds[3]-bounds[2])); - double delta=std::max(xDelta,yDelta); - double characSize=sqrt(delta/(double)thisNbOfTuples); - BBTreePts<2,mcIdType> myTree(begin(),0,0,getNumberOfTuples(),characSize*1e-12); + double const delta=std::max(xDelta,yDelta); + double const characSize=sqrt(delta/(double)thisNbOfTuples); + BBTreePts<2,mcIdType> const myTree(begin(),nullptr,0,getNumberOfTuples(),characSize*1e-12); FindClosestTupleIdAlg<2>(myTree,2.*characSize*characSize,other->begin(),nbOfTuples,begin(),thisNbOfTuples,ret->getPointer()); break; } case 1: { - double characSize=fabs(bounds[1]-bounds[0])/FromIdType(thisNbOfTuples); - BBTreePts<1,mcIdType> myTree(begin(),0,0,getNumberOfTuples(),characSize*1e-12); + double const characSize=fabs(bounds[1]-bounds[0])/FromIdType(thisNbOfTuples); + BBTreePts<1,mcIdType> const myTree(begin(),nullptr,0,getNumberOfTuples(),characSize*1e-12); FindClosestTupleIdAlg<1>(myTree,1.*characSize*characSize,other->begin(),nbOfTuples,begin(),thisNbOfTuples,ret->getPointer()); break; } @@ -1199,8 +1213,8 @@ DataArrayIdType *DataArrayDouble::computeNbOfInteractionsWith(const DataArrayDou throw INTERP_KERNEL::Exception("DataArrayDouble::computeNbOfInteractionsWith : input array is NULL !"); if(!isAllocated() || !otherBBoxFrmt->isAllocated()) throw INTERP_KERNEL::Exception("DataArrayDouble::computeNbOfInteractionsWith : this and input array must be allocated !"); - std::size_t nbOfComp(getNumberOfComponents()); - mcIdType nbOfTuples(getNumberOfTuples()); + std::size_t const nbOfComp(getNumberOfComponents()); + mcIdType const nbOfTuples(getNumberOfTuples()); if(nbOfComp!=otherBBoxFrmt->getNumberOfComponents()) { std::ostringstream oss; oss << "DataArrayDouble::computeNbOfInteractionsWith : this number of components (" << nbOfComp << ") must be equal to the number of components of input array (" << otherBBoxFrmt->getNumberOfComponents() << ") !"; @@ -1218,21 +1232,21 @@ DataArrayIdType *DataArrayDouble::computeNbOfInteractionsWith(const DataArrayDou { case 3: { - BBTree<3,mcIdType> bbt(otherBBoxFrmt->begin(),0,0,otherBBoxFrmt->getNumberOfTuples(),eps); + BBTree<3,mcIdType> bbt(otherBBoxFrmt->begin(),nullptr,0,otherBBoxFrmt->getNumberOfTuples(),eps); for(mcIdType i=0;i bbt(otherBBoxFrmt->begin(),0,0,otherBBoxFrmt->getNumberOfTuples(),eps); + BBTree<2,mcIdType> bbt(otherBBoxFrmt->begin(),nullptr,0,otherBBoxFrmt->getNumberOfTuples(),eps); for(mcIdType i=0;i bbt(otherBBoxFrmt->begin(),0,0,otherBBoxFrmt->getNumberOfTuples(),eps); + BBTree<1,mcIdType> bbt(otherBBoxFrmt->begin(),nullptr,0,otherBBoxFrmt->getNumberOfTuples(),eps); for(mcIdType i=0;i c(c0),cI(cI0); mcIdType newNbOfTuples=-1; @@ -1296,9 +1310,9 @@ void DataArrayDouble::setSelectedComponents(const DataArrayDouble *a, const std: throw INTERP_KERNEL::Exception("DataArrayDouble::setSelectedComponents : input DataArrayDouble is NULL !"); checkAllocated(); copyPartOfStringInfoFrom2(compoIds,*a); - std::size_t partOfCompoSz=compoIds.size(); - std::size_t nbOfCompo=getNumberOfComponents(); - mcIdType nbOfTuples=std::min(getNumberOfTuples(),a->getNumberOfTuples()); + std::size_t const partOfCompoSz=compoIds.size(); + std::size_t const nbOfCompo=getNumberOfComponents(); + mcIdType const nbOfTuples=std::min(getNumberOfTuples(),a->getNumberOfTuples()); const double *ac=a->getConstPointer(); double *nc=getPointer(); for(mcIdType i=0;i::max(); bounds[idim*2+1]=-std::numeric_limits::max(); } const double *ptr=getConstPointer(); - mcIdType nbOfTuples=getNumberOfTuples(); + mcIdType const nbOfTuples=getNumberOfTuples(); for(mcIdType i=0;i bbox=DataArrayDouble::New(); bbox->alloc(nbTuples,2*nbOfCompo); double *bboxPtr=bbox->getPointer(); @@ -1411,30 +1425,30 @@ void DataArrayDouble::computeTupleIdsNearTuples(const DataArrayDouble *other, do throw INTERP_KERNEL::Exception("DataArrayDouble::computeTupleIdsNearTuples : input pointer other is null !"); checkAllocated(); other->checkAllocated(); - std::size_t nbOfCompo=getNumberOfComponents(); - std::size_t otherNbOfCompo=other->getNumberOfComponents(); + std::size_t const nbOfCompo=getNumberOfComponents(); + std::size_t const otherNbOfCompo=other->getNumberOfComponents(); if(nbOfCompo!=otherNbOfCompo) throw INTERP_KERNEL::Exception("DataArrayDouble::computeTupleIdsNearTuples : number of components should be equal between this and other !"); - mcIdType nbOfTuplesOther=other->getNumberOfTuples(); - mcIdType nbOfTuples=getNumberOfTuples(); + mcIdType const nbOfTuplesOther=other->getNumberOfTuples(); + mcIdType const nbOfTuples=getNumberOfTuples(); MCAuto cArr(DataArrayIdType::New()),cIArr(DataArrayIdType::New()); cArr->alloc(0,1); cIArr->pushBackSilent(0); switch(nbOfCompo) { case 3: { - BBTreePts<3,mcIdType> myTree(begin(),0,0,nbOfTuples,eps); + BBTreePts<3,mcIdType> const myTree(begin(),nullptr,0,nbOfTuples,eps); FindTupleIdsNearTuplesAlg<3>(myTree,other->getConstPointer(),nbOfTuplesOther,eps,cArr,cIArr); break; } case 2: { - BBTreePts<2,mcIdType> myTree(begin(),0,0,nbOfTuples,eps); + BBTreePts<2,mcIdType> const myTree(begin(),nullptr,0,nbOfTuples,eps); FindTupleIdsNearTuplesAlg<2>(myTree,other->getConstPointer(),nbOfTuplesOther,eps,cArr,cIArr); break; } case 1: { - BBTreePts<1,mcIdType> myTree(begin(),0,0,nbOfTuples,eps); + BBTreePts<1,mcIdType> const myTree(begin(),nullptr,0,nbOfTuples,eps); FindTupleIdsNearTuplesAlg<1>(myTree,other->getConstPointer(),nbOfTuplesOther,eps,cArr,cIArr); break; } @@ -1453,13 +1467,13 @@ void DataArrayDouble::computeTupleIdsNearTuples(const DataArrayDouble *other, do void DataArrayDouble::recenterForMaxPrecision(double eps) { checkAllocated(); - std::size_t dim=getNumberOfComponents(); + std::size_t const dim=getNumberOfComponents(); std::vector bounds(2*dim); getMinMaxPerComponent(&bounds[0]); for(std::size_t i=0;ieps) applyLin(1./delta,-offset/delta,i); else @@ -1479,8 +1493,8 @@ void DataArrayDouble::recenterForMaxPrecision(double eps) double DataArrayDouble::getMaxValue2(DataArrayIdType*& tupleIds) const { mcIdType tmp; - tupleIds=0; - double ret=getMaxValue(tmp); + tupleIds=nullptr; + double const ret=getMaxValue(tmp); tupleIds=findIdsInRange(ret,ret); return ret; } @@ -1497,8 +1511,8 @@ double DataArrayDouble::getMaxValue2(DataArrayIdType*& tupleIds) const double DataArrayDouble::getMinValue2(DataArrayIdType*& tupleIds) const { mcIdType tmp; - tupleIds=0; - double ret=getMinValue(tmp); + tupleIds=nullptr; + double const ret=getMinValue(tmp); tupleIds=findIdsInRange(ret,ret); return ret; } @@ -1519,7 +1533,7 @@ mcIdType DataArrayDouble::count(double value, double eps) const if(getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("DataArrayDouble::count : must be applied on DataArrayDouble with only one component, you can call 'rearrange' method before !"); const double *vals=begin(); - mcIdType nbOfTuples=getNumberOfTuples(); + mcIdType const nbOfTuples=getNumberOfTuples(); for(mcIdType i=0;i 0 !"); const double *vals=getConstPointer(); - double ret=std::accumulate(vals,vals+nbOfTuples,0.); + double const ret=std::accumulate(vals,vals+nbOfTuples,0.); return ret/FromIdType(nbOfTuples); } @@ -1554,7 +1568,7 @@ double DataArrayDouble::norm2() const { checkAllocated(); double ret=0.; - std::size_t nbOfElems=getNbOfElems(); + std::size_t const nbOfElems=getNbOfElems(); const double *pt=getConstPointer(); for(std::size_t i=0;iret) ret=val; } @@ -1594,14 +1608,14 @@ double DataArrayDouble::normMax() const void DataArrayDouble::normMaxPerComponent(double * res) const { checkAllocated(); - mcIdType nbOfTuples(getNumberOfTuples()); - std::size_t nbOfCompos(getNumberOfComponents()); + mcIdType const nbOfTuples(getNumberOfTuples()); + std::size_t const nbOfCompos(getNumberOfComponents()); std::fill(res, res+nbOfCompos, -1.0); const double *pt(getConstPointer()); for(mcIdType i=0;ires[j]) res[j]=val; } @@ -1620,11 +1634,11 @@ double DataArrayDouble::normMin() const { checkAllocated(); double ret(std::numeric_limits::max()); - std::size_t nbOfElems(getNbOfElems()); + std::size_t const nbOfElems(getNbOfElems()); const double *pt(getConstPointer()); for(std::size_t i=0;i()); @@ -1666,8 +1680,8 @@ void DataArrayDouble::accumulate(double *res) const double DataArrayDouble::distanceToTuple(const double *tupleBg, const double *tupleEnd, mcIdType& tupleId) const { checkAllocated(); - mcIdType nbTuple(getNumberOfTuples()); - std::size_t nbComps(getNumberOfComponents()); + mcIdType const nbTuple(getNumberOfTuples()); + std::size_t const nbComps(getNumberOfComponents()); if(nbComps!=(std::size_t)std::distance(tupleBg,tupleEnd)) { std::ostringstream oss; oss << "DataArrayDouble::distanceToTuple : size of input tuple is " << std::distance(tupleBg,tupleEnd) << " should be equal to the number of components in this : " << nbComps << " !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } if(nbTuple==0) @@ -1700,8 +1714,8 @@ double DataArrayDouble::accumulate(std::size_t compId) const { checkAllocated(); const double *ptr=getConstPointer(); - mcIdType nbTuple(getNumberOfTuples()); - std::size_t nbComps(getNumberOfComponents()); + mcIdType const nbTuple(getNumberOfTuples()); + std::size_t const nbComps(getNumberOfComponents()); if(compId>=nbComps) throw INTERP_KERNEL::Exception("DataArrayDouble::accumulate : Invalid compId specified : No such nb of components !"); double ret=0.; @@ -1732,8 +1746,8 @@ DataArrayDouble *DataArrayDouble::accumulatePerChunck(const mcIdType *bgOfIndex, if(!bgOfIndex || !endOfIndex) throw INTERP_KERNEL::Exception("DataArrayDouble::accumulatePerChunck : input pointer NULL !"); checkAllocated(); - std::size_t nbCompo(getNumberOfComponents()); - mcIdType nbOfTuples(getNumberOfTuples()); + std::size_t const nbCompo(getNumberOfComponents()); + mcIdType const nbOfTuples(getNumberOfTuples()); std::size_t sz=std::distance(bgOfIndex,endOfIndex); if(sz<1) throw INTERP_KERNEL::Exception("DataArrayDouble::accumulatePerChunck : invalid size of input index array !"); @@ -1781,7 +1795,7 @@ MCAuto DataArrayDouble::cumSum() const { checkAllocated(); checkNbOfComps(1,"DataArrayDouble::cumSum : this is expected to be single component"); - mcIdType nbOfTuple(getNumberOfTuples()); + mcIdType const nbOfTuple(getNumberOfTuples()); MCAuto ret(DataArrayDouble::New()); ret->alloc(nbOfTuple+1,1); double *ptr(ret->getPointer()); ptr[0]=0.; @@ -1805,10 +1819,10 @@ MCAuto DataArrayDouble::cumSum() const DataArrayDouble *DataArrayDouble::fromPolarToCart() const { checkAllocated(); - std::size_t nbOfComp(getNumberOfComponents()); + std::size_t const nbOfComp(getNumberOfComponents()); if(nbOfComp!=2) throw INTERP_KERNEL::Exception("DataArrayDouble::fromPolarToCart : must be an array with exactly 2 components !"); - mcIdType nbOfTuple(getNumberOfTuples()); + mcIdType const nbOfTuple(getNumberOfTuples()); DataArrayDouble *ret(DataArrayDouble::New()); ret->alloc(nbOfTuple,2); double *w(ret->getPointer()); @@ -1836,10 +1850,10 @@ DataArrayDouble *DataArrayDouble::fromPolarToCart() const DataArrayDouble *DataArrayDouble::fromCylToCart() const { checkAllocated(); - std::size_t nbOfComp(getNumberOfComponents()); + std::size_t const nbOfComp(getNumberOfComponents()); if(nbOfComp!=3) throw INTERP_KERNEL::Exception("DataArrayDouble::fromCylToCart : must be an array with exactly 3 components !"); - mcIdType nbOfTuple(getNumberOfTuples()); + mcIdType const nbOfTuple(getNumberOfTuples()); DataArrayDouble *ret(DataArrayDouble::New()); ret->alloc(getNumberOfTuples(),3); double *w(ret->getPointer()); @@ -1869,10 +1883,10 @@ DataArrayDouble *DataArrayDouble::fromCylToCart() const DataArrayDouble *DataArrayDouble::fromSpherToCart() const { checkAllocated(); - std::size_t nbOfComp(getNumberOfComponents()); + std::size_t const nbOfComp(getNumberOfComponents()); if(nbOfComp!=3) throw INTERP_KERNEL::Exception("DataArrayDouble::fromSpherToCart : must be an array with exactly 3 components !"); - mcIdType nbOfTuple(getNumberOfTuples()); + mcIdType const nbOfTuple(getNumberOfTuples()); DataArrayDouble *ret(DataArrayDouble::New()); ret->alloc(getNumberOfTuples(),3); double *w(ret->getPointer()); @@ -1897,7 +1911,7 @@ DataArrayDouble *DataArrayDouble::fromSpherToCart() const DataArrayDouble *DataArrayDouble::cartesianize(MEDCouplingAxisType atOfThis) const { checkAllocated(); - std::size_t nbOfComp(getNumberOfComponents()); + std::size_t const nbOfComp(getNumberOfComponents()); MCAuto ret; switch(atOfThis) { @@ -1946,8 +1960,8 @@ DataArrayDouble *DataArrayDouble::fromCartToPolar() const { MCAuto ret(DataArrayDouble::New()); checkAllocated(); - std::size_t nbOfComp(getNumberOfComponents()); - mcIdType nbTuples(getNumberOfTuples()); + std::size_t const nbOfComp(getNumberOfComponents()); + mcIdType const nbTuples(getNumberOfTuples()); if(nbOfComp!=2) throw INTERP_KERNEL::Exception("DataArrayDouble::fromCartToPolar : must be an array with exactly 2 components !"); ret->alloc(nbTuples,2); @@ -1970,8 +1984,8 @@ DataArrayDouble *DataArrayDouble::fromCartToCyl() const { MCAuto ret(DataArrayDouble::New()); checkAllocated(); - std::size_t nbOfComp(getNumberOfComponents()); - mcIdType nbTuples(getNumberOfTuples()); + std::size_t const nbOfComp(getNumberOfComponents()); + mcIdType const nbTuples(getNumberOfTuples()); if(nbOfComp!=3) throw INTERP_KERNEL::Exception("DataArrayDouble::fromCartToCyl : must be an array with exactly 3 components !"); ret->alloc(nbTuples,3); @@ -1994,8 +2008,8 @@ DataArrayDouble *DataArrayDouble::fromCartToSpher() const { MCAuto ret(DataArrayDouble::New()); checkAllocated(); - std::size_t nbOfComp(getNumberOfComponents()); - mcIdType nbTuples(getNumberOfTuples()); + std::size_t const nbOfComp(getNumberOfComponents()); + mcIdType const nbTuples(getNumberOfTuples()); if(nbOfComp!=3) throw INTERP_KERNEL::Exception("DataArrayDouble::fromCartToSpher : must be an array with exactly 3 components !"); ret->alloc(nbTuples,3); @@ -2021,8 +2035,8 @@ DataArrayDouble *DataArrayDouble::fromCartToCylGiven(const DataArrayDouble *coor throw INTERP_KERNEL::Exception("DataArrayDouble::fromCartToCylGiven : input coords are NULL !"); MCAuto ret(DataArrayDouble::New()); checkAllocated(); coords->checkAllocated(); - std::size_t nbOfComp(getNumberOfComponents()); - mcIdType nbTuples(getNumberOfTuples()); + std::size_t const nbOfComp(getNumberOfComponents()); + mcIdType const nbTuples(getNumberOfTuples()); if(nbOfComp!=3) throw INTERP_KERNEL::Exception("DataArrayDouble::fromCartToCylGiven : must be an array with exactly 3 components !"); if(coords->getNumberOfComponents()!=3) @@ -2030,7 +2044,7 @@ DataArrayDouble *DataArrayDouble::fromCartToCylGiven(const DataArrayDouble *coor if(coords->getNumberOfTuples()!=nbTuples) throw INTERP_KERNEL::Exception("DataArrayDouble::fromCartToCylGiven : coords array must have the same number of tuples !"); ret->alloc(nbTuples,nbOfComp); - double magOfVect(sqrt(vect[0]*vect[0]+vect[1]*vect[1]+vect[2]*vect[2])); + double const magOfVect(sqrt(vect[0]*vect[0]+vect[1]*vect[1]+vect[2]*vect[2])); if(magOfVect<1e-12) throw INTERP_KERNEL::Exception("DataArrayDouble::fromCartToCylGiven : magnitude of vect is too low !"); double Ur[3],Uteta[3],Uz[3],*retPtr(ret->getPointer()); @@ -2040,7 +2054,7 @@ DataArrayDouble *DataArrayDouble::fromCartToCylGiven(const DataArrayDouble *coor { std::transform(coo,coo+3,center,Ur,std::minus()); Uteta[0]=Uz[1]*Ur[2]-Uz[2]*Ur[1]; Uteta[1]=Uz[2]*Ur[0]-Uz[0]*Ur[2]; Uteta[2]=Uz[0]*Ur[1]-Uz[1]*Ur[0]; - double magOfTeta(sqrt(Uteta[0]*Uteta[0]+Uteta[1]*Uteta[1]+Uteta[2]*Uteta[2])); + double const magOfTeta(sqrt(Uteta[0]*Uteta[0]+Uteta[1]*Uteta[1]+Uteta[2]*Uteta[2])); std::transform(Uteta,Uteta+3,Uteta,std::bind(std::multiplies(),std::placeholders::_1,1./magOfTeta)); Ur[0]=Uteta[1]*Uz[2]-Uteta[2]*Uz[1]; Ur[1]=Uteta[2]*Uz[0]-Uteta[0]*Uz[2]; Ur[2]=Uteta[0]*Uz[1]-Uteta[1]*Uz[0]; retPtr[0]=Ur[0]*vectField[0]+Ur[1]*vectField[1]+Ur[2]*vectField[2]; @@ -2063,11 +2077,11 @@ DataArrayDouble *DataArrayDouble::fromCartToCylGiven(const DataArrayDouble *coor DataArrayDouble *DataArrayDouble::doublyContractedProduct() const { checkAllocated(); - std::size_t nbOfComp(getNumberOfComponents()); + std::size_t const nbOfComp(getNumberOfComponents()); if(nbOfComp!=6) throw INTERP_KERNEL::Exception("DataArrayDouble::doublyContractedProduct : must be an array with exactly 6 components !"); DataArrayDouble *ret=DataArrayDouble::New(); - mcIdType nbOfTuple=getNumberOfTuples(); + mcIdType const nbOfTuple=getNumberOfTuples(); ret->alloc(nbOfTuple,1); const double *src=getConstPointer(); double *dest=ret->getPointer(); @@ -2090,7 +2104,7 @@ DataArrayDouble *DataArrayDouble::determinant() const { checkAllocated(); DataArrayDouble *ret=DataArrayDouble::New(); - mcIdType nbOfTuple=getNumberOfTuples(); + mcIdType const nbOfTuple=getNumberOfTuples(); ret->alloc(nbOfTuple,1); const double *src=getConstPointer(); double *dest=ret->getPointer(); @@ -2133,11 +2147,11 @@ DataArrayDouble *DataArrayDouble::determinant() const DataArrayDouble *DataArrayDouble::eigenValues() const { checkAllocated(); - std::size_t nbOfComp=getNumberOfComponents(); + std::size_t const nbOfComp=getNumberOfComponents(); if(nbOfComp!=6) throw INTERP_KERNEL::Exception("DataArrayDouble::eigenValues : must be an array with exactly 6 components !"); DataArrayDouble *ret=DataArrayDouble::New(); - mcIdType nbOfTuple=getNumberOfTuples(); + mcIdType const nbOfTuple=getNumberOfTuples(); ret->alloc(nbOfTuple,3); const double *src=getConstPointer(); double *dest=ret->getPointer(); @@ -2165,11 +2179,11 @@ DataArrayDouble *DataArrayDouble::eigenValues() const DataArrayDouble *DataArrayDouble::eigenVectors() const { checkAllocated(); - std::size_t nbOfComp=getNumberOfComponents(); + std::size_t const nbOfComp=getNumberOfComponents(); if(nbOfComp!=6) throw INTERP_KERNEL::Exception("DataArrayDouble::eigenVectors : must be an array with exactly 6 components !"); DataArrayDouble *ret=DataArrayDouble::New(); - mcIdType nbOfTuple=getNumberOfTuples(); + mcIdType const nbOfTuple=getNumberOfTuples(); ret->alloc(nbOfTuple,9); const double *src=getConstPointer(); double *dest=ret->getPointer(); @@ -2197,18 +2211,18 @@ DataArrayDouble *DataArrayDouble::eigenVectors() const DataArrayDouble *DataArrayDouble::inverse() const { checkAllocated(); - std::size_t nbOfComp=getNumberOfComponents(); + std::size_t const nbOfComp=getNumberOfComponents(); if(nbOfComp!=6 && nbOfComp!=9 && nbOfComp!=4) throw INTERP_KERNEL::Exception("DataArrayDouble::inversion : must be an array with 4,6 or 9 components !"); DataArrayDouble *ret=DataArrayDouble::New(); - mcIdType nbOfTuple=getNumberOfTuples(); + mcIdType const nbOfTuple=getNumberOfTuples(); ret->alloc(nbOfTuple,nbOfComp); const double *src=getConstPointer(); double *dest=ret->getPointer(); if(nbOfComp==6) for(mcIdType i=0;ialloc(nbOfTuple,1); const double *src=getConstPointer(); double *dest=ret->getPointer(); @@ -2288,17 +2302,17 @@ DataArrayDouble *DataArrayDouble::trace() const DataArrayDouble *DataArrayDouble::deviator() const { checkAllocated(); - std::size_t nbOfComp=getNumberOfComponents(); + std::size_t const nbOfComp=getNumberOfComponents(); if(nbOfComp!=6) throw INTERP_KERNEL::Exception("DataArrayDouble::deviator : must be an array with exactly 6 components !"); DataArrayDouble *ret=DataArrayDouble::New(); - mcIdType nbOfTuple=getNumberOfTuples(); + mcIdType const nbOfTuple=getNumberOfTuples(); ret->alloc(nbOfTuple,6); const double *src=getConstPointer(); double *dest=ret->getPointer(); for(mcIdType i=0;ialloc(nbOfTuple,1); const double *src=getConstPointer(); double *dest=ret->getPointer(); @@ -2340,9 +2354,9 @@ DataArrayDouble *DataArrayDouble::magnitude() const DataArrayDouble *DataArrayDouble::operatePerTuple(std::function func) const { checkAllocated(); - std::size_t nbOfComp(getNumberOfComponents()); + std::size_t const nbOfComp(getNumberOfComponents()); MCAuto ret=DataArrayDouble::New(); - mcIdType nbOfTuple(getNumberOfTuples()); + mcIdType const nbOfTuple(getNumberOfTuples()); ret->alloc(nbOfTuple,1); const double *src=getConstPointer(); double *dest=ret->getPointer(); @@ -2395,10 +2409,10 @@ DataArrayDouble *DataArrayDouble::minPerTuple() const DataArrayDouble *DataArrayDouble::maxPerTupleWithCompoId(DataArrayIdType* &compoIdOfMaxPerTuple) const { checkAllocated(); - std::size_t nbOfComp(getNumberOfComponents()); + std::size_t const nbOfComp(getNumberOfComponents()); MCAuto ret0=DataArrayDouble::New(); MCAuto ret1=DataArrayIdType::New(); - mcIdType nbOfTuple=getNumberOfTuples(); + mcIdType const nbOfTuple=getNumberOfTuples(); ret0->alloc(nbOfTuple,1); ret1->alloc(nbOfTuple,1); const double *src=getConstPointer(); double *dest=ret0->getPointer(); mcIdType *dest1=ret1->getPointer(); @@ -2429,8 +2443,8 @@ DataArrayDouble *DataArrayDouble::maxPerTupleWithCompoId(DataArrayIdType* &compo DataArrayDouble *DataArrayDouble::buildEuclidianDistanceDenseMatrix() const { checkAllocated(); - std::size_t nbOfComp(getNumberOfComponents()); - mcIdType nbOfTuples(getNumberOfTuples()); + std::size_t const nbOfComp(getNumberOfComponents()); + mcIdType const nbOfTuples(getNumberOfTuples()); const double *inData=getConstPointer(); MCAuto ret=DataArrayDouble::New(); ret->alloc(nbOfTuples*nbOfTuples,1); @@ -2442,7 +2456,7 @@ DataArrayDouble *DataArrayDouble::buildEuclidianDistanceDenseMatrix() const { double dist=0.; for(std::size_t k=0;kcheckAllocated(); - std::size_t nbOfComp(getNumberOfComponents()); - std::size_t otherNbOfComp(other->getNumberOfComponents()); + std::size_t const nbOfComp(getNumberOfComponents()); + std::size_t const otherNbOfComp(other->getNumberOfComponents()); if(nbOfComp!=otherNbOfComp) { std::ostringstream oss; oss << "DataArrayDouble::buildEuclidianDistanceDenseMatrixWith : this nb of compo=" << nbOfComp << " and other nb of compo=" << otherNbOfComp << ". It should match !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - mcIdType nbOfTuples(getNumberOfTuples()); - mcIdType otherNbOfTuples(other->getNumberOfTuples()); + mcIdType const nbOfTuples(getNumberOfTuples()); + mcIdType const otherNbOfTuples(other->getNumberOfTuples()); const double *inData=getConstPointer(); const double *inDataOther=other->getConstPointer(); MCAuto ret=DataArrayDouble::New(); @@ -2493,7 +2507,7 @@ DataArrayDouble *DataArrayDouble::buildEuclidianDistanceDenseMatrixWith(const Da { double dist=0.; for(std::size_t k=0;k n0(new INTERP_KERNEL::Node(pt[0],pt[1])),n1(new INTERP_KERNEL::Node(pt[2],pt[3])),n2(new INTERP_KERNEL::Node(pt[4],pt[5])); { INTERP_KERNEL::AutoCppPtr e1(new INTERP_KERNEL::EdgeLin(n0,n2)),e2(new INTERP_KERNEL::EdgeLin(n2,n1)); - INTERP_KERNEL::SegSegIntersector inters(*e1,*e2); - bool colinearity(inters.areColinears()); + INTERP_KERNEL::SegSegIntersector const inters(*e1,*e2); + bool const colinearity(inters.areColinears()); if(colinearity) throw INTERP_KERNEL::Exception("DataArrayDouble::asArcOfCircle : 3 points in this have been detected as colinear !"); } @@ -2543,8 +2557,8 @@ void DataArrayDouble::sortPerTuple(bool asc) { checkAllocated(); double *pt=getPointer(); - mcIdType nbOfTuple(getNumberOfTuples()); - std::size_t nbOfComp(getNumberOfComponents()); + mcIdType const nbOfTuple(getNumberOfTuples()); + std::size_t const nbOfComp(getNumberOfComponents()); if(asc) for(mcIdType i=0;istd::numeric_limits::min()) @@ -2599,9 +2613,9 @@ void DataArrayDouble::applyPow(double val) { checkAllocated(); double *ptr=getPointer(); - std::size_t nbOfElems=getNbOfElems(); - int val2=(int)val; - bool isInt=((double)val2)==val; + std::size_t const nbOfElems=getNbOfElems(); + int const val2=(int)val; + bool const isInt=((double)val2)==val; if(!isInt) { for(std::size_t i=0;i= 0 !"); double *ptr=getPointer(); - std::size_t nbOfElems=getNbOfElems(); + std::size_t const nbOfElems=getNbOfElems(); for(std::size_t i=0;ialloc(nbOfTuples,nbOfComp); const double *ptr=getConstPointer(); double *ptrToFill=newArr->getPointer(); @@ -2708,7 +2722,7 @@ DataArrayDouble *DataArrayDouble::applyFunc(std::size_t nbOfComp, const std::str expr.parse(); std::set vars; expr.getTrueSetOfVars(vars); - std::vector varsV(vars.begin(),vars.end()); + std::vector const varsV(vars.begin(),vars.end()); return applyFuncNamedCompo(nbOfComp,varsV,func,isSafe); } @@ -2732,11 +2746,11 @@ DataArrayDouble *DataArrayDouble::applyFunc(std::size_t nbOfComp, const std::str */ DataArrayDouble *DataArrayDouble::applyFunc(const std::string& func, bool isSafe) const { - std::size_t nbOfComp(getNumberOfComponents()); + std::size_t const nbOfComp(getNumberOfComponents()); if(nbOfComp<=0) throw INTERP_KERNEL::Exception("DataArrayDouble::applyFunc : output number of component must be > 0 !"); checkAllocated(); - mcIdType nbOfTuples(getNumberOfTuples()); + mcIdType const nbOfTuples(getNumberOfTuples()); MCAuto newArr(DataArrayDouble::New()); newArr->alloc(nbOfTuples,nbOfComp); INTERP_KERNEL::ExprParser expr(func); @@ -2757,7 +2771,7 @@ DataArrayDouble *DataArrayDouble::applyFunc(const std::string& func, bool isSafe newArr->rearrange(nbOfComp); return newArr.retn(); } - std::vector vars2(vars.begin(),vars.end()); + std::vector const vars2(vars.begin(),vars.end()); double buff,*ptrToFill(newArr->getPointer()); const double *ptr(begin()); std::vector stck; @@ -2817,11 +2831,11 @@ DataArrayDouble *DataArrayDouble::applyFunc(const std::string& func, bool isSafe */ void DataArrayDouble::applyFuncOnThis(const std::string& func, bool isSafe) { - std::size_t nbOfComp(getNumberOfComponents()); + std::size_t const nbOfComp(getNumberOfComponents()); if(nbOfComp<=0) throw INTERP_KERNEL::Exception("DataArrayDouble::applyFuncOnThis : output number of component must be > 0 !"); checkAllocated(); - mcIdType nbOfTuples(getNumberOfTuples()); + mcIdType const nbOfTuples(getNumberOfTuples()); INTERP_KERNEL::ExprParser expr(func); expr.parse(); std::set vars; @@ -2835,14 +2849,14 @@ void DataArrayDouble::applyFuncOnThis(const std::string& func, bool isSafe) if(vars.empty()) { expr.prepareFastEvaluator(); - std::vector compInfo(getInfoOnComponents()); + std::vector const compInfo(getInfoOnComponents()); rearrange(1); fillWithValue(expr.evaluateDouble()); rearrange(nbOfComp); setInfoOnComponents(compInfo); return ; } - std::vector vars2(vars.begin(),vars.end()); + std::vector const vars2(vars.begin(),vars.end()); double buff,*ptrToFill(getPointer()); const double *ptr(begin()); std::vector stck; @@ -2931,11 +2945,11 @@ DataArrayDouble *DataArrayDouble::applyFuncNamedCompo(std::size_t nbOfComp, cons if(nbOfComp<=0) throw INTERP_KERNEL::Exception("DataArrayDouble::applyFuncNamedCompo : output number of component must be > 0 !"); std::vector varsOrder2(varsOrder); - std::size_t oldNbOfComp(getNumberOfComponents()); + std::size_t const oldNbOfComp(getNumberOfComponents()); for(std::size_t i=varsOrder.size();i vars; @@ -3002,9 +3016,9 @@ void DataArrayDouble::applyFuncFast32(const std::string& func) *((void **)&funcPtr)=funcStr;//he he... // double *ptr=getPointer(); - std::size_t nbOfComp=getNumberOfComponents(); - mcIdType nbOfTuples=getNumberOfTuples(); - std::size_t nbOfElems=nbOfTuples*nbOfComp; + std::size_t const nbOfComp=getNumberOfComponents(); + mcIdType const nbOfTuples=getNumberOfTuples(); + std::size_t const nbOfElems=nbOfTuples*nbOfComp; for(std::size_t i=0;i DataArrayDouble::symmetry3DPlane(const double point[3], checkAllocated(); if(getNumberOfComponents()!=3) throw INTERP_KERNEL::Exception("DataArrayDouble::symmetry3DPlane : this is excepted to have 3 components !"); - mcIdType nbTuples(getNumberOfTuples()); + mcIdType const nbTuples(getNumberOfTuples()); MCAuto ret(DataArrayDouble::New()); ret->alloc(nbTuples,3); Symmetry3DPlane(point,normalVector,nbTuples,begin(),ret->getPointer()); @@ -3072,7 +3086,7 @@ DataArrayIdType *DataArrayDouble::findIdsInRange(double vmin, double vmax) const throw INTERP_KERNEL::Exception("DataArrayDouble::findIdsInRange : this must have exactly one component !"); const double *cptr(begin()); MCAuto ret(DataArrayIdType::New()); ret->alloc(0,1); - mcIdType nbOfTuples(getNumberOfTuples()); + mcIdType const nbOfTuples(getNumberOfTuples()); for(mcIdType i=0;i=vmin && *cptr<=vmax) ret->pushBackSilent(i); @@ -3098,7 +3112,7 @@ DataArrayIdType *DataArrayDouble::findIdsNotInRange(double vmin, double vmax) co throw INTERP_KERNEL::Exception("DataArrayDouble::findIdsNotInRange : this must have exactly one component !"); const double *cptr(begin()); MCAuto ret(DataArrayIdType::New()); ret->alloc(0,1); - mcIdType nbOfTuples(getNumberOfTuples()); + mcIdType const nbOfTuples(getNumberOfTuples()); for(mcIdType i=0;ivmax) ret->pushBackSilent(i); @@ -3144,13 +3158,13 @@ DataArrayDouble *DataArrayDouble::Aggregate(const DataArrayDouble *a1, const Dat DataArrayDouble *DataArrayDouble::Aggregate(const std::vector& arr) { std::vector a; - for(std::vector::const_iterator it4=arr.begin();it4!=arr.end();it4++) - if(*it4) - a.push_back(*it4); + for(auto it4 : arr) + if(it4) + a.push_back(it4); if(a.empty()) throw INTERP_KERNEL::Exception("DataArrayDouble::Aggregate : input list must contain at least one NON EMPTY DataArrayDouble !"); std::vector::const_iterator it=a.begin(); - std::size_t nbOfComp((*it)->getNumberOfComponents()); + std::size_t const nbOfComp((*it)->getNumberOfComponents()); mcIdType nbt=(*it++)->getNumberOfTuples(); for(mcIdType i=1;it!=a.end();it++,i++) { @@ -3189,10 +3203,10 @@ DataArrayDouble *DataArrayDouble::Dot(const DataArrayDouble *a1, const DataArray throw INTERP_KERNEL::Exception("DataArrayDouble::Dot : input DataArrayDouble instance is NULL !"); a1->checkAllocated(); a2->checkAllocated(); - std::size_t nbOfComp(a1->getNumberOfComponents()); + std::size_t const nbOfComp(a1->getNumberOfComponents()); if(nbOfComp!=a2->getNumberOfComponents()) throw INTERP_KERNEL::Exception("Nb of components mismatch for array Dot !"); - mcIdType nbOfTuple(a1->getNumberOfTuples()); + mcIdType const nbOfTuple(a1->getNumberOfTuples()); if(nbOfTuple!=a2->getNumberOfTuples()) throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array Dot !"); DataArrayDouble *ret=DataArrayDouble::New(); @@ -3232,12 +3246,12 @@ DataArrayDouble *DataArrayDouble::CrossProduct(const DataArrayDouble *a1, const { if(!a1 || !a2) throw INTERP_KERNEL::Exception("DataArrayDouble::CrossProduct : input DataArrayDouble instance is NULL !"); - std::size_t nbOfComp(a1->getNumberOfComponents()); + std::size_t const nbOfComp(a1->getNumberOfComponents()); if(nbOfComp!=a2->getNumberOfComponents()) throw INTERP_KERNEL::Exception("Nb of components mismatch for array crossProduct !"); if(nbOfComp!=3) throw INTERP_KERNEL::Exception("Nb of components must be equal to 3 for array crossProduct !"); - mcIdType nbOfTuple(a1->getNumberOfTuples()); + mcIdType const nbOfTuple(a1->getNumberOfTuples()); if(nbOfTuple!=a2->getNumberOfTuples()) throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array crossProduct !"); DataArrayDouble *ret=DataArrayDouble::New(); @@ -3271,17 +3285,17 @@ DataArrayDouble *DataArrayDouble::Max(const DataArrayDouble *a1, const DataArray { if(!a1 || !a2) throw INTERP_KERNEL::Exception("DataArrayDouble::Max : input DataArrayDouble instance is NULL !"); - std::size_t nbOfComp(a1->getNumberOfComponents()); + std::size_t const nbOfComp(a1->getNumberOfComponents()); if(nbOfComp!=a2->getNumberOfComponents()) throw INTERP_KERNEL::Exception("Nb of components mismatch for array Max !"); - mcIdType nbOfTuple(a1->getNumberOfTuples()); + mcIdType const nbOfTuple(a1->getNumberOfTuples()); if(nbOfTuple!=a2->getNumberOfTuples()) throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array Max !"); MCAuto ret(DataArrayDouble::New()); ret->alloc(nbOfTuple,nbOfComp); double *retPtr(ret->getPointer()); const double *a1Ptr(a1->begin()),*a2Ptr(a2->begin()); - std::size_t nbElem(nbOfTuple*nbOfComp); + std::size_t const nbElem(nbOfTuple*nbOfComp); for(std::size_t i=0;icopyStringInfoFrom(*a1); @@ -3305,17 +3319,17 @@ DataArrayDouble *DataArrayDouble::Min(const DataArrayDouble *a1, const DataArray { if(!a1 || !a2) throw INTERP_KERNEL::Exception("DataArrayDouble::Min : input DataArrayDouble instance is NULL !"); - std::size_t nbOfComp(a1->getNumberOfComponents()); + std::size_t const nbOfComp(a1->getNumberOfComponents()); if(nbOfComp!=a2->getNumberOfComponents()) throw INTERP_KERNEL::Exception("Nb of components mismatch for array min !"); - mcIdType nbOfTuple(a1->getNumberOfTuples()); + mcIdType const nbOfTuple(a1->getNumberOfTuples()); if(nbOfTuple!=a2->getNumberOfTuples()) throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array min !"); MCAuto ret(DataArrayDouble::New()); ret->alloc(nbOfTuple,nbOfComp); double *retPtr(ret->getPointer()); const double *a1Ptr(a1->begin()),*a2Ptr(a2->begin()); - std::size_t nbElem(nbOfTuple*nbOfComp); + std::size_t const nbElem(nbOfTuple*nbOfComp); for(std::size_t i=0;icopyStringInfoFrom(*a1); @@ -3340,10 +3354,10 @@ DataArrayDouble *DataArrayDouble::Pow(const DataArrayDouble *a1, const DataArray { if(!a1 || !a2) throw INTERP_KERNEL::Exception("DataArrayDouble::Pow : at least one of input instances is null !"); - mcIdType nbOfTuple=a1->getNumberOfTuples(); - mcIdType nbOfTuple2=a2->getNumberOfTuples(); - std::size_t nbOfComp=a1->getNumberOfComponents(); - std::size_t nbOfComp2=a2->getNumberOfComponents(); + mcIdType const nbOfTuple=a1->getNumberOfTuples(); + mcIdType const nbOfTuple2=a2->getNumberOfTuples(); + std::size_t const nbOfComp=a1->getNumberOfComponents(); + std::size_t const nbOfComp2=a2->getNumberOfComponents(); if(nbOfTuple!=nbOfTuple2) throw INTERP_KERNEL::Exception("DataArrayDouble::Pow : number of tuples mismatches !"); if(nbOfComp!=1 || nbOfComp2!=1) @@ -3379,10 +3393,10 @@ void DataArrayDouble::powEqual(const DataArrayDouble *other) { if(!other) throw INTERP_KERNEL::Exception("DataArrayDouble::powEqual : input instance is null !"); - mcIdType nbOfTuple=getNumberOfTuples(); - mcIdType nbOfTuple2=other->getNumberOfTuples(); - std::size_t nbOfComp=getNumberOfComponents(); - std::size_t nbOfComp2=other->getNumberOfComponents(); + mcIdType const nbOfTuple=getNumberOfTuples(); + mcIdType const nbOfTuple2=other->getNumberOfTuples(); + std::size_t const nbOfComp=getNumberOfComponents(); + std::size_t const nbOfComp2=other->getNumberOfComponents(); if(nbOfTuple!=nbOfTuple2) throw INTERP_KERNEL::Exception("DataArrayDouble::powEqual : number of tuples mismatches !"); if(nbOfComp!=1 || nbOfComp2!=1) @@ -3415,7 +3429,7 @@ std::vector DataArrayDouble::toVectorOfBool(double eps) const checkAllocated(); if(getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("DataArrayDouble::toVectorOfBool : must be applied on single component array !"); - mcIdType nbt(getNumberOfTuples()); + mcIdType const nbt(getNumberOfTuples()); std::vector ret(nbt); const double *pt(begin()); for(mcIdType i=0;i& tinyInfoI) { - mcIdType nbOfTuple=tinyInfoI[0]; - mcIdType nbOfComp=tinyInfoI[1]; + mcIdType const nbOfTuple=tinyInfoI[0]; + mcIdType const nbOfComp=tinyInfoI[1]; if(nbOfTuple!=-1 || nbOfComp!=-1) { alloc(nbOfTuple,nbOfComp); @@ -3492,12 +3506,12 @@ bool DataArrayDouble::resizeForUnserialization(const std::vector& tiny /*! * Useless method for end user. Only for MPI/Corba/File serialsation for multi arrays class. */ -void DataArrayDouble::finishUnserialization(const std::vector& tinyInfoI, const std::vector& tinyInfoS) +void DataArrayDouble::finishUnserialization(const std::vector& /*tinyInfoI*/, const std::vector& tinyInfoS) { setName(tinyInfoS[0]); if(isAllocated()) { - std::size_t nbOfCompo(getNumberOfComponents()); + std::size_t const nbOfCompo(getNumberOfComponents()); for(std::size_t i=0;i::min()) throw INTERP_KERNEL::Exception("DataArrayDouble::Rotate3DAlg : magnitude of input vector is too close of 0. !"); std::transform(vect,vect+3,vectorNorm,std::bind(std::multiplies(),std::placeholders::_1,1/norm)); @@ -3610,8 +3624,8 @@ void DataArrayDouble::ComputeIntegralOfSeg2IntoTri3(const double seg2[4], const */ void DataArrayDouble::Rotate2DAlg(const double *center, double angle, mcIdType nbNodes, const double *coordsIn, double *coordsOut) { - double cosa=cos(angle); - double sina=sin(angle); + double const cosa=cos(angle); + double const sina=sin(angle); double matrix[4]; matrix[0]=cosa; matrix[1]=-sina; matrix[2]=sina; matrix[3]=cosa; double tmp[2]; diff --git a/src/MEDCoupling/MEDCouplingMemArray.hxx b/src/MEDCoupling/MEDCouplingMemArray.hxx old mode 100755 new mode 100644 index bde9a3816..170dae82e --- a/src/MEDCoupling/MEDCouplingMemArray.hxx +++ b/src/MEDCoupling/MEDCouplingMemArray.hxx @@ -30,9 +30,11 @@ #include "MEDCouplingMap.hxx" #include "BBTreePts.txx" +#include +#include #include +#include #include -#include #include namespace MEDCoupling @@ -51,14 +53,14 @@ namespace MEDCoupling class MEDCouplingPointer { public: - MEDCouplingPointer():_internal(0),_external(0) { } + MEDCouplingPointer():_internal(nullptr),_external(nullptr) { } void null() { _internal=0; _external=0; } bool isNull() const { return _internal==0 && _external==0; } void setInternal(T *pointer); void setExternal(const T *pointer); const T *getConstPointer() const { if(_internal) return _internal; else return _external; } const T *getConstPointerLoc(std::size_t offset) const { if(_internal) return _internal+offset; else return _external+offset; } - T *getPointer() { if(_internal) return _internal; if(_external) throw INTERP_KERNEL::Exception("Trying to write on an external pointer."); else return 0; } + T *getPointer() { if(_internal) return _internal; if(_external) throw INTERP_KERNEL::Exception("Trying to write on an external pointer."); else return nullptr; } private: T *_internal; const T *_external; @@ -68,9 +70,9 @@ namespace MEDCoupling class MemArray { public: - typedef void (*Deallocator)(void *,void *); + using Deallocator = void (*)(void *, void *); public: - MemArray():_nb_of_elem(0),_nb_of_elem_alloc(0),_ownership(false),_dealloc(0),_param_for_deallocator(0) { } + MemArray() = default; MemArray(const MemArray& other); bool isNull() const { return _pointer.isNull(); } const T *getConstPointerLoc(std::size_t offset) const { return _pointer.getConstPointerLoc(offset); } @@ -117,12 +119,12 @@ namespace MEDCoupling static void DestroyPointer(T *pt, Deallocator dealloc, void *param); static Deallocator BuildFromType(DeallocType type); private: - std::size_t _nb_of_elem; - std::size_t _nb_of_elem_alloc; - bool _ownership; + std::size_t _nb_of_elem{0}; + std::size_t _nb_of_elem_alloc{0}; + bool _ownership{false}; MEDCouplingPointer _pointer; - Deallocator _dealloc; - void *_param_for_deallocator; + Deallocator _dealloc{nullptr}; + void *_param_for_deallocator{nullptr}; }; template class DataArrayTools @@ -142,8 +144,8 @@ namespace MEDCoupling class MEDCOUPLING_EXPORT DataArray : public RefCountObject, public TimeLabel { public: - std::size_t getHeapMemorySizeWithoutChildren() const; - std::vector getDirectChildrenWithNull() const; + std::size_t getHeapMemorySizeWithoutChildren() const override; + std::vector getDirectChildrenWithNull() const override; void setName(const std::string& name); void copyStringInfoFrom(const DataArray& other); void copyPartOfStringInfoFrom(const DataArray& other, const std::vector& compoIds); @@ -213,7 +215,7 @@ namespace MEDCoupling virtual void reprQuickOverviewData(std::ostream& stream, std::size_t maxNbOfByteInRepr) const = 0; protected: DataArray() { } - ~DataArray() { } + ~DataArray() override = default; protected: static void CheckValueInRange(mcIdType ref, mcIdType value, const std::string& msg); static void CheckValueInRangeEx(mcIdType value, mcIdType start, mcIdType end, const std::string& msg); @@ -231,7 +233,7 @@ namespace MEDCoupling class DataArrayTemplate : public DataArray { public: - typedef T Type; + using Type = T; public: static MCAuto< typename Traits::ArrayTypeCh > NewFromStdVector(const typename std::vector& v); static MCAuto< typename Traits::ArrayTypeCh > NewFromArray(const T *arrBegin, const T *arrEnd); @@ -244,19 +246,19 @@ namespace MEDCoupling std::for_each(this->begin(),this->end(),[&comma,&oss](const T& elt) { oss << comma << elt; comma[0]=','; } ); oss << std::endl; } - std::size_t getHeapMemorySizeWithoutChildren() const; - void updateTime() const { } + std::size_t getHeapMemorySizeWithoutChildren() const override; + void updateTime() const override { } // - mcIdType getNumberOfTuples() const { return ToIdType(_info_on_compo.empty()?0:_mem.getNbOfElem()/getNumberOfComponents()); } - mcIdType getNbOfElems() const { return ToIdType(_mem.getNbOfElem()); } + mcIdType getNumberOfTuples() const override { return ToIdType(_info_on_compo.empty()?0:_mem.getNbOfElem()/getNumberOfComponents()); } + mcIdType getNbOfElems() const override { return ToIdType(_mem.getNbOfElem()); } bool empty() const; - void *getVoidStarPointer() { return getPointer(); } + void *getVoidStarPointer() override { return getPointer(); } const T *getConstPointer() const { return _mem.getConstPointer(); } const T *begin() const { return getConstPointer(); } const T *end() const { return getConstPointer()+getNbOfElems(); } T *rwBegin() { return getPointer(); } T *rwEnd() { return getPointer()+getNbOfElems(); } - void alloc(std::size_t nbOfTuple, std::size_t nbOfCompo=1); + void alloc(std::size_t nbOfTuple, std::size_t nbOfCompo=1) override; void useArray(const T *array, bool ownership, DeallocType type, std::size_t nbOfTuple, std::size_t nbOfCompo); void useExternalArrayWithRWAccess(const T *array, std::size_t nbOfTuple, std::size_t nbOfCompo); T getIJSafe(std::size_t tupleId, std::size_t compoId) const; @@ -267,10 +269,10 @@ namespace MEDCoupling T *getPointerSilent() { return _mem.getPointer(); } void pack() const; bool isAllocated() const override; - void checkAllocated() const; - void desallocate(); + void checkAllocated() const override; + void desallocate() override; void reserve(std::size_t nbOfElems); - void rearrange(std::size_t newNbOfCompo); + void rearrange(std::size_t newNbOfCompo) override; void transpose(); void pushBackSilent(T val); template @@ -278,14 +280,14 @@ namespace MEDCoupling T popBackSilent(); T front() const; T back() const; - std::size_t getNbOfElemAllocated() const { return _mem.getNbOfElemAllocated(); } + std::size_t getNbOfElemAllocated() const override { return _mem.getNbOfElemAllocated(); } void allocIfNecessary(std::size_t nbOfTuple, std::size_t nbOfCompo); void deepCopyFrom(const DataArrayTemplate& other); void reverse(); void fillWithValue(T val); - void reAlloc(std::size_t newNbOfTuple); - void renumberInPlace(const mcIdType *old2New); - void renumberInPlaceR(const mcIdType *new2Old); + void reAlloc(std::size_t newNbOfTuple) override; + void renumberInPlace(const mcIdType *old2New) override; + void renumberInPlaceR(const mcIdType *new2Old) override; void sort(bool asc=true); typename Traits::ArrayType *renumber(const mcIdType *old2New) const; typename Traits::ArrayType *renumberR(const mcIdType *new2Old) const; @@ -293,9 +295,9 @@ namespace MEDCoupling typename Traits::ArrayType *changeNbOfComponents(std::size_t newNbOfComp, T dftValue) const; typename Traits::ArrayType *subArray(mcIdType tupleIdBg, mcIdType tupleIdEnd=-1) const; MCAuto::ArrayTypeCh> selectPartDef(const PartDefinition* pd) const; - void circularPermutation(mcIdType nbOfShift=1); - void circularPermutationPerTuple(mcIdType nbOfShift=1); - void reversePerTuple(); + void circularPermutation(mcIdType nbOfShift=1) override; + void circularPermutationPerTuple(mcIdType nbOfShift=1) override; + void reversePerTuple() override; void setPartOfValues1(const typename Traits::ArrayType *a, mcIdType bgTuples, mcIdType endTuples, mcIdType stepTuples, mcIdType bgComp, mcIdType endComp, mcIdType stepComp, bool strictCompoCompare=true); void setPartOfValuesSimple1(T a, mcIdType bgTuples, mcIdType endTuples, mcIdType stepTuples, mcIdType bgComp, mcIdType endComp, mcIdType stepComp); void setPartOfValues2(const typename Traits::ArrayType *a, const mcIdType *bgTuples, const mcIdType *endTuples, const mcIdType *bgComp, const mcIdType *endComp, bool strictCompoCompare=true); @@ -305,8 +307,8 @@ namespace MEDCoupling void setPartOfValues4(const typename Traits::ArrayType *a, mcIdType bgTuples, mcIdType endTuples, mcIdType stepTuples, const mcIdType *bgComp, const mcIdType *endComp, bool strictCompoCompare=true); void setPartOfValuesSimple4(T a, mcIdType bgTuples, mcIdType endTuples, mcIdType stepTuples, const mcIdType *bgComp, const mcIdType *endComp); void setPartOfValuesAdv(const typename Traits::ArrayType *a, const DataArrayIdType *tuplesSelec); - void setContigPartOfSelectedValues(mcIdType tupleIdStart, const DataArray *aBase, const DataArrayIdType *tuplesSelec); - void setContigPartOfSelectedValuesSlice(mcIdType tupleIdStart, const DataArray *aBase, mcIdType bg, mcIdType end2, mcIdType step); + void setContigPartOfSelectedValues(mcIdType tupleIdStart, const DataArray *aBase, const DataArrayIdType *tuplesSelec) override; + void setContigPartOfSelectedValuesSlice(mcIdType tupleIdStart, const DataArray *aBase, mcIdType bg, mcIdType end2, mcIdType step) override; T getMaxValue(mcIdType& tupleId) const; T getMaxValueInArray() const; T getMaxAbsValue(std::size_t& tupleId) const; @@ -370,11 +372,11 @@ namespace MEDCoupling typename Traits::ArrayType *performCopyOrIncrRef(bool dCpy) const; typename Traits::ArrayType *sumPerTuple() const; void iota(T init=(T)0); - void reprStream(std::ostream& stream) const; - void reprZipStream(std::ostream& stream) const; + void reprStream(std::ostream& stream) const override; + void reprZipStream(std::ostream& stream) const override; void reprNotTooLongStream(std::ostream& stream) const; - void reprWithoutNameStream(std::ostream& stream) const; - void reprZipWithoutNameStream(std::ostream& stream) const; + void reprWithoutNameStream(std::ostream& stream) const override; + void reprZipWithoutNameStream(std::ostream& stream) const override; void reprNotTooLongWithoutNameStream(std::ostream& stream) const; std::string repr() const; std::string reprZip() const; @@ -406,18 +408,18 @@ namespace MEDCoupling public: static DataArrayFloat *New(); public:// abstract method overload - DataArrayFloat *deepCopy() const; + DataArrayFloat *deepCopy() const override; DataArrayFloat *copySorted(bool asc=true) const override { return this->copySortedImpl(asc); } std::string getClassName() const override { return std::string("DataArrayFloat"); } - DataArrayFloat *buildNewEmptyInstance() const { return DataArrayFloat::New(); } - DataArrayFloat *selectByTupleRanges(const std::vector >& ranges) const { return DataArrayTemplateFP::mySelectByTupleRanges(ranges); } - DataArrayFloat *keepSelectedComponents(const std::vector& compoIds) const { return DataArrayTemplateFP::myKeepSelectedComponents(compoIds); } - DataArrayFloat *selectByTupleId(const mcIdType *new2OldBg, const mcIdType *new2OldEnd) const { return this->mySelectByTupleId(new2OldBg,new2OldEnd); } - DataArrayFloat *selectByTupleIdSafe(const mcIdType *new2OldBg, const mcIdType *new2OldEnd) const { return DataArrayTemplateFP::mySelectByTupleIdSafe(new2OldBg,new2OldEnd); } - DataArrayFloat *selectByTupleIdSafeSlice(mcIdType bg, mcIdType end2, mcIdType step) const { return DataArrayTemplateFP::mySelectByTupleIdSafeSlice(bg,end2,step); } - void reprCppStream(const std::string& varName, std::ostream& stream) const; - void reprQuickOverview(std::ostream& stream) const; - void reprQuickOverviewData(std::ostream& stream, std::size_t maxNbOfByteInRepr) const; + DataArrayFloat *buildNewEmptyInstance() const override { return DataArrayFloat::New(); } + DataArrayFloat *selectByTupleRanges(const std::vector >& ranges) const override { return DataArrayTemplateFP::mySelectByTupleRanges(ranges); } + DataArrayFloat *keepSelectedComponents(const std::vector& compoIds) const override { return DataArrayTemplateFP::myKeepSelectedComponents(compoIds); } + DataArrayFloat *selectByTupleId(const mcIdType *new2OldBg, const mcIdType *new2OldEnd) const override { return this->mySelectByTupleId(new2OldBg,new2OldEnd); } + DataArrayFloat *selectByTupleIdSafe(const mcIdType *new2OldBg, const mcIdType *new2OldEnd) const override { return DataArrayTemplateFP::mySelectByTupleIdSafe(new2OldBg,new2OldEnd); } + DataArrayFloat *selectByTupleIdSafeSlice(mcIdType bg, mcIdType end2, mcIdType step) const override { return DataArrayTemplateFP::mySelectByTupleIdSafeSlice(bg,end2,step); } + void reprCppStream(const std::string& varName, std::ostream& stream) const override; + void reprQuickOverview(std::ostream& stream) const override; + void reprQuickOverviewData(std::ostream& stream, std::size_t maxNbOfByteInRepr) const override; public:// non abstract but essential bool isEqual(const DataArrayFloat& other, float prec) const; bool isEqualIfNotWhy(const DataArrayFloat& other, float prec, std::string& reason) const; @@ -425,7 +427,7 @@ namespace MEDCoupling public: DataArrayFloatIterator *iterator(); private: - ~DataArrayFloat() { } + ~DataArrayFloat() override = default; DataArrayFloat() { } }; } @@ -438,25 +440,25 @@ namespace MEDCoupling public: static DataArrayDouble *New(); double doubleValue() const; - DataArrayDouble *deepCopy() const; + DataArrayDouble *deepCopy() const override; DataArrayDouble *copySorted(bool asc=true) const override { return this->copySortedImpl(asc); } std::string getClassName() const override { return std::string("DataArrayDouble"); } - DataArrayDouble *buildNewEmptyInstance() const { return DataArrayDouble::New(); } + DataArrayDouble *buildNewEmptyInstance() const override { return DataArrayDouble::New(); } void checkMonotonic(bool increasing, double eps) const; bool isMonotonic(bool increasing, double eps) const; void writeVTK(std::ostream& ofs, mcIdType indent, const std::string& nameInFile, DataArrayByte *byteArr) const; - void reprCppStream(const std::string& varName, std::ostream& stream) const; - void reprQuickOverview(std::ostream& stream) const; - void reprQuickOverviewData(std::ostream& stream, std::size_t maxNbOfByteInRepr) const; + void reprCppStream(const std::string& varName, std::ostream& stream) const override; + void reprQuickOverview(std::ostream& stream) const override; + void reprQuickOverviewData(std::ostream& stream, std::size_t maxNbOfByteInRepr) const override; bool isEqual(const DataArrayDouble& other, double prec) const; bool isEqualIfNotWhy(const DataArrayDouble& other, double prec, std::string& reason) const; bool isEqualWithoutConsideringStr(const DataArrayDouble& other, double prec) const; - DataArrayDouble *selectByTupleId(const mcIdType *new2OldBg, const mcIdType *new2OldEnd) const { return this->mySelectByTupleId(new2OldBg,new2OldEnd); } + DataArrayDouble *selectByTupleId(const mcIdType *new2OldBg, const mcIdType *new2OldEnd) const override { return this->mySelectByTupleId(new2OldBg,new2OldEnd); } DataArrayDouble *selectByTupleId(const DataArrayIdType& di) const { return this->mySelectByTupleId(di); } - DataArrayDouble *selectByTupleIdSafe(const mcIdType *new2OldBg, const mcIdType *new2OldEnd) const { return DataArrayTemplateFP::mySelectByTupleIdSafe(new2OldBg,new2OldEnd); } - DataArrayDouble *keepSelectedComponents(const std::vector& compoIds) const { return DataArrayTemplateFP::myKeepSelectedComponents(compoIds); } - DataArrayDouble *selectByTupleIdSafeSlice(mcIdType bg, mcIdType end2, mcIdType step) const { return DataArrayTemplateFP::mySelectByTupleIdSafeSlice(bg,end2,step); } - DataArrayDouble *selectByTupleRanges(const std::vector >& ranges) const { return DataArrayTemplateFP::mySelectByTupleRanges(ranges); } + DataArrayDouble *selectByTupleIdSafe(const mcIdType *new2OldBg, const mcIdType *new2OldEnd) const override { return DataArrayTemplateFP::mySelectByTupleIdSafe(new2OldBg,new2OldEnd); } + DataArrayDouble *keepSelectedComponents(const std::vector& compoIds) const override { return DataArrayTemplateFP::myKeepSelectedComponents(compoIds); } + DataArrayDouble *selectByTupleIdSafeSlice(mcIdType bg, mcIdType end2, mcIdType step) const override { return DataArrayTemplateFP::mySelectByTupleIdSafeSlice(bg,end2,step); } + DataArrayDouble *selectByTupleRanges(const std::vector >& ranges) const override { return DataArrayTemplateFP::mySelectByTupleRanges(ranges); } bool areIncludedInMe(const DataArrayDouble *other, double prec, DataArrayIdType *&tupleIds) const; void findCommonTuples(double prec, mcIdType limitTupleId, DataArrayIdType *&comm, DataArrayIdType *&commIndex) const; double minimalDistanceTo(const DataArrayDouble *other, mcIdType& thisTupleId, mcIdType& otherTupleId) const; @@ -550,7 +552,7 @@ namespace MEDCoupling private: DataArrayDouble *operatePerTuple(std::function func) const; private: - ~DataArrayDouble() { } + ~DataArrayDouble() override = default; DataArrayDouble() { } }; } @@ -579,9 +581,9 @@ namespace MEDCoupling void checkStrictlyMonotonic(bool increasing) const; bool isStrictlyMonotonic(bool increasing) const; mcIdType getHashCode() const; - void reprCppStream(const std::string& varName, std::ostream& stream) const; - void reprQuickOverview(std::ostream& stream) const; - void reprQuickOverviewData(std::ostream& stream, std::size_t maxNbOfByteInRepr) const; + void reprCppStream(const std::string& varName, std::ostream& stream) const override; + void reprQuickOverview(std::ostream& stream) const override; + void reprQuickOverviewData(std::ostream& stream, std::size_t maxNbOfByteInRepr) const override; void writeVTK(std::ostream& ofs, mcIdType indent, const std::string& type, const std::string& nameInFile, DataArrayByte *byteArr) const; void transformWithIndArr(const T *indArrBg, const T *indArrEnd); void transformWithIndArr(const MapKeyVal& m); @@ -706,7 +708,7 @@ namespace MEDCoupling template void switchOnTupleAlg(T val, std::vector& vec, ALG algo) const; protected: - ~DataArrayDiscrete() { } + ~DataArrayDiscrete() override = default; }; template @@ -715,7 +717,7 @@ namespace MEDCoupling public: bool isFittingWith(const std::vector& v) const; protected: - ~DataArrayDiscreteSigned() { } + ~DataArrayDiscreteSigned() override = default; }; class DataArrayInt32Iterator; @@ -724,22 +726,22 @@ namespace MEDCoupling { friend class DataArrayDiscrete; public: - DataArrayInt32 *deepCopy() const; + DataArrayInt32 *deepCopy() const override; DataArrayInt32 *copySorted(bool asc=true) const override { return this->copySortedImpl(asc); } - DataArrayInt32 *buildNewEmptyInstance() const { return DataArrayInt32::New(); } + DataArrayInt32 *buildNewEmptyInstance() const override { return DataArrayInt32::New(); } MCAuto convertToInt64Arr() const; public: - DataArrayInt32 *selectByTupleId(const mcIdType *new2OldBg, const mcIdType *new2OldEnd) const { return this->mySelectByTupleId(new2OldBg,new2OldEnd); } + DataArrayInt32 *selectByTupleId(const mcIdType *new2OldBg, const mcIdType *new2OldEnd) const override { return this->mySelectByTupleId(new2OldBg,new2OldEnd); } DataArrayInt32 *selectByTupleId(const DataArrayIdType& di) const { return this->mySelectByTupleId(di); } - DataArrayInt32 *selectByTupleIdSafe(const mcIdType *new2OldBg, const mcIdType *new2OldEnd) const { return this->mySelectByTupleIdSafe(new2OldBg,new2OldEnd); } - DataArrayInt32 *keepSelectedComponents(const std::vector& compoIds) const { return this->myKeepSelectedComponents(compoIds); } - DataArrayInt32 *selectByTupleIdSafeSlice(mcIdType bg, mcIdType end2, mcIdType step) const { return this->mySelectByTupleIdSafeSlice(bg,end2,step); } - DataArrayInt32 *selectByTupleRanges(const std::vector >& ranges) const { return this->mySelectByTupleRanges(ranges); } + DataArrayInt32 *selectByTupleIdSafe(const mcIdType *new2OldBg, const mcIdType *new2OldEnd) const override { return this->mySelectByTupleIdSafe(new2OldBg,new2OldEnd); } + DataArrayInt32 *keepSelectedComponents(const std::vector& compoIds) const override { return this->myKeepSelectedComponents(compoIds); } + DataArrayInt32 *selectByTupleIdSafeSlice(mcIdType bg, mcIdType end2, mcIdType step) const override { return this->mySelectByTupleIdSafeSlice(bg,end2,step); } + DataArrayInt32 *selectByTupleRanges(const std::vector >& ranges) const override { return this->mySelectByTupleRanges(ranges); } std::string getClassName() const override { return std::string("DataArrayInt32"); } public: DataArrayInt32Iterator *iterator(); private: - ~DataArrayInt32() { } + ~DataArrayInt32() override = default; DataArrayInt32() { } }; @@ -747,22 +749,22 @@ namespace MEDCoupling { friend class DataArrayDiscrete; public: - DataArrayInt64 *deepCopy() const; + DataArrayInt64 *deepCopy() const override; DataArrayInt64 *copySorted(bool asc=true) const override { return this->copySortedImpl(asc); } - DataArrayInt64 *buildNewEmptyInstance() const { return DataArrayInt64::New(); }//ok + DataArrayInt64 *buildNewEmptyInstance() const override { return DataArrayInt64::New(); }//ok MCAuto convertToInt32Arr() const; public: - DataArrayInt64 *selectByTupleId(const mcIdType *new2OldBg, const mcIdType *new2OldEnd) const { return this->mySelectByTupleId(new2OldBg,new2OldEnd); } + DataArrayInt64 *selectByTupleId(const mcIdType *new2OldBg, const mcIdType *new2OldEnd) const override { return this->mySelectByTupleId(new2OldBg,new2OldEnd); } DataArrayInt64 *selectByTupleId(const DataArrayIdType& di) const { return this->mySelectByTupleId(di); } - DataArrayInt64 *selectByTupleIdSafe(const mcIdType *new2OldBg, const mcIdType *new2OldEnd) const { return DataArrayTemplate::mySelectByTupleIdSafe(new2OldBg,new2OldEnd); } - DataArrayInt64 *keepSelectedComponents(const std::vector& compoIds) const { return DataArrayTemplate::myKeepSelectedComponents(compoIds); } - DataArrayInt64 *selectByTupleIdSafeSlice(mcIdType bg, mcIdType end2, mcIdType step) const { return DataArrayTemplate::mySelectByTupleIdSafeSlice(bg,end2,step); } - DataArrayInt64 *selectByTupleRanges(const std::vector >& ranges) const { return DataArrayTemplate::mySelectByTupleRanges(ranges); } + DataArrayInt64 *selectByTupleIdSafe(const mcIdType *new2OldBg, const mcIdType *new2OldEnd) const override { return DataArrayTemplate::mySelectByTupleIdSafe(new2OldBg,new2OldEnd); } + DataArrayInt64 *keepSelectedComponents(const std::vector& compoIds) const override { return DataArrayTemplate::myKeepSelectedComponents(compoIds); } + DataArrayInt64 *selectByTupleIdSafeSlice(mcIdType bg, mcIdType end2, mcIdType step) const override { return DataArrayTemplate::mySelectByTupleIdSafeSlice(bg,end2,step); } + DataArrayInt64 *selectByTupleRanges(const std::vector >& ranges) const override { return DataArrayTemplate::mySelectByTupleRanges(ranges); } std::string getClassName() const override { return std::string("DataArrayInt64"); } public: DataArrayInt64Iterator *iterator(); private: - ~DataArrayInt64() { } + ~DataArrayInt64() override = default; DataArrayInt64() { } }; } @@ -797,14 +799,14 @@ namespace MEDCoupling std::string repr() const; std::string reprZip() const; DataArrayInt *convertToIntArr() const; - DataArrayChar *selectByTupleId(const mcIdType *new2OldBg, const mcIdType *new2OldEnd) const { return this->mySelectByTupleId(new2OldBg,new2OldEnd); } + DataArrayChar *selectByTupleId(const mcIdType *new2OldBg, const mcIdType *new2OldEnd) const override { return this->mySelectByTupleId(new2OldBg,new2OldEnd); } DataArrayChar *selectByTupleId(const DataArrayIdType& di) const { return this->mySelectByTupleId(di); } - DataArrayChar *selectByTupleIdSafe(const mcIdType *new2OldBg, const mcIdType *new2OldEnd) const { return DataArrayTemplate::mySelectByTupleIdSafe(new2OldBg,new2OldEnd); } - DataArrayChar *keepSelectedComponents(const std::vector& compoIds) const { return DataArrayTemplate::myKeepSelectedComponents(compoIds); } - DataArrayChar *selectByTupleIdSafeSlice(mcIdType bg, mcIdType end2, mcIdType step) const { return DataArrayTemplate::mySelectByTupleIdSafeSlice(bg,end2,step); } + DataArrayChar *selectByTupleIdSafe(const mcIdType *new2OldBg, const mcIdType *new2OldEnd) const override { return DataArrayTemplate::mySelectByTupleIdSafe(new2OldBg,new2OldEnd); } + DataArrayChar *keepSelectedComponents(const std::vector& compoIds) const override { return DataArrayTemplate::myKeepSelectedComponents(compoIds); } + DataArrayChar *selectByTupleIdSafeSlice(mcIdType bg, mcIdType end2, mcIdType step) const override { return DataArrayTemplate::mySelectByTupleIdSafeSlice(bg,end2,step); } bool isUniform(char val) const; void meldWith(const DataArrayChar *other); - DataArray *selectByTupleRanges(const std::vector >& ranges) const { return DataArrayTemplate::mySelectByTupleRanges(ranges); } + DataArray *selectByTupleRanges(const std::vector >& ranges) const override { return DataArrayTemplate::mySelectByTupleRanges(ranges); } DataArrayIdType *findIdsEqual(char val) const; DataArrayIdType *findIdsNotEqual(char val) const; mcIdType findIdSequence(const std::vector& vals) const; @@ -836,25 +838,25 @@ namespace MEDCoupling { public: static DataArrayByte *New(); - DataArrayChar *buildEmptySpecializedDAChar() const; + DataArrayChar *buildEmptySpecializedDAChar() const override; DataArrayByteIterator *iterator(); - DataArrayByte *deepCopy() const; + DataArrayByte *deepCopy() const override; DataArrayByte *copySorted(bool asc=true) const override { return this->copySortedImpl(asc); } DataArrayByte *performCopyOrIncrRef(bool deepCopy) const; - DataArrayByte *buildNewEmptyInstance() const { return DataArrayByte::New(); } + DataArrayByte *buildNewEmptyInstance() const override { return DataArrayByte::New(); } char byteValue() const; - void reprStream(std::ostream& stream) const; - void reprZipStream(std::ostream& stream) const; - void reprWithoutNameStream(std::ostream& stream) const; - void reprZipWithoutNameStream(std::ostream& stream) const; - void reprCppStream(const std::string& varName, std::ostream& stream) const; - void reprQuickOverview(std::ostream& stream) const; - void reprQuickOverviewData(std::ostream& stream, std::size_t maxNbOfByteInRepr) const; - bool isEqualIfNotWhy(const DataArrayChar& other, std::string& reason) const; + void reprStream(std::ostream& stream) const override; + void reprZipStream(std::ostream& stream) const override; + void reprWithoutNameStream(std::ostream& stream) const override; + void reprZipWithoutNameStream(std::ostream& stream) const override; + void reprCppStream(const std::string& varName, std::ostream& stream) const override; + void reprQuickOverview(std::ostream& stream) const override; + void reprQuickOverviewData(std::ostream& stream, std::size_t maxNbOfByteInRepr) const override; + bool isEqualIfNotWhy(const DataArrayChar& other, std::string& reason) const override; std::vector toVectorOfBool() const; std::string getClassName() const override { return std::string("DataArrayByte"); } private: - ~DataArrayByte() { } + ~DataArrayByte() override = default; DataArrayByte() { } }; @@ -866,24 +868,24 @@ namespace MEDCoupling static DataArrayAsciiChar *New(); static DataArrayAsciiChar *New(const std::string& st); static DataArrayAsciiChar *New(const std::vector& vst, char defaultChar); - DataArrayChar *buildEmptySpecializedDAChar() const; + DataArrayChar *buildEmptySpecializedDAChar() const override; DataArrayAsciiCharIterator *iterator(); - DataArrayAsciiChar *deepCopy() const; + DataArrayAsciiChar *deepCopy() const override; DataArrayAsciiChar *copySorted(bool asc=true) const override { (void)asc;throw INTERP_KERNEL::Exception("DataArrayAsciiChar::copySorted : not implemented for DataArrayByte"); } DataArrayAsciiChar *performCopyOrIncrRef(bool deepCopy) const; - DataArrayAsciiChar *buildNewEmptyInstance() const { return DataArrayAsciiChar::New(); } + DataArrayAsciiChar *buildNewEmptyInstance() const override { return DataArrayAsciiChar::New(); } char asciiCharValue() const; - void reprStream(std::ostream& stream) const; - void reprZipStream(std::ostream& stream) const; - void reprWithoutNameStream(std::ostream& stream) const; - void reprZipWithoutNameStream(std::ostream& stream) const; - void reprCppStream(const std::string& varName, std::ostream& stream) const; - void reprQuickOverview(std::ostream& stream) const; - void reprQuickOverviewData(std::ostream& stream, std::size_t maxNbOfByteInRepr) const; - bool isEqualIfNotWhy(const DataArrayChar& other, std::string& reason) const; + void reprStream(std::ostream& stream) const override; + void reprZipStream(std::ostream& stream) const override; + void reprWithoutNameStream(std::ostream& stream) const override; + void reprZipWithoutNameStream(std::ostream& stream) const override; + void reprCppStream(const std::string& varName, std::ostream& stream) const override; + void reprQuickOverview(std::ostream& stream) const override; + void reprQuickOverviewData(std::ostream& stream, std::size_t maxNbOfByteInRepr) const override; + bool isEqualIfNotWhy(const DataArrayChar& other, std::string& reason) const override; std::string getClassName() const override { return std::string("DataArrayAsciiChar"); } private: - ~DataArrayAsciiChar() { } + ~DataArrayAsciiChar() override = default; DataArrayAsciiChar() { } DataArrayAsciiChar(const std::string& st); DataArrayAsciiChar(const std::vector& vst, char defaultChar); @@ -927,7 +929,7 @@ namespace MEDCoupling { public: DataArrayDoubleIterator(DataArrayDouble *da); - ~DataArrayDoubleIterator() { } + ~DataArrayDoubleIterator() = default; }; class MEDCOUPLING_EXPORT DataArrayDoubleTuple : public DataArrayTuple @@ -945,7 +947,7 @@ namespace MEDCoupling { public: DataArrayFloatIterator(DataArrayFloat *da); - ~DataArrayFloatIterator() { } + ~DataArrayFloatIterator() = default; }; class MEDCOUPLING_EXPORT DataArrayFloatTuple : public DataArrayTuple @@ -961,14 +963,14 @@ namespace MEDCoupling { public: DataArrayInt32Iterator(DataArrayInt32 *da); - ~DataArrayInt32Iterator() { } + ~DataArrayInt32Iterator() = default; }; class MEDCOUPLING_EXPORT DataArrayInt64Iterator : public DataArrayIterator { public: DataArrayInt64Iterator(DataArrayInt64 *da); - ~DataArrayInt64Iterator() { } + ~DataArrayInt64Iterator() = default; }; class MEDCOUPLING_EXPORT DataArrayInt32Tuple : public DataArrayTuple @@ -989,7 +991,7 @@ namespace MEDCoupling DataArrayInt64 *buildDAInt(std::size_t nbOfTuples, std::size_t nbOfCompo) const; }; - typedef DataArrayInt32Tuple DataArrayIntTuple; + using DataArrayIntTuple = DataArrayInt32Tuple; class DataArrayAsciiCharTuple; diff --git a/src/MEDCoupling/MEDCouplingMemArray.txx b/src/MEDCoupling/MEDCouplingMemArray.txx old mode 100755 new mode 100644 index b00a16418..6b7acf9f9 --- a/src/MEDCoupling/MEDCouplingMemArray.txx +++ b/src/MEDCoupling/MEDCouplingMemArray.txx @@ -21,21 +21,31 @@ #ifndef __PARAMEDMEM_MEDCOUPLINGMEMARRAY_TXX__ #define __PARAMEDMEM_MEDCOUPLINGMEMARRAY_TXX__ +#include "MCType.hxx" +#include "MEDCouplingMap.txx" #include "MEDCouplingMemArray.hxx" -#include "NormalizedUnstructuredMesh.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include "MEDCouplingTraits.hxx" #include "InterpKernelException.hxx" -#include "InterpolationUtils.hxx" #include "MEDCouplingPartDefinition.hxx" #include "InterpKernelAutoPtr.hxx" #include "MCAuto.hxx" -#include "MEDCouplingMap.txx" +#include +#include +#include +#include +#include +#include #include +#include #include #include #include #include -#include +#include +#include +#include namespace MEDCoupling { @@ -43,7 +53,7 @@ namespace MEDCoupling void MEDCouplingPointer::setInternal(T *pointer) { _internal=pointer; - _external=0; + _external=nullptr; } template @@ -54,7 +64,7 @@ namespace MEDCoupling } template - MemArray::MemArray(const MemArray& other):_nb_of_elem(0),_nb_of_elem_alloc(0),_ownership(false),_dealloc(0),_param_for_deallocator(0) + MemArray::MemArray(const MemArray& other) { if(!other._pointer.isNull()) { @@ -178,7 +188,7 @@ namespace MEDCoupling stream << "No data"; stream << "\n"; stream << "Data content :\n"; - bool ret=!_pointer.isNull(); + bool const ret=!_pointer.isNull(); if(!ret) stream << "No data !\n"; return ret; @@ -195,7 +205,7 @@ namespace MEDCoupling const T *data=getConstPointer(); if(_nb_of_elem!=0 && sl!=0) { - std::size_t nbOfTuples=_nb_of_elem/std::abs(sl); + std::size_t const nbOfTuples=_nb_of_elem/std::abs(sl); for(std::size_t i=0;i it1(pt+_nb_of_elem); - typename std::reverse_iterator it2(pt); + typename std::reverse_iterator const it1(pt+_nb_of_elem); + typename std::reverse_iterator const it2(pt); std::sort(it1,it2); } } @@ -401,7 +411,7 @@ namespace MEDCoupling _nb_of_elem_alloc=newNbOfElements; _ownership=true; _dealloc=CDeallocator; - _param_for_deallocator=0; + _param_for_deallocator=nullptr; } /*! @@ -425,17 +435,17 @@ namespace MEDCoupling _nb_of_elem_alloc=newNbOfElements; _ownership=true; _dealloc=CDeallocator; - _param_for_deallocator=0; + _param_for_deallocator=nullptr; } template - void MemArray::CPPDeallocator(void *pt, void *param) + void MemArray::CPPDeallocator(void *pt, void * /*param*/) { delete [] reinterpret_cast(pt); } template - void MemArray::CDeallocator(void *pt, void *param) + void MemArray::CDeallocator(void *pt, void * /*param*/) { free(pt); } @@ -443,7 +453,7 @@ namespace MEDCoupling template void MemArray::COffsetDeallocator(void *pt, void *param) { - int64_t *offset(reinterpret_cast(param)); + auto *offset(reinterpret_cast(param)); char *ptcast(reinterpret_cast(pt)); free(ptcast+*offset); } @@ -478,8 +488,8 @@ namespace MEDCoupling DestroyPointer(const_cast(_pointer.getConstPointer()),_dealloc,_param_for_deallocator);//Do not use getPointer because in case of _external _pointer.null(); _ownership=false; - _dealloc=NULL; - _param_for_deallocator=NULL; + _dealloc=nullptr; + _param_for_deallocator=nullptr; _nb_of_elem=0; _nb_of_elem_alloc=0; } @@ -522,7 +532,7 @@ namespace MEDCoupling if(_tuple_id<_nb_tuple) { _tuple_id++; - typename Traits::ArrayTuple *ret=new typename Traits::ArrayTuple(_pt,_nb_comp); + auto *ret=new typename Traits::ArrayTuple(_pt,_nb_comp); _pt+=_nb_comp; return ret; } @@ -813,7 +823,7 @@ namespace MEDCoupling template bool DataArrayTemplate::isAllocated() const { - return getConstPointer()!=0; + return getConstPointer()!=nullptr; } /*! @@ -956,7 +966,7 @@ namespace MEDCoupling mcIdType nbOfTuples(other.getNumberOfTuples()); std::size_t nbOfComp(other.getNumberOfComponents()); allocIfNecessary(nbOfTuples,nbOfComp); - std::size_t nbOfElems(nbOfTuples*nbOfComp); + std::size_t const nbOfElems(nbOfTuples*nbOfComp); T *pt(getPointer()); const T *ptI(other.begin()); for(std::size_t i=0;i::renumberInPlace(const mcIdType *old2New) { checkAllocated(); - mcIdType nbTuples(getNumberOfTuples()); - std::size_t nbOfCompo(getNumberOfComponents()); + mcIdType const nbTuples(getNumberOfTuples()); + std::size_t const nbOfCompo(getNumberOfComponents()); T *tmp(new T[nbTuples*nbOfCompo]); const T *iptr(begin()); for(mcIdType i=0;i=0 && v::renumberInPlaceR(const mcIdType *new2Old) { checkAllocated(); - mcIdType nbTuples(getNumberOfTuples()); - std::size_t nbOfCompo(getNumberOfComponents()); + mcIdType const nbTuples(getNumberOfTuples()); + std::size_t const nbOfCompo(getNumberOfComponents()); T *tmp(new T[nbTuples*nbOfCompo]); const T *iptr(begin()); for(mcIdType i=0;i=0 && vgetPointer(); for(mcIdType i=0;i=0) std::copy(iptr+i*nbOfCompo,iptr+(i+1)*nbOfCompo,optr+w*nbOfCompo); } @@ -1225,7 +1235,7 @@ namespace MEDCoupling checkAllocated(); MCAuto ret0(buildNewEmptyInstance()); MCAuto< typename Traits::ArrayType > ret(DynamicCastSafe::ArrayType>(ret0)); - std::size_t nbComp(getNumberOfComponents()); + std::size_t const nbComp(getNumberOfComponents()); ret->alloc(std::distance(new2OldBg,new2OldEnd),nbComp); ret->copyStringInfoFrom(*this); T *pt(ret->getPointer()); @@ -1249,7 +1259,7 @@ namespace MEDCoupling if(!pd) throw INTERP_KERNEL::Exception("DataArrayTemplate::selectPartDef : null input pointer !"); MCAuto::ArrayTypeCh> ret(Traits::ArrayTypeCh::New()); - const SlicePartDefinition *spd(dynamic_cast(pd)); + const auto *spd(dynamic_cast(pd)); if(spd) { mcIdType a,b,c; @@ -1267,7 +1277,7 @@ namespace MEDCoupling return DynamicCastSafe::ArrayTypeCh>(ret2); } } - const DataArrayPartDefinition *dpd(dynamic_cast(pd)); + const auto *dpd(dynamic_cast(pd)); if(dpd) { MCAuto arr(dpd->toDAI()); @@ -1303,8 +1313,8 @@ namespace MEDCoupling checkAllocated(); MCAuto ret0(buildNewEmptyInstance()); MCAuto< typename Traits::ArrayType > ret(DynamicCastSafe::ArrayType>(ret0)); - std::size_t nbComp(getNumberOfComponents()); - mcIdType oldNbOfTuples(getNumberOfTuples()); + std::size_t const nbComp(getNumberOfComponents()); + mcIdType const oldNbOfTuples(getNumberOfTuples()); ret->alloc(std::distance(new2OldBg,new2OldEnd),nbComp); ret->copyStringInfoFrom(*this); T *pt(ret->getPointer()); @@ -1342,7 +1352,7 @@ namespace MEDCoupling std::ostringstream oss; oss << Traits::ArrayTypeName << "::rearrange : input newNbOfCompo must be > 0 !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - std::size_t nbOfElems=getNbOfElems(); + std::size_t const nbOfElems=getNbOfElems(); if(nbOfElems%newNbOfCompo!=0) { std::ostringstream oss; oss << Traits::ArrayTypeName << "::rearrange : nbOfElems%newNbOfCompo!=0 !"; @@ -1399,7 +1409,7 @@ namespace MEDCoupling T *nc(ret->getPointer()); mcIdType nbOfTuples=getNumberOfTuples(); std::size_t oldNbOfComp=getNumberOfComponents(); - std::size_t dim(std::min(oldNbOfComp,newNbOfComp)); + std::size_t const dim(std::min(oldNbOfComp,newNbOfComp)); for(mcIdType i=0;i ret0(buildNewEmptyInstance()); MCAuto< typename Traits::ArrayType > ret(DynamicCastSafe::ArrayType>(ret0)); - std::size_t newNbOfCompo=compoIds.size(); - std::size_t oldNbOfCompo=getNumberOfComponents(); - for(std::vector::const_iterator it=compoIds.begin();it!=compoIds.end();it++) - if((*it)>=oldNbOfCompo) // (*it) >= 0 (it is a size_t) + std::size_t const newNbOfCompo=compoIds.size(); + std::size_t const oldNbOfCompo=getNumberOfComponents(); + for(unsigned long const compoId : compoIds) + if(compoId>=oldNbOfCompo) // (*it) >= 0 (it is a size_t) { - std::ostringstream oss; oss << Traits::ArrayTypeName << "::keepSelectedComponents : invalid requested component : " << *it << " whereas it should be in [0," << oldNbOfCompo << ") !"; + std::ostringstream oss; oss << Traits::ArrayTypeName << "::keepSelectedComponents : invalid requested component : " << compoId << " whereas it should be in [0," << oldNbOfCompo << ") !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - mcIdType nbOfTuples(getNumberOfTuples()); + mcIdType const nbOfTuples(getNumberOfTuples()); ret->alloc(nbOfTuples,newNbOfCompo); ret->copyPartOfStringInfoFrom(*this,compoIds); const T *oldc(getConstPointer()); @@ -1528,9 +1538,9 @@ namespace MEDCoupling checkAllocated(); MCAuto ret0(buildNewEmptyInstance()); MCAuto< typename Traits::ArrayType > ret(DynamicCastSafe::ArrayType>(ret0)); - std::size_t nbComp(getNumberOfComponents()); + std::size_t const nbComp(getNumberOfComponents()); std::ostringstream oss; oss << Traits::ArrayTypeName << "::selectByTupleIdSafeSlice : "; - mcIdType newNbOfTuples(GetNumberOfItemGivenBESRelative(bg,end2,step,oss.str())); + mcIdType const newNbOfTuples(GetNumberOfItemGivenBESRelative(bg,end2,step,oss.str())); ret->alloc(newNbOfTuples,nbComp); T *pt(ret->getPointer()); const T *srcPt(getConstPointer()+bg*nbComp); @@ -1650,8 +1660,8 @@ namespace MEDCoupling { const char msg[]="DataArrayTemplate::setPartOfValuesSimple1"; checkAllocated(); - mcIdType newNbOfTuples(DataArray::GetNumberOfItemGivenBES(bgTuples,endTuples,stepTuples,msg)); - mcIdType newNbOfComp(DataArray::GetNumberOfItemGivenBES(bgComp,endComp,stepComp,msg)); + mcIdType const newNbOfTuples(DataArray::GetNumberOfItemGivenBES(bgTuples,endTuples,stepTuples,msg)); + mcIdType const newNbOfComp(DataArray::GetNumberOfItemGivenBES(bgComp,endComp,stepComp,msg)); std::size_t nbComp(getNumberOfComponents()); mcIdType nbOfTuples(getNumberOfTuples()); DataArray::CheckValueInRangeEx(nbOfTuples,bgTuples,endTuples,"invalid tuple value"); @@ -1919,7 +1929,7 @@ namespace MEDCoupling { const char msg[]="DataArrayTemplate::setPartOfValuesSimple3"; checkAllocated(); - std::size_t newNbOfComp(DataArray::GetNumberOfItemGivenBES(bgComp,endComp,stepComp,msg)); + std::size_t const newNbOfComp(DataArray::GetNumberOfItemGivenBES(bgComp,endComp,stepComp,msg)); std::size_t nbComp(getNumberOfComponents()); mcIdType nbOfTuples(getNumberOfTuples()); DataArray::CheckValueInRangeEx(ToIdType(nbComp),bgComp,endComp,"invalid component value"); @@ -2015,7 +2025,7 @@ namespace MEDCoupling { const char msg[]="DataArrayTemplate::setPartOfValuesSimple4"; checkAllocated(); - mcIdType newNbOfTuples(DataArray::GetNumberOfItemGivenBES(bgTuples,endTuples,stepTuples,msg)); + mcIdType const newNbOfTuples(DataArray::GetNumberOfItemGivenBES(bgTuples,endTuples,stepTuples,msg)); std::size_t nbComp(getNumberOfComponents()); for(const mcIdType *z=bgComp;z!=endComp;z++) DataArray::CheckValueInRange(ToIdType(nbComp),*z,"invalid component id"); @@ -2115,20 +2125,20 @@ namespace MEDCoupling { if(!aBase || !tuplesSelec) throw INTERP_KERNEL::Exception("DataArrayTemplate::setContigPartOfSelectedValues : input DataArray is NULL !"); - const typename Traits::ArrayType *a(dynamic_cast::ArrayType *>(aBase)); + const auto *a(dynamic_cast::ArrayType *>(aBase)); if(!a) throw INTERP_KERNEL::Exception("DataArrayTemplate::setContigPartOfSelectedValues : input DataArray aBase is not a DataArrayDouble !"); checkAllocated(); a->checkAllocated(); tuplesSelec->checkAllocated(); - std::size_t nbOfComp(getNumberOfComponents()); + std::size_t const nbOfComp(getNumberOfComponents()); if(nbOfComp!=a->getNumberOfComponents()) throw INTERP_KERNEL::Exception("DataArrayTemplate::setContigPartOfSelectedValues : This and a do not have the same number of components !"); if(tuplesSelec->getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("DataArrayTemplate::setContigPartOfSelectedValues : Expecting to have a tuple selector DataArrayInt instance with exactly 1 component !"); - mcIdType thisNt(getNumberOfTuples()); - mcIdType aNt(a->getNumberOfTuples()); - mcIdType nbOfTupleToWrite(tuplesSelec->getNumberOfTuples()); + mcIdType const thisNt(getNumberOfTuples()); + mcIdType const aNt(a->getNumberOfTuples()); + mcIdType const nbOfTupleToWrite(tuplesSelec->getNumberOfTuples()); T *valsToSet(getPointer()+tupleIdStart*nbOfComp); if(tupleIdStart+nbOfTupleToWrite>thisNt) throw INTERP_KERNEL::Exception("DataArrayTemplate::setContigPartOfSelectedValues : invalid number range of values to write !"); @@ -2181,18 +2191,18 @@ namespace MEDCoupling std::ostringstream oss; oss << Traits::ArrayTypeName << "::setContigPartOfSelectedValuesSlice : input DataArray is NULL !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - const typename Traits::ArrayType *a(dynamic_cast::ArrayType *>(aBase)); + const auto *a(dynamic_cast::ArrayType *>(aBase)); if(!a) throw INTERP_KERNEL::Exception("DataArrayTemplate::setContigPartOfSelectedValuesSlice : input DataArray aBase is not a DataArrayDouble !"); checkAllocated(); a->checkAllocated(); - std::size_t nbOfComp(getNumberOfComponents()); + std::size_t const nbOfComp(getNumberOfComponents()); const char msg[]="DataArrayDouble::setContigPartOfSelectedValuesSlice"; - mcIdType nbOfTupleToWrite(DataArray::GetNumberOfItemGivenBES(bg,end2,step,msg)); + mcIdType const nbOfTupleToWrite(DataArray::GetNumberOfItemGivenBES(bg,end2,step,msg)); if(nbOfComp!=a->getNumberOfComponents()) throw INTERP_KERNEL::Exception("DataArrayTemplate::setContigPartOfSelectedValuesSlice : This and a do not have the same number of components !"); - mcIdType thisNt(getNumberOfTuples()); - mcIdType aNt(a->getNumberOfTuples()); + mcIdType const thisNt(getNumberOfTuples()); + mcIdType const aNt(a->getNumberOfTuples()); T *valsToSet(getPointer()+tupleIdStart*nbOfComp); if(tupleIdStart+nbOfTupleToWrite>thisNt) throw INTERP_KERNEL::Exception("DataArrayTemplate::setContigPartOfSelectedValuesSlice : invalid number range of values to write !"); @@ -2221,8 +2231,8 @@ namespace MEDCoupling typename Traits::ArrayType *DataArrayTemplate::mySelectByTupleRanges(const std::vector >& ranges) const { checkAllocated(); - std::size_t nbOfComp(getNumberOfComponents()); - mcIdType nbOfTuplesThis(getNumberOfTuples()); + std::size_t const nbOfComp(getNumberOfComponents()); + mcIdType const nbOfTuplesThis(getNumberOfTuples()); if(ranges.empty()) { MCAuto ret0(buildNewEmptyInstance()); @@ -2233,7 +2243,7 @@ namespace MEDCoupling } mcIdType ref(ranges.front().first),nbOfTuples(0); bool isIncreasing(true); - for(std::vector >::const_iterator it=ranges.begin();it!=ranges.end();it++) + for(auto it=ranges.begin();it!=ranges.end();it++) { if((*it).first<=(*it).second) { @@ -2266,8 +2276,8 @@ namespace MEDCoupling ret->copyStringInfoFrom(*this); const T *src(getConstPointer()); T *work(ret->getPointer()); - for(std::vector >::const_iterator it=ranges.begin();it!=ranges.end();it++) - work=std::copy(src+(*it).first*nbOfComp,src+(*it).second*nbOfComp,work); + for(const auto & range : ranges) + work=std::copy(src+range.first*nbOfComp,src+range.second*nbOfComp,work); return ret.retn(); } @@ -2434,9 +2444,9 @@ namespace MEDCoupling void DataArrayTemplate::circularPermutation(mcIdType nbOfShift) { checkAllocated(); - std::size_t nbOfCompo(getNumberOfComponents()); - mcIdType nbTuples(getNumberOfTuples()); - mcIdType effNbSh(EffectiveCircPerm(nbOfShift,nbTuples)); + std::size_t const nbOfCompo(getNumberOfComponents()); + mcIdType const nbTuples(getNumberOfTuples()); + mcIdType const effNbSh(EffectiveCircPerm(nbOfShift,nbTuples)); if(effNbSh==0) return ; T *work(getPointer()); @@ -2460,9 +2470,9 @@ namespace MEDCoupling void DataArrayTemplate::circularPermutationPerTuple(mcIdType nbOfShift) { checkAllocated(); - std::size_t nbOfCompo(getNumberOfComponents()); - mcIdType nbTuples(getNumberOfTuples()); - mcIdType effNbSh(EffectiveCircPerm(nbOfShift,ToIdType(nbOfCompo))); + std::size_t const nbOfCompo(getNumberOfComponents()); + mcIdType const nbTuples(getNumberOfTuples()); + mcIdType const effNbSh(EffectiveCircPerm(nbOfShift,ToIdType(nbOfCompo))); if(effNbSh==0) return ; T *work(getPointer()); @@ -2496,8 +2506,8 @@ namespace MEDCoupling void DataArrayTemplate::reversePerTuple() { checkAllocated(); - std::size_t nbOfCompo(getNumberOfComponents()); - mcIdType nbTuples(getNumberOfTuples()); + std::size_t const nbOfCompo(getNumberOfComponents()); + mcIdType const nbTuples(getNumberOfTuples()); if(nbOfCompo<=1) return ; T *work(getPointer()); @@ -3806,7 +3816,7 @@ struct NotInRange mcIdType *retToFill(ret->getPointer()); for(mcIdType i=0;i::const_iterator it=mm.find(ToIdType(pt[i])); + auto it=mm.find(ToIdType(pt[i])); if(it==mm.end()) { std::ostringstream oss; oss << "DataArrayInt::buildPermutationArr : Arrays mismatch : element (" << pt[i] << ") in 'other' not findable in 'this' !"; @@ -3848,7 +3858,7 @@ struct NotInRange throw INTERP_KERNEL::Exception("DataArrayInt::indicesOfSubPart : some elements appears more than once !"); for(mcIdType i=0;i::const_iterator it(m.find(ToIdType(*pt))); + auto it(m.find(ToIdType(*pt))); if(it!=m.end()) *retPt=(*it).second; else @@ -3999,8 +4009,8 @@ struct NotInRange template void DataArrayDiscrete::reprCppStream(const std::string& varName, std::ostream& stream) const { - mcIdType nbTuples(this->getNumberOfTuples()); - std::size_t nbComp(this->getNumberOfComponents()); + mcIdType const nbTuples(this->getNumberOfTuples()); + std::size_t const nbComp(this->getNumberOfComponents()); const T *data(this->getConstPointer()); stream << Traits::ArrayTypeName << " *" << varName << "=" << Traits::ArrayTypeName << "::New();" << std::endl; if(nbTuples*nbComp>=1) @@ -4025,10 +4035,10 @@ struct NotInRange stream << Traits::ArrayTypeName << " C++ instance at " << this << ". "; if(this->isAllocated()) { - std::size_t nbOfCompo(this->getNumberOfComponents()); + std::size_t const nbOfCompo(this->getNumberOfComponents()); if(nbOfCompo>=1) { - mcIdType nbOfTuples(this->getNumberOfTuples()); + mcIdType const nbOfTuples(this->getNumberOfTuples()); stream << "Number of tuples : " << nbOfTuples << ". Number of components : " << nbOfCompo << "." << std::endl; reprQuickOverviewData(stream,MAX_NB_OF_BYTE_IN_REPR); } @@ -4043,8 +4053,8 @@ struct NotInRange void DataArrayDiscrete::reprQuickOverviewData(std::ostream& stream, std::size_t maxNbOfByteInRepr) const { const T *data(this->begin()); - mcIdType nbOfTuples(this->getNumberOfTuples()); - std::size_t nbOfCompo(this->getNumberOfComponents()); + mcIdType const nbOfTuples(this->getNumberOfTuples()); + std::size_t const nbOfCompo(this->getNumberOfComponents()); std::ostringstream oss2; oss2 << "["; std::string oss2Str(oss2.str()); bool isFinished=true; @@ -4063,7 +4073,7 @@ struct NotInRange else oss2 << *data++; if(i!=nbOfTuples-1) oss2 << ", "; - std::string oss3Str(oss2.str()); + std::string const oss3Str(oss2.str()); if(oss3Str.length()(),std::placeholders::_1,work[i])); std::size_t pos=std::distance(bg,res); - std::size_t pos2=nbOfCast-pos; + std::size_t const pos2=nbOfCast-pos; if(pos2(pos2); @@ -4707,8 +4717,8 @@ struct NotInRange MCAuto ret(DataArrayIdType::New()); ret->alloc(nbOfTuples,1); mcIdType *retPtr=ret->getPointer(); - for(std::vector< std::vector >::const_iterator it1=tmp.begin();it1!=tmp.end();it1++) - retPtr=std::copy((*it1).begin(),(*it1).end(),retPtr); + for(const auto & it1 : tmp) + retPtr=std::copy(it1.begin(),it1.end(),retPtr); arr=ret.retn(); arrI=retI.retn(); } @@ -4887,7 +4897,7 @@ struct NotInRange this->checkAllocated(); a->checkAllocated(); this->copyPartOfStringInfoFrom2(compoIds,*a); - std::size_t partOfCompoSz=compoIds.size(); + std::size_t const partOfCompoSz=compoIds.size(); std::size_t nbOfCompo = this->getNumberOfComponents(); mcIdType nbOfTuples=std::min(this->getNumberOfTuples(),a->getNumberOfTuples()); const T *ac=a->getConstPointer(); @@ -5644,7 +5654,7 @@ struct NotInRange tmp[*w]=true; else throw INTERP_KERNEL::Exception("DataArrayInt::buildComplement : an element is not in valid range : [0,nbOfElement) !"); - std::size_t nbOfRetVal=std::count(tmp.begin(),tmp.end(),false); + std::size_t const nbOfRetVal=std::count(tmp.begin(),tmp.end(),false); DataArrayIdType *ret=DataArrayIdType::New(); ret->alloc(nbOfRetVal,1); mcIdType j=0; @@ -6780,7 +6790,7 @@ struct NotInRange this->setName(tinyInfoS[0]); if(this->isAllocated()) { - mcIdType nbOfCompo=tinyInfoI[1]; + mcIdType const nbOfCompo=tinyInfoI[1]; for(mcIdType i=0;isetInfoOnComponent(i,tinyInfoS[i+1]); } @@ -7060,7 +7070,7 @@ struct NotInRange mcIdType *DataArrayDiscrete::CheckAndPreparePermutation(const T *start, const T *end) { std::size_t sz=std::distance(start,end); - mcIdType *ret=(mcIdType *)malloc(sz*sizeof(mcIdType)); + auto *ret=(mcIdType *)malloc(sz*sizeof(mcIdType)); T *work=new T[sz]; std::copy(start,end,work); std::sort(work,work+sz); @@ -7343,10 +7353,10 @@ struct NotInRange arrIn->checkAllocated(); arrIndxIn->checkAllocated(); if(arrIn->getNumberOfComponents()!=1 || arrIndxIn->getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("DataArrayInt::ExtractFromIndexedArrays : input arrays must have exactly one component !"); - std::size_t sz=std::distance(idsOfSelectBg,idsOfSelectEnd); + std::size_t const sz=std::distance(idsOfSelectBg,idsOfSelectEnd); const T *arrInPtr=arrIn->begin(); const mcIdType *arrIndxPtr=arrIndxIn->begin(); - mcIdType nbOfGrps=arrIndxIn->getNumberOfTuples()-1; + mcIdType const nbOfGrps=arrIndxIn->getNumberOfTuples()-1; if(nbOfGrps<0) throw INTERP_KERNEL::Exception("DataArrayInt::ExtractFromIndexedArrays : The format of \"arrIndxIn\" is invalid ! Its nb of tuples should be >=1 !"); mcIdType maxSizeOfArr(arrIn->getNumberOfTuples()); @@ -7419,10 +7429,10 @@ struct NotInRange arrIn->checkAllocated(); arrIndxIn->checkAllocated(); if(arrIn->getNumberOfComponents()!=1 || arrIndxIn->getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("DataArrayInt::ExtractFromIndexedArraysSlice : input arrays must have exactly one component !"); - mcIdType sz=DataArray::GetNumberOfItemGivenBESRelative(idsOfSelectStart,idsOfSelectStop,idsOfSelectStep,"MEDCouplingUMesh::ExtractFromIndexedArraysSlice : Input slice "); + mcIdType const sz=DataArray::GetNumberOfItemGivenBESRelative(idsOfSelectStart,idsOfSelectStop,idsOfSelectStep,"MEDCouplingUMesh::ExtractFromIndexedArraysSlice : Input slice "); const T *arrInPtr=arrIn->begin(); const mcIdType *arrIndxPtr=arrIndxIn->begin(); - mcIdType nbOfGrps=arrIndxIn->getNumberOfTuples()-1; + mcIdType const nbOfGrps=arrIndxIn->getNumberOfTuples()-1; if(nbOfGrps<0) throw INTERP_KERNEL::Exception("DataArrayInt::ExtractFromIndexedArraysSlice : The format of \"arrIndxIn\" is invalid ! Its nb of tuples should be >=1 !"); mcIdType maxSizeOfArr(arrIn->getNumberOfTuples()); @@ -7492,11 +7502,11 @@ struct NotInRange const DataArrayType *srcArr, const DataArrayIdType *srcArrIndex, DataArrayType* &arrOut, DataArrayIdType* &arrIndexOut) { - if(arrIn==0 || arrIndxIn==0 || srcArr==0 || srcArrIndex==0) + if(arrIn==0 || arrIndxIn==nullptr || srcArr==0 || srcArrIndex==nullptr) throw INTERP_KERNEL::Exception("DataArrayInt::SetPartOfIndexedArrays : presence of null pointer in input parameter !"); MCAuto arro=DataArrayType::New(); MCAuto arrIo=DataArrayIdType::New(); - mcIdType nbOfTuples=arrIndxIn->getNumberOfTuples()-1; + mcIdType const nbOfTuples=arrIndxIn->getNumberOfTuples()-1; std::vector v(nbOfTuples,true); mcIdType offset=0; const mcIdType *arrIndxInPtr=arrIndxIn->begin(); @@ -7530,7 +7540,7 @@ struct NotInRange } else { - std::size_t pos=std::distance(idsOfSelectBg,std::find(idsOfSelectBg,idsOfSelectEnd,ii)); + std::size_t const pos=std::distance(idsOfSelectBg,std::find(idsOfSelectBg,idsOfSelectEnd,ii)); arroPtr=std::copy(srcArrPtr+srcArrIndexPtr[pos],srcArrPtr+srcArrIndexPtr[pos+1],arroPtr); *arrIoPtr=arrIoPtr[-1]+(srcArrIndexPtr[pos+1]-srcArrIndexPtr[pos]); } @@ -7563,15 +7573,15 @@ struct NotInRange const DataArrayType *srcArr, const DataArrayIdType *srcArrIndex, DataArrayType* &arrOut, DataArrayIdType* &arrIndexOut) { - if(arrIn==0 || arrIndxIn==0 || srcArr==0 || srcArrIndex==0) + if(arrIn==0 || arrIndxIn==nullptr || srcArr==0 || srcArrIndex==nullptr) throw INTERP_KERNEL::Exception("DataArrayInt::SetPartOfIndexedArraysSlice : presence of null pointer in input parameter !"); MCAuto arro=DataArrayType::New(); MCAuto arrIo=DataArrayIdType::New(); - mcIdType nbOfTuples=arrIndxIn->getNumberOfTuples()-1; + mcIdType const nbOfTuples=arrIndxIn->getNumberOfTuples()-1; mcIdType offset=0; const mcIdType *arrIndxInPtr=arrIndxIn->begin(); const mcIdType *srcArrIndexPtr=srcArrIndex->begin(); - mcIdType nbOfElemsToSet=DataArray::GetNumberOfItemGivenBESRelative(start,end,step,"DataArrayInt::SetPartOfIndexedArraysSlice : "); + mcIdType const nbOfElemsToSet=DataArray::GetNumberOfItemGivenBESRelative(start,end,step,"DataArrayInt::SetPartOfIndexedArraysSlice : "); mcIdType it=start; for(mcIdType i=0;igetPointer(); for(mcIdType ii=0;iigetNumberOfTuples()-1; + mcIdType const nbOfTuples=arrIndxIn->getNumberOfTuples()-1; const mcIdType *arrIndxInPtr=arrIndxIn->begin(); const mcIdType *srcArrIndexPtr=srcArrIndex->begin(); T *arrInOutPtr=arrInOut->getPointer(); @@ -7672,14 +7682,14 @@ struct NotInRange DataArrayType *arrInOut, const DataArrayIdType *arrIndxIn, const DataArrayType *srcArr, const DataArrayIdType *srcArrIndex) { - if(arrInOut==0 || arrIndxIn==0 || srcArr==0 || srcArrIndex==0) + if(arrInOut==0 || arrIndxIn==nullptr || srcArr==0 || srcArrIndex==nullptr) throw INTERP_KERNEL::Exception("DataArrayInt::SetPartOfIndexedArraysSameIdxSlice : presence of null pointer in input parameter !"); - mcIdType nbOfTuples=arrIndxIn->getNumberOfTuples()-1; + mcIdType const nbOfTuples=arrIndxIn->getNumberOfTuples()-1; const mcIdType *arrIndxInPtr=arrIndxIn->begin(); const mcIdType *srcArrIndexPtr=srcArrIndex->begin(); T *arrInOutPtr=arrInOut->getPointer(); const T *srcArrPtr=srcArr->begin(); - mcIdType nbOfElemsToSet=DataArray::GetNumberOfItemGivenBESRelative(start,end,step,"DataArrayInt::SetPartOfIndexedArraysSameIdxSlice : "); + mcIdType const nbOfElemsToSet=DataArray::GetNumberOfItemGivenBESRelative(start,end,step,"DataArrayInt::SetPartOfIndexedArraysSameIdxSlice : "); mcIdType it=start; for(mcIdType i=0;i=0 !"); std::set s(idsToRemoveBg,idsToRemoveEnd); - mcIdType nbOfGrps=arrIndx->getNumberOfTuples()-1; + mcIdType const nbOfGrps=arrIndx->getNumberOfTuples()-1; mcIdType *arrIPtr=arrIndx->getPointer(); *arrIPtr++=0; mcIdType previousArrI=0; @@ -7813,7 +7823,7 @@ struct NotInRange ret->alloc(nbOfOldTuples,1); mcIdType *pt=ret->getPointer(); std::fill(pt,pt+nbOfOldTuples,-1); - mcIdType nbOfGrps=ToIdType(std::distance(arrIBg,arrIEnd))-1; + mcIdType const nbOfGrps=ToIdType(std::distance(arrIBg,arrIEnd))-1; const mcIdType *cIPtr=arrIBg; for(mcIdType i=0;i=0 && arr[j]getConstPointer(); std::size_t nbOfElem=(*iter)->getNbOfElems(); - mcIdType sfid=fid; + mcIdType const sfid=fid; for(mcIdType j=0;j(_cnt); _cnt++; } private: T *_pt; - MEDCoupling::mcIdType _cnt; + MEDCoupling::mcIdType _cnt{0}; }; template class OpSwitchedOff { public: - OpSwitchedOff(T *pt):_pt(pt),_cnt(0) { } + OpSwitchedOff(T *pt):_pt(pt) { } void operator()(const bool& b) { if(!b) *_pt++=FromIdType(_cnt); _cnt++; } private: T *_pt; - MEDCoupling::mcIdType _cnt; + MEDCoupling::mcIdType _cnt{0}; }; } /// @endcond @@ -8003,7 +8013,7 @@ namespace MEDCoupling const T *w(this->begin()),*end2(this->end()); T refVal=-std::numeric_limits::max(); T i=0; - std::vector::const_iterator it(v.begin()); + auto it(v.begin()); for(;it!=v.end();it++,i++) { if(*it) diff --git a/src/MEDCoupling/MEDCouplingMemArrayChar.cxx b/src/MEDCoupling/MEDCouplingMemArrayChar.cxx old mode 100755 new mode 100644 index 90b42eb1d..7415ff7a8 --- a/src/MEDCoupling/MEDCouplingMemArrayChar.cxx +++ b/src/MEDCoupling/MEDCouplingMemArrayChar.cxx @@ -19,14 +19,22 @@ // Author : Anthony Geay (CEA/DEN) #include "MEDCouplingMemArray.txx" +#include "MCIdType.hxx" +#include "MCType.hxx" #include "MCAuto.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include +#include +#include +#include #include #include -#include #include #include -#include +#include +#include +#include using namespace MEDCoupling; @@ -42,8 +50,8 @@ template class MEDCoupling::DataArrayTemplate; mcIdType DataArrayChar::getHashCode() const { checkAllocated(); - std::size_t nbOfElems=getNbOfElems(); - std::size_t ret=nbOfElems*65536; + std::size_t const nbOfElems=getNbOfElems(); + std::size_t const ret=nbOfElems*65536; std::size_t delta=3; if(nbOfElems>48) delta=nbOfElems/8; @@ -122,7 +130,7 @@ DataArrayInt *DataArrayChar::convertToIntArr() const checkAllocated(); DataArrayInt *ret=DataArrayInt::New(); ret->alloc(getNumberOfTuples(),getNumberOfComponents()); - std::size_t nbOfVals=getNbOfElems(); + std::size_t const nbOfVals=getNbOfElems(); const char *src=getConstPointer(); int *dest=ret->getPointer(); std::copy(src,src+nbOfVals,dest); @@ -142,7 +150,7 @@ bool DataArrayChar::isUniform(char val) const checkAllocated(); if(getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("DataArrayChar::isUniform : must be applied on DataArrayChar with only one component, you can call 'rearrange' method before !"); - mcIdType nbOfTuples=getNumberOfTuples(); + mcIdType const nbOfTuples=getNumberOfTuples(); const char *w=getConstPointer(); const char *end2=w+nbOfTuples; for(;w!=end2;w++) @@ -171,11 +179,11 @@ void DataArrayChar::meldWith(const DataArrayChar *other) throw INTERP_KERNEL::Exception("DataArrayChar::meldWith : DataArrayChar pointer in input is NULL !"); checkAllocated(); other->checkAllocated(); - mcIdType nbOfTuples=getNumberOfTuples(); + mcIdType const nbOfTuples=getNumberOfTuples(); if(nbOfTuples!=other->getNumberOfTuples()) throw INTERP_KERNEL::Exception("DataArrayChar::meldWith : mismatch of number of tuples !"); - std::size_t nbOfComp1=getNumberOfComponents(); - std::size_t nbOfComp2=other->getNumberOfComponents(); + std::size_t const nbOfComp1=getNumberOfComponents(); + std::size_t const nbOfComp2=other->getNumberOfComponents(); char *newArr=(char *)malloc(nbOfTuples*(nbOfComp1+nbOfComp2)*sizeof(char)); char *w=newArr; const char *inp1=getConstPointer(); @@ -208,7 +216,7 @@ DataArrayIdType *DataArrayChar::findIdsEqual(char val) const throw INTERP_KERNEL::Exception("DataArrayChar::findIdsEqual : the array must have only one component, you can call 'rearrange' method before !"); const char *cptr=getConstPointer(); MCAuto ret(DataArrayIdType::New()); ret->alloc(0,1); - mcIdType nbOfTuples=getNumberOfTuples(); + mcIdType const nbOfTuples=getNumberOfTuples(); for(mcIdType i=0;ipushBackSilent(i); @@ -231,7 +239,7 @@ DataArrayIdType *DataArrayChar::findIdsNotEqual(char val) const throw INTERP_KERNEL::Exception("DataArrayChar::findIdsNotEqual : the array must have only one component, you can call 'rearrange' method before !"); const char *cptr=getConstPointer(); MCAuto ret(DataArrayIdType::New()); ret->alloc(0,1); - mcIdType nbOfTuples=getNumberOfTuples(); + mcIdType const nbOfTuples=getNumberOfTuples(); for(mcIdType i=0;ipushBackSilent(i); @@ -250,7 +258,7 @@ mcIdType DataArrayChar::findIdSequence(const std::vector& vals) const if(getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("DataArrayChar::findIdSequence : works only for DataArrayChar instance with one component !"); const char *cptr=getConstPointer(); - std::size_t nbOfVals=getNbOfElems(); + std::size_t const nbOfVals=getNbOfElems(); const char *loc=std::search(cptr,cptr+nbOfVals,vals.begin(),vals.end()); if(loc!=cptr+nbOfVals) return ToIdType(std::distance(cptr,loc)); @@ -272,7 +280,7 @@ mcIdType DataArrayChar::findIdSequence(const std::vector& vals) const mcIdType DataArrayChar::findIdFirstEqualTuple(const std::vector& tupl) const { checkAllocated(); - std::size_t nbOfCompo=getNumberOfComponents(); + std::size_t const nbOfCompo=getNumberOfComponents(); if(nbOfCompo==0) throw INTERP_KERNEL::Exception("DataArrayChar::findIdFirstEqualTuple : 0 components in 'this' !"); if(nbOfCompo!=tupl.size()) @@ -281,7 +289,7 @@ mcIdType DataArrayChar::findIdFirstEqualTuple(const std::vector& tupl) con throw INTERP_KERNEL::Exception(oss.str().c_str()); } const char *cptr=getConstPointer(); - std::size_t nbOfVals=getNbOfElems(); + std::size_t const nbOfVals=getNbOfElems(); for(const char *work=cptr;work!=cptr+nbOfVals;) { work=std::search(work,cptr+nbOfVals,tupl.begin(),tupl.end()); @@ -345,7 +353,7 @@ mcIdType DataArrayChar::findIdFirstEqual(char value) const if(getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("DataArrayChar::presenceOfValue : the array must have only one component, you can call 'rearrange' method before !"); const char *cptr=getConstPointer(); - mcIdType nbOfTuples=getNumberOfTuples(); + mcIdType const nbOfTuples=getNumberOfTuples(); const char *ret=std::find(cptr,cptr+nbOfTuples,value); if(ret!=cptr+nbOfTuples) return ToIdType(std::distance(cptr,ret)); @@ -365,7 +373,7 @@ mcIdType DataArrayChar::findIdFirstEqual(const std::vector& vals) const throw INTERP_KERNEL::Exception("DataArrayChar::findIdFirstEqual : the array must have only one component, you can call 'rearrange' method before !"); std::set vals2(vals.begin(),vals.end()); const char *cptr=getConstPointer(); - mcIdType nbOfTuples=getNumberOfTuples(); + mcIdType const nbOfTuples=getNumberOfTuples(); for(const char *w=cptr;w!=cptr+nbOfTuples;w++) if(vals2.find(*w)!=vals2.end()) return ToIdType(std::distance(cptr,w)); @@ -388,7 +396,7 @@ DataArrayIdType *DataArrayChar::findIdsInRange(char vmin, char vmax) const throw INTERP_KERNEL::Exception("DataArrayChar::findIdsInRange : this must have exactly one component !"); const char *cptr=getConstPointer(); MCAuto ret=DataArrayIdType::New(); ret->alloc(0,1); - mcIdType nbOfTuples=getNumberOfTuples(); + mcIdType const nbOfTuples=getNumberOfTuples(); for(mcIdType i=0;i=vmin && *cptrpushBackSilent(i); @@ -433,13 +441,13 @@ DataArrayChar *DataArrayChar::Aggregate(const DataArrayChar *a1, const DataArray DataArrayChar *DataArrayChar::Aggregate(const std::vector& arr) { std::vector a; - for(std::vector::const_iterator it4=arr.begin();it4!=arr.end();it4++) - if(*it4) - a.push_back(*it4); + for(auto it4 : arr) + if(it4) + a.push_back(it4); if(a.empty()) throw INTERP_KERNEL::Exception("DataArrayChar::Aggregate : input list must be NON EMPTY !"); std::vector::const_iterator it=a.begin(); - std::size_t nbOfComp((*it)->getNumberOfComponents()); + std::size_t const nbOfComp((*it)->getNumberOfComponents()); mcIdType nbt=(*it++)->getNumberOfTuples(); for(;it!=a.end();it++) { @@ -497,16 +505,16 @@ DataArrayChar *DataArrayChar::Meld(const DataArrayChar *a1, const DataArrayChar DataArrayChar *DataArrayChar::Meld(const std::vector& arr) { std::vector a; - for(std::vector::const_iterator it4=arr.begin();it4!=arr.end();it4++) - if(*it4) - a.push_back(*it4); + for(auto it4 : arr) + if(it4) + a.push_back(it4); if(a.empty()) throw INTERP_KERNEL::Exception("DataArrayChar::Meld : array must be NON empty !"); std::vector::const_iterator it; for(it=a.begin();it!=a.end();it++) (*it)->checkAllocated(); it=a.begin(); - mcIdType nbOfTuples=(*it)->getNumberOfTuples(); + mcIdType const nbOfTuples=(*it)->getNumberOfTuples(); std::vector nbc(a.size()); std::vector pts(a.size()); nbc[0]=(*it)->getNumberOfComponents(); @@ -518,7 +526,7 @@ DataArrayChar *DataArrayChar::Meld(const std::vector& arr nbc[i]=(*it)->getNumberOfComponents(); pts[i]=(*it)->getConstPointer(); } - std::size_t totalNbOfComp=std::accumulate(nbc.begin(),nbc.end(),(std::size_t)0); + std::size_t const totalNbOfComp=std::accumulate(nbc.begin(),nbc.end(),(std::size_t)0); DataArrayChar *ret=a[0]->buildEmptySpecializedDAChar(); ret->alloc(nbOfTuples,totalNbOfComp); char *retPtr=ret->getPointer(); @@ -621,8 +629,8 @@ void DataArrayByte::reprWithoutNameStream(std::ostream& stream) const if(_mem.reprHeader(ToIdType(getNumberOfComponents()),stream)) { const char *data=begin(); - mcIdType nbOfTuples=getNumberOfTuples(); - std::size_t nbCompo=getNumberOfComponents(); + mcIdType const nbOfTuples=getNumberOfTuples(); + std::size_t const nbCompo=getNumberOfComponents(); for(mcIdType i=0;i=1) @@ -665,10 +673,10 @@ void DataArrayByte::reprQuickOverview(std::ostream& stream) const stream << "DataArrayByte C++ instance at " << this << ". "; if(isAllocated()) { - std::size_t nbOfCompo=_info_on_compo.size(); + std::size_t const nbOfCompo=_info_on_compo.size(); if(nbOfCompo>=1) { - mcIdType nbOfTuples=getNumberOfTuples(); + mcIdType const nbOfTuples=getNumberOfTuples(); stream << "Number of tuples : " << nbOfTuples << ". Number of components : " << nbOfCompo << "." << std::endl; reprQuickOverviewData(stream,MAX_NB_OF_BYTE_IN_REPR); } @@ -682,8 +690,8 @@ void DataArrayByte::reprQuickOverview(std::ostream& stream) const void DataArrayByte::reprQuickOverviewData(std::ostream& stream, std::size_t maxNbOfByteInRepr) const { const char *data=begin(); - mcIdType nbOfTuples=getNumberOfTuples(); - std::size_t nbOfCompo=_info_on_compo.size(); + mcIdType const nbOfTuples=getNumberOfTuples(); + std::size_t const nbOfCompo=_info_on_compo.size(); std::ostringstream oss2; oss2 << "["; std::string oss2Str(oss2.str()); bool isFinished=true; @@ -702,7 +710,7 @@ void DataArrayByte::reprQuickOverviewData(std::ostream& stream, std::size_t maxN else { oss2 << (int)*data; data++; } if(i!=nbOfTuples-1) oss2 << ", "; - std::string oss3Str(oss2.str()); + std::string const oss3Str(oss2.str()); if(oss3Str.length()(&other); + const auto *otherC=dynamic_cast(&other); if(!otherC) { reason="this is of type DataArrayByte whereas other is not a DataArrayByte instance"; return false; } return DataArrayChar::isEqualIfNotWhy(other,reason); @@ -732,7 +740,7 @@ std::vector DataArrayByte::toVectorOfBool() const checkAllocated(); if(getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("DataArrayByte::toVectorOfBool : this method can be used only if this has one component !"); - mcIdType nbt(getNumberOfTuples()); + mcIdType const nbt(getNumberOfTuples()); std::vector ret(nbt,false); const char *pt(begin()); for(mcIdType i=0;i DataArrayByte::toVectorOfBool() const return ret; } -DataArrayByteIterator::DataArrayByteIterator(DataArrayByte *da):_da(da),_pt(0),_tuple_id(0),_nb_comp(0),_nb_tuple(0) +DataArrayByteIterator::DataArrayByteIterator(DataArrayByte *da):_da(da),_pt(nullptr),_tuple_id(0),_nb_comp(0),_nb_tuple(0) { if(_da) { @@ -766,12 +774,12 @@ DataArrayByteTuple *DataArrayByteIterator::nextt() if(_tuple_id<_nb_tuple) { _tuple_id++; - DataArrayByteTuple *ret=new DataArrayByteTuple(_pt,_nb_comp); + auto *ret=new DataArrayByteTuple(_pt,_nb_comp); _pt+=_nb_comp; return ret; } else - return 0; + return nullptr; } DataArrayByteTuple::DataArrayByteTuple(char *pt, std::size_t nbOfComp):_pt(pt),_nb_of_compo(nbOfComp) @@ -840,7 +848,7 @@ DataArrayAsciiChar *DataArrayAsciiChar::New(const std::string& st) */ DataArrayAsciiChar::DataArrayAsciiChar(const std::string& st) { - std::size_t lgth=st.length(); + std::size_t const lgth=st.length(); if(lgth==0) throw INTERP_KERNEL::Exception("DataArrayAsciiChar constructor with string ! Size of input string is null !"); alloc(1,lgth); @@ -881,17 +889,17 @@ DataArrayAsciiChar::DataArrayAsciiChar(const std::vector& vst, char if(vst.empty()) throw INTERP_KERNEL::Exception("DataArrayAsciiChar constructor with vector of strings ! Empty array !"); std::size_t nbCompo=0; - for(std::vector::const_iterator it=vst.begin();it!=vst.end();it++) - nbCompo=std::max(nbCompo,(*it).length()); + for(const auto & it : vst) + nbCompo=std::max(nbCompo,it.length()); if(nbCompo==0) throw INTERP_KERNEL::Exception("DataArrayAsciiChar constructor with vector of strings ! All strings in not empty vector are empty !"); - std::size_t nbTuples=vst.size(); + std::size_t const nbTuples=vst.size(); alloc(nbTuples,nbCompo); char *pt=getPointer(); for(std::size_t i=0;i=1) @@ -1017,10 +1025,10 @@ void DataArrayAsciiChar::reprQuickOverview(std::ostream& stream) const stream << "DataArrayAsciiChar C++ instance at " << this << ". "; if(isAllocated()) { - std::size_t nbOfCompo=_info_on_compo.size(); + std::size_t const nbOfCompo=_info_on_compo.size(); if(nbOfCompo>=1) { - mcIdType nbOfTuples=getNumberOfTuples(); + mcIdType const nbOfTuples=getNumberOfTuples(); stream << "Number of tuples : " << nbOfTuples << ". Number of components : " << nbOfCompo << "." << std::endl; reprQuickOverviewData(stream,MAX_NB_OF_BYTE_IN_REPR); } @@ -1034,8 +1042,8 @@ void DataArrayAsciiChar::reprQuickOverview(std::ostream& stream) const void DataArrayAsciiChar::reprQuickOverviewData(std::ostream& stream, std::size_t maxNbOfByteInRepr) const { const char *data=begin(); - mcIdType nbOfTuples=getNumberOfTuples(); - std::size_t nbOfCompo=_info_on_compo.size(); + mcIdType const nbOfTuples=getNumberOfTuples(); + std::size_t const nbOfCompo=_info_on_compo.size(); std::ostringstream oss2; oss2 << "["; std::string oss2Str(oss2.str()); bool isFinished=true; @@ -1062,7 +1070,7 @@ void DataArrayAsciiChar::reprQuickOverviewData(std::ostream& stream, std::size_t oss2 << ")"; } if(i!=nbOfTuples-1) oss2 << ", "; - std::string oss3Str(oss2.str()); + std::string const oss3Str(oss2.str()); if(oss3Str.length()(&other); + const auto *otherC=dynamic_cast(&other); if(!otherC) { reason="this is of type DataArrayAsciiChar whereas other is not a DataArrayAsciiChar instance"; return false; } return DataArrayChar::isEqualIfNotWhy(other,reason); } -DataArrayAsciiCharIterator::DataArrayAsciiCharIterator(DataArrayAsciiChar *da):_da(da),_pt(0),_tuple_id(0),_nb_comp(0),_nb_tuple(0) +DataArrayAsciiCharIterator::DataArrayAsciiCharIterator(DataArrayAsciiChar *da):_da(da),_pt(nullptr),_tuple_id(0),_nb_comp(0),_nb_tuple(0) { if(_da) { @@ -1107,12 +1115,12 @@ DataArrayAsciiCharTuple *DataArrayAsciiCharIterator::nextt() if(_tuple_id<_nb_tuple) { _tuple_id++; - DataArrayAsciiCharTuple *ret=new DataArrayAsciiCharTuple(_pt,_nb_comp); + auto *ret=new DataArrayAsciiCharTuple(_pt,_nb_comp); _pt+=_nb_comp; return ret; } else - return 0; + return nullptr; } DataArrayAsciiCharTuple::DataArrayAsciiCharTuple(char *pt, std::size_t nbOfComp):_pt(pt),_nb_of_compo(nbOfComp) diff --git a/src/MEDCoupling/MEDCouplingMemArrayFloat.cxx b/src/MEDCoupling/MEDCouplingMemArrayFloat.cxx index 4b7132cd5..6aa588162 100644 --- a/src/MEDCoupling/MEDCouplingMemArrayFloat.cxx +++ b/src/MEDCoupling/MEDCouplingMemArrayFloat.cxx @@ -19,6 +19,13 @@ // Author : Anthony Geay (EDF R&D) #include "MEDCouplingMemArray.txx" +#include "MCType.hxx" +#include +#include +#include +#include +#include +#include using namespace MEDCoupling; @@ -40,8 +47,8 @@ DataArrayFloat *DataArrayFloat::deepCopy() const void DataArrayFloat::reprCppStream(const std::string& varName, std::ostream& stream) const { - mcIdType nbTuples(getNumberOfTuples()); - std::size_t nbComp(getNumberOfComponents()); + mcIdType const nbTuples(getNumberOfTuples()); + std::size_t const nbComp(getNumberOfComponents()); const float *data(begin()); stream.precision(7); stream << "DataArrayFloat *" << varName << "=DataArrayFloat::New();" << std::endl; @@ -63,10 +70,10 @@ void DataArrayFloat::reprQuickOverview(std::ostream& stream) const stream << "DataArrayFloat C++ instance at " << this << ". "; if(isAllocated()) { - std::size_t nbOfCompo=_info_on_compo.size(); + std::size_t const nbOfCompo=_info_on_compo.size(); if(nbOfCompo>=1) { - mcIdType nbOfTuples=getNumberOfTuples(); + mcIdType const nbOfTuples=getNumberOfTuples(); stream << "Number of tuples : " << nbOfTuples << ". Number of components : " << nbOfCompo << "." << std::endl; reprQuickOverviewData(stream,MAX_NB_OF_BYTE_IN_REPR); } @@ -80,8 +87,8 @@ void DataArrayFloat::reprQuickOverview(std::ostream& stream) const void DataArrayFloat::reprQuickOverviewData(std::ostream& stream, std::size_t maxNbOfByteInRepr) const { const float *data(begin()); - mcIdType nbOfTuples(getNumberOfTuples()); - std::size_t nbOfCompo=_info_on_compo.size(); + mcIdType const nbOfTuples(getNumberOfTuples()); + std::size_t const nbOfCompo=_info_on_compo.size(); std::ostringstream oss2; oss2 << "["; oss2.precision(7); std::string oss2Str(oss2.str()); @@ -101,7 +108,7 @@ void DataArrayFloat::reprQuickOverviewData(std::ostream& stream, std::size_t max else oss2 << *data++; if(i!=nbOfTuples-1) oss2 << ", "; - std::string oss3Str(oss2.str()); + std::string const oss3Str(oss2.str()); if(oss3Str.length() +#include +#include +#include #include #include #include #include -#include +#include using namespace MEDCoupling; @@ -56,7 +64,7 @@ bool MEDCouplingMesh::isStructured() const return getType()==CARTESIAN; } -bool MEDCouplingMesh::isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const +bool MEDCouplingMesh::isEqualIfNotWhy(const MEDCouplingMesh *other, double /*prec*/, std::string& reason) const { if(!other) throw INTERP_KERNEL::Exception("MEDCouplingMesh::isEqualIfNotWhy : other instance is NULL !"); @@ -148,8 +156,8 @@ bool MEDCouplingMesh::isEqual(const MEDCouplingMesh *other, double prec) const void MEDCouplingMesh::checkGeoEquivalWith(const MEDCouplingMesh *other, int levOfCheck, double prec, DataArrayIdType *&cellCor, DataArrayIdType *&nodeCor) const { - cellCor=0; - nodeCor=0; + cellCor=nullptr; + nodeCor=nullptr; if(this==other) return ; switch(levOfCheck) @@ -203,7 +211,7 @@ DataArrayIdType *MEDCouplingMesh::getCellIdsFullyIncludedInNodeIds(const mcIdTyp { std::vector crest; std::set p(partBg,partEnd); - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbOfCells=getNumberOfCells(); for(mcIdType i=0;i conn; @@ -224,7 +232,7 @@ DataArrayIdType *MEDCouplingMesh::getCellIdsFullyIncludedInNodeIds(const mcIdTyp /*! * This method checks fastly that \a this and \a other are equal. All common checks are done here. */ -void MEDCouplingMesh::checkFastEquivalWith(const MEDCouplingMesh *other, double prec) const +void MEDCouplingMesh::checkFastEquivalWith(const MEDCouplingMesh *other, double /*prec*/) const { if(!other) throw INTERP_KERNEL::Exception("MEDCouplingMesh::checkFastEquivalWith : input mesh is null !"); @@ -263,7 +271,7 @@ MEDCouplingMesh *MEDCouplingMesh::buildPartRange(mcIdType beginCellIds, mcIdType { if(beginCellIds==0 && endCellIds==getNumberOfCells() && stepCellIds==1) { - MEDCouplingMesh *ret(const_cast(this)); + auto *ret(const_cast(this)); ret->incrRef(); return ret; } @@ -279,7 +287,7 @@ MEDCouplingMesh *MEDCouplingMesh::buildPartRange(mcIdType beginCellIds, mcIdType * * \sa MEDCouplingMesh::buildPartAndReduceNodes */ -MEDCouplingMesh *MEDCouplingMesh::buildPartRangeAndReduceNodes(mcIdType beginCellIds, mcIdType endCellIds, mcIdType stepCellIds, mcIdType& beginOut, mcIdType& endOut, mcIdType& stepOut, DataArrayIdType*& arr) const +MEDCouplingMesh *MEDCouplingMesh::buildPartRangeAndReduceNodes(mcIdType beginCellIds, mcIdType endCellIds, mcIdType stepCellIds, mcIdType& /*beginOut*/, mcIdType& /*endOut*/, mcIdType& /*stepOut*/, DataArrayIdType*& arr) const { MCAuto cellIds=DataArrayIdType::Range(beginCellIds,endCellIds,stepCellIds); return buildPartAndReduceNodes(cellIds->begin(),cellIds->end(),arr); @@ -651,7 +659,7 @@ void MEDCouplingMesh::getCellsContainingPoints(const double *pos, mcIdType nbOfP { eltsIndex=DataArrayIdType::New(); elts=DataArrayIdType::New(); eltsIndex->alloc(nbOfPoints+1,1); eltsIndex->setIJ(0,0,0); elts->alloc(0,1); mcIdType *eltsIndexPtr(eltsIndex->getPointer()); - int spaceDim(getSpaceDimension()); + int const spaceDim(getSpaceDimension()); const double *work(pos); for(mcIdType i=0;i MEDCouplingMesh::computeMeshCenterOfMass() const MCAuto volXCenter( DataArrayDouble::Multiply(cellCenters,vol->getArray()) ); MCAuto ret(DataArrayDouble::New()); ret->alloc(1, this->getSpaceDimension()); volXCenter->accumulate( ret->getPointer() ); - double volOfMesh(vol->accumulate(0)); + double const volOfMesh(vol->accumulate(0)); ret->applyLin(1.0/volOfMesh,0.0); return ret; } @@ -752,7 +760,7 @@ void MEDCouplingMesh::writeVTKAdvanced(const std::string& fileName, const std::s void MEDCouplingMesh::SplitExtension(const std::string& fileName, std::string& baseName, std::string& extension) { - std::size_t pos(fileName.find_last_of('.')); + std::size_t const pos(fileName.find_last_of('.')); if(pos==std::string::npos) { baseName=fileName; diff --git a/src/MEDCoupling/MEDCouplingMesh.hxx b/src/MEDCoupling/MEDCouplingMesh.hxx index 7ba57fc24..562c0da3d 100644 --- a/src/MEDCoupling/MEDCouplingMesh.hxx +++ b/src/MEDCoupling/MEDCouplingMesh.hxx @@ -25,12 +25,14 @@ #include "MCType.hxx" #include "MEDCouplingTimeLabel.hxx" #include "MEDCouplingRefCountObject.hxx" -#include "NormalizedUnstructuredMesh.hxx" #include "MCAuto.hxx" +#include "NormalizedGeometricTypes" -#include "InterpKernelException.hxx" +#include +#include #include +#include #include namespace MEDCoupling @@ -56,7 +58,7 @@ namespace MEDCoupling class MEDCouplingMesh : public RefCountObject, public TimeLabel { public: - MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; + MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const override; MEDCOUPLING_EXPORT void setName(const std::string& name) { _name=name; } MEDCOUPLING_EXPORT std::string getName() const { return _name; } MEDCOUPLING_EXPORT void setDescription(const std::string& descr) { _description=descr; } @@ -163,7 +165,7 @@ namespace MEDCoupling MEDCOUPLING_EXPORT MEDCouplingMesh(); MEDCOUPLING_EXPORT MEDCouplingMesh(const MEDCouplingMesh& other); MEDCOUPLING_EXPORT virtual std::string getVTKDataSetType() const = 0; - MEDCOUPLING_EXPORT virtual ~MEDCouplingMesh() { } + MEDCOUPLING_EXPORT ~MEDCouplingMesh() override = default; private: std::string _name; std::string _description; diff --git a/src/MEDCoupling/MEDCouplingMultiFields.cxx b/src/MEDCoupling/MEDCouplingMultiFields.cxx index 366f106d9..a8d2ec80b 100644 --- a/src/MEDCoupling/MEDCouplingMultiFields.cxx +++ b/src/MEDCoupling/MEDCouplingMultiFields.cxx @@ -19,13 +19,20 @@ // Author : Anthony Geay (CEA/DEN) #include "MEDCouplingMultiFields.hxx" +#include "MCAuto.hxx" +#include "MCIdType.hxx" +#include "MCType.hxx" #include "MEDCouplingFieldTemplate.hxx" #include "MEDCouplingFieldDouble.hxx" #include "MEDCouplingMesh.hxx" -#include "MCAuto.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include +#include #include #include +#include +#include using namespace MEDCoupling; @@ -44,9 +51,9 @@ MEDCouplingMultiFields *MEDCouplingMultiFields::deepCopy() const return new MEDCouplingMultiFields(*this); } -bool MEDCouplingMultiFields::isEqual(const MEDCouplingMultiFields *other, double meshPrec, double valsPrec) const +bool MEDCouplingMultiFields::isEqual(const MEDCouplingMultiFields *other, double meshPrec, double valsPrec) const { - std::size_t sz=_fs.size(); + std::size_t const sz=_fs.size(); if(sz!=other->_fs.size()) return false; for(std::size_t i=0;i_fs[i]; if(f1!=f2) { - if(f1==0 || f2==0) + if(f1==nullptr || f2==nullptr) return false; if(!_fs[i]->isEqual(other->_fs[i],meshPrec,valsPrec)) return false; } } std::vector refs1,refs2; - std::vector ms1=getDifferentMeshes(refs1); - std::vector ms2=other->getDifferentMeshes(refs2); + std::vector const ms1=getDifferentMeshes(refs1); + std::vector const ms2=other->getDifferentMeshes(refs2); if(ms1.size()!=ms2.size()) return false; if(refs1!=refs2) return false; std::vector< std::vector > refs3,refs4; - std::vector das1=getDifferentArrays(refs3); - std::vector das2=getDifferentArrays(refs4); + std::vector const das1=getDifferentArrays(refs3); + std::vector const das2=getDifferentArrays(refs4); if(das1.size()!=das2.size()) return false; if(refs3!=refs4) @@ -80,7 +87,7 @@ bool MEDCouplingMultiFields::isEqual(const MEDCouplingMultiFields *other, double std::string MEDCouplingMultiFields::getName() const { - std::vector< MCAuto >::const_iterator it=_fs.begin(); + auto it=_fs.begin(); for(;it!=_fs.end();it++) if((const MEDCouplingFieldDouble *)(*it)) return (*it)->getName(); @@ -89,7 +96,7 @@ std::string MEDCouplingMultiFields::getName() const std::string MEDCouplingMultiFields::getDescription() const { - std::vector< MCAuto >::const_iterator it=_fs.begin(); + auto it=_fs.begin(); for(;it!=_fs.end();it++) if((const MEDCouplingFieldDouble *)(*it)) return (*it)->getDescription(); @@ -98,7 +105,7 @@ std::string MEDCouplingMultiFields::getDescription() const std::string MEDCouplingMultiFields::getTimeUnit() const { - std::vector< MCAuto >::const_iterator it=_fs.begin(); + auto it=_fs.begin(); for(;it!=_fs.end();it++) if((const MEDCouplingFieldDouble *)(*it)) return (*it)->getTimeUnit(); @@ -107,7 +114,7 @@ std::string MEDCouplingMultiFields::getTimeUnit() const double MEDCouplingMultiFields::getTimeResolution() const { - std::vector< MCAuto >::const_iterator it=_fs.begin(); + auto it=_fs.begin(); for(;it!=_fs.end();it++) if((const MEDCouplingFieldDouble *)(*it)) return (*it)->getTimeTolerance(); @@ -138,9 +145,9 @@ std::string MEDCouplingMultiFields::advancedRepr() const return simpleRepr(); } -bool MEDCouplingMultiFields::isEqualWithoutConsideringStr(const MEDCouplingMultiFields *other, double meshPrec, double valsPrec) const +bool MEDCouplingMultiFields::isEqualWithoutConsideringStr(const MEDCouplingMultiFields *other, double meshPrec, double valsPrec) const { - std::size_t sz=_fs.size(); + std::size_t const sz=_fs.size(); if(sz!=other->_fs.size()) return false; for(std::size_t i=0;i >::const_iterator it=_fs.begin(); + auto it=_fs.begin(); for(;it!=_fs.end();it++) if((const MEDCouplingFieldDouble *)(*it)) (*it)->updateTime(); @@ -198,19 +205,19 @@ std::size_t MEDCouplingMultiFields::getHeapMemorySizeWithoutChildren() const std::vector MEDCouplingMultiFields::getDirectChildrenWithNull() const { std::vector ret; - for(std::vector< MCAuto >::const_iterator it=_fs.begin();it!=_fs.end();it++) - ret.push_back((const MEDCouplingFieldDouble *)*it); + for(const auto & _f : _fs) + ret.push_back((const MEDCouplingFieldDouble *)_f); return ret; } std::vector MEDCouplingMultiFields::getMeshes() const { std::vector ms; - for(std::vector< MCAuto >::const_iterator it=_fs.begin();it!=_fs.end();it++) + for(const auto & _f : _fs) { - const MEDCouplingMesh *m=0; - if((const MEDCouplingFieldDouble *)(*it)) - m=(*it)->getMesh(); + const MEDCouplingMesh *m=nullptr; + if((const MEDCouplingFieldDouble *)_f) + m=_f->getMesh(); ms.push_back(const_cast(m)); } return ms; @@ -221,14 +228,14 @@ std::vector MEDCouplingMultiFields::getDifferentMeshes(std::v refs.resize(_fs.size()); std::vector ms; int id=0; - for(std::vector< MCAuto >::const_iterator it=_fs.begin();it!=_fs.end();it++,id++) + for(auto it=_fs.begin();it!=_fs.end();it++,id++) { - const MEDCouplingMesh *m=0; + const MEDCouplingMesh *m=nullptr; if((const MEDCouplingFieldDouble *)(*it)) m=(*it)->getMesh(); if(m) { - std::vector::iterator it2=std::find(ms.begin(),ms.end(),m); + auto const it2=std::find(ms.begin(),ms.end(),m); if(it2==ms.end()) { ms.push_back(const_cast(m)); @@ -246,9 +253,9 @@ std::vector MEDCouplingMultiFields::getDifferentMeshes(std::v std::vector MEDCouplingMultiFields::getArrays() const { std::vector tmp; - for(std::vector< MCAuto >::const_iterator it=_fs.begin();it!=_fs.end();it++) + for(const auto & _f : _fs) { - std::vector tmp2=(*it)->getArrays(); + std::vector tmp2=_f->getArrays(); tmp.insert(tmp.end(),tmp2.begin(),tmp2.end()); } return tmp; @@ -259,7 +266,7 @@ std::vector MEDCouplingMultiFields::getDifferentArrays(std::v refs.resize(_fs.size()); int id=0; std::vector ret; - for(std::vector< MCAuto >::const_iterator it=_fs.begin();it!=_fs.end();it++,id++) + for(auto it=_fs.begin();it!=_fs.end();it++,id++) { std::vector tmp2; if((const MEDCouplingFieldDouble *)(*it)) @@ -274,7 +281,7 @@ std::vector MEDCouplingMultiFields::getDifferentArrays(std::v { if(*it2) { - std::vector::iterator it3=std::find(ret.begin(),ret.end(),*it2); + auto const it3=std::find(ret.begin(),ret.end(),*it2); if(it3==ret.end()) { ret.push_back(*it2); @@ -292,10 +299,10 @@ std::vector MEDCouplingMultiFields::getDifferentArrays(std::v void MEDCouplingMultiFields::checkConsistencyLight() const { - std::vector< MCAuto >::const_iterator it=_fs.begin(); + auto it=_fs.begin(); for(;it!=_fs.end();it++) { - if((const MEDCouplingFieldDouble *)(*it)==0) + if((const MEDCouplingFieldDouble *)(*it)==nullptr) throw INTERP_KERNEL::Exception("MEDCouplingMultiFields::checkConsistencyLight : There is an empty Field in array..."); (*it)->checkConsistencyLight(); } @@ -304,7 +311,7 @@ void MEDCouplingMultiFields::checkConsistencyLight() const MEDCouplingMultiFields::MEDCouplingMultiFields(const std::vector& fs):_fs(fs.size()) { int id=0; - for(std::vector< MEDCouplingFieldDouble * >::const_iterator it=fs.begin();it!=fs.end();it++,id++) + for(auto it=fs.begin();it!=fs.end();it++,id++) { if(*it) (*it)->incrRef(); @@ -321,17 +328,17 @@ MEDCouplingMultiFields::MEDCouplingMultiFields(const std::vector refs; std::vector< std::vector > refs2; std::vector ms=other.getDifferentMeshes(refs); - std::size_t msLgh=ms.size(); + std::size_t const msLgh=ms.size(); std::vector< MCAuto > ms2(msLgh); for(std::size_t i=0;ideepCopy(); std::vector das=other.getDifferentArrays(refs2); - std::size_t dasLgth=das.size(); + std::size_t const dasLgth=das.size(); std::vector< MCAuto > das2(dasLgth); for(std::size_t i=0;ideepCopy(); @@ -344,14 +351,14 @@ MEDCouplingMultiFields::MEDCouplingMultiFields(const MEDCouplingMultiFields& oth tmp->decrRef(); if(refs[i]!=-1) _fs[i]->setMesh(ms2[refs[i]]); - std::size_t nbOfArr=refs2[i].size(); + std::size_t const nbOfArr=refs2[i].size(); std::vector tmp2(nbOfArr); for(std::size_t j=0;jsetArrays(tmp2); std::vector tinyInfo; @@ -364,25 +371,24 @@ MEDCouplingMultiFields::MEDCouplingMultiFields(const MEDCouplingMultiFields& oth } MEDCouplingMultiFields::MEDCouplingMultiFields() -{ -} += default; void MEDCouplingMultiFields::getTinySerializationInformation(std::vector& tinyInfo, std::vector& tinyInfo2, int& nbOfDiffMeshes, int& nbOfDiffArr) const { std::vector refs; - std::vector ms=getDifferentMeshes(refs); + std::vector const ms=getDifferentMeshes(refs); nbOfDiffMeshes=(int)ms.size(); std::vector< std::vector > refs2; - std::vector fs=getDifferentArrays(refs2); + std::vector const fs=getDifferentArrays(refs2); nbOfDiffArr=(int)fs.size(); // - mcIdType sz=ToIdType(refs.size());//==_fs.size() + mcIdType const sz=ToIdType(refs.size());//==_fs.size() mcIdType sz2=0; for(mcIdType i=0;i doubleDaInd(sz); + std::vector const doubleDaInd(sz); std::vector timeDiscrInt; tinyInfo.resize(sz2+5*sz+3); tinyInfo[0]=sz; @@ -398,7 +404,7 @@ void MEDCouplingMultiFields::getTinySerializationInformation(std::vector& const std::vector& ft, const std::vector& ms, const std::vector& das) { - mcIdType sz=tinyInfoI[0]; + mcIdType const sz=tinyInfoI[0]; _fs.resize(sz); - mcIdType sz2=tinyInfoI[1]; + mcIdType const sz2=tinyInfoI[1]; // dealing with ft with no mesh set. for(mcIdType i=0;isetMesh(ms[meshId]); } @@ -435,23 +441,23 @@ void MEDCouplingMultiFields::finishUnserialization(const std::vector& for(mcIdType i=0;i tmp(sz3); for(mcIdType j=0;jsetArrays(tmp); // time discr tiny info - mcIdType lgthI=tinyInfoI[4*sz+3+i]; - mcIdType lgthD=tinyInfoI[3*sz+3+i]; + mcIdType const lgthI=tinyInfoI[4*sz+3+i]; + mcIdType const lgthD=tinyInfoI[3*sz+3+i]; // - std::vector tdInfoI(tinyInfoI.begin()+sz2+5*sz+3+offI,tinyInfoI.begin()+sz2+5*sz+3+offI+lgthI); - std::vector tdInfoD(tinyInfoD.begin()+offD,tinyInfoD.begin()+offD+lgthD); + std::vector const tdInfoI(tinyInfoI.begin()+sz2+5*sz+3+offI,tinyInfoI.begin()+sz2+5*sz+3+offI+lgthI); + std::vector const tdInfoD(tinyInfoD.begin()+offD,tinyInfoD.begin()+offD+lgthD); _fs[i]->getTimeDiscretizationUnderGround()->finishUnserialization2(tdInfoI,tdInfoD); // offI+=lgthI; diff --git a/src/MEDCoupling/MEDCouplingMultiFields.hxx b/src/MEDCoupling/MEDCouplingMultiFields.hxx index eff41fef8..2fb6b6d47 100644 --- a/src/MEDCoupling/MEDCouplingMultiFields.hxx +++ b/src/MEDCoupling/MEDCouplingMultiFields.hxx @@ -21,13 +21,15 @@ #ifndef __PARAMEDMEM_MEDCOUPLINGMULTIFIELDS_HXX__ #define __PARAMEDMEM_MEDCOUPLINGMULTIFIELDS_HXX__ +#include "MEDCoupling.hxx" #include "MEDCouplingRefCountObject.hxx" #include "MEDCouplingTimeLabel.hxx" #include "MCAuto.hxx" #include "MCType.hxx" -#include "InterpKernelException.hxx" +#include +#include #include namespace MEDCoupling @@ -60,9 +62,9 @@ namespace MEDCoupling MEDCOUPLING_EXPORT virtual std::vector getDifferentMeshes(std::vector& refs) const; MEDCOUPLING_EXPORT virtual std::vector getArrays() const; MEDCOUPLING_EXPORT virtual std::vector getDifferentArrays(std::vector< std::vector >& refs) const; - MEDCOUPLING_EXPORT void updateTime() const; - MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; - MEDCOUPLING_EXPORT std::vector getDirectChildrenWithNull() const; + MEDCOUPLING_EXPORT void updateTime() const override; + MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const override; + MEDCOUPLING_EXPORT std::vector getDirectChildrenWithNull() const override; MEDCOUPLING_EXPORT void getTinySerializationInformation(std::vector& tinyInfo, std::vector& tinyInfo2, int& nbOfDiffMeshes, int& nbOfDiffArr) const; MEDCOUPLING_EXPORT void finishUnserialization(const std::vector& tinyInfoI, const std::vector& tinyInfoD, const std::vector& ft, const std::vector& ms, diff --git a/src/MEDCoupling/MEDCouplingNatureOfField.cxx b/src/MEDCoupling/MEDCouplingNatureOfField.cxx index 725e27267..6c2405bf0 100644 --- a/src/MEDCoupling/MEDCouplingNatureOfField.cxx +++ b/src/MEDCoupling/MEDCouplingNatureOfField.cxx @@ -19,9 +19,14 @@ // Author : Anthony Geay (CEA/DEN) #include "MEDCouplingNatureOfField.hxx" +#include "MEDCouplingNatureOfFieldEnum" +#include "InterpKernelException.hxx" #include +#include +#include #include +#include namespace MEDCoupling { @@ -43,7 +48,7 @@ namespace MEDCoupling oss << GetAllPossibilitiesStr() << " !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - std::size_t pos2=std::distance(POS_OF_NATUREOFFIELD,pos); + std::size_t const pos2=std::distance(POS_OF_NATUREOFFIELD,pos); return REPR_OF_NATUREOFFIELD[pos2]; } @@ -52,7 +57,7 @@ namespace MEDCoupling const int *pos=std::find(POS_OF_NATUREOFFIELD,POS_OF_NATUREOFFIELD+NB_OF_POSSIBILITIES,(int)nat); if(pos==POS_OF_NATUREOFFIELD+NB_OF_POSSIBILITIES) return std::string("Unrecognized nature of field !"); - std::size_t pos2=std::distance(POS_OF_NATUREOFFIELD,pos); + std::size_t const pos2=std::distance(POS_OF_NATUREOFFIELD,pos); return std::string(REPR_OF_NATUREOFFIELD[pos2]); } diff --git a/src/MEDCoupling/MEDCouplingNatureOfField.hxx b/src/MEDCoupling/MEDCouplingNatureOfField.hxx index af97d6894..dba2966c4 100644 --- a/src/MEDCoupling/MEDCouplingNatureOfField.hxx +++ b/src/MEDCoupling/MEDCouplingNatureOfField.hxx @@ -24,7 +24,7 @@ #include "MEDCoupling.hxx" #include "MEDCouplingNatureOfFieldEnum" -#include "InterpKernelException.hxx" +#include namespace MEDCoupling { diff --git a/src/MEDCoupling/MEDCouplingNormalizedCartesianMesh.hxx b/src/MEDCoupling/MEDCouplingNormalizedCartesianMesh.hxx index a590a5a58..3f05b001c 100644 --- a/src/MEDCoupling/MEDCouplingNormalizedCartesianMesh.hxx +++ b/src/MEDCoupling/MEDCouplingNormalizedCartesianMesh.hxx @@ -21,6 +21,7 @@ #ifndef __PARAMEDMEM_MEDCOUPLINGNORMALIZEDCARTESIANMESH_HXX__ #define __PARAMEDMEM_MEDCOUPLINGNORMALIZEDCARTESIANMESH_HXX__ +#include "MCIdType.hxx" #include "NormalizedUnstructuredMesh.hxx" namespace MEDCoupling @@ -34,7 +35,7 @@ class MEDCouplingNormalizedCartesianMesh public: static const int MY_SPACEDIM=SPACEDIM; static const int MY_MESHDIM=SPACEDIM; - typedef mcIdType MyConnType; + using MyConnType = int; static const INTERP_KERNEL::NumberingPolicy My_numPol=INTERP_KERNEL::ALL_C_MODE; public: MEDCouplingNormalizedCartesianMesh(const MEDCoupling::MEDCouplingCMesh *mesh); diff --git a/src/MEDCoupling/MEDCouplingNormalizedCartesianMesh.txx b/src/MEDCoupling/MEDCouplingNormalizedCartesianMesh.txx index f5c0d45fe..858d922e6 100644 --- a/src/MEDCoupling/MEDCouplingNormalizedCartesianMesh.txx +++ b/src/MEDCoupling/MEDCouplingNormalizedCartesianMesh.txx @@ -21,8 +21,10 @@ // Author : Edward AGAPOV (eap) // +#include "MCIdType.hxx" #include "MEDCouplingNormalizedCartesianMesh.hxx" #include "MEDCouplingCMesh.hxx" +#include "MEDCouplingMemArray.hxx" template MEDCouplingNormalizedCartesianMesh::MEDCouplingNormalizedCartesianMesh(const MEDCoupling::MEDCouplingCMesh *mesh):_mesh(mesh) diff --git a/src/MEDCoupling/MEDCouplingNormalizedUnstructuredMesh.hxx b/src/MEDCoupling/MEDCouplingNormalizedUnstructuredMesh.hxx index 7782da84d..bee841eaa 100644 --- a/src/MEDCoupling/MEDCouplingNormalizedUnstructuredMesh.hxx +++ b/src/MEDCoupling/MEDCouplingNormalizedUnstructuredMesh.hxx @@ -21,8 +21,9 @@ #ifndef __PARAMEDMEM_MEDCOUPLINGNORMALIZEDUNSTRUCTUREDMESH_HXX__ #define __PARAMEDMEM_MEDCOUPLINGNORMALIZEDUNSTRUCTUREDMESH_HXX__ +#include "MCIdType.hxx" #include "NormalizedUnstructuredMesh.hxx" -#include "MCType.hxx" +#include "NormalizedGeometricTypes" namespace MEDCoupling { diff --git a/src/MEDCoupling/MEDCouplingNormalizedUnstructuredMesh.txx b/src/MEDCoupling/MEDCouplingNormalizedUnstructuredMesh.txx index a4f57f3c6..145406625 100644 --- a/src/MEDCoupling/MEDCouplingNormalizedUnstructuredMesh.txx +++ b/src/MEDCoupling/MEDCouplingNormalizedUnstructuredMesh.txx @@ -22,12 +22,15 @@ #define __MEDCOUPLINGNORMALIZEDUNSTRUCTUREDMESH_TXX__ #include "MEDCouplingNormalizedUnstructuredMesh.hxx" -#include "InterpKernelAssert.hxx" +#include "MCIdType.hxx" +#include "InterpKernelAssert.hxx" #include "MEDCouplingUMesh.hxx" #include "MEDCoupling1GTUMesh.hxx" #include "MEDCouplingMemArray.hxx" +#include "NormalizedGeometricTypes" +#include #include template @@ -110,8 +113,8 @@ void MEDCouplingNormalizedUnstructuredMesh::releaseTempArrays( { delete [] _conn_for_interp; delete [] _conn_index_for_interp; - _conn_for_interp=0; - _conn_index_for_interp=0; + _conn_for_interp=nullptr; + _conn_index_for_interp=nullptr; } template @@ -126,11 +129,11 @@ template void MEDCouplingNormalizedUnstructuredMesh::prepare() { IKAssert(_mesh->getSpaceDimension()==SPACEDIM); - const MEDCoupling::MEDCouplingUMesh *m1(dynamic_cast(_mesh)); + const auto *m1(dynamic_cast(_mesh)); if(m1) { - mcIdType nbOfCell=ToIdType(m1->getNumberOfCells()); - mcIdType initialConnSize=ToIdType(m1->getNodalConnectivity()->getNbOfElems()); + mcIdType const nbOfCell=ToIdType(m1->getNumberOfCells()); + mcIdType const initialConnSize=ToIdType(m1->getNodalConnectivity()->getNbOfElems()); _conn_for_interp=new mcIdType[initialConnSize-nbOfCell]; _conn_index_for_interp=new mcIdType[nbOfCell+1]; _conn_index_for_interp[0]=0; @@ -140,7 +143,7 @@ void MEDCouplingNormalizedUnstructuredMesh::prepare() mcIdType *work_conn_index_for_interp=_conn_index_for_interp; for(mcIdType i=0;i::prepare() } return ; } - const MEDCoupling::MEDCoupling1DGTUMesh *m2(dynamic_cast(_mesh)); + const auto *m2(dynamic_cast(_mesh)); if(m2) { - mcIdType nbOfCell=ToIdType(m2->getNumberOfCells()); + mcIdType const nbOfCell=ToIdType(m2->getNumberOfCells()); _conn_index_for_interp=new mcIdType[nbOfCell+1]; const mcIdType *conni(m2->getNodalConnectivityIndex()->begin()); std::copy(conni,conni+nbOfCell+1,_conn_index_for_interp); @@ -160,7 +163,7 @@ void MEDCouplingNormalizedUnstructuredMesh::prepare() std::copy(m2->getNodalConnectivity()->begin(),m2->getNodalConnectivity()->end(),_conn_for_interp); return ; } - const MEDCoupling::MEDCoupling1SGTUMesh *m3(dynamic_cast(_mesh)); + const auto *m3(dynamic_cast(_mesh)); if(m3) { mcIdType nbOfCell=ToIdType(m3->getNumberOfCells()),nbNodesPerCell(m3->getNumberOfNodesPerCell()); diff --git a/src/MEDCoupling/MEDCouplingPartDefinition.cxx b/src/MEDCoupling/MEDCouplingPartDefinition.cxx index 0457a1d03..c28d926ea 100644 --- a/src/MEDCoupling/MEDCouplingPartDefinition.cxx +++ b/src/MEDCoupling/MEDCouplingPartDefinition.cxx @@ -19,9 +19,18 @@ // Author : Anthony Geay (EDF R&D) #include "MEDCouplingPartDefinition.hxx" - +#include "MCType.hxx" +#include "MCAuto.hxx" +#include "MCIdType.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include "MEDCouplingMemArray.hxx" + +#include +#include #include #include +#include +#include using namespace MEDCoupling; @@ -54,8 +63,7 @@ PartDefinition *PartDefinition::Unserialize(std::vector& tinyInt, std: } PartDefinition::~PartDefinition() -{ -} += default; DataArrayPartDefinition *DataArrayPartDefinition::New(DataArrayIdType *listOfIds) { @@ -69,7 +77,7 @@ bool DataArrayPartDefinition::isEqual(const PartDefinition *other, std::string& what="DataArrayPartDefinition::isEqual : other is null, this is not null !"; return false; } - const DataArrayPartDefinition *otherC(dynamic_cast(other)); + const auto *otherC(dynamic_cast(other)); if(!otherC) { what="DataArrayPartDefinition::isEqual : other is not DataArrayPartDefinition !"; @@ -84,7 +92,7 @@ bool DataArrayPartDefinition::isEqual(const PartDefinition *other, std::string& return false; } std::string what1; - bool ret(arr0->isEqualIfNotWhy(*arr1,what1)); + bool const ret(arr0->isEqualIfNotWhy(*arr1,what1)); if(!ret) { what=std::string("DataArrayPartDefinition::isEqual : arrays are not equal :\n")+what1; @@ -112,10 +120,10 @@ PartDefinition *DataArrayPartDefinition::operator+(const PartDefinition& other) const PartDefinition *otherPt(&other); if(!otherPt) throw INTERP_KERNEL::Exception("DataArrayPartDefinition::operator+ : NULL input !"); - const DataArrayPartDefinition *other1(dynamic_cast(otherPt)); + const auto *other1(dynamic_cast(otherPt)); if(other1) return add1(other1); - const SlicePartDefinition *other2(dynamic_cast(otherPt)); + const auto *other2(dynamic_cast(otherPt)); if(other2) return add2(other2); throw INTERP_KERNEL::Exception("DataArrayPartDefinition::operator+ : unrecognized type in input !"); @@ -142,7 +150,7 @@ PartDefinition *DataArrayPartDefinition::composeWith(const PartDefinition *other throw INTERP_KERNEL::Exception("DataArrayPartDefinition::composeWith : input PartDef must be not NULL !"); checkConsistencyLight(); other->checkConsistencyLight(); - const SlicePartDefinition *spd(dynamic_cast(other)); + const auto *spd(dynamic_cast(other)); if(spd) {//special case for optim mcIdType a(0),b(0),c(0); @@ -187,7 +195,7 @@ PartDefinition *DataArrayPartDefinition::tryToSimplify() const } } -void DataArrayPartDefinition::serialize(std::vector& tinyInt, std::vector< MCAuto >& bigArraysI) const +void DataArrayPartDefinition::serialize(std::vector& /*tinyInt*/, std::vector< MCAuto >& bigArraysI) const { bigArraysI.push_back(_arr); } @@ -196,7 +204,7 @@ DataArrayIdType *DataArrayPartDefinition::toDAI() const { checkInternalArrayOK(); const DataArrayIdType *arr(_arr); - DataArrayIdType *arr2(const_cast(arr)); + auto *arr2(const_cast(arr)); arr2->incrRef(); return arr2; } @@ -253,8 +261,7 @@ DataArrayPartDefinition *DataArrayPartDefinition::add2(const SlicePartDefinition } DataArrayPartDefinition::~DataArrayPartDefinition() -{ -} += default; SlicePartDefinition *SlicePartDefinition::New(mcIdType start, mcIdType stop, mcIdType step) { @@ -268,13 +275,13 @@ bool SlicePartDefinition::isEqual(const PartDefinition *other, std::string& what what="SlicePartDefinition::isEqual : other is null, this is not null !"; return false; } - const SlicePartDefinition *otherC(dynamic_cast(other)); + const auto *otherC(dynamic_cast(other)); if(!otherC) { what="SlicePartDefinition::isEqual : other is not SlicePartDefinition !"; return false; } - bool ret((_start==otherC->_start) && (_stop==otherC->_stop) && (_step==otherC->_step)); + bool const ret((_start==otherC->_start) && (_stop==otherC->_stop) && (_step==otherC->_step)); if(!ret) { what="SlicePartDefinition::isEqual : values are not the same !"; @@ -303,10 +310,10 @@ PartDefinition *SlicePartDefinition::operator+(const PartDefinition& other) cons const PartDefinition *otherPt(&other); if(!otherPt) throw INTERP_KERNEL::Exception("DataArrayPartDefinition::operator+ : NULL input !"); - const DataArrayPartDefinition *other1(dynamic_cast(otherPt)); + const auto *other1(dynamic_cast(otherPt)); if(other1) return add1(other1); - const SlicePartDefinition *other2(dynamic_cast(otherPt)); + const auto *other2(dynamic_cast(otherPt)); if(other2) return add2(other2); throw INTERP_KERNEL::Exception("SlicePartDefinition::operator+ : unrecognized type in input !"); @@ -346,7 +353,7 @@ PartDefinition *SlicePartDefinition::tryToSimplify() const return ret; } -void SlicePartDefinition::serialize(std::vector& tinyInt, std::vector< MCAuto >& bigArraysI) const +void SlicePartDefinition::serialize(std::vector& tinyInt, std::vector< MCAuto >& /*bigArraysI*/) const { tinyInt.push_back(_start); tinyInt.push_back(_stop); @@ -362,7 +369,7 @@ std::string SlicePartDefinition::getRepr() const mcIdType SlicePartDefinition::getEffectiveStop() const { - mcIdType nbElems(DataArray::GetNumberOfItemGivenBES(_start,_stop,_step,"SlicePartDefinition::getEffectiveStop")); + mcIdType const nbElems(DataArray::GetNumberOfItemGivenBES(_start,_stop,_step,"SlicePartDefinition::getEffectiveStop")); return _start+nbElems*_step; } @@ -418,5 +425,4 @@ PartDefinition *SlicePartDefinition::add2(const SlicePartDefinition *other) cons } SlicePartDefinition::~SlicePartDefinition() -{ -} += default; diff --git a/src/MEDCoupling/MEDCouplingPartDefinition.hxx b/src/MEDCoupling/MEDCouplingPartDefinition.hxx index 4c6b56f46..d3fcc7df1 100644 --- a/src/MEDCoupling/MEDCouplingPartDefinition.hxx +++ b/src/MEDCoupling/MEDCouplingPartDefinition.hxx @@ -20,9 +20,15 @@ #pragma once +#include "MCType.hxx" #include "MEDCoupling.hxx" #include "MEDCouplingMemArray.hxx" #include "MCAuto.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include "MEDCouplingTimeLabel.hxx" +#include +#include +#include namespace MEDCoupling { @@ -43,7 +49,7 @@ namespace MEDCoupling MEDCOUPLING_EXPORT virtual PartDefinition *tryToSimplify() const = 0; MEDCOUPLING_EXPORT virtual void serialize(std::vector& tinyInt, std::vector< MCAuto >& bigArraysI) const = 0; protected: - virtual ~PartDefinition(); + ~PartDefinition() override; }; class SlicePartDefinition; @@ -53,26 +59,26 @@ namespace MEDCoupling public: MEDCOUPLING_EXPORT static DataArrayPartDefinition *New(DataArrayIdType *listOfIds); MEDCOUPLING_EXPORT std::string getClassName() const override { return std::string("DataArrayPartDefinition"); } - MEDCOUPLING_EXPORT bool isEqual(const PartDefinition *other, std::string& what) const; - MEDCOUPLING_EXPORT DataArrayPartDefinition *deepCopy() const; - MEDCOUPLING_EXPORT DataArrayIdType *toDAI() const; - MEDCOUPLING_EXPORT mcIdType getNumberOfElems() const; - MEDCOUPLING_EXPORT PartDefinition *operator+(const PartDefinition& other) const; - MEDCOUPLING_EXPORT std::string getRepr() const; - MEDCOUPLING_EXPORT PartDefinition *composeWith(const PartDefinition *other) const; - MEDCOUPLING_EXPORT void checkConsistencyLight() const; - MEDCOUPLING_EXPORT PartDefinition *tryToSimplify() const; - MEDCOUPLING_EXPORT void serialize(std::vector& tinyInt, std::vector< MCAuto >& bigArraysI) const; + MEDCOUPLING_EXPORT bool isEqual(const PartDefinition *other, std::string& what) const override; + MEDCOUPLING_EXPORT DataArrayPartDefinition *deepCopy() const override; + MEDCOUPLING_EXPORT DataArrayIdType *toDAI() const override; + MEDCOUPLING_EXPORT mcIdType getNumberOfElems() const override; + MEDCOUPLING_EXPORT PartDefinition *operator+(const PartDefinition& other) const override; + MEDCOUPLING_EXPORT std::string getRepr() const override; + MEDCOUPLING_EXPORT PartDefinition *composeWith(const PartDefinition *other) const override; + MEDCOUPLING_EXPORT void checkConsistencyLight() const override; + MEDCOUPLING_EXPORT PartDefinition *tryToSimplify() const override; + MEDCOUPLING_EXPORT void serialize(std::vector& tinyInt, std::vector< MCAuto >& bigArraysI) const override; private: DataArrayPartDefinition(DataArrayIdType *listOfIds); void checkInternalArrayOK() const; static void CheckInternalArrayOK(const DataArrayIdType *listOfIds); - MEDCOUPLING_EXPORT void updateTime() const; - MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; - MEDCOUPLING_EXPORT std::vector getDirectChildrenWithNull() const; + MEDCOUPLING_EXPORT void updateTime() const override; + MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const override; + MEDCOUPLING_EXPORT std::vector getDirectChildrenWithNull() const override; DataArrayPartDefinition *add1(const DataArrayPartDefinition *other) const; DataArrayPartDefinition *add2(const SlicePartDefinition *other) const; - virtual ~DataArrayPartDefinition(); + ~DataArrayPartDefinition() override; private: MCAuto _arr; }; @@ -82,27 +88,27 @@ namespace MEDCoupling public: MEDCOUPLING_EXPORT static SlicePartDefinition *New(mcIdType start, mcIdType stop, mcIdType step); MEDCOUPLING_EXPORT std::string getClassName() const override { return std::string("SlicePartDefinition"); } - MEDCOUPLING_EXPORT bool isEqual(const PartDefinition *other, std::string& what) const; - MEDCOUPLING_EXPORT SlicePartDefinition *deepCopy() const; - MEDCOUPLING_EXPORT DataArrayIdType *toDAI() const; - MEDCOUPLING_EXPORT mcIdType getNumberOfElems() const; - MEDCOUPLING_EXPORT PartDefinition *operator+(const PartDefinition& other) const; - MEDCOUPLING_EXPORT std::string getRepr() const; - MEDCOUPLING_EXPORT PartDefinition *composeWith(const PartDefinition *other) const; - MEDCOUPLING_EXPORT void checkConsistencyLight() const; - MEDCOUPLING_EXPORT PartDefinition *tryToSimplify() const; - MEDCOUPLING_EXPORT void serialize(std::vector& tinyInt, std::vector< MCAuto >& bigArraysI) const; + MEDCOUPLING_EXPORT bool isEqual(const PartDefinition *other, std::string& what) const override; + MEDCOUPLING_EXPORT SlicePartDefinition *deepCopy() const override; + MEDCOUPLING_EXPORT DataArrayIdType *toDAI() const override; + MEDCOUPLING_EXPORT mcIdType getNumberOfElems() const override; + MEDCOUPLING_EXPORT PartDefinition *operator+(const PartDefinition& other) const override; + MEDCOUPLING_EXPORT std::string getRepr() const override; + MEDCOUPLING_EXPORT PartDefinition *composeWith(const PartDefinition *other) const override; + MEDCOUPLING_EXPORT void checkConsistencyLight() const override; + MEDCOUPLING_EXPORT PartDefinition *tryToSimplify() const override; + MEDCOUPLING_EXPORT void serialize(std::vector& tinyInt, std::vector< MCAuto >& bigArraysI) const override; //specific method MEDCOUPLING_EXPORT mcIdType getEffectiveStop() const; MEDCOUPLING_EXPORT void getSlice(mcIdType& start, mcIdType& stop, mcIdType& step) const; private: SlicePartDefinition(mcIdType start, mcIdType stop, mcIdType step); - MEDCOUPLING_EXPORT void updateTime() const; - MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; - MEDCOUPLING_EXPORT std::vector getDirectChildrenWithNull() const; + MEDCOUPLING_EXPORT void updateTime() const override; + MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const override; + MEDCOUPLING_EXPORT std::vector getDirectChildrenWithNull() const override; DataArrayPartDefinition *add1(const DataArrayPartDefinition *other) const; PartDefinition *add2(const SlicePartDefinition *other) const; - virtual ~SlicePartDefinition(); + ~SlicePartDefinition() override; private: mcIdType _start; mcIdType _stop; diff --git a/src/MEDCoupling/MEDCouplingPointSet.cxx b/src/MEDCoupling/MEDCouplingPointSet.cxx old mode 100755 new mode 100644 index 2b1eac589..745be33d4 --- a/src/MEDCoupling/MEDCouplingPointSet.cxx +++ b/src/MEDCoupling/MEDCouplingPointSet.cxx @@ -19,28 +19,39 @@ // Author : Anthony Geay (CEA/DEN) #include "MEDCouplingPointSet.hxx" +#include "InterpKernelGeo2DPrecision.hxx" #include "MCAuto.hxx" +#include "MCIdType.hxx" +#include "MCType.hxx" #include "MEDCoupling1GTUMesh.hxx" +#include "MEDCouplingMesh.hxx" +#include "MEDCouplingRefCountObject.hxx" #include "MEDCouplingUMesh.hxx" #include "MEDCouplingMemArray.hxx" +#include "NormalizedUnstructuredMesh.hxx" #include "PlanarIntersector.txx" #include "InterpKernelGeo2DQuadraticPolygon.hxx" #include "InterpKernelGeo2DNode.hxx" #include "DirectedBoundingBox.hxx" #include "InterpKernelAutoPtr.hxx" +#include #include +#include +#include +#include #include -#include #include +#include +#include using namespace MEDCoupling; -MEDCouplingPointSet::MEDCouplingPointSet():_coords(0) +MEDCouplingPointSet::MEDCouplingPointSet():_coords(nullptr) { } -MEDCouplingPointSet::MEDCouplingPointSet(const MEDCouplingPointSet& other, bool deepCpy):MEDCouplingMesh(other),_coords(0) +MEDCouplingPointSet::MEDCouplingPointSet(const MEDCouplingPointSet& other, bool deepCpy):MEDCouplingMesh(other),_coords(nullptr) { if(other._coords) _coords=other._coords->performCopyOrIncrRef(deepCpy); @@ -125,7 +136,7 @@ DataArrayDouble *MEDCouplingPointSet::getCoordinatesAndOwner() const void MEDCouplingPointSet::copyTinyStringsFrom(const MEDCouplingMesh *other) { MEDCouplingMesh::copyTinyStringsFrom(other); - const MEDCouplingPointSet *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("MEDCouplingPointSet::copyTinyStringsFrom : meshes have not same type !"); if(_coords && otherC->_coords) @@ -136,7 +147,7 @@ bool MEDCouplingPointSet::isEqualIfNotWhy(const MEDCouplingMesh *other, double p { if(!other) throw INTERP_KERNEL::Exception("MEDCouplingPointSet::isEqualIfNotWhy : null mesh instance in input !"); - const MEDCouplingPointSet *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) { reason="mesh given in input is not castable in MEDCouplingPointSet !"; @@ -158,7 +169,7 @@ bool MEDCouplingPointSet::isEqualIfNotWhy(const MEDCouplingMesh *other, double p */ bool MEDCouplingPointSet::isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const { - const MEDCouplingPointSet *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) return false; if(!areCoordsEqualWithoutConsideringStr(*otherC,prec)) @@ -168,16 +179,16 @@ bool MEDCouplingPointSet::isEqualWithoutConsideringStr(const MEDCouplingMesh *ot bool MEDCouplingPointSet::areCoordsEqualIfNotWhy(const MEDCouplingPointSet& other, double prec, std::string& reason) const { - if(_coords==0 && other._coords==0) + if(_coords==nullptr && other._coords==nullptr) return true; - if(_coords==0 || other._coords==0) + if(_coords==nullptr || other._coords==nullptr) { reason="Only one PointSet between the two this and other has coordinate defined !"; return false; } if(_coords==other._coords) return true; - bool ret=_coords->isEqualIfNotWhy(*other._coords,prec,reason); + bool const ret=_coords->isEqualIfNotWhy(*other._coords,prec,reason); if(!ret) reason.insert(0,"Coordinates DataArray do not match : "); return ret; @@ -205,9 +216,9 @@ bool MEDCouplingPointSet::areCoordsEqual(const MEDCouplingPointSet& other, doubl */ bool MEDCouplingPointSet::areCoordsEqualWithoutConsideringStr(const MEDCouplingPointSet& other, double prec) const { - if(_coords==0 && other._coords==0) + if(_coords==nullptr && other._coords==nullptr) return true; - if(_coords==0 || other._coords==0) + if(_coords==nullptr || other._coords==nullptr) return false; if(_coords==other._coords) return true; @@ -232,11 +243,11 @@ void MEDCouplingPointSet::getCoordinatesOfNode(mcIdType nodeId, std::vector=0 && nodeIdgetConstPointer(); - std::size_t spaceDim=getSpaceDimension(); + std::size_t const spaceDim=getSpaceDimension(); coo.insert(coo.end(),cooPtr+spaceDim*nodeId,cooPtr+spaceDim*(nodeId+1)); } else @@ -265,7 +276,7 @@ DataArrayIdType *MEDCouplingPointSet::buildPermArrayForMergeNode(double precisio { DataArrayIdType *comm,*commI; findCommonNodes(precision,limitNodeId,comm,commI); - mcIdType oldNbOfNodes=getNumberOfNodes(); + mcIdType const oldNbOfNodes=getNumberOfNodes(); MCAuto ret=buildNewNumberingFromCommonNodesFormat(comm,commI,newNbOfNodes); areNodesMerged=(oldNbOfNodes!=newNbOfNodes); comm->decrRef(); @@ -325,9 +336,9 @@ void MEDCouplingPointSet::findCommonNodes(double prec, mcIdType limitNodeId, Dat */ DataArrayIdType *MEDCouplingPointSet::getNodeIdsNearPoint(const double *pos, double eps) const { - DataArrayIdType *c=0,*cI=0; + DataArrayIdType *c=nullptr,*cI=nullptr; getNodeIdsNearPoints(pos,1,eps,c,cI); - MCAuto cITmp(cI); + MCAuto const cITmp(cI); return c; } @@ -362,7 +373,7 @@ void MEDCouplingPointSet::getNodeIdsNearPoints(const double *pos, mcIdType nbOfP { if(!_coords) throw INTERP_KERNEL::Exception("MEDCouplingPointSet::getNodeIdsNearPoint : no coordiantes set !"); - std::size_t spaceDim=getSpaceDimension(); + std::size_t const spaceDim=getSpaceDimension(); MCAuto points=DataArrayDouble::New(); points->useArray(pos,false,DeallocType::CPP_DEALLOC,nbOfPoints,spaceDim); _coords->computeTupleIdsNearTuples(points,eps,c,cI); @@ -431,11 +442,11 @@ void MEDCouplingPointSet::renumberNodesCenter(const mcIdType *newNodeNumbers, mc { DataArrayDouble *newCoords=DataArrayDouble::New(); std::vector div(newNbOfNodes); - std::size_t spaceDim=getSpaceDimension(); + std::size_t const spaceDim=getSpaceDimension(); newCoords->alloc(newNbOfNodes,spaceDim); newCoords->copyStringInfoFrom(*_coords); newCoords->fillWithZero(); - mcIdType oldNbOfNodes=getNumberOfNodes(); + mcIdType const oldNbOfNodes=getNumberOfNodes(); double *ptToFill=newCoords->getPointer(); const double *oldCoordsPtr=_coords->getConstPointer(); for(mcIdType i=0;igetConstPointer(); - std::size_t nbOfValues=_coords->getNbOfElems(); + std::size_t const nbOfValues=_coords->getNbOfElems(); return std::abs(*std::max_element(coords,coords+nbOfValues,MEDCouplingCompAbs())); } @@ -544,7 +555,7 @@ void MEDCouplingPointSet::recenterForMaxPrecision(double eps) */ void MEDCouplingPointSet::rotate(const double *center, const double *vector, double angle) { - std::size_t spaceDim=getSpaceDimension(); + std::size_t const spaceDim=getSpaceDimension(); if(spaceDim==3) rotate3D(center,vector,angle); else if(spaceDim==2) @@ -574,8 +585,8 @@ void MEDCouplingPointSet::translate(const double *vector) if(!_coords) throw INTERP_KERNEL::Exception("MEDCouplingPointSet::translate : no coordinates set !"); double *coords=_coords->getPointer(); - mcIdType nbNodes=getNumberOfNodes(); - std::size_t dim=getSpaceDimension(); + mcIdType const nbNodes=getNumberOfNodes(); + std::size_t const dim=getSpaceDimension(); for(mcIdType i=0; igetPointer(); - mcIdType nbNodes=getNumberOfNodes(); - std::size_t dim=getSpaceDimension(); + mcIdType const nbNodes=getNumberOfNodes(); + std::size_t const dim=getSpaceDimension(); for(mcIdType i=0;i()); @@ -629,11 +640,11 @@ void MEDCouplingPointSet::scale(const double *point, double factor) */ void MEDCouplingPointSet::changeSpaceDimension(int newSpaceDim, double dftValue) { - if(getCoords()==0) + if(getCoords()==nullptr) throw INTERP_KERNEL::Exception("changeSpaceDimension must be called on an MEDCouplingPointSet instance with coordinates set !"); if(newSpaceDim<1) throw INTERP_KERNEL::Exception("changeSpaceDimension must be called a newSpaceDim >=1 !"); - int oldSpaceDim=getSpaceDimension(); + int const oldSpaceDim=getSpaceDimension(); if(newSpaceDim==oldSpaceDim) return ; DataArrayDouble *newCoords=getCoords()->changeNbOfComponents(newSpaceDim,dftValue); @@ -704,9 +715,9 @@ void MEDCouplingPointSet::findNodesOnPlane(const double *pt, const double *vec, throw INTERP_KERNEL::Exception("MEDCouplingPointSet::findNodesOnPlane : NULL point pointer specified !"); if(!vec) throw INTERP_KERNEL::Exception("MEDCouplingPointSet::findNodesOnPlane : NULL vector pointer specified !"); - mcIdType nbOfNodes=getNumberOfNodes(); + mcIdType const nbOfNodes=getNumberOfNodes(); double a=vec[0],b=vec[1],c=vec[2],d=-pt[0]*vec[0]-pt[1]*vec[1]-pt[2]*vec[2]; - double deno=sqrt(a*a+b*b+c*c); + double const deno=sqrt(a*a+b*b+c*c); if(deno::min()) throw INTERP_KERNEL::Exception("MEDCouplingPointSet::findNodesOnPlane : vector pointer specified has norm equal to 0. !"); const double *work=_coords->getConstPointer(); @@ -737,18 +748,18 @@ void MEDCouplingPointSet::findNodesOnPlane(const double *pt, const double *vec, */ void MEDCouplingPointSet::findNodesOnLine(const double *pt, const double *vec, double eps, std::vector& nodes) const { - std::size_t spaceDim=getSpaceDimension(); + std::size_t const spaceDim=getSpaceDimension(); if(spaceDim!=2 && spaceDim!=3) throw INTERP_KERNEL::Exception("MEDCouplingPointSet::findNodesOnLine : Invalid spacedim to be applied on this ! Must be equal to 2 or 3 !"); if(!pt) throw INTERP_KERNEL::Exception("MEDCouplingPointSet::findNodesOnLine : NULL point pointer specified !"); if(!vec) throw INTERP_KERNEL::Exception("MEDCouplingPointSet::findNodesOnLine : NULL vector pointer specified !"); - mcIdType nbOfNodes=getNumberOfNodes(); + mcIdType const nbOfNodes=getNumberOfNodes(); double den=0.; for(std::size_t i=0;i vecn=new double[spaceDim]; @@ -768,9 +779,9 @@ void MEDCouplingPointSet::findNodesOnLine(const double *pt, const double *vec, d { for(mcIdType i=0;igetSpaceDimension(); + int const spaceDim=m1->getSpaceDimension(); if(spaceDim!=m2->getSpaceDimension()) throw INTERP_KERNEL::Exception("Mismatch in SpaceDim during call of MergeNodesArray !"); return DataArrayDouble::Aggregate(m1->getCoords(),m2->getCoords()); @@ -805,9 +816,9 @@ DataArrayDouble *MEDCouplingPointSet::MergeNodesArray(const std::vector::const_iterator it=ms.begin(); + auto it=ms.begin(); std::vector coo(ms.size()); - int spaceDim=(*it)->getSpaceDimension(); + int const spaceDim=(*it)->getSpaceDimension(); coo[0]=(*it++)->getCoords(); if(!coo[0]->isAllocated()) throw INTERP_KERNEL::Exception("MEDCouplingPointSet::MergeNodesArray : first element in coordinates is not allocated !"); @@ -857,7 +868,7 @@ MEDCouplingPointSet *MEDCouplingPointSet::BuildInstanceFromMeshType(MEDCouplingM void MEDCouplingPointSet::getTinySerializationInformation(std::vector& tinyInfoD, std::vector& tinyInfo, std::vector& littleStrings) const { int it,order; - double time=getTime(it,order); + double const time=getTime(it,order); if(_coords) { int spaceDim=getSpaceDimension(); @@ -895,7 +906,7 @@ void MEDCouplingPointSet::getTinySerializationInformation(std::vector& t /*! * Third and final step of serialization process. */ -void MEDCouplingPointSet::serialize(DataArrayIdType *&a1, DataArrayDouble *&a2) const +void MEDCouplingPointSet::serialize(DataArrayIdType *& /*a1*/, DataArrayDouble *&a2) const { if(_coords) { @@ -903,14 +914,14 @@ void MEDCouplingPointSet::serialize(DataArrayIdType *&a1, DataArrayDouble *&a2) a2->incrRef(); } else - a2=0; + a2=nullptr; } /*! * Second step of serialization process. * @param tinyInfo must be equal to the result given by getTinySerializationInformation method. */ -void MEDCouplingPointSet::resizeForUnserialization(const std::vector& tinyInfo, DataArrayIdType *a1, DataArrayDouble *a2, std::vector& littleStrings) const +void MEDCouplingPointSet::resizeForUnserialization(const std::vector& tinyInfo, DataArrayIdType * /*a1*/, DataArrayDouble *a2, std::vector& littleStrings) const { if(tinyInfo[2]>=0 && tinyInfo[1]>=1) { @@ -927,7 +938,7 @@ void MEDCouplingPointSet::resizeForUnserialization(const std::vector& * Second and final unserialization process. * @param tinyInfo must be equal to the result given by getTinySerializationInformation method. */ -void MEDCouplingPointSet::unserialization(const std::vector& tinyInfoD, const std::vector& tinyInfo, const DataArrayIdType *a1, DataArrayDouble *a2, const std::vector& littleStrings) +void MEDCouplingPointSet::unserialization(const std::vector& tinyInfoD, const std::vector& tinyInfo, const DataArrayIdType * /*a1*/, DataArrayDouble *a2, const std::vector& littleStrings) { if(tinyInfo[2]>=0 && tinyInfo[1]>=1) { @@ -960,12 +971,12 @@ void MEDCouplingPointSet::checkConsistencyLight() const */ bool MEDCouplingPointSet::intersectsBoundingBox(const double* bb1, const double* bb2, int dim, double eps) { - double* bbtemp = new double[2*dim]; + auto* bbtemp = new double[2*dim]; double deltamax=0.0; for (int i=0; i< dim; i++) { - double delta = bb1[2*i+1]-bb1[2*i]; + double const delta = bb1[2*i+1]-bb1[2*i]; if ( delta > deltamax ) { deltamax = delta ; @@ -979,7 +990,7 @@ bool MEDCouplingPointSet::intersectsBoundingBox(const double* bb1, const double* for (int idim=0; idim < dim; idim++) { - bool intersects = (bbtemp[idim*2] deltamax ) { deltamax = delta ; @@ -1013,7 +1024,7 @@ bool MEDCouplingPointSet::intersectsBoundingBox(const INTERP_KERNEL::DirectedBou bbtemp[i*2+1]=bb2[i*2+1]+deltamax*eps; } - bool intersects(!bb1.isDisjointWith(bbtemp)); + bool const intersects(!bb1.isDisjointWith(bbtemp)); delete [] bbtemp; return intersects; } @@ -1024,7 +1035,7 @@ bool MEDCouplingPointSet::intersectsBoundingBox(const INTERP_KERNEL::DirectedBou void MEDCouplingPointSet::rotate3D(const double *center, const double *vect, double angle) { double *coords(_coords->getPointer()); - mcIdType nbNodes(getNumberOfNodes()); + mcIdType const nbNodes(getNumberOfNodes()); DataArrayDouble::Rotate3DAlg(center,vect,angle,nbNodes,coords,coords); } @@ -1117,7 +1128,7 @@ MEDCouplingMesh *MEDCouplingPointSet::buildPartRange(mcIdType beginCellIds, mcId * * \sa MEDCouplingUMesh::buildPartOfMySelfSlice */ -MEDCouplingMesh *MEDCouplingPointSet::buildPartRangeAndReduceNodes(mcIdType beginCellIds, mcIdType endCellIds, mcIdType stepCellIds, mcIdType& beginOut, mcIdType& endOut, mcIdType& stepOut, DataArrayIdType*& arr) const +MEDCouplingMesh *MEDCouplingPointSet::buildPartRangeAndReduceNodes(mcIdType beginCellIds, mcIdType endCellIds, mcIdType stepCellIds, mcIdType& /*beginOut*/, mcIdType& /*endOut*/, mcIdType& /*stepOut*/, DataArrayIdType*& arr) const { MCAuto ret(buildPartOfMySelfSlice(beginCellIds,endCellIds,stepCellIds,true)); arr=ret->zipCoordsTraducer(); @@ -1130,7 +1141,7 @@ MEDCouplingMesh *MEDCouplingPointSet::buildPartRangeAndReduceNodes(mcIdType begi void MEDCouplingPointSet::rotate2D(const double *center, double angle) { double *coords(_coords->getPointer()); - mcIdType nbNodes(getNumberOfNodes()); + mcIdType const nbNodes(getNumberOfNodes()); DataArrayDouble::Rotate2DAlg(center,angle,nbNodes,coords,coords); } @@ -1141,7 +1152,7 @@ class DummyClsMCPS public: static const int MY_SPACEDIM=3; static const int MY_MESHDIM=2; - typedef mcIdType MyConnType; + using MyConnType = mcIdType; static const INTERP_KERNEL::NumberingPolicy My_numPol=INTERP_KERNEL::ALL_C_MODE; }; @@ -1156,7 +1167,7 @@ public: void MEDCouplingPointSet::project2DCellOnXY(const mcIdType *startConn, const mcIdType *endConn, std::vector& res) const { const double *coords(_coords->getConstPointer()); - std::size_t spaceDim(getSpaceDimension()); + std::size_t const spaceDim(getSpaceDimension()); for(const mcIdType *it=startConn;it!=endConn;it++) res.insert(res.end(),coords+spaceDim*(*it),coords+spaceDim*(*it+1)); if(spaceDim==2) @@ -1164,7 +1175,7 @@ void MEDCouplingPointSet::project2DCellOnXY(const mcIdType *startConn, const mcI if(spaceDim==3) { std::vector cpy(res); - mcIdType nbNodes=ToIdType(std::distance(startConn,endConn)); + mcIdType const nbNodes=ToIdType(std::distance(startConn,endConn)); INTERP_KERNEL::PlanarIntersector::Projection(&res[0],&cpy[0],nbNodes,nbNodes,1.e-12,0./*max distance*/,-1./*min dot*/,0.,true); res.resize(2*nbNodes); for(mcIdType i=0;i& res, bool isQuad, double eps) { - INTERP_KERNEL::QuadraticPlanarPrecision prec(eps); + INTERP_KERNEL::QuadraticPlanarPrecision const prec(eps); - std::size_t nbOfNodes(res.size()/2); + std::size_t const nbOfNodes(res.size()/2); std::vector nodes(nbOfNodes); for(std::size_t i=0;iisButterflyAbs()); + bool const ret(pol->isButterflyAbs()); delete pol; return ret; } @@ -1212,7 +1223,7 @@ bool MEDCouplingPointSet::areCellsFrom2MeshEqual(const MEDCouplingPointSet *othe std::vector c1,c2; getNodeIdsOfCell(cellId,c1); other->getNodeIdsOfCell(cellId,c2); - std::size_t sz(c1.size()); + std::size_t const sz(c1.size()); if(sz!=c2.size()) return false; for(std::size_t i=0;i newCoords=MergeNodesArray(&other,this); _coords->incrRef(); MCAuto oldCoords=_coords; @@ -1263,7 +1274,7 @@ void MEDCouplingPointSet::tryToShareSameCoordsPermute(const MEDCouplingPointSet& setCoords(oldCoords); throw INTERP_KERNEL::Exception("MEDCouplingPointSet::tryToShareSameCoordsPermute fails : no nodes are mergeable with specified given epsilon !"); } - mcIdType maxId=*std::max_element(da->getConstPointer(),da->getConstPointer()+otherNbOfNodes); + mcIdType const maxId=*std::max_element(da->getConstPointer(),da->getConstPointer()+otherNbOfNodes); const mcIdType *pt=std::find_if(da->getConstPointer()+otherNbOfNodes,da->getConstPointer()+da->getNbOfElems(),std::bind(std::greater(),std::placeholders::_1,maxId)); if(pt!=da->getConstPointer()+da->getNbOfElems()) { @@ -1316,9 +1327,9 @@ MEDCouplingPointSet *MEDCouplingPointSet::buildPartOfMySelfSlice(mcIdType start, */ MEDCouplingPointSet *MEDCouplingPointSet::buildPartOfMySelfNode(const mcIdType *begin, const mcIdType *end, bool fullyIn) const { - DataArrayIdType *cellIdsKept=0; + DataArrayIdType *cellIdsKept=nullptr; fillCellIdsToKeepFromNodeIds(begin,end,fullyIn,cellIdsKept); - MCAuto cellIdsKept2(cellIdsKept); + MCAuto const cellIdsKept2(cellIdsKept); return buildPartOfMySelf(cellIdsKept->begin(),cellIdsKept->end(),true); } @@ -1374,7 +1385,7 @@ DataArrayIdType *MEDCouplingPointSet::zipConnectivityTraducer(int compType, mcId bool MEDCouplingPointSet::areAllNodesFetched() const { checkFullyDefined(); - mcIdType nbNodes(getNumberOfNodes()); + mcIdType const nbNodes(getNumberOfNodes()); std::vector fetchedNodes(nbNodes,false); computeNodeIdsAlg(fetchedNodes); return std::find(fetchedNodes.begin(),fetchedNodes.end(),false)==fetchedNodes.end(); @@ -1415,13 +1426,13 @@ void MEDCouplingPointSet::checkDeepEquivalWith(const MEDCouplingMesh *other, int { if(!other) throw INTERP_KERNEL::Exception("MEDCouplingPointSet::checkDeepEquivalWith : input is null !"); - const MEDCouplingPointSet *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("MEDCouplingPointSet::checkDeepEquivalWith : other is not a PointSet mesh !"); MCAuto m=dynamic_cast(mergeMyselfWith(otherC)); bool areNodesMerged; mcIdType newNbOfNodes; - mcIdType oldNbOfNodes=getNumberOfNodes(); + mcIdType const oldNbOfNodes=getNumberOfNodes(); MCAuto da=m->buildPermArrayForMergeNode(prec,oldNbOfNodes,areNodesMerged,newNbOfNodes); //mergeNodes if(!areNodesMerged && oldNbOfNodes != 0) @@ -1435,10 +1446,10 @@ void MEDCouplingPointSet::checkDeepEquivalWith(const MEDCouplingMesh *other, int da=m->mergeNodes(prec,areNodesMerged,newNbOfNodes); // da=m->zipConnectivityTraducer(cellCompPol); - mcIdType nbCells=ToIdType(getNumberOfCells()); + mcIdType const nbCells=ToIdType(getNumberOfCells()); if (nbCells != ToIdType(other->getNumberOfCells())) throw INTERP_KERNEL::Exception("checkDeepEquivalWith : some cells in other are not in this !"); - mcIdType dan(da->getNumberOfTuples()); + mcIdType const dan(da->getNumberOfTuples()); if (dan) { MCAuto da1(DataArrayIdType::New()),da2(DataArrayIdType::New()); @@ -1450,8 +1461,8 @@ void MEDCouplingPointSet::checkDeepEquivalWith(const MEDCouplingMesh *other, int throw INTERP_KERNEL::Exception("checkDeepEquivalWith : some cells in other are not in this !"); } MCAuto cellCor2=da->selectByTupleIdSafeSlice(nbCells,ToIdType(da->getNbOfElems()),1); - nodeCor=nodeCor2->isIota(nodeCor2->getNumberOfTuples())?0:nodeCor2.retn(); - cellCor=cellCor2->isIota(cellCor2->getNumberOfTuples())?0:cellCor2.retn(); + nodeCor=nodeCor2->isIota(nodeCor2->getNumberOfTuples())?nullptr:nodeCor2.retn(); + cellCor=cellCor2->isIota(cellCor2->getNumberOfTuples())?nullptr:cellCor2.retn(); } /*! @@ -1476,36 +1487,36 @@ void MEDCouplingPointSet::checkDeepEquivalWith(const MEDCouplingMesh *other, int * \ref py_mcumesh_checkDeepEquivalWith "Here is a Python example". * \endif */ -void MEDCouplingPointSet::checkDeepEquivalOnSameNodesWith(const MEDCouplingMesh *other, int cellCompPol, double prec, +void MEDCouplingPointSet::checkDeepEquivalOnSameNodesWith(const MEDCouplingMesh *other, int cellCompPol, double /*prec*/, DataArrayIdType *&cellCor) const { if(!other) throw INTERP_KERNEL::Exception("MEDCouplingPointSet::checkDeepEquivalOnSameNodesWith : input is null !"); - const MEDCouplingPointSet *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("MEDCouplingPointSet::checkDeepEquivalOnSameNodesWith : other is not a PointSet mesh !"); if(_coords!=otherC->_coords) throw INTERP_KERNEL::Exception("checkDeepEquivalOnSameNodesWith : meshes do not share the same coordinates ! Use tryToShareSameCoordinates or call checkDeepEquivalWith !"); MCAuto m=mergeMyselfWithOnSameCoords(otherC); MCAuto da=m->zipConnectivityTraducer(cellCompPol); - mcIdType maxId=*std::max_element(da->getConstPointer(),da->getConstPointer()+getNumberOfCells()); + mcIdType const maxId=*std::max_element(da->getConstPointer(),da->getConstPointer()+getNumberOfCells()); const mcIdType *pt=std::find_if(da->getConstPointer()+getNumberOfCells(),da->getConstPointer()+da->getNbOfElems(),std::bind(std::greater(),std::placeholders::_1,maxId)); if(pt!=da->getConstPointer()+da->getNbOfElems()) { throw INTERP_KERNEL::Exception("checkDeepEquivalOnSameNodesWith : some cells in other are not in this !"); } MCAuto cellCor2=da->selectByTupleIdSafeSlice(ToIdType(getNumberOfCells()),ToIdType(da->getNbOfElems()),1); - cellCor=cellCor2->isIota(cellCor2->getNumberOfTuples())?0:cellCor2.retn(); + cellCor=cellCor2->isIota(cellCor2->getNumberOfTuples())?nullptr:cellCor2.retn(); } void MEDCouplingPointSet::checkFastEquivalWith(const MEDCouplingMesh *other, double prec) const { MEDCouplingMesh::checkFastEquivalWith(other,prec); //other not null checked by the line before - const MEDCouplingPointSet *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("MEDCouplingPointSet::checkFastEquivalWith : fails because other is not a pointset mesh !"); - mcIdType nbOfCells=ToIdType(getNumberOfCells()); + mcIdType const nbOfCells=ToIdType(getNumberOfCells()); if(nbOfCells<1) return ; bool status=true; @@ -1539,7 +1550,7 @@ void MEDCouplingPointSet::checkFastEquivalWith(const MEDCouplingMesh *other, dou */ DataArrayIdType *MEDCouplingPointSet::getCellIdsLyingOnNodes(const mcIdType *begin, const mcIdType *end, bool fullyIn) const { - DataArrayIdType *cellIdsKept=0; + DataArrayIdType *cellIdsKept=nullptr; fillCellIdsToKeepFromNodeIds(begin,end,fullyIn,cellIdsKept); cellIdsKept->setName(getName()); return cellIdsKept; diff --git a/src/MEDCoupling/MEDCouplingPointSet.hxx b/src/MEDCoupling/MEDCouplingPointSet.hxx index 6db127e8a..0b46cb922 100644 --- a/src/MEDCoupling/MEDCouplingPointSet.hxx +++ b/src/MEDCoupling/MEDCouplingPointSet.hxx @@ -21,11 +21,16 @@ #ifndef __PARAMEDMEM_MEDCOUPLINGPOINTSET_HXX__ #define __PARAMEDMEM_MEDCOUPLINGPOINTSET_HXX__ +#include "MCType.hxx" #include "MEDCoupling.hxx" #include "MEDCouplingMesh.hxx" #include "InterpKernelHashMap.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include +#include +#include #include namespace INTERP_KERNEL @@ -51,26 +56,26 @@ namespace MEDCoupling protected: MEDCOUPLING_EXPORT MEDCouplingPointSet(); MEDCOUPLING_EXPORT MEDCouplingPointSet(const MEDCouplingPointSet& other, bool deepCpy); - MEDCOUPLING_EXPORT ~MEDCouplingPointSet(); + MEDCOUPLING_EXPORT ~MEDCouplingPointSet() override; public: - MEDCOUPLING_EXPORT void updateTime() const; - MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; - MEDCOUPLING_EXPORT std::vector getDirectChildrenWithNull() const; - MEDCOUPLING_EXPORT mcIdType getNumberOfNodes() const; - MEDCOUPLING_EXPORT int getSpaceDimension() const; + MEDCOUPLING_EXPORT void updateTime() const override; + MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const override; + MEDCOUPLING_EXPORT std::vector getDirectChildrenWithNull() const override; + MEDCOUPLING_EXPORT mcIdType getNumberOfNodes() const override; + MEDCOUPLING_EXPORT int getSpaceDimension() const override; MEDCOUPLING_EXPORT void setCoords(const DataArrayDouble *coords); MEDCOUPLING_EXPORT const DataArrayDouble *getCoords() const { return _coords; } MEDCOUPLING_EXPORT DataArrayDouble *getCoords() { return _coords; } - MEDCOUPLING_EXPORT DataArrayDouble *getCoordinatesAndOwner() const; - MEDCOUPLING_EXPORT const DataArrayDouble *getDirectAccessOfCoordsArrIfInStructure() const { return _coords; } - MEDCOUPLING_EXPORT void copyTinyStringsFrom(const MEDCouplingMesh *other); - MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const; - MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const; - MEDCOUPLING_EXPORT void checkFastEquivalWith(const MEDCouplingMesh *other, double prec) const; + MEDCOUPLING_EXPORT DataArrayDouble *getCoordinatesAndOwner() const override; + MEDCOUPLING_EXPORT const DataArrayDouble *getDirectAccessOfCoordsArrIfInStructure() const override { return _coords; } + MEDCOUPLING_EXPORT void copyTinyStringsFrom(const MEDCouplingMesh *other) override; + MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const override; + MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const override; + MEDCOUPLING_EXPORT void checkFastEquivalWith(const MEDCouplingMesh *other, double prec) const override; MEDCOUPLING_EXPORT void checkDeepEquivalWith(const MEDCouplingMesh *other, int cellCompPol, double prec, - DataArrayIdType *&cellCor, DataArrayIdType *&nodeCor) const; + DataArrayIdType *&cellCor, DataArrayIdType *&nodeCor) const override; MEDCOUPLING_EXPORT void checkDeepEquivalOnSameNodesWith(const MEDCouplingMesh *other, int cellCompPol, double prec, - DataArrayIdType *&cellCor) const; + DataArrayIdType *&cellCor) const override; MEDCOUPLING_EXPORT bool areCoordsEqualIfNotWhy(const MEDCouplingPointSet& other, double prec, std::string& reason) const; MEDCOUPLING_EXPORT bool areCoordsEqual(const MEDCouplingPointSet& other, double prec) const; MEDCOUPLING_EXPORT bool areCoordsEqualWithoutConsideringStr(const MEDCouplingPointSet& other, double prec) const; @@ -80,7 +85,7 @@ namespace MEDCoupling MEDCOUPLING_EXPORT virtual DataArrayIdType *mergeNodesCenter(double precision, bool& areNodesMerged, mcIdType& newNbOfNodes); MEDCOUPLING_EXPORT virtual MEDCouplingPointSet *mergeMyselfWithOnSameCoords(const MEDCouplingPointSet *other) const = 0; MEDCOUPLING_EXPORT virtual void computeNodeIdsAlg(std::vector& nodeIdsInUse) const = 0; - MEDCOUPLING_EXPORT void getCoordinatesOfNode(mcIdType nodeId, std::vector& coo) const; + MEDCOUPLING_EXPORT void getCoordinatesOfNode(mcIdType nodeId, std::vector& coo) const override; MEDCOUPLING_EXPORT DataArrayIdType *buildPermArrayForMergeNode(double precision, mcIdType limitNodeId, bool& areNodesMerged, mcIdType& newNbOfNodes) const; MEDCOUPLING_EXPORT DataArrayIdType *getNodeIdsNearPoint(const double *pos, double eps) const; MEDCOUPLING_EXPORT void getNodeIdsNearPoints(const double *pos, mcIdType nbOfPoints, double eps, DataArrayIdType *& c, DataArrayIdType *& cI) const; @@ -88,13 +93,13 @@ namespace MEDCoupling MEDCOUPLING_EXPORT virtual void findCommonCells(int compType, mcIdType startCellId, DataArrayIdType *& commonCellsArr, DataArrayIdType *& commonCellsIArr) const = 0; MEDCOUPLING_EXPORT DataArrayIdType *buildNewNumberingFromCommonNodesFormat(const DataArrayIdType *comm, const DataArrayIdType *commIndex, mcIdType& newNbOfNodes) const; - MEDCOUPLING_EXPORT void getBoundingBox(double *bbox) const; + MEDCOUPLING_EXPORT void getBoundingBox(double *bbox) const override; MEDCOUPLING_EXPORT void zipCoords(); MEDCOUPLING_EXPORT double getCaracteristicDimension() const; MEDCOUPLING_EXPORT void recenterForMaxPrecision(double eps); - MEDCOUPLING_EXPORT void rotate(const double *center, const double *vector, double angle); - MEDCOUPLING_EXPORT void translate(const double *vector); - MEDCOUPLING_EXPORT void scale(const double *point, double factor); + MEDCOUPLING_EXPORT void rotate(const double *center, const double *vector, double angle) override; + MEDCOUPLING_EXPORT void translate(const double *vector) override; + MEDCOUPLING_EXPORT void scale(const double *point, double factor) override; MEDCOUPLING_EXPORT void changeSpaceDimension(int newSpaceDim, double dftVal=0.); MEDCOUPLING_EXPORT void tryToShareSameCoords(const MEDCouplingPointSet& other, double epsilon); MEDCOUPLING_EXPORT void duplicateNodesInCoords(const mcIdType *nodeIdsToDuplicateBg, const mcIdType *nodeIdsToDuplicateEnd); @@ -105,11 +110,11 @@ namespace MEDCoupling MEDCOUPLING_EXPORT static DataArrayDouble *MergeNodesArray(const std::vector& ms); MEDCOUPLING_EXPORT static MEDCouplingPointSet *BuildInstanceFromMeshType(MEDCouplingMeshType type); MEDCOUPLING_EXPORT static DataArrayIdType *ComputeNbOfInteractionsWithSrcCells(const MEDCouplingPointSet *srcMesh, const MEDCouplingPointSet *trgMesh, double eps); - MEDCOUPLING_EXPORT MEDCouplingMesh *buildPart(const mcIdType *start, const mcIdType *end) const; - MEDCOUPLING_EXPORT MEDCouplingMesh *buildPartAndReduceNodes(const mcIdType *start, const mcIdType *end, DataArrayIdType*& arr) const; - MEDCOUPLING_EXPORT MEDCouplingMesh *buildPartRange(mcIdType beginCellIds, mcIdType endCellIds, mcIdType stepCellIds) const; - MEDCOUPLING_EXPORT MEDCouplingMesh *buildPartRangeAndReduceNodes(mcIdType beginCellIds, mcIdType endCellIds, mcIdType stepCellIds, mcIdType& beginOut, mcIdType& endOut, mcIdType& stepOut, DataArrayIdType*& arr) const; - MEDCOUPLING_EXPORT DataArrayIdType *getCellIdsFullyIncludedInNodeIds(const mcIdType *partBg, const mcIdType *partEnd) const; + MEDCOUPLING_EXPORT MEDCouplingMesh *buildPart(const mcIdType *start, const mcIdType *end) const override; + MEDCOUPLING_EXPORT MEDCouplingMesh *buildPartAndReduceNodes(const mcIdType *start, const mcIdType *end, DataArrayIdType*& arr) const override; + MEDCOUPLING_EXPORT MEDCouplingMesh *buildPartRange(mcIdType beginCellIds, mcIdType endCellIds, mcIdType stepCellIds) const override; + MEDCOUPLING_EXPORT MEDCouplingMesh *buildPartRangeAndReduceNodes(mcIdType beginCellIds, mcIdType endCellIds, mcIdType stepCellIds, mcIdType& beginOut, mcIdType& endOut, mcIdType& stepOut, DataArrayIdType*& arr) const override; + MEDCOUPLING_EXPORT DataArrayIdType *getCellIdsFullyIncludedInNodeIds(const mcIdType *partBg, const mcIdType *partEnd) const override; MEDCOUPLING_EXPORT DataArrayIdType *getCellIdsLyingOnNodes(const mcIdType *begin, const mcIdType *end, bool fullyIn) const; MEDCOUPLING_EXPORT virtual MEDCouplingPointSet *buildPartOfMySelf(const mcIdType *start, const mcIdType *end, bool keepCoords=true) const; MEDCOUPLING_EXPORT virtual MEDCouplingPointSet *buildPartOfMySelfSlice(mcIdType start, mcIdType end, mcIdType step, bool keepCoords=true) const; @@ -132,11 +137,11 @@ namespace MEDCoupling MEDCOUPLING_EXPORT virtual bool isEmptyMesh(const std::vector& tinyInfo) const = 0; MEDCOUPLING_EXPORT virtual void invertOrientationOfAllCells() = 0; MEDCOUPLING_EXPORT virtual void checkFullyDefined() const = 0; - MEDCOUPLING_EXPORT void getTinySerializationInformation(std::vector& tinyInfoD, std::vector& tinyInfo, std::vector& littleStrings) const; - MEDCOUPLING_EXPORT void resizeForUnserialization(const std::vector& tinyInfo, DataArrayIdType *a1, DataArrayDouble *a2, std::vector& littleStrings) const; - MEDCOUPLING_EXPORT void serialize(DataArrayIdType *&a1, DataArrayDouble *&a2) const; + MEDCOUPLING_EXPORT void getTinySerializationInformation(std::vector& tinyInfoD, std::vector& tinyInfo, std::vector& littleStrings) const override; + MEDCOUPLING_EXPORT void resizeForUnserialization(const std::vector& tinyInfo, DataArrayIdType *a1, DataArrayDouble *a2, std::vector& littleStrings) const override; + MEDCOUPLING_EXPORT void serialize(DataArrayIdType *&a1, DataArrayDouble *&a2) const override; MEDCOUPLING_EXPORT void unserialization(const std::vector& tinyInfoD, const std::vector& tinyInfo, const DataArrayIdType *a1, DataArrayDouble *a2, - const std::vector& littleStrings); + const std::vector& littleStrings) override; MEDCOUPLING_EXPORT virtual DataArrayDouble *getBoundingBoxForBBTree(double arcDetEps=1e-12) const = 0; MEDCOUPLING_EXPORT virtual DataArrayIdType *getCellsInBoundingBox(const double *bbox, double eps) const = 0; MEDCOUPLING_EXPORT virtual DataArrayIdType *getCellsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bbox, double eps) = 0; @@ -148,7 +153,7 @@ namespace MEDCoupling public: MEDCOUPLING_EXPORT bool areCellsFrom2MeshEqual(const MEDCouplingPointSet *other, mcIdType cellId, double prec) const; protected: - MEDCOUPLING_EXPORT void checkConsistencyLight() const; + MEDCOUPLING_EXPORT void checkConsistencyLight() const override; MEDCOUPLING_EXPORT static bool intersectsBoundingBox(const double* bb1, const double* bb2, int dim, double eps); MEDCOUPLING_EXPORT static bool intersectsBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bb1, const double* bb2, int dim, double eps); MEDCOUPLING_EXPORT void rotate2D(const double *center, double angle); diff --git a/src/MEDCoupling/MEDCouplingRefCountObject.cxx b/src/MEDCoupling/MEDCouplingRefCountObject.cxx index a4a79aec1..94d24fbd2 100644 --- a/src/MEDCoupling/MEDCouplingRefCountObject.cxx +++ b/src/MEDCoupling/MEDCouplingRefCountObject.cxx @@ -24,12 +24,19 @@ #include "InterpKernelException.hxx" +#include +#include +#include +#include +#include #include #include +#include +#include using namespace MEDCoupling; -GlobalDict *GlobalDict::UNIQUE_INSTANCE=0; +GlobalDict *GlobalDict::UNIQUE_INSTANCE=nullptr; const char *MEDCoupling::MEDCouplingVersionStr() { @@ -43,7 +50,7 @@ int MEDCoupling::MEDCouplingVersion() void MEDCoupling::MEDCouplingVersionMajMinRel(int& maj, int& minor, int& releas) { - int ver=MEDCOUPLING_VERSION; + int const ver=MEDCOUPLING_VERSION; maj=(ver & 0xFF0000) >> 16; minor=(ver & 0xFF00) >> 8; releas=(ver & 0xFF); @@ -67,7 +74,7 @@ std::size_t MEDCoupling::MEDCouplingSizeOfIDs() bool MEDCoupling::MEDCouplingByteOrder() { unsigned int x(1); - unsigned char *xc(reinterpret_cast(&x)); + auto *xc(reinterpret_cast(&x)); return xc[0]==1; } @@ -105,7 +112,7 @@ std::string BigMemoryObject::debugHeapMemorySize() const ret = it->getHeapMemorySizeWithoutChildren(); sum+=ret; oss << it->getClassName() << " -> " << ret << std::endl; s1.insert(it); - std::vector v2(it->getDirectChildren()); + std::vector const v2(it->getDirectChildren()); for(auto it2 : v2) if(s1.find(it2)==s1.end()) s3.push_back(it2); @@ -119,7 +126,7 @@ std::string BigMemoryObject::debugHeapMemorySize() const std::size_t BigMemoryObject::getHeapMemorySize() const { - std::size_t ret(getHeapMemorySizeWithoutChildren()); + std::size_t const ret(getHeapMemorySizeWithoutChildren()); std::vector v(getDirectChildren()); std::set s1,s2(v.begin(),v.end()); return ret+GetHeapMemoryOfSet(s1,s2); @@ -138,16 +145,16 @@ std::vector BigMemoryObject::getAllTheProgeny() const { ret.insert(ret.end(),s1.begin(),s1.end()); std::vector s3; - for(std::vector::const_iterator it0=s1.begin();it0!=s1.end();it0++) + for(auto it0 : s1) { std::vector s2; - if(*it0) - s2=(*it0)->getDirectChildren(); - for(std::vector::const_iterator it1=s2.begin();it1!=s2.end();it1++) + if(it0) + s2=it0->getDirectChildren(); + for(auto it1 : s2) { - if(*it1) - if(std::find(ret.begin(),ret.end(),*it1)==ret.end()) - s3.push_back(*it1); + if(it1) + if(std::find(ret.begin(),ret.end(),it1)==ret.end()) + s3.push_back(it1); } } s1=s3; @@ -172,15 +179,15 @@ std::size_t BigMemoryObject::GetHeapMemorySizeOfObjs(const std::vector s1,s2; - for(std::vector::const_iterator it0=objs.begin();it0!=objs.end();it0++) + for(auto obj : objs) { - if(*it0) - if(s1.find(*it0)==s1.end()) + if(obj) + if(s1.find(obj)==s1.end()) { - std::vector vTmp((*it0)->getDirectChildren()); + std::vector vTmp(obj->getDirectChildren()); s2.insert(vTmp.begin(),vTmp.end()); - ret+=(*it0)->getHeapMemorySizeWithoutChildren(); - s1.insert(*it0); + ret+=obj->getHeapMemorySizeWithoutChildren(); + s1.insert(obj); } } return ret+GetHeapMemoryOfSet(s1,s2); @@ -192,16 +199,16 @@ std::size_t BigMemoryObject::GetHeapMemoryOfSet(std::set s3; - for(std::set::const_iterator it=s2.begin();it!=s2.end();it++) + for(auto it : s2) { - if(s1.find(*it)==s1.end()) + if(s1.find(it)==s1.end()) { - ret+=(*it)->getHeapMemorySizeWithoutChildren(); - s1.insert(*it); - std::vector v2((*it)->getDirectChildren()); - for(std::vector::const_iterator it2=v2.begin();it2!=v2.end();it2++) - if(s1.find(*it2)==s1.end()) - s3.insert(*it2); + ret+=it->getHeapMemorySizeWithoutChildren(); + s1.insert(it); + std::vector const v2(it->getDirectChildren()); + for(auto it2 : v2) + if(s1.find(it2)==s1.end()) + s3.insert(it2); } } s2=s3; @@ -226,7 +233,7 @@ std::string BigMemoryObject::getHeapMemorySizeStr() const std::ostringstream oss2; oss2 << std::fixed << ((double)remain)/1024.; std::string s(oss2.str()); s=s.substr(1,4); - std::size_t pos(s.find_last_not_of('0')); + std::size_t const pos(s.find_last_not_of('0')); if(pos==4) oss << s; else @@ -252,16 +259,15 @@ std::string BigMemoryObject::getHeapMemorySizeStr() const std::vector BigMemoryObject::getDirectChildren() const { std::vector ret; - std::vector retWithNull(getDirectChildrenWithNull()); - for(std::vector::const_iterator it=retWithNull.begin();it!=retWithNull.end();it++) - if(*it) - ret.push_back(*it); + std::vector const retWithNull(getDirectChildrenWithNull()); + for(auto it : retWithNull) + if(it) + ret.push_back(it); return ret; } BigMemoryObject::~BigMemoryObject() -{ -} += default; //= @@ -269,13 +275,13 @@ RefCountObjectOnly::RefCountObjectOnly():_cnt(1) { } -RefCountObjectOnly::RefCountObjectOnly(const RefCountObjectOnly& other):_cnt(1) +RefCountObjectOnly::RefCountObjectOnly(const RefCountObjectOnly& /*other*/):_cnt(1) { } bool RefCountObjectOnly::decrRef() const { - bool ret=((--_cnt)==0); + bool const ret=((--_cnt)==0); if(ret) delete this; return ret; @@ -292,14 +298,13 @@ int RefCountObjectOnly::getRCValue() const } RefCountObjectOnly::~RefCountObjectOnly() -{ -} += default; /*! * Do nothing here ! It is not a bug ( I hope :) ) because all subclasses that * copies using operator= should not copy the ref counter of \a other ! */ -RefCountObjectOnly& RefCountObjectOnly::operator=(const RefCountObjectOnly& other) +RefCountObjectOnly& RefCountObjectOnly::operator=(const RefCountObjectOnly& /*other*/) { return *this; } @@ -307,16 +312,14 @@ RefCountObjectOnly& RefCountObjectOnly::operator=(const RefCountObjectOnly& othe //= RefCountObject::RefCountObject() -{ -} += default; RefCountObject::RefCountObject(const RefCountObject& other):RefCountObjectOnly(other) { } RefCountObject::~RefCountObject() -{ -} += default; //= @@ -329,13 +332,13 @@ GlobalDict *GlobalDict::GetInstance() bool GlobalDict::hasKey(const std::string& key) const { - std::map::const_iterator it(_my_map.find(key)); + auto const it(_my_map.find(key)); return it!=_my_map.end(); } std::string GlobalDict::value(const std::string& key) const { - std::map::const_iterator it(_my_map.find(key)); + auto const it(_my_map.find(key)); if(it==_my_map.end()) { std::ostringstream oss; @@ -348,14 +351,14 @@ std::string GlobalDict::value(const std::string& key) const std::vector GlobalDict::keys() const { std::vector ret; - for(std::map::const_iterator it=_my_map.begin();it!=_my_map.end();it++) - ret.push_back((*it).first); + for(const auto & it : _my_map) + ret.push_back(it.first); return ret; } void GlobalDict::erase(const std::string& key) { - std::map::iterator it(_my_map.find(key)); + auto const it(_my_map.find(key)); if(it==_my_map.end()) { std::ostringstream oss; @@ -372,7 +375,7 @@ void GlobalDict::clear() void GlobalDict::setKeyValue(const std::string& key, const std::string& val) { - std::map::const_iterator it(_my_map.find(key)); + std::map::const_iterator const it(_my_map.find(key)); if(it!=_my_map.end()) { std::ostringstream oss; @@ -390,9 +393,9 @@ void GlobalDict::setKeyValueForce(const std::string& key, const std::string& val std::string GlobalDict::printSelf() const { std::ostringstream oss; - for(std::map::const_iterator it=_my_map.begin();it!=_my_map.end();it++) + for(const auto & it : _my_map) { - oss << "(" << (*it).first << "," << (*it).second << ")" << std::endl; + oss << "(" << it.first << "," << it.second << ")" << std::endl; } return oss.str(); } diff --git a/src/MEDCoupling/MEDCouplingRefCountObject.hxx b/src/MEDCoupling/MEDCouplingRefCountObject.hxx index ea5afa956..0d6b4773f 100644 --- a/src/MEDCoupling/MEDCouplingRefCountObject.hxx +++ b/src/MEDCoupling/MEDCouplingRefCountObject.hxx @@ -108,7 +108,7 @@ namespace MEDCoupling protected: RefCountObject(); RefCountObject(const RefCountObject& other); - virtual ~RefCountObject(); + ~RefCountObject() override; }; class MEDCOUPLING_EXPORT GlobalDict diff --git a/src/MEDCoupling/MEDCouplingRemapper.cxx b/src/MEDCoupling/MEDCouplingRemapper.cxx old mode 100755 new mode 100644 index 1b1c3caf7..e9b24e662 --- a/src/MEDCoupling/MEDCouplingRemapper.cxx +++ b/src/MEDCoupling/MEDCouplingRemapper.cxx @@ -19,19 +19,36 @@ // Author : Anthony Geay (CEA/DEN) #include "MEDCouplingRemapper.hxx" +#include "Interpolation.txx" +#include "MCAuto.hxx" +#include "InterpolationOptions.hxx" +#include "MCType.hxx" +#include "Interpolation1D.hxx" +#include "Interpolation2D.hxx" +#include "Interpolation3D.hxx" +#include "Interpolation3D1D.hxx" +#include "Interpolation1D0D.hxx" +#include "Interpolation2D1D.hxx" +#include "Interpolation2D3D.hxx" +#include "InterpolationCU.hxx" +#include "InterpolationCC.hxx" +#include "InterpKernelException.hxx" +#include "MEDCouplingGaussLocalization.hxx" +#include "MCIdType.hxx" #include "MEDCouplingMemArray.hxx" #include "MEDCouplingFieldDouble.hxx" #include "MEDCouplingFieldTemplate.hxx" #include "MEDCouplingFieldDiscretization.hxx" #include "MEDCouplingMappedExtrudedMesh.hxx" #include "MEDCouplingCMesh.hxx" +#include "MEDCouplingNatureOfFieldEnum" #include "MEDCouplingNormalizedUnstructuredMesh.txx" +#include "MEDCouplingNormalizedCartesianMesh.hxx" #include "MEDCouplingNormalizedCartesianMesh.txx" #include "MEDCouplingFieldDiscretizationOnNodesFE.hxx" +#include "MEDCouplingUMesh.hxx" -#include "Interpolation1D.txx" #include "Interpolation2DCurve.hxx" -#include "Interpolation2D.txx" #include "Interpolation3D.txx" #include "Interpolation3DSurf.hxx" #include "Interpolation2D1D.txx" @@ -40,10 +57,18 @@ #include "Interpolation1D0D.txx" #include "InterpolationCU.txx" #include "InterpolationCC.txx" +#include +#include +#include +#include +#include "MEDCouplingPointSet.hxx" +#include +#include +#include using namespace MEDCoupling; -MEDCouplingRemapper::MEDCouplingRemapper():_src_ft(0),_target_ft(0),_interp_matrix_pol(IK_ONLY_PREFERED),_nature_of_deno(NoNature),_time_deno_update(0) +MEDCouplingRemapper::MEDCouplingRemapper():_src_ft(nullptr),_target_ft(nullptr),_interp_matrix_pol(IK_ONLY_PREFERED),_nature_of_deno(NoNature),_time_deno_update(0) { } @@ -129,7 +154,7 @@ void MEDCouplingRemapper::setCrudeMatrixEx(const MEDCouplingFieldTemplate *src, int MEDCouplingRemapper::prepareInterpKernelOnly() { - int meshInterpType=((int)_src_ft->getMesh()->getType()*16)+(int)_target_ft->getMesh()->getType(); + int const meshInterpType=((int)_src_ft->getMesh()->getType()*16)+(int)_target_ft->getMesh()->getType(); // *** Remember: // typedef enum // { @@ -404,8 +429,8 @@ void MEDCouplingRemapper::setInterpolationMatrixPolicy(int newInterpMatPol) int MEDCouplingRemapper::prepareInterpKernelOnlyUU() { - const MEDCouplingPointSet *src_mesh=static_cast(_src_ft->getMesh()); - const MEDCouplingPointSet *target_mesh=static_cast(_target_ft->getMesh()); + const auto *src_mesh=static_cast(_src_ft->getMesh()); + const auto *target_mesh=static_cast(_target_ft->getMesh()); std::string srcMeth,trgMeth; std::string method(checkAndGiveInterpolationMethodStr(srcMeth,trgMeth)); const int srcMeshDim=src_mesh->getMeshDimension(); @@ -532,7 +557,7 @@ int MEDCouplingRemapper::prepareInterpKernelOnlyUU() nbCols=interpolation.interpolateMeshes(target_mesh_wrapper,source_mesh_wrapper,matrixTmp,revMethod); ReverseMatrix(matrixTmp,nbCols,_matrix); nbCols=ToIdType(matrixTmp.size()); - INTERP_KERNEL::Interpolation2D1D::DuplicateFacesType duplicateFaces=interpolation.retrieveDuplicateFaces(); + INTERP_KERNEL::Interpolation2D1D::DuplicateFacesType const duplicateFaces=interpolation.retrieveDuplicateFaces(); if(!duplicateFaces.empty()) { std::ostringstream oss; oss << "An unexpected situation happened ! For the following 1D Cells are part of edges shared by 2D cells :\n"; @@ -573,7 +598,7 @@ int MEDCouplingRemapper::prepareInterpKernelOnlyUU() MEDCouplingNormalizedUnstructuredMesh<2,2> target_mesh_wrapper(target_mesh); INTERP_KERNEL::Interpolation2D1D interpolation(*this); nbCols=interpolation.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,_matrix,method); - INTERP_KERNEL::Interpolation2D1D::DuplicateFacesType duplicateFaces=interpolation.retrieveDuplicateFaces(); + INTERP_KERNEL::Interpolation2D1D::DuplicateFacesType const duplicateFaces=interpolation.retrieveDuplicateFaces(); if(!duplicateFaces.empty()) { std::ostringstream oss; oss << "An unexpected situation happened ! For the following 1D Cells are part of edges shared by 2D cells :\n"; @@ -596,7 +621,7 @@ int MEDCouplingRemapper::prepareInterpKernelOnlyUU() MEDCouplingNormalizedUnstructuredMesh<3,3> target_mesh_wrapper(target_mesh); INTERP_KERNEL::Interpolation2D3D interpolation(*this); nbCols=interpolation.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,_matrix,method); - INTERP_KERNEL::Interpolation2D3D::DuplicateFacesType duplicateFaces=interpolation.retrieveDuplicateFaces(); + INTERP_KERNEL::Interpolation2D3D::DuplicateFacesType const duplicateFaces=interpolation.retrieveDuplicateFaces(); if(!duplicateFaces.empty()) { std::ostringstream oss; oss << "An unexpected situation happened ! For the following 2D Cells are part of edges shared by 3D cells :\n"; @@ -628,7 +653,7 @@ int MEDCouplingRemapper::prepareInterpKernelOnlyUU() nbCols=interpolation.interpolateMeshes(target_mesh_wrapper,source_mesh_wrapper,matrixTmp,revMethod); ReverseMatrix(matrixTmp,nbCols,_matrix); nbCols=ToIdType(matrixTmp.size()); - INTERP_KERNEL::Interpolation2D3D::DuplicateFacesType duplicateFaces=interpolation.retrieveDuplicateFaces(); + INTERP_KERNEL::Interpolation2D3D::DuplicateFacesType const duplicateFaces=interpolation.retrieveDuplicateFaces(); if(!duplicateFaces.empty()) { std::ostringstream oss; oss << "An unexpected situation happened ! For the following 2D Cells are part of edges shared by 3D cells :\n"; @@ -697,8 +722,8 @@ int MEDCouplingRemapper::prepareInterpKernelOnlyEE() { std::string srcMeth,trgMeth; std::string methC=checkAndGiveInterpolationMethodStr(srcMeth,trgMeth); - const MEDCouplingMappedExtrudedMesh *src_mesh=static_cast(_src_ft->getMesh()); - const MEDCouplingMappedExtrudedMesh *target_mesh=static_cast(_target_ft->getMesh()); + const auto *src_mesh=static_cast(_src_ft->getMesh()); + const auto *target_mesh=static_cast(_target_ft->getMesh()); if(methC!="P0P0") throw INTERP_KERNEL::Exception("MEDCouplingRemapper::prepareInterpKernelOnlyEE : Only P0P0 method implemented for Extruded/Extruded meshes !"); MCAuto src2D(src_mesh->getMesh2D()->clone(false)); src2D->changeSpaceDimension(2,0.); @@ -730,13 +755,13 @@ int MEDCouplingRemapper::prepareInterpKernelOnlyEE() int MEDCouplingRemapper::prepareInterpKernelOnlyUC() { std::string srcMeth,trgMeth; - std::string methodCpp=checkAndGiveInterpolationMethodStr(srcMeth,trgMeth); + std::string const methodCpp=checkAndGiveInterpolationMethodStr(srcMeth,trgMeth); if(methodCpp!="P0P0") throw INTERP_KERNEL::Exception("MEDCouplingRemapper::prepareInterpKernelOnlyUC: only P0P0 interpolation supported for the moment !"); if(InterpolationOptions::getIntersectionType()!=INTERP_KERNEL::Triangulation) throw INTERP_KERNEL::Exception("MEDCouplingRemapper::prepareInterpKernelOnlyUC: only 'Triangulation' intersection type supported!"); - const MEDCouplingUMesh *src_mesh=static_cast(_src_ft->getMesh()); - const MEDCouplingCMesh *target_mesh=static_cast(_target_ft->getMesh()); + const auto *src_mesh=static_cast(_src_ft->getMesh()); + const auto *target_mesh=static_cast(_target_ft->getMesh()); const int srcMeshDim=src_mesh->getMeshDimension(); const int srcSpceDim=src_mesh->getSpaceDimension(); const int trgMeshDim=target_mesh->getMeshDimension(); @@ -782,13 +807,13 @@ int MEDCouplingRemapper::prepareInterpKernelOnlyUC() int MEDCouplingRemapper::prepareInterpKernelOnlyCU() { std::string srcMeth,trgMeth; - std::string methodCpp=checkAndGiveInterpolationMethodStr(srcMeth,trgMeth); + std::string const methodCpp=checkAndGiveInterpolationMethodStr(srcMeth,trgMeth); if(methodCpp!="P0P0") throw INTERP_KERNEL::Exception("MEDCouplingRemapper::prepareInterpKernelOnlyCU : only P0P0 interpolation supported for the moment !"); if(InterpolationOptions::getIntersectionType()!=INTERP_KERNEL::Triangulation) throw INTERP_KERNEL::Exception("MEDCouplingRemapper::prepareInterpKernelOnlyCU: only 'Triangulation' intersection type supported!"); - const MEDCouplingCMesh *src_mesh=static_cast(_src_ft->getMesh()); - const MEDCouplingUMesh *target_mesh=static_cast(_target_ft->getMesh()); + const auto *src_mesh=static_cast(_src_ft->getMesh()); + const auto *target_mesh=static_cast(_target_ft->getMesh()); const int srcMeshDim=src_mesh->getMeshDimension(); const int trgMeshDim=target_mesh->getMeshDimension(); const int trgSpceDim=target_mesh->getSpaceDimension(); @@ -832,13 +857,13 @@ int MEDCouplingRemapper::prepareInterpKernelOnlyCU() int MEDCouplingRemapper::prepareInterpKernelOnlyCC() { std::string srcMeth,trgMeth; - std::string methodCpp=checkAndGiveInterpolationMethodStr(srcMeth,trgMeth); + std::string const methodCpp=checkAndGiveInterpolationMethodStr(srcMeth,trgMeth); if(methodCpp!="P0P0") throw INTERP_KERNEL::Exception("MEDCouplingRemapper::prepareInterpKernelOnlyCC : only P0P0 interpolation supported for the moment !"); if(InterpolationOptions::getIntersectionType()!=INTERP_KERNEL::Triangulation) throw INTERP_KERNEL::Exception("MEDCouplingRemapper::prepareInterpKernelOnlyCC: only 'Triangulation' intersection type supported!"); - const MEDCouplingCMesh *src_mesh=static_cast(_src_ft->getMesh()); - const MEDCouplingCMesh *target_mesh=static_cast(_target_ft->getMesh()); + const auto *src_mesh=static_cast(_src_ft->getMesh()); + const auto *target_mesh=static_cast(_target_ft->getMesh()); const int srcMeshDim=src_mesh->getMeshDimension(); const int trgMeshDim=target_mesh->getMeshDimension(); if(trgMeshDim!=srcMeshDim) @@ -906,7 +931,7 @@ int MEDCouplingRemapper::prepareNotInterpKernelOnlyGaussGauss() for(const mcIdType *trgId=ids0->begin();trgId!=ids0->end();trgId++) { const double *ptTrg=trgLocPtr+trgSpaceDim*(*trgId); - mcIdType srcCellId=elts[eltsIndex[*trgId]]; + mcIdType const srcCellId=elts[eltsIndex[*trgId]]; double dist=std::numeric_limits::max(); mcIdType srcEntry=-1; for(mcIdType srcId=srcOffsetArrPtr[srcCellId];srcIdgetNumberOfTuples()!=trgNbOfGaussPts) { - MCAuto orphanTrgIds=nbOfSrcCellsShTrgPts->findIdsEqual(0); + MCAuto const orphanTrgIds=nbOfSrcCellsShTrgPts->findIdsEqual(0); MCAuto orphanTrg=trgLoc->selectByTupleId(orphanTrgIds->begin(),orphanTrgIds->end()); MCAuto srcIdPerTrg=srcLoc->findClosestTupleId(orphanTrg); const mcIdType *srcIdPerTrgPtr=srcIdPerTrg->begin(); @@ -943,8 +968,8 @@ int MEDCouplingRemapper::prepareNotInterpKernelOnlyFEFE() THROW_IK_EXCEPTION("prepareNotInterpKernelOnlyFEFE : only spacedim 3 supported for target !") if(_src_ft->getMesh()->getSpaceDimension() != 3) THROW_IK_EXCEPTION("prepareNotInterpKernelOnlyFEFE : only spacedim 3 supported for source !") - const MEDCouplingUMesh *srcUMesh( dynamic_cast(_src_ft->getMesh()) ); - const MEDCouplingPointSet *trgMesh( dynamic_cast(_target_ft->getMesh()) ); + const auto *srcUMesh( dynamic_cast(_src_ft->getMesh()) ); + const auto *trgMesh( dynamic_cast(_target_ft->getMesh()) ); if( !srcUMesh ) THROW_IK_EXCEPTION("prepareNotInterpKernelOnlyFEFE : only 3D UMesh supported as source !"); if( !trgMesh ) @@ -1092,8 +1117,8 @@ void MEDCouplingRemapper::BuildFieldTemplatesFrom(const MEDCouplingMesh *srcMesh void MEDCouplingRemapper::releaseData(bool matrixSuppression) { - _src_ft=0; - _target_ft=0; + _src_ft=nullptr; + _target_ft=nullptr; if(matrixSuppression) { _matrix.clear(); @@ -1241,7 +1266,7 @@ void MEDCouplingRemapper::computeDenoFromScratch(NatureOfField nat, const MEDCou void MEDCouplingRemapper::computeProduct(const double *inputPointer, int inputNbOfCompo, bool isDftVal, double dftValue, double *resPointer) { int idx=0; - double *tmp=new double[inputNbOfCompo]; + auto *tmp=new double[inputNbOfCompo]; for(std::vector >::const_iterator iter1=_matrix.begin();iter1!=_matrix.end();iter1++,idx++) { if((*iter1).empty()) @@ -1266,7 +1291,7 @@ void MEDCouplingRemapper::computeReverseProduct(const double *inputPointer, int { std::vector isReached(_deno_reverse_multiply.size(),false); mcIdType idx=0; - double *tmp=new double[inputNbOfCompo]; + auto *tmp=new double[inputNbOfCompo]; std::fill(resPointer,resPointer+inputNbOfCompo*_deno_reverse_multiply.size(),0.); for(std::vector >::const_iterator iter1=_matrix.begin();iter1!=_matrix.end();iter1++,idx++) { @@ -1343,12 +1368,12 @@ void MEDCouplingRemapper::ComputeColSumAndRowSum(const std::vector >& m1D, const std::vector< std::map >& m2D, - const mcIdType *corrCellIdSrc, mcIdType nbOf2DCellsSrc, mcIdType nbOf1DCellsSrc, + const mcIdType *corrCellIdSrc, mcIdType nbOf2DCellsSrc, mcIdType /*nbOf1DCellsSrc*/, const mcIdType *corrCellIdTrg) { mcIdType nbOf2DCellsTrg=ToIdType(m2D.size()); mcIdType nbOf1DCellsTrg=ToIdType(m1D.size()); - mcIdType nbOf3DCellsTrg=nbOf2DCellsTrg*nbOf1DCellsTrg; + mcIdType const nbOf3DCellsTrg=nbOf2DCellsTrg*nbOf1DCellsTrg; _matrix.resize(nbOf3DCellsTrg); mcIdType id2R=0; for(std::vector< std::map >::const_iterator iter2R=m2D.begin();iter2R!=m2D.end();iter2R++,id2R++) @@ -1441,7 +1466,7 @@ int MEDCouplingRemapper::nullifiedTinyCoeffInCrudeMatrixAbs(double maxValAbs) */ int MEDCouplingRemapper::nullifiedTinyCoeffInCrudeMatrix(double scaleFactor) { - double maxVal=getMaxValueInCrudeMatrix(); + double const maxVal=getMaxValueInCrudeMatrix(); if(maxVal==0.) return -1; return nullifiedTinyCoeffInCrudeMatrixAbs(scaleFactor*maxVal); diff --git a/src/MEDCoupling/MEDCouplingRemapper.hxx b/src/MEDCoupling/MEDCouplingRemapper.hxx index 9110cf9d2..564c387a9 100644 --- a/src/MEDCoupling/MEDCouplingRemapper.hxx +++ b/src/MEDCoupling/MEDCouplingRemapper.hxx @@ -22,15 +22,15 @@ #define __PARAMEDMEM_MEDCOUPLINGREMAPPER_HXX__ #include "MEDCoupling.hxx" +#include "MEDCouplingNatureOfFieldEnum" #include "MEDCouplingTimeLabel.hxx" #include "InterpolationOptions.hxx" -#include "MEDCouplingNatureOfField.hxx" #include "MCType.hxx" #include "MCAuto.hxx" -#include "InterpKernelException.hxx" #include +#include #include namespace MEDCoupling @@ -54,7 +54,7 @@ namespace MEDCoupling { public: MEDCOUPLINGREMAPPER_EXPORT MEDCouplingRemapper(); - MEDCOUPLINGREMAPPER_EXPORT ~MEDCouplingRemapper(); + MEDCOUPLINGREMAPPER_EXPORT ~MEDCouplingRemapper() override; MEDCOUPLINGREMAPPER_EXPORT int prepare(const MEDCouplingMesh *srcMesh, const MEDCouplingMesh *targetMesh, const std::string& method); MEDCOUPLINGREMAPPER_EXPORT int prepareEx(const MEDCouplingFieldTemplate *src, const MEDCouplingFieldTemplate *target); MEDCOUPLINGREMAPPER_EXPORT void setCrudeMatrix(const MEDCouplingMesh *srcMesh, const MEDCouplingMesh *targetMesh, const std::string& method, const std::vector >& m); @@ -94,7 +94,7 @@ namespace MEDCoupling static int CheckInterpolationMethodManageableByNotOnlyInterpKernel(const std::string& method); // bool isInterpKernelOnlyOrNotOnly() const; - void updateTime() const; + void updateTime() const override; void checkPrepare() const; void synchronizeSizeOfSideMatricesAfterMatrixComputation(mcIdType nbOfColsInMatrix); std::string checkAndGiveInterpolationMethodStr(std::string& srcMeth, std::string& trgMeth) const; diff --git a/src/MEDCoupling/MEDCouplingSkyLineArray.cxx b/src/MEDCoupling/MEDCouplingSkyLineArray.cxx old mode 100755 new mode 100644 index 1ed26a036..1636c5b21 --- a/src/MEDCoupling/MEDCouplingSkyLineArray.cxx +++ b/src/MEDCoupling/MEDCouplingSkyLineArray.cxx @@ -18,10 +18,21 @@ // #include "MEDCouplingSkyLineArray.hxx" - +#include "MCType.hxx" +#include "NormalizedGeometricTypes" +#include "MCIdType.hxx" +#include "MCAuto.hxx" +#include "MEDCouplingRefCountObject.hxx" + +#include +#include +#include +#include +#include #include #include #include +#include using namespace MEDCoupling; @@ -31,8 +42,7 @@ MEDCouplingSkyLineArray::MEDCouplingSkyLineArray(): } MEDCouplingSkyLineArray::~MEDCouplingSkyLineArray() -{ -} += default; MEDCouplingSkyLineArray* MEDCouplingSkyLineArray::New() { @@ -42,7 +52,7 @@ MEDCouplingSkyLineArray* MEDCouplingSkyLineArray::New() MEDCouplingSkyLineArray* MEDCouplingSkyLineArray::New( const std::vector& index, const std::vector& value ) { - MEDCouplingSkyLineArray * ret = new MEDCouplingSkyLineArray(); + auto * ret = new MEDCouplingSkyLineArray(); ret->_index->reserve( index.size() ); ret->_index->insertAtTheEnd( index.begin(), index.end() ); ret->_values->reserve( value.size() ); @@ -52,14 +62,14 @@ MEDCouplingSkyLineArray* MEDCouplingSkyLineArray::New( const std::vectorset(index, value); return ret; } MEDCouplingSkyLineArray* MEDCouplingSkyLineArray::New( const MEDCouplingSkyLineArray & other ) { - MEDCouplingSkyLineArray* ret = new MEDCouplingSkyLineArray(); + auto* ret = new MEDCouplingSkyLineArray(); ret->_super_index = other._super_index; ret->_index = other._index; ret->_values = other._values; @@ -74,7 +84,7 @@ MEDCouplingSkyLineArray * MEDCouplingSkyLineArray::BuildFromPolyhedronConn( cons { using namespace std; - MEDCouplingSkyLineArray* ret = new MEDCouplingSkyLineArray(); + auto* ret = new MEDCouplingSkyLineArray(); const mcIdType * cP(c->begin()), * cIP(cI->begin()); mcIdType prev = -1; @@ -82,7 +92,7 @@ MEDCouplingSkyLineArray * MEDCouplingSkyLineArray::BuildFromPolyhedronConn( cons throw INTERP_KERNEL::Exception("MEDCouplingSkyLineArray::BuildFromDynamicConn: misformatted connectivity (wrong nb of tuples)!"); for (mcIdType i=0; i < cI->getNbOfElems(); i++) { - mcIdType j = cIP[i]; + mcIdType const j = cIP[i]; if (cIP[i] < prev) throw INTERP_KERNEL::Exception("MEDCouplingSkyLineArray::BuildFromDynamicConn: misformatted connectivity (indices not monotonic ascending)!"); prev = cIP[i]; @@ -106,7 +116,7 @@ MEDCouplingSkyLineArray * MEDCouplingSkyLineArray::BuildFromPolyhedronConn( cons while (w2 != cP+end) { copy(w, w2, work); - mcIdType d = ToIdType(distance(w, w2)); + mcIdType const d = ToIdType(distance(w, w2)); cnt += d; work +=d; idx.push_back(cnt); cnt2++; w = w2+1; // skip the -1 @@ -143,14 +153,14 @@ void MEDCouplingSkyLineArray::convertToPolyhedronConn( MCAuto& cI->alloc(_super_index->getNbOfElems(),1); // same number of super packs as number of cells mcIdType * cIVecP(cI->getPointer()); MCAuto dsi = _index->deltaShiftIndex(); - mcIdType sz = dsi->accumulate((std::size_t)0) + ToIdType(dsi->getNbOfElems()); // think about it: one slot for the type, -1 at the end of each face of the cell + mcIdType const sz = dsi->accumulate((std::size_t)0) + ToIdType(dsi->getNbOfElems()); // think about it: one slot for the type, -1 at the end of each face of the cell c->alloc(sz, 1); mcIdType * cVecP(c->getPointer()); for ( mcIdType i=0; i < _super_index->getNbOfElems()-1; i++) { cIVecP[i]= cnt; - mcIdType endId = siP[i+1]; + mcIdType const endId = siP[i+1]; cVecP[cnt++] = INTERP_KERNEL::NORM_POLYHED; for (mcIdType j=siP[i]; j < endId; j++) { @@ -220,7 +230,7 @@ MEDCouplingSkyLineArray *MEDCouplingSkyLineArray::deepCopy() const MCAuto ret(MEDCouplingSkyLineArray::New(indexCpy,valuesCpy)); if(_super_index.isNotNull()) { - MCAuto superIndexCpy(this->_super_index->deepCopy()); + MCAuto const superIndexCpy(this->_super_index->deepCopy()); ret->_super_index = superIndexCpy; } return ret.retn(); @@ -259,7 +269,7 @@ void MEDCouplingSkyLineArray::validIndex(const std::string& func, mcIdType idx) void MEDCouplingSkyLineArray::validSuperIndexAndIndex(const std::string& func, mcIdType superIndex, mcIdType index) const { validSuperIndex(func, superIndex); - mcIdType idx = _super_index->begin()[superIndex] + index; + mcIdType const idx = _super_index->begin()[superIndex] + index; if(idx < 0 || idx >= _index->getNbOfElems()) { std::ostringstream oss; @@ -333,7 +343,7 @@ std::string MEDCouplingSkyLineArray::simpleRepr() const */ void MEDCouplingSkyLineArray::thresholdPerPack(mcIdType threshold, MCAuto& left, MCAuto& right) const { - mcIdType nbPacks(this->getNumberOf()); + mcIdType const nbPacks(this->getNumberOf()); MCAuto lCount(DataArrayIdType::New()); lCount->alloc(nbPacks,1); lCount->fillWithZero(); mcIdType *lCountPtr(lCount->getPointerSilent()); const mcIdType *valuesPtr(this->_values->begin()),*indexPtr(this->_index->begin()); @@ -360,7 +370,7 @@ MEDCouplingSkyLineArray *MEDCouplingSkyLineArray::groupPacks(const DataArrayIdTy indexedPacks->checkAllocated(); if( indexedPacks->getNumberOfComponents() != 1 ) throw INTERP_KERNEL::Exception("MEDCouplingSkyLineArray::groupPacks : number of components must be 1 !"); - std::size_t nbTuples(indexedPacks->getNumberOfTuples()); + std::size_t const nbTuples(indexedPacks->getNumberOfTuples()); if( nbTuples == 0 ) throw INTERP_KERNEL::Exception("MEDCouplingSkyLineArray::groupPacks : number of tuples must be > 0 !"); const DataArrayIdType *index(this->getIndexArray()); @@ -371,20 +381,20 @@ MEDCouplingSkyLineArray *MEDCouplingSkyLineArray::groupPacks(const DataArrayIdTy MEDCouplingSkyLineArray *MEDCouplingSkyLineArray::uniqueNotSortedByPack() const { - mcIdType nbPacks(this->getNumberOf()); + mcIdType const nbPacks(this->getNumberOf()); MCAuto retIndex(DataArrayIdType::New()); retIndex->alloc(nbPacks+1,1); const mcIdType *valuesPtr(this->_values->begin()),*indexPtr(this->_index->begin()); mcIdType *retIndexPtr(retIndex->getPointer()); *retIndexPtr = 0; for(mcIdType i = 0 ; i < nbPacks ; ++i, ++retIndexPtr) { - std::set s(valuesPtr+indexPtr[i],valuesPtr+indexPtr[i+1]); + std::set const s(valuesPtr+indexPtr[i],valuesPtr+indexPtr[i+1]); retIndexPtr[1] = retIndexPtr[0] + ToIdType(s.size()); } MCAuto retValues(DataArrayIdType::New()); retValues->alloc(retIndex->back(),1); mcIdType *retValuesPtr(retValues->getPointer()); for(mcIdType i = 0 ; i < nbPacks ; ++i) { - std::set s(valuesPtr+indexPtr[i],valuesPtr+indexPtr[i+1]); + std::set const s(valuesPtr+indexPtr[i],valuesPtr+indexPtr[i+1]); retValuesPtr = std::copy(s.begin(),s.end(),retValuesPtr); } MCAuto ret(MEDCouplingSkyLineArray::New(retIndex,retValues)); @@ -406,7 +416,7 @@ MEDCouplingSkyLineArray *MEDCouplingSkyLineArray::AggregatePacks(const std::vect { if(sk) { - mcIdType curNbPacks(sk->getNumberOf()); + mcIdType const curNbPacks(sk->getNumberOf()); if(sksEff.empty()) nbOfPacks = curNbPacks; if(nbOfPacks != curNbPacks) @@ -432,7 +442,7 @@ MEDCouplingSkyLineArray *MEDCouplingSkyLineArray::AggregatePacks(const std::vect std::for_each(indicesIn.begin(),indicesIn.end(),[packId,&nbOfAggPacks](const mcIdType *elt) { nbOfAggPacks+=elt[packId+1]-elt[packId]; }); indexPtr[1] = indexPtr[0] + nbOfAggPacks; } - mcIdType nbOfTuplesOut(index->back()); + mcIdType const nbOfTuplesOut(index->back()); MCAuto values(DataArrayIdType::New()); values->alloc(nbOfTuplesOut,1); mcIdType *valuesPtr(values->getPointer()); // let's go to populate values array @@ -457,7 +467,7 @@ void MEDCouplingSkyLineArray::getSimplePackSafe(const mcIdType absolutePackId, s if(absolutePackId < 0 || absolutePackId >= _index->getNbOfElems()) throw INTERP_KERNEL::Exception("MEDCouplingSkyLineArray::getPackSafe: invalid index!"); const mcIdType * iP(_index->begin()), *vP(_values->begin()); - mcIdType sz = iP[absolutePackId+1]-iP[absolutePackId]; + mcIdType const sz = iP[absolutePackId+1]-iP[absolutePackId]; pack.resize(sz); std::copy(vP+iP[absolutePackId], vP+iP[absolutePackId+1],pack.begin()); } @@ -492,14 +502,14 @@ void MEDCouplingSkyLineArray::findPackIds(const std::vector & superPac checkSuperIndex("findPackIds"); - mcIdType packSz = ToIdType(std::distance(packBg, packEnd)); + mcIdType const packSz = ToIdType(std::distance(packBg, packEnd)); if (!packSz) throw INTERP_KERNEL::Exception("MEDCouplingSkyLineArray::findPackIds: void pack!"); out.resize(superPackIndices.size()); mcIdType i = 0; const mcIdType * siP(_super_index->begin()), * iP(_index->begin()), *vP(_values->begin()); - for(vector::const_iterator it=superPackIndices.begin(); it!=superPackIndices.end(); ++it, i++) + for(auto it=superPackIndices.begin(); it!=superPackIndices.end(); ++it, i++) { out[i] = -1; const mcIdType sPackIdx = *it; @@ -534,7 +544,7 @@ void MEDCouplingSkyLineArray::deletePack(const mcIdType superIdx, const mcIdType _values->reAlloc(_values->getNbOfElems() - (end-start)); // _index - mcIdType nt = _index->getNbOfElems(); + mcIdType const nt = _index->getNbOfElems(); std::copy(iP+siP[superIdx]+idx+1, iP+nt, iP+siP[superIdx]+idx); _index->reAlloc(nt-1); iP = _index->getPointer(); // better not forget this ... for(mcIdType ii = siP[superIdx]+idx; ii < nt-1; ii++) @@ -553,8 +563,8 @@ void MEDCouplingSkyLineArray::deleteSimplePack(const mcIdType idx) const mcIdType start(iP[idx]), end(iP[idx+1]); // _values - mcIdType initValSz=_values->getNbOfElems(); - mcIdType deltaSz( start-end ); // should be negative + mcIdType const initValSz=_values->getNbOfElems(); + mcIdType const deltaSz( start-end ); // should be negative mcIdType *vP(_values->getPointer()); if (deltaSz < 0) { @@ -564,7 +574,7 @@ void MEDCouplingSkyLineArray::deleteSimplePack(const mcIdType idx) else throw INTERP_KERNEL::Exception("MEDCouplingSkyLineArray::deleteSimplePack"); // _index - mcIdType nt=_index->getNbOfElems(); + mcIdType const nt=_index->getNbOfElems(); std::copy(iP+idx+1, iP+nt, iP+idx); for(mcIdType ii = idx; ii < nt-1; ii++) iP[ii] += deltaSz; @@ -576,8 +586,8 @@ void MEDCouplingSkyLineArray::replaceSimplePacks(const DataArrayIdType* idx, con if (idx->empty()) return; - for (const mcIdType * id = idx->begin(); id != idx->end(); id++) - validIndex("deleteSimplePacks", *id); + for (long const id : *idx) + validIndex("deleteSimplePacks", id); if (idx->getNbOfElems() != ToIdType( packs.size())) throw INTERP_KERNEL::Exception("MEDCouplingSkyLineArray::deleteSimplePacks: size of list of pack is incorrect"); @@ -586,23 +596,23 @@ void MEDCouplingSkyLineArray::replaceSimplePacks(const DataArrayIdType* idx, con std::deque< std::set > valuesByIdx; mcIdType* vP(_values->getPointer()); mcIdType* iP(_index->getPointer()); - mcIdType nt = _index->getNbOfElems(); + mcIdType const nt = _index->getNbOfElems(); for (mcIdType ii = 0; ii < nt-1; ii++) valuesByIdx.push_back(std::set(vP+iP[ii], vP+iP[ii+1])); // modify the deque> according to idx and packs mcIdType ii(0); - for (const mcIdType *id = idx->begin(); id != idx->end(); id++) + for (long const id : *idx) { - valuesByIdx[*id] = std::set(packs[ii]->begin(), packs[ii]->end()); + valuesByIdx[id] = std::set(packs[ii]->begin(), packs[ii]->end()); ii++; } // copy back the deque> into _index, _values mcIdType valSz(0); *iP = 0; - for (std::deque< std::set >::const_iterator values=valuesByIdx.begin();values!=valuesByIdx.end();values++) + for (const auto & values : valuesByIdx) { - valSz += ToIdType((*values).size()); + valSz += ToIdType(values.size()); *(++iP) = valSz; } _values->reAlloc(valSz); @@ -617,45 +627,45 @@ void MEDCouplingSkyLineArray::replaceSimplePacks(const DataArrayIdType* idx, con void MEDCouplingSkyLineArray::deleteSimplePacks(const DataArrayIdType* idx) { - for (auto id = idx->begin(); id != idx->end(); id++) - validIndex("deleteSimplePacks", *id); + for (long const id : *idx) + validIndex("deleteSimplePacks", id); - std::set packsToDelete(idx->begin(), idx->end()); + std::set const packsToDelete(idx->begin(), idx->end()); // _values mcIdType* iP(_index->getPointer()); - mcIdType initValSz = _values->getNbOfElems(); + mcIdType const initValSz = _values->getNbOfElems(); mcIdType *vP(_values->getPointer()); mcIdType end_prec(0),start_prec(0); - for(std::set::const_iterator ii=packsToDelete.begin();ii!=packsToDelete.end();ii++) + for(long const ii : packsToDelete) { - mcIdType start = iP[*ii]; + mcIdType const start = iP[ii]; if (end_prec != 0) std::copy(vP+end_prec, vP+start, vP+start_prec); start_prec += start-end_prec; - end_prec = iP[*ii+1]; + end_prec = iP[ii+1]; } if (end_prec != 0) std::copy(vP+end_prec, vP+initValSz, vP+start_prec); _values->reAlloc(initValSz-(end_prec-start_prec)); // _index - mcIdType nt = _index->getNbOfElems(); + mcIdType const nt = _index->getNbOfElems(); mcIdType offset = 0; end_prec = 0; start_prec = 0; mcIdType deleted = 0; - for(std::set::const_iterator ii=packsToDelete.begin();ii!=packsToDelete.end();ii++) + for(long const ii : packsToDelete) { if (end_prec != 0) { - std::copy(iP+end_prec, iP+*ii, iP+start_prec); - for (mcIdType i=start_prec; i<*ii; i++) + std::copy(iP+end_prec, iP+ii, iP+start_prec); + for (mcIdType i=start_prec; igetNbOfElems()); + mcIdType const nt = ToIdType(_index->getNbOfElems()); _index->reAlloc(nt+1); iP = _index->getPointer(); copy(iP+siP[superIdx+1]+1, iP+nt, iP+siP[superIdx+1]+2); iP[siP[superIdx+1]+1] = iP[siP[superIdx+1]] + sz; @@ -710,12 +720,12 @@ void MEDCouplingSkyLineArray::replaceSimplePack(const mcIdType idx, const mcIdTy validIndex("replaceSimplePack", idx); mcIdType * iP(_index->getPointer()); - mcIdType newSz = ToIdType(std::distance(packBg, packEnd)); + mcIdType const newSz = ToIdType(std::distance(packBg, packEnd)); const mcIdType start = iP[idx], end = iP[idx+1]; // _values - mcIdType initValSz = _values->getNbOfElems(); - mcIdType deltaSz = newSz-(end-start); // can be negative + mcIdType const initValSz = _values->getNbOfElems(); + mcIdType const deltaSz = newSz-(end-start); // can be negative if (deltaSz) { if (deltaSz > 0) @@ -744,12 +754,12 @@ void MEDCouplingSkyLineArray::replacePack(const mcIdType superIdx, const mcIdTyp validSuperIndexAndIndex("replacePack", superIdx, idx); mcIdType * siP(_super_index->getPointer()), *iP(_index->getPointer()); - mcIdType newSz = ToIdType(std::distance(packBg, packEnd)); + mcIdType const newSz = ToIdType(std::distance(packBg, packEnd)); const mcIdType start = iP[siP[superIdx]+idx], end = iP[siP[superIdx]+idx+1]; // _values - mcIdType initValSz = _values->getNbOfElems(); - mcIdType deltaSz = newSz-(end-start); // can be negative + mcIdType const initValSz = _values->getNbOfElems(); + mcIdType const deltaSz = newSz-(end-start); // can be negative if (deltaSz) { if (deltaSz > 0) diff --git a/src/MEDCoupling/MEDCouplingSkyLineArray.hxx b/src/MEDCoupling/MEDCouplingSkyLineArray.hxx index 3beab9cb0..fc682fec8 100644 --- a/src/MEDCoupling/MEDCouplingSkyLineArray.hxx +++ b/src/MEDCoupling/MEDCouplingSkyLineArray.hxx @@ -19,11 +19,17 @@ #pragma once +#include "MCType.hxx" +#include "MCIdType.hxx" #include "MEDCoupling.hxx" #include "MEDCouplingMemArray.hxx" #include "MCAuto.hxx" -#include "NormalizedGeometricTypes" +#include "MEDCouplingRefCountObject.hxx" +#include +#include +#include +#include #include #include @@ -78,16 +84,16 @@ namespace MEDCoupling static std::vector< MCAuto > RetrieveVecOfSkyLineArrayGen(const std::vector< MCAuto >& vecSka, std::function fct) { - std::size_t sz(vecSka.size()); + std::size_t const sz(vecSka.size()); std::vector< MCAuto > ret(sz); - std::vector< MCAuto >::iterator it(ret.begin()); + auto it(ret.begin()); std::for_each(vecSka.begin(),vecSka.end(),[&it,fct](MCAuto elt) { *it++ = MCAuto::TakeRef(fct(elt)); } ); return ret; } std::string getClassName() const override { return std::string("MEDCouplingSkyLineArray"); } - std::size_t getHeapMemorySizeWithoutChildren() const; - std::vector getDirectChildrenWithNull() const; + std::size_t getHeapMemorySizeWithoutChildren() const override; + std::vector getDirectChildrenWithNull() const override; void set( DataArrayIdType* index, DataArrayIdType* value ); void set3( DataArrayIdType* superIndex, DataArrayIdType* index, DataArrayIdType* value ); @@ -133,7 +139,7 @@ namespace MEDCoupling private: MEDCouplingSkyLineArray(); - ~MEDCouplingSkyLineArray(); + ~MEDCouplingSkyLineArray() override; void checkSuperIndex(const std::string& func) const; void validSuperIndex(const std::string& func, mcIdType superIndex) const; diff --git a/src/MEDCoupling/MEDCouplingStructuredMesh.cxx b/src/MEDCoupling/MEDCouplingStructuredMesh.cxx old mode 100755 new mode 100644 index d52a07ae6..4b1031fcf --- a/src/MEDCoupling/MEDCouplingStructuredMesh.cxx +++ b/src/MEDCoupling/MEDCouplingStructuredMesh.cxx @@ -19,27 +19,42 @@ // Author : Anthony Geay (CEA/DEN) #include "MEDCouplingStructuredMesh.hxx" +#include "MCType.hxx" +#include "MCIdType.hxx" +#include "CellModel.hxx" +#include "MCAuto.hxx" #include "MEDCouplingFieldDouble.hxx" #include "MEDCouplingMemArray.hxx" #include "MEDCoupling1GTUMesh.hxx" +#include "MEDCouplingMesh.hxx" +#include "MEDCouplingRefCountObject.hxx" #include "MEDCouplingUMesh.hxx" -#include "MEDCouplingIMesh.hxx"//tony to throw when optimization will be performed in AssignPartOfFieldOfDoubleUsing - +#include "MEDCouplingIMesh.hxx" +#include "NormalizedGeometricTypes" + +#include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include using namespace MEDCoupling; MEDCouplingStructuredMesh::MEDCouplingStructuredMesh() -{ -} += default; -MEDCouplingStructuredMesh::MEDCouplingStructuredMesh(const MEDCouplingStructuredMesh& other, bool deepCpy):MEDCouplingMesh(other) +MEDCouplingStructuredMesh::MEDCouplingStructuredMesh(const MEDCouplingStructuredMesh& other, bool /*deepCpy*/):MEDCouplingMesh(other) { } MEDCouplingStructuredMesh::~MEDCouplingStructuredMesh() -{ -} += default; std::size_t MEDCouplingStructuredMesh::getHeapMemorySizeWithoutChildren() const { @@ -56,7 +71,7 @@ bool MEDCouplingStructuredMesh::isEqualIfNotWhy(const MEDCouplingMesh *other, do return MEDCouplingMesh::isEqualIfNotWhy(other,prec,reason); } -INTERP_KERNEL::NormalizedCellType MEDCouplingStructuredMesh::getTypeOfCell(mcIdType cellId) const +INTERP_KERNEL::NormalizedCellType MEDCouplingStructuredMesh::getTypeOfCell(mcIdType /*cellId*/) const { return GetGeoTypeGivenMeshDimension(getMeshDimension()); } @@ -87,7 +102,7 @@ std::set MEDCouplingStructuredMesh::getAllGeo mcIdType MEDCouplingStructuredMesh::getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const { - mcIdType ret(getNumberOfCells()); + mcIdType const ret(getNumberOfCells()); if(type==getTypeOfCell(0)) return ret; const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(getTypeOfCell(0))); @@ -110,7 +125,7 @@ DataArrayIdType *MEDCouplingStructuredMesh::giveCellsWithType(INTERP_KERNEL::Nor DataArrayIdType *MEDCouplingStructuredMesh::computeNbOfNodesPerCell() const { - std::size_t nbCells=getNumberOfCells(); + std::size_t const nbCells=getNumberOfCells(); MCAuto ret=DataArrayIdType::New(); ret->alloc(nbCells,1); const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getTypeOfCell(0)); @@ -120,7 +135,7 @@ DataArrayIdType *MEDCouplingStructuredMesh::computeNbOfNodesPerCell() const DataArrayIdType *MEDCouplingStructuredMesh::computeNbOfFacesPerCell() const { - std::size_t nbCells=getNumberOfCells(); + std::size_t const nbCells=getNumberOfCells(); MCAuto ret=DataArrayIdType::New(); ret->alloc(nbCells,1); const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getTypeOfCell(0)); @@ -142,7 +157,7 @@ DataArrayIdType *MEDCouplingStructuredMesh::computeEffectiveNbOfNodesPerCell() c void MEDCouplingStructuredMesh::getNodeIdsOfCell(mcIdType cellId, std::vector& conn) const { - int meshDim=getMeshDimension(); + int const meshDim=getMeshDimension(); mcIdType tmpCell[3],tmpNode[3]; getSplitCellValues(tmpCell); getSplitNodeValues(tmpNode); @@ -199,7 +214,7 @@ int MEDCouplingStructuredMesh::getSpaceDimensionOnNodeStruct() const int spd1(0),pos(0); for(std::vector::const_iterator it=nodeStr.begin();it!=nodeStr.end();it++,pos++) { - mcIdType elt(*it); + mcIdType const elt(*it); if(elt<=0) { std::ostringstream oss; oss << "MEDCouplingStructuredMesh::getSpaceDimensionOnNodeStruct : At pos #" << pos << " value of node grid structure is " << *it << " ! must be >=1 !"; @@ -212,14 +227,14 @@ int MEDCouplingStructuredMesh::getSpaceDimensionOnNodeStruct() const void MEDCouplingStructuredMesh::getSplitCellValues(mcIdType *res) const { - std::vector strct(getCellGridStructure()); + std::vector const strct(getCellGridStructure()); std::vector ret(MEDCouplingStructuredMesh::GetSplitVectFromStruct(strct)); std::copy(ret.begin(),ret.end(),res); } void MEDCouplingStructuredMesh::getSplitNodeValues(mcIdType *res) const { - std::vector strct(getNodeGridStructure()); + std::vector const strct(getNodeGridStructure()); std::vector ret(MEDCouplingStructuredMesh::GetSplitVectFromStruct(strct)); std::copy(ret.begin(),ret.end(),res); } @@ -229,7 +244,7 @@ void MEDCouplingStructuredMesh::getSplitNodeValues(mcIdType *res) const */ mcIdType MEDCouplingStructuredMesh::getNumberOfCellsOfSubLevelMesh() const { - std::vector cgs(getCellGridStructure()); + std::vector const cgs(getCellGridStructure()); return GetNumberOfCellsOfSubLevelMesh(cgs,getMeshDimension()); } @@ -254,7 +269,7 @@ std::vector MEDCouplingStructuredMesh::getDistributionOfTypes() const */ DataArrayIdType *MEDCouplingStructuredMesh::checkTypeConsistencyAndContig(const std::vector& code, const std::vector& idsPerType) const { - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbOfCells=getNumberOfCells(); if(code.size()!=3) throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::checkTypeConsistencyAndContig : invalid input code should be exactly of size 3 !"); if(code[0]!=ToIdType(getTypeOfCell(0))) @@ -265,7 +280,7 @@ DataArrayIdType *MEDCouplingStructuredMesh::checkTypeConsistencyAndContig(const if(code[2]==-1) { if(code[1]==nbOfCells) - return 0; + return nullptr; else { std::ostringstream oss; oss << "MEDCouplingStructuredMesh::checkTypeConsistencyAndContig : mismatch between the number of cells in this (" << nbOfCells << ") and the number of non profile (" << code[1] << ") !"; @@ -316,8 +331,8 @@ void MEDCouplingStructuredMesh::splitProfilePerType(const DataArrayIdType *profi throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::splitProfilePerType : input profile is NULL or not allocated !"); if(profile->getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::splitProfilePerType : input profile should have exactly one component !"); - mcIdType nbTuples(profile->getNumberOfTuples()); - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbTuples(profile->getNumberOfTuples()); + mcIdType const nbOfCells=getNumberOfCells(); code.resize(3); idsInPflPerType.resize(1); code[0]=ToIdType(getTypeOfCell(0)); code[1]=nbOfCells; idsInPflPerType.resize(1); @@ -371,7 +386,7 @@ MEDCoupling1SGTUMesh *MEDCouplingStructuredMesh::build1SGTUnstructured() const */ MEDCoupling1SGTUMesh *MEDCouplingStructuredMesh::build1SGTSubLevelMesh() const { - int meshDim(getMeshDimension()); + int const meshDim(getMeshDimension()); if(meshDim<1 || meshDim>3) throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::build1SGTSubLevelMesh : meshdim must be in [2,3] !"); MCAuto coords(getCoordinatesAndOwner()); @@ -417,14 +432,14 @@ MEDCouplingMesh *MEDCouplingStructuredMesh::buildPart(const mcIdType *start, con MEDCouplingMesh *MEDCouplingStructuredMesh::buildPartAndReduceNodes(const mcIdType *start, const mcIdType *end, DataArrayIdType*& arr) const { - std::vector cgs(getCellGridStructure()); + std::vector const cgs(getCellGridStructure()); std::vector< std::pair > cellPartFormat,nodePartFormat; if(IsPartStructured(start,end,cgs,cellPartFormat)) { MCAuto ret(buildStructuredSubPart(cellPartFormat)); nodePartFormat=cellPartFormat; - for(std::vector< std::pair >::iterator it=nodePartFormat.begin();it!=nodePartFormat.end();it++) - (*it).second++; + for(auto & it : nodePartFormat) + it.second++; MCAuto tmp1(BuildExplicitIdsFrom(getNodeGridStructure(),nodePartFormat)); MCAuto tmp2(DataArrayIdType::New()); tmp2->alloc(getNumberOfNodes(),1); tmp2->fillWithValue(-1); @@ -440,7 +455,7 @@ MEDCouplingMesh *MEDCouplingStructuredMesh::buildPartAndReduceNodes(const mcIdTy } } -DataArrayIdType *MEDCouplingStructuredMesh::simplexize(int policy) +DataArrayIdType *MEDCouplingStructuredMesh::simplexize(int /*policy*/) { throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::simplexize : not available for Cartesian mesh !"); } @@ -459,7 +474,7 @@ MEDCouplingFieldDouble *MEDCouplingStructuredMesh::buildOrthogonalField() const throw INTERP_KERNEL::Exception("Expected a MEDCouplingStructuredMesh with meshDim == 2 !"); MCAuto ret(MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME)); MCAuto array(DataArrayDouble::New()); - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbOfCells=getNumberOfCells(); array->alloc(nbOfCells,3); double *vals(array->getPointer()); for(mcIdType i=0;i ngs(getNodeGridStructure()); - int dim(getSpaceDimension()); + std::vector const ngs(getNodeGridStructure()); + int const dim(getSpaceDimension()); switch(dim) { case 1: @@ -488,7 +503,7 @@ void MEDCouplingStructuredMesh::getReverseNodalConnectivity(DataArrayIdType *rev void MEDCouplingStructuredMesh::GetReverseNodalConnectivity1(const std::vector& ngs, DataArrayIdType *revNodal, DataArrayIdType *revNodalIndx) { - mcIdType nbNodes(ngs[0]); + mcIdType const nbNodes(ngs[0]); revNodalIndx->alloc(nbNodes+1,1); if(nbNodes==0) { revNodal->alloc(0,1); revNodalIndx->setIJ(0,0,0); return ; } @@ -509,7 +524,7 @@ void MEDCouplingStructuredMesh::GetReverseNodalConnectivity1(const std::vector& ngs, DataArrayIdType *revNodal, DataArrayIdType *revNodalIndx) { mcIdType nbNodesX(ngs[0]),nbNodesY(ngs[1]); - mcIdType nbNodes(nbNodesX*nbNodesY); + mcIdType const nbNodes(nbNodesX*nbNodesY); if(nbNodesX==0 || nbNodesY==0) { revNodal->alloc(0,1); revNodalIndx->setIJ(0,0,0); return ; } if(nbNodesX==1 || nbNodesY==1) @@ -539,7 +554,7 @@ void MEDCouplingStructuredMesh::GetReverseNodalConnectivity2(const std::vector& ngs, DataArrayIdType *revNodal, DataArrayIdType *revNodalIndx) { mcIdType nbNodesX(ngs[0]),nbNodesY(ngs[1]),nbNodesZ(ngs[2]); - mcIdType nbNodes(nbNodesX*nbNodesY*nbNodesZ); + mcIdType const nbNodes(nbNodesX*nbNodesY*nbNodesZ); if(nbNodesX==0 || nbNodesY==0 || nbNodesZ==0) { revNodal->alloc(0,1); revNodalIndx->setIJ(0,0,0); return ; } if(nbNodesX==1 || nbNodesY==1 || nbNodesZ==1) @@ -581,15 +596,15 @@ void MEDCouplingStructuredMesh::GetReverseNodalConnectivity3(const std::vector= 0 !"); - std::size_t dim(st.size()); + std::size_t const dim(st.size()); MCAuto ret(DataArrayIdType::New()); switch(dim) { @@ -686,7 +701,7 @@ DataArrayIdType *MEDCouplingStructuredMesh::ComputeCornersGhost(const std::vecto mcIdType *ptr(ret->getPointer()); for(mcIdType i=0;i= 0 !"); for(mcIdType i=0;i= 0 !"); ret->alloc(8*ghostLev,1); mcIdType *ptr(ret->getPointer()); - mcIdType zeOffsetZ((offsetX+2*ghostLev)*(offsetY+2*ghostLev)); + mcIdType const zeOffsetZ((offsetX+2*ghostLev)*(offsetY+2*ghostLev)); for(mcIdType i=0;i >::const_iterator it=partCompactFormat.begin();it!=partCompactFormat.end();it++,ii++) + for(auto it=partCompactFormat.begin();it!=partCompactFormat.end();it++,ii++) { mcIdType a((*it).first),b((*it).second); if(a<0 || b<0 || b-a<0) @@ -770,11 +785,11 @@ mcIdType MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(const std::vect { mcIdType ret(1); bool isFetched(false); - for(std::size_t i=0;i >& partCompactFormat, int& axisId, mcIdType& sizeOfRange) { - mcIdType dim(ToIdType(partCompactFormat.size())); + mcIdType const dim(ToIdType(partCompactFormat.size())); mcIdType ret(-1); for(int i=0;i dims(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(partCompactFormat)); + std::vector const dims(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(partCompactFormat)); mcIdType i(0); - for(std::vector< std::pair >::iterator it=partCompactFormat.begin();it!=partCompactFormat.end();it++,i++) + for(auto it=partCompactFormat.begin();it!=partCompactFormat.end();it++,i++) { if(st[i] > MEDCouplingStructuredMesh::ComputeSignaturePerAxisOf(const std::vector& st, const std::vector& crit) { - std::size_t dim(st.size()); + std::size_t const dim(st.size()); std::vector< std::vector > ret(dim); switch(dim) { case 1: { - mcIdType nx(st[0]); + mcIdType const nx(st[0]); ret[0].resize(nx); std::vector& retX(ret[0]); for(mcIdType i=0;i > MEDCouplingStructuredMesh::ComputeSignature mcIdType cnt(0); for(mcIdType k=0;k > MEDCouplingStructuredMesh::ComputeSignature mcIdType cnt(0),offy(j*nx); for(mcIdType k=0;k > MEDCouplingStructuredMesh::ComputeSignature mcIdType cnt(0),offz(k*nx*ny); for(mcIdType j=0;j > MEDCouplingStructuredMesh::ComputeSignature DataArrayIdType *MEDCouplingStructuredMesh::Build1GTNodalConnectivity1D(const mcIdType *nodeStBg) { - mcIdType nbOfCells=*nodeStBg-1; + mcIdType const nbOfCells=*nodeStBg-1; MCAuto conn(DataArrayIdType::New()); conn->alloc(2*nbOfCells,1); mcIdType *cp=conn->getPointer(); @@ -1006,7 +1021,7 @@ DataArrayIdType *MEDCouplingStructuredMesh::Build1GTNodalConnectivity3D(const mc for(mcIdType j=0;j3 || spaceDim<1) throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::ZipNodeStructure : spaceDim must in [1,2,3] !"); zipNodeSt[0]=0; zipNodeSt[1]=0; zipNodeSt[2]=0; int zippedI(0); for(std::size_t i=0;i ngs(2); mcIdType n0(nodeStBg[0]-1),n1(nodeStBg[1]-1); ngs[0]=n0; ngs[1]=n1; - mcIdType off0(nodeStBg[0]); + mcIdType const off0(nodeStBg[0]); MCAuto conn(DataArrayIdType::New()); conn->alloc(2*GetNumberOfCellsOfSubLevelMesh(ngs,2)); mcIdType *cp(conn->getPointer()); @@ -1215,7 +1230,7 @@ mcIdType MEDCouplingStructuredMesh::getCellIdFromPos(mcIdType i, mcIdType j, mcI { mcIdType tmp[3]={i,j,k}; mcIdType tmp2[3]; - mcIdType meshDim(getMeshDimension()); + mcIdType const meshDim(getMeshDimension()); getSplitCellValues(tmp2); std::transform(tmp,tmp+meshDim,tmp2,tmp,std::multiplies()); return std::accumulate(tmp,tmp+meshDim,0); @@ -1232,7 +1247,7 @@ mcIdType MEDCouplingStructuredMesh::getNodeIdFromPos(mcIdType i, mcIdType j, mcI { mcIdType tmp[3]={i,j,k}; mcIdType tmp2[3]; - mcIdType spaceDim(getSpaceDimension()); + mcIdType const spaceDim(getSpaceDimension()); getSplitNodeValues(tmp2); std::transform(tmp,tmp+spaceDim,tmp2,tmp,std::multiplies()); return std::accumulate(tmp,tmp+spaceDim,0); @@ -1247,7 +1262,7 @@ mcIdType MEDCouplingStructuredMesh::getNumberOfCells() const std::size_t ii(0); for(std::vector::const_iterator it=ngs.begin();it!=ngs.end();it++,ii++) { - mcIdType elt(*it); + mcIdType const elt(*it); if(elt<=0) { std::ostringstream oss; oss << "MEDCouplingStructuredMesh::getNumberOfCells : at pos #" << ii << " the number of nodes in nodeStructure is " << *it << " ! Must be > 0 !"; @@ -1264,10 +1279,10 @@ mcIdType MEDCouplingStructuredMesh::getNumberOfCells() const mcIdType MEDCouplingStructuredMesh::getNumberOfNodes() const { - std::vector ngs(getNodeGridStructure()); + std::vector const ngs(getNodeGridStructure()); mcIdType ret(1); - for(std::vector::const_iterator it=ngs.begin();it!=ngs.end();it++) - ret*=*it; + for(long const ng : ngs) + ret*=ng; return ret; } @@ -1280,10 +1295,10 @@ mcIdType MEDCouplingStructuredMesh::getNumberOfNodes() const */ std::vector MEDCouplingStructuredMesh::getLocationFromCellId(mcIdType cellId) const { - int meshDim(getMeshDimension()); + int const meshDim(getMeshDimension()); std::vector ret(meshDim); std::vector struc(getCellGridStructure()); - mcIdType nbCells(std::accumulate(struc.begin(),struc.end(),1,std::multiplies())); + mcIdType const nbCells(std::accumulate(struc.begin(),struc.end(),1,std::multiplies())); if(cellId<0 || cellId>=nbCells) { std::ostringstream oss; oss << "MEDCouplingStructuredMesh::getLocationFromCellId : Input cell id (" << cellId << ") is invalid ! Should be in [0," << nbCells << ") !"; @@ -1303,10 +1318,10 @@ std::vector MEDCouplingStructuredMesh::getLocationFromCellId(mcIdType */ std::vector MEDCouplingStructuredMesh::getLocationFromNodeId(mcIdType nodeId) const { - int spaceDim(getSpaceDimension()); + int const spaceDim(getSpaceDimension()); std::vector ret(spaceDim); std::vector struc(getNodeGridStructure()); - mcIdType nbNodes(std::accumulate(struc.begin(),struc.end(),1,std::multiplies())); + mcIdType const nbNodes(std::accumulate(struc.begin(),struc.end(),1,std::multiplies())); if(nodeId<0 || nodeId>=nbNodes) { std::ostringstream oss; oss << "MEDCouplingStructuredMesh::getLocationFromNodeId : Input node id (" << nodeId << ") is invalid ! Should be in [0," << nbNodes << ") !"; @@ -1322,7 +1337,7 @@ void MEDCouplingStructuredMesh::GetPosFromId(mcIdType eltId, int meshDim, const mcIdType work(eltId); for(int i=meshDim-1;i>=0;i--) { - mcIdType pos=work/split[i]; + mcIdType const pos=work/split[i]; work=work%split[i]; res[i]=pos; } @@ -1343,7 +1358,7 @@ double MEDCouplingStructuredMesh::computeSquareness() const std::vector cgs(getCellGridStructure()); if(cgs.empty()) throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::computeSquareness : empty mesh !"); - std::size_t dim(cgs.size()); + std::size_t const dim(cgs.size()); if(dim==1) throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::computeSquareness : A segment cannot be square !"); if(dim<4) @@ -1365,7 +1380,7 @@ double MEDCouplingStructuredMesh::computeSquareness() const */ std::vector MEDCouplingStructuredMesh::GetSplitVectFromStruct(const std::vector& strct) { - std::size_t spaceDim(strct.size()); + std::size_t const spaceDim(strct.size()); std::vector res(spaceDim); for(std::size_t l=0;l MEDCouplingStructuredMesh::GetSplitVectFromStruct(const st */ bool MEDCouplingStructuredMesh::IsPartStructured(const mcIdType *startIds, const mcIdType *stopIds, const std::vector& st, std::vector< std::pair >& partCompactFormat) { - int dim((int)st.size()); + int const dim((int)st.size()); partCompactFormat.resize(dim); if(dim<1 || dim>3) throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::isPartStructured : input structure must be of dimension in [1,2,3] !"); std::vector tmp2(dim),tmp(dim),tmp3(dim),tmp4(dim); tmp2[0]=1; for(int i=1;i MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(co */ std::vector< std::pair > MEDCouplingStructuredMesh::GetCompactFrmtFromDimensions(const std::vector& dims) { - std::size_t sz(dims.size()); + std::size_t const sz(dims.size()); std::vector< std::pair > ret(sz); for(std::size_t i=0;i > MEDCouplingStructuredMesh::GetCompac */ std::vector< std::pair > MEDCouplingStructuredMesh::IntersectRanges(const std::vector< std::pair >& r1, const std::vector< std::pair >& r2) { - std::size_t sz(r1.size()); + std::size_t const sz(r1.size()); if(sz!=r2.size()) throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::IntersectRanges : the two ranges must have the same dimension !"); std::vector< std::pair > ret(sz); @@ -1555,7 +1570,7 @@ std::vector< std::pair > MEDCouplingStructuredMesh::Intersect */ bool MEDCouplingStructuredMesh::AreRangesIntersect(const std::vector< std::pair >& r1, const std::vector< std::pair >& r2) { - std::size_t sz(r1.size()); + std::size_t const sz(r1.size()); if(sz!=r2.size()) throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::AreRangesIntersect : the two ranges must have the same dimension !"); for(std::size_t i=0;i& st, { for(mcIdType i=0;i& st, { for(mcIdType j=0;j dims(GetDimensionsFromCompactFrmt(partCompactFormat)); - mcIdType nbOfTuplesOfOutField(DeduceNumberOfGivenStructure(dims)); + mcIdType const nbOfTuplesOfOutField(DeduceNumberOfGivenStructure(dims)); fieldOut.resize(nbOfTuplesOfOutField); mcIdType it(0); switch(st.size()) @@ -1661,10 +1676,10 @@ void MEDCouplingStructuredMesh::ExtractFieldOfBoolFrom(const std::vectorgetNumberOfTuples()!=DeduceNumberOfGivenStructure(st)) throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::ExtractFieldOfDoubleFrom : invalid size of input array of double regarding the structure !"); std::vector dims(GetDimensionsFromCompactFrmt(partCompactFormat)); - mcIdType nbOfTuplesOfOutField(DeduceNumberOfGivenStructure(dims)); - std::size_t nbComp(fieldOfDbl->getNumberOfComponents()); + mcIdType const nbOfTuplesOfOutField(DeduceNumberOfGivenStructure(dims)); + std::size_t const nbComp(fieldOfDbl->getNumberOfComponents()); MCAuto ret(DataArrayDouble::New()); ret->alloc(nbOfTuplesOfOutField,nbComp); ret->copyStringInfoFrom(*fieldOfDbl); double *ptRet(ret->getPointer()); @@ -1724,10 +1739,10 @@ DataArrayDouble *MEDCouplingStructuredMesh::ExtractFieldOfDoubleFrom(const std:: { for(mcIdType i=0;i& st, DataArrayDouble *fieldOfDbl, const std::vector< std::pair >& partCompactFormat, const DataArrayDouble *other) {//to be optimized - std::vector facts(st.size(),1); + std::vector const facts(st.size(),1); MEDCouplingIMesh::CondenseFineToCoarse(st,other,partCompactFormat,facts,fieldOfDbl); } @@ -1780,7 +1795,7 @@ void MEDCouplingStructuredMesh::AssignPartOfFieldOfDoubleUsing(const std::vector */ void MEDCouplingStructuredMesh::ChangeReferenceFromGlobalOfCompactFrmt(const std::vector< std::pair >& bigInAbs, const std::vector< std::pair >& partOfBigInAbs, std::vector< std::pair >& partOfBigRelativeToBig, bool check) { - std::size_t dim(bigInAbs.size()); + std::size_t const dim(bigInAbs.size()); if(dim!=partOfBigInAbs.size()) throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::ChangeReferenceFromGlobalOfCompactFrmt : The size of parts (dimension) must be the same !"); partOfBigRelativeToBig.resize(dim); @@ -1819,7 +1834,7 @@ void MEDCouplingStructuredMesh::ChangeReferenceFromGlobalOfCompactFrmt(const std */ void MEDCouplingStructuredMesh::ChangeReferenceToGlobalOfCompactFrmt(const std::vector< std::pair >& bigInAbs, const std::vector< std::pair >& partOfBigRelativeToBig, std::vector< std::pair >& partOfBigInAbs, bool check) { - std::size_t dim(bigInAbs.size()); + std::size_t const dim(bigInAbs.size()); if(dim!=partOfBigRelativeToBig.size()) throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::ChangeReferenceToGlobalOfCompactFrmt : The size of parts (dimension) must be the same !"); partOfBigInAbs.resize(dim); @@ -1858,7 +1873,7 @@ void MEDCouplingStructuredMesh::ChangeReferenceToGlobalOfCompactFrmt(const std:: */ std::vector< std::pair > MEDCouplingStructuredMesh::TranslateCompactFrmt(const std::vector< std::pair >& part, const std::vector& translation) { - std::size_t sz(part.size()); + std::size_t const sz(part.size()); if(translation.size()!=sz) throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::TranslateCompactFrmt : the sizes are not equal !"); std::vector< std::pair > ret(sz); @@ -1875,7 +1890,7 @@ std::vector< std::pair > MEDCouplingStructuredMesh::Translate */ std::vector MEDCouplingStructuredMesh::FindTranslationFrom(const std::vector< std::pair >& startingFrom, const std::vector< std::pair >& goingTo) { - std::size_t sz(startingFrom.size()); + std::size_t const sz(startingFrom.size()); if(goingTo.size()!=sz) throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::FindTranslationFrom : the sizes are not equal !"); std::vector< mcIdType > ret(sz); @@ -1919,10 +1934,10 @@ DataArrayIdType *MEDCouplingStructuredMesh::BuildExplicitIdsFrom(const std::vect { for(mcIdType i=0;i& st, throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::MultiplyPartOf : invalid input range 3 !"); dims[i]=part[i].second-part[i].first; } - mcIdType nbOfTuplesExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(st)); - std::size_t nbCompo(da->getNumberOfComponents()); + mcIdType const nbOfTuplesExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(st)); + std::size_t const nbCompo(da->getNumberOfComponents()); if(da->getNumberOfTuples()!=nbOfTuplesExp) { std::ostringstream oss; oss << "MEDCouplingStructuredMesh::MultiplyPartOf : invalid nb of tuples ! Expected " << nbOfTuplesExp << " having " << da->getNumberOfTuples() << " !"; @@ -1992,13 +2007,13 @@ void MEDCouplingStructuredMesh::MultiplyPartOf(const std::vector& st, { for(mcIdType i=0;i(),std::placeholders::_1,factor)); } } @@ -2009,10 +2024,10 @@ void MEDCouplingStructuredMesh::MultiplyPartOf(const std::vector& st, { for(mcIdType j=0;j(),std::placeholders::_1,factor)); } } @@ -2022,7 +2037,7 @@ void MEDCouplingStructuredMesh::MultiplyPartOf(const std::vector& st, { for(mcIdType k=0;k(),std::placeholders::_1,factor)); } break; @@ -2066,7 +2081,7 @@ void MEDCouplingStructuredMesh::PutInGhostFormat(mcIdType ghostSize, const std:: { if(ghostSize<0) throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::PutInGhostFormat : ghost size must be >= 0 !"); - std::size_t dim(part.size()); + std::size_t const dim(part.size()); if(st.size()!=dim) throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::PutInGhostFormat : the dimension of input vectors must be the same !"); for(std::size_t i=0;i= 0 !"); - std::size_t sz(partBeforeFact.size()); + std::size_t const sz(partBeforeFact.size()); for(std::size_t i=0;i +#include +#include +#include +#include namespace MEDCoupling { @@ -31,39 +38,39 @@ namespace MEDCoupling class MEDCouplingStructuredMesh : public MEDCouplingMesh { public: - MEDCOUPLING_EXPORT INTERP_KERNEL::NormalizedCellType getTypeOfCell(mcIdType cellId) const; - MEDCOUPLING_EXPORT std::set getAllGeoTypes() const; - MEDCOUPLING_EXPORT mcIdType getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const; - MEDCOUPLING_EXPORT DataArrayIdType *giveCellsWithType(INTERP_KERNEL::NormalizedCellType type) const; - MEDCOUPLING_EXPORT DataArrayIdType *computeNbOfNodesPerCell() const; - MEDCOUPLING_EXPORT DataArrayIdType *computeNbOfFacesPerCell() const; - MEDCOUPLING_EXPORT DataArrayIdType *computeEffectiveNbOfNodesPerCell() const; + MEDCOUPLING_EXPORT INTERP_KERNEL::NormalizedCellType getTypeOfCell(mcIdType cellId) const override; + MEDCOUPLING_EXPORT std::set getAllGeoTypes() const override; + MEDCOUPLING_EXPORT mcIdType getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const override; + MEDCOUPLING_EXPORT DataArrayIdType *giveCellsWithType(INTERP_KERNEL::NormalizedCellType type) const override; + MEDCOUPLING_EXPORT DataArrayIdType *computeNbOfNodesPerCell() const override; + MEDCOUPLING_EXPORT DataArrayIdType *computeNbOfFacesPerCell() const override; + MEDCOUPLING_EXPORT DataArrayIdType *computeEffectiveNbOfNodesPerCell() const override; MEDCOUPLING_EXPORT std::vector getLocationFromCellId(mcIdType cellId) const; MEDCOUPLING_EXPORT std::vector getLocationFromNodeId(mcIdType nodeId) const; MEDCOUPLING_EXPORT static void GetPosFromId(mcIdType eltId, int meshDim, const mcIdType *split, mcIdType *res); MEDCOUPLING_EXPORT static INTERP_KERNEL::NormalizedCellType GetGeoTypeGivenMeshDimension( int meshDim); - MEDCOUPLING_EXPORT void getNodeIdsOfCell(mcIdType cellId, std::vector& conn) const; - MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; - MEDCOUPLING_EXPORT void copyTinyStringsFrom(const MEDCouplingMesh *other); - MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const; + MEDCOUPLING_EXPORT void getNodeIdsOfCell(mcIdType cellId, std::vector& conn) const override; + MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const override; + MEDCOUPLING_EXPORT void copyTinyStringsFrom(const MEDCouplingMesh *other) override; + MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const override; //tools - MEDCOUPLING_EXPORT std::vector getDistributionOfTypes() const; - MEDCOUPLING_EXPORT DataArrayIdType *checkTypeConsistencyAndContig(const std::vector& code, const std::vector& idsPerType) const; - MEDCOUPLING_EXPORT void splitProfilePerType(const DataArrayIdType *profile, std::vector& code, std::vector& idsInPflPerType, std::vector& idsPerType, bool smartPflKiller=true) const; + MEDCOUPLING_EXPORT std::vector getDistributionOfTypes() const override; + MEDCOUPLING_EXPORT DataArrayIdType *checkTypeConsistencyAndContig(const std::vector& code, const std::vector& idsPerType) const override; + MEDCOUPLING_EXPORT void splitProfilePerType(const DataArrayIdType *profile, std::vector& code, std::vector& idsInPflPerType, std::vector& idsPerType, bool smartPflKiller=true) const override; MEDCOUPLING_EXPORT MEDCoupling1SGTUMesh *build1SGTUnstructured() const; - MEDCOUPLING_EXPORT MEDCouplingUMesh *buildUnstructured() const; - MEDCOUPLING_EXPORT MEDCouplingMesh *buildPart(const mcIdType *start, const mcIdType *end) const; - MEDCOUPLING_EXPORT MEDCouplingMesh *buildPartAndReduceNodes(const mcIdType *start, const mcIdType *end, DataArrayIdType*& arr) const; - MEDCOUPLING_EXPORT DataArrayIdType *simplexize(int policy); - MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildOrthogonalField() const; - MEDCOUPLING_EXPORT void getReverseNodalConnectivity(DataArrayIdType *revNodal, DataArrayIdType *revNodalIndx) const; + MEDCOUPLING_EXPORT MEDCouplingUMesh *buildUnstructured() const override; + MEDCOUPLING_EXPORT MEDCouplingMesh *buildPart(const mcIdType *start, const mcIdType *end) const override; + MEDCOUPLING_EXPORT MEDCouplingMesh *buildPartAndReduceNodes(const mcIdType *start, const mcIdType *end, DataArrayIdType*& arr) const override; + MEDCOUPLING_EXPORT DataArrayIdType *simplexize(int policy) override; + MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildOrthogonalField() const override; + MEDCOUPLING_EXPORT void getReverseNodalConnectivity(DataArrayIdType *revNodal, DataArrayIdType *revNodalIndx) const override; //some useful methods MEDCOUPLING_EXPORT MEDCoupling1SGTUMesh *build1SGTSubLevelMesh() const; MEDCOUPLING_EXPORT mcIdType getCellIdFromPos(mcIdType i, mcIdType j, mcIdType k) const; MEDCOUPLING_EXPORT mcIdType getNodeIdFromPos(mcIdType i, mcIdType j, mcIdType k) const; - MEDCOUPLING_EXPORT mcIdType getNumberOfCells() const; - MEDCOUPLING_EXPORT mcIdType getNumberOfNodes() const; - MEDCOUPLING_EXPORT int getMeshDimension() const; + MEDCOUPLING_EXPORT mcIdType getNumberOfCells() const override; + MEDCOUPLING_EXPORT mcIdType getNumberOfNodes() const override; + MEDCOUPLING_EXPORT int getMeshDimension() const override; MEDCOUPLING_EXPORT mcIdType getNumberOfCellsOfSubLevelMesh() const; MEDCOUPLING_EXPORT int getSpaceDimensionOnNodeStruct() const; MEDCOUPLING_EXPORT virtual void getNodeGridStructure(mcIdType *res) const = 0; @@ -118,7 +125,7 @@ namespace MEDCoupling protected: MEDCOUPLING_EXPORT MEDCouplingStructuredMesh(); MEDCOUPLING_EXPORT MEDCouplingStructuredMesh(const MEDCouplingStructuredMesh& other, bool deepCpy); - MEDCOUPLING_EXPORT ~MEDCouplingStructuredMesh(); + MEDCOUPLING_EXPORT ~MEDCouplingStructuredMesh() override; }; } diff --git a/src/MEDCoupling/MEDCouplingTimeDiscretization.cxx b/src/MEDCoupling/MEDCouplingTimeDiscretization.cxx index d01ce7784..ebeefe662 100644 --- a/src/MEDCoupling/MEDCouplingTimeDiscretization.cxx +++ b/src/MEDCoupling/MEDCouplingTimeDiscretization.cxx @@ -19,13 +19,22 @@ // Author : Anthony Geay (CEA/DEN) #include "MEDCouplingTimeDiscretization.txx" + #include "MCAuto.hxx" +#include "MCIdType.hxx" +#include "MCType.hxx" #include "MEDCouplingMemArray.hxx" #include "MEDCouplingMesh.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include "MEDCouplingTimeLabel.hxx" -#include +#include +#include #include #include +#include +#include +#include using namespace MEDCoupling; @@ -72,9 +81,9 @@ bool MEDCouplingTimeDiscretization::areCompatibleForMeld(const MEDCouplingTimeDi { if(std::fabs(_time_tolerance-other->_time_tolerance)>1.e-16) return false; - if(_array==0 && other->_array==0) + if(_array==nullptr && other->_array==nullptr) return true; - if(_array==0 || other->_array==0) + if(_array==nullptr || other->_array==nullptr) return false; if(_array->getNumberOfTuples()!=other->_array->getNumberOfTuples()) return false; @@ -114,23 +123,23 @@ MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::buildNewTimeReprFr MCAuto arr; if(arrSrc) arr=arrSrc->performCopyOrIncrRef(deepCopy); - ret->setArray(arr,0); + ret->setArray(arr,nullptr); return ret; } bool MEDCouplingTimeDiscretization::isBefore(const MEDCouplingTimeDiscretization *other) const { int iteration,order; - double time1=getEndTime(iteration,order)-_time_tolerance; - double time2=other->getStartTime(iteration,order)+other->getTimeTolerance(); + double const time1=getEndTime(iteration,order)-_time_tolerance; + double const time2=other->getStartTime(iteration,order)+other->getTimeTolerance(); return time1<=time2; } bool MEDCouplingTimeDiscretization::isStrictlyBefore(const MEDCouplingTimeDiscretization *other) const { int iteration,order; - double time1=getEndTime(iteration,order)+_time_tolerance; - double time2=other->getStartTime(iteration,order)-other->getTimeTolerance(); + double const time1=getEndTime(iteration,order)+_time_tolerance; + double const time2=other->getStartTime(iteration,order)-other->getTimeTolerance(); return time1 arrays3(arrays.size()); for(std::size_t j=0;jsetArrays(arrays3,0); + ret->setArrays(arrays3,nullptr); return ret; } @@ -168,7 +177,7 @@ MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::doublyContractedPr std::vector arrays3(arrays.size()); for(std::size_t j=0;jsetArrays(arrays3,0); + ret->setArrays(arrays3,nullptr); return ret; } @@ -187,7 +196,7 @@ MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::determinant() cons arrays3[j]=arrays2[j]; MEDCouplingTimeDiscretization *ret(MEDCouplingTimeDiscretization::New(getEnum())); ret->setTimeUnit(getTimeUnit()); - ret->setArrays(arrays3,0); + ret->setArrays(arrays3,nullptr); return ret; } @@ -206,7 +215,7 @@ MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::eigenValues() cons arrays3[j]=arrays2[j]; MEDCouplingTimeDiscretization *ret(MEDCouplingTimeDiscretization::New(getEnum())); ret->setTimeUnit(getTimeUnit()); - ret->setArrays(arrays3,0); + ret->setArrays(arrays3,nullptr); return ret; } @@ -225,7 +234,7 @@ MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::eigenVectors() con arrays3[j]=arrays2[j]; MEDCouplingTimeDiscretization *ret(MEDCouplingTimeDiscretization::New(getEnum())); ret->setTimeUnit(getTimeUnit()); - ret->setArrays(arrays3,0); + ret->setArrays(arrays3,nullptr); return ret; } @@ -244,7 +253,7 @@ MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::inverse() const arrays3[j]=arrays2[j]; MEDCouplingTimeDiscretization *ret(MEDCouplingTimeDiscretization::New(getEnum())); ret->setTimeUnit(getTimeUnit()); - ret->setArrays(arrays3,0); + ret->setArrays(arrays3,nullptr); return ret; } @@ -263,7 +272,7 @@ MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::trace() const arrays3[j]=arrays2[j]; MEDCouplingTimeDiscretization *ret(MEDCouplingTimeDiscretization::New(getEnum())); ret->setTimeUnit(getTimeUnit()); - ret->setArrays(arrays3,0); + ret->setArrays(arrays3,nullptr); return ret; } @@ -282,7 +291,7 @@ MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::deviator() const arrays3[j]=arrays2[j]; MEDCouplingTimeDiscretization *ret(MEDCouplingTimeDiscretization::New(getEnum())); ret->setTimeUnit(getTimeUnit()); - ret->setArrays(arrays3,0); + ret->setArrays(arrays3,nullptr); return ret; } @@ -301,7 +310,7 @@ MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::magnitude() const arrays3[j]=arrays2[j]; MEDCouplingTimeDiscretization *ret(MEDCouplingTimeDiscretization::New(getEnum())); ret->setTimeUnit(getTimeUnit()); - ret->setArrays(arrays3,0); + ret->setArrays(arrays3,nullptr); return ret; } @@ -320,7 +329,7 @@ MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::negate() const arrays3[j]=arrays2[j]; MEDCouplingTimeDiscretization *ret(MEDCouplingTimeDiscretization::New(getEnum())); ret->setTimeUnit(getTimeUnit()); - ret->setArrays(arrays3,0); + ret->setArrays(arrays3,nullptr); return ret; } @@ -339,7 +348,7 @@ MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::maxPerTuple() cons arrays3[j]=arrays2[j]; MEDCouplingTimeDiscretization *ret(MEDCouplingTimeDiscretization::New(getEnum())); ret->setTimeUnit(getTimeUnit()); - ret->setArrays(arrays3,0); + ret->setArrays(arrays3,nullptr); return ret; } @@ -358,7 +367,7 @@ MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::keepSelectedCompon arrays3[j]=arrays2[j]; MEDCouplingTimeDiscretization *ret(MEDCouplingTimeDiscretization::New(getEnum())); ret->setTimeUnit(getTimeUnit()); - ret->setArrays(arrays3,0); + ret->setArrays(arrays3,nullptr); return ret; } @@ -371,9 +380,9 @@ void MEDCouplingTimeDiscretization::setSelectedComponents(const MEDCouplingTimeD throw INTERP_KERNEL::Exception("TimeDiscretization::setSelectedComponents : number of arrays mismatch !"); for(std::size_t i=0;isetSelectedComponents(arrays2[i],compoIds); - else if(arrays1[i]!=0 || arrays2[i]!=0) + else if(arrays1[i]!=nullptr || arrays2[i]!=nullptr) throw INTERP_KERNEL::Exception("TimeDiscretization::setSelectedComponents : some time array in correspondence are not defined symmetrically !"); } } @@ -391,17 +400,17 @@ void MEDCouplingTimeDiscretization::changeNbOfComponents(std::size_t newNbOfComp std::vector arrays3(arrays.size()); for(std::size_t j=0;j arrays; getArrays(arrays); - for(std::size_t j=0;jsortPerTuple(asc); + if(array) + array->sortPerTuple(asc); } } @@ -427,7 +436,7 @@ void MEDCouplingTimeDiscretization::setUniformValue(mcIdType nbOfTuple, int nbOf std::vector arrays3(arrays.size()); for(std::size_t j=0;j arrays3(arrays.size()); for(std::size_t j=0;j arrays; getArrays(arrays); - for(std::size_t j=0;japplyLin(a,b,compoId); + if(array) + array->applyLin(a,b,compoId); } } @@ -475,10 +484,10 @@ void MEDCouplingTimeDiscretization::applyLin(double a, double b) { std::vector arrays; getArrays(arrays); - for(std::size_t j=0;japplyLin(a,b); + if(array) + array->applyLin(a,b); } } @@ -495,7 +504,7 @@ void MEDCouplingTimeDiscretization::applyFunc(int nbOfComp, FunctionToEvaluate f std::vector arrays3(arrays.size()); for(std::size_t j=0;japplyFunc(nbOfComp,func); else - arrays2[j]=0; + arrays2[j]=nullptr; } std::vector arrays3(arrays.size()); for(std::size_t j=0;j arrays3(arrays.size()); for(std::size_t j=0;j& varsOrder, const std::string& func) @@ -545,7 +554,7 @@ void MEDCouplingTimeDiscretization::applyFuncNamedCompo(int nbOfComp, const std: std::vector arrays3(arrays.size()); for(std::size_t j=0;j arrays3(arrays.size()); for(std::size_t j=0;j arrays; getArrays(arrays); - for(std::size_t j=0;japplyFuncFast32(func); + if(array) + array->applyFuncFast32(func); } } @@ -579,10 +588,10 @@ void MEDCouplingTimeDiscretization::applyFuncFast64(const std::string& func) { std::vector arrays; getArrays(arrays); - for(std::size_t j=0;japplyFuncFast64(func); + if(array) + array->applyFuncFast64(func); } } @@ -596,7 +605,7 @@ void MEDCouplingTimeDiscretization::fillFromAnalytic(const DataArrayDouble *loc, std::vector arrays3(arrays.size()); for(std::size_t j=0;j arrays3(arrays.size()); for(std::size_t j=0;j arrays3(arrays.size()); for(std::size_t j=0;j& varsOrder, const std::string& func) @@ -635,7 +644,7 @@ void MEDCouplingTimeDiscretization::fillFromAnalyticNamedCompo(const DataArrayDo std::vector arrays3(arrays.size()); for(std::size_t j=0;j(other)); + const auto *otherC(dynamic_cast(other)); if(!otherC) throw INTERP_KERNEL::Exception("isEqualIfNotWhy : other is not a MEDCouplingTimeDiscretizationInt32 !"); if(!MEDCouplingTimeDiscretizationTemplate::areStrictlyCompatible(other,reason)) @@ -739,7 +748,7 @@ bool MEDCouplingTimeDiscretizationInt32::isEqualWithoutConsideringStr(const MEDC { if(prec!=0) throw INTERP_KERNEL::Exception("MEDCouplingTimeDiscretizationInt32::isEqualWithoutConsideringStr : only precision 0 is supported !"); - const MEDCouplingTimeDiscretizationInt32 *otherC(dynamic_cast(other)); + const auto *otherC(dynamic_cast(other)); if(!otherC) throw INTERP_KERNEL::Exception("isEqualWithoutConsideringStr : other is not a MEDCouplingTimeDiscretizationInt !"); std::string tmp; @@ -784,7 +793,7 @@ bool MEDCouplingTimeDiscretizationInt64::isEqualIfNotWhy(const MEDCouplingTimeDi reason="Time discretization is NULL."; return false; } - const MEDCouplingTimeDiscretizationInt64 *otherC(dynamic_cast(other)); + const auto *otherC(dynamic_cast(other)); if(!otherC) throw INTERP_KERNEL::Exception("isEqualIfNotWhy : other is not a MEDCouplingTimeDiscretizationInt64 !"); if(!MEDCouplingTimeDiscretizationTemplate::areStrictlyCompatible(other,reason)) @@ -800,7 +809,7 @@ bool MEDCouplingTimeDiscretizationInt64::isEqualWithoutConsideringStr(const MEDC { if(prec!=0) throw INTERP_KERNEL::Exception("MEDCouplingTimeDiscretizationInt64::isEqualWithoutConsideringStr : only precision 0 is supported !"); - const MEDCouplingTimeDiscretizationInt64 *otherC(dynamic_cast(other)); + const auto *otherC(dynamic_cast(other)); if(!otherC) throw INTERP_KERNEL::Exception("isEqualWithoutConsideringStr : other is not a MEDCouplingTimeDiscretizationInt !"); std::string tmp; @@ -843,7 +852,7 @@ bool MEDCouplingTimeDiscretizationFloat::isEqualIfNotWhy(const MEDCouplingTimeDi reason="Time discretization is NULL."; return false; } - const MEDCouplingTimeDiscretizationFloat *otherC(dynamic_cast(other)); + const auto *otherC(dynamic_cast(other)); if(!otherC) throw INTERP_KERNEL::Exception("isEqualIfNotWhy : other is not a MEDCouplingTimeDiscretizationFloat !"); if(!MEDCouplingTimeDiscretizationTemplate::areStrictlyCompatible(other,reason)) @@ -859,7 +868,7 @@ bool MEDCouplingTimeDiscretizationFloat::isEqualWithoutConsideringStr(const MEDC { if(prec!=0) throw INTERP_KERNEL::Exception("MEDCouplingTimeDiscretizationFloat::isEqualWithoutConsideringStr : only precision 0 is supported !"); - const MEDCouplingTimeDiscretizationFloat *otherC(dynamic_cast(other)); + const auto *otherC(dynamic_cast(other)); if(!otherC) throw INTERP_KERNEL::Exception("isEqualWithoutConsideringStr : other is not a MEDCouplingTimeDiscretizationFloat !"); std::string tmp; @@ -876,8 +885,7 @@ bool MEDCouplingTimeDiscretizationFloat::isEqualWithoutConsideringStr(const MEDC //////////////////////// MEDCouplingNoTimeLabel::MEDCouplingNoTimeLabel() -{ -} += default; MEDCouplingNoTimeLabel::MEDCouplingNoTimeLabel(const MEDCouplingTimeDiscretization& other, bool deepCopy):MEDCouplingTimeDiscretization(other,deepCopy) { @@ -891,7 +899,7 @@ std::string MEDCouplingNoTimeLabel::getStringRepr() const return stream.str(); } -void MEDCouplingNoTimeLabel::synchronizeTimeWith(const MEDCouplingMesh *mesh) +void MEDCouplingNoTimeLabel::synchronizeTimeWith(const MEDCouplingMesh * /*mesh*/) { throw INTERP_KERNEL::Exception("MEDCouplingNoTimeLabel::synchronizeTimeWith : impossible to synchronize time with a MEDCouplingMesh because the time discretization is incompatible with it !"); } @@ -900,16 +908,16 @@ bool MEDCouplingNoTimeLabel::areCompatible(const MEDCouplingTimeDiscretizationTe { if(!MEDCouplingTimeDiscretization::areCompatible(other)) return false; - const MEDCouplingNoTimeLabel *otherC(dynamic_cast(other)); - return otherC!=0; + const auto *otherC(dynamic_cast(other)); + return otherC!=nullptr; } bool MEDCouplingNoTimeLabel::areStrictlyCompatible(const MEDCouplingTimeDiscretizationTemplate *other, std::string& reason) const { if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other,reason)) return false; - const MEDCouplingNoTimeLabel *otherC(dynamic_cast(other)); - bool ret=otherC!=0; + const auto *otherC(dynamic_cast(other)); + bool const ret=otherC!=nullptr; if(!ret) reason.insert(0,"time discretization of this is NO_TIME, other has a different time discretization."); return ret; @@ -919,29 +927,29 @@ bool MEDCouplingNoTimeLabel::areStrictlyCompatibleForMul(const MEDCouplingTimeDi { if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(other)) return false; - const MEDCouplingNoTimeLabel *otherC(dynamic_cast(other)); - return otherC!=0; + const auto *otherC(dynamic_cast(other)); + return otherC!=nullptr; } bool MEDCouplingNoTimeLabel::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretizationTemplate *other) const { if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other)) return false; - const MEDCouplingNoTimeLabel *otherC(dynamic_cast(other)); - return otherC!=0; + const auto *otherC(dynamic_cast(other)); + return otherC!=nullptr; } bool MEDCouplingNoTimeLabel::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const { if(!MEDCouplingTimeDiscretization::areCompatibleForMeld(other)) return false; - const MEDCouplingNoTimeLabel *otherC(dynamic_cast(other)); - return otherC!=0; + const auto *otherC(dynamic_cast(other)); + return otherC!=nullptr; } bool MEDCouplingNoTimeLabel::isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate *other, double prec, std::string& reason) const { - const MEDCouplingNoTimeLabel *otherC(dynamic_cast(other)); + const auto *otherC(dynamic_cast(other)); if(!otherC) { reason="This has time discretization NO_TIME, other not."; @@ -952,7 +960,7 @@ bool MEDCouplingNoTimeLabel::isEqualIfNotWhy(const MEDCouplingTimeDiscretization bool MEDCouplingNoTimeLabel::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate *other, double prec) const { - const MEDCouplingNoTimeLabel *otherC(dynamic_cast(other)); + const auto *otherC(dynamic_cast(other)); if(!otherC) return false; return MEDCouplingTimeDiscretization::isEqualWithoutConsideringStr(other,prec); @@ -960,12 +968,12 @@ bool MEDCouplingNoTimeLabel::isEqualWithoutConsideringStr(const MEDCouplingTimeD MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::aggregate(const MEDCouplingTimeDiscretization *other) const { - const MEDCouplingNoTimeLabel *otherC(dynamic_cast(other)); + const auto *otherC(dynamic_cast(other)); if(!otherC) throw INTERP_KERNEL::Exception("NoTimeLabel::aggregation on mismatched time discretization !"); MCAuto arr(DataArrayDouble::Aggregate(getArray(),other->getArray())); - MEDCouplingNoTimeLabel *ret(new MEDCouplingNoTimeLabel); - ret->setArray(arr,0); + auto *ret(new MEDCouplingNoTimeLabel); + ret->setArray(arr,nullptr); return ret; } @@ -973,89 +981,89 @@ MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::aggregate(const std::vect { std::vector a(other.size()); int i=0; - for(std::vector::const_iterator it=other.begin();it!=other.end();it++,i++) + for(auto it=other.begin();it!=other.end();it++,i++) { - const MEDCouplingNoTimeLabel *itC=dynamic_cast(*it); + const auto *itC=dynamic_cast(*it); if(!itC) throw INTERP_KERNEL::Exception("NoTimeLabel::aggregate on mismatched time discretization !"); a[i]=itC->getArray(); } MCAuto arr(DataArrayDouble::Aggregate(a)); - MEDCouplingNoTimeLabel *ret(new MEDCouplingNoTimeLabel); - ret->setArray(arr,0); + auto *ret(new MEDCouplingNoTimeLabel); + ret->setArray(arr,nullptr); return ret; } MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::meld(const MEDCouplingTimeDiscretization *other) const { - const MEDCouplingNoTimeLabel *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("NoTimeLabel::meld on mismatched time discretization !"); MCAuto arr=DataArrayDouble::Meld(getArray(),other->getArray()); - MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel; + auto *ret=new MEDCouplingNoTimeLabel; ret->setTimeTolerance(getTimeTolerance()); - ret->setArray(arr,0); + ret->setArray(arr,nullptr); return ret; } MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::dot(const MEDCouplingTimeDiscretization *other) const { - const MEDCouplingNoTimeLabel *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("NoTimeLabel::dot on mismatched time discretization !"); MCAuto arr=DataArrayDouble::Dot(getArray(),other->getArray()); - MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel; - ret->setArray(arr,0); + auto *ret=new MEDCouplingNoTimeLabel; + ret->setArray(arr,nullptr); return ret; } MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::crossProduct(const MEDCouplingTimeDiscretization *other) const { - const MEDCouplingNoTimeLabel *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("NoTimeLabel::crossProduct on mismatched time discretization !"); MCAuto arr=DataArrayDouble::CrossProduct(getArray(),other->getArray()); - MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel; - ret->setArray(arr,0); + auto *ret=new MEDCouplingNoTimeLabel; + ret->setArray(arr,nullptr); return ret; } MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::max(const MEDCouplingTimeDiscretization *other) const { - const MEDCouplingNoTimeLabel *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("NoTimeLabel::max on mismatched time discretization !"); MCAuto arr=DataArrayDouble::Max(getArray(),other->getArray()); - MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel; - ret->setArray(arr,0); + auto *ret=new MEDCouplingNoTimeLabel; + ret->setArray(arr,nullptr); return ret; } MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::min(const MEDCouplingTimeDiscretization *other) const { - const MEDCouplingNoTimeLabel *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("NoTimeLabel::max on mismatched time discretization !"); MCAuto arr=DataArrayDouble::Min(getArray(),other->getArray()); - MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel; - ret->setArray(arr,0); + auto *ret=new MEDCouplingNoTimeLabel; + ret->setArray(arr,nullptr); return ret; } MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::add(const MEDCouplingTimeDiscretization *other) const { - const MEDCouplingNoTimeLabel *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("NoTimeLabel::add on mismatched time discretization !"); MCAuto arr=DataArrayDouble::Add(getArray(),other->getArray()); - MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel; - ret->setArray(arr,0); + auto *ret=new MEDCouplingNoTimeLabel; + ret->setArray(arr,nullptr); return ret; } void MEDCouplingNoTimeLabel::addEqual(const MEDCouplingTimeDiscretization *other) { - const MEDCouplingNoTimeLabel *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("NoTimeLabel::addEqual on mismatched time discretization !"); if(!getArray()) @@ -1065,20 +1073,20 @@ void MEDCouplingNoTimeLabel::addEqual(const MEDCouplingTimeDiscretization *other MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::substract(const MEDCouplingTimeDiscretization *other) const { - const MEDCouplingNoTimeLabel *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("NoTimeLabel::substract on mismatched time discretization !"); if(!getArray()) throw INTERP_KERNEL::Exception("MEDCouplingNoTimeLabel::substract : Data Array is NULL !"); MCAuto arr=DataArrayDouble::Substract(getArray(),other->getArray()); - MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel; - ret->setArray(arr,0); + auto *ret=new MEDCouplingNoTimeLabel; + ret->setArray(arr,nullptr); return ret; } void MEDCouplingNoTimeLabel::substractEqual(const MEDCouplingTimeDiscretization *other) { - const MEDCouplingNoTimeLabel *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("NoTimeLabel::substractEqual on mismatched time discretization !"); if(!getArray()) @@ -1088,18 +1096,18 @@ void MEDCouplingNoTimeLabel::substractEqual(const MEDCouplingTimeDiscretization MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::multiply(const MEDCouplingTimeDiscretization *other) const { - const MEDCouplingNoTimeLabel *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("NoTimeLabel::multiply on mismatched time discretization !"); MCAuto arr=DataArrayDouble::Multiply(getArray(),other->getArray()); - MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel; - ret->setArray(arr,0); + auto *ret=new MEDCouplingNoTimeLabel; + ret->setArray(arr,nullptr); return ret; } void MEDCouplingNoTimeLabel::multiplyEqual(const MEDCouplingTimeDiscretization *other) { - const MEDCouplingNoTimeLabel *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("NoTimeLabel::multiplyEqual on mismatched time discretization !"); if(!getArray()) @@ -1109,18 +1117,18 @@ void MEDCouplingNoTimeLabel::multiplyEqual(const MEDCouplingTimeDiscretization * MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::divide(const MEDCouplingTimeDiscretization *other) const { - const MEDCouplingNoTimeLabel *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("divide on mismatched time discretization !"); MCAuto arr=DataArrayDouble::Divide(getArray(),other->getArray()); - MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel; - ret->setArray(arr,0); + auto *ret=new MEDCouplingNoTimeLabel; + ret->setArray(arr,nullptr); return ret; } void MEDCouplingNoTimeLabel::divideEqual(const MEDCouplingTimeDiscretization *other) { - const MEDCouplingNoTimeLabel *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("NoTimeLabel::divideEqual on mismatched time discretization !"); if(!getArray()) @@ -1130,18 +1138,18 @@ void MEDCouplingNoTimeLabel::divideEqual(const MEDCouplingTimeDiscretization *ot MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::pow(const MEDCouplingTimeDiscretization *other) const { - const MEDCouplingNoTimeLabel *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("pow on mismatched time discretization !"); MCAuto arr=DataArrayDouble::Pow(getArray(),other->getArray()); - MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel; - ret->setArray(arr,0); + auto *ret=new MEDCouplingNoTimeLabel; + ret->setArray(arr,nullptr); return ret; } void MEDCouplingNoTimeLabel::powEqual(const MEDCouplingTimeDiscretization *other) { - const MEDCouplingNoTimeLabel *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("NoTimeLabel::powEqual on mismatched time discretization !"); if(!getArray()) @@ -1154,87 +1162,87 @@ MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::performCopyOrIncrRef(bool return new MEDCouplingNoTimeLabel(*this,deepCopy); } -void MEDCouplingNoTimeLabel::checkTimePresence(double time) const +void MEDCouplingNoTimeLabel::checkTimePresence(double /*time*/) const { throw INTERP_KERNEL::Exception(EXCEPTION_MSG); } -std::vector< const DataArrayDouble *> MEDCouplingNoTimeLabel::getArraysForTime(double time) const +std::vector< const DataArrayDouble *> MEDCouplingNoTimeLabel::getArraysForTime(double /*time*/) const { throw INTERP_KERNEL::Exception(EXCEPTION_MSG); } -void MEDCouplingNoTimeLabel::getValueForTime(double time, const std::vector& vals, double *res) const +void MEDCouplingNoTimeLabel::getValueForTime(double /*time*/, const std::vector& /*vals*/, double * /*res*/) const { throw INTERP_KERNEL::Exception(EXCEPTION_MSG); } -bool MEDCouplingNoTimeLabel::isBefore(const MEDCouplingTimeDiscretization *other) const +bool MEDCouplingNoTimeLabel::isBefore(const MEDCouplingTimeDiscretization * /*other*/) const { throw INTERP_KERNEL::Exception(EXCEPTION_MSG); } -bool MEDCouplingNoTimeLabel::isStrictlyBefore(const MEDCouplingTimeDiscretization *other) const +bool MEDCouplingNoTimeLabel::isStrictlyBefore(const MEDCouplingTimeDiscretization * /*other*/) const { throw INTERP_KERNEL::Exception(EXCEPTION_MSG); } -double MEDCouplingNoTimeLabel::getStartTime(int& iteration, int& order) const +double MEDCouplingNoTimeLabel::getStartTime(int& /*iteration*/, int& /*order*/) const { throw INTERP_KERNEL::Exception(EXCEPTION_MSG); } -double MEDCouplingNoTimeLabel::getEndTime(int& iteration, int& order) const +double MEDCouplingNoTimeLabel::getEndTime(int& /*iteration*/, int& /*order*/) const { throw INTERP_KERNEL::Exception(EXCEPTION_MSG); } -void MEDCouplingNoTimeLabel::setStartIteration(int it) +void MEDCouplingNoTimeLabel::setStartIteration(int /*it*/) { throw INTERP_KERNEL::Exception(EXCEPTION_MSG); } -void MEDCouplingNoTimeLabel::setEndIteration(int it) +void MEDCouplingNoTimeLabel::setEndIteration(int /*it*/) { throw INTERP_KERNEL::Exception(EXCEPTION_MSG); } -void MEDCouplingNoTimeLabel::setStartOrder(int order) +void MEDCouplingNoTimeLabel::setStartOrder(int /*order*/) { throw INTERP_KERNEL::Exception(EXCEPTION_MSG); } -void MEDCouplingNoTimeLabel::setEndOrder(int order) +void MEDCouplingNoTimeLabel::setEndOrder(int /*order*/) { throw INTERP_KERNEL::Exception(EXCEPTION_MSG); } -void MEDCouplingNoTimeLabel::setStartTimeValue(double time) +void MEDCouplingNoTimeLabel::setStartTimeValue(double /*time*/) { throw INTERP_KERNEL::Exception(EXCEPTION_MSG); } -void MEDCouplingNoTimeLabel::setEndTimeValue(double time) +void MEDCouplingNoTimeLabel::setEndTimeValue(double /*time*/) { throw INTERP_KERNEL::Exception(EXCEPTION_MSG); } -void MEDCouplingNoTimeLabel::setStartTime(double time, int iteration, int order) +void MEDCouplingNoTimeLabel::setStartTime(double /*time*/, int /*iteration*/, int /*order*/) { throw INTERP_KERNEL::Exception(EXCEPTION_MSG); } -void MEDCouplingNoTimeLabel::setEndTime(double time, int iteration, int order) +void MEDCouplingNoTimeLabel::setEndTime(double /*time*/, int /*iteration*/, int /*order*/) { throw INTERP_KERNEL::Exception(EXCEPTION_MSG); } -void MEDCouplingNoTimeLabel::getValueOnTime(mcIdType eltId, double time, double *value) const +void MEDCouplingNoTimeLabel::getValueOnTime(mcIdType /*eltId*/, double /*time*/, double * /*value*/) const { throw INTERP_KERNEL::Exception(EXCEPTION_MSG); } -void MEDCouplingNoTimeLabel::getValueOnDiscTime(mcIdType eltId, int iteration, int order, double *value) const +void MEDCouplingNoTimeLabel::getValueOnDiscTime(mcIdType /*eltId*/, int /*iteration*/, int /*order*/, double * /*value*/) const { throw INTERP_KERNEL::Exception(EXCEPTION_MSG); } @@ -1259,7 +1267,7 @@ void MEDCouplingNoTimeLabel::getTinySerializationDbleInformation2(std::vector& tinyInfoI, const std::vector& tinyInfoD) +void MEDCouplingNoTimeLabel::finishUnserialization2(const std::vector& /*tinyInfoI*/, const std::vector& tinyInfoD) { _time_tolerance=tinyInfoD[0]; } @@ -1269,8 +1277,7 @@ MEDCouplingWithTimeStep::MEDCouplingWithTimeStep(const MEDCouplingWithTimeStep& } MEDCouplingWithTimeStep::MEDCouplingWithTimeStep() -{ -} += default; std::string MEDCouplingWithTimeStep::getStringRepr() const { @@ -1285,9 +1292,9 @@ void MEDCouplingWithTimeStep::synchronizeTimeWith(const MEDCouplingMesh *mesh) if(!mesh) throw INTERP_KERNEL::Exception("MEDCouplingWithTimeStep::synchronizeTimeWith : mesh instance is NULL ! Impossible to synchronize time !"); int it=-1,order=-1; - double val=mesh->getTime(it,order); + double const val=mesh->getTime(it,order); _tk.setAllInfo(val,it,order); - std::string tUnit(mesh->getTimeUnit()); + std::string const tUnit(mesh->getTimeUnit()); setTimeUnit(tUnit); } @@ -1347,16 +1354,16 @@ bool MEDCouplingWithTimeStep::areCompatible(const MEDCouplingTimeDiscretizationT { if(!MEDCouplingTimeDiscretization::areCompatible(other)) return false; - const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); - return otherC!=0; + const auto *otherC=dynamic_cast(other); + return otherC!=nullptr; } bool MEDCouplingWithTimeStep::areStrictlyCompatible(const MEDCouplingTimeDiscretizationTemplate *other, std::string& reason) const { if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other,reason)) return false; - const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); - bool ret=otherC!=0; + const auto *otherC=dynamic_cast(other); + bool const ret=otherC!=nullptr; if(!ret) reason.insert(0,"time discretization of this is ONE_TIME, other has a different time discretization."); return ret; @@ -1366,29 +1373,29 @@ bool MEDCouplingWithTimeStep::areStrictlyCompatibleForMul(const MEDCouplingTimeD { if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(other)) return false; - const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); - return otherC!=0; + const auto *otherC=dynamic_cast(other); + return otherC!=nullptr; } bool MEDCouplingWithTimeStep::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretizationTemplate *other) const { if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other)) return false; - const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); - return otherC!=0; + const auto *otherC=dynamic_cast(other); + return otherC!=nullptr; } bool MEDCouplingWithTimeStep::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const { if(!MEDCouplingTimeDiscretization::areCompatibleForMeld(other)) return false; - const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); - return otherC!=0; + const auto *otherC=dynamic_cast(other); + return otherC!=nullptr; } bool MEDCouplingWithTimeStep::isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate *other, double prec, std::string& reason) const { - const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); std::ostringstream oss; oss.precision(15); if(!otherC) { @@ -1402,7 +1409,7 @@ bool MEDCouplingWithTimeStep::isEqualIfNotWhy(const MEDCouplingTimeDiscretizatio bool MEDCouplingWithTimeStep::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate *other, double prec) const { - const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) return false; if(!_tk.isEqual(otherC->_tk,_time_tolerance)) @@ -1413,7 +1420,7 @@ bool MEDCouplingWithTimeStep::isEqualWithoutConsideringStr(const MEDCouplingTime void MEDCouplingWithTimeStep::copyTinyAttrFrom(const MEDCouplingTimeDiscretizationTemplate& other) { MEDCouplingTimeDiscretization::copyTinyAttrFrom(other); - const MEDCouplingWithTimeStep *otherC=dynamic_cast(&other); + const auto *otherC=dynamic_cast(&other); if(!otherC) throw INTERP_KERNEL::Exception("MEDCouplingWithTimeStep::copyTinyAttrFrom : mismatch of time discretization !"); _tk.copyFrom(otherC->_tk); @@ -1421,12 +1428,12 @@ void MEDCouplingWithTimeStep::copyTinyAttrFrom(const MEDCouplingTimeDiscretizati MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::aggregate(const MEDCouplingTimeDiscretization *other) const { - const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("WithTimeStep::aggregation on mismatched time discretization !"); MCAuto arr=DataArrayDouble::Aggregate(getArray(),other->getArray()); - MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep; - ret->setArray(arr,0); + auto *ret=new MEDCouplingWithTimeStep; + ret->setArray(arr,nullptr); return ret; } @@ -1434,91 +1441,91 @@ MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::aggregate(const std::vec { std::vector a(other.size()); int i=0; - for(std::vector::const_iterator it=other.begin();it!=other.end();it++,i++) + for(auto it=other.begin();it!=other.end();it++,i++) { - const MEDCouplingWithTimeStep *itC=dynamic_cast(*it); + const auto *itC=dynamic_cast(*it); if(!itC) throw INTERP_KERNEL::Exception("WithTimeStep::aggregate on mismatched time discretization !"); a[i]=itC->getArray(); } MCAuto arr=DataArrayDouble::Aggregate(a); - MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep; - ret->setArray(arr,0); + auto *ret=new MEDCouplingWithTimeStep; + ret->setArray(arr,nullptr); return ret; } MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::meld(const MEDCouplingTimeDiscretization *other) const { - const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("WithTimeStep::meld on mismatched time discretization !"); MCAuto arr=DataArrayDouble::Meld(getArray(),other->getArray()); - MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep; - ret->setArray(arr,0); + auto *ret=new MEDCouplingWithTimeStep; + ret->setArray(arr,nullptr); return ret; } MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::dot(const MEDCouplingTimeDiscretization *other) const { - const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("WithTimeStep::dot on mismatched time discretization !"); - MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep; + auto *ret=new MEDCouplingWithTimeStep; MCAuto arr=DataArrayDouble::Dot(getArray(),other->getArray()); - ret->setArray(arr,0); + ret->setArray(arr,nullptr); return ret; } MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::crossProduct(const MEDCouplingTimeDiscretization *other) const { - const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("WithTimeStep::crossProduct on mismatched time discretization !"); MCAuto arr=DataArrayDouble::CrossProduct(getArray(),other->getArray()); - MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep; - ret->setArray(arr,0); + auto *ret=new MEDCouplingWithTimeStep; + ret->setArray(arr,nullptr); return ret; } MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::max(const MEDCouplingTimeDiscretization *other) const { - const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("WithTimeStep::max on mismatched time discretization !"); MCAuto arr=DataArrayDouble::Max(getArray(),other->getArray()); - MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep; - ret->setArray(arr,0); + auto *ret=new MEDCouplingWithTimeStep; + ret->setArray(arr,nullptr); return ret; } MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::min(const MEDCouplingTimeDiscretization *other) const { - const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("WithTimeStep::min on mismatched time discretization !"); MCAuto arr=DataArrayDouble::Min(getArray(),other->getArray()); - MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep; - ret->setArray(arr,0); + auto *ret=new MEDCouplingWithTimeStep; + ret->setArray(arr,nullptr); return ret; } MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::add(const MEDCouplingTimeDiscretization *other) const { - const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("WithTimeStep::add on mismatched time discretization !"); MCAuto arr=DataArrayDouble::Add(getArray(),other->getArray()); - MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep; - ret->setArray(arr,0); + auto *ret=new MEDCouplingWithTimeStep; + ret->setArray(arr,nullptr); int tmp1,tmp2; - double tmp3=getStartTime(tmp1,tmp2); + double const tmp3=getStartTime(tmp1,tmp2); ret->setStartTime(tmp3,tmp1,tmp2); return ret; } void MEDCouplingWithTimeStep::addEqual(const MEDCouplingTimeDiscretization *other) { - const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("WithTimeStep::addEqual on mismatched time discretization !"); if(!getArray()) @@ -1528,21 +1535,21 @@ void MEDCouplingWithTimeStep::addEqual(const MEDCouplingTimeDiscretization *othe MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::substract(const MEDCouplingTimeDiscretization *other) const { - const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("WithTimeStep::substract on mismatched time discretization !"); MCAuto arr=DataArrayDouble::Substract(getArray(),other->getArray()); - MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep; - ret->setArray(arr,0); + auto *ret=new MEDCouplingWithTimeStep; + ret->setArray(arr,nullptr); int tmp1,tmp2; - double tmp3=getStartTime(tmp1,tmp2); + double const tmp3=getStartTime(tmp1,tmp2); ret->setStartTime(tmp3,tmp1,tmp2); return ret; } void MEDCouplingWithTimeStep::substractEqual(const MEDCouplingTimeDiscretization *other) { - const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("WithTimeStep::substractEqual on mismatched time discretization !"); if(!getArray()) @@ -1552,21 +1559,21 @@ void MEDCouplingWithTimeStep::substractEqual(const MEDCouplingTimeDiscretization MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::multiply(const MEDCouplingTimeDiscretization *other) const { - const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("WithTimeStep::multiply on mismatched time discretization !"); MCAuto arr=DataArrayDouble::Multiply(getArray(),other->getArray()); - MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep; - ret->setArray(arr,0); + auto *ret=new MEDCouplingWithTimeStep; + ret->setArray(arr,nullptr); int tmp1,tmp2; - double tmp3=getStartTime(tmp1,tmp2); + double const tmp3=getStartTime(tmp1,tmp2); ret->setStartTime(tmp3,tmp1,tmp2); return ret; } void MEDCouplingWithTimeStep::multiplyEqual(const MEDCouplingTimeDiscretization *other) { - const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("WithTimeStep::multiplyEqual on mismatched time discretization !"); if(!getArray()) @@ -1576,21 +1583,21 @@ void MEDCouplingWithTimeStep::multiplyEqual(const MEDCouplingTimeDiscretization MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::divide(const MEDCouplingTimeDiscretization *other) const { - const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("WithTimeStep::divide on mismatched time discretization !"); MCAuto arr=DataArrayDouble::Divide(getArray(),other->getArray()); - MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep; - ret->setArray(arr,0); + auto *ret=new MEDCouplingWithTimeStep; + ret->setArray(arr,nullptr); int tmp1,tmp2; - double tmp3=getStartTime(tmp1,tmp2); + double const tmp3=getStartTime(tmp1,tmp2); ret->setStartTime(tmp3,tmp1,tmp2); return ret; } void MEDCouplingWithTimeStep::divideEqual(const MEDCouplingTimeDiscretization *other) { - const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("WithTimeStep::divideEqual on mismatched time discretization !"); if(!getArray()) @@ -1600,21 +1607,21 @@ void MEDCouplingWithTimeStep::divideEqual(const MEDCouplingTimeDiscretization *o MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::pow(const MEDCouplingTimeDiscretization *other) const { - const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("WithTimeStep::pow on mismatched time discretization !"); MCAuto arr=DataArrayDouble::Pow(getArray(),other->getArray()); - MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep; - ret->setArray(arr,0); + auto *ret=new MEDCouplingWithTimeStep; + ret->setArray(arr,nullptr); int tmp1,tmp2; - double tmp3=getStartTime(tmp1,tmp2); + double const tmp3=getStartTime(tmp1,tmp2); ret->setStartTime(tmp3,tmp1,tmp2); return ret; } void MEDCouplingWithTimeStep::powEqual(const MEDCouplingTimeDiscretization *other) { - const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("WithTimeStep::powEqual on mismatched time discretization !"); if(!getArray()) @@ -1649,7 +1656,7 @@ std::vector< const DataArrayDouble *> MEDCouplingWithTimeStep::getArraysForTime( throw INTERP_KERNEL::Exception(EXCEPTION_MSG); } -void MEDCouplingWithTimeStep::getValueForTime(double time, const std::vector& vals, double *res) const +void MEDCouplingWithTimeStep::getValueForTime(double /*time*/, const std::vector& vals, double *res) const { std::copy(vals.begin(),vals.end(),res); } @@ -1677,13 +1684,12 @@ void MEDCouplingWithTimeStep::getValueOnDiscTime(mcIdType eltId, int iteration, } MEDCouplingConstOnTimeInterval::MEDCouplingConstOnTimeInterval() -{ -} += default; void MEDCouplingConstOnTimeInterval::copyTinyAttrFrom(const MEDCouplingTimeDiscretizationTemplate& other) { MEDCouplingTimeDiscretization::copyTinyAttrFrom(other); - const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(&other); + const auto *otherC=dynamic_cast(&other); if(!otherC) throw INTERP_KERNEL::Exception("MEDCouplingConstOnTimeInterval::copyTinyAttrFrom : mismatch of time discretization !"); _start.copyFrom(otherC->_start); @@ -1773,10 +1779,10 @@ void MEDCouplingConstOnTimeInterval::synchronizeTimeWith(const MEDCouplingMesh * if(!mesh) throw INTERP_KERNEL::Exception("MEDCouplingWithTimeStep::synchronizeTimeWith : mesh instance is NULL ! Impossible to synchronize time !"); int it=-1,order=-1; - double val=mesh->getTime(it,order); + double const val=mesh->getTime(it,order); _start.setAllInfo(val,it,order); _end.setAllInfo(val,it,order); - std::string tUnit(mesh->getTimeUnit()); + std::string const tUnit(mesh->getTimeUnit()); setTimeUnit(tUnit); } @@ -1797,7 +1803,7 @@ std::vector< const DataArrayDouble *> MEDCouplingConstOnTimeInterval::getArraysF throw INTERP_KERNEL::Exception(EXCEPTION_MSG); } -void MEDCouplingConstOnTimeInterval::getValueForTime(double time, const std::vector& vals, double *res) const +void MEDCouplingConstOnTimeInterval::getValueForTime(double /*time*/, const std::vector& vals, double *res) const { std::copy(vals.begin(),vals.end(),res); } @@ -1806,16 +1812,16 @@ bool MEDCouplingConstOnTimeInterval::areCompatible(const MEDCouplingTimeDiscreti { if(!MEDCouplingTimeDiscretization::areCompatible(other)) return false; - const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); - return otherC!=0; + const auto *otherC=dynamic_cast(other); + return otherC!=nullptr; } bool MEDCouplingConstOnTimeInterval::areStrictlyCompatible(const MEDCouplingTimeDiscretizationTemplate *other, std::string& reason) const { if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other,reason)) return false; - const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); - bool ret=otherC!=0; + const auto *otherC=dynamic_cast(other); + bool const ret=otherC!=nullptr; if(!ret) reason.insert(0,"time discretization of this is CONST_ON_TIME_INTERVAL, other has a different time discretization."); return ret; @@ -1825,29 +1831,29 @@ bool MEDCouplingConstOnTimeInterval::areStrictlyCompatibleForMul(const MEDCoupli { if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(other)) return false; - const MEDCouplingConstOnTimeInterval *otherC(dynamic_cast(other)); - return otherC!=0; + const auto *otherC(dynamic_cast(other)); + return otherC!=nullptr; } bool MEDCouplingConstOnTimeInterval::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretizationTemplate *other) const { if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other)) return false; - const MEDCouplingConstOnTimeInterval *otherC(dynamic_cast(other)); - return otherC!=0; + const auto *otherC(dynamic_cast(other)); + return otherC!=nullptr; } bool MEDCouplingConstOnTimeInterval::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const { if(!MEDCouplingTimeDiscretization::areCompatibleForMeld(other)) return false; - const MEDCouplingConstOnTimeInterval *otherC(dynamic_cast(other)); - return otherC!=0; + const auto *otherC(dynamic_cast(other)); + return otherC!=nullptr; } bool MEDCouplingConstOnTimeInterval::isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate *other, double prec, std::string& reason) const { - const MEDCouplingConstOnTimeInterval *otherC(dynamic_cast(other)); + const auto *otherC(dynamic_cast(other)); std::ostringstream oss; oss.precision(15); if(!otherC) { @@ -1863,7 +1869,7 @@ bool MEDCouplingConstOnTimeInterval::isEqualIfNotWhy(const MEDCouplingTimeDiscre bool MEDCouplingConstOnTimeInterval::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate *other, double prec) const { - const MEDCouplingConstOnTimeInterval *otherC(dynamic_cast(other)); + const auto *otherC(dynamic_cast(other)); if(!otherC) return false; if(!_start.isEqual(otherC->_start,_time_tolerance)) @@ -1884,7 +1890,7 @@ void MEDCouplingConstOnTimeInterval::getValueOnTime(mcIdType eltId, double time, throw INTERP_KERNEL::Exception(EXCEPTION_MSG); } -void MEDCouplingConstOnTimeInterval::getValueOnDiscTime(mcIdType eltId, int iteration, int order, double *value) const +void MEDCouplingConstOnTimeInterval::getValueOnDiscTime(mcIdType eltId, int iteration, int /*order*/, double *value) const { if(iteration>=_start.getIteration() && iteration<=_end.getIteration()) if(_array) @@ -1913,12 +1919,12 @@ void MEDCouplingConstOnTimeInterval::checkTimePresence(double time) const MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::aggregate(const MEDCouplingTimeDiscretization *other) const { - const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("ConstOnTimeInterval::aggregation on mismatched time discretization !"); MCAuto arr=DataArrayDouble::Aggregate(getArray(),other->getArray()); - MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval; - ret->setArray(arr,0); + auto *ret=new MEDCouplingConstOnTimeInterval; + ret->setArray(arr,nullptr); return ret; } @@ -1926,83 +1932,83 @@ MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::aggregate(const s { std::vector a(other.size()); int i=0; - for(std::vector::const_iterator it=other.begin();it!=other.end();it++,i++) + for(auto it=other.begin();it!=other.end();it++,i++) { - const MEDCouplingConstOnTimeInterval *itC=dynamic_cast(*it); + const auto *itC=dynamic_cast(*it); if(!itC) throw INTERP_KERNEL::Exception("ConstOnTimeInterval::aggregate on mismatched time discretization !"); a[i]=itC->getArray(); } MCAuto arr=DataArrayDouble::Aggregate(a); - MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval; - ret->setArray(arr,0); + auto *ret=new MEDCouplingConstOnTimeInterval; + ret->setArray(arr,nullptr); return ret; } MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::meld(const MEDCouplingTimeDiscretization *other) const { - const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("ConstOnTimeInterval::meld on mismatched time discretization !"); MCAuto arr=DataArrayDouble::Meld(getArray(),other->getArray()); - MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval; + auto *ret=new MEDCouplingConstOnTimeInterval; ret->setTimeTolerance(getTimeTolerance()); - ret->setArray(arr,0); + ret->setArray(arr,nullptr); return ret; } MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::dot(const MEDCouplingTimeDiscretization *other) const { - const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("ConstOnTimeInterval::dot on mismatched time discretization !"); MCAuto arr=DataArrayDouble::Dot(getArray(),other->getArray()); - MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval; - ret->setArray(arr,0); + auto *ret=new MEDCouplingConstOnTimeInterval; + ret->setArray(arr,nullptr); return ret; } MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::crossProduct(const MEDCouplingTimeDiscretization *other) const { - const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("ConstOnTimeInterval::crossProduct on mismatched time discretization !"); MCAuto arr=DataArrayDouble::CrossProduct(getArray(),other->getArray()); - MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval; - ret->setArray(arr,0); + auto *ret=new MEDCouplingConstOnTimeInterval; + ret->setArray(arr,nullptr); return ret; } MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::max(const MEDCouplingTimeDiscretization *other) const { - const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("ConstOnTimeInterval::max on mismatched time discretization !"); MCAuto arr=DataArrayDouble::Max(getArray(),other->getArray()); - MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval; - ret->setArray(arr,0); + auto *ret=new MEDCouplingConstOnTimeInterval; + ret->setArray(arr,nullptr); return ret; } MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::min(const MEDCouplingTimeDiscretization *other) const { - const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("ConstOnTimeInterval::min on mismatched time discretization !"); MCAuto arr=DataArrayDouble::Min(getArray(),other->getArray()); - MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval; - ret->setArray(arr,0); + auto *ret=new MEDCouplingConstOnTimeInterval; + ret->setArray(arr,nullptr); return ret; } MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::add(const MEDCouplingTimeDiscretization *other) const { - const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("ConstOnTimeInterval::add on mismatched time discretization !"); MCAuto arr=DataArrayDouble::Add(getArray(),other->getArray()); - MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval; - ret->setArray(arr,0); + auto *ret=new MEDCouplingConstOnTimeInterval; + ret->setArray(arr,nullptr); int tmp1,tmp2; double tmp3=getStartTime(tmp1,tmp2); ret->setStartTime(tmp3,tmp1,tmp2); @@ -2013,7 +2019,7 @@ MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::add(const MEDCoup void MEDCouplingConstOnTimeInterval::addEqual(const MEDCouplingTimeDiscretization *other) { - const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("ConstOnTimeInterval::addEqual on mismatched time discretization !"); if(!getArray()) @@ -2023,12 +2029,12 @@ void MEDCouplingConstOnTimeInterval::addEqual(const MEDCouplingTimeDiscretizatio MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::substract(const MEDCouplingTimeDiscretization *other) const { - const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("ConstOnTimeInterval::substract on mismatched time discretization !"); MCAuto arr=DataArrayDouble::Substract(getArray(),other->getArray()); - MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval; - ret->setArray(arr,0); + auto *ret=new MEDCouplingConstOnTimeInterval; + ret->setArray(arr,nullptr); int tmp1,tmp2; double tmp3=getStartTime(tmp1,tmp2); ret->setStartTime(tmp3,tmp1,tmp2); @@ -2039,7 +2045,7 @@ MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::substract(const M void MEDCouplingConstOnTimeInterval::substractEqual(const MEDCouplingTimeDiscretization *other) { - const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("ConstOnTimeInterval::substractEqual on mismatched time discretization !"); if(!getArray()) @@ -2049,12 +2055,12 @@ void MEDCouplingConstOnTimeInterval::substractEqual(const MEDCouplingTimeDiscret MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::multiply(const MEDCouplingTimeDiscretization *other) const { - const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("multiply on mismatched time discretization !"); MCAuto arr=DataArrayDouble::Multiply(getArray(),other->getArray()); - MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval; - ret->setArray(arr,0); + auto *ret=new MEDCouplingConstOnTimeInterval; + ret->setArray(arr,nullptr); int tmp1,tmp2; double tmp3=getStartTime(tmp1,tmp2); ret->setStartTime(tmp3,tmp1,tmp2); @@ -2065,7 +2071,7 @@ MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::multiply(const ME void MEDCouplingConstOnTimeInterval::multiplyEqual(const MEDCouplingTimeDiscretization *other) { - const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("ConstOnTimeInterval::multiplyEqual on mismatched time discretization !"); if(!getArray()) @@ -2075,12 +2081,12 @@ void MEDCouplingConstOnTimeInterval::multiplyEqual(const MEDCouplingTimeDiscreti MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::divide(const MEDCouplingTimeDiscretization *other) const { - const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("divide on mismatched time discretization !"); MCAuto arr=DataArrayDouble::Divide(getArray(),other->getArray()); - MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval; - ret->setArray(arr,0); + auto *ret=new MEDCouplingConstOnTimeInterval; + ret->setArray(arr,nullptr); int tmp1,tmp2; double tmp3=getStartTime(tmp1,tmp2); ret->setStartTime(tmp3,tmp1,tmp2); @@ -2091,7 +2097,7 @@ MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::divide(const MEDC void MEDCouplingConstOnTimeInterval::divideEqual(const MEDCouplingTimeDiscretization *other) { - const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("ConstOnTimeInterval::divideEqual on mismatched time discretization !"); if(!getArray()) @@ -2101,12 +2107,12 @@ void MEDCouplingConstOnTimeInterval::divideEqual(const MEDCouplingTimeDiscretiza MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::pow(const MEDCouplingTimeDiscretization *other) const { - const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("pow on mismatched time discretization !"); MCAuto arr=DataArrayDouble::Pow(getArray(),other->getArray()); - MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval; - ret->setArray(arr,0); + auto *ret=new MEDCouplingConstOnTimeInterval; + ret->setArray(arr,nullptr); int tmp1,tmp2; double tmp3=getStartTime(tmp1,tmp2); ret->setStartTime(tmp3,tmp1,tmp2); @@ -2117,7 +2123,7 @@ MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::pow(const MEDCoup void MEDCouplingConstOnTimeInterval::powEqual(const MEDCouplingTimeDiscretization *other) { - const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("ConstOnTimeInterval::powEqual on mismatched time discretization !"); if(!getArray()) @@ -2131,7 +2137,7 @@ MEDCouplingTwoTimeSteps::MEDCouplingTwoTimeSteps(const MEDCouplingTwoTimeSteps& if(other._end_array) _end_array=other._end_array->performCopyOrIncrRef(deepCopy); else - _end_array=0; + _end_array=nullptr; } void MEDCouplingTwoTimeSteps::updateTime() const @@ -2146,10 +2152,10 @@ void MEDCouplingTwoTimeSteps::synchronizeTimeWith(const MEDCouplingMesh *mesh) if(!mesh) throw INTERP_KERNEL::Exception("MEDCouplingTwoTimeSteps::synchronizeTimeWith : mesh instance is NULL ! Impossible to synchronize time !"); int it=-1,order=-1; - double val=mesh->getTime(it,order); + double const val=mesh->getTime(it,order); _start.setAllInfo(val,it,order); _end.setAllInfo(val,it,order); - std::string tUnit(mesh->getTimeUnit()); + std::string const tUnit(mesh->getTimeUnit()); setTimeUnit(tUnit); } @@ -2168,7 +2174,7 @@ std::vector MEDCouplingTwoTimeSteps::getDirectChildrenW void MEDCouplingTwoTimeSteps::copyTinyAttrFrom(const MEDCouplingTimeDiscretizationTemplate& other) { MEDCouplingTimeDiscretization::copyTinyAttrFrom(other); - const MEDCouplingTwoTimeSteps *otherC=dynamic_cast(&other); + const auto *otherC=dynamic_cast(&other); if(!otherC) throw INTERP_KERNEL::Exception("MEDCouplingTwoTimeSteps::copyTinyAttrFrom : mismatch of time discretization !"); _start.copyFrom(otherC->_start); @@ -2178,7 +2184,7 @@ void MEDCouplingTwoTimeSteps::copyTinyAttrFrom(const MEDCouplingTimeDiscretizati void MEDCouplingTwoTimeSteps::copyTinyStringsFrom(const MEDCouplingTimeDiscretizationTemplate& other) { MEDCouplingTimeDiscretization::copyTinyStringsFrom(other); - const MEDCouplingTwoTimeSteps *otherC=dynamic_cast(&other); + const auto *otherC=dynamic_cast(&other); if(!otherC) throw INTERP_KERNEL::Exception("Trying to operate copyTinyStringsFrom on different field type (two times//one time) !"); if(_end_array && otherC->_end_array) @@ -2208,8 +2214,8 @@ void MEDCouplingTwoTimeSteps::checkConsistencyLight() const bool MEDCouplingTwoTimeSteps::isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate *other, double prec, std::string& reason) const { - std::ostringstream oss; - const MEDCouplingTwoTimeSteps *otherC(dynamic_cast(other)); + std::ostringstream const oss; + const auto *otherC(dynamic_cast(other)); if(!otherC) { reason="This has time discretization LINEAR_TIME, other not."; @@ -2230,7 +2236,7 @@ bool MEDCouplingTwoTimeSteps::isEqualIfNotWhy(const MEDCouplingTimeDiscretizatio bool MEDCouplingTwoTimeSteps::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate *other, double prec) const { - const MEDCouplingTwoTimeSteps *otherC(dynamic_cast(other)); + const auto *otherC(dynamic_cast(other)); if(!otherC) return false; if(!_start.isEqual(otherC->_start,_time_tolerance)) @@ -2243,7 +2249,7 @@ bool MEDCouplingTwoTimeSteps::isEqualWithoutConsideringStr(const MEDCouplingTime return MEDCouplingTimeDiscretization::isEqualWithoutConsideringStr(other,prec); } -MEDCouplingTwoTimeSteps::MEDCouplingTwoTimeSteps():_end_array(0) +MEDCouplingTwoTimeSteps::MEDCouplingTwoTimeSteps():_end_array(nullptr) { } @@ -2318,7 +2324,7 @@ void MEDCouplingTwoTimeSteps::getTinySerializationDbleInformation(std::vector& tinyInfo) const { - std::size_t nbOfCompo=_array->getNumberOfComponents(); + std::size_t const nbOfCompo=_array->getNumberOfComponents(); for(std::size_t i=0;igetInfoOnComponent(i)); for(std::size_t i=0;i& tinyInfoI, std::vector& arrays) { arrays.resize(2); - if(_array!=0) + if(_array!=nullptr) _array->decrRef(); - if(_end_array!=0) + if(_end_array!=nullptr) _end_array->decrRef(); - DataArrayDouble *arr=0; + DataArrayDouble *arr=nullptr; if(tinyInfoI[0]!=-1 && tinyInfoI[1]!=-1) { arr=DataArrayDouble::New(); @@ -2340,7 +2346,7 @@ void MEDCouplingTwoTimeSteps::resizeForUnserialization(const std::vectordecrRef(); - if(_end_array!=0) + if(_end_array!=nullptr) _end_array->decrRef(); - _array=0; _end_array=0; + _array=nullptr; _end_array=nullptr; if(tinyInfoI[0]!=-1 && tinyInfoI[1]!=-1) { if(!arrays[0]) @@ -2450,8 +2456,7 @@ MEDCouplingLinearTime::MEDCouplingLinearTime(const MEDCouplingLinearTime& other, } MEDCouplingLinearTime::MEDCouplingLinearTime() -{ -} += default; std::string MEDCouplingLinearTime::getStringRepr() const { @@ -2478,12 +2483,12 @@ bool MEDCouplingLinearTime::areCompatible(const MEDCouplingTimeDiscretizationTem { if(!MEDCouplingTimeDiscretization::areCompatible(other)) return false; - const MEDCouplingLinearTime *otherC=dynamic_cast(other); - if(otherC==0) + const auto *otherC=dynamic_cast(other); + if(otherC==nullptr) return false; - if(_end_array==0 && otherC->_end_array==0) + if(_end_array==nullptr && otherC->_end_array==nullptr) return true; - if(_end_array==0 || otherC->_end_array==0) + if(_end_array==nullptr || otherC->_end_array==nullptr) return false; if(_end_array->getNumberOfComponents()!=otherC->_end_array->getNumberOfComponents()) return false; @@ -2494,8 +2499,8 @@ bool MEDCouplingLinearTime::areStrictlyCompatible(const MEDCouplingTimeDiscretiz { if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other,reason)) return false; - const MEDCouplingLinearTime *otherC=dynamic_cast(other); - bool ret=otherC!=0; + const auto *otherC=dynamic_cast(other); + bool const ret=otherC!=nullptr; if(!ret) reason.insert(0,"time discretization of this is LINEAR_TIME, other has a different time discretization."); return ret; @@ -2505,23 +2510,23 @@ bool MEDCouplingLinearTime::areStrictlyCompatibleForMul(const MEDCouplingTimeDis { if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(other)) return false; - const MEDCouplingLinearTime *otherC=dynamic_cast(other); - return otherC!=0; + const auto *otherC=dynamic_cast(other); + return otherC!=nullptr; } bool MEDCouplingLinearTime::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretizationTemplate *other) const { if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other)) return false; - const MEDCouplingLinearTime *otherC=dynamic_cast(other); - if(otherC==0) + const auto *otherC=dynamic_cast(other); + if(otherC==nullptr) return false; - if(_end_array==0 && otherC->_end_array==0) + if(_end_array==nullptr && otherC->_end_array==nullptr) return true; - if(_end_array==0 || otherC->_end_array==0) + if(_end_array==nullptr || otherC->_end_array==nullptr) return false; - std::size_t nbC1=_end_array->getNumberOfComponents(); - std::size_t nbC2=otherC->_end_array->getNumberOfComponents(); + std::size_t const nbC1=_end_array->getNumberOfComponents(); + std::size_t const nbC2=otherC->_end_array->getNumberOfComponents(); if(nbC1!=nbC2 && nbC2!=1) return false; return true; @@ -2531,8 +2536,8 @@ bool MEDCouplingLinearTime::areCompatibleForMeld(const MEDCouplingTimeDiscretiza { if(!MEDCouplingTimeDiscretization::areCompatibleForMeld(other)) return false; - const MEDCouplingLinearTime *otherC=dynamic_cast(other); - return otherC!=0; + const auto *otherC=dynamic_cast(other); + return otherC!=nullptr; } /*! @@ -2540,8 +2545,8 @@ bool MEDCouplingLinearTime::areCompatibleForMeld(const MEDCouplingTimeDiscretiza */ void MEDCouplingLinearTime::getValueForTime(double time, const std::vector& vals, double *res) const { - double alpha=(_end.getTimeValue()-time)/(_end.getTimeValue()-_start.getTimeValue()); - std::size_t nbComp=vals.size()/2; + double const alpha=(_end.getTimeValue()-time)/(_end.getTimeValue()-_start.getTimeValue()); + std::size_t const nbComp=vals.size()/2; std::transform(vals.begin(),vals.begin()+nbComp,res,std::bind(std::multiplies(),std::placeholders::_1,alpha)); std::vector tmp(nbComp); std::transform(vals.begin()+nbComp,vals.end(),tmp.begin(),std::bind(std::multiplies(),std::placeholders::_1,1-alpha)); @@ -2550,12 +2555,12 @@ void MEDCouplingLinearTime::getValueForTime(double time, const std::vectorgetTuple(eltId,value); else throw INTERP_KERNEL::Exception("No start array existing."); - std::size_t nbComp=_array->getNumberOfComponents(); + std::size_t const nbComp=_array->getNumberOfComponents(); std::transform(value,value+nbComp,value,std::bind(std::multiplies(),std::placeholders::_1,alpha)); std::vector tmp(nbComp); if(_end_array) @@ -2588,14 +2593,14 @@ void MEDCouplingLinearTime::getValueOnDiscTime(mcIdType eltId, int iteration, in MEDCouplingTimeDiscretization *MEDCouplingLinearTime::aggregate(const MEDCouplingTimeDiscretization *other) const { - const MEDCouplingLinearTime *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("LinearTime::aggregation on mismatched time discretization !"); MCAuto arr1=DataArrayDouble::Aggregate(getArray(),other->getArray()); MCAuto arr2=DataArrayDouble::Aggregate(getEndArray(),other->getEndArray()); - MEDCouplingLinearTime *ret=new MEDCouplingLinearTime; - ret->setArray(arr1,0); - ret->setEndArray(arr2,0); + auto *ret=new MEDCouplingLinearTime; + ret->setArray(arr1,nullptr); + ret->setEndArray(arr2,nullptr); return ret; } @@ -2604,97 +2609,97 @@ MEDCouplingTimeDiscretization *MEDCouplingLinearTime::aggregate(const std::vecto std::vector a(other.size()); std::vector b(other.size()); int i=0; - for(std::vector::const_iterator it=other.begin();it!=other.end();it++,i++) + for(auto it=other.begin();it!=other.end();it++,i++) { - const MEDCouplingLinearTime *itC=dynamic_cast(*it); + const auto *itC=dynamic_cast(*it); if(!itC) throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::aggregate on mismatched time discretization !"); a[i]=itC->getArray(); b[i]=itC->getEndArray(); } MCAuto arr(DataArrayDouble::Aggregate(a)),arr2(DataArrayDouble::Aggregate(b)); - MEDCouplingLinearTime *ret(new MEDCouplingLinearTime); - ret->setArray(arr,0); - ret->setEndArray(arr2,0); + auto *ret(new MEDCouplingLinearTime); + ret->setArray(arr,nullptr); + ret->setEndArray(arr2,nullptr); return ret; } MEDCouplingTimeDiscretization *MEDCouplingLinearTime::meld(const MEDCouplingTimeDiscretization *other) const { - const MEDCouplingLinearTime *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("LinearTime::meld on mismatched time discretization !"); MCAuto arr1(DataArrayDouble::Meld(getArray(),other->getArray())),arr2(DataArrayDouble::Meld(getEndArray(),other->getEndArray())); - MEDCouplingLinearTime *ret(new MEDCouplingLinearTime); + auto *ret(new MEDCouplingLinearTime); ret->setTimeTolerance(getTimeTolerance()); - ret->setArray(arr1,0); - ret->setEndArray(arr2,0); + ret->setArray(arr1,nullptr); + ret->setEndArray(arr2,nullptr); return ret; } MEDCouplingTimeDiscretization *MEDCouplingLinearTime::dot(const MEDCouplingTimeDiscretization *other) const { - const MEDCouplingLinearTime *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("LinearTime::dot on mismatched time discretization !"); MCAuto arr1(DataArrayDouble::Dot(getArray(),other->getArray())),arr2(DataArrayDouble::Dot(getEndArray(),other->getEndArray())); - MEDCouplingLinearTime *ret(new MEDCouplingLinearTime); - ret->setArray(arr1,0); - ret->setEndArray(arr2,0); + auto *ret(new MEDCouplingLinearTime); + ret->setArray(arr1,nullptr); + ret->setEndArray(arr2,nullptr); return ret; } MEDCouplingTimeDiscretization *MEDCouplingLinearTime::crossProduct(const MEDCouplingTimeDiscretization *other) const { - const MEDCouplingLinearTime *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("LinearTime::crossProduct on mismatched time discretization !"); MCAuto arr1(DataArrayDouble::CrossProduct(getArray(),other->getArray())),arr2(DataArrayDouble::CrossProduct(getEndArray(),other->getEndArray())); - MEDCouplingLinearTime *ret(new MEDCouplingLinearTime); - ret->setArray(arr1,0); - ret->setEndArray(arr2,0); + auto *ret(new MEDCouplingLinearTime); + ret->setArray(arr1,nullptr); + ret->setEndArray(arr2,nullptr); return ret; } MEDCouplingTimeDiscretization *MEDCouplingLinearTime::max(const MEDCouplingTimeDiscretization *other) const { - const MEDCouplingLinearTime *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("LinearTime::max on mismatched time discretization !"); - MEDCouplingLinearTime *ret=new MEDCouplingLinearTime; + auto *ret=new MEDCouplingLinearTime; MCAuto arr1(DataArrayDouble::Max(getArray(),other->getArray())),arr2(DataArrayDouble::Max(getEndArray(),other->getEndArray())); - ret->setArray(arr1,0); - ret->setEndArray(arr2,0); + ret->setArray(arr1,nullptr); + ret->setEndArray(arr2,nullptr); return ret; } MEDCouplingTimeDiscretization *MEDCouplingLinearTime::min(const MEDCouplingTimeDiscretization *other) const { - const MEDCouplingLinearTime *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("LinearTime::min on mismatched time discretization !"); MCAuto arr1(DataArrayDouble::Min(getArray(),other->getArray())),arr2(DataArrayDouble::Min(getEndArray(),other->getEndArray())); - MEDCouplingLinearTime *ret(new MEDCouplingLinearTime); - ret->setArray(arr1,0); - ret->setEndArray(arr2,0); + auto *ret(new MEDCouplingLinearTime); + ret->setArray(arr1,nullptr); + ret->setEndArray(arr2,nullptr); return ret; } MEDCouplingTimeDiscretization *MEDCouplingLinearTime::add(const MEDCouplingTimeDiscretization *other) const { - const MEDCouplingLinearTime *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("LinearTime::add on mismatched time discretization !"); MCAuto arr1(DataArrayDouble::Add(getArray(),other->getArray())),arr2(DataArrayDouble::Add(getEndArray(),other->getEndArray())); - MEDCouplingLinearTime *ret(new MEDCouplingLinearTime); - ret->setArray(arr1,0); - ret->setEndArray(arr2,0); + auto *ret(new MEDCouplingLinearTime); + ret->setArray(arr1,nullptr); + ret->setEndArray(arr2,nullptr); return ret; } void MEDCouplingLinearTime::addEqual(const MEDCouplingTimeDiscretization *other) { - const MEDCouplingLinearTime *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("LinearTime::addEqual on mismatched time discretization !"); if(!getArray()) @@ -2707,20 +2712,20 @@ void MEDCouplingLinearTime::addEqual(const MEDCouplingTimeDiscretization *other) MEDCouplingTimeDiscretization *MEDCouplingLinearTime::substract(const MEDCouplingTimeDiscretization *other) const { - const MEDCouplingLinearTime *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("LinearTime::substract on mismatched time discretization !"); MCAuto arr1=DataArrayDouble::Substract(getArray(),other->getArray()); MCAuto arr2=DataArrayDouble::Substract(getEndArray(),other->getEndArray()); - MEDCouplingLinearTime *ret=new MEDCouplingLinearTime; - ret->setArray(arr1,0); - ret->setEndArray(arr2,0); + auto *ret=new MEDCouplingLinearTime; + ret->setArray(arr1,nullptr); + ret->setEndArray(arr2,nullptr); return ret; } void MEDCouplingLinearTime::substractEqual(const MEDCouplingTimeDiscretization *other) { - const MEDCouplingLinearTime *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("LinearTime::addEqual on mismatched time discretization !"); if(!getArray()) @@ -2733,20 +2738,20 @@ void MEDCouplingLinearTime::substractEqual(const MEDCouplingTimeDiscretization * MEDCouplingTimeDiscretization *MEDCouplingLinearTime::multiply(const MEDCouplingTimeDiscretization *other) const { - const MEDCouplingLinearTime *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("LinearTime::multiply on mismatched time discretization !"); MCAuto arr1=DataArrayDouble::Multiply(getArray(),other->getArray()); MCAuto arr2=DataArrayDouble::Multiply(getEndArray(),other->getEndArray()); - MEDCouplingLinearTime *ret=new MEDCouplingLinearTime; - ret->setArray(arr1,0); - ret->setEndArray(arr2,0); + auto *ret=new MEDCouplingLinearTime; + ret->setArray(arr1,nullptr); + ret->setEndArray(arr2,nullptr); return ret; } void MEDCouplingLinearTime::multiplyEqual(const MEDCouplingTimeDiscretization *other) { - const MEDCouplingLinearTime *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("LinearTime::addEqual on mismatched time discretization !"); if(!getArray()) @@ -2759,20 +2764,20 @@ void MEDCouplingLinearTime::multiplyEqual(const MEDCouplingTimeDiscretization *o MEDCouplingTimeDiscretization *MEDCouplingLinearTime::divide(const MEDCouplingTimeDiscretization *other) const { - const MEDCouplingLinearTime *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("LinearTime::divide on mismatched time discretization !"); MCAuto arr1=DataArrayDouble::Divide(getArray(),other->getArray()); MCAuto arr2=DataArrayDouble::Divide(getEndArray(),other->getEndArray()); - MEDCouplingLinearTime *ret=new MEDCouplingLinearTime; - ret->setArray(arr1,0); - ret->setEndArray(arr2,0); + auto *ret=new MEDCouplingLinearTime; + ret->setArray(arr1,nullptr); + ret->setEndArray(arr2,nullptr); return ret; } void MEDCouplingLinearTime::divideEqual(const MEDCouplingTimeDiscretization *other) { - const MEDCouplingLinearTime *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("LinearTime::addEqual on mismatched time discretization !"); if(!getArray()) @@ -2785,20 +2790,20 @@ void MEDCouplingLinearTime::divideEqual(const MEDCouplingTimeDiscretization *oth MEDCouplingTimeDiscretization *MEDCouplingLinearTime::pow(const MEDCouplingTimeDiscretization *other) const { - const MEDCouplingLinearTime *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("LinearTime::pow on mismatched time discretization !"); MCAuto arr1=DataArrayDouble::Pow(getArray(),other->getArray()); MCAuto arr2=DataArrayDouble::Pow(getEndArray(),other->getEndArray()); - MEDCouplingLinearTime *ret=new MEDCouplingLinearTime; - ret->setArray(arr1,0); - ret->setEndArray(arr2,0); + auto *ret=new MEDCouplingLinearTime; + ret->setArray(arr1,nullptr); + ret->setEndArray(arr2,nullptr); return ret; } void MEDCouplingLinearTime::powEqual(const MEDCouplingTimeDiscretization *other) { - const MEDCouplingLinearTime *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("LinearTime::addEqual on mismatched time discretization !"); if(!getArray()) diff --git a/src/MEDCoupling/MEDCouplingTimeDiscretization.hxx b/src/MEDCoupling/MEDCouplingTimeDiscretization.hxx index 5a31fdc21..a49929959 100644 --- a/src/MEDCoupling/MEDCouplingTimeDiscretization.hxx +++ b/src/MEDCoupling/MEDCouplingTimeDiscretization.hxx @@ -21,12 +21,14 @@ #ifndef __MEDCOUPLINGTIMEDISCRETIZATION_HXX__ #define __MEDCOUPLINGTIMEDISCRETIZATION_HXX__ +#include "MCType.hxx" #include "MEDCoupling.hxx" #include "MEDCouplingTimeLabel.hxx" #include "MEDCouplingRefCountObject.hxx" -#include "InterpKernelException.hxx" #include "MEDCouplingTraits.hxx" +#include +#include #include namespace MEDCoupling @@ -45,8 +47,8 @@ namespace MEDCoupling void copyTinyAttrFrom(const TimeHolder& other) { _time_unit=other._time_unit; } protected: TimeHolder() { } - TimeHolder(const TimeHolder& other):_time_unit(other._time_unit) { } - virtual ~TimeHolder() { } + TimeHolder(const TimeHolder& other) = default; + virtual ~TimeHolder() = default; private: std::string _time_unit; }; @@ -55,7 +57,7 @@ namespace MEDCoupling class MEDCouplingTimeDiscretizationTemplate : public TimeLabel, public BigMemoryObject, public TimeHolder { public: - MEDCOUPLING_EXPORT void updateTime() const; + MEDCOUPLING_EXPORT void updateTime() const override; MEDCOUPLING_EXPORT virtual void setArray(typename Traits::ArrayType *array, TimeLabel *owner); MEDCOUPLING_EXPORT typename Traits::ArrayType *getArray() { return _array; } MEDCOUPLING_EXPORT const typename Traits::ArrayType *getArray() const { return _array; } @@ -88,8 +90,8 @@ namespace MEDCoupling MEDCOUPLING_EXPORT virtual void copyTinyAttrFrom(const MEDCouplingTimeDiscretizationTemplate& other); MEDCOUPLING_EXPORT virtual void copyTinyStringsFrom(const MEDCouplingTimeDiscretizationTemplate& other); MEDCOUPLING_EXPORT virtual void checkConsistencyLight() const; - MEDCOUPLING_EXPORT virtual std::size_t getHeapMemorySizeWithoutChildren() const; - MEDCOUPLING_EXPORT virtual std::vector getDirectChildrenWithNull() const; + MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const override; + MEDCOUPLING_EXPORT std::vector getDirectChildrenWithNull() const override; // MEDCOUPLING_EXPORT virtual bool isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate *other, T prec, std::string& reason) const = 0; MEDCOUPLING_EXPORT virtual bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate *other, T prec) const = 0; @@ -98,7 +100,7 @@ namespace MEDCoupling MEDCOUPLING_EXPORT virtual bool areCompatible(const MEDCouplingTimeDiscretizationTemplate *other) const; MEDCOUPLING_EXPORT virtual bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretizationTemplate *other) const; MEDCOUPLING_EXPORT virtual bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretizationTemplate *other) const; - MEDCOUPLING_EXPORT virtual ~MEDCouplingTimeDiscretizationTemplate(); + MEDCOUPLING_EXPORT ~MEDCouplingTimeDiscretizationTemplate() override; MEDCOUPLING_EXPORT virtual void getTinySerializationIntInformation(std::vector& tinyInfo) const; MEDCOUPLING_EXPORT virtual void getTinySerializationDbleInformation(std::vector& tinyInfo) const; MEDCOUPLING_EXPORT virtual void getTinySerializationStrInformation(std::vector& tinyInfo) const; @@ -118,7 +120,7 @@ namespace MEDCoupling class MEDCouplingTimeKeeper { public: - MEDCOUPLING_EXPORT MEDCouplingTimeKeeper():_time(0.),_iteration(-1),_order(-1) { } + MEDCOUPLING_EXPORT MEDCouplingTimeKeeper() = default; MEDCOUPLING_EXPORT double getAllInfo(int& iteration, int& order) const { iteration=_iteration; order=_order; return _time; } MEDCOUPLING_EXPORT void setAllInfo(double time, int iteration, int order) { _time=time; _iteration=iteration; _order=order; } MEDCOUPLING_EXPORT int getIteration() const { return _iteration; } @@ -132,9 +134,9 @@ namespace MEDCoupling MEDCOUPLING_EXPORT void copyFrom(const MEDCouplingTimeKeeper& other); MEDCOUPLING_EXPORT void checkTimePresence(double time, double eps) const; private: - double _time; - int _iteration; - int _order; + double _time{0.}; + int _iteration{-1}; + int _order{-1}; }; class MEDCouplingTimeDiscretization : public MEDCouplingTimeDiscretizationTemplate @@ -145,8 +147,8 @@ namespace MEDCoupling public: MEDCOUPLING_EXPORT static MEDCouplingTimeDiscretization *New(TypeOfTimeDiscretization type); MEDCOUPLING_EXPORT virtual bool areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const; - MEDCOUPLING_EXPORT virtual bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate *other, double prec) const; - MEDCOUPLING_EXPORT virtual bool isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate *other, double prec, std::string& reason) const; + MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate *other, double prec) const override; + MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate *other, double prec, std::string& reason) const override; MEDCOUPLING_EXPORT virtual bool isEqual(const MEDCouplingTimeDiscretization *other, double prec) const; MEDCOUPLING_EXPORT virtual MEDCouplingTimeDiscretization *buildNewTimeReprFromThis(TypeOfTimeDiscretization type, bool deepCopy) const; MEDCOUPLING_EXPORT virtual void synchronizeTimeWith(const MEDCouplingMesh *mesh) = 0; @@ -215,18 +217,18 @@ namespace MEDCoupling class MEDCouplingTimeDiscretizationSimple : public MEDCouplingTimeDiscretizationTemplate { public: - std::string getStringRepr() const; - double getStartTime(int& iteration, int& order) const { return _tk.getAllInfo(iteration,order); } - void setStartIteration(int it) { _tk.setIteration(it); } - void setStartOrder(int order) { _tk.setOrder(order); } - void setStartTimeValue(double time) { _tk.setTimeValue(time); } - void setStartTime(double time, int iteration, int order) { _tk.setAllInfo(time,iteration,order); } - double getEndTime(int& iteration, int& order) const; - void setEndIteration(int it); - void setEndOrder(int order); - void setEndTimeValue(double time); - void setEndTime(double time, int iteration, int order); - TypeOfTimeDiscretization getEnum() const { return DISCRETIZATION; } + std::string getStringRepr() const override; + double getStartTime(int& iteration, int& order) const override { return _tk.getAllInfo(iteration,order); } + void setStartIteration(int it) override { _tk.setIteration(it); } + void setStartOrder(int order) override { _tk.setOrder(order); } + void setStartTimeValue(double time) override { _tk.setTimeValue(time); } + void setStartTime(double time, int iteration, int order) override { _tk.setAllInfo(time,iteration,order); } + double getEndTime(int& iteration, int& order) const override; + void setEndIteration(int it) override; + void setEndOrder(int order) override; + void setEndTimeValue(double time) override; + void setEndTime(double time, int iteration, int order) override; + TypeOfTimeDiscretization getEnum() const override { return DISCRETIZATION; } protected: MEDCouplingTimeDiscretizationSimple(const MEDCouplingTimeDiscretizationSimple& other, bool deepCopy); MEDCouplingTimeDiscretizationSimple() { } @@ -241,23 +243,23 @@ namespace MEDCoupling class MEDCouplingTimeDiscretizationInt32 : public MEDCouplingTimeDiscretizationSimple { public: - MEDCouplingTimeDiscretizationInt32() { } + MEDCouplingTimeDiscretizationInt32() = default; std::string getClassName() const override { return std::string("MEDCouplingTimeDiscretizationInt32"); } MEDCouplingTimeDiscretizationInt32(const MEDCouplingTimeDiscretizationInt32& other, bool deepCopy); static MEDCouplingTimeDiscretizationInt32 *New(TypeOfTimeDiscretization type); - MEDCouplingTimeDiscretizationInt32 *performCopyOrIncrRef(bool deepCopy) const; - bool isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate *other, Int32 prec, std::string& reason) const; - bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate *other, Int32 prec) const; + MEDCouplingTimeDiscretizationInt32 *performCopyOrIncrRef(bool deepCopy) const override; + bool isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate *other, Int32 prec, std::string& reason) const override; + bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate *other, Int32 prec) const override; }; class MEDCouplingTimeDiscretizationInt64 : public MEDCouplingTimeDiscretizationSimple { public: - MEDCouplingTimeDiscretizationInt64() { } + MEDCouplingTimeDiscretizationInt64() = default; std::string getClassName() const override { return std::string("MEDCouplingTimeDiscretizationInt64"); } MEDCouplingTimeDiscretizationInt64(const MEDCouplingTimeDiscretizationInt64& other, bool deepCopy); static MEDCouplingTimeDiscretizationInt64 *New(TypeOfTimeDiscretization type); - MEDCouplingTimeDiscretizationInt64 *performCopyOrIncrRef(bool deepCopy) const; + MEDCouplingTimeDiscretizationInt64 *performCopyOrIncrRef(bool deepCopy) const override; bool isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate *other, Int64 prec, std::string& reason) const override; bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate *other, Int64 prec) const override; }; @@ -265,13 +267,13 @@ namespace MEDCoupling class MEDCouplingTimeDiscretizationFloat : public MEDCouplingTimeDiscretizationSimple { public: - MEDCouplingTimeDiscretizationFloat() { } + MEDCouplingTimeDiscretizationFloat() = default; std::string getClassName() const override { return std::string("MEDCouplingTimeDiscretizationFloat"); } MEDCouplingTimeDiscretizationFloat(const MEDCouplingTimeDiscretizationFloat& other, bool deepCopy); static MEDCouplingTimeDiscretizationFloat *New(TypeOfTimeDiscretization type); - MEDCouplingTimeDiscretizationFloat *performCopyOrIncrRef(bool deepCopy) const; - bool isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate *other, float prec, std::string& reason) const; - bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate *other, float prec) const; + MEDCouplingTimeDiscretizationFloat *performCopyOrIncrRef(bool deepCopy) const override; + bool isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate *other, float prec, std::string& reason) const override; + bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate *other, float prec) const override; private: static const TypeOfTimeDiscretization DISCRETIZATION=ONE_TIME; }; @@ -281,56 +283,56 @@ namespace MEDCoupling public: MEDCOUPLING_EXPORT MEDCouplingNoTimeLabel(); MEDCOUPLING_EXPORT MEDCouplingNoTimeLabel(const MEDCouplingTimeDiscretization& other, bool deepCopy); - MEDCOUPLING_EXPORT std::string getStringRepr() const; + MEDCOUPLING_EXPORT std::string getStringRepr() const override; MEDCOUPLING_EXPORT std::string getClassName() const override { return std::string("MEDCouplingNoTimeLabel"); } - MEDCOUPLING_EXPORT TypeOfTimeDiscretization getEnum() const { return DISCRETIZATION; } - MEDCOUPLING_EXPORT void synchronizeTimeWith(const MEDCouplingMesh *mesh); - MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *aggregate(const MEDCouplingTimeDiscretization *other) const; - MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *aggregate(const std::vector& other) const; - MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *meld(const MEDCouplingTimeDiscretization *other) const; - MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *dot(const MEDCouplingTimeDiscretization *other) const; - MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *crossProduct(const MEDCouplingTimeDiscretization *other) const; - MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *max(const MEDCouplingTimeDiscretization *other) const; - MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *min(const MEDCouplingTimeDiscretization *other) const; - MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *add(const MEDCouplingTimeDiscretization *other) const; - MEDCOUPLING_EXPORT void addEqual(const MEDCouplingTimeDiscretization *other); - MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *substract(const MEDCouplingTimeDiscretization *other) const; - MEDCOUPLING_EXPORT void substractEqual(const MEDCouplingTimeDiscretization *other); - MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *multiply(const MEDCouplingTimeDiscretization *other) const; - MEDCOUPLING_EXPORT void multiplyEqual(const MEDCouplingTimeDiscretization *other); - MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *divide(const MEDCouplingTimeDiscretization *other) const; - MEDCOUPLING_EXPORT void divideEqual(const MEDCouplingTimeDiscretization *other); - MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *pow(const MEDCouplingTimeDiscretization *other) const; - MEDCOUPLING_EXPORT void powEqual(const MEDCouplingTimeDiscretization *other); - MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate *other, double prec, std::string& reason) const; - MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate *other, double prec) const; - MEDCOUPLING_EXPORT bool areCompatible(const MEDCouplingTimeDiscretizationTemplate *other) const; - MEDCOUPLING_EXPORT bool areStrictlyCompatible(const MEDCouplingTimeDiscretizationTemplate *other, std::string& reason) const; - MEDCOUPLING_EXPORT bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretizationTemplate *other) const; - MEDCOUPLING_EXPORT bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretizationTemplate *other) const; - MEDCOUPLING_EXPORT bool areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const; - MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *performCopyOrIncrRef(bool deepCopy) const; - MEDCOUPLING_EXPORT void checkNoTimePresence() const { } - MEDCOUPLING_EXPORT void checkTimePresence(double time) const; - MEDCOUPLING_EXPORT std::vector< const DataArrayDouble *> getArraysForTime(double time) const; - MEDCOUPLING_EXPORT void getValueForTime(double time, const std::vector& vals, double *res) const; - MEDCOUPLING_EXPORT bool isBefore(const MEDCouplingTimeDiscretization *other) const; - MEDCOUPLING_EXPORT bool isStrictlyBefore(const MEDCouplingTimeDiscretization *other) const; - MEDCOUPLING_EXPORT double getStartTime(int& iteration, int& order) const; - MEDCOUPLING_EXPORT double getEndTime(int& iteration, int& order) const; - MEDCOUPLING_EXPORT void setStartIteration(int it); - MEDCOUPLING_EXPORT void setEndIteration(int it); - MEDCOUPLING_EXPORT void setStartOrder(int order); - MEDCOUPLING_EXPORT void setEndOrder(int order); - MEDCOUPLING_EXPORT void setStartTimeValue(double time); - MEDCOUPLING_EXPORT void setEndTimeValue(double time); - MEDCOUPLING_EXPORT void setStartTime(double time, int iteration, int order); - MEDCOUPLING_EXPORT void setEndTime(double time, int iteration, int order); - MEDCOUPLING_EXPORT void getValueOnTime(mcIdType eltId, double time, double *value) const; - MEDCOUPLING_EXPORT void getValueOnDiscTime(mcIdType eltId, int iteration, int order, double *value) const; - MEDCOUPLING_EXPORT void getTinySerializationIntInformation2(std::vector& tinyInfo) const; - MEDCOUPLING_EXPORT void getTinySerializationDbleInformation2(std::vector& tinyInfo) const; - MEDCOUPLING_EXPORT void finishUnserialization2(const std::vector& tinyInfoI, const std::vector& tinyInfoD); + MEDCOUPLING_EXPORT TypeOfTimeDiscretization getEnum() const override { return DISCRETIZATION; } + MEDCOUPLING_EXPORT void synchronizeTimeWith(const MEDCouplingMesh *mesh) override; + MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *aggregate(const MEDCouplingTimeDiscretization *other) const override; + MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *aggregate(const std::vector& other) const override; + MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *meld(const MEDCouplingTimeDiscretization *other) const override; + MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *dot(const MEDCouplingTimeDiscretization *other) const override; + MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *crossProduct(const MEDCouplingTimeDiscretization *other) const override; + MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *max(const MEDCouplingTimeDiscretization *other) const override; + MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *min(const MEDCouplingTimeDiscretization *other) const override; + MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *add(const MEDCouplingTimeDiscretization *other) const override; + MEDCOUPLING_EXPORT void addEqual(const MEDCouplingTimeDiscretization *other) override; + MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *substract(const MEDCouplingTimeDiscretization *other) const override; + MEDCOUPLING_EXPORT void substractEqual(const MEDCouplingTimeDiscretization *other) override; + MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *multiply(const MEDCouplingTimeDiscretization *other) const override; + MEDCOUPLING_EXPORT void multiplyEqual(const MEDCouplingTimeDiscretization *other) override; + MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *divide(const MEDCouplingTimeDiscretization *other) const override; + MEDCOUPLING_EXPORT void divideEqual(const MEDCouplingTimeDiscretization *other) override; + MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *pow(const MEDCouplingTimeDiscretization *other) const override; + MEDCOUPLING_EXPORT void powEqual(const MEDCouplingTimeDiscretization *other) override; + MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate *other, double prec, std::string& reason) const override; + MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate *other, double prec) const override; + MEDCOUPLING_EXPORT bool areCompatible(const MEDCouplingTimeDiscretizationTemplate *other) const override; + MEDCOUPLING_EXPORT bool areStrictlyCompatible(const MEDCouplingTimeDiscretizationTemplate *other, std::string& reason) const override; + MEDCOUPLING_EXPORT bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretizationTemplate *other) const override; + MEDCOUPLING_EXPORT bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretizationTemplate *other) const override; + MEDCOUPLING_EXPORT bool areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const override; + MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *performCopyOrIncrRef(bool deepCopy) const override; + MEDCOUPLING_EXPORT void checkNoTimePresence() const override { } + MEDCOUPLING_EXPORT void checkTimePresence(double time) const override; + MEDCOUPLING_EXPORT std::vector< const DataArrayDouble *> getArraysForTime(double time) const override; + MEDCOUPLING_EXPORT void getValueForTime(double time, const std::vector& vals, double *res) const override; + MEDCOUPLING_EXPORT bool isBefore(const MEDCouplingTimeDiscretization *other) const override; + MEDCOUPLING_EXPORT bool isStrictlyBefore(const MEDCouplingTimeDiscretization *other) const override; + MEDCOUPLING_EXPORT double getStartTime(int& iteration, int& order) const override; + MEDCOUPLING_EXPORT double getEndTime(int& iteration, int& order) const override; + MEDCOUPLING_EXPORT void setStartIteration(int it) override; + MEDCOUPLING_EXPORT void setEndIteration(int it) override; + MEDCOUPLING_EXPORT void setStartOrder(int order) override; + MEDCOUPLING_EXPORT void setEndOrder(int order) override; + MEDCOUPLING_EXPORT void setStartTimeValue(double time) override; + MEDCOUPLING_EXPORT void setEndTimeValue(double time) override; + MEDCOUPLING_EXPORT void setStartTime(double time, int iteration, int order) override; + MEDCOUPLING_EXPORT void setEndTime(double time, int iteration, int order) override; + MEDCOUPLING_EXPORT void getValueOnTime(mcIdType eltId, double time, double *value) const override; + MEDCOUPLING_EXPORT void getValueOnDiscTime(mcIdType eltId, int iteration, int order, double *value) const override; + MEDCOUPLING_EXPORT void getTinySerializationIntInformation2(std::vector& tinyInfo) const override; + MEDCOUPLING_EXPORT void getTinySerializationDbleInformation2(std::vector& tinyInfo) const override; + MEDCOUPLING_EXPORT void finishUnserialization2(const std::vector& tinyInfoI, const std::vector& tinyInfoD) override; public: static const TypeOfTimeDiscretization DISCRETIZATION=NO_TIME; MEDCOUPLING_EXPORT static const char REPR[]; @@ -345,57 +347,57 @@ namespace MEDCoupling public: MEDCOUPLING_EXPORT MEDCouplingWithTimeStep(); MEDCOUPLING_EXPORT std::string getClassName() const override { return std::string("MEDCouplingWithTimeLabel"); } - MEDCOUPLING_EXPORT std::string getStringRepr() const; - MEDCOUPLING_EXPORT void copyTinyAttrFrom(const MEDCouplingTimeDiscretizationTemplate& other); - MEDCOUPLING_EXPORT TypeOfTimeDiscretization getEnum() const { return DISCRETIZATION; } - MEDCOUPLING_EXPORT void synchronizeTimeWith(const MEDCouplingMesh *mesh); - MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *aggregate(const MEDCouplingTimeDiscretization *other) const; - MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *aggregate(const std::vector& other) const; - MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *meld(const MEDCouplingTimeDiscretization *other) const; - MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *dot(const MEDCouplingTimeDiscretization *other) const; - MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *crossProduct(const MEDCouplingTimeDiscretization *other) const; - MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *max(const MEDCouplingTimeDiscretization *other) const; - MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *min(const MEDCouplingTimeDiscretization *other) const; - MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *add(const MEDCouplingTimeDiscretization *other) const; - MEDCOUPLING_EXPORT void addEqual(const MEDCouplingTimeDiscretization *other); - MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *substract(const MEDCouplingTimeDiscretization *other) const; - MEDCOUPLING_EXPORT void substractEqual(const MEDCouplingTimeDiscretization *other); - MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *multiply(const MEDCouplingTimeDiscretization *other) const; - MEDCOUPLING_EXPORT void multiplyEqual(const MEDCouplingTimeDiscretization *other); - MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *divide(const MEDCouplingTimeDiscretization *other) const; - MEDCOUPLING_EXPORT void divideEqual(const MEDCouplingTimeDiscretization *other); - MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *pow(const MEDCouplingTimeDiscretization *other) const; - MEDCOUPLING_EXPORT void powEqual(const MEDCouplingTimeDiscretization *other); - MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate *other, double prec, std::string& reason) const; - MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate *other, double prec) const; - MEDCOUPLING_EXPORT bool areCompatible(const MEDCouplingTimeDiscretizationTemplate *other) const; - MEDCOUPLING_EXPORT bool areStrictlyCompatible(const MEDCouplingTimeDiscretizationTemplate *other, std::string& reason) const; - MEDCOUPLING_EXPORT bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretizationTemplate *other) const; - MEDCOUPLING_EXPORT bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretizationTemplate *other) const; - MEDCOUPLING_EXPORT bool areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const; - MEDCOUPLING_EXPORT void getTinySerializationIntInformation(std::vector& tinyInfo) const; - MEDCOUPLING_EXPORT void getTinySerializationDbleInformation(std::vector& tinyInfo) const; - MEDCOUPLING_EXPORT void finishUnserialization(const std::vector& tinyInfoI, const std::vector& tinyInfoD, const std::vector& tinyInfoS); - MEDCOUPLING_EXPORT void getTinySerializationIntInformation2(std::vector& tinyInfo) const; - MEDCOUPLING_EXPORT void getTinySerializationDbleInformation2(std::vector& tinyInfo) const; - MEDCOUPLING_EXPORT void finishUnserialization2(const std::vector& tinyInfoI, const std::vector& tinyInfoD); - MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *performCopyOrIncrRef(bool deepCopy) const; - MEDCOUPLING_EXPORT void checkNoTimePresence() const; - MEDCOUPLING_EXPORT void checkTimePresence(double time) const; - MEDCOUPLING_EXPORT void setStartTime(double time, int iteration, int order) { _tk.setAllInfo(time,iteration,order); } - MEDCOUPLING_EXPORT void setEndTime(double time, int iteration, int order) { _tk.setAllInfo(time,iteration,order); } - MEDCOUPLING_EXPORT double getStartTime(int& iteration, int& order) const { return _tk.getAllInfo(iteration,order); } - MEDCOUPLING_EXPORT double getEndTime(int& iteration, int& order) const { return _tk.getAllInfo(iteration,order); } - MEDCOUPLING_EXPORT void setStartIteration(int it) { _tk.setIteration(it); } - MEDCOUPLING_EXPORT void setEndIteration(int it) { _tk.setIteration(it); } - MEDCOUPLING_EXPORT void setStartOrder(int order) { _tk.setOrder(order); } - MEDCOUPLING_EXPORT void setEndOrder(int order) { _tk.setOrder(order); } - MEDCOUPLING_EXPORT void setStartTimeValue(double time) { _tk.setTimeValue(time); } - MEDCOUPLING_EXPORT void setEndTimeValue(double time) { _tk.setTimeValue(time); } - MEDCOUPLING_EXPORT std::vector< const DataArrayDouble *> getArraysForTime(double time) const; - MEDCOUPLING_EXPORT void getValueForTime(double time, const std::vector& vals, double *res) const; - MEDCOUPLING_EXPORT void getValueOnTime(mcIdType eltId, double time, double *value) const; - MEDCOUPLING_EXPORT void getValueOnDiscTime(mcIdType eltId, int iteration, int order, double *value) const; + MEDCOUPLING_EXPORT std::string getStringRepr() const override; + MEDCOUPLING_EXPORT void copyTinyAttrFrom(const MEDCouplingTimeDiscretizationTemplate& other) override; + MEDCOUPLING_EXPORT TypeOfTimeDiscretization getEnum() const override { return DISCRETIZATION; } + MEDCOUPLING_EXPORT void synchronizeTimeWith(const MEDCouplingMesh *mesh) override; + MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *aggregate(const MEDCouplingTimeDiscretization *other) const override; + MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *aggregate(const std::vector& other) const override; + MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *meld(const MEDCouplingTimeDiscretization *other) const override; + MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *dot(const MEDCouplingTimeDiscretization *other) const override; + MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *crossProduct(const MEDCouplingTimeDiscretization *other) const override; + MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *max(const MEDCouplingTimeDiscretization *other) const override; + MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *min(const MEDCouplingTimeDiscretization *other) const override; + MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *add(const MEDCouplingTimeDiscretization *other) const override; + MEDCOUPLING_EXPORT void addEqual(const MEDCouplingTimeDiscretization *other) override; + MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *substract(const MEDCouplingTimeDiscretization *other) const override; + MEDCOUPLING_EXPORT void substractEqual(const MEDCouplingTimeDiscretization *other) override; + MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *multiply(const MEDCouplingTimeDiscretization *other) const override; + MEDCOUPLING_EXPORT void multiplyEqual(const MEDCouplingTimeDiscretization *other) override; + MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *divide(const MEDCouplingTimeDiscretization *other) const override; + MEDCOUPLING_EXPORT void divideEqual(const MEDCouplingTimeDiscretization *other) override; + MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *pow(const MEDCouplingTimeDiscretization *other) const override; + MEDCOUPLING_EXPORT void powEqual(const MEDCouplingTimeDiscretization *other) override; + MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate *other, double prec, std::string& reason) const override; + MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate *other, double prec) const override; + MEDCOUPLING_EXPORT bool areCompatible(const MEDCouplingTimeDiscretizationTemplate *other) const override; + MEDCOUPLING_EXPORT bool areStrictlyCompatible(const MEDCouplingTimeDiscretizationTemplate *other, std::string& reason) const override; + MEDCOUPLING_EXPORT bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretizationTemplate *other) const override; + MEDCOUPLING_EXPORT bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretizationTemplate *other) const override; + MEDCOUPLING_EXPORT bool areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const override; + MEDCOUPLING_EXPORT void getTinySerializationIntInformation(std::vector& tinyInfo) const override; + MEDCOUPLING_EXPORT void getTinySerializationDbleInformation(std::vector& tinyInfo) const override; + MEDCOUPLING_EXPORT void finishUnserialization(const std::vector& tinyInfoI, const std::vector& tinyInfoD, const std::vector& tinyInfoS) override; + MEDCOUPLING_EXPORT void getTinySerializationIntInformation2(std::vector& tinyInfo) const override; + MEDCOUPLING_EXPORT void getTinySerializationDbleInformation2(std::vector& tinyInfo) const override; + MEDCOUPLING_EXPORT void finishUnserialization2(const std::vector& tinyInfoI, const std::vector& tinyInfoD) override; + MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *performCopyOrIncrRef(bool deepCopy) const override; + MEDCOUPLING_EXPORT void checkNoTimePresence() const override; + MEDCOUPLING_EXPORT void checkTimePresence(double time) const override; + MEDCOUPLING_EXPORT void setStartTime(double time, int iteration, int order) override { _tk.setAllInfo(time,iteration,order); } + MEDCOUPLING_EXPORT void setEndTime(double time, int iteration, int order) override { _tk.setAllInfo(time,iteration,order); } + MEDCOUPLING_EXPORT double getStartTime(int& iteration, int& order) const override { return _tk.getAllInfo(iteration,order); } + MEDCOUPLING_EXPORT double getEndTime(int& iteration, int& order) const override { return _tk.getAllInfo(iteration,order); } + MEDCOUPLING_EXPORT void setStartIteration(int it) override { _tk.setIteration(it); } + MEDCOUPLING_EXPORT void setEndIteration(int it) override { _tk.setIteration(it); } + MEDCOUPLING_EXPORT void setStartOrder(int order) override { _tk.setOrder(order); } + MEDCOUPLING_EXPORT void setEndOrder(int order) override { _tk.setOrder(order); } + MEDCOUPLING_EXPORT void setStartTimeValue(double time) override { _tk.setTimeValue(time); } + MEDCOUPLING_EXPORT void setEndTimeValue(double time) override { _tk.setTimeValue(time); } + MEDCOUPLING_EXPORT std::vector< const DataArrayDouble *> getArraysForTime(double time) const override; + MEDCOUPLING_EXPORT void getValueForTime(double time, const std::vector& vals, double *res) const override; + MEDCOUPLING_EXPORT void getValueOnTime(mcIdType eltId, double time, double *value) const override; + MEDCOUPLING_EXPORT void getValueOnDiscTime(mcIdType eltId, int iteration, int order, double *value) const override; public: static const TypeOfTimeDiscretization DISCRETIZATION=ONE_TIME; MEDCOUPLING_EXPORT static const char REPR[]; @@ -412,57 +414,57 @@ namespace MEDCoupling public: MEDCOUPLING_EXPORT MEDCouplingConstOnTimeInterval(); MEDCOUPLING_EXPORT std::string getClassName() const override { return std::string("MEDCouplingConstOnTimeInterval"); } - MEDCOUPLING_EXPORT void copyTinyAttrFrom(const MEDCouplingTimeDiscretizationTemplate& other); - MEDCOUPLING_EXPORT void getTinySerializationIntInformation(std::vector& tinyInfo) const; - MEDCOUPLING_EXPORT void getTinySerializationDbleInformation(std::vector& tinyInfo) const; - MEDCOUPLING_EXPORT void finishUnserialization(const std::vector& tinyInfoI, const std::vector& tinyInfoD, const std::vector& tinyInfoS); - MEDCOUPLING_EXPORT void getTinySerializationIntInformation2(std::vector& tinyInfo) const; - MEDCOUPLING_EXPORT void getTinySerializationDbleInformation2(std::vector& tinyInfo) const; - MEDCOUPLING_EXPORT void finishUnserialization2(const std::vector& tinyInfoI, const std::vector& tinyInfoD); - MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *performCopyOrIncrRef(bool deepCopy) const; - MEDCOUPLING_EXPORT bool areCompatible(const MEDCouplingTimeDiscretizationTemplate *other) const; - MEDCOUPLING_EXPORT bool areStrictlyCompatible(const MEDCouplingTimeDiscretizationTemplate *other, std::string& reason) const; - MEDCOUPLING_EXPORT bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretizationTemplate *other) const; - MEDCOUPLING_EXPORT bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretizationTemplate *other) const; - MEDCOUPLING_EXPORT bool areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const; - MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate *other, double prec, std::string& reason) const; - MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate *other, double prec) const; - MEDCOUPLING_EXPORT std::vector< const DataArrayDouble *> getArraysForTime(double time) const; - MEDCOUPLING_EXPORT void getValueForTime(double time, const std::vector& vals, double *res) const; - MEDCOUPLING_EXPORT void getValueOnTime(mcIdType eltId, double time, double *value) const; - MEDCOUPLING_EXPORT void getValueOnDiscTime(mcIdType eltId, int iteration, int order, double *value) const; - MEDCOUPLING_EXPORT TypeOfTimeDiscretization getEnum() const { return DISCRETIZATION; } - MEDCOUPLING_EXPORT void synchronizeTimeWith(const MEDCouplingMesh *mesh); - MEDCOUPLING_EXPORT std::string getStringRepr() const; - MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *aggregate(const MEDCouplingTimeDiscretization *other) const; - MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *aggregate(const std::vector& other) const; - MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *meld(const MEDCouplingTimeDiscretization *other) const; - MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *dot(const MEDCouplingTimeDiscretization *other) const; - MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *crossProduct(const MEDCouplingTimeDiscretization *other) const; - MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *max(const MEDCouplingTimeDiscretization *other) const; - MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *min(const MEDCouplingTimeDiscretization *other) const; - MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *add(const MEDCouplingTimeDiscretization *other) const; - MEDCOUPLING_EXPORT void addEqual(const MEDCouplingTimeDiscretization *other); - MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *substract(const MEDCouplingTimeDiscretization *other) const; - MEDCOUPLING_EXPORT void substractEqual(const MEDCouplingTimeDiscretization *other); - MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *multiply(const MEDCouplingTimeDiscretization *other) const; - MEDCOUPLING_EXPORT void multiplyEqual(const MEDCouplingTimeDiscretization *other); - MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *divide(const MEDCouplingTimeDiscretization *other) const; - MEDCOUPLING_EXPORT void divideEqual(const MEDCouplingTimeDiscretization *other); - MEDCouplingTimeDiscretization *pow(const MEDCouplingTimeDiscretization *other) const; - MEDCOUPLING_EXPORT void powEqual(const MEDCouplingTimeDiscretization *other); - MEDCOUPLING_EXPORT void setStartTime(double time, int iteration, int order) { _start.setAllInfo(time,iteration,order); } - MEDCOUPLING_EXPORT void setEndTime(double time, int iteration, int order) { _end.setAllInfo(time,iteration,order); } - MEDCOUPLING_EXPORT double getStartTime(int& iteration, int& order) const { return _start.getAllInfo(iteration,order); } - MEDCOUPLING_EXPORT double getEndTime(int& iteration, int& order) const { return _end.getAllInfo(iteration,order); } - MEDCOUPLING_EXPORT void setStartIteration(int it) { _start.setIteration(it); } - MEDCOUPLING_EXPORT void setEndIteration(int it) { _end.setIteration(it); } - MEDCOUPLING_EXPORT void setStartOrder(int order) { _start.setOrder(order); } - MEDCOUPLING_EXPORT void setEndOrder(int order) { _end.setOrder(order); } - MEDCOUPLING_EXPORT void setStartTimeValue(double time) { _start.setTimeValue(time); } - MEDCOUPLING_EXPORT void setEndTimeValue(double time) { _end.setTimeValue(time); } - MEDCOUPLING_EXPORT void checkNoTimePresence() const; - MEDCOUPLING_EXPORT void checkTimePresence(double time) const; + MEDCOUPLING_EXPORT void copyTinyAttrFrom(const MEDCouplingTimeDiscretizationTemplate& other) override; + MEDCOUPLING_EXPORT void getTinySerializationIntInformation(std::vector& tinyInfo) const override; + MEDCOUPLING_EXPORT void getTinySerializationDbleInformation(std::vector& tinyInfo) const override; + MEDCOUPLING_EXPORT void finishUnserialization(const std::vector& tinyInfoI, const std::vector& tinyInfoD, const std::vector& tinyInfoS) override; + MEDCOUPLING_EXPORT void getTinySerializationIntInformation2(std::vector& tinyInfo) const override; + MEDCOUPLING_EXPORT void getTinySerializationDbleInformation2(std::vector& tinyInfo) const override; + MEDCOUPLING_EXPORT void finishUnserialization2(const std::vector& tinyInfoI, const std::vector& tinyInfoD) override; + MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *performCopyOrIncrRef(bool deepCopy) const override; + MEDCOUPLING_EXPORT bool areCompatible(const MEDCouplingTimeDiscretizationTemplate *other) const override; + MEDCOUPLING_EXPORT bool areStrictlyCompatible(const MEDCouplingTimeDiscretizationTemplate *other, std::string& reason) const override; + MEDCOUPLING_EXPORT bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretizationTemplate *other) const override; + MEDCOUPLING_EXPORT bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretizationTemplate *other) const override; + MEDCOUPLING_EXPORT bool areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const override; + MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate *other, double prec, std::string& reason) const override; + MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate *other, double prec) const override; + MEDCOUPLING_EXPORT std::vector< const DataArrayDouble *> getArraysForTime(double time) const override; + MEDCOUPLING_EXPORT void getValueForTime(double time, const std::vector& vals, double *res) const override; + MEDCOUPLING_EXPORT void getValueOnTime(mcIdType eltId, double time, double *value) const override; + MEDCOUPLING_EXPORT void getValueOnDiscTime(mcIdType eltId, int iteration, int order, double *value) const override; + MEDCOUPLING_EXPORT TypeOfTimeDiscretization getEnum() const override { return DISCRETIZATION; } + MEDCOUPLING_EXPORT void synchronizeTimeWith(const MEDCouplingMesh *mesh) override; + MEDCOUPLING_EXPORT std::string getStringRepr() const override; + MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *aggregate(const MEDCouplingTimeDiscretization *other) const override; + MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *aggregate(const std::vector& other) const override; + MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *meld(const MEDCouplingTimeDiscretization *other) const override; + MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *dot(const MEDCouplingTimeDiscretization *other) const override; + MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *crossProduct(const MEDCouplingTimeDiscretization *other) const override; + MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *max(const MEDCouplingTimeDiscretization *other) const override; + MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *min(const MEDCouplingTimeDiscretization *other) const override; + MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *add(const MEDCouplingTimeDiscretization *other) const override; + MEDCOUPLING_EXPORT void addEqual(const MEDCouplingTimeDiscretization *other) override; + MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *substract(const MEDCouplingTimeDiscretization *other) const override; + MEDCOUPLING_EXPORT void substractEqual(const MEDCouplingTimeDiscretization *other) override; + MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *multiply(const MEDCouplingTimeDiscretization *other) const override; + MEDCOUPLING_EXPORT void multiplyEqual(const MEDCouplingTimeDiscretization *other) override; + MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *divide(const MEDCouplingTimeDiscretization *other) const override; + MEDCOUPLING_EXPORT void divideEqual(const MEDCouplingTimeDiscretization *other) override; + MEDCouplingTimeDiscretization *pow(const MEDCouplingTimeDiscretization *other) const override; + MEDCOUPLING_EXPORT void powEqual(const MEDCouplingTimeDiscretization *other) override; + MEDCOUPLING_EXPORT void setStartTime(double time, int iteration, int order) override { _start.setAllInfo(time,iteration,order); } + MEDCOUPLING_EXPORT void setEndTime(double time, int iteration, int order) override { _end.setAllInfo(time,iteration,order); } + MEDCOUPLING_EXPORT double getStartTime(int& iteration, int& order) const override { return _start.getAllInfo(iteration,order); } + MEDCOUPLING_EXPORT double getEndTime(int& iteration, int& order) const override { return _end.getAllInfo(iteration,order); } + MEDCOUPLING_EXPORT void setStartIteration(int it) override { _start.setIteration(it); } + MEDCOUPLING_EXPORT void setEndIteration(int it) override { _end.setIteration(it); } + MEDCOUPLING_EXPORT void setStartOrder(int order) override { _start.setOrder(order); } + MEDCOUPLING_EXPORT void setEndOrder(int order) override { _end.setOrder(order); } + MEDCOUPLING_EXPORT void setStartTimeValue(double time) override { _start.setTimeValue(time); } + MEDCOUPLING_EXPORT void setEndTimeValue(double time) override { _end.setTimeValue(time); } + MEDCOUPLING_EXPORT void checkNoTimePresence() const override; + MEDCOUPLING_EXPORT void checkTimePresence(double time) const override; public: static const TypeOfTimeDiscretization DISCRETIZATION=CONST_ON_TIME_INTERVAL; MEDCOUPLING_EXPORT static const char REPR[]; @@ -478,45 +480,45 @@ namespace MEDCoupling protected: MEDCOUPLING_EXPORT MEDCouplingTwoTimeSteps(const MEDCouplingTwoTimeSteps& other, bool deepCopy); MEDCOUPLING_EXPORT MEDCouplingTwoTimeSteps(); - MEDCOUPLING_EXPORT ~MEDCouplingTwoTimeSteps(); + MEDCOUPLING_EXPORT ~MEDCouplingTwoTimeSteps() override; public: MEDCOUPLING_EXPORT std::string getClassName() const override { return std::string("MEDCouplingTwoTimeSteps"); } - MEDCOUPLING_EXPORT void updateTime() const; - MEDCOUPLING_EXPORT void synchronizeTimeWith(const MEDCouplingMesh *mesh); - MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; - MEDCOUPLING_EXPORT std::vector getDirectChildrenWithNull() const; - MEDCOUPLING_EXPORT void copyTinyAttrFrom(const MEDCouplingTimeDiscretizationTemplate& other); - MEDCOUPLING_EXPORT void copyTinyStringsFrom(const MEDCouplingTimeDiscretizationTemplate& other); - MEDCOUPLING_EXPORT const DataArrayDouble *getEndArray() const; - MEDCOUPLING_EXPORT DataArrayDouble *getEndArray(); - MEDCOUPLING_EXPORT void checkConsistencyLight() const; - MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate *other, double prec, std::string& reason) const; - MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate *other, double prec) const; - MEDCOUPLING_EXPORT void checkNoTimePresence() const; - MEDCOUPLING_EXPORT void checkTimePresence(double time) const; - MEDCOUPLING_EXPORT void getArrays(std::vector& arrays) const; - MEDCOUPLING_EXPORT void setEndArray(DataArrayDouble *array, TimeLabel *owner); - MEDCOUPLING_EXPORT void setStartTime(double time, int iteration, int order) { _start.setAllInfo(time,iteration,order); } - MEDCOUPLING_EXPORT void setEndTime(double time, int iteration, int order) { _end.setAllInfo(time,iteration,order); } - MEDCOUPLING_EXPORT double getStartTime(int& iteration, int& order) const { return _start.getAllInfo(iteration,order); } - MEDCOUPLING_EXPORT double getEndTime(int& iteration, int& order) const { return _end.getAllInfo(iteration,order); } - MEDCOUPLING_EXPORT void setStartIteration(int it) { _start.setIteration(it); } - MEDCOUPLING_EXPORT void setEndIteration(int it) { _end.setIteration(it); } - MEDCOUPLING_EXPORT void setStartOrder(int order) { _start.setOrder(order); } - MEDCOUPLING_EXPORT void setEndOrder(int order) { _end.setOrder(order); } - MEDCOUPLING_EXPORT void setStartTimeValue(double time) { _start.setTimeValue(time); } - MEDCOUPLING_EXPORT void setEndTimeValue(double time) { _end.setTimeValue(time); } - MEDCOUPLING_EXPORT void getTinySerializationIntInformation(std::vector& tinyInfo) const; - MEDCOUPLING_EXPORT void getTinySerializationDbleInformation(std::vector& tinyInfo) const; - MEDCOUPLING_EXPORT void getTinySerializationStrInformation(std::vector& tinyInfo) const; - MEDCOUPLING_EXPORT void resizeForUnserialization(const std::vector& tinyInfoI, std::vector& arrays); - MEDCOUPLING_EXPORT void checkForUnserialization(const std::vector& tinyInfoI, const std::vector& arrays); - MEDCOUPLING_EXPORT void finishUnserialization(const std::vector& tinyInfoI, const std::vector& tinyInfoD, const std::vector& tinyInfoS); - MEDCOUPLING_EXPORT void getTinySerializationIntInformation2(std::vector& tinyInfo) const; - MEDCOUPLING_EXPORT void getTinySerializationDbleInformation2(std::vector& tinyInfo) const; - MEDCOUPLING_EXPORT void finishUnserialization2(const std::vector& tinyInfoI, const std::vector& tinyInfoD); - MEDCOUPLING_EXPORT std::vector< const DataArrayDouble *> getArraysForTime(double time) const; - MEDCOUPLING_EXPORT void setArrays(const std::vector& arrays, TimeLabel *owner); + MEDCOUPLING_EXPORT void updateTime() const override; + MEDCOUPLING_EXPORT void synchronizeTimeWith(const MEDCouplingMesh *mesh) override; + MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const override; + MEDCOUPLING_EXPORT std::vector getDirectChildrenWithNull() const override; + MEDCOUPLING_EXPORT void copyTinyAttrFrom(const MEDCouplingTimeDiscretizationTemplate& other) override; + MEDCOUPLING_EXPORT void copyTinyStringsFrom(const MEDCouplingTimeDiscretizationTemplate& other) override; + MEDCOUPLING_EXPORT const DataArrayDouble *getEndArray() const override; + MEDCOUPLING_EXPORT DataArrayDouble *getEndArray() override; + MEDCOUPLING_EXPORT void checkConsistencyLight() const override; + MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate *other, double prec, std::string& reason) const override; + MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate *other, double prec) const override; + MEDCOUPLING_EXPORT void checkNoTimePresence() const override; + MEDCOUPLING_EXPORT void checkTimePresence(double time) const override; + MEDCOUPLING_EXPORT void getArrays(std::vector& arrays) const override; + MEDCOUPLING_EXPORT void setEndArray(DataArrayDouble *array, TimeLabel *owner) override; + MEDCOUPLING_EXPORT void setStartTime(double time, int iteration, int order) override { _start.setAllInfo(time,iteration,order); } + MEDCOUPLING_EXPORT void setEndTime(double time, int iteration, int order) override { _end.setAllInfo(time,iteration,order); } + MEDCOUPLING_EXPORT double getStartTime(int& iteration, int& order) const override { return _start.getAllInfo(iteration,order); } + MEDCOUPLING_EXPORT double getEndTime(int& iteration, int& order) const override { return _end.getAllInfo(iteration,order); } + MEDCOUPLING_EXPORT void setStartIteration(int it) override { _start.setIteration(it); } + MEDCOUPLING_EXPORT void setEndIteration(int it) override { _end.setIteration(it); } + MEDCOUPLING_EXPORT void setStartOrder(int order) override { _start.setOrder(order); } + MEDCOUPLING_EXPORT void setEndOrder(int order) override { _end.setOrder(order); } + MEDCOUPLING_EXPORT void setStartTimeValue(double time) override { _start.setTimeValue(time); } + MEDCOUPLING_EXPORT void setEndTimeValue(double time) override { _end.setTimeValue(time); } + MEDCOUPLING_EXPORT void getTinySerializationIntInformation(std::vector& tinyInfo) const override; + MEDCOUPLING_EXPORT void getTinySerializationDbleInformation(std::vector& tinyInfo) const override; + MEDCOUPLING_EXPORT void getTinySerializationStrInformation(std::vector& tinyInfo) const override; + MEDCOUPLING_EXPORT void resizeForUnserialization(const std::vector& tinyInfoI, std::vector& arrays) override; + MEDCOUPLING_EXPORT void checkForUnserialization(const std::vector& tinyInfoI, const std::vector& arrays) override; + MEDCOUPLING_EXPORT void finishUnserialization(const std::vector& tinyInfoI, const std::vector& tinyInfoD, const std::vector& tinyInfoS) override; + MEDCOUPLING_EXPORT void getTinySerializationIntInformation2(std::vector& tinyInfo) const override; + MEDCOUPLING_EXPORT void getTinySerializationDbleInformation2(std::vector& tinyInfo) const override; + MEDCOUPLING_EXPORT void finishUnserialization2(const std::vector& tinyInfoI, const std::vector& tinyInfoD) override; + MEDCOUPLING_EXPORT std::vector< const DataArrayDouble *> getArraysForTime(double time) const override; + MEDCOUPLING_EXPORT void setArrays(const std::vector& arrays, TimeLabel *owner) override; protected: static const char EXCEPTION_MSG[]; protected: @@ -531,35 +533,35 @@ namespace MEDCoupling MEDCOUPLING_EXPORT MEDCouplingLinearTime(const MEDCouplingLinearTime& other, bool deepCopy); public: MEDCOUPLING_EXPORT MEDCouplingLinearTime(); - MEDCOUPLING_EXPORT std::string getStringRepr() const; - MEDCOUPLING_EXPORT TypeOfTimeDiscretization getEnum() const { return DISCRETIZATION; } - MEDCOUPLING_EXPORT void checkConsistencyLight() const; - MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *performCopyOrIncrRef(bool deepCopy) const; - MEDCOUPLING_EXPORT bool areCompatible(const MEDCouplingTimeDiscretizationTemplate *other) const; - MEDCOUPLING_EXPORT bool areStrictlyCompatible(const MEDCouplingTimeDiscretizationTemplate *other, std::string& reason) const; - MEDCOUPLING_EXPORT bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretizationTemplate *other) const; - MEDCOUPLING_EXPORT bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretizationTemplate *other) const; - MEDCOUPLING_EXPORT bool areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const; - MEDCOUPLING_EXPORT void getValueForTime(double time, const std::vector& vals, double *res) const; - MEDCOUPLING_EXPORT void getValueOnTime(mcIdType eltId, double time, double *value) const; - MEDCOUPLING_EXPORT void getValueOnDiscTime(mcIdType eltId, int iteration, int order, double *value) const; - MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *aggregate(const MEDCouplingTimeDiscretization *other) const; - MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *aggregate(const std::vector& other) const; - MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *meld(const MEDCouplingTimeDiscretization *other) const; - MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *dot(const MEDCouplingTimeDiscretization *other) const; - MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *crossProduct(const MEDCouplingTimeDiscretization *other) const; - MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *max(const MEDCouplingTimeDiscretization *other) const; - MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *min(const MEDCouplingTimeDiscretization *other) const; - MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *add(const MEDCouplingTimeDiscretization *other) const; - MEDCOUPLING_EXPORT void addEqual(const MEDCouplingTimeDiscretization *other); - MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *substract(const MEDCouplingTimeDiscretization *other) const; - MEDCOUPLING_EXPORT void substractEqual(const MEDCouplingTimeDiscretization *other); - MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *multiply(const MEDCouplingTimeDiscretization *other) const; - MEDCOUPLING_EXPORT void multiplyEqual(const MEDCouplingTimeDiscretization *other); - MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *divide(const MEDCouplingTimeDiscretization *other) const; - MEDCOUPLING_EXPORT void divideEqual(const MEDCouplingTimeDiscretization *other); - MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *pow(const MEDCouplingTimeDiscretization *other) const; - MEDCOUPLING_EXPORT void powEqual(const MEDCouplingTimeDiscretization *other); + MEDCOUPLING_EXPORT std::string getStringRepr() const override; + MEDCOUPLING_EXPORT TypeOfTimeDiscretization getEnum() const override { return DISCRETIZATION; } + MEDCOUPLING_EXPORT void checkConsistencyLight() const override; + MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *performCopyOrIncrRef(bool deepCopy) const override; + MEDCOUPLING_EXPORT bool areCompatible(const MEDCouplingTimeDiscretizationTemplate *other) const override; + MEDCOUPLING_EXPORT bool areStrictlyCompatible(const MEDCouplingTimeDiscretizationTemplate *other, std::string& reason) const override; + MEDCOUPLING_EXPORT bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretizationTemplate *other) const override; + MEDCOUPLING_EXPORT bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretizationTemplate *other) const override; + MEDCOUPLING_EXPORT bool areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const override; + MEDCOUPLING_EXPORT void getValueForTime(double time, const std::vector& vals, double *res) const override; + MEDCOUPLING_EXPORT void getValueOnTime(mcIdType eltId, double time, double *value) const override; + MEDCOUPLING_EXPORT void getValueOnDiscTime(mcIdType eltId, int iteration, int order, double *value) const override; + MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *aggregate(const MEDCouplingTimeDiscretization *other) const override; + MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *aggregate(const std::vector& other) const override; + MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *meld(const MEDCouplingTimeDiscretization *other) const override; + MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *dot(const MEDCouplingTimeDiscretization *other) const override; + MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *crossProduct(const MEDCouplingTimeDiscretization *other) const override; + MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *max(const MEDCouplingTimeDiscretization *other) const override; + MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *min(const MEDCouplingTimeDiscretization *other) const override; + MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *add(const MEDCouplingTimeDiscretization *other) const override; + MEDCOUPLING_EXPORT void addEqual(const MEDCouplingTimeDiscretization *other) override; + MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *substract(const MEDCouplingTimeDiscretization *other) const override; + MEDCOUPLING_EXPORT void substractEqual(const MEDCouplingTimeDiscretization *other) override; + MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *multiply(const MEDCouplingTimeDiscretization *other) const override; + MEDCOUPLING_EXPORT void multiplyEqual(const MEDCouplingTimeDiscretization *other) override; + MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *divide(const MEDCouplingTimeDiscretization *other) const override; + MEDCOUPLING_EXPORT void divideEqual(const MEDCouplingTimeDiscretization *other) override; + MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *pow(const MEDCouplingTimeDiscretization *other) const override; + MEDCOUPLING_EXPORT void powEqual(const MEDCouplingTimeDiscretization *other) override; public: static const TypeOfTimeDiscretization DISCRETIZATION=LINEAR_TIME; MEDCOUPLING_EXPORT static const char REPR[]; diff --git a/src/MEDCoupling/MEDCouplingTimeDiscretization.txx b/src/MEDCoupling/MEDCouplingTimeDiscretization.txx index a02489ac1..f48d9b772 100644 --- a/src/MEDCoupling/MEDCouplingTimeDiscretization.txx +++ b/src/MEDCoupling/MEDCouplingTimeDiscretization.txx @@ -21,11 +21,19 @@ #ifndef __MEDCOUPLINGTIMEDISCRETIZATION_TXX__ #define __MEDCOUPLINGTIMEDISCRETIZATION_TXX__ +#include "MEDCouplingRefCountObject.hxx" +#include "MCType.hxx" #include "MEDCouplingTimeDiscretization.hxx" +#include "MEDCouplingTraits.hxx" +#include "InterpKernelException.hxx" #include "MEDCouplingMemArray.txx" +#include #include +#include #include +#include +#include namespace MEDCoupling { @@ -111,9 +119,9 @@ namespace MEDCoupling reason=oss.str(); return false; } - if(_array==0 && other->_array==0) + if(_array==nullptr && other->_array==nullptr) return true; - if(_array==0 || other->_array==0) + if(_array==nullptr || other->_array==nullptr) { reason="Field discretizations differ : Only one timediscretization between the two this and other has a DataArrayDouble for values defined"; return false; @@ -130,9 +138,9 @@ namespace MEDCoupling { if(std::fabs(_time_tolerance-other->_time_tolerance)>1.e-16) return false; - if(_array==0 && other->_array==0) + if(_array==nullptr && other->_array==nullptr) return true; - if(_array==0 || other->_array==0) + if(_array==nullptr || other->_array==nullptr) return false; if(_array->getNumberOfComponents()!=other->_array->getNumberOfComponents()) return false; @@ -144,12 +152,12 @@ namespace MEDCoupling { if(std::fabs(_time_tolerance-other->_time_tolerance)>1.e-16) return false; - if(_array==0 && other->_array==0) + if(_array==nullptr && other->_array==nullptr) return true; - if(_array==0 || other->_array==0) + if(_array==nullptr || other->_array==nullptr) return false; std::size_t nbC1(_array->getNumberOfComponents()),nbC2(other->_array->getNumberOfComponents()); - std::size_t nbMin(std::min(nbC1,nbC2)); + std::size_t const nbMin(std::min(nbC1,nbC2)); if(nbC1!=nbC2 && nbMin!=1) return false; return true; @@ -160,9 +168,9 @@ namespace MEDCoupling { if(std::fabs(_time_tolerance-other->_time_tolerance)>1.e-16) return false; - if(_array==0 && other->_array==0) + if(_array==nullptr && other->_array==nullptr) return true; - if(_array==0 || other->_array==0) + if(_array==nullptr || other->_array==nullptr) return false; std::size_t nbC1(_array->getNumberOfComponents()),nbC2(other->_array->getNumberOfComponents()); if(nbC1!=nbC2 && nbC2!=1) @@ -171,7 +179,7 @@ namespace MEDCoupling } template - MEDCouplingTimeDiscretizationTemplate::MEDCouplingTimeDiscretizationTemplate():_time_tolerance(TIME_TOLERANCE_DFT),_array(0) + MEDCouplingTimeDiscretizationTemplate::MEDCouplingTimeDiscretizationTemplate():_time_tolerance(TIME_TOLERANCE_DFT),_array(nullptr) { } @@ -181,7 +189,7 @@ namespace MEDCoupling if(other._array) _array=other._array->performCopyOrIncrRef(deepCopy); else - _array=0; + _array=nullptr; } template @@ -192,7 +200,7 @@ namespace MEDCoupling } template - void MEDCouplingTimeDiscretizationTemplate::setEndArray(typename Traits::ArrayType *array, TimeLabel *owner) + void MEDCouplingTimeDiscretizationTemplate::setEndArray(typename Traits::ArrayType * /*array*/, TimeLabel * /*owner*/) { throw INTERP_KERNEL::Exception("setEndArray not available for this type of time discretization !"); } @@ -248,7 +256,7 @@ namespace MEDCoupling template void MEDCouplingTimeDiscretizationTemplate::getTinySerializationStrInformation(std::vector& tinyInfo) const { - std::size_t nbOfCompo(_array->getNumberOfComponents()); + std::size_t const nbOfCompo(_array->getNumberOfComponents()); for(std::size_t i=0;igetInfoOnComponent(i)); } @@ -257,9 +265,9 @@ namespace MEDCoupling void MEDCouplingTimeDiscretizationTemplate::resizeForUnserialization(const std::vector& tinyInfoI, std::vector::ArrayType *>& arrays) { arrays.resize(1); - if(_array!=0) + if(_array!=nullptr) _array->decrRef(); - typename Traits::ArrayType *arr=0; + typename Traits::ArrayType *arr=nullptr; if(tinyInfoI[0]!=-1 && tinyInfoI[1]!=-1) { arr=Traits::ArrayType::New(); @@ -275,9 +283,9 @@ namespace MEDCoupling static const char MSG[]="MEDCouplingTimeDiscretization::checkForUnserialization : arrays in input is expected to have size one !"; if(arrays.size()!=1) throw INTERP_KERNEL::Exception(MSG); - if(_array!=0) + if(_array!=nullptr) _array->decrRef(); - _array=0; + _array=nullptr; if(tinyInfoI[0]!=-1 && tinyInfoI[1]!=-1) { if(!arrays[0]) @@ -289,10 +297,10 @@ namespace MEDCoupling } template - void MEDCouplingTimeDiscretizationTemplate::finishUnserialization(const std::vector& tinyInfoI, const std::vector& tinyInfoD, const std::vector& tinyInfoS) + void MEDCouplingTimeDiscretizationTemplate::finishUnserialization(const std::vector& /*tinyInfoI*/, const std::vector& tinyInfoD, const std::vector& tinyInfoS) { _time_tolerance=tinyInfoD[0]; - std::size_t nbOfCompo=_array->getNumberOfComponents(); + std::size_t const nbOfCompo=_array->getNumberOfComponents(); for(std::size_t i=0;isetInfoOnComponent(i,tinyInfoS[i]); } @@ -309,31 +317,31 @@ namespace MEDCoupling } template - double MEDCouplingTimeDiscretizationSimple::getEndTime(int& iteration, int& order) const + double MEDCouplingTimeDiscretizationSimple::getEndTime(int& /*iteration*/, int& /*order*/) const { throw INTERP_KERNEL::Exception("getEndTime : invalid for this type of time discr !"); } template - void MEDCouplingTimeDiscretizationSimple::setEndIteration(int it) + void MEDCouplingTimeDiscretizationSimple::setEndIteration(int /*it*/) { throw INTERP_KERNEL::Exception("setEndIteration : invalid for this type of time discr !"); } template - void MEDCouplingTimeDiscretizationSimple::setEndOrder(int order) + void MEDCouplingTimeDiscretizationSimple::setEndOrder(int /*order*/) { throw INTERP_KERNEL::Exception("setEndOrder : invalid for this type of time discr !"); } template - void MEDCouplingTimeDiscretizationSimple::setEndTimeValue(double time) + void MEDCouplingTimeDiscretizationSimple::setEndTimeValue(double /*time*/) { throw INTERP_KERNEL::Exception("setEndTimeValue : invalid for this type of time discr !"); } template - void MEDCouplingTimeDiscretizationSimple::setEndTime(double time, int iteration, int order) + void MEDCouplingTimeDiscretizationSimple::setEndTime(double /*time*/, int /*iteration*/, int /*order*/) { throw INTERP_KERNEL::Exception("setEndTime : invalid for this type of time discr !"); } diff --git a/src/MEDCoupling/MEDCouplingTimeLabel.cxx b/src/MEDCoupling/MEDCouplingTimeLabel.cxx index fe4173d30..c0ca4e22b 100644 --- a/src/MEDCoupling/MEDCouplingTimeLabel.cxx +++ b/src/MEDCoupling/MEDCouplingTimeLabel.cxx @@ -22,6 +22,8 @@ #include "InterpKernelException.hxx" +#include +#include #include using namespace MEDCoupling; @@ -33,10 +35,9 @@ TimeLabel::TimeLabel():_time(GLOBAL_TIME++) } TimeLabel::~TimeLabel() -{ -} += default; -TimeLabel& TimeLabel::operator=(const TimeLabel& other) +TimeLabel& TimeLabel::operator=(const TimeLabel& /*other*/) { _time=GLOBAL_TIME++; return *this; diff --git a/src/MEDCoupling/MEDCouplingTraits.cxx b/src/MEDCoupling/MEDCouplingTraits.cxx index 55417282c..37167fa0d 100644 --- a/src/MEDCoupling/MEDCouplingTraits.cxx +++ b/src/MEDCoupling/MEDCouplingTraits.cxx @@ -19,6 +19,7 @@ // Author : Anthony Geay (EDF R&D) #include "MEDCouplingTraits.hxx" +#include "MCType.hxx" using namespace MEDCoupling; diff --git a/src/MEDCoupling/MEDCouplingTraits.hxx b/src/MEDCoupling/MEDCouplingTraits.hxx index 7602cbfd6..1a4381179 100644 --- a/src/MEDCoupling/MEDCouplingTraits.hxx +++ b/src/MEDCoupling/MEDCouplingTraits.hxx @@ -22,7 +22,6 @@ #include "MEDCoupling.hxx" #include "MCType.hxx" -#include namespace MEDCoupling { diff --git a/src/MEDCoupling/MEDCouplingUMesh.cxx b/src/MEDCoupling/MEDCouplingUMesh.cxx old mode 100755 new mode 100644 index 5f7cccd60..853a68b5c --- a/src/MEDCoupling/MEDCouplingUMesh.cxx +++ b/src/MEDCoupling/MEDCouplingUMesh.cxx @@ -18,19 +18,30 @@ // // Author : Anthony Geay (EDF R&D) -#include "MEDCouplingUMesh.txx" +#include "InterpKernelHashMap.hxx" +#include "MCAuto.hxx" +#include "MCIdType.hxx" +#include "MCType.hxx" +#include "InterpKernelException.hxx" +#include "InterpKernelGeo2DPrecision.hxx" #include "MEDCouplingCMesh.hxx" #include "MEDCoupling1GTUMesh.hxx" #include "MEDCouplingFieldDouble.hxx" +#include "MEDCouplingPointSet.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include "MEDCouplingMesh.hxx" +#include "MEDCouplingMemArray.txx" #include "MEDCouplingSkyLineArray.hxx" #include "CellModel.hxx" +#include "MEDCouplingUMesh.txx" +#include "NormalizedGeometricTypes" +#include "NormalizedUnstructuredMesh.hxx" +#include "VolSurfFormulae.hxx" +#include "MEDCouplingTraits.hxx" #include "VolSurfUser.txx" #include "InterpolationUtils.hxx" -#include "PointLocatorAlgos.txx" -#include "BBTree.txx" #include "BBTreeDst.txx" -#include "SplitterTetra.hxx" -#include "DiameterCalculator.hxx" +#include "SplitterTetra.txx" #include "DirectedBoundingBox.hxx" #include "InterpKernelMatrixTools.hxx" #include "InterpKernelMeshQuality.hxx" @@ -38,19 +49,30 @@ #include "InterpKernelGeo2DEdgeArcCircle.hxx" #include "InterpKernelAutoPtr.hxx" #include "InterpKernelGeo2DNode.hxx" -#include "InterpKernelGeo2DEdgeLin.hxx" #include "InterpKernelGeo2DEdgeArcCircle.hxx" #include "InterpKernelGeo2DQuadraticPolygon.hxx" -#include "OrientationInverter.hxx" #include "MEDCouplingUMesh_internal.hxx" +#include "OrientationInverter.hxx" +#include "DiameterCalculator.hxx" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include -#include #include -#include #include #include -#include +#include +#include +#include using namespace MEDCoupling; @@ -68,7 +90,7 @@ MEDCouplingUMesh *MEDCouplingUMesh::New() MEDCouplingUMesh *MEDCouplingUMesh::New(const std::string& meshName, int meshDim) { - MEDCouplingUMesh *ret=new MEDCouplingUMesh; + auto *ret=new MEDCouplingUMesh; ret->setName(meshName); ret->setMeshDimension(meshDim); return ret; @@ -118,16 +140,16 @@ void MEDCouplingUMesh::shallowCopyConnectivityFrom(const MEDCouplingPointSet *ot { if(!other) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::shallowCopyConnectivityFrom : input pointer is null !"); - const MEDCouplingUMesh *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::shallowCopyConnectivityFrom : input pointer is not an MEDCouplingUMesh instance !"); - MEDCouplingUMesh *otherC2=const_cast(otherC);//sorry :( + auto *otherC2=const_cast(otherC);//sorry :( setConnectivity(otherC2->getNodalConnectivity(),otherC2->getNodalConnectivityIndex(),true); } std::size_t MEDCouplingUMesh::getHeapMemorySizeWithoutChildren() const { - std::size_t ret(MEDCouplingPointSet::getHeapMemorySizeWithoutChildren()); + std::size_t const ret(MEDCouplingPointSet::getHeapMemorySizeWithoutChildren()); return ret; } @@ -152,7 +174,7 @@ void MEDCouplingUMesh::updateTime() const } } -MEDCouplingUMesh::MEDCouplingUMesh():_mesh_dim(-2),_nodal_connec(0),_nodal_connec_index(0) +MEDCouplingUMesh::MEDCouplingUMesh():_mesh_dim(-2),_nodal_connec(nullptr),_nodal_connec_index(nullptr) { } @@ -175,12 +197,12 @@ void MEDCouplingUMesh::checkConsistencyLight() const throw INTERP_KERNEL::Exception("No mesh dimension specified !"); if(_mesh_dim!=-1) MEDCouplingPointSet::checkConsistencyLight(); - for(std::set::const_iterator iter=_types.begin();iter!=_types.end();iter++) + for(auto _type : _types) { - if(ToIdType(INTERP_KERNEL::CellModel::GetCellModel(*iter).getDimension())!=_mesh_dim) + if(ToIdType(INTERP_KERNEL::CellModel::GetCellModel(_type).getDimension())!=_mesh_dim) { std::ostringstream message; - message << "Mesh invalid because dimension is " << _mesh_dim << " and there is presence of cell(s) with type " << (*iter); + message << "Mesh invalid because dimension is " << _mesh_dim << " and there is presence of cell(s) with type " << _type; throw INTERP_KERNEL::Exception(message.str().c_str()); } } @@ -226,14 +248,14 @@ void MEDCouplingUMesh::checkConsistencyLight() const * \throw If number of nodes defining an element does not correspond to the type of element. * \throw If the nodal connectivity includes an invalid node id. */ -void MEDCouplingUMesh::checkConsistency(double eps) const +void MEDCouplingUMesh::checkConsistency(double /*eps*/) const { checkConsistencyLight(); if(_mesh_dim==-1) return ; - int meshDim=getMeshDimension(); - mcIdType nbOfNodes=getNumberOfNodes(); - mcIdType nbOfCells=getNumberOfCells(); + int const meshDim=getMeshDimension(); + mcIdType const nbOfNodes=getNumberOfNodes(); + mcIdType const nbOfCells=getNumberOfCells(); const mcIdType *ptr=_nodal_connec->getConstPointer(); const mcIdType *ptrI=_nodal_connec_index->getConstPointer(); for(mcIdType i=0;i=0) { if(nodeId>=nbOfNodes) @@ -303,7 +325,7 @@ void MEDCouplingUMesh::checkGeomConsistency(double eps) const const mcIdType *ptr(_nodal_connec->begin()),*ptrI(_nodal_connec_index->begin()); for(auto icell = 0 ; icell < nbOfCells ; ++icell) { - std::set s(ptr+ptrI[icell]+1,ptr+ptrI[icell+1]); + std::set const s(ptr+ptrI[icell]+1,ptr+ptrI[icell+1]); if(ToIdType(s.size())==ptrI[icell+1]-ptrI[icell]-1) continue; std::ostringstream oss; oss << "MEDCouplingUMesh::checkGeomConsistency : for cell #" << icell << " presence of multiple same nodeID !"; @@ -376,7 +398,7 @@ void MEDCouplingUMesh::allocateCells(mcIdType nbOfCells) void MEDCouplingUMesh::insertNextCell(INTERP_KERNEL::NormalizedCellType type, mcIdType size, const mcIdType *nodalConnOfCell) { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(type); - if(_nodal_connec_index==0) + if(_nodal_connec_index==nullptr) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::insertNextCell : nodal connectivity not set ! invoke allocateCells before calling insertNextCell !"); if(ToIdType(cm.getDimension())==_mesh_dim) { @@ -387,8 +409,8 @@ void MEDCouplingUMesh::insertNextCell(INTERP_KERNEL::NormalizedCellType type, mc oss << " ! Expecting " << cm.getNumberOfNodes() << " !"; throw INTERP_KERNEL::Exception(oss.str()); } - mcIdType idx=_nodal_connec_index->back(); - mcIdType val=idx+size+1; + mcIdType const idx=_nodal_connec_index->back(); + mcIdType const val=idx+size+1; _nodal_connec_index->pushBackSilent(val); _nodal_connec->writeOnPlace(idx,type,nodalConnOfCell,size); _types.insert(type); @@ -466,7 +488,7 @@ std::vector MEDCouplingUMesh::getAllGeoTypesS { std::vector ret; checkConnectivityFullyDefined(); - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbOfCells=getNumberOfCells(); if(nbOfCells==0) return ret; if(getNodalConnectivityArrayLen()<1) @@ -488,7 +510,7 @@ bool MEDCouplingUMesh::isEqualIfNotWhy(const MEDCouplingMesh *other, double prec if(!other) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::isEqualIfNotWhy : input other pointer is null !"); std::ostringstream oss; oss.precision(15); - const MEDCouplingUMesh *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) { reason="mesh given in input is not castable in MEDCouplingUMesh !"; @@ -505,16 +527,16 @@ bool MEDCouplingUMesh::isEqualIfNotWhy(const MEDCouplingMesh *other, double prec if(_types!=otherC->_types) { oss << "umesh geometric type mismatch :\nThis geometric types are :"; - for(std::set::const_iterator iter=_types.begin();iter!=_types.end();iter++) - { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*iter); oss << cm.getRepr() << ", "; } + for(auto _type : _types) + { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_type); oss << cm.getRepr() << ", "; } oss << "\nOther geometric types are :"; - for(std::set::const_iterator iter=otherC->_types.begin();iter!=otherC->_types.end();iter++) - { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*iter); oss << cm.getRepr() << ", "; } + for(auto _type : otherC->_types) + { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_type); oss << cm.getRepr() << ", "; } reason=oss.str(); return false; } - if(_nodal_connec!=0 || otherC->_nodal_connec!=0) - if(_nodal_connec==0 || otherC->_nodal_connec==0) + if(_nodal_connec!=nullptr || otherC->_nodal_connec!=nullptr) + if(_nodal_connec==nullptr || otherC->_nodal_connec==nullptr) { reason="Only one UMesh between the two this and other has its nodal connectivity DataArrayInt defined !"; return false; @@ -525,8 +547,8 @@ bool MEDCouplingUMesh::isEqualIfNotWhy(const MEDCouplingMesh *other, double prec reason.insert(0,"Nodal connectivity DataArrayInt differ : "); return false; } - if(_nodal_connec_index!=0 || otherC->_nodal_connec_index!=0) - if(_nodal_connec_index==0 || otherC->_nodal_connec_index==0) + if(_nodal_connec_index!=nullptr || otherC->_nodal_connec_index!=nullptr) + if(_nodal_connec_index==nullptr || otherC->_nodal_connec_index==nullptr) { reason="Only one UMesh between the two this and other has its nodal connectivity index DataArrayInt defined !"; return false; @@ -550,7 +572,7 @@ bool MEDCouplingUMesh::isEqualIfNotWhy(const MEDCouplingMesh *other, double prec */ bool MEDCouplingUMesh::isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const { - const MEDCouplingUMesh *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) return false; if(!MEDCouplingPointSet::isEqualWithoutConsideringStr(other,prec)) @@ -559,14 +581,14 @@ bool MEDCouplingUMesh::isEqualWithoutConsideringStr(const MEDCouplingMesh *other return false; if(_types!=otherC->_types) return false; - if(_nodal_connec!=0 || otherC->_nodal_connec!=0) - if(_nodal_connec==0 || otherC->_nodal_connec==0) + if(_nodal_connec!=nullptr || otherC->_nodal_connec!=nullptr) + if(_nodal_connec==nullptr || otherC->_nodal_connec==nullptr) return false; if(_nodal_connec!=otherC->_nodal_connec) if(!_nodal_connec->isEqualWithoutConsideringStr(*otherC->_nodal_connec)) return false; - if(_nodal_connec_index!=0 || otherC->_nodal_connec_index!=0) - if(_nodal_connec_index==0 || otherC->_nodal_connec_index==0) + if(_nodal_connec_index!=nullptr || otherC->_nodal_connec_index!=nullptr) + if(_nodal_connec_index==nullptr || otherC->_nodal_connec_index==nullptr) return false; if(_nodal_connec_index!=otherC->_nodal_connec_index) if(!_nodal_connec_index->isEqualWithoutConsideringStr(*otherC->_nodal_connec_index)) @@ -587,7 +609,7 @@ bool MEDCouplingUMesh::isEqualWithoutConsideringStr(const MEDCouplingMesh *other void MEDCouplingUMesh::checkFastEquivalWith(const MEDCouplingMesh *other, double prec) const { MEDCouplingPointSet::checkFastEquivalWith(other,prec); - const MEDCouplingUMesh *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::checkFastEquivalWith : Two meshes are not not unstructured !"); } @@ -618,8 +640,8 @@ void MEDCouplingUMesh::checkFastEquivalWith(const MEDCouplingMesh *other, double void MEDCouplingUMesh::getReverseNodalConnectivity(DataArrayIdType *revNodal, DataArrayIdType *revNodalIndx) const { checkFullyDefined(); - mcIdType nbOfNodes(getNumberOfNodes()); - mcIdType *revNodalIndxPtr=(mcIdType *)malloc((nbOfNodes+1)*sizeof(mcIdType)); + mcIdType const nbOfNodes(getNumberOfNodes()); + auto *revNodalIndxPtr=(mcIdType *)malloc((nbOfNodes+1)*sizeof(mcIdType)); revNodalIndx->useArray(revNodalIndxPtr,true,DeallocType::C_DEALLOC,nbOfNodes+1,1); std::fill(revNodalIndxPtr,revNodalIndxPtr+nbOfNodes+1,0); const mcIdType *conn(_nodal_connec->begin()),*connIndex(_nodal_connec_index->begin()); @@ -635,7 +657,7 @@ void MEDCouplingUMesh::getReverseNodalConnectivity(DataArrayIdType *revNodal, Da } } std::transform(revNodalIndxPtr+1,revNodalIndxPtr+nbOfNodes+1,revNodalIndxPtr,revNodalIndxPtr+1,std::plus()); - mcIdType *revNodalPtr=(mcIdType *)malloc(nbOfEltsInRevNodal*sizeof(mcIdType)); + auto *revNodalPtr=(mcIdType *)malloc(nbOfEltsInRevNodal*sizeof(mcIdType)); revNodal->useArray(revNodalPtr,true,DeallocType::C_DEALLOC,nbOfEltsInRevNodal,1); std::fill(revNodalPtr,revNodalPtr+nbOfEltsInRevNodal,-1); for(mcIdType eltId=0;eltId MEDCouplingUMesh::explodeMeshTo(int targetDeltaLevel, M if( targetDeltaLevel == -1 ) { desc = DataArrayIdType::New(); descIndx = DataArrayIdType::New(); revDesc = DataArrayIdType::New(); revDescIndx = DataArrayIdType::New(); - MCAuto ret( this->buildDescendingConnectivity(desc,descIndx,revDesc,revDescIndx) ); + MCAuto const ret( this->buildDescendingConnectivity(desc,descIndx,revDesc,revDescIndx) ); return ret; } if( targetDeltaLevel == -2 && this->getMeshDimension() == 3 ) { desc = DataArrayIdType::New(); descIndx = DataArrayIdType::New(); revDesc = DataArrayIdType::New(); revDescIndx = DataArrayIdType::New(); - MCAuto ret( this->explode3DMeshTo1D(desc,descIndx,revDesc,revDescIndx) ); + MCAuto const ret( this->explode3DMeshTo1D(desc,descIndx,revDesc,revDescIndx) ); return ret; } if( targetDeltaLevel == -this->getMeshDimension() ) { - MCAuto ret = MEDCouplingUMesh::Build0DMeshFromCoords( const_cast( this->getCoords() ) ); + MCAuto const ret = MEDCouplingUMesh::Build0DMeshFromCoords( const_cast( this->getCoords() ) ); MEDCouplingUMesh::DeleteCellTypeInIndexedArray(getNodalConnectivity(),getNodalConnectivityIndex(),desc,descIndx); revDesc = DataArrayIdType::New(); revDescIndx = DataArrayIdType::New(); this->getReverseNodalConnectivity(revDesc,revDescIndx); @@ -849,7 +871,7 @@ void MEDCouplingUMesh::computeNeighborsOfCells(DataArrayIdType *&neighbors, Data MCAuto revDesc=DataArrayIdType::New(); MCAuto revDescIndx=DataArrayIdType::New(); MCAuto meshDM1=buildDescendingConnectivity(desc,descIndx,revDesc,revDescIndx); - meshDM1=0; + meshDM1=nullptr; ComputeNeighborsOfCellsAdv(desc,descIndx,revDesc,revDescIndx,neighbors,neighborsIndx); } @@ -878,7 +900,7 @@ void MEDCouplingUMesh::computeCellNeighborhoodFromNodesOne(const DataArrayIdType nodeNeigh->checkNbOfComps(1,"MEDCouplingUMesh::computeCellNeighborhoodFromNodesOne : node neigh"); nodeNeighI->checkNbOfComps(1,"MEDCouplingUMesh::computeCellNeighborhoodFromNodesOne : node neigh index"); nodeNeighI->checkNbOfTuples(1+getNumberOfNodes(),"MEDCouplingUMesh::computeCellNeighborhoodFromNodesOne : invalid length"); - mcIdType nbCells=getNumberOfCells(); + mcIdType const nbCells=getNumberOfCells(); const mcIdType *c(_nodal_connec->begin()),*ci(_nodal_connec_index->begin()),*ne(nodeNeigh->begin()),*nei(nodeNeighI->begin()); cellNeigh=DataArrayIdType::New(); cellNeigh->alloc(0,1); cellNeighIndex=DataArrayIdType::New(); cellNeighIndex->alloc(1,1); cellNeighIndex->setIJ(0,0,0); for(mcIdType i=0;ibegin(); const mcIdType *revDescIPtr=revDescIndx->begin(); // - mcIdType nbCells=descIndx->getNumberOfTuples()-1; + mcIdType const nbCells=descIndx->getNumberOfTuples()-1; MCAuto out0=DataArrayIdType::New(); MCAuto out1=DataArrayIdType::New(); out1->alloc(nbCells+1,1); mcIdType *out1Ptr=out1->getPointer(); @@ -949,7 +971,7 @@ void MEDCouplingUMesh::ComputeNeighborsOfCellsAdv(const DataArrayIdType *desc, c MCAuto MEDCouplingUMesh::explodeIntoEdges(MCAuto& desc, MCAuto& descIndex, MCAuto& revDesc, MCAuto& revDescIndx) const { checkFullyDefined(); - int mdim(getMeshDimension()); + int const mdim(getMeshDimension()); desc=DataArrayIdType::New(); descIndex=DataArrayIdType::New(); revDesc=DataArrayIdType::New(); revDescIndx=DataArrayIdType::New(); MCAuto mesh1D; switch(mdim) @@ -1017,7 +1039,7 @@ void MEDCouplingUMesh::computeNeighborsOfNodes(DataArrayIdType *&neighbors, Data throw INTERP_KERNEL::Exception("MEDCouplingUMesh::computeNeighborsOfNodes : Mesh dimension supported are [3,2,1] !"); } } - desc=DataArrayIdType::New(); descIndx=DataArrayIdType::New(); revDesc=0; revDescIndx=0; + desc=DataArrayIdType::New(); descIndx=DataArrayIdType::New(); revDesc=nullptr; revDescIndx=nullptr; mesh1D->getReverseNodalConnectivity(desc,descIndx); MCAuto ret0(DataArrayIdType::New()); ret0->alloc(desc->getNumberOfTuples(),1); @@ -1042,15 +1064,15 @@ void MEDCouplingUMesh::computeNeighborsOfNodes(DataArrayIdType *&neighbors, Data void MEDCouplingUMesh::computeEnlargedNeighborsOfNodes(MCAuto &neighbors, MCAuto& neighborsIdx) const { checkFullyDefined(); - mcIdType nbOfNodes(getNumberOfNodes()); + mcIdType const nbOfNodes(getNumberOfNodes()); const mcIdType *conn(_nodal_connec->begin()),*connIndex(_nodal_connec_index->begin()); - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbOfCells=getNumberOfCells(); std::vector< std::set > st0(nbOfNodes); for(mcIdType eltId=0;eltId s(strtNdlConnOfCurCell,endNdlConnOfCurCell); s.erase(-1); //for polyhedrons - for(std::set::const_iterator iter2=s.begin();iter2!=s.end();iter2++) + for(auto iter2=s.begin();iter2!=s.end();iter2++) st0[*iter2].insert(s.begin(),s.end()); } neighborsIdx=DataArrayIdType::New(); neighborsIdx->alloc(nbOfNodes+1,1); neighborsIdx->setIJ(0,0,0); @@ -1102,10 +1124,10 @@ void MEDCouplingUMesh::computeEnlargedNeighborsOfNodes(MCAuto & void MEDCouplingUMesh::convertToPolyTypes(const mcIdType *cellIdsToConvertBg, const mcIdType *cellIdsToConvertEnd) { checkFullyDefined(); - int dim=getMeshDimension(); + int const dim=getMeshDimension(); if(dim<2 || dim>3) throw INTERP_KERNEL::Exception("Invalid mesh dimension : must be 2 or 3 !"); - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbOfCells=getNumberOfCells(); if(dim==2) { const mcIdType *connIndex=_nodal_connec_index->begin(); @@ -1148,21 +1170,21 @@ void MEDCouplingUMesh::convertToPolyTypes(const mcIdType *cellIdsToConvertBg, co for(mcIdType cellId=0;cellIdpushBackValsSilent(tmp,tmp+newLgth); connNewI->pushBackSilent(connNewI->back()+ToIdType(newLgth)); delete [] tmp; @@ -1190,7 +1212,7 @@ void MEDCouplingUMesh::convertToPolyTypes(const mcIdType *cellIdsToConvertBg, co */ void MEDCouplingUMesh::convertAllToPoly() { - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbOfCells=getNumberOfCells(); std::vector cellIds(nbOfCells); for(mcIdType i=0;i newCi=DataArrayIdType::New(); newCi->alloc(nbOfCells+1,1); mcIdType *newci=newCi->getPointer(); @@ -1238,7 +1260,7 @@ void MEDCouplingUMesh::convertExtrudedPolyhedra() newci[0]=0; for(mcIdType i=0;igetPointer(); for(mcIdType i=0;igetPointer(); mcIdType *index=_nodal_connec_index->getPointer(); mcIdType posOfCurCell=0; @@ -1323,7 +1345,7 @@ bool MEDCouplingUMesh::unPolyze() for(mcIdType i=0;i coords=getCoords()->deepCopy(); coords->recenterForMaxPrecision(eps); // - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbOfCells=getNumberOfCells(); const mcIdType *conn=_nodal_connec->getConstPointer(); const mcIdType *index=_nodal_connec_index->getConstPointer(); MCAuto connINew=DataArrayIdType::New(); @@ -1435,7 +1457,7 @@ void MEDCouplingUMesh::colinearizeEdges(double eps) checkFullyDefined(); if(getMeshDimension()!=3 || getSpaceDimension()!=3) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::colinearizeEdges() : works with meshdim=3 and spaceDim=3!"); - double seps = sqrt(1-eps); + double const seps = sqrt(1-eps); // Computing connectivities and correspondances : elements -> segments -> points DAI E_Fi(DataArrayIdType::New()), E_F(DataArrayIdType::New()), F_Ei(DataArrayIdType::New()), F_E(DataArrayIdType::New()), F_Si(DataArrayIdType::New()), F_S(DataArrayIdType::New()), S_Fi(DataArrayIdType::New()), S_F(DataArrayIdType::New()), @@ -1447,7 +1469,7 @@ void MEDCouplingUMesh::colinearizeEdges(double eps) std::set pt_rem; const mcIdType *m_pi = m_p->getNodalConnectivityIndex()->begin(), *m_pc = m_p->getNodalConnectivity()->begin(); - double (*coord)[3] = (double (*)[3]) getCoords()->begin(); + auto *coord = (double (*)[3]) getCoords()->begin(); // Find all points only connected to exaclty 2 segments - they are the candidates for elimination // Note that in 3D this can only happen for polyhedrons (when this happens at all) DAI dsi = P_Si->deltaShiftIndex(); @@ -1459,9 +1481,9 @@ void MEDCouplingUMesh::colinearizeEdges(double eps) for (mcIdType j = 0; j < 2; j++) for (mcIdType k = 0; k < 2; k++) { - mcIdType off1 = P_Sip[i] + j; // offset to get ID of the j-th seg (around the i-th point) in the point->seg correspondance - mcIdType pt_id = P_Sp[off1] + k; // ID of the k-th point of the j-th seg in the point->seg correspondance - mcIdType pt_id2 = S_Pp[S_Pip[pt_id]]; // ID of the point in the point mesh + mcIdType const off1 = P_Sip[i] + j; // offset to get ID of the j-th seg (around the i-th point) in the point->seg correspondance + mcIdType const pt_id = P_Sp[off1] + k; // ID of the k-th point of the j-th seg in the point->seg correspondance + mcIdType const pt_id2 = S_Pp[S_Pip[pt_id]]; // ID of the point in the point mesh p[j][k] = m_pc[m_pi[pt_id2] + 1]; // Absolute ID, as read from the connectvity (+1 to skip type: NORM_POINT1) // Just for fun, as initially written by Antoine :-) // p[j][k] = m_pc[m_pi[S_P->getIJ(S_Pi->getIJ(P_S->getIJ(P_Si->getIJ(i, 0) + j, 0), 0) + k, 0)] + 1]; @@ -1506,7 +1528,7 @@ DataArrayIdType *MEDCouplingUMesh::computeFetchedNodeIds() const { checkConnectivityFullyDefined(); const mcIdType *maxEltPt(std::max_element(_nodal_connec->begin(),_nodal_connec->end())); - mcIdType maxElt(maxEltPt==_nodal_connec->end()?0:std::abs(*maxEltPt)+1); + mcIdType const maxElt(maxEltPt==_nodal_connec->end()?0:std::abs(*maxEltPt)+1); std::vector retS(maxElt,false); computeNodeIdsAlg(retS); return DataArrayIdType::BuildListOfSwitchedOn(retS); @@ -1539,9 +1561,9 @@ void MEDCouplingUMesh::computeNodeIdsAlg(std::vector& nodeIdsInUse) const struct MEDCouplingAccVisit { - MEDCouplingAccVisit():_new_nb_of_nodes(0) { } + MEDCouplingAccVisit() = default; mcIdType operator()(mcIdType val) { if(val!=-1) return _new_nb_of_nodes++; else return -1; } - mcIdType _new_nb_of_nodes; + mcIdType _new_nb_of_nodes{0}; }; /// @endcond @@ -1568,12 +1590,12 @@ struct MEDCouplingAccVisit DataArrayIdType *MEDCouplingUMesh::getNodeIdsInUse(mcIdType& nbrOfNodesInUse) const { nbrOfNodesInUse=-1; - mcIdType nbOfNodes(getNumberOfNodes()); + mcIdType const nbOfNodes(getNumberOfNodes()); MCAuto ret=DataArrayIdType::New(); ret->alloc(nbOfNodes,1); mcIdType *traducer=ret->getPointer(); std::fill(traducer,traducer+nbOfNodes,-1); - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbOfCells=getNumberOfCells(); const mcIdType *connIndex=_nodal_connec_index->getConstPointer(); const mcIdType *conn=_nodal_connec->getConstPointer(); for(mcIdType i=0;i ret=DataArrayIdType::New(); ret->alloc(nbOfCells,1); mcIdType *retPtr=ret->getPointer(); @@ -1631,7 +1653,7 @@ DataArrayIdType *MEDCouplingUMesh::computeNbOfNodesPerCell() const DataArrayIdType *MEDCouplingUMesh::computeEffectiveNbOfNodesPerCell() const { checkConnectivityFullyDefined(); - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbOfCells=getNumberOfCells(); MCAuto ret=DataArrayIdType::New(); ret->alloc(nbOfCells,1); mcIdType *retPtr=ret->getPointer(); @@ -1660,7 +1682,7 @@ DataArrayIdType *MEDCouplingUMesh::computeEffectiveNbOfNodesPerCell() const DataArrayIdType *MEDCouplingUMesh::computeNbOfFacesPerCell() const { checkConnectivityFullyDefined(); - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbOfCells=getNumberOfCells(); MCAuto ret=DataArrayIdType::New(); ret->alloc(nbOfCells,1); mcIdType *retPtr=ret->getPointer(); @@ -1733,18 +1755,18 @@ int MEDCouplingUMesh::AreCellsEqualPolicy0(const mcIdType *conn, const mcIdType */ int MEDCouplingUMesh::AreCellsEqualPolicy1(const mcIdType *conn, const mcIdType *connI, mcIdType cell1, mcIdType cell2) { - mcIdType sz=connI[cell1+1]-connI[cell1]; + mcIdType const sz=connI[cell1+1]-connI[cell1]; if(sz==connI[cell2+1]-connI[cell2]) { if(conn[connI[cell1]]==conn[connI[cell2]]) { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel((INTERP_KERNEL::NormalizedCellType)conn[connI[cell1]]); - unsigned dim=cm.getDimension(); + unsigned const dim=cm.getDimension(); if(dim!=3) { if(dim!=1) { - mcIdType sz1=2*(sz-1); + mcIdType const sz1=2*(sz-1); INTERP_KERNEL::AutoPtr tmp=new mcIdType[sz1]; mcIdType *work=std::copy(conn+connI[cell1]+1,conn+connI[cell1+1],(mcIdType *)tmp); std::copy(conn+connI[cell1]+1,conn+connI[cell1+1],work); @@ -1770,8 +1792,8 @@ int MEDCouplingUMesh::AreCellsEqualPolicy2(const mcIdType *conn, const mcIdType { if(conn[connI[cell1]]==conn[connI[cell2]]) { - std::set s1(conn+connI[cell1]+1,conn+connI[cell1+1]); - std::set s2(conn+connI[cell2]+1,conn+connI[cell2+1]); + std::set const s1(conn+connI[cell1]+1,conn+connI[cell1+1]); + std::set const s2(conn+connI[cell2]+1,conn+connI[cell2+1]); return s1==s2?1:0; } } @@ -1785,8 +1807,8 @@ int MEDCouplingUMesh::AreCellsEqualPolicy2NoType(const mcIdType *conn, const mcI { if(connI[cell1+1]-connI[cell1]==connI[cell2+1]-connI[cell2]) { - std::set s1(conn+connI[cell1]+1,conn+connI[cell1+1]); - std::set s2(conn+connI[cell2]+1,conn+connI[cell2+1]); + std::set const s1(conn+connI[cell1]+1,conn+connI[cell1+1]); + std::set const s2(conn+connI[cell2]+1,conn+connI[cell2+1]); return s1==s2?1:0; } return 0; @@ -1797,18 +1819,18 @@ int MEDCouplingUMesh::AreCellsEqualPolicy2NoType(const mcIdType *conn, const mcI */ int MEDCouplingUMesh::AreCellsEqualPolicy7(const mcIdType *conn, const mcIdType *connI, mcIdType cell1, mcIdType cell2) { - mcIdType sz=connI[cell1+1]-connI[cell1]; + mcIdType const sz=connI[cell1+1]-connI[cell1]; if(sz==connI[cell2+1]-connI[cell2]) { if(conn[connI[cell1]]==conn[connI[cell2]]) { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel((INTERP_KERNEL::NormalizedCellType)conn[connI[cell1]]); - unsigned dim=cm.getDimension(); + unsigned const dim=cm.getDimension(); if(dim!=3) { if(dim!=1) { - mcIdType sz1=2*(sz-1); + mcIdType const sz1=2*(sz-1); INTERP_KERNEL::AutoPtr tmp=new mcIdType[sz1]; mcIdType *work=std::copy(conn+connI[cell1]+1,conn+connI[cell1+1],(mcIdType *)tmp); std::copy(conn+connI[cell1]+1,conn+connI[cell1+1],work); @@ -1817,8 +1839,8 @@ int MEDCouplingUMesh::AreCellsEqualPolicy7(const mcIdType *conn, const mcIdType return 1; else { - std::reverse_iterator it1((mcIdType *)tmp+sz1); - std::reverse_iterator it2((mcIdType *)tmp); + std::reverse_iterator const it1((mcIdType *)tmp+sz1); + std::reverse_iterator const it2((mcIdType *)tmp); if(std::search(it1,it2,conn+connI[cell2]+1,conn+connI[cell2+1])!=it2) return 2; else @@ -1831,8 +1853,8 @@ int MEDCouplingUMesh::AreCellsEqualPolicy7(const mcIdType *conn, const mcIdType return 1; if(!cm.isQuadratic()) { - std::reverse_iterator it1(conn+connI[cell1+1]); - std::reverse_iterator it2(conn+connI[cell1]+1); + std::reverse_iterator const it1(conn+connI[cell1+1]); + std::reverse_iterator const it2(conn+connI[cell1]+1); if(std::equal(it1,it2,conn+connI[cell2]+1)) return 2; return 0; @@ -1882,7 +1904,7 @@ void MEDCouplingUMesh::FindCommonCellsAlg(int compType, mcIdType startCellId, co DataArrayIdType *& commonCellsArr, DataArrayIdType *& commonCellsIArr) { MCAuto commonCells=DataArrayIdType::New(),commonCellsI=DataArrayIdType::New(); commonCells->alloc(0,1); - mcIdType nbOfCells=nodalI->getNumberOfTuples()-1; + mcIdType const nbOfCells=nodalI->getNumberOfTuples()-1; commonCellsI->reserve(1); commonCellsI->pushBackSilent(0); const mcIdType *revNodalPtr=revNodal->getConstPointer(),*revNodalIPtr=revNodalI->getConstPointer(); const mcIdType *connPtr=nodal->getConstPointer(),*connIPtr=nodalI->getConstPointer(); @@ -1906,14 +1928,14 @@ void MEDCouplingUMesh::FindCommonCellsAlg(int compType, mcIdType startCellId, co { v=v2; const mcIdType *locRevNodal=std::find(revNodalPtr+revNodalIPtr[*connOfNode],revNodalPtr+revNodalIPtr[*connOfNode+1],i); - std::vector::iterator it=std::set_intersection(v.begin(),v.end(),locRevNodal,revNodalPtr+revNodalIPtr[*connOfNode+1],v2.begin()); + auto const it=std::set_intersection(v.begin(),v.end(),locRevNodal,revNodalPtr+revNodalIPtr[*connOfNode+1],v2.begin()); v2.resize(std::distance(v2.begin(),it)); } if(v2.size()>1) { if(AreCellsEqualInPool(v2,compType,connPtr,connIPtr,commonCells)) { - mcIdType pos=commonCellsI->back(); + mcIdType const pos=commonCellsI->back(); commonCellsI->pushBackSilent(commonCells->getNumberOfTuples()); for(const mcIdType *it=commonCells->begin()+pos;it!=commonCells->end();it++) isFetched[*it]=true; @@ -1940,7 +1962,7 @@ void MEDCouplingUMesh::FindCommonCellsAlg(int compType, mcIdType startCellId, co if(*connOfNode>=0) { v=v2; - std::vector::iterator it=std::set_intersection(v.begin(),v.end(),revNodalPtr+revNodalIPtr[*connOfNode],revNodalPtr+revNodalIPtr[*connOfNode+1],v2.begin()); + auto const it=std::set_intersection(v.begin(),v.end(),revNodalPtr+revNodalIPtr[*connOfNode],revNodalPtr+revNodalIPtr[*connOfNode+1],v2.begin()); v2.resize(std::distance(v2.begin(),it)); } // v2 contains now candidates. Problem candidates are sorted using id rank. @@ -1953,8 +1975,8 @@ void MEDCouplingUMesh::FindCommonCellsAlg(int compType, mcIdType startCellId, co } if(AreCellsEqualInPool(v2,compType,connPtr,connIPtr,commonCells)) { - mcIdType newPos(commonCells->getNumberOfTuples()); - mcIdType pos(commonCellsI->back()); + mcIdType const newPos(commonCells->getNumberOfTuples()); + mcIdType const pos(commonCellsI->back()); std::sort(commonCells->getPointerSilent()+pos,commonCells->getPointerSilent()+newPos); commonCellsI->pushBackSilent(newPos); for(const mcIdType *it=commonCells->begin()+pos;it!=commonCells->end();it++) @@ -1995,7 +2017,7 @@ void MEDCouplingUMesh::FindCommonCellsAlg(int compType, mcIdType startCellId, co bool MEDCouplingUMesh::areCellsIncludedIn(const MEDCouplingUMesh *other, int compType, DataArrayIdType *& arr) const { MCAuto mesh=MergeUMeshesOnSameCoords(this,other); - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbOfCells=getNumberOfCells(); static const int possibleCompType[]={0,1,2}; if(std::find(possibleCompType,possibleCompType+sizeof(possibleCompType)/sizeof(int),compType)==possibleCompType+sizeof(possibleCompType)/sizeof(int)) { @@ -2016,8 +2038,8 @@ bool MEDCouplingUMesh::areCellsIncludedIn(const MEDCouplingUMesh *other, int com mcIdType newNbOfCells=-1; MCAuto o2n = DataArrayIdType::ConvertIndexArrayToO2N(ToIdType(mesh->getNumberOfCells()),commonCells->begin(),commonCellsI->begin(),commonCellsI->end(),newNbOfCells); MCAuto p0(o2n->selectByTupleIdSafeSlice(0,nbOfCells,1)); - mcIdType maxPart(p0->getMaxValueInArray()); - bool ret(maxPart==newNbOfCells-1); + mcIdType const maxPart(p0->getMaxValueInArray()); + bool const ret(maxPart==newNbOfCells-1); MCAuto p1(p0->invertArrayO2N2N2O(newNbOfCells)); // fill p1 array in case of presence of cells in other not in this mcIdType *pt(p1->getPointer()); @@ -2043,26 +2065,26 @@ bool MEDCouplingUMesh::areCellsIncludedIn(const MEDCouplingUMesh *other, int com bool MEDCouplingUMesh::areCellsIncludedInPolicy7(const MEDCouplingUMesh *other, DataArrayIdType *& arr) const { MCAuto mesh=MergeUMeshesOnSameCoords(this,other); - DataArrayIdType *commonCells=0,*commonCellsI=0; - mcIdType thisNbCells=getNumberOfCells(); + DataArrayIdType *commonCells=nullptr,*commonCellsI=nullptr; + mcIdType const thisNbCells=getNumberOfCells(); mesh->findCommonCells(7,thisNbCells,commonCells,commonCellsI); MCAuto commonCellsTmp(commonCells),commonCellsITmp(commonCellsI); const mcIdType *commonCellsPtr=commonCells->getConstPointer(),*commonCellsIPtr=commonCellsI->getConstPointer(); - mcIdType otherNbCells=other->getNumberOfCells(); + mcIdType const otherNbCells=other->getNumberOfCells(); MCAuto arr2=DataArrayIdType::New(); arr2->alloc(otherNbCells,1); arr2->fillWithZero(); mcIdType *arr2Ptr=arr2->getPointer(); - mcIdType nbOfCommon=commonCellsI->getNumberOfTuples()-1; + mcIdType const nbOfCommon=commonCellsI->getNumberOfTuples()-1; for(mcIdType i=0;i0?1:-1; - mcIdType val=std::abs(commonCellsPtr[j])-1; + mcIdType const sig=commonCellsPtr[j]>0?1:-1; + mcIdType const val=std::abs(commonCellsPtr[j])-1; if(val>=thisNbCells) arr2Ptr[val-thisNbCells]=sig*(start+1); } @@ -2079,7 +2101,7 @@ MEDCouplingUMesh *MEDCouplingUMesh::mergeMyselfWithOnSameCoords(const MEDCouplin { if(!other) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::mergeMyselfWithOnSameCoords : input other is null !"); - const MEDCouplingUMesh *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::mergeMyselfWithOnSameCoords : the input other mesh is not of type unstructured !"); std::vector ms(2); @@ -2108,7 +2130,7 @@ MEDCouplingUMesh *MEDCouplingUMesh::buildPartOfMySelfSlice(mcIdType start, mcIdT return static_cast(MEDCouplingPointSet::buildPartOfMySelfSlice(start,end,step,keepCoords)); else { - mcIdType newNbOfCells=DataArray::GetNumberOfItemGivenBESRelative(start,end,step,"MEDCouplingUMesh::buildPartOfMySelfSlice for -1 dimension mesh "); + mcIdType const newNbOfCells=DataArray::GetNumberOfItemGivenBESRelative(start,end,step,"MEDCouplingUMesh::buildPartOfMySelfSlice for -1 dimension mesh "); if(newNbOfCells!=1) throw INTERP_KERNEL::Exception("-1D mesh has only one cell !"); if(start!=0) @@ -2180,13 +2202,13 @@ void MEDCouplingUMesh::setPartOfMySelf(const mcIdType *cellIdsBg, const mcIdType oss << ", whereas other mesh dimension is set equal to " << otherOnSameCoordsThanThis.getMeshDimension() << " !"; throw INTERP_KERNEL::Exception(oss.str()); } - mcIdType nbOfCellsToModify( ToIdType((std::distance(cellIdsBg,cellIdsEnd)))); + mcIdType const nbOfCellsToModify( ToIdType((std::distance(cellIdsBg,cellIdsEnd)))); if(nbOfCellsToModify!=otherOnSameCoordsThanThis.getNumberOfCells()) { std::ostringstream oss; oss << "MEDCouplingUMesh::setPartOfMySelf : cells ids length (" << nbOfCellsToModify << ") do not match the number of cells of other mesh (" << otherOnSameCoordsThanThis.getNumberOfCells() << ") !"; throw INTERP_KERNEL::Exception(oss.str()); } - mcIdType nbOfCells(getNumberOfCells()); + mcIdType const nbOfCells(getNumberOfCells()); bool easyAssign(true); const mcIdType *connI(_nodal_connec_index->begin()); const mcIdType *connIOther=otherOnSameCoordsThanThis._nodal_connec_index->begin(); @@ -2209,7 +2231,7 @@ void MEDCouplingUMesh::setPartOfMySelf(const mcIdType *cellIdsBg, const mcIdType } else { - DataArrayIdType *arrOut=0,*arrIOut=0; + DataArrayIdType *arrOut=nullptr,*arrIOut=nullptr; DataArrayIdType::SetPartOfIndexedArrays(cellIdsBg,cellIdsEnd,_nodal_connec,_nodal_connec_index,otherOnSameCoordsThanThis._nodal_connec,otherOnSameCoordsThanThis._nodal_connec_index, arrOut,arrIOut); MCAuto arrOutAuto(arrOut),arrIOutAuto(arrIOut); @@ -2229,13 +2251,13 @@ void MEDCouplingUMesh::setPartOfMySelfSlice(mcIdType start, mcIdType end, mcIdTy oss << ", whereas other mesh dimension is set equal to " << otherOnSameCoordsThanThis.getMeshDimension() << " !"; throw INTERP_KERNEL::Exception(oss.str()); } - mcIdType nbOfCellsToModify=DataArray::GetNumberOfItemGivenBESRelative(start,end,step,"MEDCouplingUMesh::setPartOfMySelfSlice : "); + mcIdType const nbOfCellsToModify=DataArray::GetNumberOfItemGivenBESRelative(start,end,step,"MEDCouplingUMesh::setPartOfMySelfSlice : "); if(nbOfCellsToModify!=otherOnSameCoordsThanThis.getNumberOfCells()) { std::ostringstream oss; oss << "MEDCouplingUMesh::setPartOfMySelfSlice : cells ids length (" << nbOfCellsToModify << ") do not match the number of cells of other mesh (" << otherOnSameCoordsThanThis.getNumberOfCells() << ") !"; throw INTERP_KERNEL::Exception(oss.str()); } - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbOfCells=getNumberOfCells(); bool easyAssign=true; const mcIdType *connI=_nodal_connec_index->getConstPointer(); const mcIdType *connIOther=otherOnSameCoordsThanThis._nodal_connec_index->getConstPointer(); @@ -2259,7 +2281,7 @@ void MEDCouplingUMesh::setPartOfMySelfSlice(mcIdType start, mcIdType end, mcIdTy } else { - DataArrayIdType *arrOut=0,*arrIOut=0; + DataArrayIdType *arrOut=nullptr,*arrIOut=nullptr; DataArrayIdType::SetPartOfIndexedArraysSlice(start,end,step,_nodal_connec,_nodal_connec_index,otherOnSameCoordsThanThis._nodal_connec,otherOnSameCoordsThanThis._nodal_connec_index, arrOut,arrIOut); MCAuto arrOutAuto(arrOut),arrIOutAuto(arrIOut); @@ -2297,7 +2319,7 @@ MEDCouplingUMesh *MEDCouplingUMesh::buildFacePartOfMySelfNode(const mcIdType *be MCAuto desc,descIndx,revDesc,revDescIndx; desc=DataArrayIdType::New(); descIndx=DataArrayIdType::New(); revDesc=DataArrayIdType::New(); revDescIndx=DataArrayIdType::New(); MCAuto subMesh=buildDescendingConnectivity(desc,descIndx,revDesc,revDescIndx); - desc=0; descIndx=0; revDesc=0; revDescIndx=0; + desc=nullptr; descIndx=nullptr; revDesc=nullptr; revDescIndx=nullptr; return static_cast(subMesh->buildPartOfMySelfNode(begin,end,fullyIn)); } @@ -2328,7 +2350,7 @@ MEDCouplingUMesh *MEDCouplingUMesh::buildBoundaryMesh(bool keepCoords) const revDesc->decrRef(); desc->decrRef(); descIndx->decrRef(); - mcIdType nbOfCells=meshDM1->getNumberOfCells(); + mcIdType const nbOfCells=meshDM1->getNumberOfCells(); const mcIdType *revDescIndxC=revDescIndx->getConstPointer(); std::vector boundaryCells; for(mcIdType i=0;i desc(DataArrayIdType::New()), descIndx(DataArrayIdType::New()), revDesc(DataArrayIdType::New()), revDescIndx(DataArrayIdType::New()); // buildDescendingConnectivity(desc,descIndx,revDesc,revDescIndx)->decrRef(); - desc=(DataArrayIdType*)0; descIndx=(DataArrayIdType*)0; + desc=(DataArrayIdType*)nullptr; descIndx=(DataArrayIdType*)nullptr; // MCAuto tmp=revDescIndx->deltaShiftIndex(); - MCAuto faceIds=tmp->findIdsEqual(1); tmp=(DataArrayIdType*)0; + MCAuto faceIds=tmp->findIdsEqual(1); tmp=(DataArrayIdType*)nullptr; const mcIdType *revDescPtr=revDesc->getConstPointer(); const mcIdType *revDescIndxPtr=revDescIndx->getConstPointer(); - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbOfCells=getNumberOfCells(); std::vector ret1(nbOfCells,false); mcIdType sz=0; - for(const mcIdType *pt=faceIds->begin();pt!=faceIds->end();pt++) - if(!ret1[revDescPtr[revDescIndxPtr[*pt]]]) - { ret1[revDescPtr[revDescIndxPtr[*pt]]]=true; sz++; } + for(long const pt : *faceIds) + if(!ret1[revDescPtr[revDescIndxPtr[pt]]]) + { ret1[revDescPtr[revDescIndxPtr[pt]]]=true; sz++; } // ret2->alloc(sz,1); mcIdType *ret2Ptr=ret2->getPointer(); @@ -2413,14 +2435,14 @@ void MEDCouplingUMesh::findCellIdsLyingOn(const MEDCouplingUMesh& otherDimM1OnSa MCAuto descThisPart=DataArrayIdType::New(),descIThisPart=DataArrayIdType::New(),revDescThisPart=DataArrayIdType::New(),revDescIThisPart=DataArrayIdType::New(); MCAuto thisPartConsti=thisPart->buildDescendingConnectivity(descThisPart,descIThisPart,revDescThisPart,revDescIThisPart); const mcIdType *revDescThisPartPtr=revDescThisPart->getConstPointer(),*revDescIThisPartPtr=revDescIThisPart->getConstPointer(); - DataArrayIdType *idsOtherInConsti=0; - bool b=thisPartConsti->areCellsIncludedIn(&otherDimM1OnSameCoords,2,idsOtherInConsti); - MCAuto idsOtherInConstiAuto(idsOtherInConsti); + DataArrayIdType *idsOtherInConsti=nullptr; + bool const b=thisPartConsti->areCellsIncludedIn(&otherDimM1OnSameCoords,2,idsOtherInConsti); + MCAuto const idsOtherInConstiAuto(idsOtherInConsti); if(!b) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::findCellIdsLyingOn : the given mdim-1 mesh in other is not a constituent of this !"); std::set s1; - for(const mcIdType *idOther=idsOtherInConsti->begin();idOther!=idsOtherInConsti->end();idOther++) - s1.insert(revDescThisPartPtr+revDescIThisPartPtr[*idOther],revDescThisPartPtr+revDescIThisPartPtr[*idOther+1]); + for(long const idOther : *idsOtherInConsti) + s1.insert(revDescThisPartPtr+revDescIThisPartPtr[idOther],revDescThisPartPtr+revDescIThisPartPtr[idOther+1]); MCAuto s1arr_renum1=DataArrayIdType::New(); s1arr_renum1->alloc(s1.size(),1); std::copy(s1.begin(),s1.end(),s1arr_renum1->getPointer()); s1arr_renum1->sort(); cellIdsRk0=s0arr.retn(); @@ -2442,7 +2464,7 @@ MEDCouplingUMesh *MEDCouplingUMesh::computeSkin() const MCAuto revDescIndx=DataArrayIdType::New(); // MCAuto meshDM1=buildDescendingConnectivity(desc,descIndx,revDesc,revDescIndx); - revDesc=0; desc=0; descIndx=0; + revDesc=nullptr; desc=nullptr; descIndx=nullptr; MCAuto revDescIndx2=revDescIndx->deltaShiftIndex(); MCAuto part=revDescIndx2->findIdsEqual(1); return static_cast(meshDM1->buildPartOfMySelf(part->begin(),part->end(),true)); @@ -2517,11 +2539,11 @@ DataArrayIdType* MEDCouplingUMesh::findNodesToDuplicate(const MEDCouplingUMesh& DAInt idsTmp0 = dsi->findIdsNotInRange(-1, 3); // for 2D: if a point is connected to more than 2 segs. For 3D: if a seg is connected to more than two faces. if(idsTmp0->getNumberOfTuples()) throw INTERP_KERNEL::Exception("MEDFileUMesh::buildInnerBoundaryAlongM1Group: group is too complex: some points (or edges) have more than two connected segments (or faces)!"); - dt0=0; dit0=0; rdt0=0; rdit0=0; idsTmp0=0; + dt0=nullptr; dit0=nullptr; rdt0=nullptr; rdit0=nullptr; idsTmp0=nullptr; // Get extreme nodes from the group (they won't be duplicated except if they also lie on bound of M0 -- see below), // ie nodes belonging to the boundary "cells" (might be points) of M1 - DAInt xtremIdsM2 = dsi->findIdsEqual(1); dsi = 0; + DAInt const xtremIdsM2 = dsi->findIdsEqual(1); dsi = nullptr; MCUMesh meshM2Part = static_cast(meshM2->buildPartOfMySelf(xtremIdsM2->begin(), xtremIdsM2->end(),true)); DAInt xtrem = meshM2Part->computeFetchedNodeIds(); // Remove from the list points on the boundary of the M0 mesh (those need duplication!). @@ -2529,13 +2551,13 @@ DataArrayIdType* MEDCouplingUMesh::findNodesToDuplicate(const MEDCouplingUMesh& // Think of a partial (plane) crack in a cube: the points at the tip of the crack and not located inside the volume of the cube are not duplicated // although they are technically on the skin of the cube. DAInt fNodes = m0skin->computeFetchedNodeIds(); - DAInt notDup = 0; + DAInt notDup = nullptr; if (getMeshDimension() == 3) { DAInt dnu1=DataArrayIdType::New(), dnu2=DataArrayIdType::New(), dnu3=DataArrayIdType::New(), dnu4=DataArrayIdType::New(); MCUMesh m0skinDesc = m0skin->buildDescendingConnectivity(dnu1, dnu2, dnu3, dnu4); // all segments of the skin of the 3D (M0) mesh - dnu1=0;dnu2=0;dnu3=0;dnu4=0; - DataArrayIdType * corresp=0; + dnu1=nullptr;dnu2=nullptr;dnu3=nullptr;dnu4=nullptr; + DataArrayIdType * corresp=nullptr; meshM2->areCellsIncludedIn(m0skinDesc,2,corresp); // validIds is the list of segments which are on both the skin of *this*, and in the segments of the M1 group // In the cube example above, this is a U-shaped polyline. @@ -2556,17 +2578,17 @@ DataArrayIdType* MEDCouplingUMesh::findNodesToDuplicate(const MEDCouplingUMesh& // algorithm would be duplicating too much ... // This is a costly algorithm so only go into it if a simple (non sufficient) criteria is met: a node connected to more than 3 segs in meshM2: dnu1=DataArrayIdType::New(), dnu2=DataArrayIdType::New(), dnu3=DataArrayIdType::New(), rdit0=DataArrayIdType::New(); - MCUMesh meshM2Desc = meshM2->buildDescendingConnectivity(dnu1, dnu2, dnu3, rdit0); // a mesh made of node cells - dnu1=0;dnu2=0;dnu3=0; - dsi = rdit0->deltaShiftIndex(); rdit0=0; - DAInt singPoints = dsi->findIdsNotInRange(-1,4) ; dsi=0;// points connected to (strictly) more than 3 segments + MCUMesh const meshM2Desc = meshM2->buildDescendingConnectivity(dnu1, dnu2, dnu3, rdit0); // a mesh made of node cells + dnu1=nullptr;dnu2=nullptr;dnu3=nullptr; + dsi = rdit0->deltaShiftIndex(); rdit0=nullptr; + DAInt singPoints = dsi->findIdsNotInRange(-1,4) ; dsi=nullptr;// points connected to (strictly) more than 3 segments if (singPoints->getNumberOfTuples()) { DAInt boundNodes = m1IntersecSkin->computeFetchedNodeIds(); // If a point on this U-shape line is connected to cells which do not share any face with M1, then it // should not be duplicated // 1. Extract N D cells touching U-shape line: - DAInt cellsAroundBN = getCellIdsLyingOnNodes(boundNodes->begin(), boundNodes->end(), false); // false= take cell in, even if not all nodes are in dupl + DAInt const cellsAroundBN = getCellIdsLyingOnNodes(boundNodes->begin(), boundNodes->end(), false); // false= take cell in, even if not all nodes are in dupl MCUMesh mAroundBN = static_cast(this->buildPartOfMySelf(cellsAroundBN->begin(), cellsAroundBN->end(), true)); DAInt descBN=DataArrayIdType::New(), descIBN=DataArrayIdType::New(), revDescBN=DataArrayIdType::New(), revDescIBN=DataArrayIdType::New(); MCUMesh mAroundBNDesc = mAroundBN->buildDescendingConnectivity(descBN,descIBN,revDescBN,revDescIBN); @@ -2581,13 +2603,13 @@ DataArrayIdType* MEDCouplingUMesh::findNodesToDuplicate(const MEDCouplingUMesh& { if (v >= nCellsDesc) // Keep valid match only continue; - mcIdType idx0 = revDescIBNP[v]; + mcIdType const idx0 = revDescIBNP[v]; // Keep the two cells on either side of the face v of M1: mcIdType c1=revDescBNP[idx0], c2=revDescBNP[idx0+1]; idsTouch->pushBackSilent(c1); idsTouch->pushBackSilent(c2); } // 3. Build complement - DAInt idsTouchCompl = idsTouch->buildComplement(nCells); + DAInt const idsTouchCompl = idsTouch->buildComplement(nCells); MCUMesh mAroundBNStrict = static_cast(mAroundBN->buildPartOfMySelf(idsTouchCompl->begin(), idsTouchCompl->end(), true)); DAInt nod3 = mAroundBNStrict->computeFetchedNodeIds(); DAInt inters = boundNodes->buildIntersection(nod3); @@ -2645,21 +2667,21 @@ void MEDCouplingUMesh::findCellsToRenumber(const MEDCouplingUMesh& otherDimM1OnS // Compute cell IDs of the mesh with cells that touch the M1 group with a least one node: DAInt cellsAroundGroupLarge = getCellIdsLyingOnNodes(nodeIdsToDuplicateBg, nodeIdsToDuplicateEnd, false); // false= take cell in, even if not all nodes are in dupl MCUMesh mAroundGrpLarge=static_cast(buildPartOfMySelf(cellsAroundGroupLarge->begin(),cellsAroundGroupLarge->end(),true)); - mcIdType nCellsLarge=cellsAroundGroupLarge->getNumberOfTuples(); + mcIdType const nCellsLarge=cellsAroundGroupLarge->getNumberOfTuples(); DAInt descL=DataArrayIdType::New(),descIL=DataArrayIdType::New(),revDescL=DataArrayIdType::New(),revDescIL=DataArrayIdType::New(); MCUMesh mArGrpLargeDesc=mAroundGrpLarge->buildDescendingConnectivity(descL,descIL,revDescL,revDescIL); const mcIdType *descILP=descIL->begin(), *descLP=descL->begin(); DataArrayIdType *idsOfM1t; mArGrpLargeDesc->areCellsIncludedIn(&otherDimM1OnSameCoords,2, idsOfM1t); DAInt idsOfM1Large(idsOfM1t); - mcIdType nL = mArGrpLargeDesc->getNumberOfCells(); + mcIdType const nL = mArGrpLargeDesc->getNumberOfCells(); // Computation of the neighbor information of the mesh WITH the crack (some neighbor links are removed): // In the neighbor information remove the connection between high dimension cells and its low level constituents which are part // of the frontier given in parameter (i.e. the cells of low dimension from the group delimiting the crack): DAInt descLTrunc = descL->deepCopy(), descILTrunc = descIL->deepCopy(); DataArrayIdType::RemoveIdsFromIndexedArrays(idsOfM1Large->begin(), idsOfM1Large->end(),descLTrunc,descILTrunc); - DataArrayIdType *neight=0, *neighIt=0; + DataArrayIdType *neight=nullptr, *neighIt=nullptr; MEDCouplingUMesh::ComputeNeighborsOfCellsAdv(descLTrunc,descILTrunc,revDescL,revDescIL, neight, neighIt); DAInt neighL(neight), neighIL(neighIt); @@ -2672,7 +2694,7 @@ void MEDCouplingUMesh::findCellsToRenumber(const MEDCouplingUMesh& otherDimM1OnS for(const auto& v: *idsOfM1Large) { if (v >= nL) continue; // Keep valid match only - see doc of areCellsIncludedIn() - mcIdType idx0 = revDescILP[v]; + mcIdType const idx0 = revDescILP[v]; // Retrieve the two cells on either side of the face v of M1: mcIdType c1=revDescLP[idx0], c2=revDescLP[idx0+1]; std::map toOther = {{c1, c2}, {c2, c1}}; @@ -2692,7 +2714,7 @@ void MEDCouplingUMesh::findCellsToRenumber(const MEDCouplingUMesh& otherDimM1OnS // If a valid value was found, use it: mcIdType val = sv.size()==1 ? *sv.begin() : 0; // Hopefully this does not conflict with an potential value on the other side: - mcIdType other = toOther[c]; + mcIdType const other = toOther[c]; if (hitCellsLargeP[other]) { if(val && hitCellsLargeP[other] != -val) @@ -2712,7 +2734,7 @@ void MEDCouplingUMesh::findCellsToRenumber(const MEDCouplingUMesh& otherDimM1OnS if (cellsRet1->getNumberOfTuples() + cellsRet2->getNumberOfTuples() != cellsAroundGroupLarge->getNumberOfTuples()) { - DAInt nonHitCells = hitCellsLarge->findIdsEqual(0); // variable kept for debug ... + DAInt const nonHitCells = hitCellsLarge->findIdsEqual(0); // variable kept for debug ... throw INTERP_KERNEL::Exception("MEDCouplingUMesh::findCellsToRenumber: Some cells not hit - Internal error should not happen"); } cellsRet1->transformWithIndArr(cellsAroundGroupLarge->begin(),cellsAroundGroupLarge->end()); @@ -2737,7 +2759,7 @@ void MEDCouplingUMesh::findCellsToRenumber(const MEDCouplingUMesh& otherDimM1OnS */ void MEDCouplingUMesh::duplicateNodes(const mcIdType *nodeIdsToDuplicateBg, const mcIdType *nodeIdsToDuplicateEnd) { - mcIdType nbOfNodes=getNumberOfNodes(); + mcIdType const nbOfNodes=getNumberOfNodes(); duplicateNodesInCoords(nodeIdsToDuplicateBg,nodeIdsToDuplicateEnd); duplicateNodesInConn(nodeIdsToDuplicateBg,nodeIdsToDuplicateEnd,nbOfNodes); } @@ -2755,7 +2777,7 @@ void MEDCouplingUMesh::renumberNodesWithOffsetInConn(mcIdType offset) checkConnectivityFullyDefined(); mcIdType *conn(getNodalConnectivity()->getPointer()); const mcIdType *connIndex(getNodalConnectivityIndex()->getConstPointer()); - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbOfCells=getNumberOfCells(); for(mcIdType i=0;igetPointer(); const mcIdType *connIndex=getNodalConnectivityIndex()->getConstPointer(); - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbOfCells=getNumberOfCells(); for(mcIdType i=0;igetPointer(); const mcIdType *connIndex=getNodalConnectivityIndex()->getConstPointer(); - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbOfCells=getNumberOfCells(); for(mcIdType i=0;igetPointer(); const mcIdType *connIndex=getNodalConnectivityIndex()->getConstPointer(); - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbOfCells=getNumberOfCells(); for(mcIdType i=0;i=0)//avoid polyhedron separator { - std::map::iterator it=m.find(node); + auto const it=m.find(node); if(it!=m.end()) node=(*it).second; } @@ -2909,7 +2931,7 @@ void MEDCouplingUMesh::duplicateNodesInConn(const mcIdType *nodeIdsToDuplicateBg void MEDCouplingUMesh::renumberCells(const mcIdType *old2NewBg, bool check) { checkConnectivityFullyDefined(); - mcIdType nbCells=getNumberOfCells(); + mcIdType const nbCells=getNumberOfCells(); const mcIdType *array=old2NewBg; if(check) array=DataArrayIdType::CheckAndPreparePermutation(old2NewBg,old2NewBg+nbCells); @@ -2932,8 +2954,8 @@ void MEDCouplingUMesh::renumberCells(const mcIdType *old2NewBg, bool check) newCI[0]=loc; for(mcIdType i=0;ipushBackSilent(0); return elems.retn(); } - int dim=getSpaceDimension(); + int const dim=getSpaceDimension(); INTERP_KERNEL::AutoPtr elem_bb=new double[2*dim]; const mcIdType* conn = getNodalConnectivity()->getConstPointer(); const mcIdType* conn_index= getNodalConnectivityIndex()->getConstPointer(); const double* coords = getCoords()->getConstPointer(); - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbOfCells=getNumberOfCells(); for ( mcIdType ielem=0; ielem=0)//avoid polyhedron separator { for (int idim=0; idimpushBackSilent(0); return elems.retn(); } - int dim=getSpaceDimension(); + int const dim=getSpaceDimension(); INTERP_KERNEL::AutoPtr elem_bb=new double[2*dim]; const mcIdType* conn = getNodalConnectivity()->getConstPointer(); const mcIdType* conn_index= getNodalConnectivityIndex()->getConstPointer(); const double* coords = getCoords()->getConstPointer(); - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbOfCells=getNumberOfCells(); for ( mcIdType ielem=0; ielem=0)//avoid polyhedron separator { for (int idim=0; idim ret=DataArrayIdType::New(); ret->alloc(0,1); checkConnectivityFullyDefined(); - mcIdType nbCells=getNumberOfCells(); - int mdim=getMeshDimension(); + mcIdType const nbCells=getNumberOfCells(); + int const mdim=getMeshDimension(); const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(type); if(mdim!=ToIdType(cm.getDimension())) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::giveCellsWithType : Mismatch between mesh dimension and dimension of the cell !"); @@ -3145,14 +3167,14 @@ std::string MEDCouplingUMesh::simpleRepr() const ret << "Unstructured mesh with name : \"" << getName() << "\"\n"; ret << "Description of mesh : \"" << getDescription() << "\"\n"; int tmpp1,tmpp2; - double tt=getTime(tmpp1,tmpp2); + double const tt=getTime(tmpp1,tmpp2); ret << "Time attached to the mesh [unit] : " << tt << " [" << getTimeUnit() << "]\n"; ret << "Iteration : " << tmpp1 << " Order : " << tmpp2 << "\n"; if(_mesh_dim>=-1) { ret << "Mesh dimension : " << _mesh_dim << "\nSpace dimension : "; } else { ret << " Mesh dimension has not been set or is invalid !"; } - if(_coords!=0) + if(_coords!=nullptr) { const int spaceDim=getSpaceDimension(); ret << spaceDim << "\nInfo attached on space dimension : "; @@ -3163,19 +3185,19 @@ std::string MEDCouplingUMesh::simpleRepr() const else ret << msg0 << "\n"; ret << "Number of nodes : "; - if(_coords!=0) + if(_coords!=nullptr) ret << getNumberOfNodes() << "\n"; else ret << msg0 << "\n"; ret << "Number of cells : "; - if(_nodal_connec!=0 && _nodal_connec_index!=0) + if(_nodal_connec!=nullptr && _nodal_connec_index!=nullptr) ret << getNumberOfCells() << "\n"; else ret << "No connectivity specified !" << "\n"; ret << "Cell types present : "; - for(std::set::const_iterator iter=_types.begin();iter!=_types.end();iter++) + for(auto _type : _types) { - const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*iter); + const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_type); ret << cm.getRepr() << " "; } ret << "\n"; @@ -3236,7 +3258,7 @@ std::string MEDCouplingUMesh::reprConnectivityOfThis() const */ MEDCouplingUMesh *MEDCouplingUMesh::buildSetInstanceFromThis(std::size_t spaceDim) const { - int mdim=getMeshDimension(); + int const mdim=getMeshDimension(); if(mdim<0) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::buildSetInstanceFromThis : invalid mesh dimension ! Should be >= 0 !"); MCAuto ret=MEDCouplingUMesh::New(getName(),mdim); @@ -3332,7 +3354,7 @@ void MEDCouplingUMesh::setConnectivity(DataArrayIdType *conn, DataArrayIdType *c * If 'deeCpy' is true all arrays (coordinates and connectivities) are deeply copied. */ MEDCouplingUMesh::MEDCouplingUMesh(const MEDCouplingUMesh& other, bool deepCpy):MEDCouplingPointSet(other,deepCpy),_mesh_dim(other._mesh_dim), - _nodal_connec(0),_nodal_connec_index(0), + _nodal_connec(nullptr),_nodal_connec_index(nullptr), _types(other._types) { if(other._nodal_connec) @@ -3452,7 +3474,7 @@ void MEDCouplingUMesh::serialize(DataArrayIdType *&a1, DataArrayDouble *&a2) con std::copy(conn,conn+getNodalConnectivityArrayLen(),ptA1); } else - a1=0; + a1=nullptr; } /*! @@ -3495,20 +3517,20 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::getMeasureField(bool isAbs) const { std::string name="MeasureOfMesh_"; name+=getName(); - mcIdType nbelem=getNumberOfCells(); + mcIdType const nbelem=getNumberOfCells(); MCAuto field=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME); field->setName(name); MCAuto array=DataArrayDouble::New(); array->alloc(nbelem,1); double *area_vol=array->getPointer(); - field->setArray(array) ; array=0; + field->setArray(array) ; array=nullptr; field->setMesh(const_cast(this)); field->synchronizeTimeWithMesh(); if(getMeshDimension()!=-1) { mcIdType ipt; INTERP_KERNEL::NormalizedCellType type; - int dim_space=getSpaceDimension(); + int const dim_space=getSpaceDimension(); const double *coords=getCoords()->getConstPointer(); const mcIdType *connec=getNodalConnectivity()->getConstPointer(); const mcIdType *connec_index=getNodalConnectivityIndex()->getConstPointer(); @@ -3552,7 +3574,7 @@ DataArrayDouble *MEDCouplingUMesh::getPartMeasureField(bool isAbs, const mcIdTyp { std::string name="PartMeasureOfMesh_"; name+=getName(); - std::size_t nbelem=std::distance(begin,end); + std::size_t const nbelem=std::distance(begin,end); MCAuto array=DataArrayDouble::New(); array->setName(name); array->alloc(nbelem,1); @@ -3561,7 +3583,7 @@ DataArrayDouble *MEDCouplingUMesh::getPartMeasureField(bool isAbs, const mcIdTyp { mcIdType ipt; INTERP_KERNEL::NormalizedCellType type; - int dim_space=getSpaceDimension(); + int const dim_space=getSpaceDimension(); const double *coords=getCoords()->getConstPointer(); const mcIdType *connec=getNodalConnectivity()->getConstPointer(); const mcIdType *connec_index=getNodalConnectivityIndex()->getConstPointer(); @@ -3601,7 +3623,7 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::getMeasureFieldOnNode(bool isAbs) cons MCAuto tmp=getMeasureField(isAbs); std::string name="MeasureOnNodeOfMesh_"; name+=getName(); - mcIdType nbNodes=getNumberOfNodes(); + mcIdType const nbNodes=getNumberOfNodes(); MCAuto nnpc; { MCAuto tmp2(computeNbOfNodesPerCell()); @@ -3651,8 +3673,8 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::buildOrthogonalField() const throw INTERP_KERNEL::Exception("Expected a umesh with ( meshDim == 2 spaceDim == 2 or 3 ) or ( meshDim == 1 spaceDim == 2 ) !"); MCAuto ret=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME); MCAuto array=DataArrayDouble::New(); - mcIdType nbOfCells=getNumberOfCells(); - int nbComp=getMeshDimension()+1; + mcIdType const nbOfCells=getNumberOfCells(); + int const nbComp=getMeshDimension()+1; array->alloc(nbOfCells,nbComp); double *vals=array->getPointer(); const mcIdType *connI=_nodal_connec_index->getConstPointer(); @@ -3666,9 +3688,9 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::buildOrthogonalField() const const double *locPtr=loc->getConstPointer(); for(mcIdType i=0;i(locPtr+3*i,coords+3*conn[offset+1],coords+3*conn[offset+2],vals); - double n=INTERP_KERNEL::norm<3>(vals); + double const n=INTERP_KERNEL::norm<3>(vals); std::transform(vals,vals+3,vals,std::bind(std::multiplies(),std::placeholders::_1,1./n)); } } @@ -3685,9 +3707,9 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::buildOrthogonalField() const double tmp[2]; for(mcIdType i=0;i()); - double n=INTERP_KERNEL::norm<2>(tmp); + double const n=INTERP_KERNEL::norm<2>(tmp); std::transform(tmp,tmp+2,tmp,std::bind(std::multiplies(),std::placeholders::_1,1./n)); *vals++=-tmp[1]; *vals++=tmp[0]; @@ -3730,8 +3752,8 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::buildPartOrthogonalField(const mcIdTyp throw INTERP_KERNEL::Exception("Expected a umesh with ( meshDim == 2 spaceDim == 2 or 3 ) or ( meshDim == 1 spaceDim == 2 ) !"); MCAuto ret=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME); MCAuto array=DataArrayDouble::New(); - std::size_t nbelems=std::distance(begin,end); - int nbComp=getMeshDimension()+1; + std::size_t const nbelems=std::distance(begin,end); + int const nbComp=getMeshDimension()+1; array->alloc(nbelems,nbComp); double *vals=array->getPointer(); const mcIdType *connI=_nodal_connec_index->getConstPointer(); @@ -3745,9 +3767,9 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::buildPartOrthogonalField(const mcIdTyp const double *locPtr=loc->getConstPointer(); for(const mcIdType *i=begin;i!=end;i++,vals+=3,locPtr+=3) { - mcIdType offset=connI[*i]; + mcIdType const offset=connI[*i]; INTERP_KERNEL::crossprod<3>(locPtr,coords+3*conn[offset+1],coords+3*conn[offset+2],vals); - double n=INTERP_KERNEL::norm<3>(vals); + double const n=INTERP_KERNEL::norm<3>(vals); std::transform(vals,vals+3,vals,std::bind(std::multiplies(),std::placeholders::_1,1./n)); } } @@ -3762,9 +3784,9 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::buildPartOrthogonalField(const mcIdTyp double tmp[2]; for(const mcIdType *i=begin;i!=end;i++) { - mcIdType offset=connI[*i]; + mcIdType const offset=connI[*i]; std::transform(coords+2*conn[offset+2],coords+2*conn[offset+2]+2,coords+2*conn[offset+1],tmp,std::minus()); - double n=INTERP_KERNEL::norm<2>(tmp); + double const n=INTERP_KERNEL::norm<2>(tmp); std::transform(tmp,tmp+2,tmp,std::bind(std::multiplies(),std::placeholders::_1,1./n)); *vals++=-tmp[1]; *vals++=tmp[0]; @@ -3796,8 +3818,8 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::buildDirectionVectorField() const throw INTERP_KERNEL::Exception("Expected a umesh with only NORM_SEG2 type of elements for buildDirectionVectorField !"); MCAuto ret=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME); MCAuto array=DataArrayDouble::New(); - mcIdType nbOfCells=getNumberOfCells(); - int spaceDim=getSpaceDimension(); + mcIdType const nbOfCells=getNumberOfCells(); + int const spaceDim=getSpaceDimension(); array->alloc(nbOfCells,spaceDim); double *pt=array->getPointer(); const double *coo=getCoords()->getConstPointer(); @@ -3847,7 +3869,7 @@ MEDCouplingUMesh *MEDCouplingUMesh::buildSlice3D(const double *origin, const dou if(candidates->empty()) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::buildSlice3D : No 3D cells in this intercepts the specified plane considering bounding boxes !"); std::vector nodes; - DataArrayIdType *cellIds1D=0; + DataArrayIdType *cellIds1D=nullptr; MCAuto subMesh=static_cast(buildPartOfMySelf(candidates->begin(),candidates->end(),false)); subMesh->findNodesOnPlane(origin,vec,eps,nodes); MCAuto desc1=DataArrayIdType::New(),desc2=DataArrayIdType::New(); @@ -3855,19 +3877,19 @@ MEDCouplingUMesh *MEDCouplingUMesh::buildSlice3D(const double *origin, const dou MCAuto revDesc1=DataArrayIdType::New(),revDesc2=DataArrayIdType::New(); MCAuto revDescIndx1=DataArrayIdType::New(),revDescIndx2=DataArrayIdType::New(); MCAuto mDesc2=subMesh->buildDescendingConnectivity(desc2,descIndx2,revDesc2,revDescIndx2);//meshDim==2 spaceDim==3 - revDesc2=0; revDescIndx2=0; + revDesc2=nullptr; revDescIndx2=nullptr; MCAuto mDesc1=mDesc2->buildDescendingConnectivity(desc1,descIndx1,revDesc1,revDescIndx1);//meshDim==1 spaceDim==3 - revDesc1=0; revDescIndx1=0; + revDesc1=nullptr; revDescIndx1=nullptr; //Marking all 1D cells that contained at least one node located on the plane //the intersection between those cells and the plane, which consist of the nodes previously tagged, thus don't need to be computed afterwards //(if said intersection is computed in MEDCouplingUMesh::split3DCurveWithPlane, then we might create additional nodes //due to accuracy errors when the needed nodes already exist) mDesc1->fillCellIdsToKeepFromNodeIds(&nodes[0],&nodes[0]+nodes.size(),false,cellIds1D); - MCAuto cellIds1DTmp(cellIds1D); + MCAuto const cellIds1DTmp(cellIds1D); // std::vector cut3DCurve(mDesc1->getNumberOfCells(),-2); - for(const mcIdType *it=cellIds1D->begin();it!=cellIds1D->end();it++) - cut3DCurve[*it]=-1; + for(long const it : *cellIds1D) + cut3DCurve[it]=-1; mDesc1->split3DCurveWithPlane(origin,vec,eps,cut3DCurve); std::vector< std::pair > cut3DSurf(mDesc2->getNumberOfCells()); AssemblyForSplitFrom3DCurve(cut3DCurve,nodes,mDesc2->getNodalConnectivity()->getConstPointer(),mDesc2->getNodalConnectivityIndex()->getConstPointer(), @@ -3917,19 +3939,19 @@ MEDCouplingUMesh *MEDCouplingUMesh::buildSlice3DSurf(const double *origin, const if(candidates->empty()) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::buildSlice3DSurf : No 3D surf cells in this intercepts the specified plane considering bounding boxes !"); std::vector nodes; - DataArrayIdType *cellIds1D(0); + DataArrayIdType *cellIds1D(nullptr); MCAuto subMesh(buildPartOfMySelf(candidates->begin(),candidates->end(),false)); subMesh->findNodesOnPlane(origin,vec,eps,nodes); MCAuto desc1(DataArrayIdType::New()),descIndx1(DataArrayIdType::New()),revDesc1(DataArrayIdType::New()),revDescIndx1(DataArrayIdType::New()); MCAuto mDesc1(subMesh->buildDescendingConnectivity(desc1,descIndx1,revDesc1,revDescIndx1));//meshDim==1 spaceDim==3 mDesc1->fillCellIdsToKeepFromNodeIds(&nodes[0],&nodes[0]+nodes.size(),true,cellIds1D); - MCAuto cellIds1DTmp(cellIds1D); + MCAuto const cellIds1DTmp(cellIds1D); // std::vector cut3DCurve(mDesc1->getNumberOfCells(),-2); - for(const mcIdType *it=cellIds1D->begin();it!=cellIds1D->end();it++) - cut3DCurve[*it]=-1; + for(long const it : *cellIds1D) + cut3DCurve[it]=-1; mDesc1->split3DCurveWithPlane(origin,vec,eps,cut3DCurve); - mcIdType ncellsSub=subMesh->getNumberOfCells(); + mcIdType const ncellsSub=subMesh->getNumberOfCells(); std::vector< std::pair > cut3DSurf(ncellsSub); AssemblyForSplitFrom3DCurve(cut3DCurve,nodes,subMesh->getNodalConnectivity()->getConstPointer(),subMesh->getNodalConnectivityIndex()->getConstPointer(), mDesc1->getNodalConnectivity()->getConstPointer(),mDesc1->getNodalConnectivityIndex()->getConstPointer(), @@ -3950,9 +3972,9 @@ MEDCouplingUMesh *MEDCouplingUMesh::buildSlice3DSurf(const double *origin, const } else { - mcIdType cellId3DSurf=cut3DSurf[i].second; - mcIdType offset=nodalI[cellId3DSurf]+1; - mcIdType nbOfEdges=nodalI[cellId3DSurf+1]-offset; + mcIdType const cellId3DSurf=cut3DSurf[i].second; + mcIdType const offset=nodalI[cellId3DSurf]+1; + mcIdType const nbOfEdges=nodalI[cellId3DSurf+1]-offset; for(mcIdType j=0;jpushBackSilent(ToIdType(INTERP_KERNEL::NORM_SEG2)); conn->pushBackSilent(nodal[offset+j]); conn->pushBackSilent(nodal[offset+(j+1)%nbOfEdges]); @@ -3983,18 +4005,18 @@ MCAuto MEDCouplingUMesh::clipSingle3DCellByPlane(const double findNodesOnPlane(origin,vec,eps,nodes); MCAuto desc1(DataArrayIdType::New()),desc2(DataArrayIdType::New()),descIndx1(DataArrayIdType::New()),descIndx2(DataArrayIdType::New()),revDesc1(DataArrayIdType::New()),revDesc2(DataArrayIdType::New()),revDescIndx1(DataArrayIdType::New()),revDescIndx2(DataArrayIdType::New()); MCAuto mDesc2(buildDescendingConnectivity(desc2,descIndx2,revDesc2,revDescIndx2));//meshDim==2 spaceDim==3 - revDesc2=0; revDescIndx2=0; + revDesc2=nullptr; revDescIndx2=nullptr; MCAuto mDesc1(mDesc2->buildDescendingConnectivity(desc1,descIndx1,revDesc1,revDescIndx1));//meshDim==1 spaceDim==3 - revDesc1=0; revDescIndx1=0; - DataArrayIdType *cellIds1D(0); + revDesc1=nullptr; revDescIndx1=nullptr; + DataArrayIdType *cellIds1D(nullptr); mDesc1->fillCellIdsToKeepFromNodeIds(&nodes[0],&nodes[0]+nodes.size(),true,cellIds1D); - MCAuto cellIds1DTmp(cellIds1D); + MCAuto const cellIds1DTmp(cellIds1D); std::vector cut3DCurve(mDesc1->getNumberOfCells(),-2); - for(const mcIdType *it=cellIds1D->begin();it!=cellIds1D->end();it++) - cut3DCurve[*it]=-1; + for(long const it : *cellIds1D) + cut3DCurve[it]=-1; bool sameNbNodes; { - mcIdType oldNbNodes(mDesc1->getNumberOfNodes()); + mcIdType const oldNbNodes(mDesc1->getNumberOfNodes()); mDesc1->split3DCurveWithPlane(origin,vec,eps,cut3DCurve); sameNbNodes=(mDesc1->getNumberOfNodes()==oldNbNodes); } @@ -4012,7 +4034,7 @@ MCAuto MEDCouplingUMesh::clipSingle3DCellByPlane(const double } std::vector > res; buildSubCellsFromCut(cut3DSurf,desc2->begin(),descIndx2->begin(),mDesc1->getCoords()->begin(),eps,res); - std::size_t sz(res.size()); + std::size_t const sz(res.size()); if(ToIdType(res.size())==mDesc1->getNumberOfCells() && sameNbNodes) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::clipSingle3DCellByPlane : cell is not clipped !"); for(std::size_t i=0;i MEDCouplingUMesh::clipSingle3DCellByPlane(const double MCAuto ret(MEDCouplingUMesh::New("",2)); ret->setCoords(mDesc1->getCoords()); ret->setConnectivity(conn,connI,true); - mcIdType nbCellsRet(ret->getNumberOfCells()); + mcIdType const nbCellsRet(ret->getNumberOfCells()); // MCAuto vec2(DataArrayDouble::New()); vec2->alloc(1,3); std::copy(vec,vec+3,vec2->getPointer()); MCAuto ortho(ret->buildOrthogonalField()); @@ -4106,18 +4128,18 @@ DataArrayIdType *MEDCouplingUMesh::getCellIdsCrossingPlane(const double *origin, checkFullyDefined(); if(getSpaceDimension()!=3) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::buildSlice3D works on umeshes with spaceDim equal to 3 !"); - double normm=sqrt(vec[0]*vec[0]+vec[1]*vec[1]+vec[2]*vec[2]); + double const normm=sqrt(vec[0]*vec[0]+vec[1]*vec[1]+vec[2]*vec[2]); if(normm<1e-6) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::getCellIdsCrossingPlane : parameter 'vec' should have a norm2 greater than 1e-6 !"); double vec2[3]; vec2[0]=vec[1]; vec2[1]=-vec[0]; vec2[2]=0.;//vec2 is the result of cross product of vec with (0,0,1) - double angle=acos(vec[2]/normm); + double const angle=acos(vec[2]/normm); MCAuto cellIds; double bbox[6]; if(angle>eps) { MCAuto coo=_coords->deepCopy(); - double normm2(sqrt(vec2[0]*vec2[0]+vec2[1]*vec2[1]+vec2[2]*vec2[2])); + double const normm2(sqrt(vec2[0]*vec2[0]+vec2[1]*vec2[1]+vec2[2]*vec2[2])); if(normm2/normm>1e-6) DataArrayDouble::Rotate3DAlg(origin,vec2,angle,coo->getNumberOfTuples(),coo->getPointer(),coo->getPointer()); MCAuto mw=clone(false);//false -> shallow copy @@ -4146,7 +4168,7 @@ bool MEDCouplingUMesh::isContiguous1D() const { if(getMeshDimension()!=1) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::isContiguous1D : this method has a sense only for 1D mesh !"); - mcIdType nbCells=getNumberOfCells(); + mcIdType const nbCells=getNumberOfCells(); if(nbCells<1) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::isContiguous1D : this method has a sense for non empty mesh !"); const mcIdType *connI(_nodal_connec_index->begin()),*conn(_nodal_connec->begin()); @@ -4230,7 +4252,7 @@ double MEDCouplingUMesh::distanceToPoint(const double *ptBg, const double *ptEnd checkFullyDefined(); if(ToIdType(std::distance(ptBg,ptEnd))!=spaceDim) { std::ostringstream oss; oss << "MEDCouplingUMesh::distanceToPoint : input point has to have dimension equal to the space dimension of this (" << spaceDim << ") !"; throw INTERP_KERNEL::Exception(oss.str()); } - DataArrayIdType *ret1=0; + DataArrayIdType *ret1=nullptr; MCAuto pts=DataArrayDouble::New(); pts->useArray(ptBg,false,DeallocType::C_DEALLOC,1,spaceDim); MCAuto ret0=distanceToPoints(pts,ret1); MCAuto ret1Safe(ret1); @@ -4275,10 +4297,10 @@ DataArrayDouble *MEDCouplingUMesh::distanceToPoints(const DataArrayDouble *pts, throw INTERP_KERNEL::Exception(oss.str()); } checkFullyDefined(); - mcIdType nbCells=getNumberOfCells(); + mcIdType const nbCells=getNumberOfCells(); if(nbCells==0) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::distanceToPoints : no cells in this !"); - mcIdType nbOfPts=pts->getNumberOfTuples(); + mcIdType const nbOfPts=pts->getNumberOfTuples(); MCAuto ret0=DataArrayDouble::New(); ret0->alloc(nbOfPts,1); MCAuto ret1=DataArrayIdType::New(); ret1->alloc(nbOfPts,1); const mcIdType *nc=_nodal_connec->begin(),*ncI=_nodal_connec_index->begin(); const double *coords=_coords->begin(); @@ -4289,7 +4311,7 @@ DataArrayDouble *MEDCouplingUMesh::distanceToPoints(const DataArrayDouble *pts, { case 3: { - BBTreeDst<3> myTree(bbox,0,0,nbCells); + BBTreeDst<3> const myTree(bbox,nullptr,0,nbCells); for(mcIdType i=0;i::max(); @@ -4302,7 +4324,7 @@ DataArrayDouble *MEDCouplingUMesh::distanceToPoints(const DataArrayDouble *pts, } case 2: { - BBTreeDst<2> myTree(bbox,0,0,nbCells); + BBTreeDst<2> const myTree(bbox,nullptr,0,nbCells); for(mcIdType i=0;i::max(); @@ -4477,20 +4499,20 @@ void MEDCouplingUMesh::checkButterflyCells(std::vector& cells, double const char msg[]="Butterfly detection work only for 2D cells with spaceDim==2 or 3!"; if(getMeshDimension()!=2) throw INTERP_KERNEL::Exception(msg); - int spaceDim=getSpaceDimension(); + int const spaceDim=getSpaceDimension(); if(spaceDim!=2 && spaceDim!=3) throw INTERP_KERNEL::Exception(msg); const mcIdType *conn=_nodal_connec->getConstPointer(); const mcIdType *connI=_nodal_connec_index->getConstPointer(); - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbOfCells=getNumberOfCells(); std::vector cell2DinS2; for(mcIdType i=0;igetConstPointer(); - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbOfCells=getNumberOfCells(); MCAuto nodalConnecIndexOut=DataArrayIdType::New(); nodalConnecIndexOut->alloc(nbOfCells+1,1); MCAuto nodalConnecOut(DataArrayIdType::New()); @@ -4532,14 +4554,14 @@ DataArrayIdType *MEDCouplingUMesh::convexEnvelop2D() isChanged->alloc(0,1); for(mcIdType i=0;igetNumberOfTuples(); + mcIdType const pos=nodalConnecOut->getNumberOfTuples(); if(BuildConvexEnvelopOf2DCellJarvis(coords,nodalConnecIn+nodalConnecIndexIn[i],nodalConnecIn+nodalConnecIndexIn[i+1],nodalConnecOut)) isChanged->pushBackSilent(i); types.insert((INTERP_KERNEL::NormalizedCellType)nodalConnecOut->getIJ(pos,0)); workIndexOut[1]=nodalConnecOut->getNumberOfTuples(); } if(isChanged->empty()) - return 0; + return nullptr; setConnectivity(nodalConnecOut,nodalConnecIndexOut,false); _types=types; return isChanged.retn(); @@ -4578,7 +4600,7 @@ MEDCouplingUMesh *MEDCouplingUMesh::buildExtrudedMesh(const MEDCouplingUMesh *me else throw INTERP_KERNEL::Exception("Invalid 2D mesh and 1D mesh because 2D mesh has quadratic cells and 1D is not fully quadratic !"); } - mcIdType oldNbOfNodes(getNumberOfNodes()); + mcIdType const oldNbOfNodes(getNumberOfNodes()); MCAuto newCoords; switch(policy) { @@ -4612,10 +4634,10 @@ bool MEDCouplingUMesh::isFullyQuadratic() const { checkFullyDefined(); bool ret=true; - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbOfCells=getNumberOfCells(); for(mcIdType i=0;ibegin(); for(mcIdType i=0;i types; checkFullyDefined(); MCAuto ret,connSafe,connISafe; MCAuto coordsSafe; - int meshDim=getMeshDimension(); + int const meshDim=getMeshDimension(); switch(conversionType) { case 0: @@ -4908,10 +4930,10 @@ DataArrayIdType *MEDCouplingUMesh::simplexize(int policy) bool MEDCouplingUMesh::areOnlySimplexCells() const { checkFullyDefined(); - int mdim=getMeshDimension(); + int const mdim=getMeshDimension(); if(mdim<1 || mdim>3) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::areOnlySimplexCells : only available with meshes having a meshdim 1, 2 or 3 !"); - mcIdType nbCells=getNumberOfCells(); + mcIdType const nbCells=getNumberOfCells(); const mcIdType *conn=_nodal_connec->begin(); const mcIdType *connI=_nodal_connec_index->begin(); for(mcIdType i=0;igetPointer(); mcIdType *index=_nodal_connec_index->getPointer(); mcIdType posOfCurCell=0; @@ -4953,9 +4975,9 @@ void MEDCouplingUMesh::convertDegeneratedCells() for(mcIdType i=0;i ret(DataArrayIdType::New()); ret->alloc(0,1); if(nbOfCells<1) return ret.retn(); - mcIdType initMeshLgth=getNodalConnectivityArrayLen(); + mcIdType const initMeshLgth=getNodalConnectivityArrayLen(); mcIdType *conn=_nodal_connec->getPointer(); mcIdType *index=_nodal_connec_index->getPointer(); mcIdType posOfCurCell=0; @@ -4994,12 +5016,12 @@ DataArrayIdType *MEDCouplingUMesh::convertDegeneratedCellsAndRemoveFlatOnes() for(mcIdType i=0;ibegin(); const mcIdType *connI=_nodal_connec_index->begin(); const double *coordsPtr=_coords->begin(); for(mcIdType i=0;igetPointer()); const mcIdType *connI(_nodal_connec_index->begin()); const double *coordsPtr(_coords->begin()); bool isModified(false); for(mcIdType i=0;igetPointer()); const mcIdType *connI(_nodal_connec_index->begin()); if(mdim==2) {//2D for(mcIdType i=0;i& { if(getMeshDimension()!=3 || getSpaceDimension()!=3) throw INTERP_KERNEL::Exception("Invalid mesh to apply arePolyhedronsNotCorrectlyOriented on it : must be meshDim==3 and spaceDim==3 !"); - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbOfCells=getNumberOfCells(); const mcIdType *conn=_nodal_connec->begin(); const mcIdType *connI=_nodal_connec_index->begin(); const double *coordsPtr=_coords->begin(); for(mcIdType i=0;igetPointer(); const mcIdType *connI=_nodal_connec_index->begin(); const double *coordsPtr=_coords->begin(); for(mcIdType i=0;i gts(getAllGeoTypes()); + std::set const gts(getAllGeoTypes()); mcIdType *conn(_nodal_connec->getPointer()); const mcIdType *conni(_nodal_connec_index->begin()); - for(std::set::const_iterator gt=gts.begin();gt!=gts.end();gt++) + for(auto gt : gts) { - INTERP_KERNEL::AutoCppPtr oi(INTERP_KERNEL::OrientationInverter::BuildInstanceFrom(*gt)); - MCAuto cwt(giveCellsWithType(*gt)); - for(const mcIdType *it=cwt->begin();it!=cwt->end();it++) - oi->operate(conn+conni[*it]+1,conn+conni[*it+1]); + INTERP_KERNEL::AutoCppPtr oi((INTERP_KERNEL::OrientationInverter::BuildInstanceFrom(gt))); + MCAuto cwt(giveCellsWithType(gt)); + for(long const it : *cwt) + oi->operate(conn+conni[it]+1,conn+conni[it+1]); } updateTime(); } @@ -5308,11 +5330,11 @@ DataArrayIdType *MEDCouplingUMesh::findAndCorrectBadOriented3DExtrudedCells() const char msg[]="check3DCellsWellOriented detection works only for 3D cells !"; if(getMeshDimension()!=3) throw INTERP_KERNEL::Exception(msg); - int spaceDim=getSpaceDimension(); + int const spaceDim=getSpaceDimension(); if(spaceDim!=3) throw INTERP_KERNEL::Exception(msg); // - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbOfCells=getNumberOfCells(); mcIdType *conn=_nodal_connec->getPointer(); const mcIdType *connI=_nodal_connec_index->begin(); const double *coo=getCoords()->begin(); @@ -5344,14 +5366,14 @@ DataArrayIdType *MEDCouplingUMesh::findAndCorrectBadOriented3DCells() { if(getMeshDimension()!=3 || getSpaceDimension()!=3) throw INTERP_KERNEL::Exception("Invalid mesh to apply findAndCorrectBadOriented3DCells on it : must be meshDim==3 and spaceDim==3 !"); - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbOfCells=getNumberOfCells(); mcIdType *conn=_nodal_connec->getPointer(); const mcIdType *connI=_nodal_connec_index->begin(); const double *coordsPtr=_coords->begin(); MCAuto ret=DataArrayIdType::New(); ret->alloc(0,1); for(mcIdType i=0;i ret=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME); ret->setMesh(this); - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbOfCells=getNumberOfCells(); MCAuto arr=DataArrayDouble::New(); arr->alloc(nbOfCells,1); double *pt=arr->getPointer(); @@ -5463,7 +5485,7 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::getEdgeRatioField() const double tmp[12]; for(mcIdType i=0;i ret=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME); ret->setMesh(this); - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbOfCells=getNumberOfCells(); MCAuto arr=DataArrayDouble::New(); arr->alloc(nbOfCells,1); double *pt=arr->getPointer(); @@ -5535,7 +5557,7 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::getAspectRatioField() const double tmp[12]; for(mcIdType i=0;i ret=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME); ret->setMesh(this); - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbOfCells=getNumberOfCells(); MCAuto arr=DataArrayDouble::New(); arr->alloc(nbOfCells,1); double *pt=arr->getPointer(); @@ -5616,7 +5638,7 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::getWarpField() const double tmp[12]; for(mcIdType i=0;i ret=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME); ret->setMesh(this); - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbOfCells=getNumberOfCells(); MCAuto arr=DataArrayDouble::New(); arr->alloc(nbOfCells,1); double *pt=arr->getPointer(); @@ -5683,7 +5705,7 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::getSkewField() const double tmp[12]; for(mcIdType i=0;isetMesh(this); std::set types; ComputeAllTypesInternal(types,_nodal_connec,_nodal_connec_index); - int spaceDim(getSpaceDimension()); - mcIdType nbCells(getNumberOfCells()); + int const spaceDim(getSpaceDimension()); + mcIdType const nbCells(getNumberOfCells()); MCAuto arr(DataArrayDouble::New()); arr->alloc(nbCells,1); - for(std::set::const_iterator it=types.begin();it!=types.end();it++) + for(auto type : types) { - INTERP_KERNEL::AutoCppPtr dc(INTERP_KERNEL::CellModel::GetCellModel(*it).buildInstanceOfDiameterCalulator(spaceDim)); - MCAuto cellIds(giveCellsWithType(*it)); + INTERP_KERNEL::AutoCppPtr dc(INTERP_KERNEL::CellModel::GetCellModel(type).buildInstanceOfDiameterCalulator(spaceDim)); + MCAuto cellIds(giveCellsWithType(type)); dc->computeForListOfCellIdsUMeshFrmt(cellIds->begin(),cellIds->end(),_nodal_connec_index->begin(),_nodal_connec->begin(),getCoords()->begin(),arr->getPointer()); } ret->setArray(arr); @@ -5750,9 +5772,9 @@ DataArrayDouble *MEDCouplingUMesh::getBoundingBoxForBBTree(double arcDetEps) con if((mDim==2 && sDim==2) || (mDim==1 && sDim==2)) { bool presenceOfQuadratic(false); - for(std::set::const_iterator it=_types.begin();it!=_types.end();it++) + for(auto _type : _types) { - const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(*it)); + const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_type)); if(cm.isQuadratic()) presenceOfQuadratic=true; } @@ -5778,7 +5800,7 @@ DataArrayDouble *MEDCouplingUMesh::getBoundingBoxForBBTree(double arcDetEps) con DataArrayDouble *MEDCouplingUMesh::getBoundingBoxForBBTreeFast() const { checkFullyDefined(); - int spaceDim(getSpaceDimension()); + int const spaceDim(getSpaceDimension()); mcIdType nbOfCells(getNumberOfCells()), nbOfNodes(getNumberOfNodes()); MCAuto ret(DataArrayDouble::New()); ret->alloc(nbOfCells,2*spaceDim); double *bbox(ret->getPointer()); @@ -5791,11 +5813,11 @@ DataArrayDouble *MEDCouplingUMesh::getBoundingBoxForBBTreeFast() const const mcIdType *conn(_nodal_connec->begin()),*connI(_nodal_connec_index->begin()); for(mcIdType i=0;i=0 && nodeId ret(DataArrayDouble::New()); ret->alloc(nbOfCells,2*spaceDim); @@ -5844,12 +5866,12 @@ DataArrayDouble *MEDCouplingUMesh::getBoundingBoxForBBTree2DQuadratic(double arc for(mcIdType i=0;i nodes(sz); - INTERP_KERNEL::QuadraticPolygon *pol(0); + INTERP_KERNEL::QuadraticPolygon *pol(nullptr); for(mcIdType j=0;j ret(DataArrayDouble::New()); ret->alloc(nbOfCells,2*spaceDim); double *bbox(ret->getPointer()); const double *coords(_coords->begin()); @@ -5890,12 +5912,12 @@ DataArrayDouble *MEDCouplingUMesh::getBoundingBoxForBBTree1DQuadratic(double arc for(mcIdType i=0;i nodes(sz); - INTERP_KERNEL::Edge *edge(0); + INTERP_KERNEL::Edge *edge(nullptr); for(mcIdType j=0;j MEDCouplingUMesh::getDistributionOfTypes() const const mcIdType *conn=_nodal_connec->begin(); const mcIdType *connI=_nodal_connec_index->begin(); const mcIdType *work=connI; - mcIdType nbOfCells=getNumberOfCells(); - std::size_t n=getAllGeoTypes().size(); + mcIdType const nbOfCells=getNumberOfCells(); + std::size_t const n=getAllGeoTypes().size(); std::vector ret(3*n,-1); //ret[3*k+2]==-1 because it has no sense here std::set types; for(std::size_t i=0;work!=connI+nbOfCells;i++) { - INTERP_KERNEL::NormalizedCellType typ=(INTERP_KERNEL::NormalizedCellType)conn[*work]; + auto const typ=(INTERP_KERNEL::NormalizedCellType)conn[*work]; if(types.find(typ)!=types.end()) { std::ostringstream oss; oss << "MEDCouplingUMesh::getDistributionOfTypes : Type " << INTERP_KERNEL::CellModel::GetCellModel(typ).getRepr(); @@ -5992,8 +6014,8 @@ DataArrayIdType *MEDCouplingUMesh::checkTypeConsistencyAndContig(const std::vect { if(code.empty()) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::checkTypeConsistencyAndContig : code is empty, should not !"); - std::size_t sz=code.size(); - std::size_t n=sz/3; + std::size_t const sz=code.size(); + std::size_t const n=sz/3; if(sz%3!=0) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::checkTypeConsistencyAndContig : code size is NOT %3 !"); std::vector types; @@ -6015,28 +6037,28 @@ DataArrayIdType *MEDCouplingUMesh::checkTypeConsistencyAndContig(const std::vect if(!checkConsecutiveCellTypesAndOrder(&types[0],&types[0]+types.size())) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::checkTypeConsistencyAndContig : non contiguous type !"); if(types.size()==_types.size()) - return 0; + return nullptr; } MCAuto ret=DataArrayIdType::New(); ret->alloc(nb,1); mcIdType *retPtr=ret->getPointer(); const mcIdType *connI=_nodal_connec_index->begin(); const mcIdType *conn=_nodal_connec->begin(); - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbOfCells=getNumberOfCells(); const mcIdType *i=connI; int kk=0; for(std::vector::const_iterator it=types.begin();it!=types.end();it++,kk++) { i=std::find_if(i,connI+nbOfCells,MEDCouplingImpl::ConnReader2(conn,ToIdType((*it)))); - mcIdType offset=ToIdType(std::distance(connI,i)); + mcIdType const offset=ToIdType(std::distance(connI,i)); const mcIdType *j=std::find_if(i+1,connI+nbOfCells,MEDCouplingImpl::ConnReader(conn,ToIdType((*it)))); - mcIdType nbOfCellsOfCurType=ToIdType(std::distance(i,j)); + mcIdType const nbOfCellsOfCurType=ToIdType(std::distance(i,j)); if(code[3*kk+2]==-1) for(mcIdType k=0;k=0 && idInIdsPerTypebegin(); const mcIdType *connI=_nodal_connec_index->begin(); - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbOfCells=getNumberOfCells(); std::vector types; std::vector typeRangeVals(1); for(const mcIdType *i=connI;i!=connI+nbOfCells;) { - INTERP_KERNEL::NormalizedCellType curType=(INTERP_KERNEL::NormalizedCellType)conn[*i]; + auto const curType=(INTERP_KERNEL::NormalizedCellType)conn[*i]; if(std::find(types.begin(),types.end(),curType)!=types.end()) { throw INTERP_KERNEL::Exception("MEDCouplingUMesh::splitProfilePerType : current mesh is not sorted by type !"); @@ -6113,19 +6135,19 @@ void MEDCouplingUMesh::splitProfilePerType(const DataArrayIdType *profile, std:: typeRangeVals.push_back(ToIdType(std::distance(connI,i))); } // - DataArrayIdType *castArr=0,*rankInsideCast=0,*castsPresent=0; + DataArrayIdType *castArr=nullptr,*rankInsideCast=nullptr,*castsPresent=nullptr; profile->splitByValueRange(&typeRangeVals[0],&typeRangeVals[0]+typeRangeVals.size(),castArr,rankInsideCast,castsPresent); - MCAuto tmp0=castArr; - MCAuto tmp1=rankInsideCast; - MCAuto tmp2=castsPresent; + MCAuto const tmp0=castArr; + MCAuto const tmp1=rankInsideCast; + MCAuto const tmp2=castsPresent; // - mcIdType nbOfCastsFinal=castsPresent->getNumberOfTuples(); + mcIdType const nbOfCastsFinal=castsPresent->getNumberOfTuples(); code.resize(3*nbOfCastsFinal); std::vector< MCAuto > idsInPflPerType2; std::vector< MCAuto > idsPerType2; for(mcIdType i=0;igetIJ(i,0); + mcIdType const castId=castsPresent->getIJ(i,0); MCAuto tmp3=castArr->findIdsEqual(castId); idsInPflPerType2.push_back(tmp3); code[3*i]=ToIdType(types[castId]); @@ -6142,7 +6164,7 @@ void MEDCouplingUMesh::splitProfilePerType(const DataArrayIdType *profile, std:: code[3*i+2]=-1; } } - std::size_t sz2=idsInPflPerType2.size(); + std::size_t const sz2=idsInPflPerType2.size(); idsInPflPerType.resize(sz2); for(std::size_t i=0;iincrRef(); idsInPflPerType[i]=locDa; } - std::size_t sz=idsPerType2.size(); + std::size_t const sz=idsPerType2.size(); idsPerType.resize(sz); for(std::size_t i=0;irenumberCells(ret0->begin(),false); revDesc=tmp->getNodalConnectivity(); revDescIndx=tmp->getNodalConnectivityIndex(); - DataArrayIdType *ret=0; + DataArrayIdType *ret=nullptr; if(!ret1->areCellsIncludedIn(nM1LevMesh,2,ret)) { mcIdType tmp2; @@ -6228,11 +6250,11 @@ bool MEDCouplingUMesh::checkConsecutiveCellTypes() const checkFullyDefined(); const mcIdType *conn=_nodal_connec->begin(); const mcIdType *connI=_nodal_connec_index->begin(); - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbOfCells=getNumberOfCells(); std::set types; for(const mcIdType *i=connI;i!=connI+nbOfCells;) { - INTERP_KERNEL::NormalizedCellType curType=(INTERP_KERNEL::NormalizedCellType)conn[*i]; + auto const curType=(INTERP_KERNEL::NormalizedCellType)conn[*i]; if(types.find(curType)!=types.end()) return false; types.insert(curType); @@ -6263,18 +6285,18 @@ bool MEDCouplingUMesh::checkConsecutiveCellTypesAndOrder(const INTERP_KERNEL::No checkFullyDefined(); const mcIdType *conn=_nodal_connec->begin(); const mcIdType *connI=_nodal_connec_index->begin(); - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbOfCells=getNumberOfCells(); if(nbOfCells==0) return true; mcIdType lastPos=-1; std::set sg; for(const mcIdType *i=connI;i!=connI+nbOfCells;) { - INTERP_KERNEL::NormalizedCellType curType=(INTERP_KERNEL::NormalizedCellType)conn[*i]; + auto const curType=(INTERP_KERNEL::NormalizedCellType)conn[*i]; const INTERP_KERNEL::NormalizedCellType *isTypeExists=std::find(orderBg,orderEnd,curType); if(isTypeExists!=orderEnd) { - mcIdType pos=ToIdType(std::distance(orderBg,isTypeExists)); + mcIdType const pos=ToIdType(std::distance(orderBg,isTypeExists)); if(pos<=lastPos) return false; lastPos=pos; @@ -6302,7 +6324,7 @@ bool MEDCouplingUMesh::checkConsecutiveCellTypesAndOrder(const INTERP_KERNEL::No DataArrayIdType *MEDCouplingUMesh::getLevArrPerCellTypes(const INTERP_KERNEL::NormalizedCellType *orderBg, const INTERP_KERNEL::NormalizedCellType *orderEnd, DataArrayIdType *&nbPerType) const { checkConnectivityFullyDefined(); - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbOfCells=getNumberOfCells(); const mcIdType *conn=_nodal_connec->begin(); const mcIdType *connI=_nodal_connec_index->begin(); MCAuto tmpa=DataArrayIdType::New(); @@ -6317,7 +6339,7 @@ DataArrayIdType *MEDCouplingUMesh::getLevArrPerCellTypes(const INTERP_KERNEL::No const INTERP_KERNEL::NormalizedCellType *where=std::find(orderBg,orderEnd,(INTERP_KERNEL::NormalizedCellType)conn[*i]); if(where!=orderEnd) { - mcIdType pos=ToIdType(std::distance(orderBg,where)); + mcIdType const pos=ToIdType(std::distance(orderBg,where)); tmp2[pos]++; tmp[std::distance(connI,i)]=pos; } @@ -6353,7 +6375,7 @@ DataArrayIdType *MEDCouplingUMesh::getRenumArrForMEDFileFrmt() const */ DataArrayIdType *MEDCouplingUMesh::getRenumArrForConsecutiveCellTypesSpec(const INTERP_KERNEL::NormalizedCellType *orderBg, const INTERP_KERNEL::NormalizedCellType *orderEnd) const { - DataArrayIdType *nbPerType=0; + DataArrayIdType *nbPerType=nullptr; MCAuto tmpa=getLevArrPerCellTypes(orderBg,orderEnd,nbPerType); nbPerType->decrRef(); return tmpa->buildPermArrPerLevel(); @@ -6373,12 +6395,12 @@ DataArrayIdType *MEDCouplingUMesh::rearrange2ConsecutiveCellTypes() computeTypes(); const mcIdType *conn=_nodal_connec->begin(); const mcIdType *connI=_nodal_connec_index->begin(); - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbOfCells=getNumberOfCells(); std::vector types; for(const mcIdType *i=connI;i!=connI+nbOfCells && (types.size()!=_types.size());) if(std::find(types.begin(),types.end(),(INTERP_KERNEL::NormalizedCellType)conn[*i])==types.end()) { - INTERP_KERNEL::NormalizedCellType curType=(INTERP_KERNEL::NormalizedCellType)conn[*i]; + auto const curType=(INTERP_KERNEL::NormalizedCellType)conn[*i]; types.push_back(curType); for(i++;i!=connI+nbOfCells && (INTERP_KERNEL::NormalizedCellType)conn[*i]==curType;i++); } @@ -6387,10 +6409,10 @@ DataArrayIdType *MEDCouplingUMesh::rearrange2ConsecutiveCellTypes() mcIdType *retPtr=ret->getPointer(); std::fill(retPtr,retPtr+nbOfCells,-1); mcIdType newCellId=0; - for(std::vector::const_iterator iter=types.begin();iter!=types.end();iter++) + for(auto type : types) { for(const mcIdType *i=connI;i!=connI+nbOfCells;i++) - if((INTERP_KERNEL::NormalizedCellType)conn[*i]==(*iter)) + if((INTERP_KERNEL::NormalizedCellType)conn[*i]==type) retPtr[std::distance(connI,i)]=newCellId++; } renumberCells(retPtr,false); @@ -6407,19 +6429,19 @@ std::vector MEDCouplingUMesh::splitByType() const checkConnectivityFullyDefined(); const mcIdType *conn=_nodal_connec->begin(); const mcIdType *connI=_nodal_connec_index->begin(); - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbOfCells=getNumberOfCells(); std::vector ret; for(const mcIdType *i=connI;i!=connI+nbOfCells;) { - INTERP_KERNEL::NormalizedCellType curType=(INTERP_KERNEL::NormalizedCellType)conn[*i]; - mcIdType beginCellId=ToIdType(std::distance(connI,i)); + auto const curType=(INTERP_KERNEL::NormalizedCellType)conn[*i]; + mcIdType const beginCellId=ToIdType(std::distance(connI,i)); i=std::find_if(i+1,connI+nbOfCells,MEDCouplingImpl::ConnReader(conn,ToIdType(curType))); - mcIdType endCellId=ToIdType(std::distance(connI,i)); - mcIdType sz=endCellId-beginCellId; - mcIdType *cells=new mcIdType[sz]; + mcIdType const endCellId=ToIdType(std::distance(connI,i)); + mcIdType const sz=endCellId-beginCellId; + auto *cells=new mcIdType[sz]; for(mcIdType j=0;j ret=MEDCoupling1GTUMesh::New(getName(),typ); ret->setCoords(getCoords()); - MEDCoupling1SGTUMesh *retC=dynamic_cast((MEDCoupling1GTUMesh*)ret); + auto *retC=dynamic_cast((MEDCoupling1GTUMesh*)ret); if(retC) { MCAuto c=convertNodalConnectivityToStaticGeoTypeMesh(); @@ -6452,10 +6474,10 @@ MEDCoupling1GTUMesh *MEDCouplingUMesh::convertIntoSingleGeoTypeMesh() const } else { - MEDCoupling1DGTUMesh *retD=dynamic_cast((MEDCoupling1GTUMesh*)ret); + auto *retD=dynamic_cast((MEDCoupling1GTUMesh*)ret); if(!retD) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::convertIntoSingleGeoTypeMesh : Internal error !"); - DataArrayIdType *c=0,*ci=0; + DataArrayIdType *c=nullptr,*ci=nullptr; convertNodalConnectivityToDynamicGeoTypeMesh(c,ci); MCAuto cs(c),cis(ci); retD->setNodalConnectivity(cs,cis); @@ -6468,7 +6490,7 @@ DataArrayIdType *MEDCouplingUMesh::convertNodalConnectivityToStaticGeoTypeMesh() checkConnectivityFullyDefined(); if(_types.size()!=1) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::convertNodalConnectivityToStaticGeoTypeMesh : current mesh does not contain exactly one geometric type !"); - INTERP_KERNEL::NormalizedCellType typ=*_types.begin(); + INTERP_KERNEL::NormalizedCellType const typ=*_types.begin(); const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ); if(cm.isDynamic()) { @@ -6476,8 +6498,8 @@ DataArrayIdType *MEDCouplingUMesh::convertNodalConnectivityToStaticGeoTypeMesh() oss << "this type is dynamic ! Only static geometric type is possible for that type ! call convertNodalConnectivityToDynamicGeoTypeMesh instead !"; throw INTERP_KERNEL::Exception(oss.str()); } - mcIdType nbCells=getNumberOfCells(); - mcIdType typi=ToIdType(typ); + mcIdType const nbCells=getNumberOfCells(); + mcIdType const typi=ToIdType(typ); mcIdType nbNodesPerCell=ToIdType(cm.getNumberOfNodes()); MCAuto connOut=DataArrayIdType::New(); connOut->alloc(nbCells*nbNodesPerCell,1); mcIdType *outPtr=connOut->getPointer(); @@ -6521,7 +6543,7 @@ void MEDCouplingUMesh::convertNodalConnectivityToDynamicGeoTypeMesh(DataArrayIdT for(mcIdType i=0;i=1) { if((strt>=0 && strt=0 && stop<=lgth)) @@ -6557,16 +6579,16 @@ MEDCouplingUMesh *MEDCouplingUMesh::AggregateSortedByTypeMeshesOnSameCoords(cons DataArrayIdType *&idInMsOfCellGrpOfSameType) { std::vector ms2; - for(std::vector::const_iterator it=ms.begin();it!=ms.end();it++) - if(*it) + for(auto m : ms) + if(m) { - (*it)->checkConnectivityFullyDefined(); - ms2.push_back(*it); + m->checkConnectivityFullyDefined(); + ms2.push_back(m); } if(ms2.empty()) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::AggregateSortedByTypeMeshesOnSameCoords : input vector is empty !"); const DataArrayDouble *refCoo=ms2[0]->getCoords(); - int meshDim=ms2[0]->getMeshDimension(); + int const meshDim=ms2[0]->getMeshDimension(); std::vector m1ssm; std::vector< MCAuto > m1ssmAuto; // @@ -6584,12 +6606,12 @@ MEDCouplingUMesh *MEDCouplingUMesh::AggregateSortedByTypeMeshesOnSameCoords(cons std::vector sp=(*it)->splitByType(); std::copy(sp.begin(),sp.end(),std::back_insert_iterator< std::vector >(m1ssm)); std::copy(sp.begin(),sp.end(),std::back_insert_iterator< std::vector > >(m1ssmAuto)); - for(std::vector::const_iterator it2=sp.begin();it2!=sp.end();it2++) + for(auto it2 : sp) { - MEDCouplingUMesh *singleCell=static_cast((*it2)->buildPartOfMySelf(&fake,&fake+1,true)); + auto *singleCell=static_cast(it2->buildPartOfMySelf(&fake,&fake+1,true)); m1ssmSingleAuto.push_back(singleCell); m1ssmSingle.push_back(singleCell); - ret1->pushBackSilent((*it2)->getNumberOfCells()); ret2->pushBackSilent(rk); + ret1->pushBackSilent(it2->getNumberOfCells()); ret2->pushBackSilent(rk); } } MCAuto m1ssmSingle2=MEDCouplingUMesh::MergeUMeshesOnSameCoords(m1ssmSingle); @@ -6628,14 +6650,14 @@ DataArrayIdType *MEDCouplingUMesh::convertCellArrayPerGeoType(const DataArrayIdT checkFullyDefined(); const mcIdType *conn=_nodal_connec->begin(); const mcIdType *connI=_nodal_connec_index->begin(); - mcIdType nbOfCells=getNumberOfCells(); - std::set types(getAllGeoTypes()); - mcIdType *tmp=new mcIdType[nbOfCells]; - for(std::set::const_iterator iter=types.begin();iter!=types.end();iter++) + mcIdType const nbOfCells=getNumberOfCells(); + std::set const types(getAllGeoTypes()); + auto *tmp=new mcIdType[nbOfCells]; + for(auto type : types) { mcIdType j=0; for(const mcIdType *i=connI;i!=connI+nbOfCells;i++) - if((INTERP_KERNEL::NormalizedCellType)conn[*i]==(*iter)) + if((INTERP_KERNEL::NormalizedCellType)conn[*i]==type) tmp[std::distance(connI,i)]=j++; } DataArrayIdType *ret=DataArrayIdType::New(); @@ -6643,7 +6665,7 @@ DataArrayIdType *MEDCouplingUMesh::convertCellArrayPerGeoType(const DataArrayIdT ret->copyStringInfoFrom(*da); mcIdType *retPtr=ret->getPointer(); const mcIdType *daPtr=da->begin(); - mcIdType nbOfElems=da->getNbOfElems(); + mcIdType const nbOfElems=da->getNbOfElems(); for(mcIdType k=0;k code=getDistributionOfTypes(); - std::size_t nOfTypesInThis=code.size()/3; + std::size_t const nOfTypesInThis=code.size()/3; mcIdType sz=0,szOfType=0; for(std::size_t i=0;i MEDCouplingUMesh::getQuadraticStatus() const { - mcIdType ncell=getNumberOfCells(); + mcIdType const ncell=getNumberOfCells(); std::vector ret(ncell); const mcIdType *cI=getNodalConnectivityIndex()->begin(); const mcIdType *c=getNodalConnectivity()->begin(); for(mcIdType i=0;igetType()!=UNSTRUCTURED) throw INTERP_KERNEL::Exception("Merge of umesh only available with umesh each other !"); - const MEDCouplingUMesh *otherC=static_cast(other); + const auto *otherC=static_cast(other); return MergeUMeshes(this,otherC); } @@ -6740,8 +6762,8 @@ MEDCouplingMesh *MEDCouplingUMesh::mergeMyselfWith(const MEDCouplingMesh *other) DataArrayDouble *MEDCouplingUMesh::computeCellCenterOfMass() const { MCAuto ret=DataArrayDouble::New(); - int spaceDim=getSpaceDimension(); - mcIdType nbOfCells=getNumberOfCells(); + int const spaceDim=getSpaceDimension(); + mcIdType const nbOfCells=getNumberOfCells(); ret->alloc(nbOfCells,spaceDim); ret->copyStringInfoFrom(*getCoords()); double *ptToFill=ret->getPointer(); @@ -6750,7 +6772,7 @@ DataArrayDouble *MEDCouplingUMesh::computeCellCenterOfMass() const const double *coor=_coords->begin(); for(mcIdType i=0;i(type,nodal+nodalI[i]+1,nodalI[i+1]-nodalI[i]-1,coor,spaceDim,ptToFill); ptToFill+=spaceDim; } @@ -6772,7 +6794,7 @@ DataArrayDouble *MEDCouplingUMesh::computeCellCenterOfMass() const */ DataArrayDouble *MEDCouplingUMesh::computeCellCenterOfMassWithPrecision(double eps) const { - INTERP_KERNEL::QuadraticPlanarPrecision prec(eps); + INTERP_KERNEL::QuadraticPlanarPrecision const prec(eps); MCAuto ret = computeCellCenterOfMass(); return ret.retn(); } @@ -6793,9 +6815,9 @@ DataArrayDouble *MEDCouplingUMesh::computeIsoBarycenterOfNodesPerCell() const { checkFullyDefined(); MCAuto ret=DataArrayDouble::New(); - int spaceDim=getSpaceDimension(); - mcIdType nbOfCells=getNumberOfCells(); - mcIdType nbOfNodes=getNumberOfNodes(); + int const spaceDim=getSpaceDimension(); + mcIdType const nbOfCells=getNumberOfCells(); + mcIdType const nbOfNodes=getNumberOfNodes(); ret->alloc(nbOfCells,spaceDim); double *ptToFill=ret->getPointer(); const mcIdType *nodal=_nodal_connec->begin(); @@ -6803,7 +6825,7 @@ DataArrayDouble *MEDCouplingUMesh::computeIsoBarycenterOfNodesPerCell() const const double *coor=_coords->begin(); for(mcIdType i=0;i0) std::transform(ptToFill,ptToFill+spaceDim,ptToFill,std::bind(std::multiplies(),std::placeholders::_1,1./(double)nbOfNodesInCell)); else @@ -6830,13 +6852,13 @@ DataArrayDouble *MEDCouplingUMesh::computeIsoBarycenterOfNodesPerCell() const { std::set s(nodal+nodalI[i]+1,nodal+nodalI[i+1]); s.erase(-1); - for(std::set::const_iterator it=s.begin();it!=s.end();it++) + for(long const it : s) { - if(*it>=0 && *it()); + if(it>=0 && it()); else { - std::ostringstream oss; oss << "MEDCouplingUMesh::computeIsoBarycenterOfNodesPerCell : on cell polyhedron cell #" << i << " presence of nodeId #" << *it << " should be in [0," << nbOfNodes << ") !"; + std::ostringstream oss; oss << "MEDCouplingUMesh::computeIsoBarycenterOfNodesPerCell : on cell polyhedron cell #" << i << " presence of nodeId #" << it << " should be in [0," << nbOfNodes << ") !"; throw INTERP_KERNEL::Exception(oss.str()); } } @@ -6874,17 +6896,17 @@ DataArrayDouble *MEDCouplingUMesh::computeIsoBarycenterOfNodesPerCell() const DataArrayDouble *MEDCouplingUMesh::getPartBarycenterAndOwner(const mcIdType *begin, const mcIdType *end) const { DataArrayDouble *ret=DataArrayDouble::New(); - int spaceDim=getSpaceDimension(); - std::size_t nbOfTuple=std::distance(begin,end); + int const spaceDim=getSpaceDimension(); + std::size_t const nbOfTuple=std::distance(begin,end); ret->alloc(nbOfTuple,spaceDim); double *ptToFill=ret->getPointer(); - double *tmp=new double[spaceDim]; + auto *tmp=new double[spaceDim]; const mcIdType *nodal=_nodal_connec->begin(); const mcIdType *nodalI=_nodal_connec_index->begin(); const double *coor=_coords->begin(); for(const mcIdType *w=begin;w!=end;w++) { - INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)nodal[nodalI[*w]]; + auto const type=(INTERP_KERNEL::NormalizedCellType)nodal[nodalI[*w]]; INTERP_KERNEL::computeBarycenter2(type,nodal+nodalI[*w]+1,nodalI[*w+1]-nodalI[*w]-1,coor,spaceDim,ptToFill); ptToFill+=spaceDim; } @@ -6907,8 +6929,8 @@ DataArrayDouble *MEDCouplingUMesh::getPartBarycenterAndOwner(const mcIdType *beg DataArrayDouble *MEDCouplingUMesh::computePlaneEquationOf3DFaces() const { MCAuto ret(DataArrayDouble::New()); - mcIdType nbOfCells=getNumberOfCells(); - mcIdType nbOfNodes(getNumberOfNodes()); + mcIdType const nbOfCells=getNumberOfCells(); + mcIdType const nbOfNodes(getNumberOfNodes()); if(getSpaceDimension()!=3 || getMeshDimension()!=2) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::computePlaneEquationOf3DFaces : This method must be applied on a mesh having meshDimension equal 2 and a spaceDimension equal to 3 !"); ret->alloc(nbOfCells,4); @@ -6926,11 +6948,11 @@ DataArrayDouble *MEDCouplingUMesh::computePlaneEquationOf3DFaces() const ,bb[3]={coor[nodal[nodalI[0]+1+2]*3+0]-coor[nodal[nodalI[0]+1+0]*3+0], coor[nodal[nodalI[0]+1+2]*3+1]-coor[nodal[nodalI[0]+1+0]*3+1], coor[nodal[nodalI[0]+1+2]*3+2]-coor[nodal[nodalI[0]+1+0]*3+2]}; - double cc[3]={aa[1]*bb[2]-aa[2]*bb[1],aa[2]*bb[0]-aa[0]*bb[2],aa[0]*bb[1]-aa[1]*bb[0]}; + double const cc[3]={aa[1]*bb[2]-aa[2]*bb[1],aa[2]*bb[0]-aa[0]*bb[2],aa[0]*bb[1]-aa[1]*bb[0]}; double aa_norm(sqrt(aa[0]*aa[0]+aa[1]*aa[1]+aa[2]*aa[2])),bb_norm(sqrt(bb[0]*bb[0]+bb[1]*bb[1]+bb[2]*bb[2])); for(int j=0;j<3;j++) { - mcIdType nodeId(nodal[nodalI[0]+1+j]); + mcIdType const nodeId(nodal[nodalI[0]+1+j]); if(nodeId>=0 && nodeId()); - mcIdType nbOfNodesInCell(nodalI[1]-nodalI[0]-1); + mcIdType const nbOfNodesInCell(nodalI[1]-nodalI[0]-1); std::transform(dd,dd+3,dd,std::bind(std::multiplies(),std::placeholders::_1,1./(double)nbOfNodesInCell)); std::copy(dd,dd+3,matrix+4*2); INTERP_KERNEL::inverseMatrix(matrix,4,matrix2); @@ -6980,12 +7002,12 @@ MEDCouplingUMesh *MEDCouplingUMesh::Build0DMeshFromCoords(DataArrayDouble *da) if(!da) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::Build0DMeshFromCoords : instance of DataArrayDouble must be not null !"); da->checkAllocated(); - std::string name(da->getName()); + std::string const name(da->getName()); MCAuto ret(MEDCouplingUMesh::New(name,0)); if(name.empty()) ret->setName("Mesh"); ret->setCoords(da); - mcIdType nbOfTuples(da->getNumberOfTuples()); + mcIdType const nbOfTuples(da->getNumberOfTuples()); MCAuto c(DataArrayIdType::New()),cI(DataArrayIdType::New()); c->alloc(2*nbOfTuples,1); cI->alloc(nbOfTuples+1,1); @@ -7006,7 +7028,7 @@ MCAuto MEDCouplingUMesh::Build1DMeshFromCoords(DataArrayDouble if(!da) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::Build01MeshFromCoords : instance of DataArrayDouble must be not null !"); da->checkAllocated(); - std::string name(da->getName()); + std::string const name(da->getName()); MCAuto ret; { MCAuto tmp(MEDCouplingCMesh::New()); @@ -7060,7 +7082,7 @@ MEDCouplingUMesh *MEDCouplingUMesh::MergeUMeshes(const MEDCouplingUMesh *mesh1, */ MEDCouplingUMesh *MEDCouplingUMesh::MergeUMeshes(const std::vector& a) { - std::size_t sz=a.size(); + std::size_t const sz=a.size(); if(sz==0) return MergeUMeshesLL(a); for(std::size_t ii=0;iigetCoords(); - int meshDim=meshes.front()->getMeshDimension(); - std::vector::const_iterator iter=meshes.begin(); + int const meshDim=meshes.front()->getMeshDimension(); + auto iter=meshes.begin(); mcIdType meshLgth=0; mcIdType meshIndexLgth=0; for(;iter!=meshes.end();iter++) @@ -7161,8 +7183,8 @@ MEDCouplingUMesh *MEDCouplingUMesh::MergeUMeshesOnSameCoords(const std::vectorgetNodalConnectivity()->begin(); const mcIdType *index=(*iter)->getNodalConnectivityIndex()->begin(); - mcIdType nbOfCells=(*iter)->getNumberOfCells(); - mcIdType meshLgth2=(*iter)->getNodalConnectivityArrayLen(); + mcIdType const nbOfCells=(*iter)->getNumberOfCells(); + mcIdType const meshLgth2=(*iter)->getNodalConnectivityArrayLen(); nodalPtr=std::copy(nod,nod+meshLgth2,nodalPtr); if(iter!=meshes.begin()) nodalIndexPtr=std::transform(index+1,index+nbOfCells+1,nodalIndexPtr,std::bind(std::plus(),std::placeholders::_1,offset)); @@ -7208,13 +7230,13 @@ MEDCouplingUMesh *MEDCouplingUMesh::FuseUMeshesOnSameCoords(const std::vector ret=MergeUMeshesOnSameCoords(meshes); MCAuto o2n=ret->zipConnectivityTraducer(compType); corr.resize(meshes.size()); - std::size_t nbOfMeshes=meshes.size(); + std::size_t const nbOfMeshes=meshes.size(); mcIdType offset=0; const mcIdType *o2nPtr=o2n->begin(); for(std::size_t i=0;igetNumberOfCells(); + mcIdType const curNbOfCells=meshes[i]->getNumberOfCells(); tmp->alloc(curNbOfCells,1); std::copy(o2nPtr+offset,o2nPtr+offset+curNbOfCells,tmp->getPointer()); offset+=curNbOfCells; @@ -7239,12 +7261,12 @@ MEDCouplingUMesh *MEDCouplingUMesh::FuseUMeshesOnSameCoords(const std::vector& meshes) { - std::size_t sz=meshes.size(); + std::size_t const sz=meshes.size(); if(sz==0 || sz==1) return; std::vector< const DataArrayDouble * > coords(meshes.size()); - std::vector< const DataArrayDouble * >::iterator it2=coords.begin(); - for(std::vector::const_iterator it=meshes.begin();it!=meshes.end();it++,it2++) + auto it2=coords.begin(); + for(auto it=meshes.begin();it!=meshes.end();it++,it2++) { if((*it)) { @@ -7267,12 +7289,12 @@ void MEDCouplingUMesh::PutUMeshesOnSameAggregatedCoords(const std::vector res=DataArrayDouble::Aggregate(coords); - std::vector::const_iterator it=meshes.begin(); + auto it=meshes.begin(); mcIdType offset=(*it)->getNumberOfNodes(); (*it++)->setCoords(res); for(;it!=meshes.end();it++) { - mcIdType oldNumberOfNodes=(*it)->getNumberOfNodes(); + mcIdType const oldNumberOfNodes=(*it)->getNumberOfNodes(); (*it)->setCoords(res); (*it)->shiftNodeNumbersInConn(offset); offset+=oldNumberOfNodes; @@ -7296,7 +7318,7 @@ void MEDCouplingUMesh::MergeNodesOnUMeshesSharingSameCoords(const std::vector s; - for(std::vector::const_iterator it=meshes.begin();it!=meshes.end();it++) + for(auto it=meshes.begin();it!=meshes.end();it++) { if(*it) s.insert((*it)->getCoords()); @@ -7318,16 +7340,16 @@ void MEDCouplingUMesh::MergeNodesOnUMeshesSharingSameCoords(const std::vectorfindCommonTuples(eps,-1,comm,commI); MCAuto tmp1(comm),tmp2(commI); - mcIdType oldNbOfNodes=coo->getNumberOfTuples(); + mcIdType const oldNbOfNodes=coo->getNumberOfTuples(); mcIdType newNbOfNodes; MCAuto o2n=DataArrayIdType::ConvertIndexArrayToO2N(oldNbOfNodes,comm->begin(),commI->begin(),commI->end(),newNbOfNodes); if(oldNbOfNodes==newNbOfNodes) return ; - MCAuto newCoords=coo->renumberAndReduce(o2n->begin(),newNbOfNodes); - for(std::vector::const_iterator it=meshes.begin();it!=meshes.end();it++) + MCAuto const newCoords=coo->renumberAndReduce(o2n->begin(),newNbOfNodes); + for(auto meshe : meshes) { - (*it)->renumberNodesInConn(o2n->begin()); - (*it)->setCoords(newCoords); + meshe->renumberNodesInConn(o2n->begin()); + meshe->setCoords(newCoords); } } @@ -7339,7 +7361,7 @@ bool MEDCouplingUMesh::IsPolygonWellOriented(bool isQuadratic, const double *vec { std::size_t i, ip1; double v[3]={0.,0.,0.}; - std::size_t sz=std::distance(begin,end); + std::size_t const sz=std::distance(begin,end); if(!isQuadratic) for(i=0;i0.); } @@ -7382,15 +7404,15 @@ bool MEDCouplingUMesh::IsPolygonWellOriented(bool isQuadratic, const double *vec bool MEDCouplingUMesh::IsPolyhedronWellOriented(const mcIdType *begin, const mcIdType *end, const double *coords) { std::vector > edges; - std::size_t nbOfFaces=std::count(begin,end,-1)+1; + std::size_t const nbOfFaces=std::count(begin,end,-1)+1; const mcIdType *bgFace=begin; for(std::size_t i=0;i p1(bgFace[j],bgFace[(j+1)%nbOfEdgesInFace]); + std::pair const p1(bgFace[j],bgFace[(j+1)%nbOfEdgesInFace]); if(std::find(edges.begin(),edges.end(),p1)!=edges.end()) return false; edges.push_back(p1); @@ -7406,10 +7428,10 @@ bool MEDCouplingUMesh::IsPolyhedronWellOriented(const mcIdType *begin, const mcI bool MEDCouplingUMesh::Is3DExtrudedStaticCellWellOriented(const mcIdType *begin, const mcIdType *end, const double *coords) { double vec0[3],vec1[3]; - std::size_t sz=std::distance(begin,end); + std::size_t const sz=std::distance(begin,end); if(sz%2!=0) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::Is3DExtrudedStaticCellWellOriented : the length of nodal connectivity of extruded cell is not even !"); - mcIdType nbOfNodes=ToIdType(sz/2); + mcIdType const nbOfNodes=ToIdType(sz/2); INTERP_KERNEL::areaVectorOfPolygon(begin,nbOfNodes,coords,vec0); const double *pt0=coords+3*begin[0]; const double *pt1=coords+3*begin[nbOfNodes]; @@ -7419,9 +7441,9 @@ bool MEDCouplingUMesh::Is3DExtrudedStaticCellWellOriented(const mcIdType *begin, void MEDCouplingUMesh::CorrectExtrudedStaticCell(mcIdType *begin, mcIdType *end) { - std::size_t sz=std::distance(begin,end); + std::size_t const sz=std::distance(begin,end); INTERP_KERNEL::AutoPtr tmp=new mcIdType[sz]; - std::size_t nbOfNodes(sz/2); + std::size_t const nbOfNodes(sz/2); std::copy(begin,end,(mcIdType *)tmp); for(std::size_t j=1;jgetIJ(index + 1, 0) - E_Fi->getIJ(index, 0); + mcIdType const nbFaces = E_Fi->getIJ(index + 1, 0) - E_Fi->getIJ(index, 0); MCAuto v=DataArrayDouble::New(); v->alloc(nbFaces,3); double *vPtr=v->getPointer(); MCAuto p=DataArrayDouble::New(); p->alloc(nbFaces,2); @@ -7474,7 +7496,7 @@ void MEDCouplingUMesh::SimplifyPolyhedronCell(double eps, const DataArrayDouble const mcIdType *f_idx = faces->getNodalConnectivityIndex()->getPointer(), *f_cnn = faces->getNodalConnectivity()->getPointer(); for(mcIdType i=0;ibegin(), f_cnn + f_idx[face] + 1, f_cnn + f_idx[face + 1], vPtr, pPtr); // to differentiate faces going to different cells: pPtr++, *pPtr = 0; @@ -7482,7 +7504,7 @@ void MEDCouplingUMesh::SimplifyPolyhedronCell(double eps, const DataArrayDouble *pPtr += FromIdType(f_e[j]); } pPtr=p->getPointer(); vPtr=v->getPointer(); - DataArrayIdType *comm1=0,*commI1=0; + DataArrayIdType *comm1=nullptr,*commI1=nullptr; v->findCommonTuples(eps,-1,comm1,commI1); for (mcIdType i = 0; i < nbFaces; i++) if (comm1->findIdFirstEqual(i) < 0) @@ -7493,14 +7515,14 @@ void MEDCouplingUMesh::SimplifyPolyhedronCell(double eps, const DataArrayDouble MCAuto comm1Auto(comm1),commI1Auto(commI1); const mcIdType *comm1Ptr=comm1->begin(); const mcIdType *commI1Ptr=commI1->begin(); - mcIdType nbOfGrps1=commI1Auto->getNumberOfTuples()-1; + mcIdType const nbOfGrps1=commI1Auto->getNumberOfTuples()-1; res->pushBackSilent(ToIdType(INTERP_KERNEL::NORM_POLYHED)); // for(mcIdType i=0;i tmpgrp2=p->selectByTupleId(comm1Ptr+commI1Ptr[i],comm1Ptr+commI1Ptr[i+1]); - DataArrayIdType *comm2=0,*commI2=0; + DataArrayIdType *comm2=nullptr,*commI2=nullptr; tmpgrp2->findCommonTuples(eps,-1,comm2,commI2); for (mcIdType j = 0; j < commI1Ptr[i+1] - commI1Ptr[i]; j++) if (comm2->findIdFirstEqual(j) < 0) @@ -7511,18 +7533,18 @@ void MEDCouplingUMesh::SimplifyPolyhedronCell(double eps, const DataArrayDouble MCAuto comm2Auto(comm2),commI2Auto(commI2); const mcIdType *comm2Ptr=comm2->begin(); const mcIdType *commI2Ptr=commI2->begin(); - mcIdType nbOfGrps2=commI2Auto->getNumberOfTuples()-1; + mcIdType const nbOfGrps2=commI2Auto->getNumberOfTuples()-1; for(mcIdType j=0;jinsertAtTheEnd(f_cnn + f_idx[face] + 1, f_cnn + f_idx[face + 1]); res->pushBackSilent(-1); } else { - mcIdType pointId=comm1Ptr[commI1Ptr[i]+comm2Ptr[commI2Ptr[j]]]; + mcIdType const pointId=comm1Ptr[commI1Ptr[i]+comm2Ptr[commI2Ptr[j]]]; MCAuto ids2=comm2->selectByTupleIdSafeSlice(commI2Ptr[j],commI2Ptr[j+1],1); ids2->transformWithIndArr(comm1Ptr+commI1Ptr[i],comm1Ptr+commI1Ptr[i+1]); ids2->transformWithIndArr(e_f + e_fi[index], e_f + e_fi[index + 1]); @@ -7532,17 +7554,17 @@ void MEDCouplingUMesh::SimplifyPolyhedronCell(double eps, const DataArrayDouble const mcIdType *idsNodePtr=idsNode->begin(); double center[3]; center[0]=pPtr[2*pointId]*vPtr[3*vecId]; center[1]=pPtr[2*pointId]*vPtr[3*vecId+1]; center[2]=pPtr[2*pointId]*vPtr[3*vecId+2]; double vec[3]; vec[0]=vPtr[3*vecId+1]; vec[1]=-vPtr[3*vecId]; vec[2]=0.; - double norm=vec[0]*vec[0]+vec[1]*vec[1]+vec[2]*vec[2]; + double const norm=vec[0]*vec[0]+vec[1]*vec[1]+vec[2]*vec[2]; if(std::abs(norm)>eps) { - double angle=INTERP_KERNEL::EdgeArcCircle::SafeAsin(norm); + double const angle=INTERP_KERNEL::EdgeArcCircle::SafeAsin(norm); mm3->rotate(center,vec,angle); } mm3->changeSpaceDimension(2); MCAuto mm4=mm3->buildSpreadZonesWithPoly(); const mcIdType *conn4=mm4->getNodalConnectivity()->begin(); const mcIdType *connI4=mm4->getNodalConnectivityIndex()->begin(); - mcIdType nbOfCells=mm4->getNumberOfCells(); + mcIdType const nbOfCells=mm4->getNumberOfCells(); for(mcIdType k=0;keps) { refFound=true; @@ -7616,12 +7638,12 @@ void MEDCouplingUMesh::ComputeVecAndPtOfFace(double eps, const double *coords, c void MEDCouplingUMesh::TryToCorrectPolyhedronOrientation(mcIdType *begin, mcIdType *end, const double *coords) { std::list< std::pair > edgesOK,edgesFinished; - std::size_t nbOfFaces=std::count(begin,end,-1)+1; + std::size_t const nbOfFaces=std::count(begin,end,-1)+1; std::vector isPerm(nbOfFaces,false);//field on faces False: I don't know, True : oriented isPerm[0]=true; mcIdType *bgFace=begin,*endFace=std::find(begin+1,end,-1); std::size_t nbOfEdgesInFace=std::distance(bgFace,endFace); - for(std::size_t l=0;l p1(bgFace[l],bgFace[(l+1)%nbOfEdgesInFace]); edgesOK.push_back(p1); } + for(std::size_t l=0;l const p1(bgFace[l],bgFace[(l+1)%nbOfEdgesInFace]); edgesOK.push_back(p1); } // while(std::find(isPerm.begin(),isPerm.end(),false)!=isPerm.end()) { @@ -7636,10 +7658,10 @@ void MEDCouplingUMesh::TryToCorrectPolyhedronOrientation(mcIdType *begin, mcIdTy bool b=false; for(std::size_t j=0;j p1(bgFace[j],bgFace[(j+1)%nbOfEdgesInFace]); - std::pair p2(p1.second,p1.first); - bool b1=std::find(edgesOK.begin(),edgesOK.end(),p1)!=edgesOK.end(); - bool b2=std::find(edgesOK.begin(),edgesOK.end(),p2)!=edgesOK.end(); + std::pair const p1(bgFace[j],bgFace[(j+1)%nbOfEdgesInFace]); + std::pair const p2(p1.second,p1.first); + bool const b1=std::find(edgesOK.begin(),edgesOK.end(),p1)!=edgesOK.end(); + bool const b2=std::find(edgesOK.begin(),edgesOK.end(),p2)!=edgesOK.end(); if(b1 || b2) { b=b2; isPerm[i]=true; smthChanged++; break; } } if(isPerm[i]) @@ -7648,13 +7670,13 @@ void MEDCouplingUMesh::TryToCorrectPolyhedronOrientation(mcIdType *begin, mcIdTy std::reverse(bgFace+1,endFace); for(std::size_t j=0;j p1(bgFace[j],bgFace[(j+1)%nbOfEdgesInFace]); - std::pair p2(p1.second,p1.first); + std::pair const p1(bgFace[j],bgFace[(j+1)%nbOfEdgesInFace]); + std::pair const p2(p1.second,p1.first); if(std::find(edgesOK.begin(),edgesOK.end(),p1)!=edgesOK.end()) { std::ostringstream oss; oss << "Face #" << j << " of polyhedron looks bad !"; throw INTERP_KERNEL::Exception(oss.str()); } if(std::find(edgesFinished.begin(),edgesFinished.end(),p1)!=edgesFinished.end() || std::find(edgesFinished.begin(),edgesFinished.end(),p2)!=edgesFinished.end()) { std::ostringstream oss; oss << "Face #" << j << " of polyhedron looks bad !"; throw INTERP_KERNEL::Exception(oss.str()); } - std::list< std::pair >::iterator it=std::find(edgesOK.begin(),edgesOK.end(),p2); + auto const it=std::find(edgesOK.begin(),edgesOK.end(),p2); if(it!=edgesOK.end()) { edgesOK.erase(it); @@ -7696,11 +7718,11 @@ DataArrayIdType *MEDCouplingUMesh::buildUnionOf2DMesh() const if(getMeshDimension()!=2 || getSpaceDimension()!=2) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::buildUnionOf2DMesh : meshdimension, spacedimension must be equal to 2 !"); MCAuto skin(computeSkin()); - mcIdType oldNbOfNodes(skin->getNumberOfNodes()); + mcIdType const oldNbOfNodes(skin->getNumberOfNodes()); MCAuto o2n(skin->zipCoordsTraducer()); - mcIdType nbOfNodesExpected(skin->getNumberOfNodes()); + mcIdType const nbOfNodesExpected(skin->getNumberOfNodes()); MCAuto n2o(o2n->invertArrayO2N2N2O(oldNbOfNodes)); - mcIdType nbCells=skin->getNumberOfCells(); + mcIdType const nbCells=skin->getNumberOfCells(); if(nbCells==nbOfNodesExpected) return buildUnionOf2DMeshLinear(skin,n2o); else if(2*nbCells==nbOfNodesExpected) @@ -7722,7 +7744,7 @@ DataArrayIdType *MEDCouplingUMesh::buildUnionOf3DMesh() const MCAuto m=computeSkin(); const mcIdType *conn=m->getNodalConnectivity()->begin(); const mcIdType *connI=m->getNodalConnectivityIndex()->begin(); - mcIdType nbOfCells=m->getNumberOfCells(); + mcIdType const nbOfCells=m->getNumberOfCells(); MCAuto ret=DataArrayIdType::New(); ret->alloc(m->getNodalConnectivity()->getNumberOfTuples(),1); mcIdType *work=ret->getPointer(); *work++=INTERP_KERNEL::NORM_POLYHED; if(nbOfCells<1) @@ -7750,7 +7772,7 @@ MEDCouplingSkyLineArray* MEDCouplingUMesh::generateGraph() const { checkConnectivityFullyDefined(); - int meshDim = this->getMeshDimension(); + int const meshDim = this->getMeshDimension(); MEDCoupling::DataArrayIdType* indexr=MEDCoupling::DataArrayIdType::New(); MEDCoupling::DataArrayIdType* revConn=MEDCoupling::DataArrayIdType::New(); this->getReverseNodalConnectivity(revConn,indexr); @@ -7761,7 +7783,7 @@ MEDCouplingSkyLineArray* MEDCouplingUMesh::generateGraph() const const MEDCoupling::DataArrayIdType* conn; conn=this->getNodalConnectivity(); // it includes a type as the 1st element!!! index=this->getNodalConnectivityIndex(); - mcIdType nbCells=this->getNumberOfCells(); + mcIdType const nbCells=this->getNumberOfCells(); const mcIdType* index_ptr=index->begin(); const mcIdType* conn_ptr=conn->begin(); @@ -7784,11 +7806,11 @@ MEDCouplingSkyLineArray* MEDCouplingUMesh::generateGraph() const std::map counter; for (mcIdType iconn=index_ptr[icell]+1; iconn::iterator iter=counter.find(icell2); + mcIdType const icell2=revConn_ptr[iconnr]; + auto const iter=counter.find(icell2); if (iter!=counter.end()) (iter->second)++; else counter.insert(std::make_pair(icell2,1)); } @@ -7815,7 +7837,7 @@ MEDCouplingSkyLineArray* MEDCouplingUMesh::generateGraph() const void MEDCouplingUMesh::writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData, DataArrayByte *byteData) const { - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbOfCells=getNumberOfCells(); if(nbOfCells<=0) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::writeVTK : the unstructured mesh has no cells !"); ofs << " <" << getVTKDataSetType() << ">\n"; @@ -7853,19 +7875,19 @@ void MEDCouplingUMesh::writeVTKLL(std::ostream& ofs, const std::string& cellData } else { - mcIdType deltaFaceOffset=cIPtr[i+1]-cIPtr[i]+1; + mcIdType const deltaFaceOffset=cIPtr[i+1]-cIPtr[i]+1; *w1=szFaceOffsets+deltaFaceOffset; szFaceOffsets+=deltaFaceOffset; std::set c(cPtr+cIPtr[i]+1,cPtr+cIPtr[i+1]); c.erase(-1); *w3=szConn+ToIdType(c.size()); szConn+=ToIdType(c.size()); w4=std::copy(c.begin(),c.end(),w4); } } - std::unique_ptr medcoupling2vtkTypeTraducer_mcIdType(new mcIdType[MEDCOUPLING2VTKTYPETRADUCER_LGTH]); + std::unique_ptr const medcoupling2vtkTypeTraducer_mcIdType(new mcIdType[MEDCOUPLING2VTKTYPETRADUCER_LGTH]); for(auto ii = 0; iitransformWithIndArr(medcoupling2vtkTypeTraducer_mcIdType.get(),medcoupling2vtkTypeTraducer_mcIdType.get()+MEDCOUPLING2VTKTYPETRADUCER_LGTH); types->writeVTK(ofs,8,"UInt8","types",byteData); - std::string vtkTypeName = Traits::VTKReprStr; + std::string const vtkTypeName = Traits::VTKReprStr; offsets->writeVTK(ofs,8,vtkTypeName,"offsets",byteData); if(szFaceOffsets!=0) {//presence of Polyhedra @@ -7876,9 +7898,9 @@ void MEDCouplingUMesh::writeVTKLL(std::ostream& ofs, const std::string& cellData for(mcIdType i=0;iisAllocated()) { stream << std::endl << "Nodal connectivity set but not allocated !"; return ; } - mcIdType lgth=_nodal_connec_index->getNumberOfTuples(); - std::size_t cpt=_nodal_connec_index->getNumberOfComponents(); + mcIdType const lgth=_nodal_connec_index->getNumberOfTuples(); + std::size_t const cpt=_nodal_connec_index->getNumberOfComponents(); if(cpt!=1 || lgth<1) return ; stream << std::endl << "Number of cells : " << lgth-1 << "."; @@ -7959,11 +7981,11 @@ DataArrayIdType *MEDCouplingUMesh::orderConsecutiveCells1D() const MCAuto _dsi(_rDI->deltaShiftIndex()); const mcIdType * dsi(_dsi->begin()); MCAuto dsii = _dsi->findIdsNotInRange(0,3); - m_points=0; + m_points=nullptr; if (dsii->getNumberOfTuples()) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::orderConsecutiveCells1D only work with a mesh being a (piecewise) connected line!"); - mcIdType nc=getNumberOfCells(); + mcIdType const nc=getNumberOfCells(); MCAuto result(DataArrayIdType::New()); result->alloc(nc,1); @@ -8005,7 +8027,7 @@ DataArrayIdType *MEDCouplingUMesh::orderConsecutiveCells1D() const activeSeg = (seg1 == activeSeg) ? seg2 : seg1; //for piecewise meshes made up of closed parts - bool segmentAlreadyTreated = (std::find(linePiece.begin(), linePiece.end(), activeSeg) != linePiece.end()); + bool const segmentAlreadyTreated = (std::find(linePiece.begin(), linePiece.end(), activeSeg) != linePiece.end()); if(segmentAlreadyTreated) break; } @@ -8048,12 +8070,12 @@ mcIdType MEDCouplingUMesh::split2DCells(const DataArrayIdType *desc, const DataA desc->checkAllocated(); descI->checkAllocated(); subNodesInSeg->checkAllocated(); subNodesInSegI->checkAllocated(); if(getSpaceDimension()!=2 || getMeshDimension()!=2) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::split2DCells : This method only works for meshes with spaceDim=2 and meshDim=2 !"); - if(midOpt==0 && midOptI==0) + if(midOpt==nullptr && midOptI==nullptr) { split2DCellsLinear(desc,descI,subNodesInSeg,subNodesInSegI); return 0; } - else if(midOpt!=0 && midOptI!=0) + else if(midOpt!=nullptr && midOptI!=nullptr) return split2DCellsQuadratic(desc,descI,subNodesInSeg,subNodesInSegI,midOpt,midOptI); else throw INTERP_KERNEL::Exception("MEDCouplingUMesh::split2DCells : middle parameters must be set to null for all or not null for all."); @@ -8070,7 +8092,7 @@ mcIdType MEDCouplingUMesh::split2DCells(const DataArrayIdType *desc, const DataA */ bool MEDCouplingUMesh::BuildConvexEnvelopOf2DCellJarvis(const double *coords, const mcIdType *nodalConnBg, const mcIdType *nodalConnEnd, DataArrayIdType *nodalConnecOut) { - std::size_t sz=std::distance(nodalConnBg,nodalConnEnd); + std::size_t const sz=std::distance(nodalConnBg,nodalConnEnd); if(sz>=4) { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel((INTERP_KERNEL::NormalizedCellType)*nodalConnBg); @@ -8106,7 +8128,7 @@ bool MEDCouplingUMesh::BuildConvexEnvelopOf2DCellJarvis(const double *coords, co if(*node!=tmpOut.back() && *node!=prevNode) { tmp2[0]=coords[2*(*node)]-coords[2*tmpOut.back()]; tmp2[1]=coords[2*(*node)+1]-coords[2*tmpOut.back()+1]; - double angleM=INTERP_KERNEL::EdgeArcCircle::GetAbsoluteAngle(tmp2,tmp1); + double const angleM=INTERP_KERNEL::EdgeArcCircle::GetAbsoluteAngle(tmp2,tmp1); double res; if(angleM<=angle0) res=angle0-angleM; @@ -8130,7 +8152,7 @@ bool MEDCouplingUMesh::BuildConvexEnvelopOf2DCellJarvis(const double *coords, co } } std::vector tmp3(2*(sz-1)); - std::vector::iterator it=std::copy(nodalConnBg+1,nodalConnEnd,tmp3.begin()); + auto const it=std::copy(nodalConnBg+1,nodalConnEnd,tmp3.begin()); std::copy(nodalConnBg+1,nodalConnEnd,it); if(std::search(tmp3.begin(),tmp3.end(),tmpOut.begin(),tmpOut.end())!=tmp3.end()) { @@ -8196,7 +8218,7 @@ DataArrayIdType *MEDCouplingUMesh::ComputeSpreadZoneGraduallyFromSeed(const mcId nbOfDepthPeelingPerformed=0; if(!arrIndxIn) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::ComputeSpreadZoneGraduallyFromSeed : arrIndxIn input pointer is NULL !"); - mcIdType nbOfTuples=arrIndxIn->getNumberOfTuples()-1; + mcIdType const nbOfTuples=arrIndxIn->getNumberOfTuples()-1; if(nbOfTuples<=0) { DataArrayIdType *ret=DataArrayIdType::New(); ret->alloc(0,1); @@ -8221,8 +8243,8 @@ DataArrayIdType *MEDCouplingUMesh::ComputeSpreadZoneGraduallyFromSeed(const mcId MEDCouplingUMesh *MEDCouplingUMesh::buildSpreadZonesWithPoly() const { checkFullyDefined(); - int mdim=getMeshDimension(); - int spaceDim=getSpaceDimension(); + int const mdim=getMeshDimension(); + int const spaceDim=getSpaceDimension(); if(mdim!=spaceDim) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::buildSpreadZonesWithPoly : meshdimension and spacedimension do not match !"); std::vector partition=partitionBySpreadZone(); @@ -8232,9 +8254,9 @@ MEDCouplingUMesh *MEDCouplingUMesh::buildSpreadZonesWithPoly() const ret->setCoords(getCoords()); ret->allocateCells(ToIdType(partition.size())); // - for(std::vector::const_iterator it=partition.begin();it!=partition.end();it++) + for(auto it : partition) { - MCAuto tmp=static_cast(buildPartOfMySelf((*it)->begin(),(*it)->end(),true)); + MCAuto tmp=static_cast(buildPartOfMySelf(it->begin(),it->end(),true)); MCAuto cell; switch(mdim) { @@ -8262,7 +8284,7 @@ MEDCouplingUMesh *MEDCouplingUMesh::buildSpreadZonesWithPoly() const */ std::vector MEDCouplingUMesh::partitionBySpreadZone() const { - DataArrayIdType *neigh=0,*neighI=0; + DataArrayIdType *neigh=nullptr,*neighI=nullptr; computeNeighborsOfCells(neigh,neighI); MCAuto neighAuto(neigh),neighIAuto(neighI); return PartitionBySpreadZone(neighAuto,neighIAuto); @@ -8273,10 +8295,10 @@ std::vector MEDCouplingUMesh::PartitionBySpreadZone(const Dat if(!arrIn || !arrIndxIn) throw INTERP_KERNEL::Exception("PartitionBySpreadZone : null input pointers !"); arrIn->checkAllocated(); arrIndxIn->checkAllocated(); - mcIdType nbOfTuples(arrIndxIn->getNumberOfTuples()); + mcIdType const nbOfTuples(arrIndxIn->getNumberOfTuples()); if(arrIn->getNumberOfComponents()!=1 || arrIndxIn->getNumberOfComponents()!=1 || nbOfTuples<1) throw INTERP_KERNEL::Exception("PartitionBySpreadZone : invalid arrays in input !"); - mcIdType nbOfCellsCur(nbOfTuples-1); + mcIdType const nbOfCellsCur(nbOfTuples-1); std::vector ret; if(nbOfCellsCur<=0) return ret; @@ -8289,8 +8311,8 @@ std::vector MEDCouplingUMesh::PartitionBySpreadZone(const Dat ret2.push_back(ComputeSpreadZoneGraduallyFromSeedAlg(fetchedCells,&seed,&seed+1,arrIn,arrIndxIn,-1,nbOfPeelPerformed)); seed=ToIdType(std::distance(fetchedCells.begin(),std::find(fetchedCells.begin()+seed,fetchedCells.end(),false))); } - for(std::vector< MCAuto >::iterator it=ret2.begin();it!=ret2.end();it++) - ret.push_back((*it).retn()); + for(auto & it : ret2) + ret.push_back(it.retn()); return ret; } @@ -8305,7 +8327,7 @@ std::vector MEDCouplingUMesh::PartitionBySpreadZone(const Dat DataArrayIdType *MEDCouplingUMesh::ComputeRangesFromTypeDistribution(const std::vector& code) { MCAuto ret=DataArrayIdType::New(); - std::size_t nb=code.size()/3; + std::size_t const nb=code.size()/3; if(code.size()%3!=0) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::ComputeRangesFromTypeDistribution : invalid input code !"); ret->alloc(nb,2); @@ -8344,11 +8366,11 @@ DataArrayIdType *MEDCouplingUMesh::ComputeRangesFromTypeDistribution(const std:: */ MEDCoupling1SGTUMesh *MEDCouplingUMesh::tetrahedrize(int policy, DataArrayIdType *& n2oCells, mcIdType& nbOfAdditionalPoints) const { - INTERP_KERNEL::SplittingPolicy pol((INTERP_KERNEL::SplittingPolicy)policy); + auto const pol((INTERP_KERNEL::SplittingPolicy)policy); checkConnectivityFullyDefined(); if(getMeshDimension()!=3 || getSpaceDimension()!=3) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::tetrahedrize : only available for mesh with meshdim == 3 and spacedim == 3 !"); - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbOfCells=getNumberOfCells(); mcIdType nbNodes(getNumberOfNodes()); MCAuto ret0(MEDCoupling1SGTUMesh::New(getName(),INTERP_KERNEL::NORM_TETRA4)); MCAuto ret(DataArrayIdType::New()); ret->alloc(nbOfCells,1); @@ -8362,13 +8384,13 @@ MEDCoupling1SGTUMesh *MEDCouplingUMesh::tetrahedrize(int policy, DataArrayIdType { std::vector a; std::vector b; INTERP_KERNEL::SplitIntoTetras(pol,(INTERP_KERNEL::NormalizedCellType)oldc[oldci[0]],oldc+oldci[0]+1,oldc+oldci[1],coords,a,b); - std::size_t nbOfTet(a.size()/4); *retPt=ToIdType(nbOfTet); + std::size_t const nbOfTet(a.size()/4); *retPt=ToIdType(nbOfTet); const mcIdType *aa(&a[0]); if(!b.empty()) { - for(std::vector::iterator it=a.begin();it!=a.end();it++) - if(*it<0) - *it=(-(*(it))-1+nbNodes); + for(long & it : a) + if(it<0) + it=(-it-1+nbNodes); addPts->insertAtTheEnd(b.begin(),b.end()); nbNodes+=ToIdType(b.size()/3); } @@ -8429,7 +8451,7 @@ MEDCouplingUMeshCell *MEDCouplingUMeshCellIterator::nextt() return _cell; } else - return 0; + return nullptr; } MEDCouplingUMeshCellByTypeEntry::MEDCouplingUMeshCellByTypeEntry(MEDCouplingUMesh *mesh):_mesh(mesh) @@ -8500,17 +8522,17 @@ MEDCouplingUMeshCellEntry *MEDCouplingUMeshCellByTypeIterator::nextt() const mcIdType *ci=_mesh->getNodalConnectivityIndex()->begin(); if(_cell_id<_nb_cell) { - INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)c[ci[_cell_id]]; - mcIdType nbOfElems=ToIdType(std::distance(ci+_cell_id,std::find_if(ci+_cell_id,ci+_nb_cell,MEDCouplingImpl::ConnReader(c,type)))); - mcIdType startId=_cell_id; + auto const type=(INTERP_KERNEL::NormalizedCellType)c[ci[_cell_id]]; + mcIdType const nbOfElems=ToIdType(std::distance(ci+_cell_id,std::find_if(ci+_cell_id,ci+_nb_cell,MEDCouplingImpl::ConnReader(c,type)))); + mcIdType const startId=_cell_id; _cell_id+=nbOfElems; return new MEDCouplingUMeshCellEntry(_mesh,type,_cell,startId,_cell_id); } else - return 0; + return nullptr; } -MEDCouplingUMeshCell::MEDCouplingUMeshCell(MEDCouplingUMesh *mesh):_conn(0),_conn_indx(0),_conn_lgth(NOTICABLE_FIRST_VAL) +MEDCouplingUMeshCell::MEDCouplingUMeshCell(MEDCouplingUMesh *mesh):_conn(nullptr),_conn_indx(nullptr),_conn_lgth(NOTICABLE_FIRST_VAL) { if(mesh) { @@ -8556,7 +8578,7 @@ const mcIdType *MEDCouplingUMeshCell::getAllConn(mcIdType& lgth) const if(_conn_lgth!=NOTICABLE_FIRST_VAL) return _conn; else - return 0; + return nullptr; } /// @cond INTERNAL @@ -8625,8 +8647,8 @@ namespace MEDCouplingImpl const mcIdType * revInd = revNodalIndx[ iM ]->begin(); const mcIdType * rev = revNodal [ iM ]->begin(); - mcIdType nbRevFaces0 = revInd[ n0 + 1 ] - revInd[ n0 ]; - mcIdType nbRevFaces1 = revInd[ n1 + 1 ] - revInd[ n1 ]; + mcIdType const nbRevFaces0 = revInd[ n0 + 1 ] - revInd[ n0 ]; + mcIdType const nbRevFaces1 = revInd[ n1 + 1 ] - revInd[ n1 ]; prevNbF = facesByEdge.size(); facesByEdge.resize( prevNbF + std::max( nbRevFaces0, nbRevFaces1 )); @@ -8656,7 +8678,7 @@ namespace MEDCouplingImpl { if ( facesByEdge[ i0 ] == theUndefID ) continue; - mcIdType objFaceID = MEDCouplingImpl::encodeID( facesByEdge[ i0 ], 0 ); + mcIdType const objFaceID = MEDCouplingImpl::encodeID( facesByEdge[ i0 ], 0 ); bool isInputFace = ( objFaceID == inputFaceID ); for ( size_t i1 = prevNbF; i1 < facesByEdge.size(); ++i1 ) @@ -8664,10 +8686,10 @@ namespace MEDCouplingImpl if ( facesByEdge[ i1 ] == theUndefID ) continue; - mcIdType f0 = facesByEdge[ i0 ]; - mcIdType f1 = facesByEdge[ i1 ]; - size_t nbNodes0 = connI[0][ f0 + 1 ] - connI[0][ f0 ] - 1; - size_t nbNodes1 = connI[1][ f1 + 1 ] - connI[1][ f1 ] - 1; + mcIdType const f0 = facesByEdge[ i0 ]; + mcIdType const f1 = facesByEdge[ i1 ]; + size_t const nbNodes0 = connI[0][ f0 + 1 ] - connI[0][ f0 ] - 1; + size_t const nbNodes1 = connI[1][ f1 + 1 ] - connI[1][ f1 ] - 1; if ( nbNodes0 != nbNodes1 ) continue; @@ -8676,7 +8698,7 @@ namespace MEDCouplingImpl if ( std::equal( fConn0, fConn0 + nbNodes0, fConn1 )) { // equal faces; remove an object one - mcIdType refFaceID = MEDCouplingImpl::encodeID( facesByEdge[ i1 ], 1 ); + mcIdType const refFaceID = MEDCouplingImpl::encodeID( facesByEdge[ i1 ], 1 ); if ( refFaceID == inputFaceID ) isInputFace = true; @@ -8775,7 +8797,7 @@ namespace MEDCouplingImpl MEDCouplingUMesh* mesh[] ) { int iMesh; - mcIdType iF = decodeID( iFEnc, iMesh ); + mcIdType const iF = decodeID( iFEnc, iMesh ); const mcIdType *conn = mesh[ iMesh ]->getNodalConnectivity()->getConstPointer(); const mcIdType *connI = mesh[ iMesh ]->getNodalConnectivityIndex()->getConstPointer(); @@ -8786,10 +8808,10 @@ namespace MEDCouplingImpl auto it1 = std::find( conn + connI[ iF ] + 1, conn + connI[ iF + 1 ], n1 ); - long i0 = it0 - conn; - long i1 = it1 - conn; + long const i0 = it0 - conn; + long const i1 = it1 - conn; - bool isRev = ( std::abs( i1 - i0 ) == 1 ) ? i1 < i0 : i0 < i1; + bool const isRev = ( std::abs( i1 - i0 ) == 1 ) ? i1 < i0 : i0 < i1; return isRev; } @@ -8804,7 +8826,7 @@ namespace MEDCouplingImpl void reverseFace( mcIdType iFEnc, MEDCouplingUMesh* mesh[] ) { int iMesh; - mcIdType face = decodeID( iFEnc, iMesh ); + mcIdType const face = decodeID( iFEnc, iMesh ); mcIdType *conn = mesh[ iMesh ]->getNodalConnectivity()->getPointer(); mcIdType *connI = mesh[ iMesh ]->getNodalConnectivityIndex()->getPointer(); @@ -8900,11 +8922,11 @@ void MEDCouplingUMesh::orientCorrectly2DCells(const MEDCouplingUMesh* refFaces) break; } - mcIdType fID = faceQueue.back(); + mcIdType const fID = faceQueue.back(); faceQueue.pop_back(); int iMesh, iMesh2; - mcIdType refFace = MEDCouplingImpl::decodeID( fID, iMesh ); + mcIdType const refFace = MEDCouplingImpl::decodeID( fID, iMesh ); nbFacesToCheck[iMesh]--; @@ -8918,7 +8940,7 @@ void MEDCouplingUMesh::orientCorrectly2DCells(const MEDCouplingUMesh* refFaces) mcIdType n0 = faceNodes[ nbEdges - 1 ]; // 1st node of edge for ( int edge = 0; edge < nbEdges; ++edge ) { - mcIdType n1 = faceNodes[ edge ]; // 2nd node of edge + mcIdType const n1 = faceNodes[ edge ]; // 2nd node of edge // get faces sharing the edge MEDCouplingImpl::getFacesOfEdge( n0, n1, fID, mesh, revNodal, revNodalIndx, @@ -8938,7 +8960,7 @@ void MEDCouplingUMesh::orientCorrectly2DCells(const MEDCouplingUMesh* refFaces) MEDCouplingImpl::reverseFace( facesByEdge[0], mesh ); } - mcIdType face2 = MEDCouplingImpl::decodeID( facesByEdge[0], iMesh2 ); + mcIdType const face2 = MEDCouplingImpl::decodeID( facesByEdge[0], iMesh2 ); if ( !isFaceQueued[iMesh2][face2] ) { isFaceQueued[iMesh2][face2] = true; @@ -8950,12 +8972,12 @@ void MEDCouplingUMesh::orientCorrectly2DCells(const MEDCouplingUMesh* refFaces) // remove face and equalFaces from revNodal in order not to treat them again equalFaces.push_back( fID ); - for ( mcIdType face : equalFaces ) + for ( mcIdType const face : equalFaces ) { - mcIdType f = MEDCouplingImpl::decodeID( face, iMesh2 ); + mcIdType const f = MEDCouplingImpl::decodeID( face, iMesh2 ); const mcIdType *conn = mesh[iMesh2]->getNodalConnectivity()->getConstPointer(); const mcIdType *connI = mesh[iMesh2]->getNodalConnectivityIndex()->getConstPointer(); - mcIdType nbNodes = connI[ f + 1 ] - connI[ f ] - 1; + mcIdType const nbNodes = connI[ f + 1 ] - connI[ f ] - 1; for ( const mcIdType* n = conn + connI[ f ] + 1, *nEnd = n + nbNodes; n < nEnd; ++n ) MEDCouplingImpl::removeFromRevNodal( *n, f, // not to treat f again diff --git a/src/MEDCoupling/MEDCouplingUMesh.hxx b/src/MEDCoupling/MEDCouplingUMesh.hxx index ca5612fa8..804a9c99d 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.hxx +++ b/src/MEDCoupling/MEDCouplingUMesh.hxx @@ -20,13 +20,28 @@ #pragma once +#include "MCType.hxx" +#include "MCAuto.hxx" +#include "InterpKernelHashMap.hxx" #include "MEDCoupling.hxx" +#include "MEDCouplingMesh.hxx" #include "MEDCouplingPointSet.hxx" #include "MEDCouplingMemArray.hxx" #include "CellModel.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include "NormalizedGeometricTypes" +#include +#include +#include +#include +#include #include +#include +#include +#include +#include namespace MEDCoupling { @@ -43,20 +58,20 @@ namespace MEDCoupling MEDCOUPLING_EXPORT static MEDCouplingUMesh *New(const std::string& meshName, int meshDim); MEDCOUPLING_EXPORT std::string getClassName() const override { return std::string("MEDCouplingUMesh"); } // Copy methods - MEDCOUPLING_EXPORT MEDCouplingUMesh *deepCopy() const; - MEDCOUPLING_EXPORT MEDCouplingUMesh *clone(bool recDeepCpy) const; - MEDCOUPLING_EXPORT MEDCouplingUMesh *deepCopyConnectivityOnly() const; + MEDCOUPLING_EXPORT MEDCouplingUMesh *deepCopy() const override; + MEDCOUPLING_EXPORT MEDCouplingUMesh *clone(bool recDeepCpy) const override; + MEDCOUPLING_EXPORT MEDCouplingUMesh *deepCopyConnectivityOnly() const override; - MEDCOUPLING_EXPORT void shallowCopyConnectivityFrom(const MEDCouplingPointSet *other); - MEDCOUPLING_EXPORT void updateTime() const; - MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; - MEDCOUPLING_EXPORT std::vector getDirectChildrenWithNull() const; - MEDCOUPLING_EXPORT MEDCouplingMeshType getType() const { return UNSTRUCTURED; } - MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const; - MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const; - MEDCOUPLING_EXPORT void checkFastEquivalWith(const MEDCouplingMesh *other, double prec) const; - MEDCOUPLING_EXPORT void checkConsistencyLight() const; - MEDCOUPLING_EXPORT void checkConsistency(double eps=1e-12) const; + MEDCOUPLING_EXPORT void shallowCopyConnectivityFrom(const MEDCouplingPointSet *other) override; + MEDCOUPLING_EXPORT void updateTime() const override; + MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const override; + MEDCOUPLING_EXPORT std::vector getDirectChildrenWithNull() const override; + MEDCOUPLING_EXPORT MEDCouplingMeshType getType() const override { return UNSTRUCTURED; } + MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const override; + MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const override; + MEDCOUPLING_EXPORT void checkFastEquivalWith(const MEDCouplingMesh *other, double prec) const override; + MEDCOUPLING_EXPORT void checkConsistencyLight() const override; + MEDCOUPLING_EXPORT void checkConsistency(double eps=1e-12) const override; MEDCOUPLING_EXPORT void checkGeomConsistency(double eps=1e-12) const; MEDCOUPLING_EXPORT void setMeshDimension(int meshDim); MEDCOUPLING_EXPORT void allocateCells(mcIdType nbOfCells=0); @@ -64,7 +79,7 @@ namespace MEDCoupling MEDCOUPLING_EXPORT void finishInsertingCells(); MEDCOUPLING_EXPORT MEDCouplingUMeshCellIterator *cellIterator(); MEDCOUPLING_EXPORT MEDCouplingUMeshCellByTypeEntry *cellsByType(); - MEDCOUPLING_EXPORT std::set getAllGeoTypes() const; + MEDCOUPLING_EXPORT std::set getAllGeoTypes() const override; MEDCOUPLING_EXPORT std::vector getAllGeoTypesSorted() const; MEDCOUPLING_EXPORT std::set getTypesOfPart(const mcIdType *begin, const mcIdType *end) const; MEDCOUPLING_EXPORT void setConnectivity(DataArrayIdType *conn, DataArrayIdType *connIndex, bool isComputingTypes=true); @@ -72,30 +87,30 @@ namespace MEDCoupling MEDCOUPLING_EXPORT const DataArrayIdType *getNodalConnectivityIndex() const { return _nodal_connec_index; } MEDCOUPLING_EXPORT DataArrayIdType *getNodalConnectivity() { return _nodal_connec; } MEDCOUPLING_EXPORT DataArrayIdType *getNodalConnectivityIndex() { return _nodal_connec_index; } - MEDCOUPLING_EXPORT INTERP_KERNEL::NormalizedCellType getTypeOfCell(mcIdType cellId) const; - MEDCOUPLING_EXPORT DataArrayIdType *giveCellsWithType(INTERP_KERNEL::NormalizedCellType type) const; - MEDCOUPLING_EXPORT mcIdType getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const; - MEDCOUPLING_EXPORT void getNodeIdsOfCell(mcIdType cellId, std::vector& conn) const; - MEDCOUPLING_EXPORT std::string simpleRepr() const; - MEDCOUPLING_EXPORT std::string advancedRepr() const; + MEDCOUPLING_EXPORT INTERP_KERNEL::NormalizedCellType getTypeOfCell(mcIdType cellId) const override; + MEDCOUPLING_EXPORT DataArrayIdType *giveCellsWithType(INTERP_KERNEL::NormalizedCellType type) const override; + MEDCOUPLING_EXPORT mcIdType getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const override; + MEDCOUPLING_EXPORT void getNodeIdsOfCell(mcIdType cellId, std::vector& conn) const override; + MEDCOUPLING_EXPORT std::string simpleRepr() const override; + MEDCOUPLING_EXPORT std::string advancedRepr() const override; MEDCOUPLING_EXPORT std::string cppRepr() const; MEDCOUPLING_EXPORT std::string reprConnectivityOfThis() const; MEDCOUPLING_EXPORT MEDCouplingUMesh *buildSetInstanceFromThis(std::size_t spaceDim) const; - MEDCOUPLING_EXPORT mcIdType getNumberOfNodesInCell(mcIdType cellId) const; - MEDCOUPLING_EXPORT mcIdType getNumberOfCells() const; - MEDCOUPLING_EXPORT int getMeshDimension() const; + MEDCOUPLING_EXPORT mcIdType getNumberOfNodesInCell(mcIdType cellId) const override; + MEDCOUPLING_EXPORT mcIdType getNumberOfCells() const override; + MEDCOUPLING_EXPORT int getMeshDimension() const override; MEDCOUPLING_EXPORT mcIdType getNodalConnectivityArrayLen() const; MEDCOUPLING_EXPORT void computeTypes(); //! size of returned tinyInfo must be always the same. - MEDCOUPLING_EXPORT void getTinySerializationInformation(std::vector& tinyInfoD, std::vector& tinyInfo, std::vector& littleStrings) const; - MEDCOUPLING_EXPORT bool isEmptyMesh(const std::vector& tinyInfo) const; - MEDCOUPLING_EXPORT void resizeForUnserialization(const std::vector& tinyInfo, DataArrayIdType *a1, DataArrayDouble *a2, std::vector& littleStrings) const; - MEDCOUPLING_EXPORT void serialize(DataArrayIdType *&a1, DataArrayDouble *&a2) const; - MEDCOUPLING_EXPORT void unserialization(const std::vector& tinyInfoD, const std::vector& tinyInfo, const DataArrayIdType *a1, DataArrayDouble *a2, const std::vector& littleStrings); - MEDCOUPLING_EXPORT std::string getVTKDataSetType() const; - MEDCOUPLING_EXPORT std::string getVTKFileExtension() const; - MEDCOUPLING_EXPORT void writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData, DataArrayByte *byteData) const; - MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const; + MEDCOUPLING_EXPORT void getTinySerializationInformation(std::vector& tinyInfoD, std::vector& tinyInfo, std::vector& littleStrings) const override; + MEDCOUPLING_EXPORT bool isEmptyMesh(const std::vector& tinyInfo) const override; + MEDCOUPLING_EXPORT void resizeForUnserialization(const std::vector& tinyInfo, DataArrayIdType *a1, DataArrayDouble *a2, std::vector& littleStrings) const override; + MEDCOUPLING_EXPORT void serialize(DataArrayIdType *&a1, DataArrayDouble *&a2) const override; + MEDCOUPLING_EXPORT void unserialization(const std::vector& tinyInfoD, const std::vector& tinyInfo, const DataArrayIdType *a1, DataArrayDouble *a2, const std::vector& littleStrings) override; + MEDCOUPLING_EXPORT std::string getVTKDataSetType() const override; + MEDCOUPLING_EXPORT std::string getVTKFileExtension() const override; + MEDCOUPLING_EXPORT void writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData, DataArrayByte *byteData) const override; + MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const override; //tools MEDCOUPLING_EXPORT static int AreCellsEqual(const mcIdType *conn, const mcIdType *connI, mcIdType cell1, mcIdType cell2, int compType); MEDCOUPLING_EXPORT static int AreCellsEqualPolicy0(const mcIdType *conn, const mcIdType *connI, mcIdType cell1, mcIdType cell2); @@ -111,17 +126,17 @@ namespace MEDCoupling MEDCOUPLING_EXPORT void colinearizeEdges(double eps); MEDCOUPLING_EXPORT MEDCouplingUMesh *buildSpreadZonesWithPoly() const; MEDCOUPLING_EXPORT std::vector partitionBySpreadZone() const; - MEDCOUPLING_EXPORT DataArrayIdType *computeFetchedNodeIds() const; - MEDCOUPLING_EXPORT DataArrayIdType *getNodeIdsInUse(mcIdType& nbrOfNodesInUse) const; - MEDCOUPLING_EXPORT void computeNodeIdsAlg(std::vector& nodeIdsInUse) const; - MEDCOUPLING_EXPORT DataArrayIdType *computeNbOfNodesPerCell() const; - MEDCOUPLING_EXPORT DataArrayIdType *computeNbOfFacesPerCell() const; - MEDCOUPLING_EXPORT DataArrayIdType *computeEffectiveNbOfNodesPerCell() const; - MEDCOUPLING_EXPORT DataArrayIdType *zipCoordsTraducer(); - MEDCOUPLING_EXPORT void findCommonCells(int compType, mcIdType startCellId, DataArrayIdType *& commonCellsArr, DataArrayIdType *& commonCellsIArr) const; + MEDCOUPLING_EXPORT DataArrayIdType *computeFetchedNodeIds() const override; + MEDCOUPLING_EXPORT DataArrayIdType *getNodeIdsInUse(mcIdType& nbrOfNodesInUse) const override; + MEDCOUPLING_EXPORT void computeNodeIdsAlg(std::vector& nodeIdsInUse) const override; + MEDCOUPLING_EXPORT DataArrayIdType *computeNbOfNodesPerCell() const override; + MEDCOUPLING_EXPORT DataArrayIdType *computeNbOfFacesPerCell() const override; + MEDCOUPLING_EXPORT DataArrayIdType *computeEffectiveNbOfNodesPerCell() const override; + MEDCOUPLING_EXPORT DataArrayIdType *zipCoordsTraducer() override; + MEDCOUPLING_EXPORT void findCommonCells(int compType, mcIdType startCellId, DataArrayIdType *& commonCellsArr, DataArrayIdType *& commonCellsIArr) const override; MEDCOUPLING_EXPORT bool areCellsIncludedIn(const MEDCouplingUMesh *other, int compType, DataArrayIdType *& arr) const; MEDCOUPLING_EXPORT bool areCellsIncludedInPolicy7(const MEDCouplingUMesh *other, DataArrayIdType *& arr) const; - MEDCOUPLING_EXPORT void getReverseNodalConnectivity(DataArrayIdType *revNodal, DataArrayIdType *revNodalIndx) const; + MEDCOUPLING_EXPORT void getReverseNodalConnectivity(DataArrayIdType *revNodal, DataArrayIdType *revNodalIndx) const override; MEDCOUPLING_EXPORT MCAuto explodeIntoEdges(MCAuto& desc, MCAuto& descIndex, MCAuto& revDesc, MCAuto& revDescIndx) const; MEDCOUPLING_EXPORT MCAuto explodeMeshTo(int targetDeltaLevel, MCAuto& desc, MCAuto& descIndx, MCAuto& revDesc, MCAuto& revDescIndx) const; MEDCOUPLING_EXPORT MEDCouplingUMesh *explode3DMeshTo1D(DataArrayIdType *desc, DataArrayIdType *descIndx, DataArrayIdType *revDesc, DataArrayIdType *revDescIndx) const; @@ -134,15 +149,15 @@ namespace MEDCoupling DataArrayIdType *&neighbors, DataArrayIdType *&neighborsIdx); MEDCOUPLING_EXPORT void computeNeighborsOfNodes(DataArrayIdType *&neighbors, DataArrayIdType *&neighborsIdx) const; MEDCOUPLING_EXPORT void computeEnlargedNeighborsOfNodes(MCAuto &neighbors, MCAuto& neighborsIdx) const; - MEDCOUPLING_EXPORT MEDCouplingUMesh *mergeMyselfWithOnSameCoords(const MEDCouplingPointSet *other) const; - MEDCOUPLING_EXPORT MEDCouplingUMesh *buildPartOfMySelf(const mcIdType *begin, const mcIdType *end, bool keepCoords=true) const; - MEDCOUPLING_EXPORT MEDCouplingUMesh *buildPartOfMySelfSlice(mcIdType start, mcIdType end, mcIdType step, bool keepCoords=true) const; + MEDCOUPLING_EXPORT MEDCouplingUMesh *mergeMyselfWithOnSameCoords(const MEDCouplingPointSet *other) const override; + MEDCOUPLING_EXPORT MEDCouplingUMesh *buildPartOfMySelf(const mcIdType *begin, const mcIdType *end, bool keepCoords=true) const override; + MEDCOUPLING_EXPORT MEDCouplingUMesh *buildPartOfMySelfSlice(mcIdType start, mcIdType end, mcIdType step, bool keepCoords=true) const override; MEDCOUPLING_EXPORT void setPartOfMySelf(const mcIdType *cellIdsBg, const mcIdType *cellIdsEnd, const MEDCouplingUMesh& otherOnSameCoordsThanThis); MEDCOUPLING_EXPORT void setPartOfMySelfSlice(mcIdType start, mcIdType end, mcIdType step, const MEDCouplingUMesh& otherOnSameCoordsThanThis); - MEDCOUPLING_EXPORT MEDCouplingUMesh *buildFacePartOfMySelfNode(const mcIdType *begin, const mcIdType *end, bool fullyIn) const; - MEDCOUPLING_EXPORT MEDCouplingUMesh *buildUnstructured() const; - MEDCOUPLING_EXPORT DataArrayIdType *findBoundaryNodes() const; - MEDCOUPLING_EXPORT MEDCouplingUMesh *buildBoundaryMesh(bool keepCoords) const; + MEDCOUPLING_EXPORT MEDCouplingUMesh *buildFacePartOfMySelfNode(const mcIdType *begin, const mcIdType *end, bool fullyIn) const override; + MEDCOUPLING_EXPORT MEDCouplingUMesh *buildUnstructured() const override; + MEDCOUPLING_EXPORT DataArrayIdType *findBoundaryNodes() const override; + MEDCOUPLING_EXPORT MEDCouplingUMesh *buildBoundaryMesh(bool keepCoords) const override; MEDCOUPLING_EXPORT DataArrayIdType *findCellIdsOnBoundary() const; MEDCOUPLING_EXPORT void findCellIdsLyingOn(const MEDCouplingUMesh& otherDimM1OnSameCoords, DataArrayIdType *&cellIdsRk0, DataArrayIdType *&cellIdsRk1) const; MEDCOUPLING_EXPORT MEDCouplingUMesh *computeSkin() const; @@ -150,19 +165,19 @@ namespace MEDCoupling MEDCOUPLING_EXPORT void findCellsToRenumber(const MEDCouplingUMesh& otherDimM1OnSameCoords, const mcIdType *nodeIdsToDuplicateBg, const mcIdType *nodeIdsToDuplicateEnd, DataArrayIdType *& cellIdsNeededToBeRenum, DataArrayIdType *& cellIdsNotModified) const; MEDCOUPLING_EXPORT void duplicateNodes(const mcIdType *nodeIdsToDuplicateBg, const mcIdType *nodeIdsToDuplicateEnd); - MEDCOUPLING_EXPORT void renumberNodesWithOffsetInConn(mcIdType offset); - MEDCOUPLING_EXPORT void renumberNodesInConn(const INTERP_KERNEL::HashMap& newNodeNumbersO2N); - MEDCOUPLING_EXPORT void renumberNodesInConn(const mcIdType *newNodeNumbersO2N); + MEDCOUPLING_EXPORT void renumberNodesWithOffsetInConn(mcIdType offset) override; + MEDCOUPLING_EXPORT void renumberNodesInConn(const INTERP_KERNEL::HashMap& newNodeNumbersO2N) override; + MEDCOUPLING_EXPORT void renumberNodesInConn(const mcIdType *newNodeNumbersO2N) override; MEDCOUPLING_EXPORT void renumberNodesInConn(const std::map& newNodeNumbersO2N) override; MEDCOUPLING_EXPORT void shiftNodeNumbersInConn(mcIdType delta); MEDCOUPLING_EXPORT void duplicateNodesInConn(const mcIdType *nodeIdsToDuplicateBg, const mcIdType *nodeIdsToDuplicateEnd, mcIdType offset); - MEDCOUPLING_EXPORT void renumberCells(const mcIdType *old2NewBg, bool check=true); - MEDCOUPLING_EXPORT DataArrayIdType *getCellsInBoundingBox(const double *bbox, double eps) const; - MEDCOUPLING_EXPORT DataArrayIdType *getCellsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bbox, double eps); - MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureField(bool isAbs) const; + MEDCOUPLING_EXPORT void renumberCells(const mcIdType *old2NewBg, bool check=true) override; + MEDCOUPLING_EXPORT DataArrayIdType *getCellsInBoundingBox(const double *bbox, double eps) const override; + MEDCOUPLING_EXPORT DataArrayIdType *getCellsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bbox, double eps) override; + MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureField(bool isAbs) const override; MEDCOUPLING_EXPORT DataArrayDouble *getPartMeasureField(bool isAbs, const mcIdType *begin, const mcIdType *end) const; - MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureFieldOnNode(bool isAbs) const; - MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildOrthogonalField() const; + MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureFieldOnNode(bool isAbs) const override; + MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildOrthogonalField() const override; MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildPartOrthogonalField(const mcIdType *begin, const mcIdType *end) const; MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildDirectionVectorField() const; MEDCOUPLING_EXPORT MEDCouplingUMesh *buildSlice3D(const double *origin, const double *vec, double eps, DataArrayIdType *&cellIds) const; @@ -173,15 +188,15 @@ namespace MEDCoupling MEDCOUPLING_EXPORT void project1D(const double *pt, const double *v, double eps, double *res) const; MEDCOUPLING_EXPORT double distanceToPoint(const double *ptBg, const double *ptEnd, mcIdType& cellId) const; MEDCOUPLING_EXPORT DataArrayDouble *distanceToPoints(const DataArrayDouble *pts, DataArrayIdType *& cellIds) const; - MEDCOUPLING_EXPORT mcIdType getCellContainingPoint(const double *pos, double eps) const; - MEDCOUPLING_EXPORT void getCellsContainingPoint(const double *pos, double eps, std::vector& elts) const; + MEDCOUPLING_EXPORT mcIdType getCellContainingPoint(const double *pos, double eps) const override; + MEDCOUPLING_EXPORT void getCellsContainingPoint(const double *pos, double eps, std::vector& elts) const override; MEDCOUPLING_EXPORT void getCellsContainingPoints(const double *pos, mcIdType nbOfPoints, double eps, MCAuto& elts, MCAuto& eltsIndex) const override; MEDCOUPLING_EXPORT void getCellsContainingPointsLinearPartOnlyOnNonDynType(const double *pos, mcIdType nbOfPoints, double eps, MCAuto& elts, MCAuto& eltsIndex) const override; MEDCOUPLING_EXPORT void checkButterflyCells(std::vector& cells, double eps=1e-12) const; MEDCOUPLING_EXPORT DataArrayIdType *convexEnvelop2D(); MEDCOUPLING_EXPORT DataArrayIdType *findAndCorrectBadOriented3DExtrudedCells(); MEDCOUPLING_EXPORT DataArrayIdType *findAndCorrectBadOriented3DCells(); - MEDCOUPLING_EXPORT DataArrayDouble *getBoundingBoxForBBTree(double arcDetEps=1e-12) const; + MEDCOUPLING_EXPORT DataArrayDouble *getBoundingBoxForBBTree(double arcDetEps=1e-12) const override; MEDCOUPLING_EXPORT DataArrayDouble *getBoundingBoxForBBTreeFast() const; MEDCOUPLING_EXPORT DataArrayDouble *getBoundingBoxForBBTree2DQuadratic(double arcDetEps=1e-12) const; MEDCOUPLING_EXPORT DataArrayDouble *getBoundingBoxForBBTree1DQuadratic(double arcDetEps=1e-12) const; @@ -192,7 +207,7 @@ namespace MEDCoupling MEDCOUPLING_EXPORT DataArrayIdType *convertLinearCellsToQuadratic(int conversionType=0); MEDCOUPLING_EXPORT void tessellate2D(double eps); MEDCOUPLING_EXPORT MEDCoupling1SGTUMesh *tetrahedrize(int policy, DataArrayIdType *& n2oCells, mcIdType& nbOfAdditionalPoints) const; - MEDCOUPLING_EXPORT DataArrayIdType *simplexize(int policy); + MEDCOUPLING_EXPORT DataArrayIdType *simplexize(int policy) override; MEDCOUPLING_EXPORT bool areOnlySimplexCells() const; MEDCOUPLING_EXPORT void convertDegeneratedCells(); MEDCOUPLING_EXPORT DataArrayIdType *convertDegeneratedCellsAndRemoveFlatOnes(); @@ -203,7 +218,7 @@ namespace MEDCoupling MEDCOUPLING_EXPORT void changeOrientationOfCells(); MEDCOUPLING_EXPORT void arePolyhedronsNotCorrectlyOriented(std::vector& cells) const; MEDCOUPLING_EXPORT void orientCorrectlyPolyhedrons(); - MEDCOUPLING_EXPORT void invertOrientationOfAllCells(); + MEDCOUPLING_EXPORT void invertOrientationOfAllCells() override; MEDCOUPLING_EXPORT void getFastAveragePlaneOfThis(double *vec, double *pos) const; MEDCOUPLING_EXPORT void attractSeg3MidPtsAroundNodes(double ratio, const mcIdType *nodeIdsBg, const mcIdType *nodeIdsEnd); //Mesh quality @@ -211,11 +226,11 @@ namespace MEDCoupling MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getAspectRatioField() const; MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getWarpField() const; MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getSkewField() const; - MEDCOUPLING_EXPORT MEDCouplingFieldDouble *computeDiameterField() const; + MEDCOUPLING_EXPORT MEDCouplingFieldDouble *computeDiameterField() const override; //utilities for MED File RW - MEDCOUPLING_EXPORT std::vector getDistributionOfTypes() const; - MEDCOUPLING_EXPORT DataArrayIdType *checkTypeConsistencyAndContig(const std::vector& code, const std::vector& idsPerType) const; - MEDCOUPLING_EXPORT void splitProfilePerType(const DataArrayIdType *profile, std::vector& code, std::vector& idsInPflPerType, std::vector& idsPerType, bool smartPflKiller=true) const; + MEDCOUPLING_EXPORT std::vector getDistributionOfTypes() const override; + MEDCOUPLING_EXPORT DataArrayIdType *checkTypeConsistencyAndContig(const std::vector& code, const std::vector& idsPerType) const override; + MEDCOUPLING_EXPORT void splitProfilePerType(const DataArrayIdType *profile, std::vector& code, std::vector& idsInPflPerType, std::vector& idsPerType, bool smartPflKiller=true) const override; MEDCOUPLING_EXPORT MEDCouplingUMesh *emulateMEDMEMBDC(const MEDCouplingUMesh *nM1LevMesh, DataArrayIdType *desc, DataArrayIdType *descIndx, DataArrayIdType *&revDesc, DataArrayIdType *&revDescIndx, DataArrayIdType *& nM1LevMeshIds, DataArrayIdType *&meshnM1Old2New) const; MEDCOUPLING_EXPORT DataArrayIdType *sortCellsInMEDFileFrmt(); MEDCOUPLING_EXPORT bool checkConsecutiveCellTypes() const; @@ -237,17 +252,17 @@ namespace MEDCoupling MEDCOUPLING_EXPORT MEDCouplingUMesh *keepSpecifiedCells(INTERP_KERNEL::NormalizedCellType type, const mcIdType *idsPerGeoTypeBg, const mcIdType *idsPerGeoTypeEnd) const; MEDCOUPLING_EXPORT std::vector getQuadraticStatus() const; // - MEDCOUPLING_EXPORT MEDCouplingMesh *mergeMyselfWith(const MEDCouplingMesh *other) const; - MEDCOUPLING_EXPORT DataArrayDouble *computeCellCenterOfMass() const; + MEDCOUPLING_EXPORT MEDCouplingMesh *mergeMyselfWith(const MEDCouplingMesh *other) const override; + MEDCOUPLING_EXPORT DataArrayDouble *computeCellCenterOfMass() const override; MEDCOUPLING_EXPORT DataArrayDouble *computeCellCenterOfMassWithPrecision(double eps) const; - MEDCOUPLING_EXPORT DataArrayDouble *computeIsoBarycenterOfNodesPerCell() const; + MEDCOUPLING_EXPORT DataArrayDouble *computeIsoBarycenterOfNodesPerCell() const override; MEDCOUPLING_EXPORT DataArrayDouble *getPartBarycenterAndOwner(const mcIdType *begin, const mcIdType *end) const; MEDCOUPLING_EXPORT DataArrayDouble *computePlaneEquationOf3DFaces() const; MEDCOUPLING_EXPORT DataArrayIdType *conformize2D(double eps); MEDCOUPLING_EXPORT DataArrayIdType *colinearize2D(double eps); MEDCOUPLING_EXPORT DataArrayIdType *colinearizeKeepingConform2D(double eps); MEDCOUPLING_EXPORT DataArrayIdType *conformize3D(double eps); - MEDCOUPLING_EXPORT mcIdType split2DCells(const DataArrayIdType *desc, const DataArrayIdType *descI, const DataArrayIdType *subNodesInSeg, const DataArrayIdType *subNodesInSegI, const DataArrayIdType *midOpt=0, const DataArrayIdType *midOptI=0); + MEDCOUPLING_EXPORT mcIdType split2DCells(const DataArrayIdType *desc, const DataArrayIdType *descI, const DataArrayIdType *subNodesInSeg, const DataArrayIdType *subNodesInSegI, const DataArrayIdType *midOpt=nullptr, const DataArrayIdType *midOptI=nullptr); MEDCOUPLING_EXPORT static MEDCouplingUMesh *Build0DMeshFromCoords(DataArrayDouble *da); MEDCOUPLING_EXPORT static MCAuto Build1DMeshFromCoords(DataArrayDouble *da); MEDCOUPLING_EXPORT static MEDCouplingUMesh *MergeUMeshes(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2); @@ -284,8 +299,8 @@ namespace MEDCoupling MEDCouplingUMesh(); MEDCouplingUMesh(const MEDCouplingUMesh& other, bool deepCpy); - ~MEDCouplingUMesh(); - void checkFullyDefined() const; + ~MEDCouplingUMesh() override; + void checkFullyDefined() const override; void checkConnectivityFullyDefined() const; void reprConnectivityOfThisLL(std::ostringstream& stream) const; //tools @@ -296,7 +311,7 @@ namespace MEDCoupling void tessellate2DInternal(double eps); void tessellate2DCurveInternal(double eps); void subDivide2DMesh(const mcIdType *nodeSubdived, const mcIdType *nodeIndxSubdived, const mcIdType *desc, const mcIdType *descIndex); - void fillCellIdsToKeepFromNodeIds(const mcIdType *begin, const mcIdType *end, bool fullyIn, DataArrayIdType *&cellIdsKeptArr) const; + void fillCellIdsToKeepFromNodeIds(const mcIdType *begin, const mcIdType *end, bool fullyIn, DataArrayIdType *&cellIdsKeptArr) const override; void split3DCurveWithPlane(const double *origin, const double *vec, double eps, std::vector& cut3DCurve); MEDCouplingUMesh *buildExtrudedMeshFromThisLowLev(mcIdType nbOfNodesOf1Lev, bool isQuad) const; DataArrayDouble *fillExtCoordsUsingTranslation(const MEDCouplingUMesh *mesh1D, bool isQuad) const; @@ -304,8 +319,8 @@ namespace MEDCoupling DataArrayDouble *fillExtCoordsUsingTranslAndAutoRotation2D(const MEDCouplingUMesh *mesh1D, bool isQuad) const; DataArrayDouble *fillExtCoordsUsingTranslAndAutoRotation3D(const MEDCouplingUMesh *mesh1D, bool isQuad) const; static bool AreCellsEqualInPool(const std::vector& candidates, int compType, const mcIdType *conn, const mcIdType *connI, DataArrayIdType *result) ; - MEDCouplingUMesh *buildPartOfMySelfKeepCoords(const mcIdType *begin, const mcIdType *end) const; - MEDCouplingUMesh *buildPartOfMySelfKeepCoordsSlice(mcIdType start, mcIdType end, mcIdType step) const; + MEDCouplingUMesh *buildPartOfMySelfKeepCoords(const mcIdType *begin, const mcIdType *end) const override; + MEDCouplingUMesh *buildPartOfMySelfKeepCoordsSlice(mcIdType start, mcIdType end, mcIdType step) const override; DataArrayIdType *convertLinearCellsToQuadratic1D0(DataArrayIdType *&conn, DataArrayIdType *&connI, DataArrayDouble *& coords, std::set& types) const; DataArrayIdType *convertLinearCellsToQuadratic2DAnd3D0(const MEDCouplingUMesh *m1D, const DataArrayIdType *desc, const DataArrayIdType *descI, DataArrayIdType *&conn, DataArrayIdType *&connI, DataArrayDouble *& coords, std::set& types) const; DataArrayIdType *convertLinearCellsToQuadratic2D0(DataArrayIdType *&conn, DataArrayIdType *&connI, DataArrayDouble *& coords, std::set& types) const; @@ -323,7 +338,7 @@ namespace MEDCoupling /// @cond INTERNAL static void DeleteCellTypeInIndexedArray(const DataArrayIdType *arrIn, const DataArrayIdType *arrIndxIn, MCAuto& arrOut, MCAuto& arrIndxOut); static MEDCouplingUMesh *MergeUMeshesLL(const std::vector& a); - typedef mcIdType (*DimM1DescNbrer)(mcIdType id, mcIdType nb, const INTERP_KERNEL::CellModel& cm, bool compute, const mcIdType *conn1, const mcIdType *conn2); + using DimM1DescNbrer = mcIdType (*)(mcIdType, mcIdType, const INTERP_KERNEL::CellModel &, bool, const mcIdType *, const mcIdType *); template MEDCouplingUMesh *buildDescendingConnectivityGen(DataArrayIdType *desc, DataArrayIdType *descIndx, DataArrayIdType *revDesc, DataArrayIdType *revDescIndx, DimM1DescNbrer nbrer) const; static void DistanceToPoint3DSurfAlg(const double *pt, const mcIdType *cellIdsBg, const mcIdType *cellIdsEnd, const double *coords, const mcIdType *nc, const mcIdType *ncI, double& ret0, mcIdType& cellId); diff --git a/src/MEDCoupling/MEDCouplingUMesh.txx b/src/MEDCoupling/MEDCouplingUMesh.txx index 438db20d7..4ba20b4b5 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.txx +++ b/src/MEDCoupling/MEDCouplingUMesh.txx @@ -19,6 +19,8 @@ // Author : Anthony Geay (EDF R&D) #pragma once +#include "MCType.hxx" +#include "MCIdType.hxx" #include "MEDCouplingUMesh.hxx" #include @@ -29,7 +31,7 @@ void MEDCoupling::MEDCouplingUMesh::renumberNodesInConnT(const MAPCLS& newNodeNu checkConnectivityFullyDefined(); mcIdType *conn(getNodalConnectivity()->getPointer()); const mcIdType *connIndex(getNodalConnectivityIndex()->getConstPointer()); - mcIdType nbOfCells=ToIdType(getNumberOfCells()); + mcIdType const nbOfCells=ToIdType(getNumberOfCells()); for(mcIdType i=0;i +#include +#include +#include +#include +#include +#include #include -#include -#include #include #include -#include +#include +#include using namespace MEDCoupling; @@ -72,9 +72,9 @@ void MEDCouplingUMesh::checkConnectivityFullyDefined() const void MEDCouplingUMesh::reprConnectivityOfThisLL(std::ostringstream& stream) const { - if(_nodal_connec!=0 && _nodal_connec_index!=0) + if(_nodal_connec!=nullptr && _nodal_connec_index!=nullptr) { - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbOfCells=getNumberOfCells(); const mcIdType *c=_nodal_connec->getConstPointer(); const mcIdType *ci=_nodal_connec_index->getConstPointer(); for(mcIdType i=0;i ret=DataArrayIdType::New(); - mcIdType nbOfCutCells=getNumberOfCellsWithType(INTERP_KERNEL::NORM_QUAD4); + mcIdType const nbOfCutCells=getNumberOfCellsWithType(INTERP_KERNEL::NORM_QUAD4); ret->alloc(nbOfCells+nbOfCutCells,1); if(nbOfCutCells==0) { ret->iota(0); return ret.retn(); } mcIdType *retPt=ret->getPointer(); @@ -151,9 +151,9 @@ DataArrayIdType *MEDCouplingUMesh::simplexizePol1() checkConnectivityFullyDefined(); if(getMeshDimension()!=2) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::simplexizePol0 : this policy is only available for mesh with meshdim == 2 !"); - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbOfCells=getNumberOfCells(); MCAuto ret=DataArrayIdType::New(); - mcIdType nbOfCutCells=getNumberOfCellsWithType(INTERP_KERNEL::NORM_QUAD4); + mcIdType const nbOfCutCells=getNumberOfCellsWithType(INTERP_KERNEL::NORM_QUAD4); ret->alloc(nbOfCells+nbOfCutCells,1); if(nbOfCutCells==0) { ret->iota(0); return ret.retn(); } mcIdType *retPt=ret->getPointer(); @@ -204,9 +204,9 @@ DataArrayIdType *MEDCouplingUMesh::simplexizePlanarFace5() checkConnectivityFullyDefined(); if(getMeshDimension()!=3) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::simplexizePlanarFace5 : this policy is only available for mesh with meshdim == 3 !"); - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbOfCells=getNumberOfCells(); MCAuto ret=DataArrayIdType::New(); - mcIdType nbOfCutCells=getNumberOfCellsWithType(INTERP_KERNEL::NORM_HEXA8); + mcIdType const nbOfCutCells=getNumberOfCellsWithType(INTERP_KERNEL::NORM_HEXA8); ret->alloc(nbOfCells+4*nbOfCutCells,1); if(nbOfCutCells==0) { ret->iota(0); return ret.retn(); } mcIdType *retPt=ret->getPointer(); @@ -256,9 +256,9 @@ DataArrayIdType *MEDCouplingUMesh::simplexizePlanarFace6() checkConnectivityFullyDefined(); if(getMeshDimension()!=3) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::simplexizePlanarFace6 : this policy is only available for mesh with meshdim == 3 !"); - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbOfCells=getNumberOfCells(); MCAuto ret=DataArrayIdType::New(); - mcIdType nbOfCutCells=getNumberOfCellsWithType(INTERP_KERNEL::NORM_HEXA8); + mcIdType const nbOfCutCells=getNumberOfCellsWithType(INTERP_KERNEL::NORM_HEXA8); ret->alloc(nbOfCells+5*nbOfCutCells,1); if(nbOfCutCells==0) { ret->iota(0); return ret.retn(); } mcIdType *retPt=ret->getPointer(); @@ -319,12 +319,12 @@ void MEDCouplingUMesh::tessellate2DInternal(double eps) checkFullyDefined(); if(getMeshDimension()!=2 || getSpaceDimension()!=2) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::tessellate2DInternal works on umeshes with meshdim equal to 2 and spaceDim equal to 2 too!"); - double epsa=fabs(eps); + double const epsa=fabs(eps); if(epsa::min()) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::tessellate2DInternal : epsilon is null ! Please specify a higher epsilon. If too tiny it can lead to a huge amount of nodes and memory !"); MCAuto desc1(DataArrayIdType::New()),descIndx1(DataArrayIdType::New()),revDesc1(DataArrayIdType::New()),revDescIndx1(DataArrayIdType::New()); MCAuto mDesc(buildDescendingConnectivity2(desc1,descIndx1,revDesc1,revDescIndx1)); - revDesc1=0; revDescIndx1=0; + revDesc1=nullptr; revDescIndx1=nullptr; mDesc->tessellate2D(eps); subDivide2DMesh(mDesc->_nodal_connec->begin(),mDesc->_nodal_connec_index->begin(),desc1->begin(),descIndx1->begin()); setCoords(mDesc->getCoords()); @@ -345,12 +345,12 @@ void MEDCouplingUMesh::tessellate2DCurveInternal(double eps) checkFullyDefined(); if(getMeshDimension()!=1 || getSpaceDimension()!=2) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::tessellate2DCurveInternal works on umeshes with meshdim equal to 1 and spaceDim equal to 2 too!"); - double epsa=fabs(eps); + double const epsa=fabs(eps); if(epsa::min()) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::tessellate2DCurveInternal : epsilon is null ! Please specify a higher epsilon. If too tiny it can lead to a huge amount of nodes and memory !"); - INTERP_KERNEL::QuadraticPlanarPrecision arcPrec(1.e-10); // RAII - mcIdType nbCells=getNumberOfCells(); - mcIdType nbNodes=getNumberOfNodes(); + INTERP_KERNEL::QuadraticPlanarPrecision const arcPrec(1.e-10); // RAII + mcIdType const nbCells=getNumberOfCells(); + mcIdType const nbNodes=getNumberOfNodes(); const mcIdType *conn=_nodal_connec->begin(); const mcIdType *connI=_nodal_connec_index->begin(); const double *coords=_coords->begin(); @@ -425,29 +425,29 @@ void MEDCouplingUMesh::subDivide2DMesh(const mcIdType *nodeSubdived, const mcIdT checkFullyDefined(); if(getMeshDimension()!=2) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::subDivide2DMesh : works only on umesh with meshdim==2 !"); - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbOfCells=getNumberOfCells(); mcIdType *connI=_nodal_connec_index->getPointer(); mcIdType newConnLgth=0; for(mcIdType i=0;i0; - mcIdType eedgeId=std::abs(desc[offset+nbOfEdges-1])-1; + bool const ddirect=desc[offset+nbOfEdges-1]>0; + mcIdType const eedgeId=std::abs(desc[offset+nbOfEdges-1])-1; mcIdType ref=ddirect?nodeSubdived[nodeIndxSubdived[eedgeId+1]-1]:nodeSubdived[nodeIndxSubdived[eedgeId]+1]; for(mcIdType j=0;j0; - mcIdType edgeId=std::abs(desc[offset+j])-1; + bool const direct=desc[offset+j]>0; + mcIdType const edgeId=std::abs(desc[offset+j])-1; if(!INTERP_KERNEL::CellModel::GetCellModel((INTERP_KERNEL::NormalizedCellType)nodeSubdived[nodeIndxSubdived[edgeId]]).isQuadratic()) { - mcIdType id1=nodeSubdived[nodeIndxSubdived[edgeId]+1]; - mcIdType id2=nodeSubdived[nodeIndxSubdived[edgeId+1]-1]; - mcIdType ref2=direct?id1:id2; + mcIdType const id1=nodeSubdived[nodeIndxSubdived[edgeId]+1]; + mcIdType const id2=nodeSubdived[nodeIndxSubdived[edgeId+1]-1]; + mcIdType const ref2=direct?id1:id2; if(ref==ref2) { - mcIdType nbOfSubNodes=nodeIndxSubdived[edgeId+1]-nodeIndxSubdived[edgeId]-1; + mcIdType const nbOfSubNodes=nodeIndxSubdived[edgeId+1]-nodeIndxSubdived[edgeId]-1; newConnLgth+=nbOfSubNodes-1; ref=direct?id2:id1; } @@ -472,18 +472,18 @@ void MEDCouplingUMesh::subDivide2DMesh(const mcIdType *nodeSubdived, const mcIdT for(mcIdType i=0;i0; - mcIdType edgeId=std::abs(desc[offset+j])-1; + bool const direct=desc[offset+j]>0; + mcIdType const edgeId=std::abs(desc[offset+j])-1; if(direct) work=std::copy(nodeSubdived+nodeIndxSubdived[edgeId]+1,nodeSubdived+nodeIndxSubdived[edgeId+1]-1,work); else { - mcIdType nbOfSubNodes=nodeIndxSubdived[edgeId+1]-nodeIndxSubdived[edgeId]-1; - std::reverse_iterator it(nodeSubdived+nodeIndxSubdived[edgeId+1]); + mcIdType const nbOfSubNodes=nodeIndxSubdived[edgeId+1]-nodeIndxSubdived[edgeId]-1; + std::reverse_iterator const it(nodeSubdived+nodeIndxSubdived[edgeId+1]); work=std::copy(it,it+nbOfSubNodes-1,work); } } @@ -520,7 +520,7 @@ void MEDCouplingUMesh::fillCellIdsToKeepFromNodeIds(const mcIdType *begin, const for(const mcIdType *work=begin;work!=end;work++) if(*work>=0 && *workgetConstPointer(); const mcIdType *connIndex=getNodalConnectivityIndex()->getConstPointer(); for(mcIdType i=0;ieps)//if colin<=eps -> current SEG2 is colinear to the input plane { const double *st2=coo+3*st; vec4[0]=st2[0]-origin[0]; vec4[1]=st2[1]-origin[1]; vec4[2]=st2[2]-origin[2]; - double pos=-(vec4[0]*vec2[0]+vec4[1]*vec2[1]+vec4[2]*vec2[2])/((vec3[0]*vec2[0]+vec3[1]*vec2[1]+vec3[2]*vec2[2])); + double const pos=-(vec4[0]*vec2[0]+vec4[1]*vec2[1]+vec4[2]*vec2[2])/((vec3[0]*vec2[0]+vec3[1]*vec2[1]+vec3[2]*vec2[2])); if(pos>eps && pos<1-eps) { - mcIdType nNode=ToIdType(addCoo.size())/3; + mcIdType const nNode=ToIdType(addCoo.size())/3; vec4[0]=st2[0]+pos*vec3[0]; vec4[1]=st2[1]+pos*vec3[1]; vec4[2]=st2[2]+pos*vec3[2]; addCoo.insert(addCoo.end(),vec4,vec4+3); cut3DCurve[i]=nnodes+nNode; @@ -596,7 +596,7 @@ void MEDCouplingUMesh::split3DCurveWithPlane(const double *origin, const double } if(!addCoo.empty()) { - mcIdType newNbOfNodes=nnodes+ToIdType(addCoo.size())/3; + mcIdType const newNbOfNodes=nnodes+ToIdType(addCoo.size())/3; MCAuto coo2=DataArrayDouble::New(); coo2->alloc(newNbOfNodes,3); double *tmp=coo2->getPointer(); @@ -613,12 +613,12 @@ void MEDCouplingUMesh::split3DCurveWithPlane(const double *origin, const double */ DataArrayDouble *MEDCouplingUMesh::fillExtCoordsUsingTranslation(const MEDCouplingUMesh *mesh1D, bool isQuad) const { - mcIdType oldNbOfNodes=getNumberOfNodes(); - mcIdType nbOf1DCells=ToIdType(mesh1D->getNumberOfCells()); - std::size_t spaceDim=getSpaceDimension(); + mcIdType const oldNbOfNodes=getNumberOfNodes(); + mcIdType const nbOf1DCells=ToIdType(mesh1D->getNumberOfCells()); + std::size_t const spaceDim=getSpaceDimension(); DataArrayDouble *ret=DataArrayDouble::New(); - std::vector isQuads; - mcIdType nbOfLevsInVec=isQuad?2*nbOf1DCells+1:nbOf1DCells+1; + std::vector const isQuads; + mcIdType const nbOfLevsInVec=isQuad?2*nbOf1DCells+1:nbOf1DCells+1; ret->alloc(oldNbOfNodes*nbOfLevsInVec,spaceDim); double *retPtr=ret->getPointer(); const double *coords=getCoords()->getConstPointer(); @@ -675,12 +675,12 @@ DataArrayDouble *MEDCouplingUMesh::fillExtCoordsUsingTranslAndAutoRotation2D(con { if(isQuad) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::fillExtCoordsUsingTranslAndAutoRotation2D : not implemented for quadratic cells !"); - mcIdType oldNbOfNodes=getNumberOfNodes(); - mcIdType nbOf1DCells=ToIdType(mesh1D->getNumberOfCells()); + mcIdType const oldNbOfNodes=getNumberOfNodes(); + mcIdType const nbOf1DCells=ToIdType(mesh1D->getNumberOfCells()); if(nbOf1DCells<2) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::fillExtCoordsUsingTranslAndAutoRotation2D : impossible to detect any angle of rotation ! Change extrusion policy 1->0 !"); MCAuto ret=DataArrayDouble::New(); - mcIdType nbOfLevsInVec=nbOf1DCells+1; + mcIdType const nbOfLevsInVec=nbOf1DCells+1; ret->alloc(oldNbOfNodes*nbOfLevsInVec,2); double *retPtr=ret->getPointer(); retPtr=std::copy(getCoords()->getConstPointer(),getCoords()->getConstPointer()+getCoords()->getNbOfElems(),retPtr); @@ -702,9 +702,9 @@ DataArrayDouble *MEDCouplingUMesh::fillExtCoordsUsingTranslAndAutoRotation2D(con const double *p1=i+1rotate(end,0,angle); + double const cosangle=i+1rotate(end,nullptr,angle); retPtr=std::copy(tmp2->getConstPointer(),tmp2->getConstPointer()+tmp2->getNbOfElems(),retPtr); } return ret.retn(); @@ -719,12 +719,12 @@ DataArrayDouble *MEDCouplingUMesh::fillExtCoordsUsingTranslAndAutoRotation3D(con { if(isQuad) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::fillExtCoordsUsingTranslAndAutoRotation3D : not implemented for quadratic cells !"); - mcIdType oldNbOfNodes=getNumberOfNodes(); - mcIdType nbOf1DCells=ToIdType(mesh1D->getNumberOfCells()); + mcIdType const oldNbOfNodes=getNumberOfNodes(); + mcIdType const nbOf1DCells=ToIdType(mesh1D->getNumberOfCells()); if(nbOf1DCells<2) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::fillExtCoordsUsingTranslAndAutoRotation3D : impossible to detect any angle of rotation ! Change extrusion policy 1->0 !"); MCAuto ret=DataArrayDouble::New(); - mcIdType nbOfLevsInVec=nbOf1DCells+1; + mcIdType const nbOfLevsInVec=nbOf1DCells+1; ret->alloc(oldNbOfNodes*nbOfLevsInVec,3); double *retPtr=ret->getPointer(); retPtr=std::copy(getCoords()->getConstPointer(),getCoords()->getConstPointer()+getCoords()->getNbOfElems(),retPtr); @@ -750,15 +750,15 @@ DataArrayDouble *MEDCouplingUMesh::fillExtCoordsUsingTranslAndAutoRotation3D(con (p1[2]-p0[2])*(p2[0]-p1[0])-(p1[0]-p0[0])*(p2[2]-p1[2]), (p1[0]-p0[0])*(p2[1]-p1[1])-(p1[1]-p0[1])*(p2[0]-p1[0]), }; - double norm=sqrt(vecPlane[0]*vecPlane[0]+vecPlane[1]*vecPlane[1]+vecPlane[2]*vecPlane[2]); + double const norm=sqrt(vecPlane[0]*vecPlane[0]+vecPlane[1]*vecPlane[1]+vecPlane[2]*vecPlane[2]); if(norm>1.e-7) { vecPlane[0]/=norm; vecPlane[1]/=norm; vecPlane[2]/=norm; - double norm2=sqrt(vecPlane[0]*vecPlane[0]+vecPlane[1]*vecPlane[1]); - double vec2[2]={vecPlane[1]/norm2,-vecPlane[0]/norm2}; - double s2=norm2; + double const norm2=sqrt(vecPlane[0]*vecPlane[0]+vecPlane[1]*vecPlane[1]); + double const vec2[2]={vecPlane[1]/norm2,-vecPlane[0]/norm2}; + double const s2=norm2; double c2=cos(asin(s2)); - double m[3][3]={ + double const m[3][3]={ {vec2[0]*vec2[0]*(1-c2)+c2, vec2[0]*vec2[1]*(1-c2), vec2[1]*s2}, {vec2[0]*vec2[1]*(1-c2), vec2[1]*vec2[1]*(1-c2)+c2, -vec2[0]*s2}, {-vec2[1]*s2, vec2[0]*s2, c2} @@ -767,8 +767,8 @@ DataArrayDouble *MEDCouplingUMesh::fillExtCoordsUsingTranslAndAutoRotation3D(con double p1r[3]={m[0][0]*p1[0]+m[0][1]*p1[1]+m[0][2]*p1[2], m[1][0]*p1[0]+m[1][1]*p1[1]+m[1][2]*p1[2], m[2][0]*p1[0]+m[2][1]*p1[1]+m[2][2]*p1[2]}; double p2r[3]={m[0][0]*p2[0]+m[0][1]*p2[1]+m[0][2]*p2[2], m[1][0]*p2[0]+m[1][1]*p2[1]+m[1][2]*p2[2], m[2][0]*p2[0]+m[2][1]*p2[1]+m[2][2]*p2[2]}; INTERP_KERNEL::EdgeArcCircle::GetArcOfCirclePassingThru(p0r,p1r,p2r,tmp3,radius,alpha,alpha0); - double cosangle=i+1rotate(end,vecPlane,angle); } retPtr=std::copy(tmp2->getConstPointer(),tmp2->getConstPointer()+tmp2->getNbOfElems(),retPtr); @@ -784,9 +784,9 @@ DataArrayDouble *MEDCouplingUMesh::fillExtCoordsUsingTranslAndAutoRotation3D(con */ MEDCouplingUMesh *MEDCouplingUMesh::buildExtrudedMeshFromThisLowLev(mcIdType nbOfNodesOf1Lev, bool isQuad) const { - mcIdType nbOf1DCells(getNumberOfNodes()/nbOfNodesOf1Lev-1); - mcIdType nbOf2DCells=getNumberOfCells(); - mcIdType nbOf3DCells(nbOf2DCells*nbOf1DCells); + mcIdType const nbOf1DCells(getNumberOfNodes()/nbOfNodesOf1Lev-1); + mcIdType const nbOf2DCells=getNumberOfCells(); + mcIdType const nbOf3DCells(nbOf2DCells*nbOf1DCells); MEDCouplingUMesh *ret(MEDCouplingUMesh::New("Extruded",getMeshDimension()+1)); const mcIdType *conn(_nodal_connec->begin()),*connI(_nodal_connec_index->begin()); MCAuto newConn(DataArrayIdType::New()),newConnI(DataArrayIdType::New()); @@ -801,7 +801,7 @@ MEDCouplingUMesh *MEDCouplingUMesh::buildExtrudedMeshFromThisLowLev(mcIdType nbO } newConn->alloc(newc.size()*nbOf1DCells,1); mcIdType *newConnPtr(newConn->getPointer()); - mcIdType deltaPerLev(isQuad?2*nbOfNodesOf1Lev:nbOfNodesOf1Lev); + mcIdType const deltaPerLev(isQuad?2*nbOfNodesOf1Lev:nbOfNodesOf1Lev); newConnIPtr=newConnI->getPointer(); for(mcIdType iz=0;iz::const_iterator iter=newc.begin();iter!=newc.end();iter++,newConnPtr++) { - mcIdType icell(ToIdType(iter-newc.begin()));//std::distance unfortunately cannot been called here in C++98 + mcIdType const icell(ToIdType(iter-newc.begin()));//std::distance unfortunately cannot been called here in C++98 if(icell!=*posOfTypeOfCell) { if(*iter!=-1) @@ -844,11 +844,11 @@ bool MEDCouplingUMesh::AreCellsEqualInPool(const std::vector& candidat if(candidates.size()<1) return false; bool ret=false; - std::vector::const_iterator iter=candidates.begin(); - mcIdType start=(*iter++); + auto iter=candidates.begin(); + mcIdType const start=(*iter++); for(;iter!=candidates.end();iter++) { - int status=AreCellsEqual(conn,connI,start,*iter,compType); + int const status=AreCellsEqual(conn,connI,start,*iter,compType); if(status!=0) { if(!ret) @@ -873,12 +873,12 @@ bool MEDCouplingUMesh::AreCellsEqualInPool(const std::vector& candidat MEDCouplingUMesh *MEDCouplingUMesh::buildPartOfMySelfKeepCoords(const mcIdType *begin, const mcIdType *end) const { checkConnectivityFullyDefined(); - mcIdType ncell=getNumberOfCells(); + mcIdType const ncell=getNumberOfCells(); MCAuto ret=MEDCouplingUMesh::New(); ret->_mesh_dim=_mesh_dim; ret->setCoords(_coords); - std::size_t nbOfElemsRet=std::distance(begin,end); - mcIdType *connIndexRet=(mcIdType *)malloc((nbOfElemsRet+1)*sizeof(mcIdType)); + std::size_t const nbOfElemsRet=std::distance(begin,end); + auto *connIndexRet=(mcIdType *)malloc((nbOfElemsRet+1)*sizeof(mcIdType)); connIndexRet[0]=0; const mcIdType *conn=_nodal_connec->getConstPointer(); const mcIdType *connIndex=_nodal_connec_index->getConstPointer(); @@ -894,7 +894,7 @@ MEDCouplingUMesh *MEDCouplingUMesh::buildPartOfMySelfKeepCoords(const mcIdType * throw INTERP_KERNEL::Exception(oss.str()); } } - mcIdType *connRet=(mcIdType *)malloc(connIndexRet[nbOfElemsRet]*sizeof(mcIdType)); + auto *connRet=(mcIdType *)malloc(connIndexRet[nbOfElemsRet]*sizeof(mcIdType)); mcIdType *connRetWork=connRet; std::set types; for(const mcIdType *work=begin;work!=end;work++) @@ -919,11 +919,11 @@ MEDCouplingUMesh *MEDCouplingUMesh::buildPartOfMySelfKeepCoords(const mcIdType * MEDCouplingUMesh *MEDCouplingUMesh::buildPartOfMySelfKeepCoordsSlice(mcIdType start, mcIdType end, mcIdType step) const { checkFullyDefined(); - mcIdType ncell=getNumberOfCells(); + mcIdType const ncell=getNumberOfCells(); MCAuto ret=MEDCouplingUMesh::New(); ret->_mesh_dim=_mesh_dim; ret->setCoords(_coords); - mcIdType newNbOfCells=DataArray::GetNumberOfItemGivenBESRelative(start,end,step,"MEDCouplingUMesh::buildPartOfMySelfKeepCoordsSlice : "); + mcIdType const newNbOfCells=DataArray::GetNumberOfItemGivenBESRelative(start,end,step,"MEDCouplingUMesh::buildPartOfMySelfKeepCoordsSlice : "); MCAuto newConnI=DataArrayIdType::New(); newConnI->alloc(newNbOfCells+1,1); mcIdType *newConnIPtr=newConnI->getPointer(); *newConnIPtr=0; mcIdType work=start; @@ -957,7 +957,7 @@ MEDCouplingUMesh *MEDCouplingUMesh::buildPartOfMySelfKeepCoordsSlice(mcIdType st } -mcIdType MEDCouplingFastNbrer(mcIdType id, mcIdType nb, const INTERP_KERNEL::CellModel& cm, bool compute, const mcIdType *conn1, const mcIdType *conn2) +mcIdType MEDCouplingFastNbrer(mcIdType id, mcIdType /*nb*/, const INTERP_KERNEL::CellModel& /*cm*/, bool /*compute*/, const mcIdType * /*conn1*/, const mcIdType * /*conn2*/) { return id; } @@ -987,14 +987,14 @@ DataArrayIdType *MEDCouplingUMesh::convertLinearCellsToQuadratic1D0(DataArrayIdT MCAuto newConn=DataArrayIdType::New(); newConn->alloc(0,1); MCAuto newConnI=DataArrayIdType::New(); newConnI->alloc(1,1); newConnI->setIJ(0,0,0); MCAuto ret=DataArrayIdType::New(); ret->alloc(0,1); - mcIdType nbOfCells=getNumberOfCells(); - mcIdType nbOfNodes=getNumberOfNodes(); + mcIdType const nbOfCells=getNumberOfCells(); + mcIdType const nbOfNodes=getNumberOfNodes(); const mcIdType *cPtr=_nodal_connec->begin(); const mcIdType *icPtr=_nodal_connec_index->begin(); mcIdType lastVal=0,offset=nbOfNodes; for(mcIdType i=0;i ret=DataArrayIdType::New(); ret->alloc(0,1); // const mcIdType *descPtr(desc->begin()),*descIPtr(descI->begin()); - DataArrayIdType *conn1D=0,*conn1DI=0; + DataArrayIdType *conn1D=nullptr,*conn1DI=nullptr; std::set types1D; - DataArrayDouble *coordsTmp=0; - MCAuto ret1D=m1D->convertLinearCellsToQuadratic1D0(conn1D,conn1DI,coordsTmp,types1D); ret1D=0; + DataArrayDouble *coordsTmp=nullptr; + MCAuto ret1D=m1D->convertLinearCellsToQuadratic1D0(conn1D,conn1DI,coordsTmp,types1D); ret1D=nullptr; MCAuto coordsTmpSafe(coordsTmp); MCAuto conn1DSafe(conn1D),conn1DISafe(conn1DI); const mcIdType *c1DPtr=conn1D->begin(); const mcIdType *c1DIPtr=conn1DI->begin(); - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbOfCells=getNumberOfCells(); const mcIdType *cPtr=_nodal_connec->begin(); const mcIdType *icPtr=_nodal_connec_index->begin(); mcIdType lastVal=0; for(mcIdType i=0;ipushBackSilent(typ2); newConn->pushBackValsSilent(cPtr+icPtr[0]+1,cPtr+icPtr[1]); for(const mcIdType *d=descPtr+descIPtr[0];d!=descPtr+descIPtr[1];d++) @@ -1072,14 +1072,14 @@ DataArrayIdType *MEDCouplingUMesh::convertLinearCellsToQuadratic2DAnd3D0(const M DataArrayIdType *MEDCouplingUMesh::convertLinearCellsToQuadratic2D0(DataArrayIdType *&conn, DataArrayIdType *&connI, DataArrayDouble *& coords, std::set& types) const { MCAuto desc(DataArrayIdType::New()),descI(DataArrayIdType::New()),tmp2(DataArrayIdType::New()),tmp3(DataArrayIdType::New()); - MCAuto m1D=buildDescendingConnectivity(desc,descI,tmp2,tmp3); tmp2=0; tmp3=0; + MCAuto m1D=buildDescendingConnectivity(desc,descI,tmp2,tmp3); tmp2=nullptr; tmp3=nullptr; return convertLinearCellsToQuadratic2DAnd3D0(m1D,desc,descI,conn,connI,coords,types); } DataArrayIdType *MEDCouplingUMesh::convertLinearCellsToQuadratic2D1(DataArrayIdType *&conn, DataArrayIdType *&connI, DataArrayDouble *& coords, std::set& types) const { MCAuto desc(DataArrayIdType::New()),descI(DataArrayIdType::New()),tmp2(DataArrayIdType::New()),tmp3(DataArrayIdType::New()); - MCAuto m1D=buildDescendingConnectivity(desc,descI,tmp2,tmp3); tmp2=0; tmp3=0; + MCAuto m1D=buildDescendingConnectivity(desc,descI,tmp2,tmp3); tmp2=nullptr; tmp3=nullptr; // MCAuto newConn=DataArrayIdType::New(); newConn->alloc(0,1); MCAuto newConnI=DataArrayIdType::New(); newConnI->alloc(1,1); newConnI->setIJ(0,0,0); @@ -1087,26 +1087,26 @@ DataArrayIdType *MEDCouplingUMesh::convertLinearCellsToQuadratic2D1(DataArrayIdT // MCAuto bary=computeCellCenterOfMass(); const mcIdType *descPtr(desc->begin()),*descIPtr(descI->begin()); - DataArrayIdType *conn1D=0,*conn1DI=0; + DataArrayIdType *conn1D=nullptr,*conn1DI=nullptr; std::set types1D; - DataArrayDouble *coordsTmp=0; - MCAuto ret1D=m1D->convertLinearCellsToQuadratic1D0(conn1D,conn1DI,coordsTmp,types1D); ret1D=0; + DataArrayDouble *coordsTmp=nullptr; + MCAuto ret1D=m1D->convertLinearCellsToQuadratic1D0(conn1D,conn1DI,coordsTmp,types1D); ret1D=nullptr; MCAuto coordsTmpSafe(coordsTmp); MCAuto conn1DSafe(conn1D),conn1DISafe(conn1DI); const mcIdType *c1DPtr=conn1D->begin(); const mcIdType *c1DIPtr=conn1DI->begin(); - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbOfCells=getNumberOfCells(); const mcIdType *cPtr=_nodal_connec->begin(); const mcIdType *icPtr=_nodal_connec_index->begin(); mcIdType lastVal=0; - mcIdType offset=coordsTmpSafe->getNumberOfTuples(); + mcIdType const offset=coordsTmpSafe->getNumberOfTuples(); for(mcIdType i=0;ipushBackSilent(typ2); newConn->pushBackValsSilent(cPtr+icPtr[0]+1,cPtr+icPtr[1]); for(const mcIdType *d=descPtr+descIPtr[0];d!=descPtr+descIPtr[1];d++) @@ -1137,16 +1137,16 @@ DataArrayIdType *MEDCouplingUMesh::convertLinearCellsToQuadratic2D1(DataArrayIdT DataArrayIdType *MEDCouplingUMesh::convertLinearCellsToQuadratic3D0(DataArrayIdType *&conn, DataArrayIdType *&connI, DataArrayDouble *& coords, std::set& types) const { MCAuto desc(DataArrayIdType::New()),descI(DataArrayIdType::New()),tmp2(DataArrayIdType::New()),tmp3(DataArrayIdType::New()); - MCAuto m1D=explode3DMeshTo1D(desc,descI,tmp2,tmp3); tmp2=0; tmp3=0; + MCAuto m1D=explode3DMeshTo1D(desc,descI,tmp2,tmp3); tmp2=nullptr; tmp3=nullptr; return convertLinearCellsToQuadratic2DAnd3D0(m1D,desc,descI,conn,connI,coords,types); } DataArrayIdType *MEDCouplingUMesh::convertLinearCellsToQuadratic3D1(DataArrayIdType *&conn, DataArrayIdType *&connI, DataArrayDouble *& coords, std::set& types) const { MCAuto desc2(DataArrayIdType::New()),desc2I(DataArrayIdType::New()),tmp2(DataArrayIdType::New()),tmp3(DataArrayIdType::New()); - MCAuto m2D=buildDescendingConnectivityGen(desc2,desc2I,tmp2,tmp3,MEDCouplingFastNbrer); tmp2=0; tmp3=0; + MCAuto m2D=buildDescendingConnectivityGen(desc2,desc2I,tmp2,tmp3,MEDCouplingFastNbrer); tmp2=nullptr; tmp3=nullptr; MCAuto desc1(DataArrayIdType::New()),desc1I(DataArrayIdType::New()),tmp4(DataArrayIdType::New()),tmp5(DataArrayIdType::New()); - MCAuto m1D=explode3DMeshTo1D(desc1,desc1I,tmp4,tmp5); tmp4=0; tmp5=0; + MCAuto m1D=explode3DMeshTo1D(desc1,desc1I,tmp4,tmp5); tmp4=nullptr; tmp5=nullptr; // MCAuto newConn=DataArrayIdType::New(); newConn->alloc(0,1); MCAuto newConnI=DataArrayIdType::New(); newConnI->alloc(1,1); newConnI->setIJ(0,0,0); @@ -1154,9 +1154,9 @@ DataArrayIdType *MEDCouplingUMesh::convertLinearCellsToQuadratic3D1(DataArrayIdT // MCAuto bary=computeCellCenterOfMass(); const mcIdType *descPtr(desc1->begin()),*descIPtr(desc1I->begin()),*desc2Ptr(desc2->begin()),*desc2IPtr(desc2I->begin()); - DataArrayIdType *conn1D=0,*conn1DI=0,*conn2D=0,*conn2DI=0; + DataArrayIdType *conn1D=nullptr,*conn1DI=nullptr,*conn2D=nullptr,*conn2DI=nullptr; std::set types1D,types2D; - DataArrayDouble *coordsTmp=0,*coordsTmp2=0; + DataArrayDouble *coordsTmp=nullptr,*coordsTmp2=nullptr; MCAuto ret1D=m1D->convertLinearCellsToQuadratic1D0(conn1D,conn1DI,coordsTmp,types1D); ret1D=DataArrayIdType::New(); ret1D->alloc(0,1); MCAuto conn1DSafe(conn1D),conn1DISafe(conn1DI); MCAuto coordsTmpSafe(coordsTmp); @@ -1164,18 +1164,18 @@ DataArrayIdType *MEDCouplingUMesh::convertLinearCellsToQuadratic3D1(DataArrayIdT MCAuto coordsTmp2Safe(coordsTmp2); MCAuto conn2DSafe(conn2D),conn2DISafe(conn2DI); const mcIdType *c1DPtr=conn1D->begin(),*c1DIPtr=conn1DI->begin(),*c2DPtr=conn2D->begin(),*c2DIPtr=conn2DI->begin(); - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbOfCells=getNumberOfCells(); const mcIdType *cPtr=_nodal_connec->begin(); const mcIdType *icPtr=_nodal_connec_index->begin(); mcIdType lastVal=0; mcIdType offset=coordsTmpSafe->getNumberOfTuples(); for(mcIdType i=0;ipushBackSilent(c1DPtr[c1DIPtr[*d]+3]); for(const mcIdType *d=desc2Ptr+desc2IPtr[0];d!=desc2Ptr+desc2IPtr[1];d++) { - mcIdType nodeId2=c2DPtr[c2DIPtr[(*d)+1]-1]; - mcIdType tmpPos=newConn->getNumberOfTuples(); + mcIdType const nodeId2=c2DPtr[c2DIPtr[(*d)+1]-1]; + mcIdType const tmpPos=newConn->getNumberOfTuples(); newConn->pushBackSilent(nodeId2); ret2D->pushBackSilent(nodeId2); ret1D->pushBackSilent(tmpPos); } @@ -1215,15 +1215,15 @@ DataArrayIdType *MEDCouplingUMesh::convertLinearCellsToQuadratic3D1(DataArrayIdT for(const mcIdType *elt=ret1D->begin();elt!=ret1D->end();elt++) c[*elt]=o2nRet2D->getIJ(c[*elt],0)+offset; offset=coordsTmp2Safe->getNumberOfTuples(); - for(const mcIdType *elt=ret->begin();elt!=ret->end();elt++) - c[cI[(*elt)+1]-1]+=offset; + for(long const elt : *ret) + c[cI[elt+1]-1]+=offset; coords=DataArrayDouble::Aggregate(v); conn=newConn.retn(); connI=newConnI.retn(); return ret.retn(); } DataArrayIdType *MEDCouplingUMesh::buildUnionOf2DMeshLinear(const MEDCouplingUMesh *skin, const DataArrayIdType *n2o) const { - mcIdType nbOfNodesExpected(skin->getNumberOfNodes()); + mcIdType const nbOfNodesExpected(skin->getNumberOfNodes()); const mcIdType *n2oPtr(n2o->begin()); MCAuto revNodal(DataArrayIdType::New()),revNodalI(DataArrayIdType::New()); skin->getReverseNodalConnectivity(revNodal,revNodalI); @@ -1244,7 +1244,7 @@ DataArrayIdType *MEDCouplingUMesh::buildUnionOf2DMeshLinear(const MEDCouplingUMe conn.erase(prevNode); if(conn.size()==1) { - mcIdType curNode(*(conn.begin())); + mcIdType const curNode(*(conn.begin())); *work++=n2oPtr[curNode]; std::set shar(revNodalPtr+revNodalIPtr[curNode],revNodalPtr+revNodalIPtr[curNode+1]); shar.erase(prevCell); @@ -1267,8 +1267,8 @@ DataArrayIdType *MEDCouplingUMesh::buildUnionOf2DMeshLinear(const MEDCouplingUMe DataArrayIdType *MEDCouplingUMesh::buildUnionOf2DMeshQuadratic(const MEDCouplingUMesh *skin, const DataArrayIdType *n2o) const { - mcIdType nbOfNodesExpected(skin->getNumberOfNodes()); - mcIdType nbOfTurn(nbOfNodesExpected/2); + mcIdType const nbOfNodesExpected(skin->getNumberOfNodes()); + mcIdType const nbOfTurn(nbOfNodesExpected/2); const mcIdType *n2oPtr(n2o->begin()); MCAuto revNodal(DataArrayIdType::New()),revNodalI(DataArrayIdType::New()); skin->getReverseNodalConnectivity(revNodal,revNodalI); @@ -1289,13 +1289,13 @@ DataArrayIdType *MEDCouplingUMesh::buildUnionOf2DMeshQuadratic(const MEDCoupling conn.erase(prevNode); if(conn.size()==1) { - mcIdType curNode(*(conn.begin())); + mcIdType const curNode(*(conn.begin())); *work=n2oPtr[curNode]; std::set shar(revNodalPtr+revNodalIPtr[curNode],revNodalPtr+revNodalIPtr[curNode+1]); shar.erase(prevCell); if(shar.size()==1) { - mcIdType curCell(*(shar.begin())); + mcIdType const curCell(*(shar.begin())); work[nbOfTurn]=n2oPtr[nodalPtr[nodalIPtr[curCell]+3]]; prevCell=curCell; prevNode=curNode; @@ -1342,8 +1342,8 @@ void MEDCouplingUMesh::DeleteCellTypeInIndexedArray(const DataArrayIdType *arrIn *outArrIndxPtr++ = 0; for( mcIdType i = 0 ; i < arrIndxNbTuples - 1 ; ++i ) { - mcIdType startPos(*inArrIndxPtr++); - mcIdType endPos(*inArrIndxPtr); + mcIdType const startPos(*inArrIndxPtr++); + mcIdType const endPos(*inArrIndxPtr); if(inArrPtr[startPos] == INTERP_KERNEL::NORM_POLYHED) { presenceOfPolyh = true; @@ -1363,8 +1363,8 @@ void MEDCouplingUMesh::DeleteCellTypeInIndexedArray(const DataArrayIdType *arrIn *outArrIndxPtr++ = 0; for( mcIdType i = 0 ; i < arrIndxNbTuples - 1 ; ++i,++outArrIndxPtr ) { - mcIdType startPos(*inArrIndxPtr++); - mcIdType endPos(*inArrIndxPtr); + mcIdType const startPos(*inArrIndxPtr++); + mcIdType const endPos(*inArrIndxPtr); if(inArrPtr[startPos] != INTERP_KERNEL::NORM_POLYHED) { arrOut->insertAtTheEnd(inArrPtr+startPos+1,inArrPtr+endPos); @@ -1385,8 +1385,8 @@ MEDCouplingUMesh *MEDCouplingUMesh::MergeUMeshesLL(const std::vector::const_iterator it=a.begin(); - int meshDim=(*it)->getMeshDimension(); + auto it=a.begin(); + int const meshDim=(*it)->getMeshDimension(); mcIdType nbOfCells=ToIdType((*it)->getNumberOfCells()); mcIdType meshLgth=(*it++)->getNodalConnectivityArrayLen(); for(;it!=a.end();it++) @@ -1412,7 +1412,7 @@ MEDCouplingUMesh *MEDCouplingUMesh::MergeUMeshesLL(const std::vectorgetNumberOfCells()); + mcIdType const curNbOfCell=ToIdType((*it)->getNumberOfCells()); const mcIdType *curCI=(*it)->_nodal_connec_index->begin(); const mcIdType *curC=(*it)->_nodal_connec->begin(); cIPtr=std::transform(curCI+1,curCI+curNbOfCell+1,cIPtr,std::bind(std::plus(),std::placeholders::_1,offset)); @@ -1457,7 +1457,7 @@ void MEDCouplingUMesh::DistanceToPoint3DSurfAlg(const double *pt, const mcIdType { case INTERP_KERNEL::NORM_TRI3: { - double tmp=INTERP_KERNEL::DistanceFromPtToTriInSpaceDim3(pt,coords+3*nc[ncI[*zeCell]+1],coords+3*nc[ncI[*zeCell]+2],coords+3*nc[ncI[*zeCell]+3]); + double const tmp=INTERP_KERNEL::DistanceFromPtToTriInSpaceDim3(pt,coords+3*nc[ncI[*zeCell]+1],coords+3*nc[ncI[*zeCell]+2],coords+3*nc[ncI[*zeCell]+3]); if(tmpgetNumberOfTuples()-1; + mcIdType const nbOfTuples=arrIndxIn->getNumberOfTuples()-1; std::vector fetched2(nbOfTuples,false); int i=0; for(const mcIdType *seedElt=seedBg;seedElt!=seedEnd;seedElt++,i++) @@ -1525,22 +1525,22 @@ DataArrayIdType *MEDCouplingUMesh::ComputeSpreadZoneGraduallyFromSeedAlg(std::ve } const mcIdType *arrInPtr=arrIn->begin(); const mcIdType *arrIndxPtr=arrIndxIn->begin(); - mcIdType targetNbOfDepthPeeling=nbOfDepthPeeling!=-1?nbOfDepthPeeling:std::numeric_limits::max(); + mcIdType const targetNbOfDepthPeeling=nbOfDepthPeeling!=-1?nbOfDepthPeeling:std::numeric_limits::max(); std::vector idsToFetch1(seedBg,seedEnd); std::vector idsToFetch2; std::vector *idsToFetch=&idsToFetch1; std::vector *idsToFetchOther=&idsToFetch2; while(!idsToFetch->empty() && nbOfDepthPeelingPerformed::const_iterator it=idsToFetch->begin();it!=idsToFetch->end();it++) - for(const mcIdType *it2=arrInPtr+arrIndxPtr[*it];it2!=arrInPtr+arrIndxPtr[*it+1];it2++) + for(long const it : *idsToFetch) + for(const mcIdType *it2=arrInPtr+arrIndxPtr[it];it2!=arrInPtr+arrIndxPtr[it+1];it2++) if(!fetched[*it2]) { fetched[*it2]=true; fetched2[*it2]=true; idsToFetchOther->push_back(*it2); } std::swap(idsToFetch,idsToFetchOther); idsToFetchOther->clear(); nbOfDepthPeelingPerformed++; } - mcIdType lgth=ToIdType(std::count(fetched2.begin(),fetched2.end(),true)); + mcIdType const lgth=ToIdType(std::count(fetched2.begin(),fetched2.end(),true)); i=0; MCAuto ret=DataArrayIdType::New(); ret->alloc(lgth,1); mcIdType *retPtr=ret->getPointer(); @@ -1580,10 +1580,10 @@ void MEDCouplingUMesh::FillInCompact3DMode(int spaceDim, mcIdType nbOfNodesInCel */ void MEDCouplingUMesh::AppendExtrudedCell(const mcIdType *connBg, const mcIdType *connEnd, mcIdType nbOfNodesPerLev, bool isQuad, std::vector& ret) { - INTERP_KERNEL::NormalizedCellType flatType=(INTERP_KERNEL::NormalizedCellType)connBg[0]; + auto const flatType=(INTERP_KERNEL::NormalizedCellType)connBg[0]; const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(flatType); ret.push_back(cm.getExtrudedType()); - mcIdType deltaz=isQuad?2*nbOfNodesPerLev:nbOfNodesPerLev; + mcIdType const deltaz=isQuad?2*nbOfNodesPerLev:nbOfNodesPerLev; switch(flatType) { case INTERP_KERNEL::NORM_POINT1: @@ -1638,10 +1638,10 @@ void MEDCouplingUMesh::AppendExtrudedCell(const mcIdType *connBg, const mcIdType std::back_insert_iterator< std::vector > ii(ret); std::copy(connBg+1,connEnd,ii); *ii++=-1; - std::reverse_iterator rConnBg(connEnd); - std::reverse_iterator rConnEnd(connBg+1); + std::reverse_iterator const rConnBg(connEnd); + std::reverse_iterator const rConnEnd(connBg+1); std::transform(rConnBg,rConnEnd,ii,std::bind(std::plus(),std::placeholders::_1,deltaz)); - std::size_t nbOfRadFaces=std::distance(connBg+1,connEnd); + std::size_t const nbOfRadFaces=std::distance(connBg+1,connEnd); for(std::size_t i=0;i& const mcIdType *desc, const mcIdType *descIndx, std::vector< std::pair >& cut3DSurf) { - std::set nodesOnP(nodesOnPlane.begin(),nodesOnPlane.end()); - mcIdType nbOf3DSurfCell=ToIdType(cut3DSurf.size()); + std::set const nodesOnP(nodesOnPlane.begin(),nodesOnPlane.end()); + mcIdType const nbOf3DSurfCell=ToIdType(cut3DSurf.size()); for(mcIdType i=0;i res; - mcIdType offset=descIndx[i]; - mcIdType nbOfSeg=descIndx[i+1]-offset; + mcIdType const offset=descIndx[i]; + mcIdType const nbOfSeg=descIndx[i+1]-offset; for(mcIdType j=0;j-1) @@ -1716,7 +1716,7 @@ void MEDCouplingUMesh::AssemblyForSplitFrom3DCurve(const std::vector& case 1: case 0: { - std::set s1(nodal3DSurf+nodalIndx3DSurf[i]+1,nodal3DSurf+nodalIndx3DSurf[i+1]); + std::set const s1(nodal3DSurf+nodalIndx3DSurf[i]+1,nodal3DSurf+nodalIndx3DSurf[i+1]); std::set_intersection(nodesOnP.begin(),nodesOnP.end(),s1.begin(),s1.end(),std::back_insert_iterator< std::vector >(res)); if(res.size()==2) { @@ -1759,12 +1759,12 @@ void MEDCouplingUMesh::assemblyForSplitFrom3DSurf(const std::vector< std::pairbegin()),*nodalIndx3D(_nodal_connec_index->begin()); - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbOfCells=getNumberOfCells(); for(mcIdType i=0;i > m; - mcIdType offset=descIndx[i]; - mcIdType nbOfFaces=descIndx[i+1]-offset; + mcIdType const offset=descIndx[i]; + mcIdType const nbOfFaces=descIndx[i+1]-offset; mcIdType start=-1; mcIdType end=-1; for(int j=0;j tmp=new mcIdType[sz]; INTERP_KERNEL::NormalizedCellType cmsId; - unsigned nbOfNodesSon=cm.fillSonCellNodalConnectivity2(j,nodal3D+nodalIndx3D[i]+1,sz,tmp,cmsId); + unsigned const nbOfNodesSon=cm.fillSonCellNodalConnectivity2(j,nodal3D+nodalIndx3D[i]+1,sz,tmp,cmsId); start=tmp[0]; end=tmp[nbOfNodesSon-1]; for(unsigned k=0;k >::const_iterator it=m.find(start); + std::map >::const_iterator const it=m.find(start); const std::set& s=(*it).second; std::set s2; s2.insert(prev); std::set s3; std::set_difference(s.begin(),s.end(),s2.begin(),s2.end(),inserter(s3,s3.begin())); if(s3.size()==1) { - mcIdType val=*s3.begin(); + mcIdType const val=*s3.begin(); conn.push_back(start); prev=start; start=val; @@ -1832,7 +1832,7 @@ void MEDCouplingUMesh::ComputeAllTypesInternal(std::setbegin()),*connIndex(nodalConnecIndex->begin()); - mcIdType nbOfElem=ToIdType(nodalConnecIndex->getNbOfElems())-1; + mcIdType const nbOfElem=ToIdType(nodalConnecIndex->getNbOfElems())-1; if(nbOfElem>0) for(const mcIdType *pt=connIndex;pt!=connIndex+nbOfElem;pt++) types.insert((INTERP_KERNEL::NormalizedCellType)conn[*pt]); @@ -1855,7 +1855,7 @@ void MEDCouplingUMesh::ComputeAllTypesInternal(std::set edges; @@ -1875,15 +1875,15 @@ void MEDCouplingUMesh::attractSeg3MidPtsAroundNodes(double ratio, const mcIdType */ void MEDCouplingUMesh::attractSeg3MidPtsAroundNodesUnderground(double ratio, const mcIdType *nodeIdsBg, const mcIdType *nodeIdsEnd) { - int spaceDim(getSpaceDimension()); + int const spaceDim(getSpaceDimension()); double *coords(getCoords()->getPointer()); auto nbNodes(getNumberOfNodes()); - std::size_t nbCells(getNumberOfCells()); + std::size_t const nbCells(getNumberOfCells()); std::vector fastFinder(nbNodes,false); for(auto work=nodeIdsBg;work!=nodeIdsEnd;work++) if(*work>=0 && *work cellsIds(getCellIdsLyingOnNodes(nodeIdsBg,nodeIdsEnd,false)); + MCAuto const cellsIds(getCellIdsLyingOnNodes(nodeIdsBg,nodeIdsEnd,false)); const mcIdType *nc(_nodal_connec->begin()),*nci(_nodal_connec_index->begin()); for(std::size_t cellId=0;cellId +#include +#include +#include +#include +#include +#include #include -#include -#include #include #include -#include #include +#include +#include using namespace MEDCoupling; @@ -56,7 +68,7 @@ mcIdType InternalAddPoint(const INTERP_KERNEL::Edge *e, mcIdType id, const doubl return id; else { - mcIdType ret(nodesCnter++); + mcIdType const ret(nodesCnter++); double newPt[2]; e->getMiddleOfPoints(coo+2*startId,coo+2*endId,newPt); addCoo.insertAtTheEnd(newPt,newPt+2); @@ -70,7 +82,7 @@ mcIdType InternalAddPointOriented(const INTERP_KERNEL::Edge *e, mcIdType id, con return id; else { - mcIdType ret(nodesCnter++); + mcIdType const ret(nodesCnter++); double newPt[2]; e->getMiddleOfPointsOriented(coo+2*startId,coo+2*endId,newPt); addCoo.insertAtTheEnd(newPt,newPt+2); @@ -82,7 +94,7 @@ mcIdType InternalAddPointOriented(const INTERP_KERNEL::Edge *e, mcIdType id, con void EnterTheResultOf2DCellFirst(const INTERP_KERNEL::Edge *e, int start, int stp, int nbOfEdges, bool linOrArc, const double *coords, const mcIdType *connBg, mcIdType offset, DataArrayIdType *newConnOfCell, DataArrayDouble *appendedCoords, std::vector& middles) { mcIdType tmp[3]; - int trueStart(start>=0?start:nbOfEdges+start); + int const trueStart(start>=0?start:nbOfEdges+start); tmp[0]=ToIdType(linOrArc?INTERP_KERNEL::NORM_QPOLYG:INTERP_KERNEL::NORM_POLYGON); tmp[1]=connBg[trueStart]; tmp[2]=connBg[stp]; newConnOfCell->insertAtTheEnd(tmp,tmp+3); if(linOrArc) @@ -115,7 +127,7 @@ void EnterTheResultOf2DCellMiddle(const INTERP_KERNEL::Edge *e, int start, int s } } -void EnterTheResultOf2DCellEnd(const INTERP_KERNEL::Edge *e, int start, int stp, int nbOfEdges, bool linOrArc, const double *coords, const mcIdType *connBg, mcIdType offset, DataArrayIdType *newConnOfCell, DataArrayDouble *appendedCoords, std::vector& middles) +void EnterTheResultOf2DCellEnd(const INTERP_KERNEL::Edge *e, int start, int stp, int nbOfEdges, bool linOrArc, const double *coords, const mcIdType *connBg, mcIdType offset, DataArrayIdType * /*newConnOfCell*/, DataArrayDouble *appendedCoords, std::vector& middles) { // only the quadratic point to deal with: if(linOrArc) @@ -135,10 +147,10 @@ void EnterTheResultOf2DCellEnd(const INTERP_KERNEL::Edge *e, int start, int stp, void IKGeo2DInternalMapper2(INTERP_KERNEL::Node *n, const std::map,mcIdType>& m, mcIdType forbVal0, mcIdType forbVal1, std::vector& isect) { MCAuto nTmp(n); nTmp->incrRef(); - std::map,mcIdType>::const_iterator it(m.find(nTmp)); + auto const it(m.find(nTmp)); if(it==m.end()) throw INTERP_KERNEL::Exception("Internal error in remapping !"); - mcIdType v((*it).second); + mcIdType const v((*it).second); if(v==forbVal0 || v==forbVal1) return ; if(std::find(isect.begin(),isect.end(),v)==isect.end()) @@ -147,10 +159,10 @@ void IKGeo2DInternalMapper2(INTERP_KERNEL::Node *n, const std::map,mcIdType>& m, mcIdType forbVal0, mcIdType forbVal1, std::vector& isect) { - int sz(c.size()); + int const sz(c.size()); if(sz<=1) return false; - bool presenceOfOn(false); + bool const presenceOfOn(false); for(int i=0;i,mcIdType>& m) { - INTERP_KERNEL::Edge *ret(0); + INTERP_KERNEL::Edge *ret(nullptr); MCAuto n0(new INTERP_KERNEL::Node(coords2D[2*bg[0]],coords2D[2*bg[0]+1])),n1(new INTERP_KERNEL::Node(coords2D[2*bg[1]],coords2D[2*bg[1]+1])); m[n0]=bg[0]; m[n1]=bg[1]; switch(typ) @@ -180,11 +192,11 @@ namespace MEDCoupling } case INTERP_KERNEL::NORM_SEG3: { - INTERP_KERNEL::Node *n2(new INTERP_KERNEL::Node(coords2D[2*bg[2]],coords2D[2*bg[2]+1])); m[n2]=bg[2]; - INTERP_KERNEL::EdgeLin *e1(new INTERP_KERNEL::EdgeLin(n0,n2)),*e2(new INTERP_KERNEL::EdgeLin(n2,n1)); - INTERP_KERNEL::SegSegIntersector inters(*e1,*e2); + auto *n2(new INTERP_KERNEL::Node(coords2D[2*bg[2]],coords2D[2*bg[2]+1])); m[n2]=bg[2]; + auto *e1(new INTERP_KERNEL::EdgeLin(n0,n2)),*e2(new INTERP_KERNEL::EdgeLin(n2,n1)); + INTERP_KERNEL::SegSegIntersector const inters(*e1,*e2); // is the SEG3 degenerated, and thus can be reduced to a SEG2? - bool colinearity(inters.areColinears()); + bool const colinearity(inters.areColinears()); delete e1; delete e2; if(colinearity) { ret=new INTERP_KERNEL::EdgeLin(n0,n1); } @@ -200,7 +212,7 @@ namespace MEDCoupling INTERP_KERNEL::Edge *MEDCouplingUMeshBuildQPFromEdge(INTERP_KERNEL::NormalizedCellType typ, std::map& mapp2, const mcIdType *bg) { - INTERP_KERNEL::Edge *ret=0; + INTERP_KERNEL::Edge *ret=nullptr; mapp2[bg[0]].second = INTERP_KERNEL::USAGE_LINEAR; mapp2[bg[1]].second = INTERP_KERNEL::USAGE_LINEAR; @@ -214,11 +226,11 @@ namespace MEDCoupling } case INTERP_KERNEL::NORM_SEG3: { - INTERP_KERNEL::EdgeLin *e1=new INTERP_KERNEL::EdgeLin(mapp2[bg[0]].first,mapp2[bg[2]].first); - INTERP_KERNEL::EdgeLin *e2=new INTERP_KERNEL::EdgeLin(mapp2[bg[2]].first,mapp2[bg[1]].first); - INTERP_KERNEL::SegSegIntersector inters(*e1,*e2); + auto *e1=new INTERP_KERNEL::EdgeLin(mapp2[bg[0]].first,mapp2[bg[2]].first); + auto *e2=new INTERP_KERNEL::EdgeLin(mapp2[bg[2]].first,mapp2[bg[1]].first); + INTERP_KERNEL::SegSegIntersector const inters(*e1,*e2); // is the SEG3 degenerated, and thus can be reduced to a SEG2? - bool colinearity=inters.areColinears(); + bool const colinearity=inters.areColinears(); delete e1; delete e2; if(colinearity) ret=new INTERP_KERNEL::EdgeLin(mapp2[bg[0]].first,mapp2[bg[1]].first); @@ -249,18 +261,18 @@ namespace MEDCoupling const mcIdType *c=mDesc->getNodalConnectivity()->getConstPointer(); const mcIdType *cI=mDesc->getNodalConnectivityIndex()->getConstPointer(); std::set s; - for(std::vector::const_iterator it=candidates.begin();it!=candidates.end();it++) - s.insert(c+cI[*it]+1,c+cI[(*it)+1]); - for(std::set::const_iterator it2=s.begin();it2!=s.end();it2++) + for(long const candidate : candidates) + s.insert(c+cI[candidate]+1,c+cI[candidate+1]); + for(long const it2 : s) { - INTERP_KERNEL::Node *n=new INTERP_KERNEL::Node(coo[2*(*it2)],coo[2*(*it2)+1]); - mapp2[*it2]=INTERP_KERNEL::NodeWithUsage(n,INTERP_KERNEL::USAGE_UNKNOWN); + auto *n=new INTERP_KERNEL::Node(coo[2*it2],coo[2*it2+1]); + mapp2[it2]=INTERP_KERNEL::NodeWithUsage(n,INTERP_KERNEL::USAGE_UNKNOWN); } - INTERP_KERNEL::QuadraticPolygon *ret=new INTERP_KERNEL::QuadraticPolygon; - for(std::vector::const_iterator it=candidates.begin();it!=candidates.end();it++) + auto *ret=new INTERP_KERNEL::QuadraticPolygon; + for(long const candidate : candidates) { - INTERP_KERNEL::NormalizedCellType typ=(INTERP_KERNEL::NormalizedCellType)c[cI[*it]]; - ret->pushBack(MEDCouplingUMeshBuildQPFromEdge(typ,mapp2,c+cI[*it]+1)); + auto const typ=(INTERP_KERNEL::NormalizedCellType)c[cI[candidate]]; + ret->pushBack(MEDCouplingUMeshBuildQPFromEdge(typ,mapp2,c+cI[candidate]+1)); } for(std::map::const_iterator it2=mapp2.begin();it2!=mapp2.end();it2++) { @@ -282,14 +294,14 @@ namespace MEDCoupling const mcIdType *c=mDesc->getNodalConnectivity()->getConstPointer(); const mcIdType *cI=mDesc->getNodalConnectivityIndex()->getConstPointer(); std::set s; - for(std::vector::const_iterator it=candidates.begin();it!=candidates.end();it++) - s.insert(c+cI[*it]+1,c+cI[(*it)+1]); - for(std::set::const_iterator it2=s.begin();it2!=s.end();it2++) + for(long const candidate : candidates) + s.insert(c+cI[candidate]+1,c+cI[candidate+1]); + for(long const it2 : s) { INTERP_KERNEL::Node *n; // Look for a potential node to merge std::vector candNode; - nodeTree.getElementsAroundPoint(coo+2*(*it2), candNode); + nodeTree.getElementsAroundPoint(coo+2*it2, candNode); if (candNode.size() > 2) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::MEDCouplingUMeshBuildQPFromMeshWithTree(): some nodes are not properly merged (within eps) in input mesh!"); bool node_created=false; @@ -304,14 +316,14 @@ namespace MEDCoupling } } if(!node_created) - n = new INTERP_KERNEL::Node(coo[2*(*it2)],coo[2*(*it2)+1]); - mapp2[*it2]=INTERP_KERNEL::NodeWithUsage(n,INTERP_KERNEL::USAGE_UNKNOWN); + n = new INTERP_KERNEL::Node(coo[2*it2],coo[2*it2+1]); + mapp2[it2]=INTERP_KERNEL::NodeWithUsage(n,INTERP_KERNEL::USAGE_UNKNOWN); } - INTERP_KERNEL::QuadraticPolygon *ret=new INTERP_KERNEL::QuadraticPolygon; - for(std::vector::const_iterator it=candidates.begin();it!=candidates.end();it++) + auto *ret=new INTERP_KERNEL::QuadraticPolygon; + for(long const candidate : candidates) { - INTERP_KERNEL::NormalizedCellType typ=(INTERP_KERNEL::NormalizedCellType)c[cI[*it]]; - ret->pushBack(MEDCouplingUMeshBuildQPFromEdge(typ,mapp2,c+cI[*it]+1)); // this call will set quad points to false in the map + auto const typ=(INTERP_KERNEL::NormalizedCellType)c[cI[candidate]]; + ret->pushBack(MEDCouplingUMeshBuildQPFromEdge(typ,mapp2,c+cI[candidate]+1)); // this call will set quad points to false in the map } for(std::map::const_iterator it2=mapp2.begin();it2!=mapp2.end();it2++) { @@ -326,12 +338,12 @@ namespace MEDCoupling { if(nodeId>=offset2) { - mcIdType locId=nodeId-offset2; + mcIdType const locId=nodeId-offset2; return new INTERP_KERNEL::Node(addCoo[2*locId],addCoo[2*locId+1]); } if(nodeId>=offset1) { - mcIdType locId=nodeId-offset1; + mcIdType const locId=nodeId-offset1; return new INTERP_KERNEL::Node(coo2[2*locId],coo2[2*locId+1]); } return new INTERP_KERNEL::Node(coo1[2*nodeId],coo1[2*nodeId+1]); @@ -346,15 +358,15 @@ namespace MEDCoupling { for(const mcIdType *desc1=desc1Bg;desc1!=desc1End;desc1++) { - mcIdType eltId1=std::abs(*desc1)-1; - for(std::vector::const_iterator it1=intesctEdges1[eltId1].begin();it1!=intesctEdges1[eltId1].end();it1++) + mcIdType const eltId1=std::abs(*desc1)-1; + for(long const it1 : intesctEdges1[eltId1]) { - std::map::const_iterator it=mappRev.find(*it1); + std::map::const_iterator const it=mappRev.find(it1); if(it==mappRev.end()) { - INTERP_KERNEL::Node *node=MEDCouplingUMeshBuildQPNode(*it1,coo1,offset1,coo2,offset2,addCoo); - mapp[node]=*it1; - mappRev[*it1]=node; + INTERP_KERNEL::Node *node=MEDCouplingUMeshBuildQPNode(it1,coo1,offset1,coo2,offset2,addCoo); + mapp[node]=it1; + mappRev[it1]=node; } } } @@ -379,7 +391,7 @@ bool MEDCouplingUMesh::Colinearize2DCell(const double *coords, const mcIdType *c INTERP_KERNEL::AutoPtr tmpConn(new mcIdType[sz]); INTERP_KERNEL::AutoPtr tmpConn2(new mcIdType[sz]); const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel((INTERP_KERNEL::NormalizedCellType)connBg[0])); - unsigned nbs(cm.getNumberOfSons2(connBg+1,ToIdType(sz))); + unsigned const nbs(cm.getNumberOfSons2(connBg+1,ToIdType(sz))); unsigned nbOfHit(0); // number of fusions operated int posBaseElt(0),posEndElt(0),nbOfTurn(0); const std::size_t maxNbOfHit = cm.isQuadratic() ? nbs-2 : nbs-3; // a quad cell is authorized to end up with only two edges, a linear one has to keep 3 at least @@ -401,13 +413,13 @@ bool MEDCouplingUMesh::Colinearize2DCell(const double *coords, const mcIdType *c { cm.fillSonCellNodalConnectivity2(nbs-i,connBg+1,ToIdType(sz),tmpConn2,typeOfSon); // Identify common point: - mcIdType commPoint = std::find((mcIdType *)tmpConn, tmpConn+2, tmpConn2[0]) != tmpConn+2 ? tmpConn2[0] : tmpConn2[1]; + mcIdType const commPoint = std::find((mcIdType *)tmpConn, tmpConn+2, tmpConn2[0]) != tmpConn+2 ? tmpConn2[0] : tmpConn2[1]; auto itE(forbiddenPoints.end()); if (forbiddenPoints.find(commPoint) != itE) // is the junction point in the list of points we can not remove? break; INTERP_KERNEL::Edge *eCand(MEDCouplingUMeshBuildQPFromEdge2(typeOfSon,tmpConn2,coords,m)); INTERP_KERNEL::EdgeIntersector *eint(INTERP_KERNEL::Edge::BuildIntersectorWith(e,eCand)); - bool isColinear=eint->areColinears(); + bool const isColinear=eint->areColinears(); if(isColinear) { nbOfHit++; @@ -428,13 +440,13 @@ bool MEDCouplingUMesh::Colinearize2DCell(const double *coords, const mcIdType *c { cm.fillSonCellNodalConnectivity2(j,connBg+1,ToIdType(sz),tmpConn2,typeOfSon); // get edge #j's connectivity // Identify common point: - mcIdType commPoint = std::find((mcIdType *)tmpConn, tmpConn+2, tmpConn2[0]) != tmpConn+2 ? tmpConn2[0] : tmpConn2[1]; + mcIdType const commPoint = std::find((mcIdType *)tmpConn, tmpConn+2, tmpConn2[0]) != tmpConn+2 ? tmpConn2[0] : tmpConn2[1]; auto itE(forbiddenPoints.end()); if (forbiddenPoints.find(commPoint) != itE) // is the junction point in the list of points we can not remove? break; INTERP_KERNEL::Edge *eCand(MEDCouplingUMeshBuildQPFromEdge2(typeOfSon,tmpConn2,coords,m)); INTERP_KERNEL::EdgeIntersector *eint(INTERP_KERNEL::Edge::BuildIntersectorWith(e,eCand)); - bool isColinear(eint->areColinears()); + bool const isColinear(eint->areColinears()); if(isColinear) { nbOfHit++; @@ -473,19 +485,19 @@ bool IsColinearOfACellOf(const std::vector< std::vector >& intersectEd { if(candidates.empty()) return false; - for(std::vector::const_iterator it=candidates.begin();it!=candidates.end();it++) + for(long const candidate : candidates) { - const std::vector& pool(intersectEdge1[*it]); + const std::vector& pool(intersectEdge1[candidate]); mcIdType tmp[2]; tmp[0]=start; tmp[1]=stop; if(std::search(pool.begin(),pool.end(),tmp,tmp+2)!=pool.end()) { - retVal=*it+1; + retVal=candidate+1; return true; } tmp[0]=stop; tmp[1]=start; if(std::search(pool.begin(),pool.end(),tmp,tmp+2)!=pool.end()) { - retVal=-*it-1; + retVal=-candidate-1; return true; } } @@ -510,24 +522,24 @@ void MEDCouplingUMesh::BuildIntersectEdges(const MEDCouplingUMesh *m1, const MED const std::vector& addCoo, const std::vector< std::vector >& subDiv, std::vector< std::vector >& intersectEdge) { - mcIdType offset1=m1->getNumberOfNodes(); - mcIdType ncell2=m2->getNumberOfCells(); + mcIdType const offset1=m1->getNumberOfNodes(); + mcIdType const ncell2=m2->getNumberOfCells(); const mcIdType *c=m2->getNodalConnectivity()->begin(); const mcIdType *cI=m2->getNodalConnectivityIndex()->begin(); const double *coo=m2->getCoords()->begin(); const double *cooBis=m1->getCoords()->begin(); - mcIdType offset2=offset1+m2->getNumberOfNodes(); + mcIdType const offset2=offset1+m2->getNumberOfNodes(); intersectEdge.resize(ncell2); for(mcIdType i=0;i& divs=subDiv[i]; - mcIdType nnode=cI[1]-cI[0]-1; + mcIdType const nnode=cI[1]-cI[0]-1; std::map mapp2; std::map mapp22; for(mcIdType j=0;j mapp3; for(std::size_t j=0;jsortIdsAbs(addNodes,mapp22,mapp3,intersectEdge[i]); - for(std::vector::const_iterator it=addNodes.begin();it!=addNodes.end();it++) - (*it)->decrRef(); + for(auto addNode : addNodes) + addNode->decrRef(); e->decrRef(); } } @@ -569,15 +581,15 @@ MEDCouplingUMesh *BuildMesh1DCutFrom(const MEDCouplingUMesh *mesh1D, const std:: { idsInRetColinear=DataArrayIdType::New(); idsInRetColinear->alloc(0,1); idsInMesh1DForIdsInRetColinear=DataArrayIdType::New(); idsInMesh1DForIdsInRetColinear->alloc(0,1); - mcIdType nCells=mesh1D->getNumberOfCells(); + mcIdType const nCells=mesh1D->getNumberOfCells(); if(nCells!=ToIdType(intersectEdge2.size())) throw INTERP_KERNEL::Exception("BuildMesh1DCutFrom : internal error # 1 !"); const DataArrayDouble *coo2(mesh1D->getCoords()); const mcIdType *c(mesh1D->getNodalConnectivity()->begin()),*ci(mesh1D->getNodalConnectivityIndex()->begin()); const double *coo2Ptr(coo2->begin()); - mcIdType offset1(coords1->getNumberOfTuples()); - mcIdType offset2(offset1+coo2->getNumberOfTuples()); - mcIdType offset3(offset2+ToIdType(addCoo.size())/2); + mcIdType const offset1(coords1->getNumberOfTuples()); + mcIdType const offset2(offset1+coo2->getNumberOfTuples()); + mcIdType const offset3(offset2+ToIdType(addCoo.size())/2); std::vector addCooQuad; MCAuto cOut(DataArrayIdType::New()),ciOut(DataArrayIdType::New()); cOut->alloc(0,1); ciOut->alloc(1,1); ciOut->setIJ(0,0,0); mcIdType tmp[4],cicnt(0),kk(0); @@ -586,7 +598,7 @@ MEDCouplingUMesh *BuildMesh1DCutFrom(const MEDCouplingUMesh *mesh1D, const std:: std::map,mcIdType> m; INTERP_KERNEL::Edge *e(MEDCouplingUMeshBuildQPFromEdge2((INTERP_KERNEL::NormalizedCellType)c[ci[i]],c+ci[i]+1,coo2Ptr,m)); const std::vector& subEdges(intersectEdge2[i]); - mcIdType nbSubEdge=ToIdType(subEdges.size()/2); + mcIdType const nbSubEdge=ToIdType(subEdges.size()/2); for(mcIdType j=0;j n1(MEDCouplingUMeshBuildQPNode(subEdges[2*j],coords1->begin(),offset1,coo2Ptr,offset2,addCoo)), @@ -652,10 +664,10 @@ MEDCouplingUMesh *BuildRefined2DCellLinear(const DataArrayDouble *coords, const else allEdges.insert(allEdges.end(),edge1.rbegin(),edge1.rend()); } - std::size_t nb(allEdges.size()); + std::size_t const nb(allEdges.size()); if(nb%2!=0) throw INTERP_KERNEL::Exception("BuildRefined2DCellLinear : internal error 1 !"); - std::size_t nbOfEdgesOf2DCellSplit(nb/2); + std::size_t const nbOfEdgesOf2DCellSplit(nb/2); MCAuto ret(MEDCouplingUMesh::New("",2)); ret->setCoords(coords); ret->allocateCells(1); @@ -671,14 +683,14 @@ MEDCouplingUMesh *BuildRefined2DCellQuadratic(const DataArrayDouble *coords, con const mcIdType *c(mesh2D->getNodalConnectivity()->begin()),*ci(mesh2D->getNodalConnectivityIndex()->begin()); const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel((INTERP_KERNEL::NormalizedCellType)c[ci[cellIdInMesh2D]])); int ii(0); - unsigned sz(cm.getNumberOfSons2(c+ci[cellIdInMesh2D]+1,ci[cellIdInMesh2D+1]-ci[cellIdInMesh2D]-1)); + unsigned const sz(cm.getNumberOfSons2(c+ci[cellIdInMesh2D]+1,ci[cellIdInMesh2D+1]-ci[cellIdInMesh2D]-1)); if(sz!=std::distance(descBg,descEnd)) throw INTERP_KERNEL::Exception("BuildRefined2DCellQuadratic : internal error 1 !"); INTERP_KERNEL::AutoPtr tmpPtr(new mcIdType[ci[cellIdInMesh2D+1]-ci[cellIdInMesh2D]]); std::vector allEdges,centers; const double *coordsPtr(coords->begin()); MCAuto addCoo(DataArrayDouble::New()); addCoo->alloc(0,1); - mcIdType offset(coords->getNumberOfTuples()); + mcIdType const offset(coords->getNumberOfTuples()); for(const mcIdType *it2(descBg);it2!=descEnd;it2++,ii++) { INTERP_KERNEL::NormalizedCellType typeOfSon; @@ -692,7 +704,7 @@ MEDCouplingUMesh *BuildRefined2DCellQuadratic(const DataArrayDouble *coords, con centers.push_back(tmpPtr[2]);//special case where no subsplit of edge -> reuse the original center. else {//the current edge has been subsplit -> create corresponding centers. - mcIdType nbOfCentersToAppend=ToIdType(edge1.size()/2); + mcIdType const nbOfCentersToAppend=ToIdType(edge1.size()/2); std::map< MCAuto,mcIdType> m; MCAuto ee(MEDCouplingUMeshBuildQPFromEdge2(typeOfSon,tmpPtr,coordsPtr,m)); std::vector::const_iterator it3(allEdges.end()-edge1.size()); @@ -707,10 +719,10 @@ MEDCouplingUMesh *BuildRefined2DCellQuadratic(const DataArrayDouble *coords, con } } } - std::size_t nb(allEdges.size()); + std::size_t const nb(allEdges.size()); if(nb%2!=0) throw INTERP_KERNEL::Exception("BuildRefined2DCellQuadratic : internal error 2 !"); - std::size_t nbOfEdgesOf2DCellSplit(nb/2); + std::size_t const nbOfEdgesOf2DCellSplit(nb/2); MCAuto ret(MEDCouplingUMesh::New("",2)); if(addCoo->empty()) ret->setCoords(coords); @@ -747,9 +759,9 @@ MEDCouplingUMesh *BuildRefined2DCell(const DataArrayDouble *coords, const MEDCou void AddCellInMesh2D(MEDCouplingUMesh *mesh2D, const std::vector& conn, const std::vector< MCAuto >& edges) { bool isQuad(false); - for(std::vector< MCAuto >::const_iterator it=edges.begin();it!=edges.end();it++) + for(const auto & edge : edges) { - const INTERP_KERNEL::Edge *ee(*it); + const INTERP_KERNEL::Edge *ee(edge); if(dynamic_cast(ee)) isQuad=true; } @@ -758,10 +770,10 @@ void AddCellInMesh2D(MEDCouplingUMesh *mesh2D, const std::vector& conn else { const double *coo(mesh2D->getCoords()->begin()); - std::size_t sz(conn.size()); + std::size_t const sz(conn.size()); std::vector addCoo; std::vector conn2(conn); - mcIdType offset(mesh2D->getNumberOfNodes()); + mcIdType const offset(mesh2D->getNumberOfNodes()); for(std::size_t i=0;i& conn void BuildMesh2DCutInternal2(const MEDCouplingUMesh *splitMesh1D, const std::vector& edge1Bis, const std::vector< MCAuto >& edge1BisPtr, std::vector< std::vector >& out0, std::vector< std::vector< MCAuto > >& out1) { - std::size_t nb(edge1Bis.size()/2); - std::size_t nbOfEdgesOf2DCellSplit(nb/2); - mcIdType iEnd=splitMesh1D->getNumberOfCells(); + std::size_t const nb(edge1Bis.size()/2); + std::size_t const nbOfEdgesOf2DCellSplit(nb/2); + mcIdType const iEnd=splitMesh1D->getNumberOfCells(); if(iEnd==0) throw INTERP_KERNEL::Exception("BuildMesh2DCutInternal2 : internal error ! input 1D mesh must have at least one cell !"); std::size_t ii,jj; @@ -822,7 +834,7 @@ void BuildMesh2DCutInternal2(const MEDCouplingUMesh *splitMesh1D, const std::vec for(mcIdType ik=0;ik,mcIdType> m; - MCAuto ee(MEDCouplingUMeshBuildQPFromEdge2((INTERP_KERNEL::NormalizedCellType)cSplitPtr[ciSplitPtr[ik]],cSplitPtr+ciSplitPtr[ik]+1,splitMesh1D->getCoords()->begin(),m)); + MCAuto const ee(MEDCouplingUMeshBuildQPFromEdge2((INTERP_KERNEL::NormalizedCellType)cSplitPtr[ciSplitPtr[ik]],cSplitPtr+ciSplitPtr[ik]+1,splitMesh1D->getCoords()->begin(),m)); ees[ik]=ee; } for(mcIdType ik=iEnd-1;ik>=0;ik--) @@ -839,7 +851,7 @@ void BuildMesh2DCutInternal2(const MEDCouplingUMesh *splitMesh1D, const std::vec struct CellInfo { public: - CellInfo() { } + CellInfo() = default; CellInfo(const std::vector& edges, const std::vector< MCAuto >& edgesPtr); public: std::vector _edges; @@ -848,7 +860,7 @@ public: CellInfo::CellInfo(const std::vector& edges, const std::vector< MCAuto >& edgesPtr) { - std::size_t nbe(edges.size()); + std::size_t const nbe(edges.size()); std::vector edges2(2*nbe); std::vector< MCAuto > edgesPtr2(2*nbe); for(std::size_t i=0;i barys(mesh->computeCellCenterOfMass()); - mcIdType cellId(mesh2D->getCellContainingPoint(barys->begin(),eps)); + mcIdType const cellId(mesh2D->getCellContainingPoint(barys->begin(),eps)); if(cellId==-1) throw INTERP_KERNEL::Exception("EdgeInfo::feedEdgeInfoAt : internal error !"); neighbors[0]=offset+cellId; neighbors[1]=offset+cellId; @@ -994,8 +1006,8 @@ void VectorOfCellInfo::setMeshAt(mcIdType pos, const MCAuto& m const std::vector< std::vector< MCAuto > >& edgePtrs) { get(pos);//to check pos - bool isFast(pos==0 && _pool.size()==1); - std::size_t sz(edges.size()); + bool const isFast(pos==0 && _pool.size()==1); + std::size_t const sz(edges.size()); // dealing with edges if(sz==1) _edge_info.push_back(EdgeInfo(istart,iend,mesh1DInCase)); @@ -1023,13 +1035,13 @@ void VectorOfCellInfo::setMeshAt(mcIdType pos, const MCAuto& m std::vector< MCAuto > ms; if(pos>0) { - MCAuto elt(static_cast(_ze_mesh->buildPartOfMySelfSlice(0,pos,true))); + MCAuto const elt(static_cast(_ze_mesh->buildPartOfMySelfSlice(0,pos,true))); ms.push_back(elt); } ms.push_back(mesh); if(pos<_ze_mesh->getNumberOfCells()-1) { - MCAuto elt(static_cast(_ze_mesh->buildPartOfMySelfSlice(pos+1,_ze_mesh->getNumberOfCells(),true))); + MCAuto const elt(static_cast(_ze_mesh->buildPartOfMySelfSlice(pos+1,_ze_mesh->getNumberOfCells(),true))); ms.push_back(elt); } std::vector< const MEDCouplingUMesh *> ms2(ms.size()); @@ -1048,7 +1060,7 @@ mcIdType VectorOfCellInfo::getZePosOfEdgeGivenItsGlobalId(mcIdType pos) const if(pos<0) throw INTERP_KERNEL::Exception("VectorOfCellInfo::getZePosOfEdgeGivenItsGlobalId : invalid id ! Must be >=0 !"); mcIdType ret(0); - for(std::vector::const_iterator it=_edge_info.begin();it!=_edge_info.end();it++,ret++) + for(auto it=_edge_info.begin();it!=_edge_info.end();it++,ret++) { if((*it).isInMyRange(pos)) return ret; @@ -1061,7 +1073,7 @@ void VectorOfCellInfo::updateEdgeInfo(mcIdType pos, const std::vector< MCAuto& allEdges, const std::vector< MCAuto >& allEdgesPtr, mcIdType offset, MCAuto& idsLeftRight) { - mcIdType nbCellsInSplitMesh1D=splitMesh1D->getNumberOfCells(); + mcIdType const nbCellsInSplitMesh1D=splitMesh1D->getNumberOfCells(); if(nbCellsInSplitMesh1D==0) throw INTERP_KERNEL::Exception("BuildMesh2DCutInternal : internal error ! input 1D mesh must have at least one cell !"); const mcIdType *cSplitPtr(splitMesh1D->getNodalConnectivity()->begin()),*ciSplitPtr(splitMesh1D->getNodalConnectivityIndex()->begin()); @@ -1157,7 +1169,7 @@ MEDCouplingUMesh *BuildMesh2DCutInternal(double eps, MEDCouplingUMesh *splitMesh iEnd++; MCAuto partOfSplitMesh1D(static_cast(splitMesh1D->buildPartOfMySelfSlice(iStart,iEnd,1,true))); - mcIdType pos(pool.getPositionOf(eps,partOfSplitMesh1D)); + mcIdType const pos(pool.getPositionOf(eps,partOfSplitMesh1D)); // MCAutoretTmp(MEDCouplingUMesh::New("",2)); retTmp->setCoords(splitMesh1D->getCoords()); @@ -1182,7 +1194,7 @@ MEDCouplingUMesh *BuildMesh2DCutInternal(double eps, MEDCouplingUMesh *splitMesh /* * splitMesh1D is an input parameter but might have its cells renumbered. */ -MEDCouplingUMesh *BuildMesh2DCutFrom(double eps, mcIdType cellIdInMesh2D, const MEDCouplingUMesh *mesh2DDesc, MEDCouplingUMesh *splitMesh1D, +MEDCouplingUMesh *BuildMesh2DCutFrom(double eps, mcIdType /*cellIdInMesh2D*/, const MEDCouplingUMesh *mesh2DDesc, MEDCouplingUMesh *splitMesh1D, const mcIdType *descBg, const mcIdType *descEnd, const std::vector< std::vector >& intersectEdge1, mcIdType offset, MCAuto& idsLeftRight) { @@ -1192,15 +1204,15 @@ MEDCouplingUMesh *BuildMesh2DCutFrom(double eps, mcIdType cellIdInMesh2D, const std::vector< MCAuto > allEdgesPtr; // for each sub edge in splitMesh2D the uncut Edge object of the original mesh2D for(const mcIdType *it(descBg);it!=descEnd;it++) // for all edges in the descending connectivity of the 2D mesh in relative Fortran mode { - mcIdType edgeId(std::abs(*it)-1); + mcIdType const edgeId(std::abs(*it)-1); std::map< MCAuto,mcIdType> m; - MCAuto ee(MEDCouplingUMeshBuildQPFromEdge2((INTERP_KERNEL::NormalizedCellType)cdescPtr[cidescPtr[edgeId]],cdescPtr+cidescPtr[edgeId]+1,mesh2DDesc->getCoords()->begin(),m)); + MCAuto const ee(MEDCouplingUMeshBuildQPFromEdge2((INTERP_KERNEL::NormalizedCellType)cdescPtr[cidescPtr[edgeId]],cdescPtr+cidescPtr[edgeId]+1,mesh2DDesc->getCoords()->begin(),m)); const std::vector& edge1(intersectEdge1[edgeId]); if(*it>0) allEdges.insert(allEdges.end(),edge1.begin(),edge1.end()); else allEdges.insert(allEdges.end(),edge1.rbegin(),edge1.rend()); - std::size_t sz(edge1.size()); + std::size_t const sz(edge1.size()); for(std::size_t cnt=0;cnt cur2D(static_cast(mesh2DSplit->buildPartOfMySelf(it,it+1,true))); const mcIdType *c(cur2D->getNodalConnectivity()->begin()),*ci(cur2D->getNodalConnectivityIndex()->begin()); const INTERP_KERNEL::CellModel &cm(INTERP_KERNEL::CellModel::GetCellModel((INTERP_KERNEL::NormalizedCellType)c[ci[0]])); - unsigned sz(cm.getNumberOfSons2(c+ci[0]+1,ci[1]-ci[0]-1)); + unsigned const sz(cm.getNumberOfSons2(c+ci[0]+1,ci[1]-ci[0]-1)); INTERP_KERNEL::AutoPtr tmpPtr(new mcIdType[ci[1]-ci[0]]); for(unsigned it2=0;it2 >& intersectEdge1, std::vector< std::vector >& colinear2, std::vector< std::vector >& subDiv2, std::vector& addCoo, std::map& mergedNodes) { static const int SPACEDIM=2; - INTERP_KERNEL::QuadraticPlanarPrecision prec(eps); + INTERP_KERNEL::QuadraticPlanarPrecision const prec(eps); const mcIdType *c1(m1Desc->getNodalConnectivity()->begin()),*ci1(m1Desc->getNodalConnectivityIndex()->begin()); // Build BB tree of all edges in the tool mesh (second mesh) MCAuto bbox1Arr(m1Desc->getBoundingBoxForBBTree(eps)),bbox2Arr(m2Desc->getBoundingBoxForBBTree(eps)); @@ -1305,12 +1317,12 @@ void MEDCouplingUMesh::Intersect1DMeshes(const MEDCouplingUMesh *m1Desc, const M intersectEdge1.resize(nDescCell1); colinear2.resize(nDescCell2); subDiv2.resize(nDescCell2); - BBTree myTree(bbox2,0,0,m2Desc->getNumberOfCells(),-eps); - BBTreePts treeNodes2(m2Desc->getCoords()->begin(),0,0,m2Desc->getCoords()->getNumberOfTuples(),eps); + BBTree const myTree(bbox2,nullptr,0,m2Desc->getNumberOfCells(),-eps); + BBTreePts const treeNodes2(m2Desc->getCoords()->begin(),nullptr,0,m2Desc->getCoords()->getNumberOfTuples(),eps); std::vector candidates1(1); - mcIdType offset1(m1Desc->getNumberOfNodes()); - mcIdType offset2(offset1+m2Desc->getNumberOfNodes()); + mcIdType const offset1(m1Desc->getNumberOfNodes()); + mcIdType const offset2(offset1+m2Desc->getNumberOfNodes()); for(mcIdType i=0;i candidates2; // edges of mesh2 candidate for intersection @@ -1331,9 +1343,9 @@ void MEDCouplingUMesh::Intersect1DMeshes(const MEDCouplingUMesh *m1Desc, const M // This trick guarantees that Node * are discriminant (i.e. form a unique identifier) std::set nodes; pol1->getAllNodes(nodes); pol2->getAllNodes(nodes); - std::size_t szz(nodes.size()); + std::size_t const szz(nodes.size()); std::vector< MCAuto > nodesSafe(szz); - std::set::const_iterator itt(nodes.begin()); + auto itt(nodes.begin()); for(std::size_t iii=0;iiiincrRef(); nodesSafe[iii]=*itt; } // end of protection @@ -1397,16 +1409,16 @@ void MEDCouplingUMesh::BuildIntersecting2DCellsFromEdges(double eps, const MEDCo static const int SPACEDIM=2; const double *coo1(m1->getCoords()->begin()); const mcIdType *conn1(m1->getNodalConnectivity()->begin()),*connI1(m1->getNodalConnectivityIndex()->begin()); - mcIdType offset1(m1->getNumberOfNodes()); + mcIdType const offset1(m1->getNumberOfNodes()); const double *coo2(m2->getCoords()->begin()); const mcIdType *conn2(m2->getNodalConnectivity()->begin()),*connI2(m2->getNodalConnectivityIndex()->begin()); - mcIdType offset2(offset1+m2->getNumberOfNodes()); - mcIdType offset3(offset2+ToIdType(addCoords.size())/2); + mcIdType const offset2(offset1+m2->getNumberOfNodes()); + mcIdType const offset3(offset2+ToIdType(addCoords.size())/2); MCAuto bbox1Arr(m1->getBoundingBoxForBBTree(eps)),bbox2Arr(m2->getBoundingBoxForBBTree(eps)); const double *bbox1(bbox1Arr->begin()),*bbox2(bbox2Arr->begin()); // Here a BBTree on 2D-cells, not on segments: - BBTree myTree(bbox2,0,0,m2->getNumberOfCells(),eps); - mcIdType ncell1=m1->getNumberOfCells(); + BBTree const myTree(bbox2,nullptr,0,m2->getNumberOfCells(),eps); + mcIdType const ncell1=m1->getNumberOfCells(); crI.push_back(0); for(mcIdType i=0;i mapp; std::map mappRev; INTERP_KERNEL::QuadraticPolygon pol1; - INTERP_KERNEL::NormalizedCellType typ=(INTERP_KERNEL::NormalizedCellType)conn1[connI1[i]]; + auto const typ=(INTERP_KERNEL::NormalizedCellType)conn1[connI1[i]]; const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ); // Populate mapp and mappRev with nodes from the current cell (i) from mesh1 - this also builds the Node* objects: MEDCouplingUMeshBuildQPFromMesh3(coo1,offset1,coo2,offset2,addCoords,desc1+descIndx1[i],desc1+descIndx1[i+1],intesctEdges1,/* output */mapp,mappRev); @@ -1436,7 +1448,7 @@ void MEDCouplingUMesh::BuildIntersecting2DCellsFromEdges(double eps, const MEDCo // Again all the additional intersecting nodes are there. for(std::vector::const_iterator it2=candidates2.begin();it2!=candidates2.end();it2++,ii++) { - INTERP_KERNEL::NormalizedCellType typ2=(INTERP_KERNEL::NormalizedCellType)conn2[connI2[*it2]]; + auto const typ2=(INTERP_KERNEL::NormalizedCellType)conn2[connI2[*it2]]; const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel(typ2); // Complete mapping with elements coming from the current cell it2 in mesh2: MEDCouplingUMeshBuildQPFromMesh3(coo1,offset1,coo2,offset2,addCoords,desc2+descIndx2[*it2],desc2+descIndx2[*it2+1],intesctEdges2,/* output */mapp,mappRev); @@ -1479,16 +1491,16 @@ void MEDCouplingUMesh::BuildIntersecting2DCellsFromEdges(double eps, const MEDCo void InsertNodeInConnIfNecessary(mcIdType nodeIdToInsert, std::vector& conn, const double *coords, double eps) { - std::vector::iterator it(std::find(conn.begin(),conn.end(),nodeIdToInsert)); + auto const it(std::find(conn.begin(),conn.end(),nodeIdToInsert)); if(it!=conn.end()) return ; - std::size_t sz(conn.size()); + std::size_t const sz(conn.size()); std::size_t found(std::numeric_limits::max()); for(std::size_t i=0;i(),std::placeholders::_1,1./normm)); std::transform(v2,v2+3,v2,std::bind(std::multiplies(),std::placeholders::_1,1./normm)); double v3[3]; @@ -1508,11 +1520,11 @@ void InsertNodeInConnIfNecessary(mcIdType nodeIdToInsert, std::vector& void SplitIntoToPart(const std::vector& conn, mcIdType pt0, mcIdType pt1, std::vector& part0, std::vector& part1) { - std::size_t sz(conn.size()); + std::size_t const sz(conn.size()); std::vector *curPart(&part0); for(std::size_t i=0;ibegin()),*nodalIndx3D(_nodal_connec_index->begin()); - mcIdType nbOfCells=getNumberOfCells(); + mcIdType const nbOfCells=getNumberOfCells(); if(nbOfCells!=1) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::buildSubCellsFromCut works only with single cell presently !"); for(mcIdType i=0;i& p=cut3DSurf[desc[offset+j]]; const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel((INTERP_KERNEL::NormalizedCellType)nodal3D[nodalIndx3D[i]])); - mcIdType sz=nodalIndx3D[i+1]-nodalIndx3D[i]-1; + mcIdType const sz=nodalIndx3D[i+1]-nodalIndx3D[i]-1; INTERP_KERNEL::AutoPtr tmp(new mcIdType[sz]); INTERP_KERNEL::NormalizedCellType cmsId; - unsigned nbOfNodesSon(cm.fillSonCellNodalConnectivity2(j,nodal3D+nodalIndx3D[i]+1,sz,tmp,cmsId)); + unsigned const nbOfNodesSon(cm.fillSonCellNodalConnectivity2(j,nodal3D+nodalIndx3D[i]+1,sz,tmp,cmsId)); std::vector elt((mcIdType *)tmp,(mcIdType *)tmp+nbOfNodesSon); if(p.first!=-1 && p.second!=-1) { @@ -1579,8 +1591,8 @@ void MEDCouplingUMesh::buildSubCellsFromCut(const std::vector< std::pairgetNumberOfTuples()); + mcIdType const ncells=getNumberOfCells(); + mcIdType const lgthToReach(getNodalConnectivityArrayLen()+subNodesInSeg->getNumberOfTuples()); MCAuto c(DataArrayIdType::New()); c->alloc((std::size_t)lgthToReach); const mcIdType *subPtr(subNodesInSeg->begin()),*subIPtr(subNodesInSegI->begin()),*descPtr(desc->begin()),*descIPtr(descI->begin()),*oldConn(getNodalConnectivity()->begin()); mcIdType *cPtr(c->getPointer()),*ciPtr(getNodalConnectivityIndex()->getPointer()); @@ -1617,8 +1629,8 @@ void MEDCouplingUMesh::split2DCellsLinear(const DataArrayIdType *desc, const Dat mcIdType MEDCouplingUMesh::split2DCellsQuadratic(const DataArrayIdType *desc, const DataArrayIdType *descI, const DataArrayIdType *subNodesInSeg, const DataArrayIdType *subNodesInSegI, const DataArrayIdType *mid, const DataArrayIdType *midI) { checkConsistencyLight(); - mcIdType ncells=getNumberOfCells(); - mcIdType lgthToReach(getNodalConnectivityArrayLen()+2*subNodesInSeg->getNumberOfTuples()); + mcIdType const ncells=getNumberOfCells(); + mcIdType const lgthToReach(getNodalConnectivityArrayLen()+2*subNodesInSeg->getNumberOfTuples()); mcIdType nodesCnt(getNumberOfNodes()); MCAuto c(DataArrayIdType::New()); c->alloc((std::size_t)lgthToReach); MCAuto addCoo(DataArrayDouble::New()); addCoo->alloc(0,1); @@ -1631,7 +1643,7 @@ mcIdType MEDCouplingUMesh::split2DCellsQuadratic(const DataArrayIdType *desc, co { mcIdType offset(descIPtr[0]),sz(descIPtr[1]-descIPtr[0]),deltaSz(sz); for(mcIdType j=0;jcheckFullyDefined(); m2->checkFullyDefined(); - INTERP_KERNEL::QuadraticPlanarPrecision prec(eps); + INTERP_KERNEL::QuadraticPlanarPrecision const prec(eps); if(m1->getMeshDimension()!=2 || m1->getSpaceDimension()!=2 || m2->getMeshDimension()!=2 || m2->getSpaceDimension()!=2) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::Intersect2DMeshes works on umeshes m1 AND m2 with meshdim equal to 2 and spaceDim equal to 2 too!"); // Step 1: compute all edge intersections (new nodes) std::vector< std::vector > intersectEdge1, colinear2, subDiv2; - MEDCouplingUMesh *m1Desc=0,*m2Desc=0; // descending connec. meshes - DataArrayIdType *desc1=0,*descIndx1=0,*revDesc1=0,*revDescIndx1=0,*desc2=0,*descIndx2=0,*revDesc2=0,*revDescIndx2=0; + MEDCouplingUMesh *m1Desc=nullptr,*m2Desc=nullptr; // descending connec. meshes + DataArrayIdType *desc1=nullptr,*descIndx1=nullptr,*revDesc1=nullptr,*revDescIndx1=nullptr,*desc2=nullptr,*descIndx2=nullptr,*revDesc2=nullptr,*revDescIndx2=nullptr; std::vector addCoo,addCoordsQuadratic; // coordinates of newly created nodes IntersectDescending2DMeshes(m1,m2,eps,intersectEdge1,colinear2, subDiv2, m1Desc,desc1,descIndx1,revDesc1,revDescIndx1, @@ -1733,7 +1745,7 @@ MEDCouplingUMesh *MEDCouplingUMesh::Intersect2DMeshes(const MEDCouplingUMesh *m1 // Step 2: re-order newly created nodes according to the ordering found in m2 std::vector< std::vector > intersectEdge2; BuildIntersectEdges(m1Desc,m2Desc,addCoo,subDiv2,intersectEdge2); - subDiv2.clear(); dd5=0; dd6=0; + subDiv2.clear(); dd5=nullptr; dd6=nullptr; // Step 3: std::vector cr,crI; //no DataArrayIdType because interface with Geometric2D @@ -1813,7 +1825,7 @@ void MEDCouplingUMesh::Intersect2DMeshWith1DLine(const MEDCouplingUMesh *mesh2D, // Step 1: compute all edge intersections (new nodes) std::vector< std::vector > intersectEdge1, colinear2, subDiv2; std::vector addCoo,addCoordsQuadratic; // coordinates of newly created nodes - INTERP_KERNEL::QuadraticPlanarPrecision prec(eps); + INTERP_KERNEL::QuadraticPlanarPrecision const prec(eps); // // Build desc connectivity DataArrayIdType *desc1(DataArrayIdType::New()),*descIndx1(DataArrayIdType::New()),*revDesc1(DataArrayIdType::New()),*revDescIndx1(DataArrayIdType::New()); @@ -1822,17 +1834,17 @@ void MEDCouplingUMesh::Intersect2DMeshWith1DLine(const MEDCouplingUMesh *mesh2D, std::map mergedNodes; Intersect1DMeshes(m1Desc,mesh1D,eps,intersectEdge1,colinear2,subDiv2,addCoo,mergedNodes); // use mergeNodes to fix intersectEdge1 - for(std::vector< std::vector >::iterator it0=intersectEdge1.begin();it0!=intersectEdge1.end();it0++) + for(auto & it0 : intersectEdge1) { - std::size_t n((*it0).size()/2); - mcIdType eltStart((*it0)[0]),eltEnd((*it0)[2*n-1]); + std::size_t const n(it0.size()/2); + mcIdType eltStart(it0[0]),eltEnd(it0[2*n-1]); std::map::const_iterator it1; it1=mergedNodes.find(eltStart); if(it1!=mergedNodes.end()) - (*it0)[0]=(*it1).second; + it0[0]=(*it1).second; it1=mergedNodes.find(eltEnd); if(it1!=mergedNodes.end()) - (*it0)[2*n-1]=(*it1).second; + it0[2*n-1]=(*it1).second; } // MCAuto addCooDa(DataArrayDouble::New()); @@ -1871,8 +1883,8 @@ void MEDCouplingUMesh::Intersect2DMeshWith1DLine(const MEDCouplingUMesh *mesh2D, const mcIdType* cellId1 = cells->begin() + cellsIndex->begin()[*it]; const mcIdType* cellId2 = cells->begin() + cellsIndex->begin()[*it]+1; - std::set s1(realIdsInDesc2D->begin()+dd2->begin()[*cellId1], realIdsInDesc2D->begin()+dd2->begin()[*cellId1+1]); - std::set s2(realIdsInDesc2D->begin()+dd2->begin()[*cellId2], realIdsInDesc2D->begin()+dd2->begin()[*cellId2+1]); + std::set const s1(realIdsInDesc2D->begin()+dd2->begin()[*cellId1], realIdsInDesc2D->begin()+dd2->begin()[*cellId1+1]); + std::set const s2(realIdsInDesc2D->begin()+dd2->begin()[*cellId2], realIdsInDesc2D->begin()+dd2->begin()[*cellId2+1]); std::vector commonEdgeId; std::set_intersection(s1.begin(),s1.end(),s2.begin(),s2.end(), std::back_inserter(commonEdgeId)); @@ -1899,17 +1911,17 @@ void MEDCouplingUMesh::Intersect2DMeshWith1DLine(const MEDCouplingUMesh *mesh2D, MCAuto out0s;//ids in mesh2D that are impacted by the fact that some edges of \a mesh1D are part of the edges of those cells if(!idsInDesc2DToBeRefined->empty()) { - DataArrayIdType *out0(0),*outi0(0); + DataArrayIdType *out0(nullptr),*outi0(nullptr); DataArrayIdType::ExtractFromIndexedArrays(idsInDesc2DToBeRefined->begin(),idsInDesc2DToBeRefined->end(),dd3,dd4,out0,outi0); - MCAuto outi0s(outi0); + MCAuto const outi0s(outi0); out0s=out0; out0s=out0s->buildUnique(); out0s->sort(true); } // MCAuto ret1NonCol(static_cast(ret1->buildPartOfMySelf(idsInRet1NotColinear->begin(),idsInRet1NotColinear->end()))); - MCAuto baryRet1(centerOfMassRet1->selectByTupleId(idsInRet1NotColinear->begin(), idsInRet1NotColinear->end())); - DataArrayIdType *out(0),*outi(0); + MCAuto const baryRet1(centerOfMassRet1->selectByTupleId(idsInRet1NotColinear->begin(), idsInRet1NotColinear->end())); + DataArrayIdType *out(nullptr),*outi(nullptr); DataArrayIdType::ExtractFromIndexedArrays(idsInRet1NotColinear->begin(),idsInRet1NotColinear->end(),cells,cellsIndex,out,outi); MCAuto elts(out),eltsIndex(outi); @@ -1935,22 +1947,22 @@ void MEDCouplingUMesh::Intersect2DMeshWith1DLine(const MEDCouplingUMesh *mesh2D, {// here dealing with cells in out0s but not in cellsToBeModified MCAuto fewModifiedCells(out0s->buildSubstraction(cellsToBeModified)); const mcIdType *rdptr(dd3->begin()),*rdiptr(dd4->begin()),*dptr(dd1->begin()),*diptr(dd2->begin()); - for(const mcIdType *it=fewModifiedCells->begin();it!=fewModifiedCells->end();it++) + for(long const it : *fewModifiedCells) { - outMesh2DSplit.push_back(BuildRefined2DCell(ret1->getCoords(),mesh2D,*it,dptr+diptr[*it],dptr+diptr[*it+1],intersectEdge1)); + outMesh2DSplit.push_back(BuildRefined2DCell(ret1->getCoords(),mesh2D,it,dptr+diptr[it],dptr+diptr[it+1],intersectEdge1)); ret1->setCoords(outMesh2DSplit.back()->getCoords()); } - mcIdType offset(ret2->getNumberOfTuples()); + mcIdType const offset(ret2->getNumberOfTuples()); ret2->pushBackValsSilent(fewModifiedCells->begin(),fewModifiedCells->end()); MCAuto partOfRet3(DataArrayIdType::New()); partOfRet3->alloc(2*idsInRet1Colinear->getNumberOfTuples(),1); partOfRet3->fillWithValue(std::numeric_limits::max()); partOfRet3->rearrange(2); mcIdType kk(0),*ret3ptr(partOfRet3->getPointer()); for(const mcIdType *it=idsInDescMesh2DForIdsInRetColinear->begin();it!=idsInDescMesh2DForIdsInRetColinear->end();it++,kk++) { - mcIdType faceId(std::abs(*it)-1); + mcIdType const faceId(std::abs(*it)-1); for(const mcIdType *it2=rdptr+rdiptr[faceId];it2!=rdptr+rdiptr[faceId+1];it2++) { - mcIdType tmp(fewModifiedCells->findIdFirstEqual(*it2)); + mcIdType const tmp(fewModifiedCells->findIdFirstEqual(*it2)); if(tmp!=-1) { if(std::find(dptr+diptr[*it2],dptr+diptr[*it2+1],-(*it))!=dptr+diptr[*it2+1]) @@ -1973,8 +1985,8 @@ void MEDCouplingUMesh::Intersect2DMeshWith1DLine(const MEDCouplingUMesh *mesh2D, if(!outMesh2DSplit.empty()) { DataArrayDouble *da(outMesh2DSplit.back()->getCoords()); - for(std::vector< MCAuto >::iterator itt=outMesh2DSplit.begin();itt!=outMesh2DSplit.end();itt++) - (*itt)->setCoords(da); + for(auto & itt : outMesh2DSplit) + itt->setCoords(da); } } cellsToBeModified=cellsToBeModified->buildUniqueNotSorted(); @@ -1992,7 +2004,7 @@ void MEDCouplingUMesh::Intersect2DMeshWith1DLine(const MEDCouplingUMesh *mesh2D, ret2->pushBackSilent(*it); } // - std::size_t nbOfMeshes(outMesh2DSplit.size()); + std::size_t const nbOfMeshes(outMesh2DSplit.size()); std::vector tmp(nbOfMeshes); for(std::size_t i=0;i edgesToDealWith(ret3->findIdsStrictlyNegative()); for(const mcIdType *it=edgesToDealWith->begin();it!=edgesToDealWith->end();it++) { - mcIdType old2DCellId(-ret3->getIJ(*it,0)-1); + mcIdType const old2DCellId(-ret3->getIJ(*it,0)-1); MCAuto candidates(ret2->findIdsEqual(old2DCellId)); ret3->setIJ(*it,0,FindRightCandidateAmong(ret2D,candidates->begin(),candidates->end(),ret1,*it%2==0?-((*it)/2+1):(*it)/2+1,eps));// div by 2 because 2 components natively in ret3 } @@ -2053,27 +2065,27 @@ DataArrayIdType *MEDCouplingUMesh::conformize2D(double eps) const double *bbox(bboxArr->begin()),*coords(getCoords()->begin()); mcIdType nCell=getNumberOfCells(),nDescCell=mDesc->getNumberOfCells(); std::vector< std::vector > intersectEdge(nDescCell),overlapEdge(nDescCell); - std::vector addCoo; - BBTree myTree(bbox,0,0,nDescCell,-eps); - INTERP_KERNEL::QuadraticPlanarPrecision prec(eps); + std::vector const addCoo; + BBTree const myTree(bbox,nullptr,0,nDescCell,-eps); + INTERP_KERNEL::QuadraticPlanarPrecision const prec(eps); for(mcIdType i=0;i candidates; myTree.getIntersectingElems(bbox+i*2*SPACEDIM,candidates); - for(std::vector::const_iterator it=candidates.begin();it!=candidates.end();it++) - if(*it>i) // we're dealing with pair of edges, no need to treat the same pair twice + for(long const candidate : candidates) + if(candidate>i) // we're dealing with pair of edges, no need to treat the same pair twice { std::map,mcIdType> m; INTERP_KERNEL::Edge *e1(MEDCouplingUMeshBuildQPFromEdge2((INTERP_KERNEL::NormalizedCellType)c[ci[i]],c+ci[i]+1,coords,m)), - *e2(MEDCouplingUMeshBuildQPFromEdge2((INTERP_KERNEL::NormalizedCellType)c[ci[*it]],c+ci[*it]+1,coords,m)); + *e2(MEDCouplingUMeshBuildQPFromEdge2((INTERP_KERNEL::NormalizedCellType)c[ci[candidate]],c+ci[candidate]+1,coords,m)); INTERP_KERNEL::MergePoints merge; INTERP_KERNEL::QuadraticPolygon c1,c2; e1->intersectWith(e2,merge,c1,c2); e1->decrRef(); e2->decrRef(); if(IKGeo2DInternalMapper(c1,m,c[ci[i]+1],c[ci[i]+2],intersectEdge[i])) - overlapEdge[i].push_back(*it); - if(IKGeo2DInternalMapper(c2,m,c[ci[*it]+1],c[ci[*it]+2],intersectEdge[*it])) - overlapEdge[*it].push_back(i); + overlapEdge[i].push_back(candidate); + if(IKGeo2DInternalMapper(c2,m,c[ci[candidate]+1],c[ci[candidate]+2],intersectEdge[candidate])) + overlapEdge[candidate].push_back(i); } } // splitting done. sort intersect point in intersectEdge. @@ -2084,7 +2096,7 @@ DataArrayIdType *MEDCouplingUMesh::conformize2D(double eps) for(mcIdType i=0;i& isect(intersectEdge[i]); - std::size_t sz(isect.size()); + std::size_t const sz(isect.size()); if(sz>1) { std::map,mcIdType> m; @@ -2110,17 +2122,17 @@ DataArrayIdType *MEDCouplingUMesh::conformize2D(double eps) middleNeedsToBeUsed=true; const std::vector& candidates(overlapEdge[i]); std::vector trueCandidates; - for(std::vector::const_iterator itc=candidates.begin();itc!=candidates.end();itc++) - if((INTERP_KERNEL::NormalizedCellType)c[ci[*itc]]==INTERP_KERNEL::NORM_SEG3) - trueCandidates.push_back(*itc); + for(long const candidate : candidates) + if((INTERP_KERNEL::NormalizedCellType)c[ci[candidate]]==INTERP_KERNEL::NORM_SEG3) + trueCandidates.push_back(candidate); mcIdType stNode(c[ci[i]+1]),endNode(isect[0]); for(std::size_t j=0;j::const_iterator itc=trueCandidates.begin();itc!=trueCandidates.end();itc++) + for(long const trueCandidate : trueCandidates) { - mcIdType tmpSt(c[ci[*itc]+1]),tmpEnd(c[ci[*itc]+2]); + mcIdType tmpSt(c[ci[trueCandidate]+1]),tmpEnd(c[ci[trueCandidate]+2]); if((tmpSt==stNode && tmpEnd==endNode) || (tmpSt==endNode && tmpEnd==stNode)) - { mid[j]=*itc; break; } + { mid[j]=trueCandidate; break; } } stNode=endNode; endNode=j mSafe,nSafe,oSafe,pSafe,qSafe,rSafe; - DataArrayIdType *m(0),*n(0),*o(0),*p(0),*q(0),*r(0); + DataArrayIdType *m(nullptr),*n(nullptr),*o(nullptr),*p(nullptr),*q(nullptr),*r(nullptr); DataArrayIdType::ExtractFromIndexedArrays(ret->begin(),ret->end(),desc1,descIndx1,m,n); mSafe=m; nSafe=n; DataArrayIdType::PutIntoToSkylineFrmt(intersectEdge,o,p); oSafe=o; pSafe=p; if(middleNeedsToBeUsed) { DataArrayIdType::PutIntoToSkylineFrmt(middle,q,r); qSafe=q; rSafe=r; } MCAuto modif(static_cast(buildPartOfMySelf(ret->begin(),ret->end(),true))); - mcIdType nbOfNodesCreated(modif->split2DCells(mSafe,nSafe,oSafe,pSafe,qSafe,rSafe)); + mcIdType const nbOfNodesCreated(modif->split2DCells(mSafe,nSafe,oSafe,pSafe,qSafe,rSafe)); setCoords(modif->getCoords());//if nbOfNodesCreated==0 modif and this have the same coordinates pointer so this line has no effect. But for quadratic cases this line is important. setPartOfMySelf(ret->begin(),ret->end(),*modif); { bool areNodesMerged; mcIdType newNbOfNodes; if(nbOfNodesCreated!=0) - MCAuto tmp(mergeNodes(eps,areNodesMerged,newNbOfNodes)); + MCAuto const tmp(mergeNodes(eps,areNodesMerged,newNbOfNodes)); } return ret.retn(); } @@ -2203,7 +2215,7 @@ DataArrayIdType *MEDCouplingUMesh::internalColinearize2D(double eps, bool stayCo checkConsistencyLight(); if(getSpaceDimension()!=2 || getMeshDimension()!=2) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::colinearize2D : This method only works for meshes with spaceDim=2 and meshDim=2 !"); - INTERP_KERNEL::QuadraticPlanarPrecision prec(eps); + INTERP_KERNEL::QuadraticPlanarPrecision const prec(eps); mcIdType nbOfCells(getNumberOfCells()),nbOfNodes(getNumberOfNodes()); const mcIdType *cptr(_nodal_connec->begin()),*ciptr(_nodal_connec_index->begin()); MCAuto newc(DataArrayIdType::New()),newci(DataArrayIdType::New()); newci->alloc(nbOfCells+1,1); newc->alloc(0,1); newci->setIJ(0,0,0); @@ -2218,8 +2230,8 @@ DataArrayIdType *MEDCouplingUMesh::internalColinearize2D(double eps, bool stayCo MCAuto dsi(revDescI2->deltaShiftIndex()); MCAuto ids(dsi->findIdsGreaterThan(2)); const mcIdType * cPtr(mDesc0D->getNodalConnectivity()->begin()); - for(auto it = ids->begin(); it != ids->end(); it++) - forbiddenPoints[cPtr[2*(*it)+1]] = true; // we know that a 0D mesh has a connectivity of the form [NORM_POINT1, i1, NORM_POINT1, i2, ...] + for(long const it : *ids) + forbiddenPoints[cPtr[2*it+1]] = true; // we know that a 0D mesh has a connectivity of the form [NORM_POINT1, i1, NORM_POINT1, i2, ...] } MCAuto appendedCoords(DataArrayDouble::New()); appendedCoords->alloc(0,1);//1 not 2 it is not a bug. @@ -2275,9 +2287,9 @@ bool MEDCouplingUMesh::OrderPointsAlongLine(const double * coo, mcIdType startNo // Keep what is inside [startNode, endNode]: mcIdType go = 0; - for (vector::const_iterator it=xx.begin(); it != xx.end(); ++it) + for (const auto & it : xx) { - const mcIdType idx = (*it).second; + const mcIdType idx = it.second; if (!go) { if (idx == startNode) go = 1; @@ -2302,9 +2314,9 @@ bool MEDCouplingUMesh::OrderPointsAlongLine(const double * coo, mcIdType startNo for (const mcIdType * it = idsBg; it != endBg; ++it) { mcIdType start = c[cI[*it]+1], end = c[cI[*it]+2]; - vector::const_iterator itStart = find(pointIds.begin(), pointIds.end(), start); + vector::const_iterator const itStart = find(pointIds.begin(), pointIds.end(), start); if (itStart == pointIds.end()) continue; - vector::const_iterator itEnd = find(pointIds.begin(), pointIds.end(), end); + vector::const_iterator const itEnd = find(pointIds.begin(), pointIds.end(), end); if (itEnd == pointIds.end()) continue; if (abs(distance(itEnd, itStart)) != 1) continue; hitSegs.push_back(*it); // segment is undivided. @@ -2317,19 +2329,19 @@ void MEDCouplingUMesh::ReplaceEdgeInFace(const mcIdType * sIdxConn, const mcIdTy const std::vector& insidePoints, std::vector& modifiedFace) { using namespace std; - size_t dst = distance(sIdxConn, sIdxConnE); + size_t const dst = distance(sIdxConn, sIdxConnE); modifiedFace.reserve(dst + insidePoints.size()-2); modifiedFace.resize(dst); copy(sIdxConn, sIdxConnE, modifiedFace.data()); - vector::iterator shortEnd = modifiedFace.begin()+dst; - vector::iterator startPos = find(modifiedFace.begin(), shortEnd , startNode); + auto const shortEnd = modifiedFace.begin()+dst; + auto startPos = find(modifiedFace.begin(), shortEnd , startNode); if (startPos == shortEnd) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::ReplaceEdgeInFace: internal error, should never happen!"); - vector::iterator endPos = find(modifiedFace.begin(),shortEnd, endNode); + auto endPos = find(modifiedFace.begin(),shortEnd, endNode); if (endPos == shortEnd) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::ReplaceEdgeInFace: internal error, should never happen!"); - size_t d = distance(startPos, endPos); + size_t const d = distance(startPos, endPos); if (d == 1 || d == (1-dst)) // don't use modulo, for neg numbers, result is implementation defined ... modifiedFace.insert(++startPos, ++insidePoints.begin(), --insidePoints.end()); // insidePoints also contains start and end node. Those don't need to be inserted. else @@ -2392,8 +2404,8 @@ DataArrayIdType *MEDCouplingUMesh::conformize3D(double eps) // Build BBTree MCAuto bboxArr(mDesc->getBoundingBoxForBBTree(eps)); const double *bbox(bboxArr->begin()); getCoords()->begin(); - mcIdType nDescCell=mDesc->getNumberOfCells(); - BBTree myTree(bbox,0,0,nDescCell,-eps); + mcIdType const nDescCell=mDesc->getNumberOfCells(); + BBTree const myTree(bbox,nullptr,0,nDescCell,-eps); // Surfaces - handle biggest first MCAuto surfF = mDesc->getMeasureField(true); DataArrayDouble * surfs = surfF->getArray(); @@ -2406,27 +2418,27 @@ DataArrayIdType *MEDCouplingUMesh::conformize3D(double eps) vector< pair > S; for(mcIdType i=0;i < surfs->getNumberOfTuples();i++) { - pair p = make_pair(surfs->begin()[i], i); + pair const p = make_pair(surfs->begin()[i], i); S.push_back(p); } sort(S.rbegin(),S.rend()); // reverse sort vector hit(nDescCell); fill(hit.begin(), hit.end(), false); - vector hitPoly; // the final result: which 3D cells have been modified. + vector const hitPoly; // the final result: which 3D cells have been modified. - for( vector >::const_iterator it = S.begin(); it != S.end(); it++) + for(const auto & it : S) { - mcIdType faceIdx = (*it).second; + mcIdType const faceIdx = it.second; if (hit[faceIdx]) continue; vector candidates, cands2; myTree.getIntersectingElems(bbox+faceIdx*2*SPACEDIM,candidates); // Keep only candidates whose normal matches the normal of current face - for(vector::const_iterator it2=candidates.begin();it2!=candidates.end();it2++) + for(long const candidate : candidates) { - bool col = INTERP_KERNEL::isColinear3D(normalsP + faceIdx*SPACEDIM, normalsP + *(it2)*SPACEDIM, eps/carMeshSz); // using rough relative epsilon - if (*it2 != faceIdx && col) - cands2.push_back(*it2); + bool const col = INTERP_KERNEL::isColinear3D(normalsP + faceIdx*SPACEDIM, normalsP + candidate*SPACEDIM, eps/carMeshSz); // using rough relative epsilon + if (candidate != faceIdx && col) + cands2.push_back(candidate); } if (!cands2.size()) continue; @@ -2483,9 +2495,9 @@ DataArrayIdType *MEDCouplingUMesh::conformize3D(double eps) double checkSurf=0.0; const mcIdType * idsGoodPlaneP(idsGoodPlane->begin()); - for (const mcIdType * ii = ids->begin(); ii != ids->end(); ii++) + for (long const ii : *ids) { - mcIdType faceIdx2 = cands2[idsGoodPlaneP[*ii]]; + mcIdType const faceIdx2 = cands2[idsGoodPlaneP[ii]]; hit[faceIdx2] = true; checkSurf += surfs->begin()[faceIdx2]; } @@ -2522,12 +2534,12 @@ DataArrayIdType *MEDCouplingUMesh::conformize3D(double eps) for (const mcIdType * ii = ids->begin(); ii != ids->end(); ii++) { // Build pack from the face to insert: - mcIdType faceIdx2 = cands2[idsGoodPlane->getIJ(*ii,0)]; + mcIdType const faceIdx2 = cands2[idsGoodPlane->getIJ(*ii,0)]; mcIdType facePack2Sz; const mcIdType * facePack2 = connSlaDesc->getSimplePackSafePtr(faceIdx2, facePack2Sz); // contains the type! // Insert it in all hit polyhedrons: - for (vector::const_iterator it2=polyIndices.begin(); it2!=polyIndices.end(); ++it2) - connSla->pushBackPack(*it2, facePack2+1, facePack2+facePack2Sz); // without the type + for (long const polyIndice : polyIndices) + connSla->pushBackPack(polyIndice, facePack2+1, facePack2+facePack2Sz); // without the type } } } // end step1 @@ -2562,8 +2574,8 @@ DataArrayIdType *MEDCouplingUMesh::conformize3D(double eps) const mcIdType *cDesc2(mDesc2->getNodalConnectivity()->begin()),*cIDesc2(mDesc2->getNodalConnectivityIndex()->begin()); MCAuto bboxArr(mDesc2->getBoundingBoxForBBTree(eps)); const double *bbox2(bboxArr->begin()); - mcIdType nDesc2Cell=mDesc2->getNumberOfCells(); - BBTree myTree2(bbox2,0,0,nDesc2Cell,-eps); + mcIdType const nDesc2Cell=mDesc2->getNumberOfCells(); + BBTree const myTree2(bbox2,nullptr,0,nDesc2Cell,-eps); // Edges - handle longest first MCAuto lenF = mDesc2->getMeasureField(true); @@ -2573,7 +2585,7 @@ DataArrayIdType *MEDCouplingUMesh::conformize3D(double eps) vector > S; for(mcIdType i=0;i < lens->getNumberOfTuples();i++) { - pair p = make_pair(lens->getIJ(i, 0), i); + pair const p = make_pair(lens->getIJ(i, 0), i); S.push_back(p); } sort(S.rbegin(),S.rend()); // reverse sort @@ -2581,9 +2593,9 @@ DataArrayIdType *MEDCouplingUMesh::conformize3D(double eps) vector hit(nDesc2Cell); fill(hit.begin(), hit.end(), false); - for( vector >::const_iterator it = S.begin(); it != S.end(); it++) + for(const auto & it : S) { - mcIdType eIdx = (*it).second; + mcIdType const eIdx = it.second; if (hit[eIdx]) continue; @@ -2595,27 +2607,27 @@ DataArrayIdType *MEDCouplingUMesh::conformize3D(double eps) for (mcIdType i3=0; i3 < 3; i3++) // TODO: use fillSonCellNodalConnectivity2 or similar? vCurr[i3] = coo[start*SPACEDIM+i3] - coo[end*SPACEDIM+i3]; double carSz = INTERP_KERNEL::caracteristicDimVector(vCurr), eps2 = eps*carSz*carSz*carSz; - for(vector::const_iterator it2=candidates.begin();it2!=candidates.end();it2++) + for(long const candidate : candidates) { double vOther[3]; - mcIdType start2 = cDesc2[cIDesc2[*it2]+1], end2 = cDesc2[cIDesc2[*it2]+2]; + mcIdType start2 = cDesc2[cIDesc2[candidate]+1], end2 = cDesc2[cIDesc2[candidate]+2]; for (mcIdType i3=0; i3 < 3; i3++) vOther[i3] = coo[start2*SPACEDIM+i3] - coo[end2*SPACEDIM+i3]; // isColinear() expect unit vecotr, and relative (non geometrical) precision. // relative prec means going from eps -> eps/curSz // normalizing vCurr and vOther means multiplying by v^4, knowing that inside isColinear3D() the square (^2) of a dot product (^2) is computed - bool col = INTERP_KERNEL::isColinear3D(vCurr, vOther, eps2); + bool const col = INTERP_KERNEL::isColinear3D(vCurr, vOther, eps2); // Warning: different from faces: we need to keep eIdx in the final list of candidates because we need // to have its nodes inside the sub mesh mPartCand below (needed in OrderPointsAlongLine()) if (col) - cands2.push_back(*it2); + cands2.push_back(candidate); } if (cands2.size() == 1 && cands2[0] == eIdx) // see warning above continue; // Now rotate edges to bring them on Ox - mcIdType startNode = cDesc2[cIDesc2[eIdx]+1]; - mcIdType endNode = cDesc2[cIDesc2[eIdx]+2]; + mcIdType const startNode = cDesc2[cIDesc2[eIdx]+1]; + mcIdType const endNode = cDesc2[cIDesc2[eIdx]+2]; INTERP_KERNEL::TranslationRotationMatrix rotation; INTERP_KERNEL::TranslationRotationMatrix::Rotate3DBipoint(coo+SPACEDIM*startNode, coo+SPACEDIM*endNode, rotation); MCAuto mPartRef(mDesc2->buildPartOfMySelfSlice(eIdx, eIdx+1,1,false)); // false=zipCoords is called @@ -2648,26 +2660,26 @@ DataArrayIdType *MEDCouplingUMesh::conformize3D(double eps) // Now the ordering along the Ox axis: std::vector insidePoints, hitSegs; - bool isSplit = OrderPointsAlongLine(mPartCand->_coords->getConstPointer(), nodeMap->begin()[startNode], nodeMap->begin()[endNode], + bool const isSplit = OrderPointsAlongLine(mPartCand->_coords->getConstPointer(), nodeMap->begin()[startNode], nodeMap->begin()[endNode], mPartCand->getNodalConnectivity()->begin(), mPartCand->getNodalConnectivityIndex()->begin(), idsGoodLine->begin(), idsGoodLine->end(), /*out*/insidePoints, hitSegs); // Optim: smaller segments completely included in eIdx and not split won't need any further treatment: - for (vector::const_iterator its=hitSegs.begin(); its != hitSegs.end(); ++its) - hit[cands2[*its]] = true; + for (long const hitSeg : hitSegs) + hit[cands2[hitSeg]] = true; if (!isSplit) // current segment remains in one piece continue; // Get original node IDs in global coords array - for (std::vector::iterator iit = insidePoints.begin(); iit!=insidePoints.end(); ++iit) - *iit = nodeMapInv->begin()[*iit]; + for (long & insidePoint : insidePoints) + insidePoint = nodeMapInv->begin()[insidePoint]; vector polyIndices, packsIds, facePack; // For each face implying this edge for (mcIdType ii=revDescIP2[eIdx]; ii < revDescIP2[eIdx+1]; ii++) { - mcIdType faceIdx = revDescP2[ii]; + mcIdType const faceIdx = revDescP2[ii]; // each cell where this face is involved connectivity will be modified: ret->pushBackValsSilent(revDescP + revDescIP[faceIdx], revDescP + revDescIP[faceIdx+1]); @@ -2688,12 +2700,12 @@ DataArrayIdType *MEDCouplingUMesh::conformize3D(double eps) MCAuto idx(DataArrayIdType::New()); idx->alloc(1); idx->fillWithValue(0); MCAuto vals(DataArrayIdType::New()); vals->alloc(0); newConn->set3(superIdx, idx, vals); - mcIdType nbCells=getNumberOfCells(); + mcIdType const nbCells=getNumberOfCells(); for(mcIdType ii = 0; ii < nbCells; ii++) for (mcIdType jj=descIP[ii]; jj < descIP[ii+1]; jj++) { mcIdType sz, faceIdx = abs(descP[jj])-1; - bool orient = descP[jj]>0; + bool const orient = descP[jj]>0; const mcIdType * p = connSlaDesc->getSimplePackSafePtr(faceIdx, sz); if (orient) newConn->pushBackPack(ii, p+1, p+sz); // +1 to skip type diff --git a/src/MEDCoupling/MEDCouplingVoronoi.cxx b/src/MEDCoupling/MEDCouplingVoronoi.cxx old mode 100755 new mode 100644 index d5a439002..27df94b77 --- a/src/MEDCoupling/MEDCouplingVoronoi.cxx +++ b/src/MEDCoupling/MEDCouplingVoronoi.cxx @@ -19,20 +19,29 @@ // Author : Anthony Geay (EDF R&D) #include "MEDCouplingVoronoi.hxx" +#include "MCAuto.hxx" +#include "MCIdType.hxx" +#include "MCType.hxx" #include "MEDCoupling1GTUMesh.hxx" #include "MEDCouplingCMesh.hxx" #include "MEDCouplingFieldDouble.hxx" #include "MCAuto.txx" -#include "MEDCouplingNormalizedUnstructuredMesh.txx" -#include "Interpolation2D.txx" -#include "Interpolation3DSurf.hxx" +#include "MEDCouplingMemArray.hxx" +#include "MEDCouplingUMesh.hxx" +#include +#include +#include +#include +#include "NormalizedGeometricTypes" +#include +#include +#include using namespace MEDCoupling; Voronizer::~Voronizer() -{ -} += default; int Voronizer1D::getDimension() const { @@ -59,13 +68,13 @@ MCAuto ComputeBigCellFrom(const double pt1[2], const double pt static const double PT[2]={0.,0.}; m->scale(PT,FACT); MCAuto mu(m->buildUnstructured()); - double l(std::max(bbox[1]-bbox[0],bbox[3]-bbox[2])); + double const l(std::max(bbox[1]-bbox[0],bbox[3]-bbox[2])); double middle[2]={(pt1[0]+pt2[0])/2.,(pt1[1]+pt2[1])/2.}; double v[2]={pt1[0],pt1[1]}; DataArrayDouble::Rotate2DAlg(middle,M_PI/2,1,v,v); v[0]=middle[0]-v[0]; v[1]=middle[1]-v[1]; { - double nor(sqrt(v[0]*v[0]+v[1]*v[1])); + double const nor(sqrt(v[0]*v[0]+v[1]*v[1])); v[0]/=nor; v[1]/=nor; } MCAuto line(MEDCouplingUMesh::New("line",1)); @@ -79,8 +88,8 @@ MCAuto ComputeBigCellFrom(const double pt1[2], const double pt line->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,CONN); MCAuto sp2,sp1; { - DataArrayIdType *cellNb1(0),*cellNb2(0); - MEDCouplingUMesh *sp2Pt(0),*sp1Pt(0); + DataArrayIdType *cellNb1(nullptr),*cellNb2(nullptr); + MEDCouplingUMesh *sp2Pt(nullptr),*sp1Pt(nullptr); MEDCouplingUMesh::Intersect2DMeshWith1DLine(mu,line,eps,sp2Pt,sp1Pt,cellNb1,cellNb2); sp1=sp1Pt; sp2=sp2Pt; MCAuto cellNb10(cellNb1),cellNb20(cellNb2); @@ -100,7 +109,7 @@ MCAuto ComputeBigCellFrom(const double pt1[2], const double pt } -MCAuto MergeVorCells2D(MEDCouplingUMesh *p, double eps, bool isZip) +MCAuto MergeVorCells2D(MEDCouplingUMesh *p, double /*eps*/, bool isZip) { MCAuto edgeToKeep; MCAuto p0; @@ -138,7 +147,7 @@ MCAuto MergeVorCells2D(MEDCouplingUMesh *p, double eps, bool i MCAuto MergeVorCells(const std::vector< MCAuto >& vcs, double eps) { - std::size_t sz(vcs.size()); + std::size_t const sz(vcs.size()); if(sz<1) throw INTERP_KERNEL::Exception("MergeVorCells : len of input vec expected to be >= 1 !"); if(sz==1) @@ -151,7 +160,7 @@ MCAuto MergeVorCells(const std::vector< MCAutozipCoords(); { bool dummy; mcIdType dummy2; - MCAuto dummy3(p->mergeNodes(eps,dummy,dummy2)); + MCAuto const dummy3(p->mergeNodes(eps,dummy,dummy2)); } return MergeVorCells2D(p,eps,true); } @@ -164,7 +173,7 @@ MCAuto SimplifyPolygon(const MEDCouplingUMesh *m, double eps) if(m->getNumberOfCells()!=1) throw INTERP_KERNEL::Exception("SimplifyPolygon : internal error !"); const mcIdType *conn(m->getNodalConnectivity()->begin()),*conni(m->getNodalConnectivityIndex()->begin()); - mcIdType nbPtsInPolygon(conni[1]-conni[0]-1); + mcIdType const nbPtsInPolygon(conni[1]-conni[0]-1); const double *coo(m->getCoords()->begin()); std::vector resConn; for(mcIdType i=0;i SimplifyPolygon(const MEDCouplingUMesh *m, double eps) coo[3*current+1]-coo[3*zeNext+1], coo[3*current+2]-coo[3*zeNext+2], }; - double c[3]={a[1]*b[2]-a[2]*b[1], a[2]*b[0]-a[0]*b[2], a[0]*b[1]-a[1]*b[0]}; + double const c[3]={a[1]*b[2]-a[2]*b[1], a[2]*b[0]-a[0]*b[2], a[0]*b[1]-a[1]*b[0]}; if(sqrt(c[0]*c[0]+c[1]*c[1]+c[2]*c[2])>eps) resConn.push_back(current); } @@ -192,7 +201,7 @@ MCAuto SimplifyPolygon(const MEDCouplingUMesh *m, double eps) MCAuto MergeVorCells3D(const std::vector< MCAuto >& vcs, double eps) { - std::size_t sz(vcs.size()); + std::size_t const sz(vcs.size()); if(sz<1) throw INTERP_KERNEL::Exception("MergeVorCells : len of input vec expected to be >= 1 !"); if(sz==1) @@ -205,7 +214,7 @@ MCAuto MergeVorCells3D(const std::vector< MCAutozipCoords(); { bool dummy; mcIdType dummy2; - MCAuto dummy3(p->mergeNodes(eps,dummy,dummy2)); + MCAuto const dummy3(p->mergeNodes(eps,dummy,dummy2)); } MCAuto edgeToKeep; MCAuto p0; @@ -219,7 +228,7 @@ MCAuto MergeVorCells3D(const std::vector< MCAuto eqn(skinOfRes->computePlaneEquationOf3DFaces()); MCAuto comm,commI; { - DataArrayIdType *a(0),*b(0); + DataArrayIdType *a(nullptr),*b(nullptr); eqn->findCommonTuples(eps,0,a,b); comm=a; commI=b; //comm=DataArrayIdType::New(); comm->alloc(0,1); commI=DataArrayIdType::New(); commI->alloc(1,1); commI->setIJ(0,0,0); @@ -298,7 +307,7 @@ MCAuto MEDCoupling::Voronizer1D::doIt(const MEDCouplingUMesh * throw INTERP_KERNEL::Exception("Voronoize1D : spacedim must be equal to 1 and meshdim also equal to 1 !"); if(m->getNumberOfCells()!=1) throw INTERP_KERNEL::Exception("Voronoize1D : mesh is expected to have only one cell !"); - mcIdType nbPts(points->getNumberOfTuples()); + mcIdType const nbPts(points->getNumberOfTuples()); if(nbPts<1) throw INTERP_KERNEL::Exception("Voronoize1D : at least one point expected !"); std::vector bbox(4); @@ -315,7 +324,7 @@ MCAuto MEDCoupling::Voronizer1D::doIt(const MEDCouplingUMesh * { bool dummy; mcIdType newNbNodes; - MCAuto dummy3(vorTess->mergeNodes(eps,dummy,newNbNodes)); + MCAuto const dummy3(vorTess->mergeNodes(eps,dummy,newNbNodes)); } std::vector polygsToIterOn; const double *pt(pts+i); @@ -325,12 +334,11 @@ MCAuto MEDCoupling::Voronizer1D::doIt(const MEDCouplingUMesh * if(polygsToIterOn.size()>2) throw INTERP_KERNEL::Exception("Voronoize1D : overlap of points !"); std::vector< MCAuto > newVorCells; - for(std::vector::const_iterator it=polygsToIterOn.begin();it!=polygsToIterOn.end();it++) + for(long const poly : polygsToIterOn) { - mcIdType poly(*it); // double seed(pts[poly]),zept(*pt); - double mid((seed+zept)/2.); + double const mid((seed+zept)/2.); // MCAuto tile(l0[poly]); tile->zipCoords(); @@ -364,7 +372,7 @@ MCAuto MEDCoupling::Voronizer1D::doIt(const MEDCouplingUMesh * MCAuto ret(MEDCouplingUMesh::MergeUMeshes(l0Bis)); { bool dummy; mcIdType dummy2; - MCAuto dummy3(ret->mergeNodes(eps,dummy,dummy2)); + MCAuto const dummy3(ret->mergeNodes(eps,dummy,dummy2)); } return ret; } @@ -379,7 +387,7 @@ MCAuto MEDCoupling::Voronizer2D::doIt(const MEDCouplingUMesh * throw INTERP_KERNEL::Exception("Voronoize2D : spacedim must be equal to 2 and meshdim also equal to 2 !"); if(m->getNumberOfCells()!=1) throw INTERP_KERNEL::Exception("Voronoize2D : mesh is expected to have only one cell !"); - mcIdType nbPts(points->getNumberOfTuples()); + mcIdType const nbPts(points->getNumberOfTuples()); if(nbPts<1) throw INTERP_KERNEL::Exception("Voronoize2D : at least one point expected !"); std::vector bbox(4); @@ -396,7 +404,7 @@ MCAuto MEDCoupling::Voronizer2D::doIt(const MEDCouplingUMesh * { bool dummy; mcIdType newNbNodes; - MCAuto dummy3(vorTess->mergeNodes(eps,dummy,newNbNodes)); + MCAuto const dummy3(vorTess->mergeNodes(eps,dummy,newNbNodes)); } std::vector polygsToIterOn; const double *pt(pts+i*2); @@ -407,7 +415,7 @@ MCAuto MEDCoupling::Voronizer2D::doIt(const MEDCouplingUMesh * std::vector< MCAuto > newVorCells; while(!elemsToDo.empty()) { - mcIdType poly(*elemsToDo.begin()); elemsToDo.erase(elemsToDo.begin()); elemsDone.insert(poly); + mcIdType const poly(*elemsToDo.begin()); elemsToDo.erase(elemsToDo.begin()); elemsDone.insert(poly); const double *seed(pts+2*poly); MCAuto cell(ComputeBigCellFrom(pt,seed,bbox,eps)); MCAuto tile(l0[poly]); @@ -415,7 +423,7 @@ MCAuto MEDCoupling::Voronizer2D::doIt(const MEDCouplingUMesh * MCAuto a; MCAuto b,c; { - DataArrayIdType *bPtr(0),*cPtr(0); + DataArrayIdType *bPtr(nullptr),*cPtr(nullptr); a=MEDCouplingUMesh::Intersect2DMeshes(tile,cell,eps,bPtr,cPtr); b=bPtr; c=cPtr; } @@ -439,8 +447,8 @@ MCAuto MEDCoupling::Voronizer2D::doIt(const MEDCouplingUMesh * // MCAuto ids; { - DataArrayIdType *tmp(0); - bool sta(a->getCoords()->areIncludedInMe(cell->getCoords(),eps,tmp)); + DataArrayIdType *tmp(nullptr); + bool const sta(a->getCoords()->areIncludedInMe(cell->getCoords(),eps,tmp)); ids=tmp; if(!sta) throw INTERP_KERNEL::Exception("Voronoize2D : internal error 2 !"); @@ -478,18 +486,18 @@ MCAuto MEDCoupling::Voronizer2D::doIt(const MEDCouplingUMesh * MCAuto ret(MEDCouplingUMesh::MergeUMeshes(l0Bis)); { bool dummy; mcIdType dummy2; - MCAuto dummy3(ret->mergeNodes(eps,dummy,dummy2)); + MCAuto const dummy3(ret->mergeNodes(eps,dummy,dummy2)); } return ret; } -MCAuto Split3DCellInParts(const MEDCouplingUMesh *m, const double pt[3], const double seed[3], double eps, mcIdType tmp[2]) +MCAuto Split3DCellInParts(const MEDCouplingUMesh *m, const double pt[3], const double seed[3], double eps, mcIdType /*tmp*/[2]) { if(m->getMeshDimension()!=3 || m->getSpaceDimension()!=3 || m->getNumberOfCells()!=1) throw INTERP_KERNEL::Exception("Split3DCellInParts : expecting a 3D with exactly one cell !"); - double middle[3]={(pt[0]+seed[0])/2.,(pt[1]+seed[1])/2.,(pt[2]+seed[2])/2.}; - double vec[3]={pt[0]-seed[0],pt[1]-seed[1],pt[2]-seed[2]}; - MCAuto res(m->clipSingle3DCellByPlane(middle,vec,eps)); + double const middle[3]={(pt[0]+seed[0])/2.,(pt[1]+seed[1])/2.,(pt[2]+seed[2])/2.}; + double const vec[3]={pt[0]-seed[0],pt[1]-seed[1],pt[2]-seed[2]}; + MCAuto const res(m->clipSingle3DCellByPlane(middle,vec,eps)); return res; } @@ -504,7 +512,7 @@ MCAuto MEDCoupling::Voronizer3D::doIt(const MEDCouplingUMesh * throw INTERP_KERNEL::Exception("Voronoize3D : spacedim must be equal to 3 and meshdim also equal to 3 !"); if(m->getNumberOfCells()!=1) throw INTERP_KERNEL::Exception("Voronoize3D : mesh is expected to have only one cell !"); - mcIdType nbPts(points->getNumberOfTuples()); + mcIdType const nbPts(points->getNumberOfTuples()); if(nbPts<1) throw INTERP_KERNEL::Exception("Voronoize3D : at least one point expected !"); std::vector< MCAuto > l0(1,MCAuto(m->deepCopy())); @@ -519,7 +527,7 @@ MCAuto MEDCoupling::Voronizer3D::doIt(const MEDCouplingUMesh * { bool dummy; mcIdType newNbNodes; - MCAuto dummy3(vorTess->mergeNodes(eps,dummy,newNbNodes)); + MCAuto const dummy3(vorTess->mergeNodes(eps,dummy,newNbNodes)); } std::vector polygsToIterOn; const double *pt(pts+i*3); @@ -555,7 +563,7 @@ MCAuto MEDCoupling::Voronizer3D::doIt(const MEDCouplingUMesh * MCAuto ret(MEDCouplingUMesh::MergeUMeshes(l0Bis)); { bool dummy; mcIdType dummy2; - MCAuto dummy3(ret->mergeNodes(eps,dummy,dummy2)); + MCAuto const dummy3(ret->mergeNodes(eps,dummy,dummy2)); } return ret; } diff --git a/src/MEDCoupling/MEDCouplingVoronoi.hxx b/src/MEDCoupling/MEDCouplingVoronoi.hxx index bb1c51e32..63f4eeb3e 100644 --- a/src/MEDCoupling/MEDCouplingVoronoi.hxx +++ b/src/MEDCoupling/MEDCouplingVoronoi.hxx @@ -21,8 +21,9 @@ #ifndef __MEDCOUPLINGVORONOI_HXX__ #define __MEDCOUPLINGVORONOI_HXX__ -#include "MEDCoupling.hxx" +#include "MCAuto.hxx" +#include "MEDCouplingMemArray.hxx" #include "MEDCouplingUMesh.hxx" namespace MEDCoupling @@ -38,22 +39,22 @@ namespace MEDCoupling class Voronizer1D : public Voronizer { public: - MCAuto doIt(const MEDCouplingUMesh *m, const DataArrayDouble *points, double eps) const; - int getDimension() const; + MCAuto doIt(const MEDCouplingUMesh *m, const DataArrayDouble *points, double eps) const override; + int getDimension() const override; }; class Voronizer2D : public Voronizer { public: - MCAuto doIt(const MEDCouplingUMesh *m, const DataArrayDouble *points, double eps) const; - int getDimension() const; + MCAuto doIt(const MEDCouplingUMesh *m, const DataArrayDouble *points, double eps) const override; + int getDimension() const override; }; class Voronizer3D : public Voronizer { public: - MCAuto doIt(const MEDCouplingUMesh *m, const DataArrayDouble *points, double eps) const; - int getDimension() const; + MCAuto doIt(const MEDCouplingUMesh *m, const DataArrayDouble *points, double eps) const override; + int getDimension() const override; }; } diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest.hxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest.hxx index ac66d2da5..ece6a2d0b 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest.hxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest.hxx @@ -21,7 +21,7 @@ #ifndef __MEDCOUPLINGBASICSTEST_HXX__ #define __MEDCOUPLINGBASICSTEST_HXX__ -#include +#include #include "MCType.hxx" #include diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest0.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest0.cxx index 52b38d9bf..e20fd2fd6 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest0.cxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest0.cxx @@ -18,7 +18,15 @@ // // Author : Anthony Geay (CEA/DEN) +#include "MCType.hxx" +#include "Interpolation.txx" +#include "Interpolation2D1D.txx" +#include "InterpolationOptions.hxx" +#include "Log.hxx" +#include "Interpolation2D3D.txx" #include "MEDCouplingBasicsTest.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include "MEDCouplingNormalizedUnstructuredMesh.txx" #include "MEDCouplingUMesh.hxx" #include "MEDCouplingMappedExtrudedMesh.hxx" #include "MEDCouplingFieldDouble.hxx" @@ -27,11 +35,14 @@ #include "MEDCouplingBasicsTestData1.hxx" -#include "Interpolation2D.txx" -#include "Interpolation2D3D.txx" -#include "Interpolation2D1D.txx" -#include "MEDCouplingNormalizedUnstructuredMesh.txx" #include "MEDCouplingNormalizedCartesianMesh.txx" +#include "NormalizedGeometricTypes" +#include "VectorUtils.hxx" +#include +#include +#include +#include +#include using namespace MEDCoupling; @@ -849,7 +860,7 @@ MEDCouplingUMesh *MEDCouplingBasicsTest::build2DTargetMesh_4() MEDCouplingUMesh *MEDCouplingBasicsTest::build3DTargetMesh_3() { - return 0; + return nullptr; } MEDCouplingMultiFields *MEDCouplingBasicsTest::buildMultiFields_1() @@ -1177,9 +1188,9 @@ MEDCouplingUMesh *MEDCouplingBasicsTest::buildPointe_1(MEDCouplingUMesh *& m1) double MEDCouplingBasicsTest::sumAll(const std::vector< std::map >& matrix) { double ret=0.; - for(std::vector< std::map >::const_iterator iter=matrix.begin();iter!=matrix.end();iter++) - for(std::map::const_iterator iter2=(*iter).begin();iter2!=(*iter).end();iter2++) - ret+=(*iter2).second; + for(const auto & iter : matrix) + for(auto iter2 : iter) + ret+=iter2.second; return ret; } @@ -1630,9 +1641,9 @@ MEDCouplingUMesh* MEDCouplingBasicsTest::build3D2DTetraTargetMesh(const double i int MEDCouplingBasicsTest::countNonZero(const std::vector< std::map >& matrix) { int ret=0; - for(std::vector< std::map >::const_iterator iter=matrix.begin();iter!=matrix.end();iter++) - for(std::map::const_iterator iter2=(*iter).begin();iter2!=(*iter).end();iter2++) - if (!INTERP_KERNEL::epsilonEqual((*iter2).second, 0.)) ret +=1; + for(const auto & iter : matrix) + for(auto iter2 : iter) + if (!INTERP_KERNEL::epsilonEqual(iter2.second, 0.)) ret +=1; return ret; } @@ -1642,8 +1653,8 @@ void MEDCouplingBasicsTest::test2D1DMeshesIntersection(MEDCouplingUMesh *sourceM const int correctDuplicateFacesNbr, const int correctTotalIntersectFacesNbr) { - MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh); - MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh); + MEDCouplingNormalizedUnstructuredMesh<2,2> const sourceWrapper(sourceMesh); + MEDCouplingNormalizedUnstructuredMesh<2,2> const targetWrapper(targetMesh); INTERP_KERNEL::Interpolation2D1D myInterpolator; myInterpolator.setPrecision(1e-12); const double prec = 1.0e-5; @@ -1657,8 +1668,8 @@ void MEDCouplingBasicsTest::test2D1DMeshesIntersection(MEDCouplingUMesh *sourceM LOG(1, "length = " << length <<" correctLength = " << correctLength ); CPPUNIT_ASSERT_DOUBLES_EQUAL(correctLength, length, prec * std::max(correctLength, length)); - INTERP_KERNEL::Interpolation2D3D::DuplicateFacesType duplicateFaces = myInterpolator.retrieveDuplicateFaces(); - int duplicateFacesNbr = (int)duplicateFaces.size(); + INTERP_KERNEL::Interpolation2D3D::DuplicateFacesType const duplicateFaces = myInterpolator.retrieveDuplicateFaces(); + int const duplicateFacesNbr = (int)duplicateFaces.size(); LOG(1, "duplicateFacesNbr = " << duplicateFacesNbr <<" correctDuplicateFacesNbr = " << correctDuplicateFacesNbr); CPPUNIT_ASSERT_EQUAL(correctDuplicateFacesNbr, duplicateFacesNbr); @@ -1679,16 +1690,16 @@ void MEDCouplingBasicsTest::test3D2DMeshesIntersection(MEDCouplingUMesh *sourceM const int correctDuplicateFacesNbr, const int correctTotalIntersectFacesNbr) { - MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh); - MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh); + MEDCouplingNormalizedUnstructuredMesh<3,3> const sourceWrapper(sourceMesh); + MEDCouplingNormalizedUnstructuredMesh<3,3> const targetWrapper(targetMesh); INTERP_KERNEL::Interpolation2D3D myInterpolator; myInterpolator.setPrecision(1e-12); const double prec = 1.0e-5; IntersectionMatrix matrix; INTERP_KERNEL::SplittingPolicy sp[] = { INTERP_KERNEL::PLANAR_FACE_5, INTERP_KERNEL::PLANAR_FACE_6, INTERP_KERNEL::GENERAL_24, INTERP_KERNEL::GENERAL_48 }; - for ( size_t i = 0; i < sizeof(sp)/sizeof(sp[0]); ++i ) + for (auto & i : sp) { - myInterpolator.setSplittingPolicy( sp[i] ); + myInterpolator.setSplittingPolicy( i ); matrix.clear(); myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,matrix,"P0P0"); @@ -1698,8 +1709,8 @@ void MEDCouplingBasicsTest::test3D2DMeshesIntersection(MEDCouplingUMesh *sourceM LOG(1, "surf = " << surf <<" correctSurf = " << correctSurf ); CPPUNIT_ASSERT_DOUBLES_EQUAL(correctSurf, surf, prec * std::max(correctSurf, surf)); - INTERP_KERNEL::Interpolation2D3D::DuplicateFacesType duplicateFaces = myInterpolator.retrieveDuplicateFaces(); - int duplicateFacesNbr = (int)duplicateFaces.size(); + INTERP_KERNEL::Interpolation2D3D::DuplicateFacesType const duplicateFaces = myInterpolator.retrieveDuplicateFaces(); + int const duplicateFacesNbr = (int)duplicateFaces.size(); LOG(1, "duplicateFacesNbr = " << duplicateFacesNbr <<" correctDuplicateFacesNbr = " << correctDuplicateFacesNbr); CPPUNIT_ASSERT_EQUAL(correctDuplicateFacesNbr, duplicateFacesNbr); diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest1.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest1.cxx index 573412698..14b4eea82 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest1.cxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest1.cxx @@ -19,15 +19,28 @@ // Author : Anthony Geay (CEA/DEN) #include "MEDCouplingBasicsTest1.hxx" +#include "MEDCouplingMemArray.txx" +#include "MEDCouplingRefCountObject.hxx" +#include "InterpKernelException.hxx" +#include "MCAuto.hxx" +#include "MCType.hxx" +#include "MCIdType.hxx" +#include "MEDCouplingPointSet.hxx" +#include "MEDCouplingNatureOfFieldEnum" +#include "MEDCouplingMesh.hxx" #include "MEDCouplingUMesh.hxx" #include "MEDCouplingCMesh.hxx" #include "MEDCouplingMappedExtrudedMesh.hxx" #include "MEDCouplingFieldDouble.hxx" -#include "MEDCouplingMemArray.txx" -#include +#include +#include "NormalizedGeometricTypes" +#include +#include +#include #include #include #include +#include using namespace MEDCoupling; @@ -170,7 +183,7 @@ void MEDCouplingBasicsTest1::testMesh() mesh->checkConsistencyLight(); //test 1 - no copy ownership C++ myCoords=DataArrayDouble::New(); - double *tmp=new double[3*nbOfNodes]; + auto *tmp=new double[3*nbOfNodes]; std::copy(coords,coords+3*nbOfNodes,tmp); myCoords->useArray(tmp,true,DeallocType::CPP_DEALLOC,nbOfNodes,3); mesh->setCoords(myCoords); @@ -585,7 +598,7 @@ void MEDCouplingBasicsTest1::testBuildPartOfMySelf() const mcIdType tab2[3]={0,2,3}; // MEDCouplingPointSet *subMeshSimple=mesh->buildPartOfMySelf(tab1,tab1+2,true); - MEDCouplingUMesh *subMesh=dynamic_cast(subMeshSimple); + auto *subMesh=dynamic_cast(subMeshSimple); CPPUNIT_ASSERT(subMesh); std::string name(subMesh->getName()); CPPUNIT_ASSERT_EQUAL(2,(int)mesh->getAllGeoTypes().size()); @@ -635,7 +648,7 @@ void MEDCouplingBasicsTest1::testBuildPartOfMySelfNode() MEDCouplingUMesh *mesh=build2DTargetMesh_1(); const mcIdType tab1[4]={5,7,8,4}; MEDCouplingPointSet *subMeshSimple=mesh->buildPartOfMySelfNode(tab1,tab1+4,true); - MEDCouplingUMesh *subMesh=dynamic_cast(subMeshSimple); + auto *subMesh=dynamic_cast(subMeshSimple); CPPUNIT_ASSERT(subMesh); CPPUNIT_ASSERT_EQUAL(1,(int)subMesh->getAllGeoTypes().size()); CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_QUAD4,*subMesh->getAllGeoTypes().begin()); @@ -704,7 +717,7 @@ void MEDCouplingBasicsTest1::testZipCoords() // const mcIdType tab1[2]={0,4}; MEDCouplingPointSet *subMeshPtSet=mesh->buildPartOfMySelf(tab1,tab1+2,true); - MEDCouplingUMesh *subMesh=dynamic_cast(subMeshPtSet); + auto *subMesh=dynamic_cast(subMeshPtSet); CPPUNIT_ASSERT(subMesh); DataArrayIdType *traducer=subMesh->zipCoordsTraducer(); const mcIdType expectedTraducer[9]={0,1,-1,2,3,4,-1,5,6}; @@ -742,7 +755,7 @@ void MEDCouplingBasicsTest1::testZipConnectivity() MEDCouplingUMesh *m2=build2DTargetMesh_1(); mcIdType cells1[3]={2,3,4}; MEDCouplingPointSet *m3_1=m2->buildPartOfMySelf(cells1,cells1+3,true); - MEDCouplingUMesh *m3=dynamic_cast(m3_1); + auto *m3=dynamic_cast(m3_1); CPPUNIT_ASSERT(m3); m2->decrRef(); MEDCouplingUMesh *m4=build2DSourceMesh_1(); @@ -787,7 +800,7 @@ void MEDCouplingBasicsTest1::testEqualMesh() CPPUNIT_ASSERT(mesh1->isEqual(mesh2,1e-12)); CPPUNIT_ASSERT(mesh2->isEqual(mesh1,1e-12)); double *pt=mesh2->getCoords()->getPointer(); - double tmp=pt[1]; + double const tmp=pt[1]; pt[1]=5.999; CPPUNIT_ASSERT(!mesh1->isEqual(mesh2,1e-12)); CPPUNIT_ASSERT(!mesh2->isEqual(mesh1,1e-12)); @@ -951,7 +964,7 @@ void MEDCouplingBasicsTest1::testBuildSubMeshData() CPPUNIT_ASSERT_EQUAL(1,(int)di->getNumberOfComponents()); const mcIdType *toCheck=di->getConstPointer(); CPPUNIT_ASSERT(std::equal(elts,elts+3,toCheck)); - MEDCouplingUMesh *ret1DC=dynamic_cast(ret1); + auto *ret1DC=dynamic_cast(ret1); CPPUNIT_ASSERT(ret1DC); ret1->decrRef(); di->decrRef(); @@ -960,7 +973,7 @@ void MEDCouplingBasicsTest1::testBuildSubMeshData() MEDCouplingFieldDouble *fieldNodes=MEDCouplingFieldDouble::New(ON_NODES,NO_TIME); fieldNodes->setMesh(targetMesh); MEDCouplingMesh *ret2=fieldNodes->buildSubMeshData(elts,elts+3,di); - MEDCouplingUMesh *ret2DC=dynamic_cast(ret2); + auto *ret2DC=dynamic_cast(ret2); CPPUNIT_ASSERT(ret2DC); CPPUNIT_ASSERT_EQUAL(3,(int)ret2->getNumberOfCells()); CPPUNIT_ASSERT_EQUAL(6,(int)ret2->getNumberOfNodes()); @@ -977,7 +990,7 @@ void MEDCouplingBasicsTest1::testBuildSubMeshData() void MEDCouplingBasicsTest1::testExtrudedMesh1() { - MEDCouplingUMesh *mesh2D=0; + MEDCouplingUMesh *mesh2D=nullptr; MEDCouplingUMesh *mesh3D=build3DExtrudedUMesh_1(mesh2D); MEDCouplingMappedExtrudedMesh *ext=MEDCouplingMappedExtrudedMesh::New(mesh3D,mesh2D,1); CPPUNIT_ASSERT_EQUAL(18,(int)ext->getNumberOfCells()); @@ -1020,7 +1033,7 @@ void MEDCouplingBasicsTest1::testExtrudedMesh2() double v[3]={0.,0.,2.}; mTT->findNodesOnPlane(pt,v,1e-12,n); CPPUNIT_ASSERT_EQUAL(43,(int)n.size()); - MEDCouplingUMesh *mTT3dSurf=(MEDCouplingUMesh *)mTT->buildFacePartOfMySelfNode(&n[0],&n[0]+n.size(),true); + auto *mTT3dSurf=(MEDCouplingUMesh *)mTT->buildFacePartOfMySelfNode(&n[0],&n[0]+n.size(),true); MEDCouplingMappedExtrudedMesh *meTT=MEDCouplingMappedExtrudedMesh::New(mTT,mTT3dSurf,0); CPPUNIT_ASSERT_EQUAL(200,(int)meTT->getNumberOfCells()); CPPUNIT_ASSERT_EQUAL(10,(int)meTT->getMesh2D()->getNumberOfCells()); @@ -1034,7 +1047,7 @@ void MEDCouplingBasicsTest1::testExtrudedMesh2() n.clear(); mN->findNodesOnPlane(pt,v,1e-12,n); CPPUNIT_ASSERT_EQUAL(30,(int)n.size()); - MEDCouplingUMesh *mN3dSurf=(MEDCouplingUMesh *)mN->buildFacePartOfMySelfNode(&n[0],&n[0]+n.size(),true); + auto *mN3dSurf=(MEDCouplingUMesh *)mN->buildFacePartOfMySelfNode(&n[0],&n[0]+n.size(),true); MEDCouplingMappedExtrudedMesh *meN=MEDCouplingMappedExtrudedMesh::New(mN,mN3dSurf,0); CPPUNIT_ASSERT_EQUAL(40,(int)meN->getNumberOfCells()); CPPUNIT_ASSERT_EQUAL(20,(int)meN->getMesh2D()->getNumberOfCells()); @@ -1048,7 +1061,7 @@ void MEDCouplingBasicsTest1::testExtrudedMesh2() n.clear(); mTF->findNodesOnPlane(pt,v,1e-12,n); CPPUNIT_ASSERT_EQUAL(27,(int)n.size()); - MEDCouplingUMesh *mTF3dSurf=(MEDCouplingUMesh *)mTF->buildFacePartOfMySelfNode(&n[0],&n[0]+n.size(),true); + auto *mTF3dSurf=(MEDCouplingUMesh *)mTF->buildFacePartOfMySelfNode(&n[0],&n[0]+n.size(),true); MEDCouplingMappedExtrudedMesh *meTF=MEDCouplingMappedExtrudedMesh::New(mTF,mTF3dSurf,0); CPPUNIT_ASSERT_EQUAL(340,(int)meTF->getNumberOfCells()); CPPUNIT_ASSERT_EQUAL(17,(int)meTF->getMesh2D()->getNumberOfCells()); @@ -1308,7 +1321,7 @@ void MEDCouplingBasicsTest1::testMergeMesh1() const double vec[2]={1.,0.}; m2->translate(vec); MEDCouplingMesh *m3=m1->mergeMyselfWith(m2); - MEDCouplingUMesh *m3C=dynamic_cast(m3); + auto *m3C=dynamic_cast(m3); CPPUNIT_ASSERT(m3C); m3->checkConsistencyLight(); MEDCouplingUMesh *m4=build2DTargetMeshMerged_1(); @@ -1376,7 +1389,7 @@ void MEDCouplingBasicsTest1::testMergeField1() MEDCouplingUMesh *m4=build2DTargetMeshMerged_1(); m4->setName(f1->getMesh()->getName()); CPPUNIT_ASSERT(f3->getMesh()->isEqual(m4,1.e-12)); - std::string name=f3->getName(); + std::string const name=f3->getName(); CPPUNIT_ASSERT(name=="MeasureOfMesh_"); CPPUNIT_ASSERT(f3->getTypeOfField()==ON_CELLS); CPPUNIT_ASSERT(f3->getTimeDiscretization()==ONE_TIME); @@ -1386,7 +1399,7 @@ void MEDCouplingBasicsTest1::testMergeField1() const double *tmp=f3->getArray()->getConstPointer(); std::transform(tmp,tmp+7,values,values,std::minus()); std::transform(values,values+7,values,[](double c){return fabs(c);}); - double max=*std::max_element(values,values+7); + double const max=*std::max_element(values,values+7); CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,max,1.e-12); m4->decrRef(); f3->decrRef(); @@ -1573,7 +1586,7 @@ void MEDCouplingBasicsTest1::testApplyFunc() const double *tmp=f1->getArray()->getConstPointer(); std::transform(tmp,tmp+9,values1,values1,std::minus()); std::transform(values1,values1+9,values1,[](double c){return fabs(c);}); - double max=*std::max_element(values1,values1+9); + double const max=*std::max_element(values1,values1+9); CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,max,1.e-12); f1->decrRef(); m->decrRef(); @@ -1819,7 +1832,7 @@ void MEDCouplingBasicsTest1::testOperationsOnFields3() void MEDCouplingBasicsTest1::testOperationsOnFields4() { MEDCouplingUMesh *m=build2DTargetMesh_1(); - std::size_t nbOfCells=m->getNumberOfCells(); + std::size_t const nbOfCells=m->getNumberOfCells(); MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,CONST_ON_TIME_INTERVAL); f1->setMesh(m); DataArrayDouble *array=DataArrayDouble::New(); @@ -2011,12 +2024,12 @@ void MEDCouplingBasicsTest1::testSplitByType() MEDCouplingUMesh *m1=build3DSurfTargetMesh_1(); std::vector v=m1->splitByType(); CPPUNIT_ASSERT_EQUAL(3,(int)v.size()); - std::vector v2(v.begin(),v.end()); + std::vector const v2(v.begin(),v.end()); MEDCouplingUMesh *m2=MEDCouplingUMesh::MergeUMeshesOnSameCoords(v2); m2->setName(m1->getName().c_str()); CPPUNIT_ASSERT(m1->isEqual(m2,1.e-12)); - for(std::vector::const_iterator iter=v.begin();iter!=v.end();iter++) - (*iter)->decrRef(); + for(auto iter : v) + iter->decrRef(); m2->decrRef(); m1->decrRef(); } @@ -2027,17 +2040,17 @@ void MEDCouplingBasicsTest1::testFuseUMeshesOnSameCoords() MEDCouplingUMesh *m2=build2DTargetMesh_1(); mcIdType cells1[3]={2,3,4}; MEDCouplingPointSet *m3_1=m2->buildPartOfMySelf(cells1,cells1+3,true); - MEDCouplingUMesh *m3=dynamic_cast(m3_1); + auto *m3=dynamic_cast(m3_1); CPPUNIT_ASSERT(m3); meshes.push_back(m3); mcIdType cells2[3]={1,2,4}; MEDCouplingPointSet *m4_1=m2->buildPartOfMySelf(cells2,cells2+3,true); - MEDCouplingUMesh *m4=dynamic_cast(m4_1); + auto *m4=dynamic_cast(m4_1); CPPUNIT_ASSERT(m4); meshes.push_back(m4); mcIdType cells3[2]={1,2}; MEDCouplingPointSet *m5_1=m2->buildPartOfMySelf(cells3,cells3+2,true); - MEDCouplingUMesh *m5=dynamic_cast(m5_1); + auto *m5=dynamic_cast(m5_1); CPPUNIT_ASSERT(m5); meshes.push_back(m5); m2->decrRef(); @@ -2052,14 +2065,14 @@ void MEDCouplingBasicsTest1::testFuseUMeshesOnSameCoords() { DataArrayIdType *arr=corr[i]; CPPUNIT_ASSERT_EQUAL(1,(int)arr->getNumberOfComponents()); - mcIdType nbOfVals=expectedVals1[i]; + mcIdType const nbOfVals=expectedVals1[i]; CPPUNIT_ASSERT_EQUAL(nbOfVals,arr->getNumberOfTuples()); const mcIdType *vals=arr->getConstPointer(); for(mcIdType j=0;j > fidsOfGroups; - std::vector corr2(corr.begin(),corr.end()); + std::vector const corr2(corr.begin(),corr.end()); DataArrayIdType *arr2=DataArrayIdType::MakePartition(corr2,m7->getNumberOfCells(),fidsOfGroups); const mcIdType fidExp[4]={5,1,3,4}; const mcIdType fidsGrp[3][3]={{1,3,5},{3,4,5},{4,5,23344}}; @@ -2069,12 +2082,12 @@ void MEDCouplingBasicsTest1::testFuseUMeshesOnSameCoords() CPPUNIT_ASSERT(std::equal(fidExp,fidExp+4,arr2->getConstPointer())); for(int i=0;i<3;i++) { - mcIdType nbOfVals=expectedVals1[i]; + mcIdType const nbOfVals=expectedVals1[i]; CPPUNIT_ASSERT_EQUAL(nbOfVals,ToIdType(fidsOfGroups[i].size())); CPPUNIT_ASSERT(std::equal(fidsOfGroups[i].begin(),fidsOfGroups[i].end(),fidsGrp[i])); } - for(std::vector::iterator iter=corr.begin();iter!=corr.end();iter++) - (*iter)->decrRef(); + for(auto & iter : corr) + iter->decrRef(); arr2->decrRef(); m7->decrRef(); // @@ -2089,9 +2102,9 @@ void MEDCouplingBasicsTest1::testFuseUMeshesOnSameCoords2() MEDCouplingUMesh *m1=build3DExtrudedUMesh_1(m2); m2->decrRef(); const mcIdType part1[5]={2,3,6,4,10}; - MEDCouplingUMesh *m3=(MEDCouplingUMesh *)m1->buildPartOfMySelf(part1,part1+5,true); + auto *m3=(MEDCouplingUMesh *)m1->buildPartOfMySelf(part1,part1+5,true); const mcIdType part2[4]={5,6,4,7}; - MEDCouplingUMesh *m4=(MEDCouplingUMesh *)m1->buildPartOfMySelf(part2,part2+4,true); + auto *m4=(MEDCouplingUMesh *)m1->buildPartOfMySelf(part2,part2+4,true); std::vector meshes; meshes.push_back(m1); meshes.push_back(m3); @@ -2100,7 +2113,7 @@ void MEDCouplingBasicsTest1::testFuseUMeshesOnSameCoords2() std::vector corr; MEDCouplingUMesh *m5=MEDCouplingUMesh::FuseUMeshesOnSameCoords(meshes,0,corr); CPPUNIT_ASSERT_EQUAL(18,(int)m5->getNumberOfCells()); - std::vector::iterator it=corr.begin(); + auto it=corr.begin(); const mcIdType exp1[4]={18,5,5,4}; const mcIdType exp2[4][18]={ {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17}, @@ -2111,7 +2124,7 @@ void MEDCouplingBasicsTest1::testFuseUMeshesOnSameCoords2() int i=0; for(;it!=corr.end();it++,i++) { - mcIdType sz=(*it)->getNumberOfTuples(); + mcIdType const sz=(*it)->getNumberOfTuples(); CPPUNIT_ASSERT_EQUAL(exp1[i],sz); CPPUNIT_ASSERT(std::equal(exp2[i],exp2[i]+sz,(*it)->getConstPointer())); } @@ -2127,7 +2140,7 @@ void MEDCouplingBasicsTest1::testBuildOrthogonalField() { MEDCouplingUMesh *targetMesh=build3DSurfTargetMesh_1(); MEDCouplingFieldDouble *field=targetMesh->buildOrthogonalField(); - double expected[3]={0.70710678118654746,0.,-0.70710678118654746}; + double const expected[3]={0.70710678118654746,0.,-0.70710678118654746}; CPPUNIT_ASSERT_EQUAL(5,(int)field->getNumberOfTuples()); CPPUNIT_ASSERT_EQUAL(3,(int)field->getNumberOfComponents()); const double *vals=field->getArray()->getConstPointer(); @@ -2175,7 +2188,7 @@ void MEDCouplingBasicsTest1::testGetCellsContainingPoint() //2D with no help of bounding box. double center[2]={0.2,0.2}; DataArrayDouble::Rotate2DAlg(center,0.78539816339744830962,6,pos,pos); - targetMesh->rotate(center,0,0.78539816339744830962); + targetMesh->rotate(center,nullptr,0.78539816339744830962); targetMesh->getCellsContainingPoints(pos,6,1e-12,t1,t2); CPPUNIT_ASSERT_EQUAL(6,(int)t1->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(7,(int)t2->getNbOfElems()); @@ -2235,7 +2248,7 @@ void MEDCouplingBasicsTest1::testGetValueOn1() { MEDCouplingUMesh *targetMesh=build2DTargetMesh_1(); MEDCouplingFieldDouble *fieldOnCells=MEDCouplingFieldDouble::New(ON_CELLS); - std::size_t nbOfCells=targetMesh->getNumberOfCells(); + std::size_t const nbOfCells=targetMesh->getNumberOfCells(); fieldOnCells->setMesh(targetMesh); DataArrayDouble *array=DataArrayDouble::New(); array->alloc(nbOfCells,2); @@ -2256,7 +2269,7 @@ void MEDCouplingBasicsTest1::testGetValueOn1() // targetMesh=build2DSourceMesh_1(); MEDCouplingFieldDouble *fieldOnNodes=MEDCouplingFieldDouble::New(ON_NODES); - mcIdType nbOfNodes=targetMesh->getNumberOfNodes(); + mcIdType const nbOfNodes=targetMesh->getNumberOfNodes(); fieldOnNodes->setMesh(targetMesh); array=DataArrayDouble::New(); array->alloc(nbOfNodes,2); @@ -2329,7 +2342,7 @@ void MEDCouplingBasicsTest1::testCMesh0() MEDCouplingMesh* meshDeepCopy=mesh->deepCopy(); MEDCouplingCMesh* meshClone=mesh->clone(false); - CPPUNIT_ASSERT_THROW(meshEmpty->copyTinyStringsFrom(0),INTERP_KERNEL::Exception); + CPPUNIT_ASSERT_THROW(meshEmpty->copyTinyStringsFrom(nullptr),INTERP_KERNEL::Exception); meshEmpty->copyTinyStringsFrom(mesh); //no data in meshEmpty, expected false CPPUNIT_ASSERT(!meshEmpty->isEqual(mesh,1e-12)); @@ -2496,7 +2509,7 @@ void MEDCouplingBasicsTest1::testCMesh2() ids->decrRef(); check->decrRef(); mcIdType cells1[4]={0,1,25,26}; - MEDCouplingUMesh *partMesh1= + auto *partMesh1= dynamic_cast(mesh1->buildPart(cells1,cells1+4)); CPPUNIT_ASSERT(partMesh1); CPPUNIT_ASSERT_EQUAL(4,(int)partMesh1->getNumberOfCellsWithType(INTERP_KERNEL::NORM_HEXA8)); @@ -2505,7 +2518,7 @@ void MEDCouplingBasicsTest1::testCMesh2() mcIdType cells2[2]={25,26}; DataArrayIdType* arr1; - MEDCouplingCMesh *partMesh2= + auto *partMesh2= dynamic_cast(mesh1->buildPartAndReduceNodes(cells2,cells2+2,arr1)); CPPUNIT_ASSERT(partMesh2); CPPUNIT_ASSERT_EQUAL(2,(int)partMesh2->getNumberOfCellsWithType(INTERP_KERNEL::NORM_HEXA8)); @@ -2513,7 +2526,7 @@ void MEDCouplingBasicsTest1::testCMesh2() mcIdType cells3[2]={2,3}; DataArrayIdType* arr2; - MEDCouplingUMesh *partMesh3= + auto *partMesh3= dynamic_cast(partMesh1->buildPartAndReduceNodes(cells3,cells3+2,arr2)); CPPUNIT_ASSERT(partMesh3); CPPUNIT_ASSERT_EQUAL(2,(int)partMesh3->getNumberOfCellsWithType(INTERP_KERNEL::NORM_HEXA8)); @@ -2626,7 +2639,7 @@ void MEDCouplingBasicsTest1::testFindNodeOnPlane() double v[3]={0.,0.,2.}; mesh->findNodesOnPlane(pt,v,1e-12,n); CPPUNIT_ASSERT_EQUAL(9,(int)n.size()); - MEDCouplingUMesh *m3dSurf=(MEDCouplingUMesh *)mesh->buildFacePartOfMySelfNode(&n[0],&n[0]+n.size(),true); + auto *m3dSurf=(MEDCouplingUMesh *)mesh->buildFacePartOfMySelfNode(&n[0],&n[0]+n.size(),true); MEDCouplingMappedExtrudedMesh *me=MEDCouplingMappedExtrudedMesh::New(mesh,m3dSurf,0); const DataArrayIdType *da=me->getMesh3DIds(); CPPUNIT_ASSERT_EQUAL(8,(int)me->getNumberOfCells()); diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest1.hxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest1.hxx index f03c67233..2b6eb43e1 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest1.hxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest1.hxx @@ -23,8 +23,7 @@ #include "MEDCouplingBasicsTest.hxx" -#include -#include +#include namespace MEDCoupling { diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest2.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest2.cxx index f9c73195f..e1fbca629 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest2.cxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest2.cxx @@ -19,17 +19,25 @@ // Author : Anthony Geay (CEA/DEN) #include "MEDCouplingBasicsTest2.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include "InterpKernelException.hxx" +#include "MCIdType.hxx" +#include "MCType.hxx" #include "MEDCouplingUMesh.hxx" -#include "MEDCouplingCMesh.hxx" #include "MEDCouplingMappedExtrudedMesh.hxx" #include "MEDCouplingFieldDouble.hxx" #include "MEDCouplingMemArray.hxx" #include "MEDCouplingGaussLocalization.hxx" +#include "NormalizedGeometricTypes" #include #include +#include +#include #include -#include +#include +#include +#include using namespace MEDCoupling; @@ -43,7 +51,7 @@ void MEDCouplingBasicsTest2::testGaussPointField1() const double gsCoo1[12]={ 2*_b-1, 1-4*_b, 2*_b-1, 2.07*_b-1, 1-4*_b, 2*_b-1, 1-4*_a, 2*_a-1, 2*_a-1, 1-4*_a, 2*_a-1, 2*_a-1 }; const double wg1[6]={ 4*_p2, 4*_p2, 4*_p2, 4*_p1, 4*_p1, 4*_p1 }; - std::vector _refCoo1(refCoo1,refCoo1+6); + std::vector const _refCoo1(refCoo1,refCoo1+6); std::vector _gsCoo1(gsCoo1,gsCoo1+12); std::vector _wg1(wg1,wg1+6); // @@ -58,7 +66,7 @@ void MEDCouplingBasicsTest2::testGaussPointField1() CPPUNIT_ASSERT_THROW(f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_QUAD4,_refCoo1,_gsCoo1,_wg1),INTERP_KERNEL::Exception); CPPUNIT_ASSERT_EQUAL(ToIdType(1),f->getNbOfGaussLocalization()); const double refCoo2[8]={ 0.,0., 1.,0., 1.,1., 0.,1. }; - std::vector _refCoo2(refCoo2,refCoo2+8); + std::vector const _refCoo2(refCoo2,refCoo2+8); _gsCoo1.resize(4); _wg1.resize(2); f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_QUAD4,_refCoo2,_gsCoo1,_wg1); CPPUNIT_ASSERT_EQUAL(ToIdType(2),f->getNbOfGaussLocalization()); @@ -110,7 +118,7 @@ void MEDCouplingBasicsTest2::testGaussPointField1() MEDCouplingFieldDouble *f2=f->clone(true); CPPUNIT_ASSERT(f->isEqual(f2,1e-14,1e-14)); MEDCouplingGaussLocalization& gl1=f2->getGaussLocalization(0); - double tmp=gl1.getGaussCoord(1,1); + double const tmp=gl1.getGaussCoord(1,1); CPPUNIT_ASSERT_DOUBLES_EQUAL(2.07*_b-1,tmp,1e-14); gl1.setGaussCoord(1,1,0.07); CPPUNIT_ASSERT(!f->isEqual(f2,1e-14,1e-14)); @@ -168,7 +176,7 @@ void MEDCouplingBasicsTest2::testCellOrientation1() vec[2]=-1.; // connectivity inversion mcIdType *conn=m->getNodalConnectivity()->getPointer(); - mcIdType tmp=conn[11]; + mcIdType const tmp=conn[11]; conn[11]=conn[12]; conn[12]=tmp; m->are2DCellsNotCorrectlyOriented(vec,false,res1); @@ -188,7 +196,7 @@ void MEDCouplingBasicsTest2::testCellOrientation1() void MEDCouplingBasicsTest2::testCellOrientation2() { - MEDCouplingUMesh *m1=0; + MEDCouplingUMesh *m1=nullptr; MEDCouplingUMesh *m2=build3DExtrudedUMesh_1(m1); m1->decrRef(); std::vector res1; @@ -375,7 +383,7 @@ void MEDCouplingBasicsTest2::testNormL12Integ1D() DataArrayDouble *f3=m1->computeCellCenterOfMass(); CPPUNIT_ASSERT_EQUAL(4,(int)f3->getNumberOfTuples()); CPPUNIT_ASSERT_EQUAL(1,(int)f3->getNumberOfComponents()); - double expected9[4]={0.75,5.105,0.8,5.155}; + double const expected9[4]={0.75,5.105,0.8,5.155}; ptr=f3->getConstPointer(); for(int i=0;i<4;i++) CPPUNIT_ASSERT_DOUBLES_EQUAL(expected9[i],ptr[i],1e-12); @@ -384,12 +392,12 @@ void MEDCouplingBasicsTest2::testNormL12Integ1D() MEDCouplingFieldDouble *f2=m1->getMeasureField(false); CPPUNIT_ASSERT_EQUAL(4,(int)f2->getArray()->getNumberOfTuples()); CPPUNIT_ASSERT_EQUAL(1,(int)f2->getNumberOfComponents()); - double expected1[4]={0.5,0.21,-0.6,-0.31}; + double const expected1[4]={0.5,0.21,-0.6,-0.31}; ptr=f2->getArray()->getConstPointer(); for(int i=0;i<4;i++) CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],ptr[i],1e-12); f2->decrRef(); - double expected2[4]={0.5,0.21,0.6,0.31}; + double const expected2[4]={0.5,0.21,0.6,0.31}; f2=m1->getMeasureField(true); ptr=f2->getArray()->getConstPointer(); for(int i=0;i<4;i++) @@ -398,19 +406,19 @@ void MEDCouplingBasicsTest2::testNormL12Integ1D() //integral double res[3]; f1->integral(false,res); - double expected3[3]={0.9866,-0.3615,0.4217}; + double const expected3[3]={0.9866,-0.3615,0.4217}; for(int i=0;i<3;i++) CPPUNIT_ASSERT_DOUBLES_EQUAL(expected3[i],res[i],1e-12); CPPUNIT_ASSERT_DOUBLES_EQUAL(expected3[0],f1->integral(0,false),1e-12); CPPUNIT_ASSERT_DOUBLES_EQUAL(expected3[1],f1->integral(1,false),1e-12); CPPUNIT_ASSERT_DOUBLES_EQUAL(expected3[2],f1->integral(2,false),1e-12); f1->integral(true,res); - double expected4[3]={-3.4152,8.7639,-14.6879}; + double const expected4[3]={-3.4152,8.7639,-14.6879}; for(int i=0;i<3;i++) CPPUNIT_ASSERT_DOUBLES_EQUAL(expected4[i],res[i],1e-12); //normL1 f1->normL1(res); - double expected5[3]={6.979506172839505, 16.89018518518518, 27.02969135802469}; + double const expected5[3]={6.979506172839505, 16.89018518518518, 27.02969135802469}; for(int i=0;i<3;i++) CPPUNIT_ASSERT_DOUBLES_EQUAL(expected5[i],res[i],1e-12); CPPUNIT_ASSERT_DOUBLES_EQUAL(expected5[0],f1->normL1(0),1e-12); @@ -418,7 +426,7 @@ void MEDCouplingBasicsTest2::testNormL12Integ1D() CPPUNIT_ASSERT_DOUBLES_EQUAL(expected5[2],f1->normL1(2),1e-12); //normL2 f1->normL2(res); - double expected7[3]={7.090910979452395, 16.9275542960123, 27.053271464160858}; + double const expected7[3]={7.090910979452395, 16.9275542960123, 27.053271464160858}; for(int i=0;i<3;i++) CPPUNIT_ASSERT_DOUBLES_EQUAL(expected7[i],res[i],1e-9); CPPUNIT_ASSERT_DOUBLES_EQUAL(expected7[0],f1->normL2(0),1e-9); @@ -454,7 +462,7 @@ void MEDCouplingBasicsTest2::testNormL12Integ1D() f3=m1->computeCellCenterOfMass(); CPPUNIT_ASSERT_EQUAL(4,(int)f3->getNumberOfTuples()); CPPUNIT_ASSERT_EQUAL(2,(int)f3->getNumberOfComponents()); - double expected10[8]={0.75,0.75,5.105,5.105,0.8,0.8,5.155,5.155}; + double const expected10[8]={0.75,0.75,5.105,5.105,0.8,0.8,5.155,5.155}; ptr=f3->getConstPointer(); for(int i=0;i<8;i++) CPPUNIT_ASSERT_DOUBLES_EQUAL(expected10[i],ptr[i],1e-12); @@ -490,7 +498,7 @@ void MEDCouplingBasicsTest2::testAreaBary2D() MEDCouplingFieldDouble *f1=m1->getMeasureField(false); CPPUNIT_ASSERT_EQUAL(10,(int)f1->getArray()->getNumberOfTuples()); CPPUNIT_ASSERT_EQUAL(1,(int)f1->getNumberOfComponents()); - double expected1[10]={-0.5,-1,-1.5,-0.5,-1, 0.5,1,1.5,0.5,1}; + double const expected1[10]={-0.5,-1,-1.5,-0.5,-1, 0.5,1,1.5,0.5,1}; const double *ptr=f1->getArray()->getConstPointer(); for(int i=0;i<10;i++) CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],ptr[i],1e-12); @@ -503,7 +511,7 @@ void MEDCouplingBasicsTest2::testAreaBary2D() DataArrayDouble *f2=m1->computeCellCenterOfMass(); CPPUNIT_ASSERT_EQUAL(10,(int)f2->getNumberOfTuples()); CPPUNIT_ASSERT_EQUAL(2,(int)f2->getNumberOfComponents()); - double expected2[20]={ + double const expected2[20]={ 0.5,0.3333333333333333,0.5,0.5,0.5,0.77777777777777777,0.5,0.3333333333333333,0.5,0.5, 0.5,0.3333333333333333,0.5,0.5,0.5,0.77777777777777777,0.5,0.3333333333333333,0.5,0.5, }; @@ -523,7 +531,7 @@ void MEDCouplingBasicsTest2::testAreaBary2D() CPPUNIT_ASSERT_EQUAL(10,(int)f2->getNumberOfTuples()); CPPUNIT_ASSERT_EQUAL(3,(int)f2->getNumberOfComponents()); ptr=f2->getConstPointer(); - double expected3[30]={ + double const expected3[30]={ 0.5,0.3333333333333333,0.,0.5,0.5,0.,0.5,0.77777777777777777,0.,0.5,0.3333333333333333,0.,0.5,0.5,0., 0.5,0.3333333333333333,0.,0.5,0.5,0.,0.5,0.77777777777777777,0.,0.5,0.3333333333333333,0.,0.5,0.5,0. }; @@ -593,7 +601,7 @@ void MEDCouplingBasicsTest2::testAreaBary3D() , 55 , 5 , 12 , 65 , -1 , 66 , 67 , 65 , 55 , 56 , 57 , -1 , 63 , 66 , 57 , 59 , 64 , -1 , 64 , 62 , 58 , 59 , -1 , 60 , 63 , 66 , 67 , 68 , 61 , -1 , 61 , 68 , 20 , 21 , -1 , 67 , 68 , 20 , 12 , 65}; - double barys[]={ -0.0165220465527 , -0.0190922868195 , 0.158882733414 , + double const barys[]={ -0.0165220465527 , -0.0190922868195 , 0.158882733414 , 0.0287618656076 , 0.135874379934 , -0.14601588119 , -0.147128055553 , 0.0465995097041 , -0.049391174453 , -0.00142506732317 , -0.0996953090351 , -0.115159183132 }; @@ -674,12 +682,12 @@ void MEDCouplingBasicsTest2::testRenumberCellsForFields() const double gsCoo1[12]={ 2*_b-1, 1-4*_b, 2*_b-1, 2.07*_b-1, 1-4*_b, 2*_b-1, 1-4*_a, 2*_a-1, 2*_a-1, 1-4*_a, 2*_a-1, 2*_a-1 }; const double wg1[6]={ 4*_p2, 4*_p2, 4*_p2, 4*_p1, 4*_p1, 4*_p1 }; - std::vector _refCoo1(refCoo1,refCoo1+6); + std::vector const _refCoo1(refCoo1,refCoo1+6); std::vector _gsCoo1(gsCoo1,gsCoo1+12); std::vector _wg1(wg1,wg1+6); f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_TRI3,_refCoo1,_gsCoo1,_wg1); const double refCoo2[8]={ 0.,0., 1.,0., 1.,1., 0.,1. }; - std::vector _refCoo2(refCoo2,refCoo2+8); + std::vector const _refCoo2(refCoo2,refCoo2+8); _gsCoo1.resize(4); _wg1.resize(2); f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_QUAD4,_refCoo2,_gsCoo1,_wg1); arr=DataArrayDouble::New(); @@ -693,7 +701,7 @@ void MEDCouplingBasicsTest2::testRenumberCellsForFields() CPPUNIT_ASSERT(f->isEqual(fCpy,1e-12,1e-12)); f->renumberCells(renumber1,false); CPPUNIT_ASSERT(!f->isEqual(fCpy,1e-12,1e-12)); - double expected2[36]={21.,1021.,22.,1022.,23.,1023.,24.,1024.,25.,1025.,26.,1026., 11.,1011.,12.,1012.,13.,1013.,14.,1014.,15.,1015.,16.,1016., 41.,1041.,42.,1042., 1.,1001.,2.,1002., 31.,1031.,32.,1032.}; + double const expected2[36]={21.,1021.,22.,1022.,23.,1023.,24.,1024.,25.,1025.,26.,1026., 11.,1011.,12.,1012.,13.,1013.,14.,1014.,15.,1015.,16.,1016., 41.,1041.,42.,1042., 1.,1001.,2.,1002., 31.,1031.,32.,1032.}; ptr=f->getArray()->getConstPointer(); for(int i=0;i<36;i++) CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],ptr[i],1e-12); @@ -716,7 +724,7 @@ void MEDCouplingBasicsTest2::testRenumberCellsForFields() CPPUNIT_ASSERT(f->isEqual(fCpy,1e-12,1e-12)); f->renumberCells(renumber1,false); CPPUNIT_ASSERT(!f->isEqual(fCpy,1e-12,1e-12)); - double expected3[36]={21.,1021.,22.,1022.,23.,1023.,11.,1011.,12.,1012.,13.,1013.,41.,1041.,42.,1042.,43.,1043.,44.,1044.,1.,1001.,2.,1002.,3.,1003.,4.,1004.,31.,1031.,32.,1032.,33.,1033.,34.,1034.}; + double const expected3[36]={21.,1021.,22.,1022.,23.,1023.,11.,1011.,12.,1012.,13.,1013.,41.,1041.,42.,1042.,43.,1043.,44.,1044.,1.,1001.,2.,1002.,3.,1003.,4.,1004.,31.,1031.,32.,1032.,33.,1033.,34.,1034.}; ptr=f->getArray()->getConstPointer(); for(int i=0;i<36;i++) CPPUNIT_ASSERT_DOUBLES_EQUAL(expected3[i],ptr[i],1e-12); @@ -735,7 +743,7 @@ void MEDCouplingBasicsTest2::testRenumberNodesForFields() f->setMesh(m); CPPUNIT_ASSERT_EQUAL(ToIdType(9),f->getNumberOfMeshPlacesExpected()); DataArrayDouble *arr=DataArrayDouble::New(); - mcIdType nbOfNodes=m->getNumberOfNodes(); + mcIdType const nbOfNodes=m->getNumberOfNodes(); arr->alloc(nbOfNodes,3); f->setArray(arr); arr->decrRef(); @@ -778,10 +786,10 @@ void MEDCouplingBasicsTest2::testConvertQuadraticCellsToLinear() { MEDCouplingUMesh *mesh=build2DTargetMesh_3(); mesh->checkConsistencyLight(); - std::set types=mesh->getAllGeoTypes(); + std::set const types=mesh->getAllGeoTypes(); CPPUNIT_ASSERT_EQUAL(5,(int)types.size()); INTERP_KERNEL::NormalizedCellType expected1[5]={INTERP_KERNEL::NORM_POLYGON, INTERP_KERNEL::NORM_TRI3, INTERP_KERNEL::NORM_QUAD4, INTERP_KERNEL::NORM_TRI6, INTERP_KERNEL::NORM_QUAD8}; - std::set expected1Bis(expected1,expected1+5); + std::set const expected1Bis(expected1,expected1+5); CPPUNIT_ASSERT(expected1Bis==types); CPPUNIT_ASSERT(mesh->isPresenceOfQuadratic()); CPPUNIT_ASSERT_EQUAL(ToIdType(62),mesh->getNodalConnectivityArrayLen()); @@ -794,10 +802,10 @@ void MEDCouplingBasicsTest2::testConvertQuadraticCellsToLinear() MEDCouplingFieldDouble *f2=mesh->getMeasureField(false); CPPUNIT_ASSERT(f1->getArray()->isEqual(*f2->getArray(),1e-12)); CPPUNIT_ASSERT_EQUAL(ToIdType(48),mesh->getNodalConnectivityArrayLen()); - std::set types2=mesh->getAllGeoTypes(); + std::set const types2=mesh->getAllGeoTypes(); CPPUNIT_ASSERT_EQUAL(3,(int)types2.size()); INTERP_KERNEL::NormalizedCellType expected2[3]={INTERP_KERNEL::NORM_POLYGON, INTERP_KERNEL::NORM_TRI3, INTERP_KERNEL::NORM_QUAD4}; - std::set expected2Bis(expected2,expected2+3); + std::set const expected2Bis(expected2,expected2+3); CPPUNIT_ASSERT(expected2Bis==types2); // f1->decrRef(); @@ -812,42 +820,42 @@ void MEDCouplingBasicsTest2::testCheckGeoEquivalWith() DataArrayIdType *cellCor,*nodeCor; //First test mesh1 mesh1->checkGeoEquivalWith(mesh1,0,1e-12,cellCor,nodeCor);//deepEqual - CPPUNIT_ASSERT(cellCor==0); - CPPUNIT_ASSERT(nodeCor==0); + CPPUNIT_ASSERT(cellCor==nullptr); + CPPUNIT_ASSERT(nodeCor==nullptr); mesh1->checkGeoEquivalWith(mesh1,1,1e-12,cellCor,nodeCor);//fastEqual - CPPUNIT_ASSERT(cellCor==0); - CPPUNIT_ASSERT(nodeCor==0); + CPPUNIT_ASSERT(cellCor==nullptr); + CPPUNIT_ASSERT(nodeCor==nullptr); mesh1->checkGeoEquivalWith(mesh1,10,1e-12,cellCor,nodeCor);//deepEqual with geo permutations - CPPUNIT_ASSERT(cellCor==0); - CPPUNIT_ASSERT(nodeCor==0); + CPPUNIT_ASSERT(cellCor==nullptr); + CPPUNIT_ASSERT(nodeCor==nullptr); //Second test mesh1 and mesh2 are 2 different meshes instance mesh1->checkGeoEquivalWith(mesh2,0,1e-12,cellCor,nodeCor);//deepEqual - CPPUNIT_ASSERT(cellCor==0); - CPPUNIT_ASSERT(nodeCor==0); + CPPUNIT_ASSERT(cellCor==nullptr); + CPPUNIT_ASSERT(nodeCor==nullptr); mesh1->checkGeoEquivalWith(mesh2,1,1e-12,cellCor,nodeCor);//fastEqual - CPPUNIT_ASSERT(cellCor==0); - CPPUNIT_ASSERT(nodeCor==0); + CPPUNIT_ASSERT(cellCor==nullptr); + CPPUNIT_ASSERT(nodeCor==nullptr); mesh1->checkGeoEquivalWith(mesh2,10,1e-12,cellCor,nodeCor);//deepEqual with geo permutations - CPPUNIT_ASSERT(cellCor==0); - CPPUNIT_ASSERT(nodeCor==0); + CPPUNIT_ASSERT(cellCor==nullptr); + CPPUNIT_ASSERT(nodeCor==nullptr); //Third test : cell permutation by keeping the first the middle and the last as it is. const mcIdType renum[]={0,2,1,3,4,5,6,8,7,9}; mesh2->renumberCells(renum,false); CPPUNIT_ASSERT_THROW(mesh1->checkGeoEquivalWith(mesh2,0,1e-12,cellCor,nodeCor),INTERP_KERNEL::Exception);//deepEqual fails - CPPUNIT_ASSERT(cellCor==0); - CPPUNIT_ASSERT(nodeCor==0); + CPPUNIT_ASSERT(cellCor==nullptr); + CPPUNIT_ASSERT(nodeCor==nullptr); mesh1->checkGeoEquivalWith(mesh2,1,1e-12,cellCor,nodeCor);//fastEqual do not see anything - CPPUNIT_ASSERT(cellCor==0); - CPPUNIT_ASSERT(nodeCor==0); + CPPUNIT_ASSERT(cellCor==nullptr); + CPPUNIT_ASSERT(nodeCor==nullptr); mesh1->checkGeoEquivalWith(mesh2,10,1e-12,cellCor,nodeCor);//deepEqual with geo permutations CPPUNIT_ASSERT(cellCor); CPPUNIT_ASSERT_EQUAL(10,(int)cellCor->getNumberOfTuples()); CPPUNIT_ASSERT_EQUAL(1,(int)cellCor->getNumberOfComponents()); CPPUNIT_ASSERT(std::equal(renum,renum+10,cellCor->getConstPointer())); - CPPUNIT_ASSERT(nodeCor==0); + CPPUNIT_ASSERT(nodeCor==nullptr); cellCor->decrRef(); - cellCor=0; - CPPUNIT_ASSERT(nodeCor==0); + cellCor=nullptr; + CPPUNIT_ASSERT(nodeCor==nullptr); //4th test : cell and node permutation by keeping the first the middle and the last as it is. mesh2->decrRef(); mesh2=build2DTargetMesh_3(); @@ -855,11 +863,11 @@ void MEDCouplingBasicsTest2::testCheckGeoEquivalWith() mesh2->renumberCells(renum,false); mesh2->renumberNodes(renum2,11); CPPUNIT_ASSERT_THROW(mesh1->checkGeoEquivalWith(mesh2,0,1e-12,cellCor,nodeCor),INTERP_KERNEL::Exception);//deepEqual fails - CPPUNIT_ASSERT(cellCor==0); - CPPUNIT_ASSERT(nodeCor==0); + CPPUNIT_ASSERT(cellCor==nullptr); + CPPUNIT_ASSERT(nodeCor==nullptr); mesh1->checkGeoEquivalWith(mesh2,1,1e-12,cellCor,nodeCor);//fastEqual do not see anything - CPPUNIT_ASSERT(cellCor==0); - CPPUNIT_ASSERT(nodeCor==0); + CPPUNIT_ASSERT(cellCor==nullptr); + CPPUNIT_ASSERT(nodeCor==nullptr); mesh1->checkGeoEquivalWith(mesh2,10,1e-12,cellCor,nodeCor);//deepEqual with geo permutations CPPUNIT_ASSERT(cellCor); CPPUNIT_ASSERT_EQUAL(10,(int)cellCor->getNumberOfTuples()); @@ -870,9 +878,9 @@ void MEDCouplingBasicsTest2::testCheckGeoEquivalWith() CPPUNIT_ASSERT_EQUAL(1,(int)nodeCor->getNumberOfComponents()); CPPUNIT_ASSERT(std::equal(renum2,renum2+11,nodeCor->getConstPointer())); cellCor->decrRef(); - cellCor=0; + cellCor=nullptr; nodeCor->decrRef(); - nodeCor=0; + nodeCor=nullptr; //5th test : modification of the last cell to check fastCheck detection. mesh2->decrRef(); mesh2=build2DTargetMesh_3(); @@ -884,14 +892,14 @@ void MEDCouplingBasicsTest2::testCheckGeoEquivalWith() } catch(INTERP_KERNEL::Exception&) { isExcep=true; } CPPUNIT_ASSERT(isExcep); isExcep=false; - CPPUNIT_ASSERT(cellCor==0); - CPPUNIT_ASSERT(nodeCor==0); + CPPUNIT_ASSERT(cellCor==nullptr); + CPPUNIT_ASSERT(nodeCor==nullptr); try { mesh1->checkGeoEquivalWith(mesh2,1,1e-12,cellCor,nodeCor);//fastEqual has detected something } catch(INTERP_KERNEL::Exception&) { isExcep=true; } CPPUNIT_ASSERT(isExcep); isExcep=false; - CPPUNIT_ASSERT(cellCor==0); - CPPUNIT_ASSERT(nodeCor==0); + CPPUNIT_ASSERT(cellCor==nullptr); + CPPUNIT_ASSERT(nodeCor==nullptr); mesh2->checkGeoEquivalWith(mesh1,10,1e-12,cellCor,nodeCor);//deepEqual with geo permutations CPPUNIT_ASSERT(cellCor); CPPUNIT_ASSERT_EQUAL(10,(int)cellCor->getNumberOfTuples()); @@ -902,9 +910,9 @@ void MEDCouplingBasicsTest2::testCheckGeoEquivalWith() CPPUNIT_ASSERT_EQUAL(1,(int)nodeCor->getNumberOfComponents()); CPPUNIT_ASSERT(std::equal(renum2,renum2+11,nodeCor->getConstPointer())); cellCor->decrRef(); - cellCor=0; + cellCor=nullptr; nodeCor->decrRef(); - nodeCor=0; + nodeCor=nullptr; // mesh1->decrRef(); mesh2->decrRef(); @@ -916,8 +924,8 @@ void MEDCouplingBasicsTest2::testCheckGeoEquivalWith2() MEDCouplingUMesh *mesh2=build2DTargetMesh_1(); DataArrayIdType *cellCor,*nodeCor; mesh1->checkGeoEquivalWith(mesh2,10,1e-12,cellCor,nodeCor); - CPPUNIT_ASSERT(cellCor==0); - CPPUNIT_ASSERT(nodeCor!=0); + CPPUNIT_ASSERT(cellCor==nullptr); + CPPUNIT_ASSERT(nodeCor!=nullptr); const mcIdType expected1[9]={0, 1, 3, 4, 5, 6, 7, 8, 9}; for(int i=0;i<9;i++) CPPUNIT_ASSERT_EQUAL(expected1[i],nodeCor->getIJ(i,0)); @@ -930,7 +938,7 @@ void MEDCouplingBasicsTest2::testCheckGeoEquivalWith2() void MEDCouplingBasicsTest2::testCopyTinyStringsFromOnFields() { MEDCouplingUMesh *m=build3DSurfTargetMesh_1(); - std::size_t nbOfCells=m->getNumberOfCells(); + std::size_t const nbOfCells=m->getNumberOfCells(); MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_CELLS,LINEAR_TIME); f->setMesh(m); CPPUNIT_ASSERT_EQUAL(ToIdType(5),f->getNumberOfMeshPlacesExpected()); @@ -1106,7 +1114,7 @@ void MEDCouplingBasicsTest2::testChangeUnderlyingMesh1() void MEDCouplingBasicsTest2::testGetMaxValue1() { MEDCouplingUMesh *m=build3DSurfTargetMesh_1(); - std::size_t nbOfCells=m->getNumberOfCells(); + std::size_t const nbOfCells=m->getNumberOfCells(); MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_CELLS,LINEAR_TIME); f->setMesh(m); DataArrayDouble *a1=DataArrayDouble::New(); @@ -1347,7 +1355,7 @@ void MEDCouplingBasicsTest2::testBuildSubPart1() CPPUNIT_ASSERT_EQUAL(6,(int)f2->getMesh()->getNumberOfNodes()); CPPUNIT_ASSERT_EQUAL(2,f2->getMesh()->getSpaceDimension()); CPPUNIT_ASSERT_EQUAL(2,f2->getMesh()->getMeshDimension()); - MEDCouplingUMesh *m2C=dynamic_cast(const_cast(f2->getMesh())); + auto *m2C=dynamic_cast(const_cast(f2->getMesh())); CPPUNIT_ASSERT_EQUAL(ToIdType(13),m2C->getNodalConnectivityArrayLen()); const double expected2[12]={0.2, -0.3, 0.7, -0.3, 0.2, 0.2, 0.7, 0.2, 0.2, 0.7, 0.7, 0.7}; for(int i=0;i<12;i++) @@ -1847,7 +1855,7 @@ void MEDCouplingBasicsTest2::testMaxPerTuple1() CPPUNIT_ASSERT_DOUBLES_EQUAL(5.6,f2->getIJ(i,0),1e-13); f2->decrRef(); // - DataArrayIdType *d2I=0; + DataArrayIdType *d2I=nullptr; DataArrayDouble *d2=array->maxPerTupleWithCompoId(d2I); CPPUNIT_ASSERT_EQUAL(1,(int)d2->getNumberOfComponents()); CPPUNIT_ASSERT_EQUAL(5,(int)d2->getNumberOfTuples()); @@ -1966,14 +1974,14 @@ void MEDCouplingBasicsTest2::testIsEqualWithoutConsideringStr1() mesh2->getCoords()->setInfoOnComponent(1,""); CPPUNIT_ASSERT(mesh1->isEqual(mesh2,1e-12)); CPPUNIT_ASSERT(mesh1->isEqualWithoutConsideringStr(mesh2,1e-12)); - double tmp=mesh2->getCoords()->getIJ(0,3); + double const tmp=mesh2->getCoords()->getIJ(0,3); mesh2->getCoords()->setIJ(0,3,9999.); CPPUNIT_ASSERT(!mesh1->isEqual(mesh2,1e-12)); CPPUNIT_ASSERT(!mesh1->isEqualWithoutConsideringStr(mesh2,1e-12)); mesh2->getCoords()->setIJ(0,3,tmp); CPPUNIT_ASSERT(mesh1->isEqual(mesh2,1e-12)); CPPUNIT_ASSERT(mesh1->isEqualWithoutConsideringStr(mesh2,1e-12)); - mcIdType tmp2=mesh2->getNodalConnectivity()->getIJ(0,4); + mcIdType const tmp2=mesh2->getNodalConnectivity()->getIJ(0,4); mesh2->getNodalConnectivity()->setIJ(0,4,0); CPPUNIT_ASSERT(!mesh1->isEqual(mesh2,1e-12)); CPPUNIT_ASSERT(!mesh1->isEqualWithoutConsideringStr(mesh2,1e-12)); diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest2.hxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest2.hxx index a945f2f42..71f554231 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest2.hxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest2.hxx @@ -23,8 +23,7 @@ #include "MEDCouplingBasicsTest.hxx" -#include -#include +#include namespace MEDCoupling { diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest3.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest3.cxx index bf292054b..1bb5c4a9d 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest3.cxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest3.cxx @@ -19,17 +19,28 @@ // Author : Anthony Geay (CEA/DEN) #include "MEDCouplingBasicsTest3.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include "MCType.hxx" +#include "MEDCouplingPointSet.hxx" +#include "MCIdType.hxx" +#include "MCAuto.hxx" +#include "InterpKernelException.hxx" #include "MEDCouplingUMesh.hxx" #include "MEDCouplingCMesh.hxx" #include "MEDCouplingMappedExtrudedMesh.hxx" #include "MEDCouplingFieldDouble.hxx" -#include "MEDCouplingMemArray.hxx" #include "MEDCouplingMemArray.txx" #include "MEDCouplingGaussLocalization.hxx" +#include "NormalizedGeometricTypes" +#include #include -#include -#include +#include +#include +#include +#include +#include +#include using namespace MEDCoupling; @@ -178,7 +189,7 @@ void MEDCouplingBasicsTest3::testFieldDoubleZipConnectivity1() MEDCouplingUMesh *m2=build2DTargetMesh_1(); const mcIdType cells1[3]={2,3,4}; MEDCouplingPointSet *m3_1=m2->buildPartOfMySelf(cells1,cells1+3,true); - MEDCouplingUMesh *m3=dynamic_cast(m3_1); + auto *m3=dynamic_cast(m3_1); CPPUNIT_ASSERT(m3); m2->decrRef(); MEDCouplingUMesh *m4=build2DSourceMesh_1(); @@ -490,7 +501,7 @@ void MEDCouplingBasicsTest3::testDaDoubleGetMinMaxValues1() void MEDCouplingBasicsTest3::testFieldDoubleGetMinMaxValues2() { - MEDCouplingUMesh *m1=0; + MEDCouplingUMesh *m1=nullptr; MEDCouplingUMesh *m2=build3DExtrudedUMesh_1(m1); m1->decrRef(); CPPUNIT_ASSERT_EQUAL(18,(int)m2->getNumberOfCells()); @@ -669,8 +680,8 @@ void MEDCouplingBasicsTest3::testKeepSetSelectedComponent1() a1->setInfoOnComponent(2,"cccc"); a1->setInfoOnComponent(3,"dddd"); const mcIdType arr2[6]={1,2,1,2,0,0}; - std::vector arr2V(arr2,arr2+6); - DataArrayDouble *a2=static_cast(a1->keepSelectedComponents(arr2V)); + std::vector const arr2V(arr2,arr2+6); + auto *a2=static_cast(a1->keepSelectedComponents(arr2V)); CPPUNIT_ASSERT_EQUAL(6,(int)a2->getNumberOfComponents()); CPPUNIT_ASSERT_EQUAL(5,(int)a2->getNumberOfTuples()); CPPUNIT_ASSERT(std::string(a2->getInfoOnComponent(0))=="bbbb"); @@ -683,7 +694,7 @@ void MEDCouplingBasicsTest3::testKeepSetSelectedComponent1() for(int i=0;i<30;i++) CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],a2->getIJ(0,i),1e-14); MCAuto a3(a1->convertToIntArr()); - DataArrayInt *a4=static_cast(a3->keepSelectedComponents(arr2V)); + auto *a4=static_cast(a3->keepSelectedComponents(arr2V)); CPPUNIT_ASSERT_EQUAL(6,(int)a4->getNumberOfComponents()); CPPUNIT_ASSERT_EQUAL(5,(int)a4->getNumberOfTuples()); CPPUNIT_ASSERT(std::string(a4->getInfoOnComponent(0))=="bbbb"); @@ -696,12 +707,12 @@ void MEDCouplingBasicsTest3::testKeepSetSelectedComponent1() CPPUNIT_ASSERT_EQUAL((int)expected1[i],a4->getIJ(0,i)); // setSelectedComponents const mcIdType arr3[2]={3,2}; - std::vector arr3V(arr3,arr3+2); - DataArrayDouble *a5=static_cast(a1->keepSelectedComponents(arr3V)); + std::vector const arr3V(arr3,arr3+2); + auto *a5=static_cast(a1->keepSelectedComponents(arr3V)); a5->setInfoOnComponent(0,"eeee"); a5->setInfoOnComponent(1,"ffff"); const mcIdType arr4[2]={1,2}; - std::vector arr4V(arr4,arr4+2); + std::vector const arr4V(arr4,arr4+2); a2->setSelectedComponents(a5,arr4V); CPPUNIT_ASSERT_EQUAL(6,(int)a2->getNumberOfComponents()); CPPUNIT_ASSERT_EQUAL(5,(int)a2->getNumberOfTuples()); @@ -732,8 +743,8 @@ void MEDCouplingBasicsTest3::testKeepSetSelectedComponent1() const mcIdType arr5[3]={2,3,6}; const mcIdType arr6[3]={2,7,5}; const mcIdType arr7[4]={2,1,4,6}; - std::vector arr5V(arr5,arr5+3); - std::vector arr6V(arr6,arr6+3); + std::vector const arr5V(arr5,arr5+3); + std::vector const arr6V(arr6,arr6+3); std::vector arr7V(arr7,arr7+4); CPPUNIT_ASSERT_THROW(a2->keepSelectedComponents(arr5V),INTERP_KERNEL::Exception); CPPUNIT_ASSERT_THROW(a2->keepSelectedComponents(arr6V),INTERP_KERNEL::Exception); @@ -766,7 +777,7 @@ void MEDCouplingBasicsTest3::testKeepSetSelectedComponent2() f1->checkConsistencyLight(); // const mcIdType arr2[6]={1,2,1,2,0,0}; - std::vector arr2V(arr2,arr2+6); + std::vector const arr2V(arr2,arr2+6); MEDCouplingFieldDouble *f2=f1->keepSelectedComponents(arr2V); CPPUNIT_ASSERT(f2->getMesh()==f1->getMesh()); CPPUNIT_ASSERT(f2->getTimeDiscretization()==ONE_TIME); @@ -788,14 +799,14 @@ void MEDCouplingBasicsTest3::testKeepSetSelectedComponent2() CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f2->getIJ(0,i),1e-14); //setSelectedComponents const mcIdType arr3[2]={3,2}; - std::vector arr3V(arr3,arr3+2); + std::vector const arr3V(arr3,arr3+2); MEDCouplingFieldDouble *f5=f1->keepSelectedComponents(arr3V); f5->setTime(6.7,8,9); f5->getArray()->setInfoOnComponent(0,"eeee"); f5->getArray()->setInfoOnComponent(1,"ffff"); f5->checkConsistencyLight(); const mcIdType arr4[2]={1,2}; - std::vector arr4V(arr4,arr4+2); + std::vector const arr4V(arr4,arr4+2); f2->setSelectedComponents(f5,arr4V); CPPUNIT_ASSERT_EQUAL(6,(int)f2->getNumberOfComponents()); CPPUNIT_ASSERT_EQUAL(5,(int)f2->getNumberOfTuples()); @@ -934,7 +945,7 @@ void MEDCouplingBasicsTest3::testElementaryDAThrowAndSpecialCases() CPPUNIT_ASSERT(!((dbl->reprZip().find("Number of components : 1"))==std::string::npos)); std::ostringstream ret; - dbl->writeVTK(ret,2,"file.tmp",0); + dbl->writeVTK(ret,2,"file.tmp",nullptr); CPPUNIT_ASSERT(!((ret.str().find("getIJ(1,0)); CPPUNIT_ASSERT_EQUAL(ToIdType(11),c->getIJ(2,0)); c->decrRef(); - DataArrayIdType *cI=0; + DataArrayIdType *cI=nullptr; mesh->getNodeIdsNearPoints(pts,3,1e-7,c,cI); CPPUNIT_ASSERT_EQUAL(ToIdType(4),cI->getNumberOfTuples()); CPPUNIT_ASSERT_EQUAL(ToIdType(4),c->getNumberOfTuples()); @@ -1455,7 +1466,7 @@ void MEDCouplingBasicsTest3::testExtrudedMesh6() f->changeSpaceDimension(2); // const double center[2]={0.,0.}; - f->rotate(center,0,M_PI/3); + f->rotate(center,nullptr,M_PI/3); MEDCouplingUMesh *g=c->buildExtrudedMesh(f,0); g->checkConsistencyLight(); const double expected1[]={ 0.4330127018922193, 0.4330127018922193, 0.649519052838329, 1.2990381056766578, 1.299038105676658, 1.948557158514987, 2.1650635094610955, 2.1650635094610964, 3.2475952641916446, 3.031088913245533, 3.0310889132455352, 4.546633369868303 }; @@ -1743,7 +1754,7 @@ void MEDCouplingBasicsTest3::testFieldMeld1() for(int i=0;i<15;i++) CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f3->getIJ(0,i),1e-12); int dt,it; - double time=f3->getTime(dt,it); + double const time=f3->getTime(dt,it); CPPUNIT_ASSERT_DOUBLES_EQUAL(3.4,time,1e-14); CPPUNIT_ASSERT_EQUAL(2,dt); CPPUNIT_ASSERT_EQUAL(1,it); @@ -1958,7 +1969,7 @@ void MEDCouplingBasicsTest3::testAreCellsIncludedIn1() { MEDCouplingUMesh *m=build3DSurfTargetMesh_1(); const mcIdType pt[2]={1,3}; - MEDCouplingUMesh *m2=(MEDCouplingUMesh *)m->buildPartOfMySelf(pt,pt+2,true); + auto *m2=(MEDCouplingUMesh *)m->buildPartOfMySelf(pt,pt+2,true); DataArrayIdType *tmp; CPPUNIT_ASSERT(m->areCellsIncludedIn(m2,0,tmp)); CPPUNIT_ASSERT_EQUAL(2,(int)tmp->getNumberOfTuples()); @@ -2234,7 +2245,7 @@ void MEDCouplingBasicsTest3::testAreCellsIncludedIn2() { const char myName[]="Vitoo"; MEDCouplingUMesh *m=build3DSurfTargetMesh_1(); - MEDCouplingUMesh *m2=(MEDCouplingUMesh *)m->buildPartOfMySelf(0,0,true); + auto *m2=(MEDCouplingUMesh *)m->buildPartOfMySelf(nullptr,nullptr,true); CPPUNIT_ASSERT_EQUAL(0,(int)m2->getNumberOfCells()); CPPUNIT_ASSERT_EQUAL(3,m2->getSpaceDimension()); CPPUNIT_ASSERT_EQUAL(2,m2->getMeshDimension()); @@ -2375,9 +2386,9 @@ void MEDCouplingBasicsTest3::testMergeUMeshes2() MEDCouplingUMesh *m3=build3DSurfTargetMesh_1(); // const mcIdType vec1[3]={0,2,3}; - MEDCouplingUMesh *m2_2=(MEDCouplingUMesh *)m2->buildPartOfMySelf(vec1,vec1+3,false); + auto *m2_2=(MEDCouplingUMesh *)m2->buildPartOfMySelf(vec1,vec1+3,false); const mcIdType vec2[2]={1,1}; - MEDCouplingUMesh *m3_2=(MEDCouplingUMesh *)m3->buildPartOfMySelf(vec2,vec2+2,false); + auto *m3_2=(MEDCouplingUMesh *)m3->buildPartOfMySelf(vec2,vec2+2,false); // std::vector ms(3); std::vector ms2(3); @@ -2395,22 +2406,22 @@ void MEDCouplingBasicsTest3::testMergeUMeshes2() m4bis->decrRef(); // const mcIdType vec3[5]={0,1,2,3,4}; - MEDCouplingUMesh *m4_1=(MEDCouplingUMesh *)m4->buildPartOfMySelf(vec3,vec3+5,false); + auto *m4_1=(MEDCouplingUMesh *)m4->buildPartOfMySelf(vec3,vec3+5,false); m4_1->setName(m1->getName().c_str()); CPPUNIT_ASSERT(m4_1->isEqual(m1,1e-12)); m4_1->decrRef(); // const mcIdType vec4[3]={5,6,7}; - MEDCouplingUMesh *m4_2=(MEDCouplingUMesh *)m4->buildPartOfMySelf(vec4,vec4+3,false); - DataArrayIdType *cellCor=0; - DataArrayIdType *nodeCor=0; + auto *m4_2=(MEDCouplingUMesh *)m4->buildPartOfMySelf(vec4,vec4+3,false); + DataArrayIdType *cellCor=nullptr; + DataArrayIdType *nodeCor=nullptr; m4_2->checkGeoEquivalWith(m2_2,10,1e-12,cellCor,nodeCor); - CPPUNIT_ASSERT(cellCor==0); - CPPUNIT_ASSERT(nodeCor==0); + CPPUNIT_ASSERT(cellCor==nullptr); + CPPUNIT_ASSERT(nodeCor==nullptr); m4_2->decrRef(); // const mcIdType vec5[2]={8,9}; - MEDCouplingUMesh *m4_3=(MEDCouplingUMesh *)m4->buildPartOfMySelf(vec5,vec5+2,false); + auto *m4_3=(MEDCouplingUMesh *)m4->buildPartOfMySelf(vec5,vec5+2,false); CPPUNIT_ASSERT_EQUAL(2,(int)m4_3->getNumberOfCells()); CPPUNIT_ASSERT_EQUAL(3,(int)m4_3->getNumberOfNodes()); m3_2->zipCoords(); @@ -2439,7 +2450,7 @@ void MEDCouplingBasicsTest3::testBuild0DMeshFromCoords1() CPPUNIT_ASSERT_EQUAL(4,(int)m->getNumberOfCells()); CPPUNIT_ASSERT_EQUAL(3,m->getSpaceDimension()); CPPUNIT_ASSERT_EQUAL(0,m->getMeshDimension()); - std::set types=m->getAllGeoTypes(); + std::set const types=m->getAllGeoTypes(); CPPUNIT_ASSERT_EQUAL(1,(int)types.size()); CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_POINT1,*types.begin()); for(int i=0;i<4;i++) diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest3.hxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest3.hxx index 0c22cb9a5..9aa8b612b 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest3.hxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest3.hxx @@ -23,8 +23,7 @@ #include "MEDCouplingBasicsTest.hxx" -#include -#include +#include namespace MEDCoupling { diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest4.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest4.cxx index 8f0297694..bf4894061 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest4.cxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest4.cxx @@ -19,18 +19,27 @@ // Author : Anthony Geay (CEA/DEN) #include "MEDCouplingBasicsTest4.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include "InterpKernelException.hxx" +#include "MEDCouplingDefinitionTime.hxx" +#include "MCType.hxx" +#include "MCIdType.hxx" +#include "MCAuto.hxx" #include "MEDCouplingUMesh.hxx" #include "MEDCouplingCMesh.hxx" #include "MEDCouplingMappedExtrudedMesh.hxx" #include "MEDCouplingFieldDouble.hxx" -#include "MEDCouplingMemArray.txx" #include "MEDCouplingGaussLocalization.hxx" #include "MEDCouplingMultiFields.hxx" #include "MEDCouplingFieldOverTime.hxx" +#include "NormalizedGeometricTypes" +#include #include -#include -#include +#include +#include +#include +#include using namespace MEDCoupling; @@ -40,7 +49,7 @@ void MEDCouplingBasicsTest4::testDescriptionInMeshTimeUnit1() MEDCouplingUMesh *m=build2DTargetMesh_1(); m->setDescription(text1); CPPUNIT_ASSERT(std::string(m->getDescription())==text1); - MEDCouplingUMesh *m2=(MEDCouplingUMesh *)m->deepCopy(); + auto *m2=(MEDCouplingUMesh *)m->deepCopy(); CPPUNIT_ASSERT(m->isEqual(m2,1e-12)); CPPUNIT_ASSERT(std::string(m2->getDescription())==text1); m2->setDescription("ggg"); @@ -61,12 +70,12 @@ void MEDCouplingBasicsTest4::testDescriptionInMeshTimeUnit1() void MEDCouplingBasicsTest4::testMultiFields1() { MEDCouplingMultiFields *mfs=buildMultiFields_1(); - std::vector ms=mfs->getMeshes(); + std::vector const ms=mfs->getMeshes(); std::vector refs; - std::vector dms=mfs->getDifferentMeshes(refs); - std::vector das=mfs->getArrays(); + std::vector const dms=mfs->getDifferentMeshes(refs); + std::vector const das=mfs->getArrays(); std::vector< std::vector > refs2; - std::vector das2=mfs->getDifferentArrays(refs2); + std::vector const das2=mfs->getDifferentArrays(refs2); // CPPUNIT_ASSERT_EQUAL(5,(int)ms.size()); CPPUNIT_ASSERT_EQUAL(2,(int)dms.size()); @@ -90,7 +99,7 @@ void MEDCouplingBasicsTest4::testFieldOverTime1() CPPUNIT_ASSERT_THROW(MEDCouplingFieldOverTime::New(fs),INTERP_KERNEL::Exception); f4bis->setTime(2.7,20,21); MEDCouplingFieldOverTime *fot=MEDCouplingFieldOverTime::New(fs); - MEDCouplingDefinitionTime dt=fot->getDefinitionTimeZone(); + MEDCouplingDefinitionTime const dt=fot->getDefinitionTimeZone(); std::vector hs=dt.getHotSpotsTime(); CPPUNIT_ASSERT_EQUAL(6,(int)hs.size()); const double expected1[]={0.2,0.7,1.2,1.35,1.7,2.7}; @@ -153,8 +162,8 @@ void MEDCouplingBasicsTest4::testFieldOverTime1() dt3.unserialize(tmp1,tmp2); CPPUNIT_ASSERT(dt2.isEqual(dt3)); // - for(std::vector::iterator it=fs.begin();it!=fs.end();it++) - (*it)->decrRef(); + for(auto & f : fs) + f->decrRef(); fot->decrRef(); } @@ -273,7 +282,7 @@ void MEDCouplingBasicsTest4::testMeshSetTime1() CPPUNIT_ASSERT(!m1->isEqual(m2,1e-12)); // m1->setTime(10.34,55,12); - MEDCouplingUMesh *m3=(MEDCouplingUMesh *)m1->deepCopy(); + auto *m3=(MEDCouplingUMesh *)m1->deepCopy(); CPPUNIT_ASSERT(m1->isEqual(m3,1e-12)); tmp3=m3->getTime(tmp1,tmp2); CPPUNIT_ASSERT_EQUAL(55,tmp1); @@ -297,7 +306,7 @@ void MEDCouplingBasicsTest4::testMeshSetTime1() CPPUNIT_ASSERT_EQUAL(8,tmp1); CPPUNIT_ASSERT_EQUAL(100,tmp2); CPPUNIT_ASSERT_DOUBLES_EQUAL(5.67,tmp3,1e-12); - MEDCouplingCMesh *c=(MEDCouplingCMesh *)b->deepCopy(); + auto *c=(MEDCouplingCMesh *)b->deepCopy(); CPPUNIT_ASSERT(c->isEqual(b,1e-12)); tmp3=c->getTime(tmp1,tmp2); CPPUNIT_ASSERT_EQUAL(8,tmp1); @@ -513,7 +522,7 @@ void MEDCouplingBasicsTest4::testGaussCoordinates1() std::vector gsCoo1(1); gsCoo1[0]=0.2; std::vector refCoo1(2); refCoo1[0]=-1.0; refCoo1[1]=1.0; f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_SEG2,refCoo1,gsCoo1,wg1); - std::vector wg2(wg1); + std::vector const wg2(wg1); std::vector gsCoo2(1); gsCoo2[0]=0.2; std::vector refCoo2(3); refCoo2[0]=-1.0; refCoo2[1]=1.0; refCoo2[2]=0.0; f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_SEG3,refCoo2,gsCoo2,wg2); @@ -534,27 +543,27 @@ void MEDCouplingBasicsTest4::testGaussCoordinates1() f->setMesh(m2); std::vector wg3(2); wg3[0]=0.3; wg3[1]=0.3; const double tria3CooGauss[4]={ 0.1, 0.8, 0.2, 0.7 }; - std::vector gsCoo3(tria3CooGauss,tria3CooGauss+4); + std::vector const gsCoo3(tria3CooGauss,tria3CooGauss+4); const double tria3CooRef[6]={ 0.0, 0.0, 1.0 , 0.0, 0.0, 1.0 }; - std::vector refCoo3(tria3CooRef,tria3CooRef+6); + std::vector const refCoo3(tria3CooRef,tria3CooRef+6); f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_TRI3,refCoo3,gsCoo3,wg3); std::vector wg4(3); wg4[0]=0.3; wg4[1]=0.3; wg4[2]=0.3; const double tria6CooGauss[6]={ 0.3, 0.2, 0.2, 0.1, 0.2, 0.4 }; - std::vector gsCoo4(tria6CooGauss,tria6CooGauss+6); + std::vector const gsCoo4(tria6CooGauss,tria6CooGauss+6); const double tria6CooRef[12]={0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.5, 0.0, 0.5, 0.5, 0.0, 0.5}; - std::vector refCoo4(tria6CooRef,tria6CooRef+12); + std::vector const refCoo4(tria6CooRef,tria6CooRef+12); f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_TRI6,refCoo4,gsCoo4,wg4); std::vector wg5(4); wg5[0]=0.3; wg5[1]=0.3; wg5[2]=0.3; wg5[3]=0.3; const double quad4CooGauss[8]={ 0.3, 0.2, 0.2, 0.1, 0.2, 0.4, 0.15, 0.27 }; - std::vector gsCoo5(quad4CooGauss,quad4CooGauss+8); + std::vector const gsCoo5(quad4CooGauss,quad4CooGauss+8); const double quad4CooRef[8]={-1.0, 1.0, -1.0, -1.0, 1.0, -1.0, 1.0, 1.0}; - std::vector refCoo5(quad4CooRef,quad4CooRef+8); + std::vector const refCoo5(quad4CooRef,quad4CooRef+8); f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_QUAD4,refCoo5,gsCoo5,wg5); std::vector wg6(4); wg6[0]=0.3; wg6[1]=0.3; wg6[2]=0.3; wg6[3]=0.3; const double quad8CooGauss[8]={ 0.34, 0.16, 0.21, 0.3, 0.23, 0.4, 0.14, 0.37 }; - std::vector gsCoo6(quad8CooGauss,quad8CooGauss+8); + std::vector const gsCoo6(quad8CooGauss,quad8CooGauss+8); const double quad8CooRef[16]={ -1.0, -1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 0.0, -1.0, 1.0, 0.0, 0.0, 1.0, -1.0, 0.0}; - std::vector refCoo6(quad8CooRef,quad8CooRef+16); + std::vector const refCoo6(quad8CooRef,quad8CooRef+16); f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_QUAD8,refCoo6,gsCoo6,wg6); // resToTest=f->getLocalizationOfDiscr(); @@ -577,51 +586,51 @@ void MEDCouplingBasicsTest4::testGaussCoordinates1() // std::vector wg7(1); wg7[0]=0.3; const double tetra4CooGauss[3]={0.34, 0.16, 0.21}; - std::vector gsCoo7(tetra4CooGauss,tetra4CooGauss+3); + std::vector const gsCoo7(tetra4CooGauss,tetra4CooGauss+3); const double tetra4CooRef[12]={0.0,1.0,0.0, 0.0,0.0,1.0, 0.0,0.0,0.0, 1.0,0.0,0.0}; - std::vector refCoo7(tetra4CooRef,tetra4CooRef+12); + std::vector const refCoo7(tetra4CooRef,tetra4CooRef+12); f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_TETRA4,refCoo7,gsCoo7,wg7); std::vector wg8(1); wg8[0]=0.3; const double tetra10CooGauss[3]={0.2, 0.3, 0.1}; - std::vector gsCoo8(tetra10CooGauss,tetra10CooGauss+3); + std::vector const gsCoo8(tetra10CooGauss,tetra10CooGauss+3); const double tetra10CooRef[30]={0.0,1.0,0.0, 0.0,0.0,0.0, 0.0,0.0,1.0, 1.0,0.0,0.0, 0.0,0.5,0.0, 0.0,0.0,0.5, 0.0,0.5,0.5, 0.5,0.5,0.0, 0.5,0.0,0.0, 0.5,0.0,0.5}; - std::vector refCoo8(tetra10CooRef,tetra10CooRef+30); + std::vector const refCoo8(tetra10CooRef,tetra10CooRef+30); f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_TETRA10,refCoo8,gsCoo8,wg8); std::vector wg9(1); wg9[0]=0.3; const double pyra5CooGauss[3]={0.2, 0.3, 0.1}; - std::vector gsCoo9(pyra5CooGauss,pyra5CooGauss+3); + std::vector const gsCoo9(pyra5CooGauss,pyra5CooGauss+3); const double pyra5CooRef[15]={1.0,0.0,0.0, 0.0,1.0,0.0, -1.0,0.0,0.0, 0.0,-1.0,0.0, 0.0,0.0,1.0}; - std::vector refCoo9(pyra5CooRef,pyra5CooRef+15); + std::vector const refCoo9(pyra5CooRef,pyra5CooRef+15); f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_PYRA5,refCoo9,gsCoo9,wg9); std::vector wg10(1); wg10[0]=0.3; const double pyra13CooGauss[3]={0.1, 0.2, 0.7}; - std::vector gsCoo10(pyra13CooGauss,pyra13CooGauss+3); + std::vector const gsCoo10(pyra13CooGauss,pyra13CooGauss+3); const double pyra13CooRef[39]={1.0,0.0,0.0, 0.0,1.0,0.0,-1.0,0.0,0.0,0.0,-1.0,0.0,0.0,0.0,1.0,0.5,0.5,0.0,-0.5,0.5,0.0,-0.5,-0.5,0.0,0.5,-0.5,0.0,0.5,0.0,0.5,0.0,0.5,0.5,-0.5,0.0,0.5,0.0,-0.5,0.5}; - std::vector refCoo10(pyra13CooRef,pyra13CooRef+39); + std::vector const refCoo10(pyra13CooRef,pyra13CooRef+39); f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_PYRA13,refCoo10,gsCoo10,wg10); std::vector wg11(1); wg11[0]=0.3; const double penta6CooGauss[3]={0.2, 0.3, 0.1}; - std::vector gsCoo11(penta6CooGauss,penta6CooGauss+3); + std::vector const gsCoo11(penta6CooGauss,penta6CooGauss+3); const double penta6CooRef[18]={-1.0,1.0,0.0,-1.0,-0.0,1.0,-1.0,0.0,0.0,1.0,1.0,0.0,1.0,0.0,1.0,1.0,0.0,0.0}; - std::vector refCoo11(penta6CooRef,penta6CooRef+18); + std::vector const refCoo11(penta6CooRef,penta6CooRef+18); f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_PENTA6,refCoo11,gsCoo11,wg11); std::vector wg12(1); wg12[0]=0.3; const double penta15CooGauss[3]={0.2, 0.3,0.15}; - std::vector gsCoo12(penta15CooGauss,penta15CooGauss+3); + std::vector const gsCoo12(penta15CooGauss,penta15CooGauss+3); const double penta15CooRef[45]={-1.0,1.0,0.0,-1.0,0.0,1.0,-1.0,0.0,0.0,1.0,1.0,0.0,1.0,0.0,1.0,1.0,0.0,0.0,-1.0,0.5,0.5,-1.0,0.0,0.5,-1.0,0.5,0.0,0.0,1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0,0.5,0.5,1.0,0.0, 0.5,1.0,0.5,0.0}; - std::vector refCoo12(penta15CooRef,penta15CooRef+45); + std::vector const refCoo12(penta15CooRef,penta15CooRef+45); f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_PENTA15,refCoo12,gsCoo12,wg12); std::vector wg13(1); wg13[0]=0.3; const double hexa8CooGauss[3]={0.2,0.3,0.15}; - std::vector gsCoo13(hexa8CooGauss,hexa8CooGauss+3); + std::vector const gsCoo13(hexa8CooGauss,hexa8CooGauss+3); const double hexa8CooRef[24]={-1.0,-1.0,-1.0,1.0,-1.0,-1.0,1.0,1.0,-1.0,-1.0,1.0,-1.0,-1.0,-1.0,1.0,1.0,-1.0,1.0,1.0,1.0,1.0,-1.0,1.0,1.0}; - std::vector refCoo13(hexa8CooRef,hexa8CooRef+24); + std::vector const refCoo13(hexa8CooRef,hexa8CooRef+24); f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_HEXA8,refCoo13,gsCoo13,wg13); std::vector wg14(1); wg14[0]=0.3; const double hexa20CooGauss[3]={0.11,0.3,0.55}; - std::vector gsCoo14(hexa20CooGauss,hexa20CooGauss+3); + std::vector const gsCoo14(hexa20CooGauss,hexa20CooGauss+3); const double hexa20CooRef[60]={-1.0,-1.0,-1.0,1.0,-1.0,-1.0,1.0,1.0,-1.0,-1.0,1.0,-1.0,-1.0,-1.0,1.0,1.0,-1.0,1.0,1.0,1.0,1.0,-1.0,1.0,1.0,0.0,-1.0,-1.0,1.0,0.0,-1.0,0.0,1.0,-1.0,-1.0,0.0,-1.0,-1.0,-1.0,0.0,1.0,-1.0,0.0,1.0,1.0,0.0,-1.0,1.0,0.0,0.0,-1.0,1.0,1.0,0.0,1.0,0.0,1.0,1.0,-1.0,0.0,1.0}; - std::vector refCoo14(hexa20CooRef,hexa20CooRef+60); + std::vector const refCoo14(hexa20CooRef,hexa20CooRef+60); f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_HEXA20,refCoo14,gsCoo14,wg14); // resToTest=f->getLocalizationOfDiscr(); @@ -734,7 +743,7 @@ void MEDCouplingBasicsTest4::testGetValueOn2() MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME); f->setMesh(m); DataArrayDouble *arr=DataArrayDouble::New(); - std::size_t nbOfCells=m->getNumberOfCells(); + std::size_t const nbOfCells=m->getNumberOfCells(); arr->alloc(nbOfCells,3); f->setArray(arr); arr->decrRef(); @@ -753,7 +762,7 @@ void MEDCouplingBasicsTest4::testGetValueOn2() f=MEDCouplingFieldDouble::New(ON_NODES,NO_TIME); f->setMesh(m); arr=DataArrayDouble::New(); - mcIdType nbOfNodes=m->getNumberOfNodes(); + mcIdType const nbOfNodes=m->getNumberOfNodes(); arr->alloc(nbOfNodes,3); f->setArray(arr); arr->decrRef(); @@ -956,7 +965,7 @@ void MEDCouplingBasicsTest4::testUnPolyze2() m->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,conn); m->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,conn); m->finishInsertingCells(); - std::vector ms(4,m); + std::vector const ms(4,m); MEDCouplingUMesh *m2=MEDCouplingUMesh::MergeUMeshesOnSameCoords(ms); std::vector temp(1,2); m2->convertToPolyTypes(&temp[0],&temp[0]+temp.size()); @@ -1134,14 +1143,14 @@ void MEDCouplingBasicsTest4::testDAIOperations1() void MEDCouplingBasicsTest4::testEmulateMEDMEMBDC1() { - MEDCouplingUMesh *m1=0; + MEDCouplingUMesh *m1=nullptr; MEDCouplingUMesh *m=buildPointe_1(m1); DataArrayIdType *da1=DataArrayIdType::New(); DataArrayIdType *da2=DataArrayIdType::New(); - DataArrayIdType *da3=0; - DataArrayIdType *da4=0; - DataArrayIdType *da5=0; - DataArrayIdType *da0=0; + DataArrayIdType *da3=nullptr; + DataArrayIdType *da4=nullptr; + DataArrayIdType *da5=nullptr; + DataArrayIdType *da0=nullptr; MEDCouplingUMesh *m2=m->emulateMEDMEMBDC(m1,da1,da2,da3,da4,da5,da0); const mcIdType expected0[47]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,36,37,32,33,34,35,38,39,40,41,42,43,44,45,46}; const mcIdType expected1[6]={1,32,29,23,41,36}; @@ -1189,7 +1198,7 @@ void MEDCouplingBasicsTest4::testEmulateMEDMEMBDC1() void MEDCouplingBasicsTest4::testGetLevArrPerCellTypes1() { - MEDCouplingUMesh *m1=0; + MEDCouplingUMesh *m1=nullptr; MEDCouplingUMesh *m=buildPointe_1(m1); m1->decrRef(); DataArrayIdType *d0=DataArrayIdType::New(); @@ -1199,7 +1208,7 @@ void MEDCouplingBasicsTest4::testGetLevArrPerCellTypes1() m1=m->buildDescendingConnectivity(d0,d1,d2,d3); d0->decrRef(); d1->decrRef(); d2->decrRef(); d3->decrRef(); INTERP_KERNEL::NormalizedCellType order[2]={INTERP_KERNEL::NORM_TRI3,INTERP_KERNEL::NORM_QUAD4}; - DataArrayIdType *da1=0; + DataArrayIdType *da1=nullptr; DataArrayIdType *da0=m1->getLevArrPerCellTypes(order,order+2,da1); const mcIdType expected0[47]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,1,1,1,1,1,1,1,1,1}; const mcIdType expected1[47]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,36,37,32,33,34,35,38,39,40,41,42,43,44,45,46}; @@ -1228,10 +1237,10 @@ void MEDCouplingBasicsTest4::testGetLevArrPerCellTypes1() void MEDCouplingBasicsTest4::testSortCellsInMEDFileFrmt1() { - MEDCouplingUMesh *m1=0; + MEDCouplingUMesh *m1=nullptr; MEDCouplingUMesh *m=buildPointe_1(m1); - MEDCouplingUMesh *m2=(MEDCouplingUMesh *)m->deepCopy(); - m->setCoords(0); + auto *m2=(MEDCouplingUMesh *)m->deepCopy(); + m->setCoords(nullptr); const mcIdType vals[16]={0,1,2,14,3,12,4,5,15,6,7,8,9,10,11,13}; DataArrayIdType *da=DataArrayIdType::New(); da->alloc(16,1); @@ -1296,7 +1305,7 @@ void MEDCouplingBasicsTest4::testDAISplitByValueRange1() DataArrayIdType *d=DataArrayIdType::New(); d->alloc(9,1); std::copy(val1,val1+9,d->getPointer()); - DataArrayIdType *ee=0,*f=0,*g=0; + DataArrayIdType *ee=nullptr,*f=nullptr,*g=nullptr; d->splitByValueRange(val2,val2+3,ee,f,g); CPPUNIT_ASSERT_EQUAL(9,(int)ee->getNumberOfTuples()); CPPUNIT_ASSERT_EQUAL(1,(int)ee->getNumberOfComponents()); @@ -1776,7 +1785,7 @@ void MEDCouplingBasicsTest4::testDADFindCommonTuples1() da->alloc(6,1); const double array1[6]={2.3,1.2,1.3,2.3,2.301,0.8}; std::copy(array1,array1+6,da->getPointer()); - DataArrayIdType *c=0,*cI=0; + DataArrayIdType *c=nullptr,*cI=nullptr; // nbOftuples=1 da->findCommonTuples(1e-2,-1,c,cI); const mcIdType expected1[3]={0,3,4}; @@ -1961,7 +1970,7 @@ void MEDCouplingBasicsTest4::testGetNodeIdsInUse1() { MEDCouplingUMesh *m0=build2DTargetMesh_1(); const mcIdType CellIds[2]={1,2}; - MEDCouplingUMesh *m1=static_cast(m0->buildPartOfMySelf(CellIds,CellIds+2,true)); + auto *m1=static_cast(m0->buildPartOfMySelf(CellIds,CellIds+2,true)); mcIdType newNbOfNodes=-1; DataArrayIdType *arr=m1->getNodeIdsInUse(newNbOfNodes); const mcIdType expected[9]={-1,0,1,-1,2,3,-1,-1,-1}; @@ -2032,14 +2041,14 @@ void MEDCouplingBasicsTest4::testIntersect2DMeshesTmp1() m1c->setCoordsAt(1,coordY); MEDCouplingUMesh *m1=m1c->buildUnstructured(); const mcIdType subPart1[3]={3,4,5}; - MEDCouplingUMesh *m1bis=static_cast(m1->buildPartOfMySelf(subPart1,subPart1+3,false)); - MEDCouplingUMesh *m2tmp=static_cast(m1->deepCopy()); + auto *m1bis=static_cast(m1->buildPartOfMySelf(subPart1,subPart1+3,false)); + auto *m2tmp=static_cast(m1->deepCopy()); const mcIdType subPart2[3]={0,1,2}; - MEDCouplingUMesh *m2=static_cast(m2tmp->buildPartOfMySelf(subPart2,subPart2+3,false)); + auto *m2=static_cast(m2tmp->buildPartOfMySelf(subPart2,subPart2+3,false)); const double vec[2]={0.5,0.5}; m2->translate(vec); // End of construction of input meshes m1bis and m2 -> start of specific part of the test - DataArrayIdType *d1=0,*d2=0; + DataArrayIdType *d1=nullptr,*d2=nullptr; MEDCouplingUMesh *m3=MEDCouplingUMesh::Intersect2DMeshes(m1bis,m2,1e-10,d1,d2); const mcIdType expected1[8]={0,0,1,1,1,2,2,2}; const mcIdType expected2[8]={0,-1,0,1,-1,1,2,-1}; @@ -2125,7 +2134,7 @@ void MEDCouplingBasicsTest4::testIntersect2DMeshesTmp2() m2c->setCoordsAt(1,coordsY2); MEDCouplingUMesh *m2=m2c->buildUnstructured(); // - DataArrayIdType *d1=0,*d2=0; + DataArrayIdType *d1=nullptr,*d2=nullptr; MEDCouplingUMesh *m3=MEDCouplingUMesh::Intersect2DMeshes(m1,m2,1e-10,d1,d2); const mcIdType expected1[9]={0,0,1,1,2,2,3,4,5}; const mcIdType expected2[9]={0,2,1,3,1,3,2,3,3}; @@ -2205,7 +2214,7 @@ void MEDCouplingBasicsTest4::testIntersect2DMeshesTmp3() m2->setCoords(myCoords2); myCoords2->decrRef(); // - DataArrayIdType *d1=0,*d2=0; + DataArrayIdType *d1=nullptr,*d2=nullptr; MEDCouplingUMesh *m3=MEDCouplingUMesh::Intersect2DMeshes(m1,m2,1e-10,d1,d2); m3->unPolyze(); const mcIdType expected1[16]={0,1,1,1,2,3,3,3,4,5,5,5,6,7,7,7}; diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest4.hxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest4.hxx index e2fc9a45a..021f7db15 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest4.hxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest4.hxx @@ -23,8 +23,7 @@ #include "MEDCouplingBasicsTest.hxx" -#include -#include +#include namespace MEDCoupling { diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest5.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest5.cxx index 162ae69bc..754e3cd18 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest5.cxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest5.cxx @@ -19,19 +19,29 @@ // Author : Anthony Geay (CEA/DEN) #include "MEDCouplingBasicsTest5.hxx" +#include "MCType.hxx" +#include "MCIdType.hxx" +#include "InterpKernelException.hxx" +#include "MCAuto.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include "MEDCouplingPointSet.hxx" #include "MEDCouplingUMesh.hxx" #include "MEDCouplingCMesh.hxx" #include "MEDCouplingMappedExtrudedMesh.hxx" #include "MEDCouplingFieldDouble.hxx" #include "MEDCouplingMemArray.hxx" -#include "MEDCouplingMemArray.txx" #include "MEDCouplingGaussLocalization.hxx" #include "MEDCouplingMultiFields.hxx" -#include "MEDCouplingFieldOverTime.hxx" +#include "NormalizedGeometricTypes" +#include #include -#include -#include +#include +#include +#include +#include +#include +#include using namespace MEDCoupling; @@ -57,7 +67,7 @@ void MEDCouplingBasicsTest5::testUMeshTessellate2D1() m1->setCoords(myCoords1); myCoords1->decrRef(); // - MEDCouplingUMesh *m11=static_cast(m1->deepCopy()); + auto *m11=static_cast(m1->deepCopy()); m11->tessellate2D(1.); CPPUNIT_ASSERT(m11->getCoords()->isEqual(*m11->getCoords(),1e-12)); const mcIdType expected1[48]={5,0,3,11,1,5,3,4,12,2,1,11,5,5,15,3,0,5,6,16,4,3,15,5,5,5,0,7,19,5,6,5,19,7,8,20,5,0,1,23,7,5,1,2,24,8,7,23}; @@ -68,7 +78,7 @@ void MEDCouplingBasicsTest5::testUMeshTessellate2D1() CPPUNIT_ASSERT(std::equal(expected2,expected2+9,m11->getNodalConnectivityIndex()->getConstPointer())); m11->decrRef(); // - MEDCouplingUMesh *m12=static_cast(m1->deepCopy()); + auto *m12=static_cast(m1->deepCopy()); m12->tessellate2D(0.5); CPPUNIT_ASSERT_EQUAL(ToIdType(41),m12->getNumberOfNodes()); const mcIdType expected3[60]={5,0,3,25,26,1,5,3,4,27,28,2,1,26,25,5,5,29,30,3,0,5,6,31,32,4,3,30,29,5,5,5,0,7,33,34,5,6,5,34,33,7,8,35,36,5,0,1,37,38,7,5,1,2,39,40,8,7,38,37}; @@ -102,7 +112,7 @@ void MEDCouplingBasicsTest5::testUMeshTessellate2DCurve1() m1->setCoords(myCoords); myCoords->decrRef(); - MEDCouplingUMesh *m2 = static_cast(m1->deepCopy()); + auto *m2 = static_cast(m1->deepCopy()); m2->tessellate2D(0.1); CPPUNIT_ASSERT_NO_THROW(m2->checkConsistency(0.0)); // eps param not used m1->decrRef(); @@ -148,7 +158,7 @@ void MEDCouplingBasicsTest5::testIntersect2DMeshesTmp4() m2->setCoords(myCoords2); myCoords2->decrRef(); // - DataArrayIdType *d1=0,*d2=0; + DataArrayIdType *d1=nullptr,*d2=nullptr; MEDCouplingUMesh *m3=MEDCouplingUMesh::Intersect2DMeshes(m2,m1,1e-10,d1,d2); m3->unPolyze(); const mcIdType expected1[16]={0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7}; @@ -179,7 +189,7 @@ void MEDCouplingBasicsTest5::testIntersect2DMeshesTmp4() void MEDCouplingBasicsTest5::testGetCellIdsCrossingPlane1() { - MEDCouplingUMesh *mesh2D=0; + MEDCouplingUMesh *mesh2D=nullptr; MEDCouplingUMesh *mesh3D=build3DExtrudedUMesh_1(mesh2D); const double vec[3]={-0.07,1.,0.07}; const double origin[3]={1.524,1.4552,1.74768}; @@ -200,13 +210,13 @@ void MEDCouplingBasicsTest5::testGetCellIdsCrossingPlane1() void MEDCouplingBasicsTest5::testBuildSlice3D1() { - MEDCouplingUMesh *mesh2D=0; + MEDCouplingUMesh *mesh2D=nullptr; MEDCouplingUMesh *mesh3D=build3DExtrudedUMesh_1(mesh2D); mesh2D->decrRef(); // First slice in the middle of 3D cells const double vec1[3]={-0.07,1.,0.07}; const double origin1[3]={1.524,1.4552,1.74768}; - DataArrayIdType *ids=0; + DataArrayIdType *ids=nullptr; MEDCouplingUMesh *slice1=mesh3D->buildSlice3D(origin1,vec1,1e-10,ids); const mcIdType expected1[9]={1,3,4,7,9,10,13,15,16}; const mcIdType expected2[47]={5,42,41,40,43,44,5,42,46,45,41,5,44,43,40,47,48,5,49,42,44,50,5,49,51,46,42,5,50,44,48,52,5,53,49,50,54,5,53,55,51,49,5,54,50,52,56}; @@ -275,7 +285,7 @@ void MEDCouplingBasicsTest5::testBuildSlice3D1() void MEDCouplingBasicsTest5::testBuildSlice3DSurf1() { - MEDCouplingUMesh *mesh2D=0; + MEDCouplingUMesh *mesh2D=nullptr; MEDCouplingUMesh *mesh3D=build3DExtrudedUMesh_1(mesh2D); mesh2D->decrRef(); DataArrayIdType *a=DataArrayIdType::New(),*b=DataArrayIdType::New(),*c=DataArrayIdType::New(),*d=DataArrayIdType::New(); @@ -285,7 +295,7 @@ void MEDCouplingBasicsTest5::testBuildSlice3DSurf1() // const double vec1[3]={-0.07,1.,0.07}; const double origin1[3]={1.524,1.4552,1.74768}; - DataArrayIdType *ids=0; + DataArrayIdType *ids=nullptr; MEDCouplingUMesh *slice1=mesh2D->buildSlice3DSurf(origin1,vec1,1e-10,ids); const mcIdType expected1[25]={6,8,10,11,13,18,19,21,23,25,26,38,41,43,47,49,52,53,64,67,69,73,75,78,79}; const mcIdType expected2[75]={1,40,41,1,42,41,1,40,43,1,44,43,1,42,44,1,45,41,1,42,46,1,46,45,1,47,40,1,47,48,1,44,48,1,49,42,1,44,50,1,49,50,1,49,51,1,51,46,1,48,52,1,50,52,1,53,49,1,50,54,1,53,54,1,53,55,1,55,51,1,52,56,1,54,56}; @@ -338,7 +348,7 @@ void MEDCouplingBasicsTest5::testDataArrayDoubleAdvSetting1() const char *comps[2]={"comp1","comp2"}; std::vector compsCpp(comps,comps+2); DataArrayDouble *da=DataArrayDouble::New(); - DataArrayDouble *tmp=0; + DataArrayDouble *tmp=nullptr; da->setInfoAndChangeNbOfCompo(compsCpp); da->setName("da"); da->alloc(7,2); @@ -432,7 +442,7 @@ void MEDCouplingBasicsTest5::testDataArrayIntAdvSetting1() const char *comps[2]={"comp1","comp2"}; std::vector compsCpp(comps,comps+2); DataArrayIdType *da=DataArrayIdType::New(); - DataArrayIdType *tmp=0; + DataArrayIdType *tmp=nullptr; da->setInfoAndChangeNbOfCompo(compsCpp); da->setName("da"); da->alloc(7,2); @@ -574,12 +584,12 @@ void MEDCouplingBasicsTest5::testAre2DCellsNotCorrectlyOriented1() myCoords1->decrRef(); // double vec1[3]={0.,0.,1.}; - double *vec2=new double[2]; + auto *vec2=new double[2]; for(int i=0;i<18;i++) { vec2[0]=3.*cos(M_PI/9.*i); vec2[1]=3.*sin(M_PI/9.*i); - MEDCouplingUMesh *m1Cpy=static_cast(m1->deepCopy()); + auto *m1Cpy=static_cast(m1->deepCopy()); m1Cpy->translate(vec2); std::vector res; CPPUNIT_ASSERT_THROW(m1Cpy->are2DCellsNotCorrectlyOriented(vec1,false,res),INTERP_KERNEL::Exception); @@ -737,19 +747,19 @@ void MEDCouplingBasicsTest5::testRenumberNodesInConn1() myCoords3D->decrRef(); mesh3D->checkConsistencyLight(); // - MEDCouplingUMesh *mesh3D_2=dynamic_cast(mesh3D->deepCopy()); - MEDCouplingUMesh *mesh2D_2=dynamic_cast(mesh2D->deepCopy()); - MEDCouplingUMesh *mesh3D_4=dynamic_cast(mesh3D->deepCopy()); - MEDCouplingUMesh *mesh2D_4=dynamic_cast(mesh2D->deepCopy()); + auto *mesh3D_2=dynamic_cast(mesh3D->deepCopy()); + auto *mesh2D_2=dynamic_cast(mesh2D->deepCopy()); + auto *mesh3D_4=dynamic_cast(mesh3D->deepCopy()); + auto *mesh2D_4=dynamic_cast(mesh2D->deepCopy()); DataArrayIdType *renumNodes=DataArrayIdType::New(); - mcIdType oldNbOf3DNodes=mesh3D->getNumberOfNodes(); + mcIdType const oldNbOf3DNodes=mesh3D->getNumberOfNodes(); renumNodes->alloc(mesh2D->getNumberOfNodes(),1); renumNodes->iota(oldNbOf3DNodes); DataArrayDouble *coo=DataArrayDouble::Aggregate(mesh3D->getCoords(),mesh2D->getCoords()); mesh3D->setCoords(coo); mesh2D->setCoords(coo); coo->decrRef(); - MEDCouplingUMesh *mesh2D_3=dynamic_cast(mesh2D->deepCopy()); + auto *mesh2D_3=dynamic_cast(mesh2D->deepCopy()); mesh2D_3->shiftNodeNumbersInConn(oldNbOf3DNodes); mesh2D->renumberNodesInConn(renumNodes->getConstPointer()); renumNodes->decrRef(); @@ -758,7 +768,7 @@ void MEDCouplingBasicsTest5::testRenumberNodesInConn1() // DataArrayIdType *da1,*da2; mesh3D->checkGeoEquivalWith(mesh3D_2,10,1e-12,da1,da2); - CPPUNIT_ASSERT(da1==0); + CPPUNIT_ASSERT(da1==nullptr); CPPUNIT_ASSERT_EQUAL(8,(int)da2->getNumberOfTuples()); CPPUNIT_ASSERT_EQUAL(1,(int)da2->getNumberOfComponents()); const mcIdType expected1[8]={8,11,12,9,4,5,6,7}; @@ -767,7 +777,7 @@ void MEDCouplingBasicsTest5::testRenumberNodesInConn1() da2->decrRef(); // mesh2D->checkGeoEquivalWith(mesh2D_2,10,1e-12,da1,da2); - CPPUNIT_ASSERT(da1==0); + CPPUNIT_ASSERT(da1==nullptr); CPPUNIT_ASSERT_EQUAL(9,(int)da2->getNumberOfTuples()); CPPUNIT_ASSERT_EQUAL(1,(int)da2->getNumberOfComponents()); for(mcIdType i=0;i<9;i++) @@ -775,7 +785,7 @@ void MEDCouplingBasicsTest5::testRenumberNodesInConn1() da2->decrRef(); // const double vect[3]={1.,0.,0.}; - MEDCouplingUMesh *mesh2D_5=dynamic_cast(mesh2D_4->deepCopy()); + auto *mesh2D_5=dynamic_cast(mesh2D_4->deepCopy()); mesh2D_5->translate(vect); std::vector meshes(3); meshes[0]=mesh3D_4; meshes[1]=mesh2D_4; meshes[2]=mesh2D_5; @@ -832,7 +842,7 @@ void MEDCouplingBasicsTest5::testRenumberNodesInConn1() void MEDCouplingBasicsTest5::testComputeNeighborsOfCells1() { MEDCouplingUMesh *m=build2DTargetMesh_1(); - DataArrayIdType *d1=0,*d2=0; + DataArrayIdType *d1=nullptr,*d2=nullptr; m->computeNeighborsOfCells(d1,d2); CPPUNIT_ASSERT_EQUAL(6,(int)d2->getNumberOfTuples()); CPPUNIT_ASSERT_EQUAL(10,(int)d1->getNumberOfTuples()); @@ -935,7 +945,7 @@ void MEDCouplingBasicsTest5::testDataArrayDoubleGetMinMaxPerComponent1() { const double values1[12]={1.,2.,3.,-0.9,2.1,3.,1.3,1.7,3.,1.,1.8,3.}; DataArrayDouble *d1=DataArrayDouble::New(); - double *res=new double[2*3]; + auto *res=new double[2*3]; CPPUNIT_ASSERT_THROW(d1->getMinMaxPerComponent(res),INTERP_KERNEL::Exception); d1->alloc(4,3); std::copy(values1,values1+12,d1->getPointer()); @@ -982,8 +992,8 @@ void MEDCouplingBasicsTest5::testZipConnectivityPol1() MEDCouplingUMesh *m1=build2DTargetMesh_1(); const mcIdType cells1[3]={2,3,4}; MEDCouplingPointSet *m2_1=m1->buildPartOfMySelf(cells1,cells1+3,true); - MEDCouplingUMesh *m2=dynamic_cast(m2_1); - DataArrayIdType *arr=0; + auto *m2=dynamic_cast(m2_1); + DataArrayIdType *arr=nullptr; CPPUNIT_ASSERT(m2); // no permutation policy 0 CPPUNIT_ASSERT(m1->areCellsIncludedIn(m2,0,arr)); @@ -1054,7 +1064,7 @@ void MEDCouplingBasicsTest5::testZipConnectivityPol1() m2_1=m1->buildPartOfMySelf(cells2,cells2+2,true); m2=dynamic_cast(m2_1); CPPUNIT_ASSERT(m2); - arr=0; + arr=nullptr; // no permutation policy 0 CPPUNIT_ASSERT(m1->areCellsIncludedIn(m2,0,arr)); CPPUNIT_ASSERT_EQUAL(2,(int)arr->getNumberOfTuples()); @@ -1206,8 +1216,8 @@ void MEDCouplingBasicsTest5::testPartitionBySpreadZone1() MEDCouplingUMesh *m=build2DTargetMesh_1(); const mcIdType part0[3]={2,3,4}; const mcIdType part1[2]={0,1}; - MEDCouplingUMesh *m1=static_cast(m->buildPartOfMySelf(part0,part0+3)); - MEDCouplingUMesh *m2=static_cast(m->buildPartOfMySelf(part1,part1+2)); + auto *m1=static_cast(m->buildPartOfMySelf(part0,part0+3)); + auto *m2=static_cast(m->buildPartOfMySelf(part1,part1+2)); std::vector v(3); v[0]=m; v[1]=m1; v[2]=m2; MEDCouplingUMesh *m4=MEDCouplingUMesh::MergeUMeshes(v); const mcIdType renum[10]={5,2,9,6,4,7,0,1,3,8}; @@ -1279,13 +1289,13 @@ void MEDCouplingBasicsTest5::testGiveCellsWithType1() void MEDCouplingBasicsTest5::testBuildSlice3D2() { - MEDCouplingUMesh *mesh2D=0; + MEDCouplingUMesh *mesh2D=nullptr; MEDCouplingUMesh *mesh3D=build3DExtrudedUMesh_1(mesh2D); mesh2D->decrRef(); // First slice in the middle of 3D cells const double vec1[3]={-0.07,1.,0.07}; const double origin1[3]={1.524,1.4552,1.74768}; - DataArrayIdType *ids=0; + DataArrayIdType *ids=nullptr; MEDCouplingUMesh *slice1=mesh3D->buildSlice3D(origin1,vec1,1e-10,ids); // MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME); @@ -1303,7 +1313,7 @@ void MEDCouplingBasicsTest5::testBuildSlice3D2() CPPUNIT_ASSERT(f2->getArray()->isEqual(*arr2,1e-12)); CPPUNIT_ASSERT(slice1->isEqual(f2->getMesh(),1e-12)); int a,b; - double c=f2->getTime(a,b); + double const c=f2->getTime(a,b); CPPUNIT_ASSERT_EQUAL(6,a); CPPUNIT_ASSERT_EQUAL(7,b); CPPUNIT_ASSERT_DOUBLES_EQUAL(4.5,c,1e-12); @@ -1375,10 +1385,10 @@ void MEDCouplingBasicsTest5::testComputeSkin1() const mcIdType expected3[18]={0,1,2,3,4,5,9,10,14,15,19,20,24,25,26,27,28,29}; CPPUNIT_ASSERT_EQUAL(ToIdType(18),ids->getNbOfElems()); CPPUNIT_ASSERT(std::equal(expected3,expected3+18,ids->getConstPointer())); - MEDCouplingUMesh *part=dynamic_cast(umesh->buildFacePartOfMySelfNode(ids->begin(),ids->end(),true)); + auto *part=dynamic_cast(umesh->buildFacePartOfMySelfNode(ids->begin(),ids->end(),true)); part->setName(skin->getName().c_str()); CPPUNIT_ASSERT(part->isEqual(skin,1e-12)); - MEDCouplingUMesh *part2=dynamic_cast(part->buildPartOfMySelfSlice(1,18,2,true)); + auto *part2=dynamic_cast(part->buildPartOfMySelfSlice(1,18,2,true)); DataArrayIdType *ids2=DataArrayIdType::Range(0,18,2); part->setPartOfMySelf(ids2->begin(),ids2->end(),*part2); ids2->decrRef(); @@ -1404,10 +1414,10 @@ void MEDCouplingBasicsTest5::testUMeshSetPartOfMySelf2() std::set s; s.insert(INTERP_KERNEL::NORM_TRI3); s.insert(INTERP_KERNEL::NORM_QUAD4); CPPUNIT_ASSERT(s==m->getAllGeoTypes()); const mcIdType ids1[3]={0,3,4}; - MEDCouplingUMesh *part=static_cast(m->buildPartOfMySelf(ids1,ids1+3,true)); + auto *part=static_cast(m->buildPartOfMySelf(ids1,ids1+3,true)); part->simplexize(0)->decrRef(); const mcIdType ids2[3]={1,2,5}; - MEDCouplingUMesh *part2=static_cast(part->buildPartOfMySelf(ids2,ids2+3,true)); + auto *part2=static_cast(part->buildPartOfMySelf(ids2,ids2+3,true)); m->setPartOfMySelf(ids1,ids1+3,*part2); const mcIdType expected1[20]={3,0,4,1,3,1,4,2,3,4,5,2,3,6,7,4,3,7,5,4}; CPPUNIT_ASSERT(std::equal(expected1,expected1+20,m->getNodalConnectivity()->getConstPointer())); @@ -1523,7 +1533,7 @@ void MEDCouplingBasicsTest5::testKrSpatialDiscretization1() const double targetPointCoordsX[40]={-0.5,-0.45,-0.4,-0.35,-0.3,-0.25,-0.2,-0.15,-0.1,-0.05,-6.93889390391e-17,0.05,0.1,0.15,0.2,0.25,0.3,0.35,0.4,0.45,0.5,0.55,0.6,0.65,0.7,0.75,0.8,0.85,0.9,0.95,1.0,1.05,1.1,1.15,1.2,1.25,1.3,1.35,1.4,1.45}; const double targetFieldValsExpected[40]={2.975379475824351, 2.95613491917003, 2.936890362515361, 2.917645805861018, 2.898401249206574, 2.879156692552137, 2.859912135897732, 2.840667579243201, 2.821423022588731, 2.802178465934342, 2.78293390927989, 2.763689352625457, 2.744444795971001, 2.725209522098197, 2.709077577124666, 2.706677252549218, 2.727467797847971, 2.713338094723676, 2.671342424824244, 2.664877370146978, 2.653840141412181, 2.619607861392791, 2.569777214476479, 2.513263929794591, 2.450732752808528, 2.368313560985155, 2.250909795670307, 2.098194272085416, 1.954257891732065, 1.895040660973802, 1.865256788315972, 1.835475248687992, 1.80569370905998, 1.775912169431971, 1.746130629803976, 1.716349090175918, 1.686567550547855, 1.656786010919941, 1.627004471291988, 1.597222931663817}; // - int nbOfInputPoints=10; + int const nbOfInputPoints=10; MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_NODES_KR,ONE_TIME); DataArrayDouble *srcArrX=DataArrayDouble::New(); srcArrX->alloc(nbOfInputPoints,1); @@ -1538,7 +1548,7 @@ void MEDCouplingBasicsTest5::testKrSpatialDiscretization1() f->setArray(srcVals); f->checkConsistencyLight(); // - double *res0=new double[1]; + auto *res0=new double[1]; f->getValueOn(targetPointCoordsX,res0); CPPUNIT_ASSERT_DOUBLES_EQUAL(targetFieldValsExpected[0],res0[0],1e-10); delete [] res0; @@ -1617,7 +1627,7 @@ void MEDCouplingBasicsTest5::testIntersect2DMeshesTmp5() m2->setConnectivity(conn,connI,true); coords->decrRef(); conn->decrRef(); connI->decrRef(); // - DataArrayIdType *d1=0,*d2=0; + DataArrayIdType *d1=nullptr,*d2=nullptr; MEDCouplingUMesh *m3=MEDCouplingUMesh::Intersect2DMeshes(m1,m2,1e-10,d1,d2); CPPUNIT_ASSERT_EQUAL(105,(int)m3->getNumberOfCells()); CPPUNIT_ASSERT_EQUAL(105,(int)d1->getNumberOfTuples()); @@ -1770,7 +1780,7 @@ void MEDCouplingBasicsTest5::testIntersect2DMeshesTmp6() m2->setConnectivity(conn,connI,true); coords->decrRef(); conn->decrRef(); connI->decrRef(); // - DataArrayIdType *d1=0,*d2=0; + DataArrayIdType *d1=nullptr,*d2=nullptr; MEDCouplingUMesh *m3=MEDCouplingUMesh::Intersect2DMeshes(m1,m2,1e-10,d1,d2); CPPUNIT_ASSERT_EQUAL(4,(int)m3->getNumberOfCells()); CPPUNIT_ASSERT_EQUAL(4,(int)d1->getNumberOfTuples()); @@ -1799,7 +1809,7 @@ void MEDCouplingBasicsTest5::testIntersect2DMeshesTmp6() void MEDCouplingBasicsTest5::testIntersect2DMeshesTmp7() { - double eps = 1.0e-8; + double const eps = 1.0e-8; // coordinates circle - SEE getCircle() on the Python side DataArrayDouble *coords1=DataArrayDouble::New(); const double coordsData1[16]={0.5328427124746189, -0.08284271247461905, -0.03284271247461901, 0.4828427124746191, -0.03284271247461906, -0.082842712474619, 0.5328427124746191, 0.482842712474619}; @@ -1832,7 +1842,7 @@ void MEDCouplingBasicsTest5::testIntersect2DMeshesTmp7() m2->setConnectivity(conn2,connI2,true); coords2->decrRef(); conn2->decrRef(); connI2->decrRef(); - DataArrayIdType * resToM1 = 0, * resToM2 = 0; + DataArrayIdType * resToM1 = nullptr, * resToM2 = nullptr; MEDCouplingUMesh *m_intersec=MEDCouplingUMesh::Intersect2DMeshes(m2, m1, eps, resToM1, resToM2); m_intersec->zipCoords(); @@ -1865,7 +1875,7 @@ void MEDCouplingBasicsTest5::testDAIBuildSubstractionOptimized1() DataArrayIdType *da3=DataArrayIdType::New(); da3->useArray(tab3,false,DeallocType::CPP_DEALLOC,3,1); DataArrayIdType *da4=DataArrayIdType::New(); da4->useArray(tab1,false,DeallocType::CPP_DEALLOC,7,1); // - DataArrayIdType *a=0; + DataArrayIdType *a=nullptr; a=da1->buildSubstractionOptimized(da2); CPPUNIT_ASSERT_EQUAL(4,(int)a->getNumberOfTuples()); CPPUNIT_ASSERT_EQUAL(1,(int)a->getNumberOfComponents()); @@ -2004,7 +2014,7 @@ void MEDCouplingBasicsTest5::testSimplexize3() c->decrRef(); m->checkConsistency(); // - MEDCouplingUMesh *m1=static_cast(m->deepCopy()); + auto *m1=static_cast(m->deepCopy()); DataArrayIdType *d1=m1->simplexize(INTERP_KERNEL::PLANAR_FACE_5); m1->checkConsistency(); MEDCouplingFieldDouble *f1=m1->getMeasureField(ON_CELLS); @@ -2029,7 +2039,7 @@ void MEDCouplingBasicsTest5::testSimplexize3() m1->decrRef(); d1->decrRef(); // - MEDCouplingUMesh *m2=static_cast(m->deepCopy()); + auto *m2=static_cast(m->deepCopy()); DataArrayIdType *d2=m2->simplexize(INTERP_KERNEL::PLANAR_FACE_6); m2->checkConsistency(); MEDCouplingFieldDouble *f2=m2->getMeasureField(ON_CELLS); diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest5.hxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest5.hxx index a67429681..aac22ac3a 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest5.hxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest5.hxx @@ -23,8 +23,7 @@ #include "MEDCouplingBasicsTest.hxx" -#include -#include +#include namespace MEDCoupling { diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTestData1.hxx b/src/MEDCoupling/Test/MEDCouplingBasicsTestData1.hxx index ba4d63673..bb4eecfdd 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTestData1.hxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTestData1.hxx @@ -18,6 +18,8 @@ // // Author : Anthony Geay (CEA/DEN) +#include "MCIdType.hxx" + static mcIdType connITT[201]={0, 50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000, 1029, 1058, 1087, 1116, 1145, 1174, 1203, 1232, 1261, 1290, 1319, 1348, 1377, 1406, 1435, 1464, 1493, 1522, 1551, 1580, 1609, 1638, 1667, 1696, 1725, 1754, 1783, 1812, 1841, 1870, 1899, 1928, 1957, 1986, 2015, 2044, 2073, 2102, 2131, 2160, 2189, 2218, 2247, 2276, 2305, 2334, 2363, 2392, 2421, 2450, 2479, 2508, 2537, 2566, 2595, diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTestInterp.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTestInterp.cxx index 08f77cf03..1d771b8cc 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTestInterp.cxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTestInterp.cxx @@ -19,11 +19,22 @@ // Author : Anthony Geay (CEA/DEN) #include "MEDCouplingBasicsTestInterp.hxx" +#include "MEDCouplingNormalizedUnstructuredMesh.txx" +#include "Interpolation2D.hxx" +#include "InterpolationOptions.hxx" +#include "MCType.hxx" +#include "Interpolation3D.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include "MEDCouplingNormalizedCartesianMesh.hxx" +#include "InterpKernelException.hxx" +#include "InterpolationCC.hxx" +#include "InterpolationCU.hxx" +#include "Interpolation1D.hxx" +#include "Interpolation2D1D.hxx" +#include "Interpolation2D3D.hxx" #include "MEDCouplingUMesh.hxx" #include "MEDCouplingMappedExtrudedMesh.hxx" -#include "MEDCouplingFieldDouble.hxx" #include "MEDCouplingMemArray.hxx" -#include "Interpolation2D.txx" #include "Interpolation3DSurf.hxx" #include "Interpolation3D.txx" #include "Interpolation2D1D.txx" @@ -31,17 +42,19 @@ #include "InterpolationCC.txx" #include "InterpolationCU.txx" #include "Interpolation2DCurve.hxx" -#include "Interpolation1D.txx" -#include "MEDCouplingNormalizedUnstructuredMesh.txx" #include "MEDCouplingNormalizedCartesianMesh.txx" +#include "NormalizedGeometricTypes" #include -#include +#include +#include +#include +#include using namespace MEDCoupling; -typedef std::vector > IntersectionMatrix; +using IntersectionMatrix = int; void MEDCouplingBasicsTestInterp::test2DInterpP0P0_1() { @@ -52,11 +65,11 @@ void MEDCouplingBasicsTestInterp::test2DInterpP0P0_1() MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh); INTERP_KERNEL::Interpolation2D myInterpolator; std::vector > res; - INTERP_KERNEL::IntersectionType types[3]={INTERP_KERNEL::Triangulation, INTERP_KERNEL::Convex, INTERP_KERNEL::Geometric2D}; - for(int i=0;i<3;i++) + INTERP_KERNEL::IntersectionType const types[3]={INTERP_KERNEL::Triangulation, INTERP_KERNEL::Convex, INTERP_KERNEL::Geometric2D}; + for(auto & type : types) { myInterpolator.setPrecision(1e-12); - myInterpolator.setIntersectionType(types[i]); + myInterpolator.setIntersectionType(type); myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0"); CPPUNIT_ASSERT_EQUAL(5,(int)res.size()); CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[0][0],1e-12); @@ -206,11 +219,11 @@ void MEDCouplingBasicsTestInterp::test2DInterpP0P1_1() MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh); INTERP_KERNEL::Interpolation2D myInterpolator; std::vector > res; - INTERP_KERNEL::IntersectionType types[2]={INTERP_KERNEL::Triangulation, INTERP_KERNEL::Geometric2D}; - for(int i=0;i<2;i++) + INTERP_KERNEL::IntersectionType const types[2]={INTERP_KERNEL::Triangulation, INTERP_KERNEL::Geometric2D}; + for(auto & type : types) { myInterpolator.setPrecision(1e-12); - myInterpolator.setIntersectionType(types[i]); + myInterpolator.setIntersectionType(type); myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P1"); CPPUNIT_ASSERT_EQUAL(9,(int)res.size()); CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664,res[0][0],1e-12); @@ -316,11 +329,11 @@ void MEDCouplingBasicsTestInterp::test2DInterpP1P0_1() MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh); INTERP_KERNEL::Interpolation2D myInterpolator; std::vector > res; - INTERP_KERNEL::IntersectionType types[2]={INTERP_KERNEL::Triangulation, INTERP_KERNEL::Geometric2D}; - for(mcIdType i=0;i<2;i++) + INTERP_KERNEL::IntersectionType const types[2]={INTERP_KERNEL::Triangulation, INTERP_KERNEL::Geometric2D}; + for(auto & type : types) { myInterpolator.setPrecision(1e-12); - myInterpolator.setIntersectionType(types[i]); + myInterpolator.setIntersectionType(type); myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0"); CPPUNIT_ASSERT_EQUAL(5,(int)res.size()); CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[0][0],1e-12); @@ -428,11 +441,11 @@ void MEDCouplingBasicsTestInterp::test2DInterpP1P1_1() MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh); INTERP_KERNEL::Interpolation2D myInterpolator; std::vector > res; - INTERP_KERNEL::IntersectionType types[2]={INTERP_KERNEL::Triangulation, INTERP_KERNEL::Geometric2D}; - for(int i=0;i<2;i++) + INTERP_KERNEL::IntersectionType const types[2]={INTERP_KERNEL::Triangulation, INTERP_KERNEL::Geometric2D}; + for(auto & type : types) { myInterpolator.setPrecision(1e-12); - myInterpolator.setIntersectionType(types[i]); + myInterpolator.setIntersectionType(type); myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P1"); CPPUNIT_ASSERT_EQUAL(9,(int)res.size()); CPPUNIT_ASSERT_DOUBLES_EQUAL(0.08333333333333334,res[0][0],1.e-12); @@ -501,7 +514,7 @@ void MEDCouplingBasicsTestInterp::test3DSurfInterpP0P0_1() MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper(targetMesh); INTERP_KERNEL::Interpolation3DSurf myInterpolator; std::vector > res; - INTERP_KERNEL::IntersectionType types[3]={INTERP_KERNEL::Triangulation, INTERP_KERNEL::Geometric2D}; + INTERP_KERNEL::IntersectionType const types[3]={INTERP_KERNEL::Triangulation, INTERP_KERNEL::Geometric2D}; for(int i=0;i<2;i++) { myInterpolator.setPrecision(1e-12); @@ -560,10 +573,10 @@ void MEDCouplingBasicsTestInterp::test3DSurfInterpP0P1_1() INTERP_KERNEL::Interpolation3DSurf myInterpolator; std::vector > res; INTERP_KERNEL::IntersectionType types[2]={INTERP_KERNEL::Triangulation, INTERP_KERNEL::Geometric2D}; - for(int i=0;i<2;i++) + for(auto & type : types) { myInterpolator.setPrecision(1e-12); - myInterpolator.setIntersectionType(types[i]); + myInterpolator.setIntersectionType(type); myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P1"); CPPUNIT_ASSERT_EQUAL(9,(int)res.size()); CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664*sqrt(2.),res[0][0],1e-12); @@ -628,10 +641,10 @@ void MEDCouplingBasicsTestInterp::test3DSurfInterpP1P0_1() INTERP_KERNEL::Interpolation3DSurf myInterpolator; std::vector > res; INTERP_KERNEL::IntersectionType types[2]={INTERP_KERNEL::Triangulation, INTERP_KERNEL::Geometric2D}; - for(int i=0;i<2;i++) + for(auto & type : types) { myInterpolator.setPrecision(1e-12); - myInterpolator.setIntersectionType(types[i]); + myInterpolator.setIntersectionType(type); myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0"); CPPUNIT_ASSERT_EQUAL(5,(int)res.size()); CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25*sqrt(2.),res[0][0],1e-12); @@ -698,10 +711,10 @@ void MEDCouplingBasicsTestInterp::test3DSurfInterpP1P1_1() INTERP_KERNEL::Interpolation3DSurf myInterpolator; std::vector > res; INTERP_KERNEL::IntersectionType types[2]={INTERP_KERNEL::Triangulation, INTERP_KERNEL::Geometric2D}; - for(int i=0;i<2;i++) + for(auto & type : types) { myInterpolator.setPrecision(1e-12); - myInterpolator.setIntersectionType(types[i]); + myInterpolator.setIntersectionType(type); myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P1"); CPPUNIT_ASSERT_EQUAL(9,(int)res.size()); CPPUNIT_ASSERT_DOUBLES_EQUAL(0.08333333333333334*sqrt(2.),res[0][0],1.e-12); @@ -833,9 +846,9 @@ void MEDCouplingBasicsTestInterp::test3DSurfInterpP0P0_3() { INTERP_KERNEL::Interpolation3DSurf myInterpolator; std::vector > res; - double vecTrans[3]={0.,0.,1.e-10}; - double vec[3]={0.,-1.,0.}; - double pt[3]={-0.3,-0.3,5.e-11}; + double const vecTrans[3]={0.,0.,1.e-10}; + double const vec[3]={0.,-1.,0.}; + double const pt[3]={-0.3,-0.3,5.e-11}; const int N=32; const double deltaA=M_PI/N; myInterpolator.setPrecision(1e-12); @@ -930,9 +943,9 @@ void MEDCouplingBasicsTestInterp::test3DInterpP0P0_1() std::vector > res; myInterpolator.setPrecision(1e-12); INTERP_KERNEL::SplittingPolicy sp[] = { INTERP_KERNEL::PLANAR_FACE_5, INTERP_KERNEL::PLANAR_FACE_6, INTERP_KERNEL::GENERAL_24, INTERP_KERNEL::GENERAL_48 }; - for ( int i = 0; i < 4; ++i ) + for (auto & i : sp) { - myInterpolator.setSplittingPolicy( sp[i] ); + myInterpolator.setSplittingPolicy( i ); res.clear(); myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0"); CPPUNIT_ASSERT_EQUAL(8,(int)res.size()); @@ -999,9 +1012,9 @@ void MEDCouplingBasicsTestInterp::test3DInterpP0P0PL_1() myInterpolator.setPrecision(1e-12); myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator); INTERP_KERNEL::SplittingPolicy sp[] = { INTERP_KERNEL::PLANAR_FACE_5, INTERP_KERNEL::PLANAR_FACE_6, INTERP_KERNEL::GENERAL_24, INTERP_KERNEL::GENERAL_48 }; - for ( int i = 0; i < 4; ++i ) + for (auto & i : sp) { - myInterpolator.setSplittingPolicy( sp[i] ); + myInterpolator.setSplittingPolicy( i ); res.clear(); myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0"); CPPUNIT_ASSERT_EQUAL(8,(int)res.size()); @@ -1049,9 +1062,9 @@ void MEDCouplingBasicsTestInterp::test3DInterpP0P0PL_2() myInterpolator.setPrecision(1e-12); myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator); INTERP_KERNEL::SplittingPolicy sp[] = { INTERP_KERNEL::PLANAR_FACE_5, INTERP_KERNEL::PLANAR_FACE_6, INTERP_KERNEL::GENERAL_24, INTERP_KERNEL::GENERAL_48 }; - for ( int i = 0; i < 4; ++i ) + for (auto & i : sp) { - myInterpolator.setSplittingPolicy( sp[i] ); + myInterpolator.setSplittingPolicy( i ); res.clear(); myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0"); CPPUNIT_ASSERT_EQUAL(8,(int)res.size()); @@ -1099,9 +1112,9 @@ void MEDCouplingBasicsTestInterp::test3DInterpP0P0PL_3() myInterpolator.setPrecision(1e-12); myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator); INTERP_KERNEL::SplittingPolicy sp[] = { INTERP_KERNEL::PLANAR_FACE_5, INTERP_KERNEL::PLANAR_FACE_6, INTERP_KERNEL::GENERAL_24, INTERP_KERNEL::GENERAL_48 }; - for ( int i = 0; i < 4; ++i ) + for (auto & i : sp) { - myInterpolator.setSplittingPolicy( sp[i] ); + myInterpolator.setSplittingPolicy( i ); res.clear(); myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0"); CPPUNIT_ASSERT_EQUAL(8,(int)res.size()); @@ -1153,9 +1166,9 @@ void MEDCouplingBasicsTestInterp::test3DInterpP0P0PL_4() myInterpolator.setPrecision(1e-12); myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator); INTERP_KERNEL::SplittingPolicy sp[] = { INTERP_KERNEL::PLANAR_FACE_5, INTERP_KERNEL::PLANAR_FACE_6, INTERP_KERNEL::GENERAL_24, INTERP_KERNEL::GENERAL_48 }; - for ( int i = 0; i < 4; ++i ) + for (auto & i : sp) { - myInterpolator.setSplittingPolicy( sp[i] ); + myInterpolator.setSplittingPolicy( i ); res.clear(); myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0"); CPPUNIT_ASSERT_EQUAL(8,(int)res.size()); @@ -1198,9 +1211,9 @@ void MEDCouplingBasicsTestInterp::test3DInterpP0P1_1() std::vector > res; myInterpolator.setPrecision(1e-12); INTERP_KERNEL::SplittingPolicy sp[] = { INTERP_KERNEL::PLANAR_FACE_5, INTERP_KERNEL::PLANAR_FACE_6, INTERP_KERNEL::GENERAL_24, INTERP_KERNEL::GENERAL_48 }; - for ( int i = 0; i < 4; ++i ) + for (auto & i : sp) { - myInterpolator.setSplittingPolicy( sp[i] ); + myInterpolator.setSplittingPolicy( i ); res.clear(); myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P1"); CPPUNIT_ASSERT_EQUAL(9,(int)res.size()); @@ -1255,9 +1268,9 @@ void MEDCouplingBasicsTestInterp::test3DInterpP0P1PL_1() myInterpolator.setPrecision(1e-12); myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator); INTERP_KERNEL::SplittingPolicy sp[] = { INTERP_KERNEL::PLANAR_FACE_5, INTERP_KERNEL::PLANAR_FACE_6, INTERP_KERNEL::GENERAL_24, INTERP_KERNEL::GENERAL_48 }; - for ( int i = 0; i < 4; ++i ) + for (auto & i : sp) { - myInterpolator.setSplittingPolicy( sp[i] ); + myInterpolator.setSplittingPolicy( i ); res.clear(); myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P1"); CPPUNIT_ASSERT_EQUAL(9,(int)res.size()); @@ -1288,9 +1301,9 @@ void MEDCouplingBasicsTestInterp::test3DInterpP1P0_1() std::vector > res; myInterpolator.setPrecision(1e-12); INTERP_KERNEL::SplittingPolicy sp[] = { INTERP_KERNEL::PLANAR_FACE_5, INTERP_KERNEL::PLANAR_FACE_6, INTERP_KERNEL::GENERAL_24}; - for ( int i = 0; i < 3; ++i ) + for (auto & i : sp) { - myInterpolator.setSplittingPolicy( sp[i] ); + myInterpolator.setSplittingPolicy( i ); res.clear(); myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0"); CPPUNIT_ASSERT_EQUAL(8,(int)res.size()); @@ -1345,9 +1358,9 @@ void MEDCouplingBasicsTestInterp::test3DInterpP1P0PL_1() myInterpolator.setPrecision(1e-12); myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator); INTERP_KERNEL::SplittingPolicy sp[] = { INTERP_KERNEL::PLANAR_FACE_5, INTERP_KERNEL::PLANAR_FACE_6, INTERP_KERNEL::GENERAL_24, INTERP_KERNEL::GENERAL_48 }; - for ( int i = 0; i < 4; ++i ) + for (auto & i : sp) { - myInterpolator.setSplittingPolicy( sp[i] ); + myInterpolator.setSplittingPolicy( i ); res.clear(); myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0"); CPPUNIT_ASSERT_EQUAL(8,(int)res.size()); @@ -1393,7 +1406,7 @@ void MEDCouplingBasicsTestInterp::test3DInterpP1P1_1() myInterpolator.setPrecision(1e-12); myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P1"); CPPUNIT_ASSERT_EQUAL(8,(int)res.size()); - double res3D[8][28]= {{124999.999883775978, 245370.370390364464, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 203703.703634892299, 187500.000094145857, 0.0, 0.0, 4629.6296266718, 0.0, 215277.777751402784, 209722.222322299582, 0.0, 0.0, 0.0, 0.0, 104166.666590829205, 121296.296368812196, 0.0, 250000.000003472145}, + double const res3D[8][28]= {{124999.999883775978, 245370.370390364464, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 203703.703634892299, 187500.000094145857, 0.0, 0.0, 4629.6296266718, 0.0, 215277.777751402784, 209722.222322299582, 0.0, 0.0, 0.0, 0.0, 104166.666590829205, 121296.296368812196, 0.0, 250000.000003472145}, {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 120370.370368827047, 0.0, 0.0, 38888.888897777797, 0.0, 0.0, 45370.3703701697596, 0.0, 0.0, 45370.3703701697596, 83333.3333263888926, 0.0}, {0.0, 0.0, 0.0, 97222.2222222221753, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 97222.2222222221608, 0.0, 97222.2222222222044, 41666.6666666666642, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, {0.0, 277777.777787084982, 199074.074074073927, 0.0, 0.0, 0.0, 4629.62962962962774, 0.0, 321759.259254934732, 83333.3333333333139, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4629.62962667180363, 0.0, 0.0, 251388.88888319055, 194444.444454861077, 0.0, 79629.6296194135939, 250000.000003472145, 0.0, 0.0, 0.0, 0.0}, @@ -1933,11 +1946,11 @@ void MEDCouplingBasicsTestInterp::test2DInterpP1P0Bary_1() MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh); INTERP_KERNEL::Interpolation2D myInterpolator; std::vector > res; - INTERP_KERNEL::IntersectionType types[2]={INTERP_KERNEL::Barycentric,INTERP_KERNEL::BarycentricGeo2D}; - for(int i=0;i<2;i++) + INTERP_KERNEL::IntersectionType const types[2]={INTERP_KERNEL::Barycentric,INTERP_KERNEL::BarycentricGeo2D}; + for(auto & type : types) { myInterpolator.setPrecision(1e-12); - myInterpolator.setIntersectionType(types[i]); + myInterpolator.setIntersectionType(type); myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0"); CPPUNIT_ASSERT_EQUAL(5,(int)res.size()); CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666669,res[0][0],1e-12); @@ -1975,10 +1988,10 @@ void MEDCouplingBasicsTestInterp::test3DSurfInterpP1P0Bary_1() INTERP_KERNEL::Interpolation3DSurf myInterpolator; std::vector > res; INTERP_KERNEL::IntersectionType types[2]={INTERP_KERNEL::Barycentric,INTERP_KERNEL::BarycentricGeo2D}; - for(int i=0;i<2;i++) + for(auto & type : types) { myInterpolator.setPrecision(1e-12); - myInterpolator.setIntersectionType(types[i]); + myInterpolator.setIntersectionType(type); myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0"); CPPUNIT_ASSERT_EQUAL(5,(int)res.size()); CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666669*sqrt(2.),res[0][0],1e-12); @@ -2006,7 +2019,6 @@ void MEDCouplingBasicsTestInterp::test3DSurfInterpP1P0Bary_1() targetMesh->decrRef(); } -#include void MEDCouplingBasicsTestInterp::test3DInterpP1P0Bary_1() { MEDCouplingUMesh *sourceMesh=build3DSourceMesh_2(); @@ -2021,7 +2033,7 @@ void MEDCouplingBasicsTestInterp::test3DInterpP1P0Bary_1() myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0"); CPPUNIT_ASSERT_EQUAL(5,(int)res.size()); - double res3D[5][28]={{104166.66658918398, 885416.666685817763, 135416.666666666541, 36458.3333333335031, 31249.9999999999018, 145833.333333333256, 41666.6666666667516, 124999.999999999971, 177083.333326388849, 0.0, 31249.9999999999636, 0.0, 41666.666620792399, 159722.22229009436, 0.0, 0.0, 41666.6666631944681, 125000, 43499.2283723790752, 164351.851924000395, 36458.3333372396883, 0.0, 0.0, 125000.000001736029, 34722.2221800900952, 13599.5370788455439, 0.0, 167438.27159690368}, + double const res3D[5][28]={{104166.66658918398, 885416.666685817763, 135416.666666666541, 36458.3333333335031, 31249.9999999999018, 145833.333333333256, 41666.6666666667516, 124999.999999999971, 177083.333326388849, 0.0, 31249.9999999999636, 0.0, 41666.666620792399, 159722.22229009436, 0.0, 0.0, 41666.6666631944681, 125000, 43499.2283723790752, 164351.851924000395, 36458.3333372396883, 0.0, 0.0, 125000.000001736029, 34722.2221800900952, 13599.5370788455439, 0.0, 167438.27159690368}, {0.0, 41666.6664479170649, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 125000.000161457952, 0.0, 0.0, 0.0, 0.0, 111111.11112005508, 0.0, 0.0, 291666.666656249959, 41666.6666666666933, 6944.4444415638809, 270833.333520485845, 0.0, 0.0, 124999.999989583303, 41666.6665798612958, 20833.3333186342825, 145833.333354303701, 83333.3333263888198, 27777.7777501651799}, {0.0, 93750.0000000000728, 125000.000000000058, 0.0, 0.0, 72916.666666666526, 291666.666666666628, 41666.6666666667152, 197916.66666666657, 166666.666666666802, 218750.000000000116, 41666.6666666665697, 0.0, 0.0, 0.0, 0.0, 0.0, 41666.6666666666861, 0.0, 0.0, 0.0, 0.0, 0.0, 41666.6666666666642, 0.0, 0.0, 0.0, 0.0}, {72916.6666484848247, 82465.2777799315081, 0.0, 0.0, 217447.916666666686, 197916.666666666802, 0.0, 41666.6666666666715, 0.0, 0.0, 0.0, 0.0, 290364.583310396119, 125000.000018181803, 41666.6666666666351, 166666.666666666599, 0.0, 41666.6666666665551, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 27777.7777734705051, 0.0, 0.0, 27777.7778028684952}, @@ -2302,7 +2314,7 @@ void MEDCouplingBasicsTestInterp::test2D1DBasicInterpP0P0() CPPUNIT_ASSERT_DOUBLES_EQUAL(6., matrix[1][6],1e-12); CPPUNIT_ASSERT_DOUBLES_EQUAL(3., matrix[1][7],1e-12); - INTERP_KERNEL::Interpolation2D3D::DuplicateFacesType duplicateFaces = myInterpolator.retrieveDuplicateFaces(); + INTERP_KERNEL::Interpolation2D3D::DuplicateFacesType const duplicateFaces = myInterpolator.retrieveDuplicateFaces(); CPPUNIT_ASSERT_EQUAL(1,(int)duplicateFaces.size()); INTERP_KERNEL::Interpolation2D3D::DuplicateFacesType correctDuplicateFaces; @@ -2431,9 +2443,9 @@ void MEDCouplingBasicsTestInterp::test3D2DBasicInterpP0P0() myInterpolator.setPrecision(1e-12); std::vector > matrix; INTERP_KERNEL::SplittingPolicy sp[] = { INTERP_KERNEL::PLANAR_FACE_5, INTERP_KERNEL::PLANAR_FACE_6, INTERP_KERNEL::GENERAL_24, INTERP_KERNEL::GENERAL_48 }; - for ( size_t i = 0; i < sizeof(sp)/sizeof(sp[0]); ++i ) + for (auto & i : sp) { - myInterpolator.setSplittingPolicy( sp[i] ); + myInterpolator.setSplittingPolicy( i ); matrix.clear(); myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,matrix,"P0P0"); @@ -2463,7 +2475,7 @@ void MEDCouplingBasicsTestInterp::test3D2DBasicInterpP0P0() CPPUNIT_ASSERT_DOUBLES_EQUAL(80. ,matrix[2][5],1e-12); CPPUNIT_ASSERT_DOUBLES_EQUAL(112. ,matrix[2][6],1e-12); - INTERP_KERNEL::Interpolation2D3D::DuplicateFacesType duplicateFaces = myInterpolator.retrieveDuplicateFaces(); + INTERP_KERNEL::Interpolation2D3D::DuplicateFacesType const duplicateFaces = myInterpolator.retrieveDuplicateFaces(); CPPUNIT_ASSERT_EQUAL(3,(int)duplicateFaces.size()); INTERP_KERNEL::Interpolation2D3D::DuplicateFacesType correctDuplicateFaces; diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTestInterp.hxx b/src/MEDCoupling/Test/MEDCouplingBasicsTestInterp.hxx index 419569d73..d8a777ec6 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTestInterp.hxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTestInterp.hxx @@ -23,8 +23,7 @@ #include "MEDCouplingBasicsTest.hxx" -#include -#include +#include namespace MEDCoupling { diff --git a/src/MEDCoupling/Test/MEDCouplingExamplesTest.cxx b/src/MEDCoupling/Test/MEDCouplingExamplesTest.cxx index f75dc967e..84930c509 100644 --- a/src/MEDCoupling/Test/MEDCouplingExamplesTest.cxx +++ b/src/MEDCoupling/Test/MEDCouplingExamplesTest.cxx @@ -18,14 +18,27 @@ // // Author : Anthony Geay (EDF R&D) +#include "MCAuto.hxx" +#include "MCIdType.hxx" +#include "MCType.hxx" +#include "InterpKernelException.hxx" #include "MEDCouplingBasicsTest.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include "MEDCouplingPointSet.hxx" #include "MEDCouplingUMesh.hxx" #include "MEDCouplingCMesh.hxx" #include "MEDCouplingMappedExtrudedMesh.hxx" #include "MEDCouplingFieldDouble.hxx" -#include "MEDCouplingMemArray.hxx" #include "MEDCouplingMemArray.txx" #include "MEDCouplingMultiFields.hxx" +#include +#include +#include +#include +#include +#include "NormalizedGeometricTypes" +#include +#include void CppExample_MEDCouplingFieldDouble_WriteVTK() @@ -109,12 +122,12 @@ void CppExample_MEDCouplingFieldDouble_MergeFields() field2->applyFunc("x + 5"); // "translate" field2 // concatenate field1 and field2 - MCAuto field3 = + MCAuto const field3 = MEDCouplingFieldDouble::MergeFields( field1, field2 ); std::vector fields( 2 ); fields[0] = field1; fields[1] = field2; - MCAuto field4 = + MCAuto const field4 = MEDCouplingFieldDouble::MergeFields( fields ); //! [CppSnippet_MEDCouplingFieldDouble_MergeFields_1] } @@ -217,7 +230,7 @@ void CppExample_MEDCouplingFieldDouble_applyFunc3() // transform the field to a 3D vector field const char func[] = "IVec * b + JVec * a + KVec * sqrt( a*a + b*b ) + 10"; const char* varNames[2] = { "a", "b" }; // names used to refer to X and Y components - std::vector varNamesVec( varNames, varNames+2 ); + std::vector const varNamesVec( varNames, varNames+2 ); field->applyFuncNamedCompo( 3, varNamesVec, func ); // require 3 components CPPUNIT_ASSERT( field->getNumberOfComponents() == 3 ); // 3 components as required //! [CppSnippet_MEDCouplingFieldDouble_applyFunc3_1] @@ -328,7 +341,7 @@ void CppExample_MEDCouplingFieldDouble_fillFromAnalytic3() field->setMesh( mesh ); const char func[] = "IVec * b + JVec * a + KVec * sqrt( a*a + b*b ) + 10"; const char* varNames[2] = { "a", "b" }; // names used to refer to X and Y coord components - std::vector varNamesVec( varNames, varNames+2 ); + std::vector const varNamesVec( varNames, varNames+2 ); field->fillFromAnalyticNamedCompo( 3, varNamesVec, func ); //! [CppSnippet_MEDCouplingFieldDouble_fillFromAnalytic3_2] //! [CppSnippet_MEDCouplingFieldDouble_fillFromAnalytic3_3] @@ -341,7 +354,7 @@ void CppExample_MEDCouplingFieldDouble_fillFromAnalytic3() double bc1[2]; // coordinates of the second point bc->getTuple( 1, bc1 ); // - double dist = sqrt( bc1[0]*bc1[0] + bc1[1]*bc1[1] ); // "sqrt( a*a + b*b )" + double const dist = sqrt( bc1[0]*bc1[0] + bc1[1]*bc1[1] ); // "sqrt( a*a + b*b )" CPPUNIT_ASSERT_DOUBLES_EQUAL( val1[0], 10 + bc1[1], 13 ); // "10 + IVec * b" CPPUNIT_ASSERT_DOUBLES_EQUAL( val1[1], 10 + bc1[0], 13 ); // "10 + JVec * a" CPPUNIT_ASSERT_DOUBLES_EQUAL( val1[2], 10 + dist , 13 ); // "10 + KVec * sqrt( a*a + b*b )" @@ -379,7 +392,7 @@ void CppExample_MEDCouplingFieldDouble_fillFromAnalytic2() double bc1[2]; // coordinates of the second point bc->getTuple( 1, bc1 ); // - double dist = sqrt( bc1[0]*bc1[0] + bc1[1]*bc1[1] ); // "sqrt( a*a + b*b )" + double const dist = sqrt( bc1[0]*bc1[0] + bc1[1]*bc1[1] ); // "sqrt( a*a + b*b )" CPPUNIT_ASSERT_DOUBLES_EQUAL( val1[0], 10 + bc1[1], 13 ); // "10 + IVec * b" CPPUNIT_ASSERT_DOUBLES_EQUAL( val1[1], 10 + bc1[0], 13 ); // "10 + JVec * a" CPPUNIT_ASSERT_DOUBLES_EQUAL( val1[2], 10 + dist , 13 ); // "10 + KVec * sqrt( a*a + b*b )" @@ -415,7 +428,7 @@ void CppExample_MEDCouplingFieldDouble_fillFromAnalytic() double bc1[2]; // coordinates of the second point bc->getTuple( 1, bc1 ); // - double dist = sqrt( bc1[0]*bc1[0] + bc1[1]*bc1[1] ); // "sqrt( a*a + b*b )" + double const dist = sqrt( bc1[0]*bc1[0] + bc1[1]*bc1[1] ); // "sqrt( a*a + b*b )" CPPUNIT_ASSERT_DOUBLES_EQUAL( val1[0], 10 + bc1[1], 13 ); // "10 + IVec * b" CPPUNIT_ASSERT_DOUBLES_EQUAL( val1[1], 10 + bc1[0], 13 ); // "10 + JVec * a" CPPUNIT_ASSERT_DOUBLES_EQUAL( val1[2], 10 + dist , 13 ); // "10 + KVec * sqrt( a*a + b*b )" @@ -665,7 +678,7 @@ void CppExample_MEDCouplingMesh_fillFromAnalytic3() //! [CppSnippet_MEDCouplingMesh_fillFromAnalytic3_2] const char func[] = "IVec * b + JVec * a + KVec * sqrt( a*a + b*b ) + 10"; const char* varNames[2] = { "a", "b" }; // names used to refer to X and Y coord components - std::vector varNamesVec( varNames, varNames+2 ); + std::vector const varNamesVec( varNames, varNames+2 ); MCAuto field = mesh->fillFromAnalyticNamedCompo( MEDCoupling::ON_CELLS, 3, varNamesVec, func ); //! [CppSnippet_MEDCouplingMesh_fillFromAnalytic3_2] @@ -679,7 +692,7 @@ void CppExample_MEDCouplingMesh_fillFromAnalytic3() double bc1[2]; // coordinates of the second point bc->getTuple( 1, bc1 ); // - double dist = sqrt( bc1[0]*bc1[0] + bc1[1]*bc1[1] ); // "sqrt( a*a + b*b )" + double const dist = sqrt( bc1[0]*bc1[0] + bc1[1]*bc1[1] ); // "sqrt( a*a + b*b )" CPPUNIT_ASSERT_DOUBLES_EQUAL( val1[0], 10 + bc1[1], 13 ); // "10 + IVec * b" CPPUNIT_ASSERT_DOUBLES_EQUAL( val1[1], 10 + bc1[0], 13 ); // "10 + JVec * a" CPPUNIT_ASSERT_DOUBLES_EQUAL( val1[2], 10 + dist , 13 ); // "10 + KVec * sqrt( a*a + b*b )" @@ -715,7 +728,7 @@ void CppExample_MEDCouplingMesh_fillFromAnalytic2() double bc1[2]; // coordinates of the second point bc->getTuple( 1, bc1 ); // - double dist = sqrt( bc1[0]*bc1[0] + bc1[1]*bc1[1] ); // "sqrt( a*a + b*b )" + double const dist = sqrt( bc1[0]*bc1[0] + bc1[1]*bc1[1] ); // "sqrt( a*a + b*b )" CPPUNIT_ASSERT_DOUBLES_EQUAL( val1[0], 10 + bc1[1], 13 ); // "10 + IVec * b" CPPUNIT_ASSERT_DOUBLES_EQUAL( val1[1], 10 + bc1[0], 13 ); // "10 + JVec * a" CPPUNIT_ASSERT_DOUBLES_EQUAL( val1[2], 10 + dist , 13 ); // "10 + KVec * sqrt( a*a + b*b )" @@ -749,7 +762,7 @@ void CppExample_MEDCouplingMesh_fillFromAnalytic() double bc1[2]; // coordinates of the second point bc->getTuple( 1, bc1 ); // - double dist = sqrt( bc1[0]*bc1[0] + bc1[1]*bc1[1] ); // "sqrt( a*a + b*b )" + double const dist = sqrt( bc1[0]*bc1[0] + bc1[1]*bc1[1] ); // "sqrt( a*a + b*b )" CPPUNIT_ASSERT_DOUBLES_EQUAL( val1[0], 10 + bc1[1], 13 ); // "10 + IVec * b" CPPUNIT_ASSERT_DOUBLES_EQUAL( val1[1], 10 + bc1[0], 13 ); // "10 + JVec * a" CPPUNIT_ASSERT_DOUBLES_EQUAL( val1[2], 10 + dist , 13 ); // "10 + KVec * sqrt( a*a + b*b )" @@ -796,7 +809,7 @@ void CppExample_MEDCouplingUMesh_areCellsIncludedIn() (MEDCouplingUMesh*) mesh1->buildPartOfMySelf( cells2, cells2+3, true ); //! [CppSnippet_MEDCouplingUMesh_areCellsIncludedIn_2] //! [CppSnippet_MEDCouplingUMesh_areCellsIncludedIn_3] - int compType = 0; // the strongest policy + int const compType = 0; // the strongest policy DataArrayIdType *corr2to1, *corr1to2; // a larger mesh1 includes a smaller mesh2 CPPUNIT_ASSERT( mesh1->areCellsIncludedIn( mesh2, compType, corr2to1 )); @@ -1351,8 +1364,8 @@ void CppExample_MEDCouplingUMesh_buildPartOfMySelf() //! [CppSnippet_MEDCouplingUMesh_buildPartOfMySelf_1] //! [CppSnippet_MEDCouplingUMesh_buildPartOfMySelf_2] const mcIdType cellIds[2]={1,2}; - MEDCouplingUMesh* mesh2=(MEDCouplingUMesh*)mesh->buildPartOfMySelf(cellIds,cellIds+2,true); - MEDCouplingUMesh* mesh3=(MEDCouplingUMesh*)mesh->buildPartOfMySelf(cellIds,cellIds+2,false); + auto* mesh2=(MEDCouplingUMesh*)mesh->buildPartOfMySelf(cellIds,cellIds+2,true); + auto* mesh3=(MEDCouplingUMesh*)mesh->buildPartOfMySelf(cellIds,cellIds+2,false); CPPUNIT_ASSERT( coordsArr->isEqual( *mesh2->getCoords(), 1e-13 )); // same nodes CPPUNIT_ASSERT( !coordsArr->isEqual( *mesh3->getCoords(), 1e-13 )); // different nodes for ( mcIdType i = 0; i < 2; ++i ) @@ -1466,7 +1479,7 @@ void CppExample_MEDCouplingUMesh_zipCoordsTraducer() //! [CppSnippet_MEDCouplingUMesh_zipCoordsTraducer_1] //! [CppSnippet_MEDCouplingUMesh_zipCoordsTraducer_2] const mcIdType cellIds[2]={1,2}; - MEDCouplingUMesh* mesh2=(MEDCouplingUMesh*)mesh->buildPartOfMySelf(cellIds,cellIds+2,true); + auto* mesh2=(MEDCouplingUMesh*)mesh->buildPartOfMySelf(cellIds,cellIds+2,true); DataArrayIdType *arr=mesh2->zipCoordsTraducer(); CPPUNIT_ASSERT_EQUAL( ToIdType(4), mesh2->getNumberOfNodes() ); // nb of nodes decreased CPPUNIT_ASSERT_EQUAL( mesh->getNumberOfNodes(), arr->getNumberOfTuples() ); @@ -1499,7 +1512,7 @@ void CppExample_MEDCouplingUMesh_getNodeIdsInUse() //! [CppSnippet_MEDCouplingUMesh_getNodeIdsInUse_1] //! [CppSnippet_MEDCouplingUMesh_getNodeIdsInUse_2] const mcIdType cellIds[2]={1,2}; - MEDCouplingUMesh* mesh2=(MEDCouplingUMesh*)mesh->buildPartOfMySelf(cellIds,cellIds+2,true); + auto* mesh2=(MEDCouplingUMesh*)mesh->buildPartOfMySelf(cellIds,cellIds+2,true); mcIdType newNbOfNodes = 0; DataArrayIdType *arr=mesh2->getNodeIdsInUse( newNbOfNodes ); const mcIdType idsExpected[9] = {-1,0,1,-1,2,3,-1,-1,-1}; @@ -2032,7 +2045,7 @@ void CppExample_DataArrayDouble_findCommonTuples() std::copy(array2,array2+12,da->getPointer()); //! [CppSnippet_DataArrayDouble_findCommonTuples1] //! [CppSnippet_DataArrayDouble_findCommonTuples2] - DataArrayIdType *c=0,*cI=0; + DataArrayIdType *c=nullptr,*cI=nullptr; da->findCommonTuples(1.01e-1,-1,c,cI); const mcIdType expected3[5]={0,3,4,1,2}; @@ -2118,7 +2131,7 @@ void CppExampleFieldDoubleBuildSubPart1() CPPUNIT_ASSERT_EQUAL(ToIdType(6),f2->getMesh()->getNumberOfNodes()); CPPUNIT_ASSERT_EQUAL(2,f2->getMesh()->getSpaceDimension()); CPPUNIT_ASSERT_EQUAL(2,f2->getMesh()->getMeshDimension()); - MEDCoupling::MEDCouplingUMesh *m2C=dynamic_cast(const_cast(f2->getMesh())); + auto *m2C=dynamic_cast(const_cast(f2->getMesh())); CPPUNIT_ASSERT_EQUAL(ToIdType(13),m2C->getNodalConnectivityArrayLen()); const double expected2[12]={0.2, -0.3, 0.7, -0.3, 0.2, 0.2, 0.7, 0.2, 0.2, 0.7, 0.7, 0.7}; for(mcIdType i=0;i<12;i++) @@ -2281,8 +2294,8 @@ void CppSnippetDataArrayBuild1() const mcIdType nbOfNodes=12; double coords[3*nbOfNodes]={2.,3.,4.,3.,4.,5.,4.,5.,6.,5.,6.,7.,6.,7.,8.,7.,8.,9.,8.,9.,10.,9.,10.,11.,10.,11.,12.,11.,12.,13.,12.,13.,14.,13.,14.,15.}; // - MEDCoupling::DataArrayDouble *coordsArr=0; - double *tmp=0; + MEDCoupling::DataArrayDouble *coordsArr=nullptr; + double *tmp=nullptr; //! [CppSnippetDataArrayBuild1_0] // //! [CppSnippetDataArrayBuild1_1] @@ -2328,7 +2341,7 @@ void CppSnippetDataArrayBuild1() coordsArr->alloc(nbOfNodes,3); tmp=coordsArr->getPointer(); std::copy(coords,coords+3*nbOfNodes,tmp); - MEDCoupling::DataArrayDouble *coordsArrCpy=0; + MEDCoupling::DataArrayDouble *coordsArrCpy=nullptr; //! [CppSnippetDataArrayBuild1_5] coordsArrCpy=coordsArr->deepCopy(); //! [CppSnippetDataArrayBuild1_5] @@ -2508,7 +2521,7 @@ void CppSnippetFieldDoubleBuild4() //! [CppSnippetFieldDoubleBuild4_1] } -int main(int argc, char *argv[]) +int main(int /*argc*/, char * /*argv*/[]) { CppExample_MEDCouplingFieldDouble_WriteVTK(); CppExample_MEDCouplingFieldDouble_MaxFields(); diff --git a/src/MEDCoupling/Test/MEDCouplingRemapperTest.cxx b/src/MEDCoupling/Test/MEDCouplingRemapperTest.cxx index c487fbe1c..a15be6f09 100644 --- a/src/MEDCoupling/Test/MEDCouplingRemapperTest.cxx +++ b/src/MEDCoupling/Test/MEDCouplingRemapperTest.cxx @@ -19,6 +19,10 @@ // Author : Anthony Geay (CEA/DEN) #include "MEDCouplingRemapperTest.hxx" +#include "InterpolationOptions.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include "MEDCouplingNatureOfFieldEnum" +#include "MCType.hxx" #include "MEDCouplingUMesh.hxx" #include "MEDCouplingMappedExtrudedMesh.hxx" #include "MEDCouplingFieldDouble.hxx" @@ -27,9 +31,14 @@ #include "MEDCouplingRemapper.hxx" #include "MEDCouplingBasicsTest.hxx" +#include "NormalizedGeometricTypes" +#include #include +#include +#include #include +#include using namespace MEDCoupling; @@ -893,12 +902,12 @@ void MEDCouplingRemapperTest::testNatureOfField() void MEDCouplingRemapperTest::testExtruded() { - MEDCouplingUMesh *mesh2DS=0; + MEDCouplingUMesh *mesh2DS=nullptr; MEDCouplingUMesh *mesh3DS=build3DExtrudedUMesh_1(mesh2DS); MEDCouplingMappedExtrudedMesh *extS=MEDCouplingMappedExtrudedMesh::New(mesh3DS,mesh2DS,1); mesh3DS->decrRef(); mesh2DS->decrRef(); - MEDCouplingUMesh *mesh2DT=0; + MEDCouplingUMesh *mesh2DT=nullptr; MEDCouplingUMesh *mesh3DT=build3DExtrudedUMesh_1(mesh2DT); MEDCouplingMappedExtrudedMesh *extT=MEDCouplingMappedExtrudedMesh::New(mesh3DT,mesh2DT,1); // @@ -915,10 +924,10 @@ void MEDCouplingRemapperTest::testExtruded2() MEDCouplingUMesh *meshN,*meshTT,*meshTF; MEDCouplingBasicsTest::build3DExtrudedUMesh_2(meshN,meshTT,meshTF); std::vector n; - double pt[3]={300.,300.,0.}; - double v[3]={0.,0.,2.}; + double const pt[3]={300.,300.,0.}; + double const v[3]={0.,0.,2.}; meshN->findNodesOnPlane(pt,v,1e-12,n); - MEDCouplingUMesh *meshN2D=(MEDCouplingUMesh *)meshN->buildFacePartOfMySelfNode(&n[0],&n[0]+n.size(),true); + auto *meshN2D=(MEDCouplingUMesh *)meshN->buildFacePartOfMySelfNode(&n[0],&n[0]+n.size(),true); n.clear(); bool b=false; mcIdType newNbOfNodes; @@ -926,10 +935,10 @@ void MEDCouplingRemapperTest::testExtruded2() CPPUNIT_ASSERT(b); da->decrRef(); meshTT->findNodesOnPlane(pt,v,1e-12,n); - MEDCouplingUMesh *meshTT2D=(MEDCouplingUMesh *)meshTT->buildFacePartOfMySelfNode(&n[0],&n[0]+n.size(),true); + auto *meshTT2D=(MEDCouplingUMesh *)meshTT->buildFacePartOfMySelfNode(&n[0],&n[0]+n.size(),true); n.clear(); meshTF->findNodesOnPlane(pt,v,1e-12,n); - MEDCouplingUMesh *meshTF2D=(MEDCouplingUMesh *)meshTF->buildFacePartOfMySelfNode(&n[0],&n[0]+n.size(),true); + auto *meshTF2D=(MEDCouplingUMesh *)meshTF->buildFacePartOfMySelfNode(&n[0],&n[0]+n.size(),true); n.clear(); // MEDCouplingMappedExtrudedMesh *meshNE=MEDCouplingMappedExtrudedMesh::New(meshN,meshN2D,0); @@ -1019,7 +1028,7 @@ void MEDCouplingRemapperTest::testExtruded2() std::copy(vals2,vals2+meshTTE->getNumberOfCells(),array->getPointer()); array->decrRef(); srcField=remapper.reverseTransferField(trgField,4.220173); - double expected3[40]={ + double const expected3[40]={ 550.,550.,551.,552.,553.,550.,550.,554.,555.,556.,550.,550.,554.,555.,556.,550.,550.,557.,558.,559., 1550.,1550.,1551.,1552.,1553.,1550.,1550.,1554.,1555.,1556.,1550.,1550.,1554.,1555.,1556.,1550.,1550.,1557.,1558.,1559. }; @@ -1061,7 +1070,7 @@ void MEDCouplingRemapperTest::testExtruded2() std::copy(vals3,vals3+meshTFE->getNumberOfCells(),array->getPointer()); array->decrRef(); srcField=remapper.reverseTransferField(trgField,4.220173); - double expected4[40]={ + double const expected4[40]={ 566.,566.,552.5,553.5,554.5,566.,566.,554.5,555.5,556.5,566.,566.,558.5,559.5,560.5,566.,566.,560.5,561.5,562.5, 1566.,1566.,1552.5,1553.5,1554.5,1566.,1566.,1554.5,1555.5,1556.5,1566.,1566.,1558.5,1559.5,1560.5,1566.,1566.,1560.5,1561.5,1562.5 }; diff --git a/src/MEDCoupling/Test/MEDCouplingRemapperTest.hxx b/src/MEDCoupling/Test/MEDCouplingRemapperTest.hxx index 2a13de667..17e99845b 100644 --- a/src/MEDCoupling/Test/MEDCouplingRemapperTest.hxx +++ b/src/MEDCoupling/Test/MEDCouplingRemapperTest.hxx @@ -21,10 +21,9 @@ #ifndef __MEDCOUPLINGREMAPPERTEST_HXX__ #define __MEDCOUPLINGREMAPPERTEST_HXX__ +#include #include -#include -#include namespace MEDCoupling { diff --git a/src/MEDCoupling/Test/TestMEDCoupling.cxx b/src/MEDCoupling/Test/TestMEDCoupling.cxx index 126b7bbd6..9a72bbbf4 100644 --- a/src/MEDCoupling/Test/TestMEDCoupling.cxx +++ b/src/MEDCoupling/Test/TestMEDCoupling.cxx @@ -24,6 +24,7 @@ #include "MEDCouplingBasicsTest4.hxx" #include "MEDCouplingBasicsTest5.hxx" #include "MEDCouplingBasicsTestInterp.hxx" +#include CPPUNIT_TEST_SUITE_REGISTRATION( MEDCoupling::MEDCouplingBasicsTest1 ); CPPUNIT_TEST_SUITE_REGISTRATION( MEDCoupling::MEDCouplingBasicsTest2 ); diff --git a/src/MEDCoupling/Test/TestMEDCouplingRemapper.cxx b/src/MEDCoupling/Test/TestMEDCouplingRemapper.cxx index bb85125c3..c8154bca8 100644 --- a/src/MEDCoupling/Test/TestMEDCouplingRemapper.cxx +++ b/src/MEDCoupling/Test/TestMEDCouplingRemapper.cxx @@ -19,6 +19,7 @@ // Author : Anthony Geay (CEA/DEN) #include "MEDCouplingRemapperTest.hxx" +#include CPPUNIT_TEST_SUITE_REGISTRATION( MEDCoupling::MEDCouplingRemapperTest ); diff --git a/src/MEDCoupling_Swig/MEDCouplingCommon.i b/src/MEDCoupling_Swig/MEDCouplingCommon.i index 7343254f6..1a9534a58 100644 --- a/src/MEDCoupling_Swig/MEDCouplingCommon.i +++ b/src/MEDCoupling_Swig/MEDCouplingCommon.i @@ -57,6 +57,7 @@ #include "InterpKernelAutoPtr.hxx" #include "BoxSplittingOptions.hxx" +#include "MEDCouplingNatureOfField.hxx" using namespace MEDCoupling; using namespace INTERP_KERNEL; diff --git a/src/MEDCoupling_Swig/MEDCouplingDataArrayTraits.hxx b/src/MEDCoupling_Swig/MEDCouplingDataArrayTraits.hxx index 0644fd71a..2a9179639 100644 --- a/src/MEDCoupling_Swig/MEDCouplingDataArrayTraits.hxx +++ b/src/MEDCoupling_Swig/MEDCouplingDataArrayTraits.hxx @@ -21,7 +21,8 @@ #ifndef __MEDCOUPLINGDATAARRAYTRAITS_HXX__ #define __MEDCOUPLINGDATAARRAYTRAITS_HXX__ -#include "MEDCouplingMemArray.hxx" +#include "MCType.hxx" +#include "MEDCouplingMemArray.txx" #include @@ -70,11 +71,11 @@ struct PyCallBackDataArraySt { MCData *_pt_mc; }; -typedef struct PyCallBackDataArraySt PyCallBackDataArrayChar; -typedef struct PyCallBackDataArraySt PyCallBackDataArrayInt32; -typedef struct PyCallBackDataArraySt PyCallBackDataArrayInt64; -typedef struct PyCallBackDataArraySt PyCallBackDataArrayFloat; -typedef struct PyCallBackDataArraySt PyCallBackDataArrayDouble; +using PyCallBackDataArrayChar = struct PyCallBackDataArraySt; +using PyCallBackDataArrayInt32 = struct PyCallBackDataArraySt; +using PyCallBackDataArrayInt64 = struct PyCallBackDataArraySt; +using PyCallBackDataArrayFloat = struct PyCallBackDataArraySt; +using PyCallBackDataArrayDouble = struct PyCallBackDataArraySt; extern "C" { @@ -82,31 +83,31 @@ extern "C" static PyObject *callbackmcdataarraychar___new__(PyTypeObject *type, PyObject *args, PyObject *kwargs) { - PyCallBackDataArrayChar *self = (PyCallBackDataArrayChar *) ( type->tp_alloc(type, 0) ); + auto *self = (PyCallBackDataArrayChar *) ( type->tp_alloc(type, 0) ); return (PyObject *)self; } static PyObject *callbackmcdataarrayint32___new__(PyTypeObject *type, PyObject *args, PyObject *kwargs) { - PyCallBackDataArrayInt32 *self = (PyCallBackDataArrayInt32 *) ( type->tp_alloc(type, 0) ); + auto *self = (PyCallBackDataArrayInt32 *) ( type->tp_alloc(type, 0) ); return (PyObject *)self; } static PyObject *callbackmcdataarrayint64___new__(PyTypeObject *type, PyObject *args, PyObject *kwargs) { - PyCallBackDataArrayInt64 *self = (PyCallBackDataArrayInt64 *) ( type->tp_alloc(type, 0) ); + auto *self = (PyCallBackDataArrayInt64 *) ( type->tp_alloc(type, 0) ); return (PyObject *)self; } static PyObject *callbackmcdataarrayfloat___new__(PyTypeObject *type, PyObject *args, PyObject *kwargs) { - PyCallBackDataArrayFloat *self = (PyCallBackDataArrayFloat *) ( type->tp_alloc(type, 0) ); + auto *self = (PyCallBackDataArrayFloat *) ( type->tp_alloc(type, 0) ); return (PyObject *)self; } static PyObject *callbackmcdataarraydouble___new__(PyTypeObject *type, PyObject *args, PyObject *kwargs) { - PyCallBackDataArrayDouble *self = (PyCallBackDataArrayDouble *) ( type->tp_alloc(type, 0) ); + auto *self = (PyCallBackDataArrayDouble *) ( type->tp_alloc(type, 0) ); return (PyObject *)self; } diff --git a/src/MEDLoader/MEDFileBasis.cxx b/src/MEDLoader/MEDFileBasis.cxx index b421a5a07..70dc4e82b 100644 --- a/src/MEDLoader/MEDFileBasis.cxx +++ b/src/MEDLoader/MEDFileBasis.cxx @@ -20,7 +20,9 @@ #include "MEDFileBasis.hxx" +#include #include +#include using namespace MEDCoupling; diff --git a/src/MEDLoader/MEDFileBasis.hxx b/src/MEDLoader/MEDFileBasis.hxx index f92907503..bca01e897 100644 --- a/src/MEDLoader/MEDFileBasis.hxx +++ b/src/MEDLoader/MEDFileBasis.hxx @@ -21,9 +21,10 @@ #ifndef __MEDFILEBASIS_HXX__ #define __MEDFILEBASIS_HXX__ -#include "InterpKernelException.hxx" +#include "MCAuto.hxx" #include "MEDCouplingMemArray.hxx" -#include "MEDCouplingMemArray.txx" +#include "MEDCouplingTraits.hxx" +#include "MEDCouplingRefCountObject.hxx" #include #include diff --git a/src/MEDLoader/MEDFileBlowStrEltUp.cxx b/src/MEDLoader/MEDFileBlowStrEltUp.cxx index 3e87d2004..6faa24af8 100644 --- a/src/MEDLoader/MEDFileBlowStrEltUp.cxx +++ b/src/MEDLoader/MEDFileBlowStrEltUp.cxx @@ -19,11 +19,38 @@ // Author : Anthony Geay (EDF R&D) #include "MEDFileBlowStrEltUp.hxx" +#include "MCAuto.hxx" +#include "MCAuto.txx" +#include "MCType.hxx" +#include "MEDCoupling1GTUMesh.hxx" +#include "MCIdType.hxx" +#include "InterpKernelAutoPtr.hxx" #include "MEDCouplingFieldDouble.hxx" +#include "MEDFileField.hxx" +#include "MEDCouplingMemArray.hxx" +#include "MEDCouplingUMesh.hxx" +#include "MEDFileFieldMultiTS.hxx" +#include "MEDFileField1TS.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include "MEDFileFieldGlobs.hxx" +#include "MEDFileFieldInternal.hxx" #include "MEDFileFieldVisitor.hxx" #include "MEDCouplingPartDefinition.hxx" -#include "MCAuto.txx" +#include "MEDFileMesh.hxx" +#include "MEDFileStructureElement.hxx" +#include +#include +#include "MEDFileMeshLL.hxx" +#include "MEDFileMeshElt.hxx" +#include "NormalizedGeometricTypes" +#include +#include +#include #include +#include +#include +#include +#include using namespace MEDCoupling; @@ -36,12 +63,12 @@ MEDFileBlowStrEltUp::MEDFileBlowStrEltUp(const MEDFileFields *fsOnlyOnSE, const _ms.takeRef(ms); _ses.takeRef(ses); std::vector< std::pair > ps; fsOnlyOnSE->getMeshSENames(ps); - std::size_t sz(ps.size()); + std::size_t const sz(ps.size()); _elts.resize(sz); for(std::size_t i=0;i& p(ps[i]); - MCAuto f(fsOnlyOnSE->partOfThisLyingOnSpecifiedMeshSEName(p.first,p.second)); + MCAuto const f(fsOnlyOnSE->partOfThisLyingOnSpecifiedMeshSEName(p.first,p.second)); _elts[i]=f; } for(std::size_t i=0;igetMeshWithName(p.first)); if(!mesh) throw INTERP_KERNEL::Exception("MEDFileBlowStrEltUp : NULL mesh !"); - MEDFileUMesh *umesh(dynamic_cast(mesh)); + auto *umesh(dynamic_cast(mesh)); if(!umesh) throw INTERP_KERNEL::Exception("MEDFileBlowStrEltUp : Blow up of Stru Elt not managed yet for unstructured meshes !"); } @@ -67,7 +94,7 @@ MCAuto MEDFileBlowStrEltUp::dealWithSEInMesh(const std::s throw INTERP_KERNEL::Exception("MEDFileBlowStrEltUp::dealWithSEInMesh : null pointer !"); if(seName==MED_BALL_STR) { - MCAuto ret(dealWithMEDBALLInMesh(mesh,mOut,fsOut)); + MCAuto const ret(dealWithMEDBALLInMesh(mesh,mOut,fsOut)); mesh->killStructureElements(); return ret; } @@ -79,11 +106,11 @@ MCAuto MEDFileBlowStrEltUp::dealWithMEDBALLInMesh(const M mOut=MEDFileUMesh::New(); fsOut=MEDFileFields::New(); const std::vector< MCAuto >& strs(mesh->getAccessOfUndergroundEltStrs()); MCAuto zeStr; - for(std::vector< MCAuto >::const_iterator it=strs.begin();it!=strs.end();it++) + for(const auto & str : strs) { - if((*it)->getGeoTypeName()==MED_BALL_STR) + if(str->getGeoTypeName()==MED_BALL_STR) { - zeStr=*it; + zeStr=str; break; } } @@ -126,13 +153,13 @@ MCAuto MEDFileBlowStrEltUp::dealWithMEDBALLInMesh(const M mOut->setRenumFieldArr(0,const_cast(nf0)); mOut->copyFamGrpMapsFrom(*mesh); const std::vector< MCAuto >& vars(zeStr->getVars()); - for(std::vector< MCAuto >::const_iterator it=vars.begin();it!=vars.end();it++) + for(const auto & var : vars) { - const DataArray *elt(*it); + const DataArray *elt(var); if(!elt) continue; { - const DataArrayDouble *eltC(dynamic_cast(elt)); + const auto *eltC(dynamic_cast(elt)); if(eltC) { MCAuto fmts(MEDFileFieldMultiTS::New()); @@ -168,9 +195,9 @@ void MEDFileBlowStrEltUp::dealWithSEInFields(const std::string& seName, const ME throw INTERP_KERNEL::Exception("MEDFileBlowStrEltUp::dealWithSEInFields : only MED_BALL is managed for the moment, but if you are interested please send spec to anthony.geay@edf.fr !"); } -void MEDFileBlowStrEltUp::dealWithMEDBALLSInFields(const MEDFileFields *fs, const MEDFileEltStruct4Mesh *zeStr, const MEDFileFields *varAtt, MEDFileFields *zeOutputs) const +void MEDFileBlowStrEltUp::dealWithMEDBALLSInFields(const MEDFileFields *fs, const MEDFileEltStruct4Mesh * /*zeStr*/, const MEDFileFields *varAtt, MEDFileFields *zeOutputs) const { - int nbf(fs->getNumberOfFields()); + int const nbf(fs->getNumberOfFields()); std::vector< MCAuto > elts0; std::vector< MEDFileAnyTypeFieldMultiTS * > elts1; std::string zeMeshName; @@ -178,12 +205,12 @@ void MEDFileBlowStrEltUp::dealWithMEDBALLSInFields(const MEDFileFields *fs, cons { MCAuto elt(fs->getFieldAtPos(i)); MCAuto eltOut(elt->buildNewEmpty()); - int nbTS(elt->getNumberOfTS()); + int const nbTS(elt->getNumberOfTS()); for(int j=0;j eltt(elt->getTimeStepAtPos(j)); MCAuto elttOut(eltt->deepCopy()); - std::string meshName(eltt->getMeshName()); + std::string const meshName(eltt->getMeshName()); zeMeshName=BuildNewMeshName(meshName,MED_BALL_STR); elttOut->setMeshName(zeMeshName); elttOut->convertMedBallIntoClassic(); @@ -203,8 +230,8 @@ void MEDFileBlowStrEltUp::dealWithMEDBALLSInFields(const MEDFileFields *fs, cons std::size_t jj(0); for(std::vector< std::vector >::const_iterator it1=sp2.begin();it1!=sp2.end();it1++,jj++) { - for(std::vector::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++) - zeOutputs->pushField(*it2); + for(auto it2 : *it1) + zeOutputs->pushField(it2); // The most exciting part. Users that put profiles on struct elements part of fields. Reduce var att. if((*it1).size()<1) throw INTERP_KERNEL::Exception("MEDFileBlowStrEltUp::dealWithMEDBALLSInFields : take a deep breath !"); @@ -212,7 +239,7 @@ void MEDFileBlowStrEltUp::dealWithMEDBALLSInFields(const MEDFileFields *fs, cons { if(!(*it1)[0]) throw INTERP_KERNEL::Exception("MEDFileBlowStrEltUp::dealWithMEDBALLSInFields : take a deep breath 2 !"); - int pdm((*it1)[0]->getNumberOfTS()); + int const pdm((*it1)[0]->getNumberOfTS()); if(pdm<1) throw INTERP_KERNEL::Exception("MEDFileBlowStrEltUp::dealWithMEDBALLSInFields : take a deep breath 3 !"); zeGuideForPfl=(*it1)[0]->getTimeStepAtPos(0); @@ -228,12 +255,12 @@ void MEDFileBlowStrEltUp::dealWithMEDBALLSInFields(const MEDFileFields *fs, cons // Yeah we have pfls std::vector t2s; std::vector< std::pair > t1s((*it1)[0]->getTimeSteps(t2s)); - std::size_t nbTS3(t2s.size()); - int nbf2(varAtt->getNumberOfFields()); + std::size_t const nbTS3(t2s.size()); + int const nbf2(varAtt->getNumberOfFields()); for(int i=0;i elt(varAtt->getFieldAtPos(i)); - int nbTS2(elt->getNumberOfTS()); + int const nbTS2(elt->getNumberOfTS()); if(nbTS2!=1) throw INTERP_KERNEL::Exception("MEDFileBlowStrEltUp::dealWithMEDBALLSInFields : internal error ! The dealWithMEDBALLInMesh is expected to return a single TS !"); MCAuto elt2(elt->getTimeStepAtPos(0)); @@ -255,20 +282,20 @@ void MEDFileBlowStrEltUp::dealWithMEDBALLSInFields(const MEDFileFields *fs, cons void MEDFileBlowStrEltUp::generate(MEDFileMeshes *msOut, MEDFileFields *allZeOutFields) { - for(std::vector< MCAuto >::iterator elt=_elts.begin();elt!=_elts.end();elt++) + for(auto & _elt : _elts) { std::vector< std::pair > ps; - (*elt)->getMeshSENames(ps); + _elt->getMeshSENames(ps); if(ps.size()!=1) throw INTERP_KERNEL::Exception("MEDFileBlowStrEltUp::generateMeshes : internal error !"); MEDFileMesh *mesh(_ms->getMeshWithName(ps[0].first)); if(!mesh) throw INTERP_KERNEL::Exception("MEDFileBlowStrEltUp::generateMeshes : NULL mesh !"); - MEDFileUMesh *umesh(dynamic_cast(mesh)); + auto *umesh(dynamic_cast(mesh)); if(!umesh) throw INTERP_KERNEL::Exception("MEDFileBlowStrEltUp::generateMeshes : Blow up of Stru Elt not managed yet for unstructured meshes !"); // - MCAuto classicalSEFields(splitFieldsPerLoc(*elt,umesh,msOut,allZeOutFields)); + MCAuto classicalSEFields(splitFieldsPerLoc(_elt,umesh,msOut,allZeOutFields)); if(classicalSEFields.isNotNull()) { MCAuto mOut; @@ -329,7 +356,7 @@ private: class LocInfo { public: - LocInfo() { } + LocInfo() = default; LocInfo(const std::vector& fw); bool operator==(const LocInfo& other) const { return _locs==other._locs && _pfl==other._pfl; } void push(const std::string& loc, const std::string& pfl) { checkUniqueLoc(loc); _locs.push_back(loc); _pfl.push_back(pfl); } @@ -365,7 +392,7 @@ const char LocInfo::EPAISSEUR[]="EPAISSEUR"; LocInfo::LocInfo(const std::vector& fw) { - std::size_t sz(fw.size()); + std::size_t const sz(fw.size()); _locs.resize(sz); _pfl.resize(sz); _cts.resize(sz); if(sz>0) _pd=fw[0].getPartDef()->deepCopy(); @@ -388,7 +415,7 @@ void LocInfo::checkUniqueLoc(const std::string& loc) const } } -MCAuto LocInfo::BuildMeshCommon(INTERP_KERNEL::NormalizedCellType gt, const std::string& pfl, const MEDFileFieldLoc& loc, const MEDFileEltStruct4Mesh *zeStr, const MEDFileUMesh *mesh, const MEDFileUMesh *section, const MEDFileFieldGlobsReal *globs, MCAuto& ptsForLoc) +MCAuto LocInfo::BuildMeshCommon(INTERP_KERNEL::NormalizedCellType gt, const std::string& pfl, const MEDFileFieldLoc& loc, const MEDFileEltStruct4Mesh *zeStr, const MEDFileUMesh *mesh, const MEDFileUMesh * /*section*/, const MEDFileFieldGlobsReal *globs, MCAuto& ptsForLoc) { MCAuto conn(zeStr->getConn()); conn=conn->deepCopy(); conn->rearrange(1); @@ -430,12 +457,12 @@ MCAuto LocInfo::BuildMeshFromAngleVrille(INTERP_KERNEL::Normali // MCAuto dir(geoMesh->buildDirectionVectorField()); MCAuto rot(dir->getArray()->fromCartToSpher()); - std::size_t nbCompo(ptsForLoc->getNumberOfComponents()); + std::size_t const nbCompo(ptsForLoc->getNumberOfComponents()); MCAuto secPts(section->getCoords()->changeNbOfComponents(nbCompo,0.)); mcIdType nbSecPts(secPts->getNumberOfTuples()),nbCells(geoMesh->getNumberOfCells()),nbg(ToIdType(loc.getGaussWeights().size())); { const int TAB[3]={2,0,1}; - std::vector v(TAB,TAB+3); + std::vector const v(TAB,TAB+3); secPts=secPts->keepSelectedComponents(v); } const double CENTER[3]={0.,0.,0.},AX0[3]={0.,0.,1.}; @@ -444,10 +471,10 @@ MCAuto LocInfo::BuildMeshFromAngleVrille(INTERP_KERNEL::Normali for(int j=0;j p(secPts->deepCopy()); - double ang0(rot->getIJ(j,2)); + double const ang0(rot->getIJ(j,2)); DataArrayDouble::Rotate3DAlg(CENTER,AX0,ang0,nbSecPts,p->begin(),p->getPointer()); AX1[0]=-sin(ang0); AX1[1]=cos(ang0);// rot Oy around OZ - double ang1(M_PI/2.-rot->getIJ(j,1)); + double const ang1(M_PI/2.-rot->getIJ(j,1)); DataArrayDouble::Rotate3DAlg(CENTER,AX1,-ang1,nbSecPts,p->begin(),p->getPointer()); DataArrayDouble::Rotate3DAlg(CENTER,dir->getArray()->begin()+j*3,angleVrille->getIJ(j,0),nbSecPts,p->begin(),p->getPointer()); for(int l=0;l LocInfo::BuildMeshFromAngleVrille(INTERP_KERNEL::Normali } } std::vector arrs2(VecAutoToVecOfCstPt(arrs)); - MCAuto resu(DataArrayDouble::Aggregate(arrs2)); + MCAuto const resu(DataArrayDouble::Aggregate(arrs2)); return resu; } @@ -481,7 +508,7 @@ MCAuto LocInfo::BuildMeshFromEpaisseur(INTERP_KERNEL::Normalize MCAuto ortho(geoMesh->buildOrthogonalField()); orthoArr.takeRef(ortho->getArray()); } - mcIdType nbCompo(ToIdType(orthoArr->getNumberOfComponents())); + mcIdType const nbCompo(ToIdType(orthoArr->getNumberOfComponents())); MCAuto secPts(section->getCoords()->duplicateEachTupleNTimes(nbCompo)); secPts->rearrange(nbCompo); std::vector< MCAuto > arrs(nbCells*nbg); @@ -504,7 +531,7 @@ MCAuto LocInfo::BuildMeshFromEpaisseur(INTERP_KERNEL::Normalize } } std::vector arrs2(VecAutoToVecOfCstPt(arrs)); - MCAuto resu(DataArrayDouble::Aggregate(arrs2)); + MCAuto const resu(DataArrayDouble::Aggregate(arrs2)); return resu; } @@ -535,11 +562,11 @@ MCAuto LocInfo::BuildMeshPipeSEG3(const DataArrayDouble *angle, dir=geoMesh2->buildDirectionVectorField(); } MCAuto rot(dir->getArray()->fromCartToSpher()); - std::size_t nbCompo(ptsForLoc->getNumberOfComponents()); + std::size_t const nbCompo(ptsForLoc->getNumberOfComponents()); MCAuto secPts(section->getCoords()->changeNbOfComponents(nbCompo,0.)); { const int TAB[3]={2,0,1}; - std::vector v(TAB,TAB+3); + std::vector const v(TAB,TAB+3); secPts=secPts->keepSelectedComponents(v); } const double CENTER[3]={0.,0.,0.},AX0[3]={0.,0.,1.}; @@ -549,7 +576,7 @@ MCAuto LocInfo::BuildMeshPipeSEG3(const DataArrayDouble *angle, { constexpr int DIM=3; MCAuto p(secPts->deepCopy()); - double ang0(rot->getIJ(j,2)); + double const ang0(rot->getIJ(j,2)); double rmin(zeScale->getIJ(j,0)),rmax(zeScale->getIJ(j,1)); { auto pt(p->rwBegin()); @@ -563,7 +590,7 @@ MCAuto LocInfo::BuildMeshPipeSEG3(const DataArrayDouble *angle, } DataArrayDouble::Rotate3DAlg(CENTER,AX0,ang0,nbSecPts,p->begin(),p->getPointer()); AX1[0]=-sin(ang0); AX1[1]=cos(ang0);// rot Oy around OZ - double ang1(M_PI/2.-rot->getIJ(j,1)); + double const ang1(M_PI/2.-rot->getIJ(j,1)); DataArrayDouble::Rotate3DAlg(CENTER,AX1,-ang1,nbSecPts,p->begin(),p->getPointer()); for(int l=0;l<3;l++) { @@ -576,7 +603,7 @@ MCAuto LocInfo::BuildMeshPipeSEG3(const DataArrayDouble *angle, } } std::vector arrs2(VecAutoToVecOfCstPt(arrs)); - MCAuto resu(DataArrayDouble::Aggregate(arrs2)); + MCAuto const resu(DataArrayDouble::Aggregate(arrs2)); return resu; } @@ -607,11 +634,11 @@ MCAuto LocInfo::BuildMeshPipeSEG4(const DataArrayDouble *angle, dir=geoMesh2->buildDirectionVectorField(); } MCAuto rot(dir->getArray()->fromCartToSpher()); - std::size_t nbCompo(ptsForLoc->getNumberOfComponents()); + std::size_t const nbCompo(ptsForLoc->getNumberOfComponents()); MCAuto secPts(section->getCoords()->changeNbOfComponents(nbCompo,0.)); { const int TAB[3]={2,0,1}; - std::vector v(TAB,TAB+3); + std::vector const v(TAB,TAB+3); secPts=secPts->keepSelectedComponents(v); } const double CENTER[3]={0.,0.,0.},AX0[3]={0.,0.,1.}; @@ -621,7 +648,7 @@ MCAuto LocInfo::BuildMeshPipeSEG4(const DataArrayDouble *angle, { constexpr int DIM=3; MCAuto p(secPts->deepCopy()); - double ang0(rot->getIJ(j,2)); + double const ang0(rot->getIJ(j,2)); double rmin(zeScale->getIJ(j,0)),rmax(zeScale->getIJ(j,1)); { auto pt(p->rwBegin()); @@ -635,7 +662,7 @@ MCAuto LocInfo::BuildMeshPipeSEG4(const DataArrayDouble *angle, } DataArrayDouble::Rotate3DAlg(CENTER,AX0,ang0,nbSecPts,p->begin(),p->getPointer()); AX1[0]=-sin(ang0); AX1[1]=cos(ang0);// rot Oy around OZ - double ang1(M_PI/2.-rot->getIJ(j,1)); + double const ang1(M_PI/2.-rot->getIJ(j,1)); DataArrayDouble::Rotate3DAlg(CENTER,AX1,-ang1,nbSecPts,p->begin(),p->getPointer()); for(int l=0;l<3;l++) { @@ -648,7 +675,7 @@ MCAuto LocInfo::BuildMeshPipeSEG4(const DataArrayDouble *angle, } } std::vector arrs2(VecAutoToVecOfCstPt(arrs)); - MCAuto resu(DataArrayDouble::Aggregate(arrs2)); + MCAuto const resu(DataArrayDouble::Aggregate(arrs2)); return resu; } @@ -712,13 +739,13 @@ MCAuto LocInfo::generateNonClassicalData(int zePos, const MEDFileU { const MEDFileFieldLoc& loc(globs->getLocalization(_locs[i])); const MEDFileGTKeeper *gtk(loc.getUndergroundGTKeeper()); - const MEDFileGTKeeperDyn *gtk2(dynamic_cast(gtk)); + const auto *gtk2(dynamic_cast(gtk)); if(!gtk2) throw INTERP_KERNEL::Exception("LocInfo::generateNonClassicalData : internal error !"); const MEDFileUMesh *meshLoc(gtk2->getMesh()),*section(gtk2->getSection()); const MEDFileStructureElement *se(gtk2->getSE()); MCAuto um(meshLoc->getMeshAtLevel(0)); - INTERP_KERNEL::NormalizedCellType gt(_cts[i]); + INTERP_KERNEL::NormalizedCellType const gt(_cts[i]); { std::vector nel(meshLoc->getNonEmptyLevels()); if(nel.size()!=1) @@ -733,18 +760,18 @@ MCAuto LocInfo::generateNonClassicalData(int zePos, const MEDFileU throw INTERP_KERNEL::Exception(MSG1); std::vector v; um->getNodeIdsOfCell(zePos,v); - std::size_t sz2(v.size()); + std::size_t const sz2(v.size()); for(std::size_t j=0;j >& strs(mesh->getAccessOfUndergroundEltStrs()); MCAuto zeStr; - for(std::vector< MCAuto >::const_iterator it=strs.begin();it!=strs.end();it++) + for(const auto & str : strs) { - if((*it)->getGeoTypeName()==se->getName()) + if(str->getGeoTypeName()==se->getName()) { - zeStr=*it; + zeStr=str; break; } } @@ -785,14 +812,14 @@ bool FieldWalker2::operator==(const FieldWalker2& other) const std::string tmp; ret2=_pd->isEqual(other._pd,tmp); } - bool ret(_loc==other._loc && _pfl==other._pfl && _is_classic==other._is_classic && ret2); + bool const ret(_loc==other._loc && _pfl==other._pfl && _is_classic==other._is_classic && ret2); return ret; } class FieldWalker1 { public: - FieldWalker1(const MEDFileAnyTypeField1TSWithoutSDA *ts):_ts(ts),_pm_pt(0),_nb_mesh(0) { } + FieldWalker1(const MEDFileAnyTypeField1TSWithoutSDA *ts):_ts(ts) { } void newMeshEntry(const MEDFileFieldPerMesh *fpm); void endMeshEntry(const MEDFileFieldPerMesh *fpm) { } void newPerMeshPerTypeEntry(const MEDFileFieldPerMeshPerTypeCommon *pmpt); @@ -803,12 +830,12 @@ public: std::vector getNonClassicalData() const { return _fw; } private: const MEDFileAnyTypeField1TSWithoutSDA *_ts; - const MEDFileFieldPerMeshPerTypeDyn *_pm_pt; + const MEDFileFieldPerMeshPerTypeDyn *_pm_pt{nullptr}; std::vector _fw; - int _nb_mesh; + int _nb_mesh{0}; }; -void FieldWalker1::newMeshEntry(const MEDFileFieldPerMesh *fpm) +void FieldWalker1::newMeshEntry(const MEDFileFieldPerMesh * /*fpm*/) { if(_nb_mesh++==1) throw INTERP_KERNEL::Exception("FieldWalker1::newMeshEntry : multi mesh not supported !"); @@ -818,7 +845,7 @@ void FieldWalker1::newPerMeshPerTypeEntry(const MEDFileFieldPerMeshPerTypeCommon { if(_pm_pt) throw INTERP_KERNEL::Exception("FieldWalker1::newPerMeshPerTypeEntry : multi SE loc not managed yet !"); - const MEDFileFieldPerMeshPerTypeDyn *pmpt2(dynamic_cast(pmpt)); + const auto *pmpt2(dynamic_cast(pmpt)); if(!pmpt2) throw INTERP_KERNEL::Exception("newPerMeshPerTypeEntry : internal error !"); _pm_pt=pmpt2; @@ -836,7 +863,7 @@ void FieldWalker1::newPerMeshPerTypePerDisc(const MEDFileFieldPerMeshPerTypePerD void FieldWalker1::checkOK(const FieldWalker1& other) const { - std::size_t sz(_fw.size()); + std::size_t const sz(_fw.size()); if(other._fw.size()!=sz) throw INTERP_KERNEL::Exception("checkOK : not OK because size are not the same !"); for(std::size_t i=0;i::const_iterator it=_fw.begin();it!=_fw.end();it++) + for(const auto & it : _fw) { - if((*it).isClassic()) + if(it.isClassic()) ic++; else inc++; @@ -898,13 +925,13 @@ void FieldWalker::newTimeStepEntry(const MEDFileAnyTypeField1TSWithoutSDA *ts) _fw=new FieldWalker1(ts); } -void FieldWalker::endTimeStepEntry(const MEDFileAnyTypeField1TSWithoutSDA *ts) +void FieldWalker::endTimeStepEntry(const MEDFileAnyTypeField1TSWithoutSDA * /*ts*/) { if(_fw_prev.isNull()) _fw_prev=new FieldWalker1(*_fw); else _fw_prev->checkOK(*_fw); - _fw=0; + _fw=nullptr; } void FieldWalker::newMeshEntry(const MEDFileFieldPerMesh *fpm) @@ -936,23 +963,23 @@ void FieldWalker::newPerMeshPerTypePerDisc(const MEDFileFieldPerMeshPerTypePerDi class LocSpliter : public MEDFileFieldVisitor { public: - LocSpliter(const MEDFileFieldGlobsReal *globs):_globs(globs),_fw(0) { } + LocSpliter(const MEDFileFieldGlobsReal *globs):_globs(globs),_fw(nullptr) { } MCAuto getClassical() const { return _classical; } void generateNonClassicalData(const MEDFileUMesh *mesh, std::vector< MCAuto >& outFields, std::vector< MCAuto >& outMeshes) const; private: - void newFieldEntry(const MEDFileAnyTypeFieldMultiTSWithoutSDA *field); - void endFieldEntry(const MEDFileAnyTypeFieldMultiTSWithoutSDA *field); + void newFieldEntry(const MEDFileAnyTypeFieldMultiTSWithoutSDA *field) override; + void endFieldEntry(const MEDFileAnyTypeFieldMultiTSWithoutSDA *field) override; // - void newTimeStepEntry(const MEDFileAnyTypeField1TSWithoutSDA *ts); - void endTimeStepEntry(const MEDFileAnyTypeField1TSWithoutSDA *ts); + void newTimeStepEntry(const MEDFileAnyTypeField1TSWithoutSDA *ts) override; + void endTimeStepEntry(const MEDFileAnyTypeField1TSWithoutSDA *ts) override; // - void newMeshEntry(const MEDFileFieldPerMesh *fpm); - void endMeshEntry(const MEDFileFieldPerMesh *fpm); + void newMeshEntry(const MEDFileFieldPerMesh *fpm) override; + void endMeshEntry(const MEDFileFieldPerMesh *fpm) override; // - void newPerMeshPerTypeEntry(const MEDFileFieldPerMeshPerTypeCommon *pmpt); - void endPerMeshPerTypeEntry(const MEDFileFieldPerMeshPerTypeCommon *pmpt); + void newPerMeshPerTypeEntry(const MEDFileFieldPerMeshPerTypeCommon *pmpt) override; + void endPerMeshPerTypeEntry(const MEDFileFieldPerMeshPerTypeCommon *pmpt) override; // - void newPerMeshPerTypePerDisc(const MEDFileFieldPerMeshPerTypePerDisc *pmptpd); + void newPerMeshPerTypePerDisc(const MEDFileFieldPerMeshPerTypePerDisc *pmptpd) override; private: const MEDFileFieldGlobsReal *_globs; std::vector< LocInfo > _locs; @@ -983,9 +1010,9 @@ void LocSpliter::endFieldEntry(const MEDFileAnyTypeFieldMultiTSWithoutSDA *field } else { - std::vector fw2(_fw->getNonClassicalData()); - LocInfo elt(fw2); - std::vector< LocInfo >::iterator it(std::find(_locs.begin(),_locs.end(),elt)); + std::vector const fw2(_fw->getNonClassicalData()); + LocInfo const elt(fw2); + auto const it(std::find(_locs.begin(),_locs.end(),elt)); if(it==_locs.end()) { _locs.push_back(elt); @@ -1005,7 +1032,7 @@ void LocSpliter::endFieldEntry(const MEDFileAnyTypeFieldMultiTSWithoutSDA *field void LocSpliter::generateNonClassicalData(const MEDFileUMesh *mesh, std::vector< MCAuto >& outFields, std::vector< MCAuto >& outMeshes) const { int i(0); - for(std::vector::const_iterator it=_locs.begin();it!=_locs.end();it++,i++) + for(auto it=_locs.begin();it!=_locs.end();it++,i++) { MCAuto m((*it).generateNonClassicalData(i,mesh,_globs)); outMeshes.push_back(m); @@ -1023,7 +1050,7 @@ void LocSpliter::generateNonClassicalData(const MEDFileUMesh *mesh, std::vector< MCAuto outF1t(MEDFileField1TS::New()); MCAuto f1ts(fmts->getTimeStepAtPos(k)); int t2,t3; - double t1(f1ts->getTime(t2,t3)); + double const t1(f1ts->getTime(t2,t3)); MCAuto mcf(MEDCouplingFieldDouble::New(ON_NODES)); MCAuto arr,arr2; arr.takeRef(f1ts->getUndergroundDataArray()); @@ -1100,16 +1127,16 @@ MCAuto MEDFileBlowStrEltUp::splitFieldsPerLoc(const MEDFileFields std::vector< MCAuto > outFields; std::vector< MCAuto > outMeshes; ls.generateNonClassicalData(mesh,outFields,outMeshes); - for(std::vector< MCAuto >::iterator it=outFields.begin();it!=outFields.end();it++) + for(auto & outField : outFields) { - for(int j=0;j<(*it)->getNumberOfFields();j++) + for(int j=0;jgetNumberOfFields();j++) { - MCAuto fmts((*it)->getFieldAtPos(j)); + MCAuto fmts(outField->getFieldAtPos(j)); //DealWithConflictNames(fmts,allZeOutFields);// uncomment to have a writable data structure allZeOutFields->pushField(fmts); } } - for(std::vector< MCAuto >::iterator it=outMeshes.begin();it!=outMeshes.end();it++) - msOut->pushMesh(*it); + for(auto & outMeshe : outMeshes) + msOut->pushMesh(outMeshe); return ls.getClassical(); } diff --git a/src/MEDLoader/MEDFileBlowStrEltUp.hxx b/src/MEDLoader/MEDFileBlowStrEltUp.hxx index 1043d56d9..4e7a262e1 100644 --- a/src/MEDLoader/MEDFileBlowStrEltUp.hxx +++ b/src/MEDLoader/MEDFileBlowStrEltUp.hxx @@ -21,13 +21,16 @@ #ifndef __MEDFILEBLOWSTRELTUP_HXX__ #define __MEDFILEBLOWSTRELTUP_HXX__ -#include "MEDLoaderDefines.hxx" -#include "MEDFileUtilities.txx" +#include "MCAuto.hxx" +#include "MEDFileMeshLL.hxx" +#include "MEDFileFieldMultiTS.hxx" #include "MEDFileMesh.hxx" #include "MEDFileField.hxx" #include "MEDFileStructureElement.hxx" -#include "MEDCouplingRefCountObject.hxx" +#include +#include +#include namespace MEDCoupling { diff --git a/src/MEDLoader/MEDFileData.cxx b/src/MEDLoader/MEDFileData.cxx index 87a09baa5..bc9b90caa 100644 --- a/src/MEDLoader/MEDFileData.cxx +++ b/src/MEDLoader/MEDFileData.cxx @@ -19,17 +19,36 @@ // Author : Anthony Geay (CEA/DEN) #include "MEDFileData.hxx" +#include "MEDFileUtilities.hxx" +#include "MCAuto.hxx" +#include "MEDFileField.hxx" +#include "MEDFileMesh.hxx" +#include "MEDFileParameter.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include "MEDFileMeshSupport.hxx" +#include "MEDFileStructureElement.hxx" +#include "MCType.hxx" +#include "MEDFileFieldMultiTS.hxx" #include "MEDLoaderBase.hxx" #include "MEDFileSafeCaller.txx" #include "MEDFileBlowStrEltUp.hxx" #include "InterpKernelAutoPtr.hxx" +#include +#include "med.h" +#include +#include +#include +#include +#include +#include +#include "medfile.h" using namespace MEDCoupling; MEDFileData *MEDFileData::New(const std::string& fileName) { - MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + MEDFileUtilities::AutoFid const fid(OpenMEDFileForRead(fileName)); return New(fid); } @@ -184,7 +203,7 @@ bool MEDFileData::changeMeshNames(const std::vector< std::pair > v(1); v[0].first=oldName; v[0].second=newMeshName; return changeMeshNames(v); @@ -212,8 +231,8 @@ bool MEDFileData::unPolyzeMeshes() if(m) { std::vector oldCode,newCode; - DataArrayIdType *o2nRenumCell=0; - bool modif=m->unPolyze(oldCode,newCode,o2nRenumCell); + DataArrayIdType *o2nRenumCell=nullptr; + bool const modif=m->unPolyze(oldCode,newCode,o2nRenumCell); if(!modif) continue; renumParamsOfMeshImpacted.push_back(o2nRenumCell); memSaverIfThrow.push_back(o2nRenumCell); @@ -253,7 +272,7 @@ MCAuto MEDFileData::Aggregate(const std::vector ret(MEDFileData::New()); std::vector ms(sz); std::vector< std::vector< std::pair > > dts(sz); - for(std::vector::const_iterator it=mfds.begin();it!=mfds.end();it++,i++) + for(auto it=mfds.begin();it!=mfds.end();it++,i++) { const MEDFileData *elt(*it); if(!elt) @@ -266,7 +285,7 @@ MCAuto MEDFileData::Aggregate(const std::vectorgetMeshAtPos(0)); if(!mesh) throw INTERP_KERNEL::Exception("MEDFileData::Aggregate : presence of null mesh in a MEDFileData instance among input vector !"); - const MEDFileUMesh *umesh(dynamic_cast(mesh)); + const auto *umesh(dynamic_cast(mesh)); if(!umesh) throw INTERP_KERNEL::Exception("MEDFileData::Aggregate : works only for unstructured meshes !"); ms[i]=umesh; @@ -277,22 +296,22 @@ MCAuto MEDFileData::Aggregate(const std::vectorsetMeshes(mss); // fields std::vector fieldNames(mfds[0]->getFields()->getFieldsNames()); - std::set fieldNamess(fieldNames.begin(),fieldNames.end()); + std::set const fieldNamess(fieldNames.begin(),fieldNames.end()); if(fieldNames.size()!=fieldNamess.size()) throw INTERP_KERNEL::Exception("MEDFileData::Aggregate : field names must be different each other !"); std::vector< std::vector > vectOfFields(fieldNames.size()); std::vector< std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > > vectOfFields2(fieldNames.size()); MCAuto fss(MEDFileFields::New()); - for(std::vector::const_iterator it=mfds.begin();it!=mfds.end();it++) + for(auto mfd : mfds) { - std::vector fieldNames0((*it)->getFields()->getFieldsNames()); - std::set fieldNamess0(fieldNames0.begin(),fieldNames0.end()); + std::vector fieldNames0(mfd->getFields()->getFieldsNames()); + std::set const fieldNamess0(fieldNames0.begin(),fieldNames0.end()); if(fieldNamess!=fieldNamess0) throw INTERP_KERNEL::Exception("MEDFileData::Aggregate : field names must be the same for all input instances !"); i=0; for(std::vector::const_iterator it1=fieldNames.begin();it1!=fieldNames.end();it1++,i++) { - MCAuto fmts((*it)->getFields()->getFieldWithName(*it1)); + MCAuto fmts(mfd->getFields()->getFieldWithName(*it1)); if(fmts.isNull()) throw INTERP_KERNEL::Exception("MEDFileData::Aggregate : internal error 1 !"); vectOfFields2[i].push_back(fmts); vectOfFields[i].push_back(fmts); @@ -310,8 +329,7 @@ MCAuto MEDFileData::Aggregate(const std::vector header(MEDLoaderBase::buildEmptyString(MED_COMMENT_SIZE)); - int ret(MEDfileCommentRd(fid,header)); + int const ret(MEDfileCommentRd(fid,header)); if(ret==0) _header=MEDLoaderBase::buildStringFromFortran(header,MED_COMMENT_SIZE); } diff --git a/src/MEDLoader/MEDFileData.hxx b/src/MEDLoader/MEDFileData.hxx index 200a2b4a6..08f180fed 100644 --- a/src/MEDLoader/MEDFileData.hxx +++ b/src/MEDLoader/MEDFileData.hxx @@ -22,11 +22,20 @@ #define __MEDFILEDATA_HXX__ #include "MCAuto.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include "MEDCouplingMemArray.hxx" #include "MEDFileParameter.hxx" #include "MEDFileField.hxx" #include "MEDFileMesh.hxx" #include "MEDFileMeshSupport.hxx" #include "MEDFileStructureElement.hxx" +#include "MEDFileUtilities.txx" +#include "MEDLoaderDefines.hxx" +#include +#include "med.h" +#include +#include +#include namespace MEDCoupling { @@ -42,8 +51,8 @@ namespace MEDCoupling MEDLOADER_EXPORT static MEDFileData *New(DataArrayByte *db) { return BuildFromMemoryChunk(db); } MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileData"); } MEDLOADER_EXPORT MEDFileData *deepCopy() const; - MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; - MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const; + MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const override; + MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const override; MEDLOADER_EXPORT MEDFileFields *getFields() const; MEDLOADER_EXPORT MEDFileMeshes *getMeshes() const; MEDLOADER_EXPORT MEDFileParameters *getParams() const; @@ -64,7 +73,7 @@ namespace MEDCoupling MEDLOADER_EXPORT void dealWithStructureElements(); MEDLOADER_EXPORT static MCAuto Aggregate(const std::vector& mfds); // - MEDLOADER_EXPORT void writeLL(med_idt fid) const; + MEDLOADER_EXPORT void writeLL(med_idt fid) const override; private: MEDFileData(); MEDFileData(med_idt fid); diff --git a/src/MEDLoader/MEDFileEntities.cxx b/src/MEDLoader/MEDFileEntities.cxx index 97865a24a..8a42e01a9 100644 --- a/src/MEDLoader/MEDFileEntities.cxx +++ b/src/MEDLoader/MEDFileEntities.cxx @@ -19,6 +19,13 @@ // Author : Anthony Geay (EDF R&D) #include "MEDFileEntities.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include "MEDFileStructureElement.hxx" +#include "MEDFileMesh.hxx" +#include "NormalizedGeometricTypes" +#include +#include +#include using namespace MEDCoupling; @@ -39,8 +46,7 @@ MEDFileEntities *MEDFileEntities::BuildFrom(const MEDFileStructureElements& se) } MEDFileEntities::~MEDFileEntities() -{ -} += default; ////////////// diff --git a/src/MEDLoader/MEDFileEntities.hxx b/src/MEDLoader/MEDFileEntities.hxx index b9ac6350f..bc65ea0c5 100644 --- a/src/MEDLoader/MEDFileEntities.hxx +++ b/src/MEDLoader/MEDFileEntities.hxx @@ -21,13 +21,17 @@ #ifndef __MEDFILEENTITIES_HXX__ #define __MEDFILEENTITIES_HXX__ +#include "MCAuto.hxx" +#include "MEDCouplingRefCountObject.hxx" #include "MEDLoaderDefines.hxx" #include "MEDFileStructureElement.hxx" - -#include "MEDCouplingRefCountObject.hxx" #include "NormalizedGeometricTypes" +#include +#include +#include + namespace MEDCoupling { class MEDLOADER_EXPORT MEDFileEntities @@ -46,8 +50,8 @@ namespace MEDCoupling public: MEDFileStaticEntities(const std::vector< std::pair >& entities):_entities(entities) { } const std::vector< std::pair >& getEntries() const { return _entities; } - std::vector getDynGTAvail() const; - bool areAllStaticTypesPresent() const; + std::vector getDynGTAvail() const override; + bool areAllStaticTypesPresent() const override; bool areAllStaticPresentAndNoDyn() const override; private: std::vector< std::pair > _entities; @@ -56,9 +60,9 @@ namespace MEDCoupling class MEDLOADER_EXPORT MEDFileAllStaticEntites : public MEDFileEntities { public: - MEDFileAllStaticEntites() { } - std::vector getDynGTAvail() const; - bool areAllStaticTypesPresent() const; + MEDFileAllStaticEntites() = default; + std::vector getDynGTAvail() const override; + bool areAllStaticTypesPresent() const override; bool areAllStaticPresentAndNoDyn() const override; }; @@ -66,8 +70,8 @@ namespace MEDCoupling { public: MEDFileAllStaticEntitiesPlusDyn(const MEDFileStructureElements *se); - std::vector getDynGTAvail() const; - bool areAllStaticTypesPresent() const; + std::vector getDynGTAvail() const override; + bool areAllStaticTypesPresent() const override; bool areAllStaticPresentAndNoDyn() const override; const MEDFileStructureElement *getWithGT(int idGT) const; const MEDFileUMesh *getSupMeshWithName(const std::string& name) const; diff --git a/src/MEDLoader/MEDFileEquivalence.cxx b/src/MEDLoader/MEDFileEquivalence.cxx index 462e0d812..2a07c1d55 100644 --- a/src/MEDLoader/MEDFileEquivalence.cxx +++ b/src/MEDLoader/MEDFileEquivalence.cxx @@ -19,12 +19,25 @@ // Author : Anthony Geay (EDF R&D) #include "MEDFileEquivalence.hxx" +#include "MCAuto.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include "MEDFileBasis.hxx" +#include "CellModel.hxx" +#include "MCType.hxx" #include "MEDFileSafeCaller.txx" -#include "MEDCouplingMemArray.hxx" -#include "MEDCouplingMemArray.txx" #include "MEDLoaderBase.hxx" #include "MEDFileMesh.hxx" #include "InterpKernelAutoPtr.hxx" +#include "med.h" +#include "NormalizedGeometricTypes" +#include +#include "medequivalence.h" +#include +#include +#include +#include +#include +#include // From MEDLOader.cxx TU extern med_geometry_type typmai[MED_N_CELL_FIXED_GEO]; @@ -45,7 +58,7 @@ MEDFileEquivalencePair *MEDFileEquivalencePair::Load(MEDFileEquivalences *father void MEDFileEquivalencePair::writeLL(med_idt fid) const { - std::string meshName(getFather()->getMeshName()); + std::string const meshName(getFather()->getMeshName()); INTERP_KERNEL::AutoPtr meshName2(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)); INTERP_KERNEL::AutoPtr name(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)); INTERP_KERNEL::AutoPtr desc(MEDLoaderBase::buildEmptyString(MED_COMMENT_SIZE)); @@ -159,7 +172,7 @@ void MEDFileEquivalencePair::setArray(int meshDimRelToMaxExt, DataArrayInt *da) MEDFileEquivalenceNode *node(_node); if(!node) { - _node=new MEDFileEquivalenceNode(this,0); + _node=new MEDFileEquivalenceNode(this,nullptr); node=_node; } node->setArray(da); @@ -190,7 +203,7 @@ MEDFileEquivalenceCell *MEDFileEquivalencePair::initCell() */ MEDFileEquivalenceNode *MEDFileEquivalencePair::initNode() { - _node=new MEDFileEquivalenceNode(this,0); + _node=new MEDFileEquivalenceNode(this,nullptr); return _node; } @@ -201,7 +214,7 @@ std::size_t MEDFileEquivalencePair::getHeapMemorySizeWithoutChildren() const void MEDFileEquivalencePair::load(med_idt fid) { - std::string meshName(_father->getMeshName()); + std::string const meshName(_father->getMeshName()); int dt,it; _father->getDtIt(dt,it); med_int ncor; @@ -213,7 +226,7 @@ void MEDFileEquivalencePair::load(med_idt fid) MEDFILESAFECALLERRD0(MEDequivalenceCorrespondenceRd,(fid,meshName.c_str(),_name.c_str(),dt,it,MED_NODE,MED_NONE,da->getPointer())); da->applyLin(1,-1); da->rearrange(2); - MCAuto node(new MEDFileEquivalenceNode(this,FromMedIntArray(da))); + MCAuto const node(new MEDFileEquivalenceNode(this,FromMedIntArray(da))); _node=node; } _cell=MEDFileEquivalenceCell::Load(fid,this); @@ -221,7 +234,7 @@ void MEDFileEquivalencePair::load(med_idt fid) std::vector MEDFileEquivalences::getDirectChildrenWithNull() const { - std::size_t sz(_equ.size()); + std::size_t const sz(_equ.size()); std::vector ret(sz); for(std::size_t i=0;i elta(elt); + MCAuto const elta(elt); if(elt) elt->incrRef(); _equ.push_back(elta); @@ -253,7 +266,7 @@ void MEDFileEquivalences::pushEquivalence(MEDFileEquivalencePair *elt) MEDFileEquivalencePair *MEDFileEquivalences::getEquivalence(int i) { - int sz(size()); + int const sz(size()); if(i<0 || i>=sz) { std::ostringstream oss; oss << "MEDFileEquivalences::getEquivalence : invalid id ! Must be in [0," << sz << ") !"; @@ -264,9 +277,9 @@ MEDFileEquivalencePair *MEDFileEquivalences::getEquivalence(int i) MEDFileEquivalencePair *MEDFileEquivalences::getEquivalenceWithName(const std::string& name) { - for(std::vector< MCAuto >::iterator it=_equ.begin();it!=_equ.end();it++) + for(auto & it : _equ) { - MEDFileEquivalencePair *elt(*it); + MEDFileEquivalencePair *elt(it); if(elt) { if(elt->getName()==name) @@ -288,9 +301,9 @@ int MEDFileEquivalences::size() const std::vector MEDFileEquivalences::getEquivalenceNames() const { std::vector ret; - for(std::vector< MCAuto >::const_iterator it=_equ.begin();it!=_equ.end();it++) + for(const auto & it : _equ) { - const MEDFileEquivalencePair *elt(*it); + const MEDFileEquivalencePair *elt(it); if(elt) { ret.push_back(elt->getName()); @@ -315,7 +328,7 @@ MEDFileEquivalences *MEDFileEquivalences::deepCopy(MEDFileMesh *owner) const bool MEDFileEquivalences::isEqual(const MEDFileEquivalences *other, std::string& what) const { - std::size_t sz(_equ.size()); + std::size_t const sz(_equ.size()); if(sz!=other->_equ.size()) { what="Equivalences differs : not same number !"; @@ -348,7 +361,7 @@ bool MEDFileEquivalences::isEqual(const MEDFileEquivalences *other, std::string& void MEDFileEquivalences::getRepr(std::ostream& oss) const { std::size_t ii(0); - for(std::vector< MCAuto >::const_iterator it=_equ.begin();it!=_equ.end();it++,ii++) + for(auto it=_equ.begin();it!=_equ.end();it++,ii++) { const MEDFileEquivalencePair *elt(*it); oss << "Equivalence #" << ii << " : " ; @@ -361,7 +374,7 @@ void MEDFileEquivalences::getRepr(std::ostream& oss) const void MEDFileEquivalences::killEquivalenceWithName(const std::string& name) { - std::vector< MCAuto >::iterator it(_equ.begin()); + auto it(_equ.begin()); for(;it!=_equ.end();it++) { const MEDFileEquivalencePair *elt(*it); @@ -378,13 +391,13 @@ void MEDFileEquivalences::killEquivalenceWithName(const std::string& name) void MEDFileEquivalences::killEquivalenceAt(int i) { - int sz(size()); + int const sz(size()); if(i<0 || i>=sz) { std::ostringstream oss; oss << "MEDFileEquivalences::killEquivalenceAt : Id must be in [0," << sz << ") !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - std::vector< MCAuto >::iterator it(_equ.begin()); + auto it(_equ.begin()); for(int j=0;j >::const_iterator it=_equ.begin();it!=_equ.end();it++) + for(const auto & it : _equ) { - const MEDFileEquivalencePair *elt(*it); + const MEDFileEquivalencePair *elt(it); if(elt) elt->writeLL(fid); } @@ -406,7 +419,7 @@ void MEDFileEquivalences::writeLL(med_idt fid) const int MEDFileEquivalences::PresenceOfEquivalences(med_idt fid, const std::string& meshName) { - med_int nequ(MEDnEquivalence(fid,meshName.c_str())); + med_int const nequ(MEDnEquivalence(fid,meshName.c_str())); return FromMedInt(nequ); } @@ -415,7 +428,7 @@ MEDFileEquivalences *MEDFileEquivalences::Load(med_idt fid, int nbOfEq, MEDFileM MCAuto ret(new MEDFileEquivalences(owner)); if(!owner) throw INTERP_KERNEL::Exception("MEDFileEquivalences::Load : owner is NULL !"); - std::string meshName(owner->getName()); + std::string const meshName(owner->getName()); for(int i=0;i equ(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)); @@ -443,9 +456,9 @@ void MEDFileEquivalences::CheckDataArray(const DataArrayInt *data) void MEDFileEquivalences::deepCpyFrom(const MEDFileEquivalences& other) { - for(std::vector< MCAuto >::const_iterator it=other._equ.begin();it!=other._equ.end();it++) + for(const auto & it : other._equ) { - const MEDFileEquivalencePair *elt(*it); + const MEDFileEquivalencePair *elt(it); MCAuto eltCpy; if(elt) { @@ -506,8 +519,8 @@ void MEDFileEquivalenceData::writeAdvanced(med_idt fid, med_entity_type medtype, const MEDFileMesh *mesh(getFather()->getMesh()); int dt,it; mesh->getTime(dt,it); - std::string meshName(mesh->getName()); - std::string equName(getFather()->getName()); + std::string const meshName(mesh->getName()); + std::string const equName(getFather()->getName()); INTERP_KERNEL::AutoPtr meshName2(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)); INTERP_KERNEL::AutoPtr name(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)); MEDLoaderBase::safeStrCpy(meshName.c_str(),MED_NAME_SIZE,meshName2,getFather()->getMesh()->getTooLongStrPolicy()); @@ -558,7 +571,7 @@ void MEDFileEquivalenceCellType::writeLL(med_idt fid) const std::vector MEDFileEquivalenceCell::getDirectChildrenWithNull() const { - std::size_t sz(_types.size()); + std::size_t const sz(_types.size()); std::vector ret(sz); for(std::size_t i=0;isize()>0) return ret.retn(); else - return 0; + return nullptr; } void MEDFileEquivalenceCell::writeLL(med_idt fid) const { - for(std::vector< MCAuto >::const_iterator it=_types.begin();it!=_types.end();it++) + for(const auto & _type : _types) { - const MEDFileEquivalenceCellType *ct(*it); + const MEDFileEquivalenceCellType *ct(_type); if(ct) ct->writeLL(fid); } @@ -593,9 +606,9 @@ void MEDFileEquivalenceCell::writeLL(med_idt fid) const MEDFileEquivalenceCell *MEDFileEquivalenceCell::deepCopy(MEDFileEquivalencePair *owner) const { MCAuto ret(new MEDFileEquivalenceCell(owner)); - for(std::vector< MCAuto >::const_iterator it=_types.begin();it!=_types.end();it++) + for(const auto & _type : _types) { - const MEDFileEquivalenceCellType *elt(*it); + const MEDFileEquivalenceCellType *elt(_type); MCAuto eltCpy; if(elt) eltCpy=elt->deepCopy(owner); @@ -606,7 +619,7 @@ MEDFileEquivalenceCell *MEDFileEquivalenceCell::deepCopy(MEDFileEquivalencePair bool MEDFileEquivalenceCell::isEqual(const MEDFileEquivalenceCell *other, std::string& what) const { - std::size_t sz(_types.size()); + std::size_t const sz(_types.size()); if(sz!=other->_types.size()) { std::ostringstream oss; oss << "Nb of geo types differs : " << sz << " != " << other->_types.size(); @@ -637,9 +650,9 @@ bool MEDFileEquivalenceCell::isEqual(const MEDFileEquivalenceCell *other, std::s void MEDFileEquivalenceCell::getRepr(std::ostream& oss) const { - for(std::vector< MCAuto >::const_iterator it=_types.begin();it!=_types.end();it++) + for(const auto & _type : _types) { - const MEDFileEquivalenceCellType *elt(*it); + const MEDFileEquivalenceCellType *elt(_type); if(elt) elt->getRepr(oss); } @@ -647,9 +660,9 @@ void MEDFileEquivalenceCell::getRepr(std::ostream& oss) const DataArrayInt *MEDFileEquivalenceCell::getArray(INTERP_KERNEL::NormalizedCellType type) { - for(std::vector< MCAuto >::iterator it=_types.begin();it!=_types.end();it++) + for(auto & _type : _types) { - MEDFileEquivalenceCellType *elt(*it); + MEDFileEquivalenceCellType *elt(_type); if(elt && elt->getType()==type) return elt->getArray(); } @@ -663,7 +676,7 @@ void MEDFileEquivalenceCell::setArray(int meshDimRelToMax, DataArrayInt *da) return ; MEDFileEquivalences::CheckDataArray(da); MEDFileMesh *mm(getMesh()); - mcIdType totalNbOfCells(mm->getNumberOfCellsAtLevel(meshDimRelToMax)); + mcIdType const totalNbOfCells(mm->getNumberOfCellsAtLevel(meshDimRelToMax)); // MCAuto tmp(da->deepCopy()); tmp->rearrange(1); int maxv,minv; @@ -674,42 +687,42 @@ void MEDFileEquivalenceCell::setArray(int meshDimRelToMax, DataArrayInt *da) throw INTERP_KERNEL::Exception(oss.str().c_str()); } // - std::vector gts(mm->getGeoTypesAtLevel(meshDimRelToMax)); + std::vector const gts(mm->getGeoTypesAtLevel(meshDimRelToMax)); int startId(0),endId; - std::vector compS(1,0); - for(std::vector::const_iterator it=gts.begin();it!=gts.end();it++) + std::vector const compS(1,0); + for(auto gt : gts) { - endId=startId+(int)mm->getNumberOfCellsWithType(*it); + endId=startId+(int)mm->getNumberOfCellsWithType(gt); MCAuto da0(da->keepSelectedComponents(compS)); MCAuto ids(da0->findIdsInRange(startId,endId)); MCAuto da1(da->selectByTupleIdSafe(ids->begin(),ids->end())); da1->applyLin(1,-startId); - setArrayForType(*it,da1); + setArrayForType(gt,da1); startId=endId; } } void MEDFileEquivalenceCell::setArrayForType(INTERP_KERNEL::NormalizedCellType type, DataArrayInt *da) { - for(std::vector< MCAuto >::iterator it=_types.begin();it!=_types.end();it++) + for(auto & _type : _types) { - MEDFileEquivalenceCellType *elt(*it); + MEDFileEquivalenceCellType *elt(_type); if(elt && elt->getType()==type) { elt->setArray(da); return ; } } - MCAuto newElt(new MEDFileEquivalenceCellType(getFather(),type,da)); + MCAuto const newElt(new MEDFileEquivalenceCellType(getFather(),type,da)); _types.push_back(newElt); } std::vector MEDFileEquivalenceCell::getTypes() const { std::vector ret; - for(std::vector< MCAuto >::const_iterator it=_types.begin();it!=_types.end();it++) + for(const auto & _type : _types) { - const MEDFileEquivalenceCellType *elt(*it); + const MEDFileEquivalenceCellType *elt(_type); if(elt) ret.push_back(elt->getType()); } @@ -732,7 +745,7 @@ void MEDFileEquivalenceCell::load(med_idt fid) MEDFILESAFECALLERRD0(MEDequivalenceCorrespondenceRd,(fid,meshName.c_str(),name.c_str(),dt,it,MED_CELL,typmai[i],da->getPointer())); da->applyLin(1,-1); da->rearrange(2); - MCAuto ct(new MEDFileEquivalenceCellType(getFather(),typmai2[i],FromMedIntArray(da))); + MCAuto const ct(new MEDFileEquivalenceCellType(getFather(),typmai2[i],FromMedIntArray(da))); _types.push_back(ct); } } diff --git a/src/MEDLoader/MEDFileEquivalence.hxx b/src/MEDLoader/MEDFileEquivalence.hxx index bc09280b9..877ca7c24 100644 --- a/src/MEDLoader/MEDFileEquivalence.hxx +++ b/src/MEDLoader/MEDFileEquivalence.hxx @@ -21,14 +21,18 @@ #ifndef __MEDFILEEQUIVALENCE_HXX__ #define __MEDFILEEQUIVALENCE_HXX__ +#include "MEDFileUtilities.hxx" +#include "MCType.hxx" #include "MEDLoaderDefines.hxx" #include "MEDCouplingRefCountObject.hxx" -#include "MEDCouplingMemArray.hxx" -#include "MEDFileUtilities.txx" #include "MCAuto.hxx" #include "NormalizedGeometricTypes" +#include "med.h" +#include +#include +#include #include namespace MEDCoupling @@ -43,7 +47,7 @@ namespace MEDCoupling public: static MEDFileEquivalencePair *Load(MEDFileEquivalences *father, med_idt fid, const std::string& name, const std::string &desc); std::string getClassName() const override { return std::string("MEDFileEquivalencePair"); } - void writeLL(med_idt fid) const; + void writeLL(med_idt fid) const override; const MEDFileEquivalences *getFather() const { return _father; } MEDFileEquivalences *getFather() { return _father; } const MEDFileMesh *getMesh() const; @@ -52,8 +56,8 @@ namespace MEDCoupling bool isEqual(const MEDFileEquivalencePair *other, std::string& what) const; void getRepr(std::ostream& oss) const; static MEDFileEquivalencePair *New(MEDFileEquivalences *father, const std::string& name); - MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const; - MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; + MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const override; + MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const override; public: MEDLOADER_EXPORT std::string getName() const { return _name; } MEDLOADER_EXPORT void setName(const std::string& name) { _name=name; } @@ -78,8 +82,8 @@ namespace MEDCoupling class MEDFileEquivalences : public RefCountObject, public MEDFileWritableStandAlone { public: - MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const; - MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; + MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const override; + MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const override; MEDLOADER_EXPORT const MEDFileMesh *getMesh() const { return _owner; } MEDLOADER_EXPORT MEDFileMesh *getMesh() { return _owner; } void getDtIt(int &dt, int &it) const; @@ -100,7 +104,7 @@ namespace MEDCoupling MEDLOADER_EXPORT void killEquivalenceAt(int i); MEDLOADER_EXPORT void clear(); public: - MEDLOADER_EXPORT void writeLL(med_idt fid) const; + MEDLOADER_EXPORT void writeLL(med_idt fid) const override; static int PresenceOfEquivalences(med_idt fid, const std::string& meshName); static MEDFileEquivalences *Load(med_idt fid, int nbOfEq, MEDFileMesh *owner); static void CheckDataArray(const DataArrayInt *data); @@ -121,7 +125,7 @@ namespace MEDCoupling const MEDFileMesh *getMesh() const { return getFather()->getMesh(); } MEDFileMesh *getMesh() { return getFather()->getMesh(); } protected: - ~MEDFileEquivalenceBase() { } + ~MEDFileEquivalenceBase() override = default; private: MEDFileEquivalencePair *_father; }; @@ -134,12 +138,12 @@ namespace MEDCoupling MEDLOADER_EXPORT void setArray(DataArrayInt *data); MEDLOADER_EXPORT const DataArrayInt *getArray() const { return _data; } MEDLOADER_EXPORT DataArrayInt *getArray() { return _data; } - MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const; + MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const override; bool isEqual(const MEDFileEquivalenceData *other, std::string& what) const; protected: void writeAdvanced(med_idt fid, med_entity_type medtype, med_geometry_type medgt) const; protected: - ~MEDFileEquivalenceData() { } + ~MEDFileEquivalenceData() override = default; protected: MCAuto _data; }; @@ -149,15 +153,15 @@ namespace MEDCoupling public: MEDFileEquivalenceCellType(MEDFileEquivalencePair *owner, INTERP_KERNEL::NormalizedCellType type, DataArrayInt *data):MEDFileEquivalenceData(owner,data),_type(type) { } MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileEquivalenceCellType"); } - MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; + MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const override; INTERP_KERNEL::NormalizedCellType getType() const { return _type; } MEDFileEquivalenceCellType *deepCopy(MEDFileEquivalencePair *owner) const; bool isEqual(const MEDFileEquivalenceCellType *other, std::string& what) const; void getRepr(std::ostream& oss) const; public: - void writeLL(med_idt fid) const; + void writeLL(med_idt fid) const override; protected: - ~MEDFileEquivalenceCellType() { } + ~MEDFileEquivalenceCellType() override = default; private: INTERP_KERNEL::NormalizedCellType _type; }; @@ -165,11 +169,11 @@ namespace MEDCoupling class MEDFileEquivalenceCell : public MEDFileEquivalenceBase { public: - MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const; - MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; + MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const override; + MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const override; MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileEquivalenceCell"); } static MEDFileEquivalenceCell *Load(med_idt fid, MEDFileEquivalencePair *owner); - void writeLL(med_idt fid) const; + void writeLL(med_idt fid) const override; MEDFileEquivalenceCell *deepCopy(MEDFileEquivalencePair *owner) const; bool isEqual(const MEDFileEquivalenceCell *other, std::string& what) const; void getRepr(std::ostream& oss) const; @@ -183,7 +187,7 @@ namespace MEDCoupling public: MEDFileEquivalenceCell(MEDFileEquivalencePair *owner):MEDFileEquivalenceBase(owner) { } private: - ~MEDFileEquivalenceCell() { } + ~MEDFileEquivalenceCell() override = default; private: void load(med_idt fid); std::string getName() const { return getFather()->getName(); } @@ -196,13 +200,13 @@ namespace MEDCoupling public: MEDFileEquivalenceNode(MEDFileEquivalencePair *owner, DataArrayInt *data):MEDFileEquivalenceData(owner,data) { } MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileEquivalenceNode"); } - MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; - void writeLL(med_idt fid) const; + MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const override; + void writeLL(med_idt fid) const override; MEDFileEquivalenceNode *deepCopy(MEDFileEquivalencePair *owner) const; bool isEqual(const MEDFileEquivalenceNode *other, std::string& what) const; void getRepr(std::ostream& oss) const; protected: - ~MEDFileEquivalenceNode() { } + ~MEDFileEquivalenceNode() override = default; }; } diff --git a/src/MEDLoader/MEDFileField.cxx b/src/MEDLoader/MEDFileField.cxx index 3993ff919..797677324 100644 --- a/src/MEDLoader/MEDFileField.cxx +++ b/src/MEDLoader/MEDFileField.cxx @@ -19,10 +19,18 @@ // Author : Anthony Geay (EDF R&D) #include "MEDFileField.hxx" +#include "MEDFileEntities.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include "MCAuto.hxx" +#include "MCType.hxx" +#include "MCIdType.hxx" +#include "MEDCouplingUMesh.hxx" +#include "MEDCoupling1GTUMesh.hxx" +#include "MEDFileFieldInternal.hxx" +#include "InterpKernelException.hxx" #include "MEDFileMesh.hxx" -#include "MEDLoaderBase.hxx" +#include "MEDFileUtilities.hxx" #include "MEDLoaderTraits.hxx" -#include "MEDFileSafeCaller.txx" #include "MEDFileFieldOverView.hxx" #include "MEDFileBlowStrEltUp.hxx" #include "MEDFileFieldVisitor.hxx" @@ -30,10 +38,20 @@ #include "MEDCouplingFieldDiscretization.hxx" #include "InterpKernelAutoPtr.hxx" -#include "CellModel.hxx" +#include "NormalizedGeometricTypes" +#include "med.h" +#include "medfield.h" #include +#include #include +#include +#include +#include +#include +#include +#include +#include // From MEDLoader.cxx TU: extern INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO]; @@ -51,24 +69,24 @@ MEDFileFields *MEDFileFields::New() MEDFileFields *MEDFileFields::New(const std::string& fileName, bool loadAll) { - MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + MEDFileUtilities::AutoFid const fid(OpenMEDFileForRead(fileName)); return New(fid,loadAll); } MEDFileFields *MEDFileFields::NewAdv(const std::string& fileName, bool loadAll, const MEDFileEntities *entities) { - MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + MEDFileUtilities::AutoFid const fid(OpenMEDFileForRead(fileName)); return NewAdv(fid,loadAll,entities); } MEDFileFields *MEDFileFields::NewAdv(med_idt fid, bool loadAll, const MEDFileEntities *entities) { - return new MEDFileFields(fid,loadAll,0,entities); + return new MEDFileFields(fid,loadAll,nullptr,entities); } MEDFileFields *MEDFileFields::NewWithDynGT(const std::string& fileName, const MEDFileStructureElements *se, bool loadAll) { - MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + MEDFileUtilities::AutoFid const fid(OpenMEDFileForRead(fileName)); return NewWithDynGT(fid,se,loadAll); } @@ -77,26 +95,26 @@ MEDFileFields *MEDFileFields::NewWithDynGT(med_idt fid, const MEDFileStructureEl if(!se) throw INTERP_KERNEL::Exception("MEDFileFields::NewWithDynGT : null struct element pointer !"); INTERP_KERNEL::AutoCppPtr entities(MEDFileEntities::BuildFrom(*se)); - return new MEDFileFields(fid,loadAll,0,entities); + return new MEDFileFields(fid,loadAll,nullptr,entities); } MEDFileFields *MEDFileFields::New(med_idt fid, bool loadAll) { - return new MEDFileFields(fid,loadAll,0,0); + return new MEDFileFields(fid,loadAll,nullptr,nullptr); } MEDFileFields *MEDFileFields::LoadPartOf(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms) { - MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); - return new MEDFileFields(fid,loadAll,ms,0); + MEDFileUtilities::AutoFid const fid(OpenMEDFileForRead(fileName)); + return new MEDFileFields(fid,loadAll,ms,nullptr); } MEDFileFields *MEDFileFields::LoadSpecificEntities(const std::string& fileName, const std::vector< std::pair >& entities, bool loadAll) { MEDFileUtilities::CheckFileForRead(fileName); INTERP_KERNEL::AutoCppPtr ent(new MEDFileStaticEntities(entities)); - MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); - return new MEDFileFields(fid,loadAll,0,ent); + MEDFileUtilities::AutoFid const fid(OpenMEDFileForRead(fileName)); + return new MEDFileFields(fid,loadAll,nullptr,ent); } std::size_t MEDFileFields::getHeapMemorySizeWithoutChildren() const @@ -109,8 +127,8 @@ std::size_t MEDFileFields::getHeapMemorySizeWithoutChildren() const std::vector MEDFileFields::getDirectChildrenWithNull() const { std::vector ret; - for(std::vector< MCAuto >::const_iterator it=_fields.begin();it!=_fields.end();it++) - ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it); + for(const auto & _field : _fields) + ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_field); return ret; } @@ -118,7 +136,7 @@ MEDFileFields *MEDFileFields::deepCopy() const { MCAuto ret(shallowCpy()); std::size_t i(0); - for(std::vector< MCAuto >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++) + for(auto it=_fields.begin();it!=_fields.end();it++,i++) { if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it) ret->_fields[i]=(*it)->deepCopy(); @@ -147,11 +165,11 @@ std::vector< std::pair > MEDFileFields::getCommonIterations(bool& areTh std::set< std::pair > s; bool firstShot=true; areThereSomeForgottenTS=false; - for(std::vector< MCAuto >::const_iterator it=_fields.begin();it!=_fields.end();it++) + for(const auto & _field : _fields) { - if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it) + if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)_field) continue; - std::vector< std::pair > v=(*it)->getIterations(); + std::vector< std::pair > v=_field->getIterations(); std::set< std::pair > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end())); if(firstShot) { s=s1; firstShot=false; } @@ -177,7 +195,7 @@ std::vector MEDFileFields::getFieldsNames() const { std::vector ret(_fields.size()); int i(0); - for(std::vector< MCAuto >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++) + for(auto it=_fields.begin();it!=_fields.end();it++,i++) { const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it); if(f) @@ -196,9 +214,9 @@ std::vector MEDFileFields::getFieldsNames() const std::vector MEDFileFields::getMeshesNames() const { std::vector ret; - for(std::vector< MCAuto >::const_iterator it=_fields.begin();it!=_fields.end();it++) + for(const auto & _field : _fields) { - const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it); + const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(_field); if(cur) ret.push_back(cur->getMeshName()); } @@ -215,11 +233,11 @@ std::string MEDFileFields::simpleRepr() const void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const { - int nbOfFields(getNumberOfFields()); - std::string startLine(bkOffset,' '); + int const nbOfFields(getNumberOfFields()); + std::string const startLine(bkOffset,' '); oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl; int i=0; - for(std::vector< MCAuto >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++) + for(auto it=_fields.begin();it!=_fields.end();it++,i++) { const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it); if(cur) @@ -232,10 +250,10 @@ void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const } } i=0; - for(std::vector< MCAuto >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++) + for(auto it=_fields.begin();it!=_fields.end();it++,i++) { const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it); - std::string chapter(17,(char)('0'+i)); + std::string const chapter(17,(char)('0'+i)); oss << startLine << chapter << std::endl; if(cur) { @@ -251,8 +269,7 @@ void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const } MEDFileFields::MEDFileFields() -{ -} += default; MEDFileFields::MEDFileFields(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities) try:MEDFileFieldGlobsReal(fid) @@ -313,7 +330,7 @@ void MEDFileFields::writeLL(med_idt fid) const { int i=0; writeGlobals(fid,*this); - for(std::vector< MCAuto >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++) + for(auto it=_fields.begin();it!=_fields.end();it++,i++) { const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it; if(!elt) @@ -336,10 +353,10 @@ void MEDFileFields::loadArrays() { if(getFileName().empty()) throw INTERP_KERNEL::Exception("MEDFileFields::loadArrays : the structure does not come from a file !"); - MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName())); - for(std::vector< MCAuto >::iterator it=_fields.begin();it!=_fields.end();it++) + MEDFileUtilities::AutoFid const fid(OpenMEDFileForRead(getFileName())); + for(auto & _field : _fields) { - MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it); + MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(_field); if(elt) elt->loadBigArraysRecursively(fid,*elt); } @@ -356,10 +373,10 @@ void MEDFileFields::loadArraysIfNecessary() { if(!getFileName().empty()) { - MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName())); - for(std::vector< MCAuto >::iterator it=_fields.begin();it!=_fields.end();it++) + MEDFileUtilities::AutoFid const fid(OpenMEDFileForRead(getFileName())); + for(auto & _field : _fields) { - MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it); + MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(_field); if(elt) elt->loadBigArraysRecursivelyIfNecessary(fid,*elt); } @@ -375,9 +392,9 @@ void MEDFileFields::loadArraysIfNecessary() */ void MEDFileFields::unloadArrays() { - for(std::vector< MCAuto >::iterator it=_fields.begin();it!=_fields.end();it++) + for(auto & _field : _fields) { - MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it); + MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(_field); if(elt) elt->unloadArrays(); } @@ -400,14 +417,14 @@ std::vector MEDFileFields::getPflsReallyUsed() const { std::vector ret; std::set ret2; - for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++) + for(const auto & _field : _fields) { - std::vector tmp=(*it)->getPflsReallyUsed2(); - for(std::vector::const_iterator it2=tmp.begin();it2!=tmp.end();it2++) - if(ret2.find(*it2)==ret2.end()) + std::vector const tmp=_field->getPflsReallyUsed2(); + for(const auto & it2 : tmp) + if(ret2.find(it2)==ret2.end()) { - ret.push_back(*it2); - ret2.insert(*it2); + ret.push_back(it2); + ret2.insert(it2); } } return ret; @@ -417,14 +434,14 @@ std::vector MEDFileFields::getLocsReallyUsed() const { std::vector ret; std::set ret2; - for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++) + for(const auto & _field : _fields) { - std::vector tmp((*it)->getLocsReallyUsed2()); - for(std::vector::const_iterator it2=tmp.begin();it2!=tmp.end();it2++) - if(ret2.find(*it2)==ret2.end()) + std::vector const tmp(_field->getLocsReallyUsed2()); + for(const auto & it2 : tmp) + if(ret2.find(it2)==ret2.end()) { - ret.push_back(*it2); - ret2.insert(*it2); + ret.push_back(it2); + ret2.insert(it2); } } return ret; @@ -433,9 +450,9 @@ std::vector MEDFileFields::getLocsReallyUsed() const std::vector MEDFileFields::getPflsReallyUsedMulti() const { std::vector ret; - for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++) + for(const auto & _field : _fields) { - std::vector tmp((*it)->getPflsReallyUsedMulti2()); + std::vector tmp(_field->getPflsReallyUsedMulti2()); ret.insert(ret.end(),tmp.begin(),tmp.end()); } return ret; @@ -444,9 +461,9 @@ std::vector MEDFileFields::getPflsReallyUsedMulti() const std::vector MEDFileFields::getLocsReallyUsedMulti() const { std::vector ret; - for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++) + for(const auto & _field : _fields) { - std::vector tmp((*it)->getLocsReallyUsed2()); + std::vector tmp(_field->getLocsReallyUsed2()); ret.insert(ret.end(),tmp.begin(),tmp.end()); } return ret; @@ -454,14 +471,14 @@ std::vector MEDFileFields::getLocsReallyUsedMulti() const void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif) { - for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++) - (*it)->changePflsRefsNamesGen2(mapOfModif); + for(auto & _field : _fields) + _field->changePflsRefsNamesGen2(mapOfModif); } void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif) { - for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++) - (*it)->changeLocsRefsNamesGen2(mapOfModif); + for(auto & _field : _fields) + _field->changeLocsRefsNamesGen2(mapOfModif); } void MEDFileFields::resize(int newSize) @@ -471,8 +488,8 @@ void MEDFileFields::resize(int newSize) void MEDFileFields::pushFields(const std::vector& fields) { - for(std::vector::const_iterator it=fields.begin();it!=fields.end();it++) - pushField(*it); + for(auto field : fields) + pushField(field); } void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field) @@ -521,7 +538,7 @@ void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds) void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step) { static const char msg[]="MEDFileFields::destroyFieldsAtPos2"; - mcIdType nbOfEntriesToKill(DataArrayIdType::GetNumberOfItemGivenBESRelative(bg,end,step,msg)); + mcIdType const nbOfEntriesToKill(DataArrayIdType::GetNumberOfItemGivenBESRelative(bg,end,step,msg)); std::vector b(_fields.size(),true); int k=bg; for(int i=0;i >& modifTab) { bool ret(false); - for(std::vector< MCAuto >::iterator it=_fields.begin();it!=_fields.end();it++) + for(auto & _field : _fields) { - MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it); + MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(_field); if(cur) ret=cur->changeMeshNames(modifTab) || ret; } @@ -565,9 +582,9 @@ bool MEDFileFields::changeMeshNames(const std::vector< std::pair& oldCode, const std::vector& newCode, const DataArrayIdType *renumO2N) { bool ret(false); - for(std::vector< MCAuto >::iterator it=_fields.begin();it!=_fields.end();it++) + for(auto & _field : _fields) { - MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it); + MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(_field); if(fmts) { ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret; @@ -587,7 +604,7 @@ MEDFileFields *MEDFileFields::extractPart(const std::map fsOut(MEDFileFields::New()); - int nbFields(getNumberOfFields()); + int const nbFields(getNumberOfFields()); for(int i=0;i fmts(getFieldAtPos(i)); @@ -604,12 +621,12 @@ MEDFileFields *MEDFileFields::extractPart(const std::map >::const_iterator it=_fields.begin();it!=_fields.end();it++) - if((*it).isNotNull()) + for(const auto & _field : _fields) + if(_field.isNotNull()) { - visitor.newFieldEntry(*it); - (*it)->accept(visitor); - visitor.endFieldEntry(*it); + visitor.newFieldEntry(_field); + _field->accept(visitor); + visitor.endFieldEntry(_field); } } @@ -631,20 +648,20 @@ private: class MEDFileFieldLin2QuadVisitor : public MEDFileFieldVisitor { public: - MEDFileFieldLin2QuadVisitor(const MEDFileUMesh *lin, const MEDFileUMesh *quad, const MEDFileFieldGlobsReal *linGlobs, MEDFileFields* outFs):_lin(lin),_quad(quad),_lin_globs(linGlobs),_out_fs(outFs),_gt(INTERP_KERNEL::NORM_ERROR),_1ts_update_requested(false) { } - void newFieldEntry(const MEDFileAnyTypeFieldMultiTSWithoutSDA *field) { if(field->getMeshName()!=_lin->getName()) return; _cur_fmts=MEDFileFieldMultiTS::New(); } - void endFieldEntry(const MEDFileAnyTypeFieldMultiTSWithoutSDA *field) { if(_cur_fmts.isNotNull()) { if(_cur_fmts->getNumberOfTS()>0) _out_fs->pushField(_cur_fmts); } } + MEDFileFieldLin2QuadVisitor(const MEDFileUMesh *lin, const MEDFileUMesh *quad, const MEDFileFieldGlobsReal *linGlobs, MEDFileFields* outFs):_lin(lin),_quad(quad),_lin_globs(linGlobs),_out_fs(outFs) { } + void newFieldEntry(const MEDFileAnyTypeFieldMultiTSWithoutSDA *field) override { if(field->getMeshName()!=_lin->getName()) return; _cur_fmts=MEDFileFieldMultiTS::New(); } + void endFieldEntry(const MEDFileAnyTypeFieldMultiTSWithoutSDA * /*field*/) override { if(_cur_fmts.isNotNull()) { if(_cur_fmts->getNumberOfTS()>0) _out_fs->pushField(_cur_fmts); } } // - void newTimeStepEntry(const MEDFileAnyTypeField1TSWithoutSDA *ts); - void endTimeStepEntry(const MEDFileAnyTypeField1TSWithoutSDA *ts); + void newTimeStepEntry(const MEDFileAnyTypeField1TSWithoutSDA *ts) override; + void endTimeStepEntry(const MEDFileAnyTypeField1TSWithoutSDA *ts) override; // - void newMeshEntry(const MEDFileFieldPerMesh *fpm); - void endMeshEntry(const MEDFileFieldPerMesh *fpm) { } + void newMeshEntry(const MEDFileFieldPerMesh *fpm) override; + void endMeshEntry(const MEDFileFieldPerMesh *fpm) override { } // - void newPerMeshPerTypeEntry(const MEDFileFieldPerMeshPerTypeCommon *pmpt); - void endPerMeshPerTypeEntry(const MEDFileFieldPerMeshPerTypeCommon *pmpt) { } + void newPerMeshPerTypeEntry(const MEDFileFieldPerMeshPerTypeCommon *pmpt) override; + void endPerMeshPerTypeEntry(const MEDFileFieldPerMeshPerTypeCommon *pmpt) override { } // - void newPerMeshPerTypePerDisc(const MEDFileFieldPerMeshPerTypePerDisc *pmptpd); + void newPerMeshPerTypePerDisc(const MEDFileFieldPerMeshPerTypePerDisc *pmptpd) override; private: void updateData(MEDFileFieldPerMeshPerTypePerDisc *pmtd, mcIdType deltaNbNodes); private: @@ -654,9 +671,9 @@ private: MEDFileFields *_out_fs; MCAuto _cur_fmts; MCAuto _cur_f1ts; - INTERP_KERNEL::NormalizedCellType _gt; + INTERP_KERNEL::NormalizedCellType _gt{INTERP_KERNEL::NORM_ERROR}; // Info on 1TS modification - bool _1ts_update_requested; + bool _1ts_update_requested{false}; // Cache of matrix to compute faster the values on newly created points std::map< std::string, PFLData > _cache; std::vector _pfls_to_be_updated; @@ -670,11 +687,11 @@ void MEDFileFieldLin2QuadVisitor::newPerMeshPerTypePerDisc(const MEDFileFieldPer throw INTERP_KERNEL::Exception("Not managed yet for ON_CELLS ON_GAUSS_NE and ON_GAUSS_PT"); _1ts_update_requested=true; MEDFileAnyTypeField1TSWithoutSDA *ct(_cur_f1ts->contentNotNullBase()); - int locId(pmptpd->getFather()->locIdOfLeaf(pmptpd)); + int const locId(pmptpd->getFather()->locIdOfLeaf(pmptpd)); MEDFileFieldPerMeshPerTypePerDisc *pmtdToModify(ct->getLeafGivenMeshAndTypeAndLocId(_lin->getName(),_gt,locId)); - std::string pflName(pmptpd->getProfile()); + std::string const pflName(pmptpd->getProfile()); _pfls_to_be_updated.push_back(pflName); - std::map< std::string, PFLData >::iterator itCache(_cache.find(pflName)); + auto const itCache(_cache.find(pflName)); if(itCache!=_cache.end()) { updateData(pmtdToModify,(*itCache).second.getNbOfAddPtsInPfl()); @@ -705,7 +722,7 @@ void MEDFileFieldLin2QuadVisitor::newPerMeshPerTypePerDisc(const MEDFileFieldPer DataArrayIdType *nodeConn(allSeg3->getNodalConnectivity()); nodeConn->rearrange(3); { - std::vector v(1,2); + std::vector const v(1,2); midPts=nodeConn->keepSelectedComponents(v); } cellSeg3Ids=DataArrayIdType::FindPermutationFromFirstToSecond(midPts,newPtsIds); @@ -724,7 +741,7 @@ void MEDFileFieldLin2QuadVisitor::newPerMeshPerTypePerDisc(const MEDFileFieldPer pflq=DataArrayIdType::Aggregate(vs); pflq->setName(pflName); } - PFLData pdata(matrix,pflq,newPtsIds->getNumberOfTuples()); + PFLData const pdata(matrix,pflq,newPtsIds->getNumberOfTuples()); _cache[pflName]=pdata; updateData(pmtdToModify,pdata.getNbOfAddPtsInPfl()); } @@ -736,7 +753,7 @@ void MEDFileFieldLin2QuadVisitor::updateData(MEDFileFieldPerMeshPerTypePerDisc * void MEDFileFieldLin2QuadVisitor::newPerMeshPerTypeEntry(const MEDFileFieldPerMeshPerTypeCommon *pmpt) { - const MEDFileFieldPerMeshPerType *pmpt2(dynamic_cast(pmpt)); + const auto *pmpt2(dynamic_cast(pmpt)); if(!pmpt2) throw INTERP_KERNEL::Exception("MEDFileFieldLin2QuadVisitor::newPerMeshPerTypeEntry : not managed for structure elements !"); if(pmpt2->getNumberOfLoc()!=1) @@ -755,7 +772,7 @@ void MEDFileFieldLin2QuadVisitor::newTimeStepEntry(const MEDFileAnyTypeField1TSW _1ts_update_requested=false; _pfls_to_be_updated.clear(); if(!ts) return ; - const MEDFileField1TSWithoutSDA *tsd(dynamic_cast(ts)); + const auto *tsd(dynamic_cast(ts)); if(!tsd) return ; MCAuto contentCpy(ts->deepCopy()); @@ -766,25 +783,25 @@ void MEDFileFieldLin2QuadVisitor::newTimeStepEntry(const MEDFileAnyTypeField1TSW _cur_f1ts->deepCpyGlobs(*_lin_globs); } -void MEDFileFieldLin2QuadVisitor::endTimeStepEntry(const MEDFileAnyTypeField1TSWithoutSDA *ts) +void MEDFileFieldLin2QuadVisitor::endTimeStepEntry(const MEDFileAnyTypeField1TSWithoutSDA * /*ts*/) { if(_cur_f1ts.isNull()) return ; if(_1ts_update_requested) { MCAuto matrix,oldPfl; - for(std::vector::const_iterator it=_pfls_to_be_updated.begin();it!=_pfls_to_be_updated.end();it++) + for(const auto & it : _pfls_to_be_updated) { - std::map< std::string, PFLData >::const_iterator it2(_cache.find(*it)); + std::map< std::string, PFLData >::const_iterator const it2(_cache.find(it)); if(it2==_cache.end()) throw INTERP_KERNEL::Exception("MEDFileFieldLin2QuadVisitor::endTimeStepEntry : invalid situation !"); matrix=(*it2).second.getMatrix(); - if((*it).empty()) + if(it.empty()) continue; - int locId(_cur_f1ts->getProfileId(*it)); - oldPfl.takeRef(_cur_f1ts->getProfile(*it)); + int const locId(_cur_f1ts->getProfileId(it)); + oldPfl.takeRef(_cur_f1ts->getProfile(it)); { - std::vector locToKill(1,locId); + std::vector const locToKill(1,locId); _cur_f1ts->killProfileIds(locToKill); } _cur_f1ts->appendProfile((*it2).second.getProfile()); @@ -826,11 +843,11 @@ MCAuto MEDFileFields::linearToQuadratic(const MEDFileMeshes *oldL MEDFileMesh *mm(oldLin->getMeshAtPos(i)); if(!mm) continue; - MEDFileUMesh *mmu(dynamic_cast(mm)); + auto *mmu(dynamic_cast(mm)); if(!mmu) continue; MEDFileMesh *mmq(newQuad->getMeshWithName(mmu->getName())); - MEDFileUMesh *mmqu(dynamic_cast(mmq)); + auto *mmqu(dynamic_cast(mmq)); if(!mmqu) { std::ostringstream oss; oss << "MEDFileFields::linearToQuadratic : mismatch of name between input meshes for name \"" << mmu->getName() << "\""; @@ -851,12 +868,12 @@ MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const } const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i]; if(!fmts) - return 0; + return nullptr; MCAuto ret; - const MEDFileFieldMultiTSWithoutSDA *fmtsC(dynamic_cast(fmts)); - const MEDFileInt32FieldMultiTSWithoutSDA *fmtsC2(dynamic_cast(fmts)); - const MEDFileInt64FieldMultiTSWithoutSDA *fmtsC4(dynamic_cast(fmts)); - const MEDFileFloatFieldMultiTSWithoutSDA *fmtsC3(dynamic_cast(fmts)); + const auto *fmtsC(dynamic_cast(fmts)); + const auto *fmtsC2(dynamic_cast(fmts)); + const auto *fmtsC4(dynamic_cast(fmts)); + const auto *fmtsC3(dynamic_cast(fmts)); if(fmtsC) ret=MEDFileFieldMultiTS::New(*fmtsC,false); else if(fmtsC2) @@ -882,7 +899,7 @@ MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const { MCAuto ret=shallowCpy(); - std::size_t sz=std::distance(startIds,endIds); + std::size_t const sz=std::distance(startIds,endIds); std::vector< MCAuto > fields(sz); int j=0; for(const int *i=startIds;i!=endIds;i++,j++) @@ -912,13 +929,13 @@ MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const std::string& f bool MEDFileFields::removeFieldsWithoutAnyTimeStep() { std::vector > newFields; - for(std::vector< MCAuto >::const_iterator it=_fields.begin();it!=_fields.end();it++) + for(const auto & _field : _fields) { - const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it); + const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(_field); if(elt) { if(elt->getNumberOfTS()>0) - newFields.push_back(*it); + newFields.push_back(_field); } } if(_fields.size()==newFields.size()) @@ -939,15 +956,15 @@ bool MEDFileFields::removeFieldsWithoutAnyTimeStep() MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const { MCAuto ret(MEDFileFields::New()); - for(std::vector< MCAuto >::const_iterator it=_fields.begin();it!=_fields.end();it++) + for(const auto & _field : _fields) { - const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it); + const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(_field); if(!cur) continue; if(cur->getMeshName()==meshName) { cur->incrRef(); - MCAuto cur2(const_cast(cur)); + MCAuto const cur2(const_cast(cur)); ret->_fields.push_back(cur2); } } @@ -971,12 +988,12 @@ MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const std::stri MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair >& timeSteps) const { MCAuto ret(MEDFileFields::New()); - for(std::vector< MCAuto >::const_iterator it=_fields.begin();it!=_fields.end();it++) + for(const auto & _field : _fields) { - const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it); + const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(_field); if(!cur) continue; - MCAuto elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps); + MCAuto const elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps); ret->_fields.push_back(elt); } ret->shallowCpyOnlyUsedGlobs(*this); @@ -989,9 +1006,9 @@ MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vec MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair >& timeSteps) const { MCAuto ret=MEDFileFields::New(); - for(std::vector< MCAuto >::const_iterator it=_fields.begin();it!=_fields.end();it++) + for(const auto & _field : _fields) { - const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it); + const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(_field); if(!cur) continue; MCAuto elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps); @@ -1004,9 +1021,9 @@ MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std:: bool MEDFileFields::presenceOfStructureElements() const { - for(std::vector< MCAuto >::const_iterator it=_fields.begin();it!=_fields.end();it++) - if((*it).isNotNull()) - if((*it)->presenceOfStructureElements()) + for(const auto & _field : _fields) + if(_field.isNotNull()) + if(_field->presenceOfStructureElements()) return true; return false; } @@ -1014,20 +1031,20 @@ bool MEDFileFields::presenceOfStructureElements() const void MEDFileFields::killStructureElements() { std::vector< MCAuto > ret; - for(std::vector< MCAuto >::iterator it=_fields.begin();it!=_fields.end();it++) - if((*it).isNotNull()) + for(auto & _field : _fields) + if(_field.isNotNull()) { - if((*it)->presenceOfStructureElements()) + if(_field->presenceOfStructureElements()) { - if(!(*it)->onlyStructureElements()) + if(!_field->onlyStructureElements()) { - (*it)->killStructureElements(); - ret.push_back(*it); + _field->killStructureElements(); + ret.push_back(_field); } } else { - ret.push_back(*it); + ret.push_back(_field); } } _fields=ret; @@ -1036,14 +1053,14 @@ void MEDFileFields::killStructureElements() void MEDFileFields::keepOnlyStructureElements() { std::vector< MCAuto > ret; - for(std::vector< MCAuto >::iterator it=_fields.begin();it!=_fields.end();it++) - if((*it).isNotNull()) + for(auto & _field : _fields) + if(_field.isNotNull()) { - if((*it)->presenceOfStructureElements()) + if(_field->presenceOfStructureElements()) { - if(!(*it)->onlyStructureElements()) - (*it)->keepOnlyStructureElements(); - ret.push_back(*it); + if(!_field->onlyStructureElements()) + _field->keepOnlyStructureElements(); + ret.push_back(_field); } } _fields=ret; @@ -1052,26 +1069,26 @@ void MEDFileFields::keepOnlyStructureElements() void MEDFileFields::keepOnlyOnMeshSE(const std::string& meshName, const std::string& seName) { std::vector< MCAuto > ret; - for(std::vector< MCAuto >::iterator it=_fields.begin();it!=_fields.end();it++) - if((*it).isNotNull()) + for(auto & _field : _fields) + if(_field.isNotNull()) { - if((*it)->getMeshName()!=meshName) + if(_field->getMeshName()!=meshName) continue; std::vector< std::pair > ps; - (*it)->getMeshSENames(ps); - std::pair p(meshName,seName); + _field->getMeshSENames(ps); + std::pair const p(meshName,seName); if(std::find(ps.begin(),ps.end(),p)!=ps.end()) - (*it)->keepOnlyOnSE(seName); - ret.push_back(*it); + _field->keepOnlyOnSE(seName); + ret.push_back(_field); } _fields=ret; } void MEDFileFields::getMeshSENames(std::vector< std::pair >& ps) const { - for(std::vector< MCAuto >::const_iterator it=_fields.begin();it!=_fields.end();it++) - if((*it).isNotNull()) - (*it)->getMeshSENames(ps); + for(const auto & _field : _fields) + if(_field.isNotNull()) + _field->getMeshSENames(ps); } void MEDFileFields::blowUpSE(MEDFileMeshes *ms, const MEDFileStructureElements *ses) @@ -1094,7 +1111,7 @@ void MEDFileFields::aggregateFieldsOnSameMeshes(MEDFileMeshes *ms) THROW_IK_EXCEPTION("MEDFileFields::aggregateFieldsOnSameMeshes : ms is nullptr !"); // std::vector msNames(ms->getMeshesNames()); - std::set msNamesSet(msNames.begin(),msNames.end()); + std::set const msNamesSet(msNames.begin(),msNames.end()); if(msNames.size() == msNamesSet.size()) return ; // @@ -1116,7 +1133,7 @@ void MEDFileFields::aggregateFieldsOnSameMeshes(MEDFileMeshes *ms) zeMeshNames.insert(fmtsWithSameName->getMeshName()); if(zeMeshNames.size()!=1) THROW_IK_EXCEPTION("MEDFileFields::aggregateFieldsOnSameMeshes : Presence of multiple MultiTS instances with same name but lying on same meshName. Looks bad !"); - std::string meshNameToMerge = *zeMeshNames.begin(); + std::string const meshNameToMerge = *zeMeshNames.begin(); if(expectedMeshNamesToMerge.find(meshNameToMerge) != expectedMeshNamesToMerge.end()) THROW_IK_EXCEPTION("MEDFileFields::aggregateFieldsOnSameMeshes : unexpected situation ! Error in implementation !"); expectedMeshNamesToMerge.insert(*zeMeshNames.begin()); @@ -1146,7 +1163,7 @@ void MEDFileFields::aggregateFieldsOnSameMeshes(MEDFileMeshes *ms) for(auto entry : entries) dtsToPush.push_back({entry.first.first,entry.second.second-entry.second.first}); dtsToAggregate.push_back(dtsToPush); - MCAuto eltToAggregate = MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(fieldToBeAggregated); + MCAuto const eltToAggregate = MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(fieldToBeAggregated); eltsToAggregate.push_back(eltToAggregate); } MCAuto gg = MEDFileAnyTypeFieldMultiTS::Aggregate(FromVecAutoToVecOfConst(eltsToAggregate),dtsToAggregate); @@ -1180,7 +1197,7 @@ void MEDFileFields::aggregateFieldsOnSameMeshes(MEDFileMeshes *ms) { if(!curMesh->getNonEmptyLevels().empty()) THROW_IK_EXCEPTION("MEDFileFields::aggregateFieldsOnSameMeshes : only meshes without cells supported."); - MEDFileUMesh *curMeshU(dynamic_cast(curMesh)); + auto *curMeshU(dynamic_cast(curMesh)); if(!curMeshU) THROW_IK_EXCEPTION("MEDFileFields::aggregateFieldsOnSameMeshes : only unstructured mesh supported."); coos.push_back(curMeshU->getCoords()); @@ -1214,12 +1231,12 @@ MCAuto MEDFileFields::partOfThisLyingOnSpecifiedMeshSEName(const void MEDFileFields::aggregate(const MEDFileFields& other) { - int nbFieldsToAdd(other.getNumberOfFields()); + int const nbFieldsToAdd(other.getNumberOfFields()); std::vector fsn(getFieldsNames()); for(int i=0;i elt(other.getFieldAtPos(i)); - std::string name(elt->getName()); + std::string const name(elt->getName()); if(std::find(fsn.begin(),fsn.end(),name)!=fsn.end()) { std::ostringstream oss; oss << "MEDFileFields::aggregate : name \"" << name << "\" already appears !"; @@ -1236,14 +1253,14 @@ MEDFileFieldsIterator *MEDFileFields::iterator() int MEDFileFields::getPosFromFieldName(const std::string& fieldName) const { - std::string tmp(fieldName); + std::string const tmp(fieldName); std::vector poss; for(unsigned int i=0;i<_fields.size();i++) { const MEDFileAnyTypeFieldMultiTSWithoutSDA *f(_fields[i]); if(f) { - std::string fname(f->getName()); + std::string const fname(f->getName()); if(tmp==fname) return i; else @@ -1266,8 +1283,7 @@ MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id } MEDFileFieldsIterator::~MEDFileFieldsIterator() -{ -} += default; MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt() { @@ -1277,8 +1293,8 @@ MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt() if(fs) return fs->getFieldAtPos(_iter_id++); else - return 0; + return nullptr; } else - return 0; + return nullptr; } diff --git a/src/MEDLoader/MEDFileField.hxx b/src/MEDLoader/MEDFileField.hxx index d0a9e880f..83415546b 100644 --- a/src/MEDLoader/MEDFileField.hxx +++ b/src/MEDLoader/MEDFileField.hxx @@ -20,6 +20,8 @@ #pragma once +#include "MEDFileUtilities.hxx" +#include "MCType.hxx" #include "MEDLoaderDefines.hxx" #include "MEDFileFieldInternal.hxx" @@ -28,23 +30,21 @@ #include "MEDFileFieldMultiTS.hxx" #include "MEDFileFieldOverView.hxx" -#include "MEDFileUtilities.txx" #include "MEDFileEntities.hxx" #include "MCAuto.hxx" -#include "MEDLoaderTraits.hxx" #include "MEDCouplingTraits.hxx" #include "MEDCouplingRefCountObject.hxx" #include "MEDCouplingMemArray.hxx" -#include "MEDCouplingPartDefinition.hxx" -#include "NormalizedUnstructuredMesh.hxx" -#include "InterpKernelException.hxx" +#include "NormalizedGeometricTypes" +#include +#include +#include +#include #include #include -#include -#include #include "med.h" @@ -76,13 +76,13 @@ namespace MEDCoupling MEDLOADER_EXPORT static MEDFileFields *NewWithDynGT(med_idt fid, const MEDFileStructureElements *se, bool loadAll=true); MEDLOADER_EXPORT static MEDFileFields *New(DataArrayByte *db) { return BuildFromMemoryChunk(db); } MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileFields"); } - MEDLOADER_EXPORT static MEDFileFields *LoadPartOf(const std::string& fileName, bool loadAll=true, const MEDFileMeshes *ms=0); + MEDLOADER_EXPORT static MEDFileFields *LoadPartOf(const std::string& fileName, bool loadAll=true, const MEDFileMeshes *ms=nullptr); MEDLOADER_EXPORT static MEDFileFields *LoadSpecificEntities(const std::string& fileName, const std::vector< std::pair >& entities, bool loadAll=true); - MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; - MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const; + MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const override; + MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const override; MEDLOADER_EXPORT MEDFileFields *deepCopy() const; MEDLOADER_EXPORT MEDFileFields *shallowCpy() const; - MEDLOADER_EXPORT void writeLL(med_idt fid) const; + MEDLOADER_EXPORT void writeLL(med_idt fid) const override; MEDLOADER_EXPORT void loadArrays(); MEDLOADER_EXPORT void loadArraysIfNecessary(); MEDLOADER_EXPORT void unloadArrays(); @@ -127,14 +127,14 @@ namespace MEDCoupling public: MEDLOADER_EXPORT MEDFileFields *extractPart(const std::map >& extractDef, MEDFileMesh *mm) const; public: - MEDLOADER_EXPORT std::vector getPflsReallyUsed() const; - MEDLOADER_EXPORT std::vector getLocsReallyUsed() const; - MEDLOADER_EXPORT std::vector getPflsReallyUsedMulti() const; - MEDLOADER_EXPORT std::vector getLocsReallyUsedMulti() const; - MEDLOADER_EXPORT void changePflsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif); - MEDLOADER_EXPORT void changeLocsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif); + MEDLOADER_EXPORT std::vector getPflsReallyUsed() const override; + MEDLOADER_EXPORT std::vector getLocsReallyUsed() const override; + MEDLOADER_EXPORT std::vector getPflsReallyUsedMulti() const override; + MEDLOADER_EXPORT std::vector getLocsReallyUsedMulti() const override; + MEDLOADER_EXPORT void changePflsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif) override; + MEDLOADER_EXPORT void changeLocsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif) override; private: - ~MEDFileFields() { } + ~MEDFileFields() override = default; MEDFileFields(); MEDFileFields(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities); private: diff --git a/src/MEDLoader/MEDFileField.txx b/src/MEDLoader/MEDFileField.txx index a6814f4b4..69cfd3b8b 100644 --- a/src/MEDLoader/MEDFileField.txx +++ b/src/MEDLoader/MEDFileField.txx @@ -20,6 +20,12 @@ #pragma once +#include "MEDCouplingMemArray.hxx" +#include "MCType.hxx" +#include "MCAuto.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include "MEDFileEntities.hxx" +#include "InterpKernelAutoPtr.hxx" #include "MEDFileField.hxx" #include "MEDCouplingTraits.hxx" #include "MEDCouplingFieldInt32.hxx" @@ -27,6 +33,19 @@ #include "MEDCouplingFieldFloat.hxx" #include "MEDCouplingFieldDouble.hxx" #include "MEDCouplingFieldTemplate.hxx" +#include "MEDFileField1TS.hxx" +#include +#include +#include "NormalizedGeometricTypes" +#include "MEDLoaderTraits.hxx" +#include +#include "MEDFileFieldInternal.hxx" +#include +#include "MEDFileUtilities.hxx" +#include "med.h" +#include +#include +#include "MEDFileFieldMultiTS.hxx" namespace MEDCoupling { @@ -39,7 +58,7 @@ namespace MEDCoupling _arr=0; return ; } - typename Traits::ArrayType *arrC=dynamic_cast::ArrayType *>(arr); + auto *arrC=dynamic_cast::ArrayType *>(arr); if(!arrC) throw INTERP_KERNEL::Exception("MEDFileField1TSTemplateWithoutSDA::setArray : the input not null array is not of type DataArrayDouble !"); else @@ -191,11 +210,11 @@ namespace MEDCoupling _arr=Traits::ArrayType::New(); _arr->alloc(start,nbCompo); _arr->copyStringInfoFrom(*arr); start=0; - for(std::vector > >::const_iterator it=extractInfo.begin();it!=extractInfo.end();it++) + for(const auto & it : extractInfo) { - const DataArray *zeArr(das[(*it).first]); - _arr->setContigPartOfSelectedValuesSlice(start,zeArr,(*it).second.first,(*it).second.second,1); - start+=(*it).second.second-(*it).second.first; + const DataArray *zeArr(das[it.first]); + _arr->setContigPartOfSelectedValuesSlice(start,zeArr,it.second.first,it.second.second,1); + start+=it.second.second-it.second.first; } // see definition of _nb_of_tuples_to_be_allocated. array is built from scratch and allocated. _nb_of_tuples_to_be_allocated=-3; @@ -350,7 +369,7 @@ namespace MEDCoupling const MEDFileAnyTypeField1TSWithoutSDA *pt(_content); if(!pt) throw INTERP_KERNEL::Exception("MEDFileTemplateField1TS::contentNotNull : the content pointer is null !"); - const typename MLFieldTraits::F1TSWSDAType *ret(dynamic_cast::F1TSWSDAType *>(pt)); + const auto *ret(dynamic_cast::F1TSWSDAType *>(pt)); if(!ret) { std::ostringstream oss; oss << "MEDFileTemplateField1TS::contentNotNull : the content pointer is not null but it is not of type double ! Reason is maybe that the read field has not the type " << MLFieldTraits::F1TSWSDAType::TYPE_STR; @@ -365,7 +384,7 @@ namespace MEDCoupling MEDFileAnyTypeField1TSWithoutSDA *pt(_content); if(!pt) throw INTERP_KERNEL::Exception("MEDFileTemplateField1TS::contentNotNull : the non const content pointer is null !"); - typename MLFieldTraits::F1TSWSDAType *ret(dynamic_cast::F1TSWSDAType *>(pt)); + auto *ret(dynamic_cast::F1TSWSDAType *>(pt)); if(!ret) { std::ostringstream oss; oss << "MEDFileTemplateField1TS::contentNotNull : the non const content pointer is not null but it is not of type double ! Reason is maybe that the read field has not the type " << MLFieldTraits::F1TSWSDAType::TYPE_STR; @@ -435,8 +454,8 @@ namespace MEDCoupling if(arr.isNull()) throw INTERP_KERNEL::Exception("MEDFileTemplateField1TS::SetDataArrayInField : no array !"); int t1,t2; - double t0(f->getTime(t1,t2)); - std::string tu(f->getTimeUnit()); + double const t0(f->getTime(t1,t2)); + std::string const tu(f->getTimeUnit()); MCAuto::ArrayType> arr2(DynamicCastSafe::ArrayType>(arr)); MCAuto ft(MEDCouplingFieldTemplate::New(*f)); MCAuto::FieldType> ret(Traits::FieldType::New(*ft)); @@ -723,22 +742,22 @@ namespace MEDCoupling if(!mm) throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : input mesh is NULL !"); MCAuto::F1TSType> ret(MLFieldTraits::F1TSType::New()); - std::vector tof(getTypesOfFieldAvailable()); - for(std::vector::const_iterator it0=tof.begin();it0!=tof.end();it0++) + std::vector const tof(getTypesOfFieldAvailable()); + for(auto it0 : tof) { - if((*it0)!=ON_NODES) + if(it0!=ON_NODES) { std::vector levs; getNonEmptyLevels(mm->getName(),levs); - for(std::vector::const_iterator lev=levs.begin();lev!=levs.end();lev++) + for(int const lev : levs) { - std::map >::const_iterator it2(extractDef.find(*lev)); + auto const it2(extractDef.find(lev)); if(it2!=extractDef.end()) { MCAuto t((*it2).second); if(t.isNull()) throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a value with null pointer 1 !"); - MCAuto::FieldType> f(getFieldOnMeshAtLevel(ON_CELLS,(*lev),mm)); + MCAuto::FieldType> f(getFieldOnMeshAtLevel(ON_CELLS,lev,mm)); MCAuto::FieldType> fOut(f->buildSubPart(t)); ret->setFieldNoProfileSBT(fOut); } @@ -746,7 +765,7 @@ namespace MEDCoupling } else { - std::map >::const_iterator it2(extractDef.find(1)); + auto const it2(extractDef.find(1)); if(it2==extractDef.end()) throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a NODE field and no extract array available for NODE !"); MCAuto t((*it2).second); @@ -811,7 +830,7 @@ namespace MEDCoupling { if(!f1ts) throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !"); - const typename MLFieldTraits::F1TSWSDAType *f1tsC(dynamic_cast::F1TSWSDAType *>(f1ts)); + const auto *f1tsC(dynamic_cast::F1TSWSDAType *>(f1ts)); if(!f1tsC) { std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a " << MLFieldTraits::F1TSWSDAType::TYPE_STR << " type !"; @@ -845,7 +864,7 @@ namespace MEDCoupling MCAuto ret(new MEDFileFieldMultiTSWithoutSDA); ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this); int i=0; - for(std::vector< MCAuto >::const_iterator it=this->_time_steps.begin();it!=this->_time_steps.end();it++,i++) + for(auto it=this->_time_steps.begin();it!=this->_time_steps.end();it++,i++) { const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it); if(eltToConv) @@ -895,7 +914,7 @@ namespace MEDCoupling if(!mm) throw INTERP_KERNEL::Exception("MEDFileTemplateFieldMultiTS::extractPart : mesh is null !"); MCAuto::FMTSType> fmtsOut(MLFieldTraits::FMTSType::New()); - int nbTS(getNumberOfTS()); + int const nbTS(getNumberOfTS()); for(int i=0;i f1ts(getTimeStepAtPos(i)); @@ -1272,7 +1291,7 @@ namespace MEDCoupling const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content); if(!pt) throw INTERP_KERNEL::Exception("MEDFileTemplateFieldMultiTS::contentNotNull : the content pointer is null !"); - const typename MLFieldTraits::FMTSWSDAType *ret=dynamic_cast::FMTSWSDAType *>(pt); + const auto *ret=dynamic_cast::FMTSWSDAType *>(pt); if(!ret) throw INTERP_KERNEL::Exception("MEDFileTemplateFieldMultiTS::contentNotNull : the content pointer is not null but it is not of type double ! Reason is maybe that the read field has not the type FLOAT64 !"); return ret; @@ -1306,7 +1325,7 @@ namespace MEDCoupling std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !"; throw INTERP_KERNEL::Exception(oss.str()); } - const typename MLFieldTraits::F1TSWSDAType *itemC=dynamic_cast::F1TSWSDAType *>(item); + const auto *itemC=dynamic_cast::F1TSWSDAType *>(item); if(itemC) { MCAuto::F1TSType> ret(MLFieldTraits::F1TSType::New(*itemC,false)); @@ -1358,7 +1377,7 @@ namespace MEDCoupling { if(!f1ts) throw INTERP_KERNEL::Exception("MEDFileTemplateFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !"); - const typename MLFieldTraits::F1TSType *f1tsC=dynamic_cast::F1TSType *>(f1ts); + const auto *f1tsC=dynamic_cast::F1TSType *>(f1ts); if(!f1tsC) { std::ostringstream oss; oss << "MEDFileTemplateFieldMultiTS::checkCoherencyOfType : the input field1TS is not a " << MLFieldTraits::F1TSWSDAType::TYPE_STR << " type !"; @@ -1383,7 +1402,7 @@ namespace MEDCoupling const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(this->_content); if(content) { - const typename MLFieldTraits::FMTSWSDAType *contc=dynamic_cast::FMTSWSDAType *>(content); + const auto *contc=dynamic_cast::FMTSWSDAType *>(content); if(!contc) throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !"); MCAuto newc(contc->convertToDouble()); diff --git a/src/MEDLoader/MEDFileField1TS.cxx b/src/MEDLoader/MEDFileField1TS.cxx index 8628c2592..1927a5f91 100644 --- a/src/MEDLoader/MEDFileField1TS.cxx +++ b/src/MEDLoader/MEDFileField1TS.cxx @@ -19,13 +19,45 @@ // Author : Anthony Geay (EDF R&D) #include "MEDFileField1TS.hxx" +#include "MCType.hxx" +#include "MCAuto.hxx" +#include "MEDCouplingMemArray.hxx" +#include "MEDFileFieldGlobs.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include "MCIdType.hxx" +#include "CellModel.hxx" +#include "MEDCouplingMesh.hxx" +#include "MEDFileEntities.hxx" +#include "InterpKernelAutoPtr.hxx" +#include "MEDFileBasis.hxx" +#include "MEDCouplingPartDefinition.hxx" +#include "MEDCouplingFieldDiscretization.hxx" +#include "MEDFileFieldInternal.hxx" #include "MEDFileFieldVisitor.hxx" +#include "MEDFileMesh.hxx" #include "MEDFileSafeCaller.txx" +#include "MEDFileUtilities.hxx" #include "MEDLoaderBase.hxx" #include "MEDFileField.txx" #include "MEDCouplingFieldTemplate.hxx" #include "MEDCouplingFieldDouble.hxx" +#include "MEDCouplingFieldInt32.hxx" +#include "MEDCouplingFieldInt64.hxx" +#include "NormalizedGeometricTypes" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "med.h" +#include "medfield.h" +#include using namespace MEDCoupling; @@ -57,7 +89,7 @@ void MEDFileAnyTypeField1TSWithoutSDA::deepCpyLeavesFrom(const MEDFileAnyTypeFie { _field_per_mesh.resize(other._field_per_mesh.size()); std::size_t i=0; - for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=other._field_per_mesh.begin();it!=other._field_per_mesh.end();it++,i++) + for(auto it=other._field_per_mesh.begin();it!=other._field_per_mesh.end();it++,i++) { if((const MEDFileFieldPerMesh *)*it) _field_per_mesh[i]=(*it)->deepCopy(this); @@ -66,12 +98,12 @@ void MEDFileAnyTypeField1TSWithoutSDA::deepCpyLeavesFrom(const MEDFileAnyTypeFie void MEDFileAnyTypeField1TSWithoutSDA::accept(MEDFileFieldVisitor& visitor) const { - for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++) - if((*it).isNotNull()) + for(const auto & it : _field_per_mesh) + if(it.isNotNull()) { - visitor.newMeshEntry(*it); - (*it)->accept(visitor); - visitor.endMeshEntry(*it); + visitor.newMeshEntry(it); + it->accept(visitor); + visitor.endMeshEntry(it); } } @@ -85,7 +117,7 @@ void MEDFileAnyTypeField1TSWithoutSDA::accept(MEDFileFieldVisitor& visitor) cons */ void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const { - std::string startOfLine(bkOffset,' '); + std::string const startOfLine(bkOffset,' '); oss << startOfLine << "Field "; if(bkOffset==0) oss << "[Type=" << getTypeStr() << "] with name \"" << getName() << "\" "; @@ -101,8 +133,8 @@ void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& os if(f1tsId<0) { oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl; - for(std::vector::const_iterator it=comps.begin();it!=comps.end();it++) - oss << startOfLine << " - \"" << (*it) << "\"" << std::endl; + for(const auto & comp : comps) + oss << startOfLine << " - \"" << comp << "\"" << std::endl; } if(arr->isAllocated()) { @@ -119,7 +151,7 @@ void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& os if(!_field_per_mesh.empty()) { int i=0; - for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++) + for(auto it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++) { const MEDFileFieldPerMesh *cur=(*it2); if(cur) @@ -140,12 +172,12 @@ std::vector< MCAuto > MEDFileAnyTypeField1TSWi const DataArray *arr(getUndergroundDataArray()); if(!arr) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !"); - std::size_t nbOfCompo=arr->getNumberOfComponents(); + std::size_t const nbOfCompo=arr->getNumberOfComponents(); std::vector< MCAuto > ret(nbOfCompo); for(std::size_t i=0;i v(1,i); + std::vector const v(1,i); MCAuto arr2=arr->keepSelectedComponents(v); ret[i]->setArray(arr2); } @@ -168,17 +200,17 @@ MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration( int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const { int ret=-2; - for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++) - (*it)->getDimension(ret); + for(const auto & it : _field_per_mesh) + it->getDimension(ret); return ret; } bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair >& modifTab) { bool ret=false; - for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++) + for(auto & it : _field_per_mesh) { - MEDFileFieldPerMesh *cur(*it); + MEDFileFieldPerMesh *cur(it); if(cur) ret=cur->changeMeshNames(modifTab) || ret; } @@ -254,11 +286,11 @@ void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair& p) cons void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector& types) const { std::set types2; - for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++) + for(const auto & it : _field_per_mesh) { - (*it)->fillTypesOfFieldAvailable(types2); + it->fillTypesOfFieldAvailable(types2); } - std::back_insert_iterator< std::vector > bi(types); + std::back_insert_iterator< std::vector > const bi(types); std::copy(types2.begin(),types2.end(),bi); } @@ -278,14 +310,14 @@ std::vector MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() { std::vector ret; std::set ret2; - for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++) + for(const auto & it : _field_per_mesh) { - std::vector tmp=(*it)->getPflsReallyUsed(); - for(std::vector::const_iterator it2=tmp.begin();it2!=tmp.end();it2++) - if(ret2.find(*it2)==ret2.end()) + std::vector const tmp=it->getPflsReallyUsed(); + for(const auto & it2 : tmp) + if(ret2.find(it2)==ret2.end()) { - ret.push_back(*it2); - ret2.insert(*it2); + ret.push_back(it2); + ret2.insert(it2); } } return ret; @@ -295,14 +327,14 @@ std::vector MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() { std::vector ret; std::set ret2; - for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++) + for(const auto & it : _field_per_mesh) { - std::vector tmp=(*it)->getLocsReallyUsed(); - for(std::vector::const_iterator it2=tmp.begin();it2!=tmp.end();it2++) - if(ret2.find(*it2)==ret2.end()) + std::vector const tmp=it->getLocsReallyUsed(); + for(const auto & it2 : tmp) + if(ret2.find(it2)==ret2.end()) { - ret.push_back(*it2); - ret2.insert(*it2); + ret.push_back(it2); + ret2.insert(it2); } } return ret; @@ -311,9 +343,9 @@ std::vector MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() std::vector MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMulti2() const { std::vector ret; - for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++) + for(const auto & it : _field_per_mesh) { - std::vector tmp=(*it)->getPflsReallyUsedMulti(); + std::vector tmp=it->getPflsReallyUsedMulti(); ret.insert(ret.end(),tmp.begin(),tmp.end()); } return ret; @@ -322,10 +354,10 @@ std::vector MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMult std::vector MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const { std::vector ret; - std::set ret2; - for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++) + std::set const ret2; + for(const auto & it : _field_per_mesh) { - std::vector tmp=(*it)->getLocsReallyUsedMulti(); + std::vector tmp=it->getLocsReallyUsedMulti(); ret.insert(ret.end(),tmp.begin(),tmp.end()); } return ret; @@ -333,14 +365,14 @@ std::vector MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMult void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair, std::string > >& mapOfModif) { - for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++) - (*it)->changePflsRefsNamesGen(mapOfModif); + for(auto & it : _field_per_mesh) + it->changePflsRefsNamesGen(mapOfModif); } void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair, std::string > >& mapOfModif) { - for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++) - (*it)->changeLocsRefsNamesGen(mapOfModif); + for(auto & it : _field_per_mesh) + it->changeLocsRefsNamesGen(mapOfModif); } /*! @@ -373,7 +405,7 @@ void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector * Length of this and of nested sequences is the same as that of \a typesF. * \throw If no field is lying on \a mname. */ -std::vector< std::vector< std::pair > > MEDFileAnyTypeField1TSWithoutSDA::getFieldSplitedByType(const std::string& mname, std::vector& types, std::vector< std::vector >& typesF, std::vector< std::vector >& pfls, std::vector< std::vector >& locs) const +std::vector< std::vector< std::pair > > MEDFileAnyTypeField1TSWithoutSDA::getFieldSplitedByType(const std::string& /*mname*/, std::vector& types, std::vector< std::vector >& typesF, std::vector< std::vector >& pfls, std::vector< std::vector >& locs) const { if(_field_per_mesh.empty()) throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !"); @@ -421,7 +453,7 @@ std::vector< std::vector< std::pair > > MEDFileAnyTypeField1T * \return int - the maximal absolute dimension of elements \a this fields lies on. * \throw If no field is lying on \a mname. */ -int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const std::string& mname, std::vector& levs) const +int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const std::string& /*mname*/, std::vector& levs) const { levs.clear(); std::vector types; @@ -437,12 +469,12 @@ int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const std::string& mname return -1; st.erase(INTERP_KERNEL::NORM_ERROR); std::set ret1; - for(std::set::const_iterator it=st.begin();it!=st.end();it++) + for(auto it : st) { - const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it); + const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(it); ret1.insert((int)cm.getDimension()); } - int ret=*std::max_element(ret1.begin(),ret1.end()); + int const ret=*std::max_element(ret1.begin(),ret1.end()); std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator >(levs)); std::transform(levs.begin(),levs.end(),levs.begin(),std::bind(std::plus(),std::placeholders::_1,-ret)); return ret; @@ -450,7 +482,7 @@ int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const std::string& mname void MEDFileAnyTypeField1TSWithoutSDA::convertMedBallIntoClassic() { - for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it<_field_per_mesh.end();it++) + for(auto it=_field_per_mesh.begin();it<_field_per_mesh.end();it++) if((*it).isNotNull()) (*it)->convertMedBallIntoClassic(); } @@ -459,7 +491,7 @@ void MEDFileAnyTypeField1TSWithoutSDA::makeReduction(INTERP_KERNEL::NormalizedCe { if(!pfl) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : null pfl !"); - std::string name(pfl->getName()); + std::string const name(pfl->getName()); pfl->checkAllocated(); if(pfl->getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : non mono compo array !"); @@ -497,7 +529,7 @@ void MEDFileAnyTypeField1TSWithoutSDA::makeReduction(INTERP_KERNEL::NormalizedCe * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0. */ -MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) +MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& /*mName*/, INTERP_KERNEL::NormalizedCellType typ, int locId) { if(_field_per_mesh.empty()) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId : This is empty !"); @@ -510,7 +542,7 @@ MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGive * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0. */ -const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const +const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& /*mName*/, INTERP_KERNEL::NormalizedCellType typ, int locId) const { if(_field_per_mesh.empty()) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId : This is empty !"); @@ -526,18 +558,18 @@ int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const std::string& m throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !"); if(mName.empty()) return 0; - std::string mName2(mName); + std::string const mName2(mName); int ret=0; std::vector msg; - for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++) + for(auto it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++) if(mName2==(*it)->getMeshName()) return ret; else msg.push_back((*it)->getMeshName()); std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n"; oss << "Possible meshes are : "; - for(std::vector::const_iterator it2=msg.begin();it2!=msg.end();it2++) - oss << "\"" << (*it2) << "\" "; + for(const auto & it2 : msg) + oss << "\"" << it2 << "\" "; throw INTERP_KERNEL::Exception(oss.str()); } @@ -545,7 +577,7 @@ int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMe { if(!mesh) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !"); - std::string tmp(mesh->getName()); + std::string const tmp(mesh->getName()); if(tmp.empty()) throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !"); setMeshName(tmp); @@ -556,7 +588,7 @@ int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMe if((*it)->getMeshName()==tmp) return i; } - std::size_t sz=_field_per_mesh.size(); + std::size_t const sz=_field_per_mesh.size(); _field_per_mesh.resize(sz+1); _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh); return (int)sz; @@ -566,9 +598,9 @@ bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const std::st MEDFileFieldGlobsReal& glob) { bool ret=false; - for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++) + for(auto & it : _field_per_mesh) { - MEDFileFieldPerMesh *fpm(*it); + MEDFileFieldPerMesh *fpm(it); if(fpm) ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret; } @@ -586,18 +618,18 @@ std::vector< MCAuto > MEDFileAnyTypeField1TSWi std::vector types; std::vector< std::vector > typesF; std::vector< std::vector > pfls,locs; - std::vector< std::vector > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs)); + std::vector< std::vector > > const bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs)); std::set allEnt; - for(std::vector< std::vector >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++) - for(std::vector::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++) - allEnt.insert(*it2); + for(const auto & it1 : typesF) + for(auto it2 : it1) + allEnt.insert(it2); std::vector< MCAuto > ret(allEnt.size()); - std::set::const_iterator it3(allEnt.begin()); + auto it3(allEnt.begin()); for(std::size_t i=0;i > its; ret[i]=shallowCpy(); - mcIdType newLgth(ret[i]->keepOnlySpatialDiscretization(*it3,its)); + mcIdType const newLgth(ret[i]->keepOnlySpatialDiscretization(*it3,its)); ret[i]->updateData(newLgth,its); } return ret; @@ -614,14 +646,14 @@ std::vector< MCAuto > MEDFileAnyTypeField1TSWi std::vector types; std::vector< std::vector > typesF; std::vector< std::vector > pfls,locs; - std::vector< std::vector > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs)); + std::vector< std::vector > > const bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs)); std::set allEnt; std::size_t nbOfMDPGT(0),ii(0); for(std::vector< std::vector >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++,ii++) { nbOfMDPGT=std::max(nbOfMDPGT,locs[ii].size()); - for(std::vector::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++) - allEnt.insert(*it2); + for(auto it2 : *it1) + allEnt.insert(it2); } if(allEnt.size()!=1) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : this field is expected to be defined only on one spatial discretization !"); @@ -638,7 +670,7 @@ std::vector< MCAuto > MEDFileAnyTypeField1TSWi { std::vector< std::pair > its; ret[i]=shallowCpy(); - mcIdType newLgth(ret[i]->keepOnlyGaussDiscretization(i,its)); + mcIdType const newLgth(ret[i]->keepOnlyGaussDiscretization(i,its)); ret[i]->updateData(newLgth,its); } return ret; @@ -647,16 +679,16 @@ std::vector< MCAuto > MEDFileAnyTypeField1TSWi mcIdType MEDFileAnyTypeField1TSWithoutSDA::keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair >& its) { mcIdType globalCounter(0); - for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++) - (*it)->keepOnlySpatialDiscretization(tof,globalCounter,its); + for(auto & it : _field_per_mesh) + it->keepOnlySpatialDiscretization(tof,globalCounter,its); return globalCounter; } mcIdType MEDFileAnyTypeField1TSWithoutSDA::keepOnlyGaussDiscretization(std::size_t idOfDisc, std::vector< std::pair >& its) { mcIdType globalCounter(0); - for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++) - (*it)->keepOnlyGaussDiscretization(idOfDisc,globalCounter,its); + for(auto & it : _field_per_mesh) + it->keepOnlyGaussDiscretization(idOfDisc,globalCounter,its); return globalCounter; } @@ -687,12 +719,12 @@ void MEDFileAnyTypeField1TSWithoutSDA::updateData(mcIdType newLgth, const std::v if(oldArr) newArr->copyStringInfoFrom(*oldArr); mcIdType pos=0; - for(std::vector< std::pair >::const_iterator it=oldStartStops.begin();it!=oldStartStops.end();it++) + for(const auto & oldStartStop : oldStartStops) { - if((*it).second<(*it).first) + if(oldStartStop.secondsetContigPartOfSelectedValuesSlice(pos,oldArr,(*it).first,(*it).second,1); - pos+=(*it).second-(*it).first; + newArr->setContigPartOfSelectedValuesSlice(pos,oldArr,oldStartStop.first,oldStartStop.second,1); + pos+=oldStartStop.second-oldStartStop.first; } setArray(newArr); return ; @@ -715,7 +747,7 @@ void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritabl */ std::string MEDFileAnyTypeField1TSWithoutSDA::FieldNameToMEDFileConvention(const std::string& nonCorrectFieldName) { - std::string::size_type pos0(nonCorrectFieldName.find_last_not_of(' ')); + std::string::size_type const pos0(nonCorrectFieldName.find_last_not_of(' ')); if(pos0==std::string::npos) return nonCorrectFieldName; if(pos0+1==nonCorrectFieldName.length()) @@ -761,7 +793,7 @@ void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_id throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !"); _field_per_mesh.resize(1); // - MEDFileMesh *mm(0); + MEDFileMesh *mm(nullptr); if(ms) { mm=ms->getMeshWithName(getMeshName()); @@ -796,27 +828,27 @@ void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_id void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) { allocIfNecessaryTheArrayToReceiveDataFromFile(); - for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++) - (*it)->loadBigArraysRecursively(fid,nasc); + for(auto & it : _field_per_mesh) + it->loadBigArraysRecursively(fid,nasc); } void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc) { if(allocIfNecessaryTheArrayToReceiveDataFromFile()) - for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++) - (*it)->loadBigArraysRecursively(fid,nasc); + for(auto & it : _field_per_mesh) + it->loadBigArraysRecursively(fid,nasc); } void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities) { - MEDFileCapability cap(fid); + MEDFileCapability const cap(fid); loadOnlyStructureOfDataRecursively(fid,nasc,ms,entities,&cap); loadBigArraysRecursively(fid,nasc); } void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const PartDefinition *pd, const MEDFileEntities *entities) { - MEDFileCapability cap(fid); + MEDFileCapability const cap(fid); loadOnlyStructureOfDataRecursively(fid,nasc,pd,entities,&cap); loadBigArraysRecursively(fid,nasc); } @@ -841,8 +873,8 @@ std::vector MEDFileAnyTypeField1TSWithoutSDA::getDirect std::vector ret; if(getUndergroundDataArray()) ret.push_back(getUndergroundDataArray()); - for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++) - ret.push_back((const MEDFileFieldPerMesh *)*it); + for(const auto & it : _field_per_mesh) + ret.push_back((const MEDFileFieldPerMesh *)it); return ret; } @@ -865,15 +897,15 @@ void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const TimeHolder *th { const MEDCouplingMesh *mesh(field->getMesh()); // - TypeOfField type(field->getTypeOfField()); - std::vector dummy; + TypeOfField const type(field->getTypeOfField()); + std::vector const dummy; if(mesh) setMeshName(mesh->getName()); mcIdType start(copyTinyInfoFrom(th,field,arr)); - int pos(addNewEntryIfNecessary(mesh)); + int const pos(addNewEntryIfNecessary(mesh)); if(type!=ON_NODES) { - std::vector code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh); + std::vector const code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh); _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc); } else @@ -911,7 +943,7 @@ void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const TimeHolder *th, con throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input field is null !"); if(!arrOfVals || !arrOfVals->isAllocated()) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input array is null or not allocated !"); - TypeOfField type=field->getTypeOfField(); + TypeOfField const type=field->getTypeOfField(); std::vector idsInPflPerType; std::vector idsPerType; std::vector code,code2; @@ -924,7 +956,7 @@ void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const TimeHolder *th, con std::vector idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin()); // start of check MCAuto field2=field->clone(false); - mcIdType nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3); + mcIdType const nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3); if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples()) { std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : The array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !"; @@ -934,7 +966,7 @@ void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const TimeHolder *th, con mcIdType start(copyTinyInfoFrom(th,field,arrOfVals)); code2=m->getDistributionOfTypes(); // - mcIdType pos=addNewEntryIfNecessary(m); + mcIdType const pos=addNewEntryIfNecessary(m); _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc); } else @@ -943,14 +975,14 @@ void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const TimeHolder *th, con throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input profile is null, not allocated or with number of components != 1 !"); std::vector v(3); v[0]=-1; v[1]=profile->getNumberOfTuples(); v[2]=0; std::vector idsPerType3(1); idsPerType3[0]=profile; - mcIdType nbOfTuplesExp=field->getNumberOfTuplesExpectedRegardingCode(v,idsPerType3); + mcIdType const nbOfTuplesExp=field->getNumberOfTuplesExpectedRegardingCode(v,idsPerType3); if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples()) { std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : For node field, the array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !"; throw INTERP_KERNEL::Exception(oss.str()); } mcIdType start(copyTinyInfoFrom(th,field,arrOfVals)); - mcIdType pos(addNewEntryIfNecessary(m)); + mcIdType const pos(addNewEntryIfNecessary(m)); _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc); } } @@ -983,7 +1015,7 @@ mcIdType MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const TimeHolder *th { if(!field) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !"); - std::string name(field->getName()); + std::string const name(field->getName()); setName(name.c_str()); if(field->getMesh()) setMeshName(field->getMesh()->getName()); @@ -1003,8 +1035,8 @@ mcIdType MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const TimeHolder *th } else { - mcIdType oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples(); - mcIdType newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples(); + mcIdType const oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples(); + mcIdType const newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples(); getOrCreateAndGetArray()->reAlloc(newNbOfTuples); _nb_of_tuples_to_be_allocated=-3; return oldNbOfTuples; @@ -1054,9 +1086,9 @@ std::vector& MEDFileAnyTypeField1TSWithoutSDA::getInfo() bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfMultiDiscPerGeoType() const { - for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++) + for(const auto & it : _field_per_mesh) { - const MEDFileFieldPerMesh *fpm(*it); + const MEDFileFieldPerMesh *fpm(it); if(!fpm) continue; if(fpm->presenceOfMultiDiscPerGeoType()) @@ -1067,48 +1099,48 @@ bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfMultiDiscPerGeoType() const bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfStructureElements() const { - for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++) - if((*it).isNotNull()) - if((*it)->presenceOfStructureElements()) + for(const auto & it : _field_per_mesh) + if(it.isNotNull()) + if(it->presenceOfStructureElements()) return true; return false; } bool MEDFileAnyTypeField1TSWithoutSDA::onlyStructureElements() const { - for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++) - if((*it).isNotNull()) - if(!(*it)->onlyStructureElements()) + for(const auto & it : _field_per_mesh) + if(it.isNotNull()) + if(!it->onlyStructureElements()) return false; return true; } void MEDFileAnyTypeField1TSWithoutSDA::killStructureElements() { - for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++) - if((*it).isNotNull()) - (*it)->killStructureElements(); + for(auto & it : _field_per_mesh) + if(it.isNotNull()) + it->killStructureElements(); } void MEDFileAnyTypeField1TSWithoutSDA::keepOnlyStructureElements() { - for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++) - if((*it).isNotNull()) - (*it)->keepOnlyStructureElements(); + for(auto & it : _field_per_mesh) + if(it.isNotNull()) + it->keepOnlyStructureElements(); } void MEDFileAnyTypeField1TSWithoutSDA::keepOnlyOnSE(const std::string& seName) { - for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++) - if((*it).isNotNull()) - (*it)->keepOnlyOnSE(seName); + for(auto & it : _field_per_mesh) + if(it.isNotNull()) + it->keepOnlyOnSE(seName); } void MEDFileAnyTypeField1TSWithoutSDA::getMeshSENames(std::vector< std::pair >& ps) const { - for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++) - if((*it).isNotNull()) - (*it)->getMeshSENames(ps); + for(const auto & it : _field_per_mesh) + if(it.isNotNull()) + it->getMeshSENames(ps); } MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh(const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto& arrOut, const MEDFileFieldNameScope& nasc) const @@ -1125,14 +1157,14 @@ MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh(const MEDF pm->fillTypesOfFieldAvailable(types); if(types.size()!=1) throw INTERP_KERNEL::Exception(MSG0); - TypeOfField type(*types.begin()); + TypeOfField const type(*types.begin()); int meshDimRelToMax(0); if(type==ON_NODES) meshDimRelToMax=0; else { int myDim(std::numeric_limits::max()); - bool isUnique(pm->isUniqueLevel(myDim)); + bool const isUnique(pm->isUniqueLevel(myDim)); if(!isUnique) throw INTERP_KERNEL::Exception(MSG0); meshDimRelToMax=myDim-mesh->getMeshDimension(); @@ -1229,8 +1261,8 @@ MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(Typ mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder()); else mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder()); - int absDim=getDimension(); - int meshDimRelToMax=absDim-mm->getMeshDimension(); + int const absDim=getDimension(); + int const meshDimRelToMax=absDim-mm->getMeshDimension(); return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc); } @@ -1284,7 +1316,7 @@ MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel( } MEDCouplingFieldDiscretization *disc=ret->getDiscretization(); if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !"); - std::vector arrOut2(1,arrOut); + std::vector const arrOut2(1,arrOut); // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true); (const_cast(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true); @@ -1371,13 +1403,13 @@ std::vector MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingM { if(!mesh) throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !"); - std::set geoTypes=mesh->getAllGeoTypes(); - std::size_t nbOfTypes=geoTypes.size(); + std::set const geoTypes=mesh->getAllGeoTypes(); + std::size_t const nbOfTypes=geoTypes.size(); std::vector code(3*nbOfTypes); MCAuto arr1=DataArrayIdType::New(); arr1->alloc(nbOfTypes,1); mcIdType *arrPtr=arr1->getPointer(); - std::set::const_iterator it=geoTypes.begin(); + auto it=geoTypes.begin(); for(std::size_t i=0;i arr2=arr1->checkAndPreparePermutation(); @@ -1385,13 +1417,13 @@ std::vector MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingM int i=0; for(it=geoTypes.begin();it!=geoTypes.end();it++,i++) { - mcIdType pos=arrPtr2[i]; - mcIdType nbCells=mesh->getNumberOfCellsWithType(*it); + mcIdType const pos=arrPtr2[i]; + mcIdType const nbCells=mesh->getNumberOfCellsWithType(*it); code[3*pos]=(mcIdType)(*it); code[3*pos+1]=nbCells; code[3*pos+2]=-1;//no profiles } - std::vector idsPerType;//no profiles + std::vector const idsPerType;//no profiles DataArrayIdType *da=mesh->checkTypeConsistencyAndContig(code,idsPerType); if(da) { @@ -1446,12 +1478,12 @@ std::vector< std::vector > MEDFileField1TSWithoutSDA::getFiel if(_field_per_mesh.empty()) throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !"); std::vector< std::vector< std::pair > > ret0=_field_per_mesh[0]->getFieldSplitedByType(types,typesF,pfls,locs); - std::size_t nbOfRet=ret0.size(); + std::size_t const nbOfRet=ret0.size(); std::vector< std::vector > ret(nbOfRet); for(std::size_t i=0;i >& p=ret0[i]; - std::size_t nbOfRet1=p.size(); + std::size_t const nbOfRet1=p.size(); ret[i].resize(nbOfRet1); for(std::size_t j=0;j& infos):MEDFileField1TSNDTemplateWithoutSDA(fieldName,meshName,csit,iteration,order,infos) @@ -1605,7 +1636,7 @@ DataArrayInt32 *MEDFileInt32Field1TSWithoutSDA::getUndergroundDataArrayIntExt(st { if(_field_per_mesh.size()!=1) throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !"); - if(_field_per_mesh[0]==0) + if(_field_per_mesh[0]==nullptr) throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !"); _field_per_mesh[0]->getUndergroundDataArrayExt(entries); return getUndergroundDataArrayTemplate(); @@ -1634,8 +1665,7 @@ MEDFileInt64Field1TSWithoutSDA *MEDFileInt64Field1TSWithoutSDA::New(const std::s } MEDFileInt64Field1TSWithoutSDA::MEDFileInt64Field1TSWithoutSDA() -{ -} += default; MEDFileInt64Field1TSWithoutSDA::MEDFileInt64Field1TSWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector& infos):MEDFileField1TSNDTemplateWithoutSDA(fieldName,meshName,csit,iteration,order,infos) @@ -1690,7 +1720,7 @@ DataArrayInt64 *MEDFileInt64Field1TSWithoutSDA::getUndergroundDataArrayIntExt(st { if(_field_per_mesh.size()!=1) throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !"); - if(_field_per_mesh[0]==0) + if(_field_per_mesh[0]==nullptr) throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !"); _field_per_mesh[0]->getUndergroundDataArrayExt(entries); return getUndergroundDataArrayTemplate(); @@ -1719,8 +1749,7 @@ MEDFileFloatField1TSWithoutSDA *MEDFileFloatField1TSWithoutSDA::New(const std::s } MEDFileFloatField1TSWithoutSDA::MEDFileFloatField1TSWithoutSDA() -{ -} += default; MEDFileFloatField1TSWithoutSDA::MEDFileFloatField1TSWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector& infos):MEDFileField1TSNDTemplateWithoutSDA(fieldName,meshName,csit,iteration,order,infos) @@ -1775,7 +1804,7 @@ DataArrayFloat *MEDFileFloatField1TSWithoutSDA::getUndergroundDataArrayFloatExt( { if(_field_per_mesh.size()!=1) throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !"); - if(_field_per_mesh[0]==0) + if(_field_per_mesh[0]==nullptr) throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !"); _field_per_mesh[0]->getUndergroundDataArrayExt(entries); return getUndergroundDataArrayTemplate(); @@ -1799,8 +1828,7 @@ MEDFileFloatField1TSWithoutSDA *MEDFileFloatField1TSWithoutSDA::deepCopy() const //= MEDFileAnyTypeField1TS MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS() -{ -} += default; MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::AllocateContentFrom(med_idt fid, const std::string& fieldName, int iteration, int order) { @@ -1884,8 +1912,8 @@ MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::AllocateContentFrom(me if(!found) { std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fName << "' in file '" << FileNameFromFID(fid) << "' ! Available iterations are : "; - for(std::vector< std::pair >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++) - oss << "(" << (*iter).first << "," << (*iter).second << "), "; + for(const auto & dtit : dtits) + oss << "(" << dtit.first << "," << dtit.second << "), "; throw INTERP_KERNEL::Exception(oss.str()); } @@ -1895,7 +1923,7 @@ MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::AllocateContentFrom(me MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities) { - std::string useless; + std::string const useless; MCAuto ret(AllocateContentFrom(fid,useless)); if(loadAll) ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities); @@ -2005,13 +2033,13 @@ MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDF MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, bool loadAll) { - MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + MEDFileUtilities::AutoFid const fid(OpenMEDFileForRead(fileName)); return New(fid,loadAll); } MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, bool loadAll) { - MCAuto c(BuildContentFrom(fid,loadAll,0,0)); + MCAuto c(BuildContentFrom(fid,loadAll,nullptr,nullptr)); MCAuto ret(BuildNewInstanceFromContent(c,fid)); ret->loadGlobals(fid); return ret.retn(); @@ -2020,13 +2048,13 @@ MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, bool loadAll) MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll) { - MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + MEDFileUtilities::AutoFid const fid(OpenMEDFileForRead(fileName)); return New(fid,fieldName,loadAll); } MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll) { - MCAuto c(BuildContentFrom(fid,fieldName,loadAll,0,0)); + MCAuto c(BuildContentFrom(fid,fieldName,loadAll,nullptr,nullptr)); MCAuto ret(BuildNewInstanceFromContent(c,fid)); ret->loadGlobals(fid); return ret.retn(); @@ -2034,13 +2062,13 @@ MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::stri MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll) { - MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + MEDFileUtilities::AutoFid const fid(OpenMEDFileForRead(fileName)); return New(fid,fieldName,iteration,order,loadAll); } MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll) { - MCAuto c(BuildContentFrom(fid,fieldName,iteration,order,loadAll,(const MEDFileMeshes *)0,0)); + MCAuto c(BuildContentFrom(fid,fieldName,iteration,order,loadAll,(const MEDFileMeshes *)nullptr,nullptr)); MCAuto ret(BuildNewInstanceFromContent(c,fid)); ret->loadGlobals(fid); return ret.retn(); @@ -2048,13 +2076,13 @@ MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::stri MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::NewAdv(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileEntities *entities) { - MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + MEDFileUtilities::AutoFid const fid(OpenMEDFileForRead(fileName)); return NewAdv(fid,fieldName,iteration,order,loadAll,entities); } MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::NewAdv(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileEntities *entities) { - MCAuto c(BuildContentFrom(fid,fieldName,iteration,order,loadAll,(const MEDFileMeshes *)0,entities)); + MCAuto c(BuildContentFrom(fid,fieldName,iteration,order,loadAll,(const MEDFileMeshes *)nullptr,entities)); MCAuto ret(BuildNewInstanceFromContent(c,fid)); ret->loadGlobals(fid); return ret.retn(); @@ -2097,14 +2125,14 @@ int MEDFileAnyTypeField1TS::LocateField2(med_idt fid, int fieldIdCFormat, bool c { if(checkFieldId) { - med_int nbFields=MEDnField(fid); + med_int const nbFields=MEDnField(fid); if(fieldIdCFormat>=nbFields) { std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << FileNameFromFID(fid) << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !"; throw INTERP_KERNEL::Exception(oss.str()); } } - med_int ncomp(MEDfieldnComponent(fid,fieldIdCFormat+1)); + med_int const ncomp(MEDfieldnComponent(fid,fieldIdCFormat+1)); INTERP_KERNEL::AutoPtr comp(MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE)); INTERP_KERNEL::AutoPtr unit(MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE)); INTERP_KERNEL::AutoPtr dtunit(MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE)); @@ -2129,7 +2157,7 @@ int MEDFileAnyTypeField1TS::LocateField2(med_idt fid, int fieldIdCFormat, bool c */ int MEDFileAnyTypeField1TS::LocateField(med_idt fid, const std::string& fieldName, int& posCFormat, med_field_type& typcha, std::vector& infos, std::string& dtunitOut, std::string& meshName) { - med_int nbFields=MEDnField(fid); + med_int const nbFields=MEDnField(fid); bool found=false; std::vector fns(nbFields); int nbOfStep2(-1); @@ -2148,8 +2176,8 @@ int MEDFileAnyTypeField1TS::LocateField(med_idt fid, const std::string& fieldNam if(!found) { std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available fields are : "; - for(std::vector::const_iterator it=fns.begin();it!=fns.end();it++) - oss << "\"" << *it << "\" "; + for(const auto & fn : fns) + oss << "\"" << fn << "\" "; throw INTERP_KERNEL::Exception(oss.str()); } return nbOfStep2; @@ -2176,9 +2204,9 @@ int MEDFileAnyTypeField1TS::LocateField(med_idt fid, const std::string& fieldNam void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob) { MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId); - std::string oldPflName=disc->getProfile(); + std::string const oldPflName=disc->getProfile(); std::vector vv=getPflsReallyUsedMulti(); - std::size_t nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName); + std::size_t const nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName); if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1)) { disc->setProfile(newPflName); @@ -2214,9 +2242,9 @@ void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const std::string& mName, INTE void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob) { MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId); - std::string oldLocName=disc->getLocalization(); + std::string const oldLocName=disc->getLocalization(); std::vector vv=getLocsReallyUsedMulti(); - std::size_t nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName); + std::size_t const nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName); if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1)) { disc->setLocalization(newLocName); @@ -2258,7 +2286,7 @@ void MEDFileAnyTypeField1TS::loadArrays() { if(getFileName().empty()) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::loadArrays : the structure does not come from a file !"); - MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName())); + MEDFileUtilities::AutoFid const fid(OpenMEDFileForRead(getFileName())); contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase()); } @@ -2273,7 +2301,7 @@ void MEDFileAnyTypeField1TS::loadArraysIfNecessary() { if(!getFileName().empty()) { - MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName())); + MEDFileUtilities::AutoFid const fid(OpenMEDFileForRead(getFileName())); contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase()); } } @@ -2305,12 +2333,12 @@ void MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss() void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const { - std::size_t nbComp(getNumberOfComponents()); + std::size_t const nbComp(getNumberOfComponents()); INTERP_KERNEL::AutoPtr comp(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE)); INTERP_KERNEL::AutoPtr unit(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE)); for(std::size_t i=0;i > MEDFileAnyTypeField1TS::splitCom if(!content) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !"); std::vector< MCAuto > contentsSplit=content->splitComponents(); - std::size_t sz(contentsSplit.size()); + std::size_t const sz(contentsSplit.size()); std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz); for(std::size_t i=0;i > MEDFileAnyTypeField1TS::splitDis if(!content) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitDiscretizations : no content in this ! Unable to split discretization !"); std::vector< MCAuto > contentsSplit(content->splitDiscretizations()); - std::size_t sz(contentsSplit.size()); + std::size_t const sz(contentsSplit.size()); std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz); for(std::size_t i=0;i > MEDFileAnyTypeField1TS::splitMul if(!content) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretization !"); std::vector< MCAuto > contentsSplit(content->splitMultiDiscrPerGeoTypes()); - std::size_t sz(contentsSplit.size()); + std::size_t const sz(contentsSplit.size()); std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz); for(std::size_t i=0;i(content); + const auto *contc=dynamic_cast(content); if(!contc) throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !"); MCAuto newc(contc->convertToInt()); @@ -2675,7 +2703,7 @@ MEDFileInt64Field1TS *MEDFileField1TS::convertToInt64(bool isDeepCpyGlobs) const const MEDFileAnyTypeField1TSWithoutSDA *content(_content); if(content) { - const MEDFileField1TSWithoutSDA *contc=dynamic_cast(content); + const auto *contc=dynamic_cast(content); if(!contc) throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !"); MCAuto newc(contc->convertToInt64()); @@ -2752,8 +2780,8 @@ MCAuto MEDFileInt32Field1TS::ConvertFieldIntToFieldDoubl if(!f) throw INTERP_KERNEL::Exception("MEDFileInt32Field1TS::ConvertFieldIntToFieldDouble : null input field !"); int t1,t2; - double t0(f->getTime(t1,t2)); - std::string tu(f->getTimeUnit()); + double const t0(f->getTime(t1,t2)); + std::string const tu(f->getTimeUnit()); MCAuto ft(MEDCouplingFieldTemplate::New(*f)); MCAuto ret(MEDCouplingFieldDouble::New(*ft)); ret->setTime(t0,t1,t2); ret->setTimeUnit(tu); @@ -2772,8 +2800,8 @@ MCAuto MEDFileInt64Field1TS::ConvertFieldIntToFieldDoubl if(!f) throw INTERP_KERNEL::Exception("MEDFileInt64Field1TS::ConvertFieldIntToFieldDouble : null input field !"); int t1,t2; - double t0(f->getTime(t1,t2)); - std::string tu(f->getTimeUnit()); + double const t0(f->getTime(t1,t2)); + std::string const tu(f->getTimeUnit()); MCAuto ft(MEDCouplingFieldTemplate::New(*f)); MCAuto ret(MEDCouplingFieldDouble::New(*ft)); ret->setTime(t0,t1,t2); ret->setTimeUnit(tu); diff --git a/src/MEDLoader/MEDFileField1TS.hxx b/src/MEDLoader/MEDFileField1TS.hxx index 007239a91..394ab88d0 100644 --- a/src/MEDLoader/MEDFileField1TS.hxx +++ b/src/MEDLoader/MEDFileField1TS.hxx @@ -21,12 +21,25 @@ #ifndef __MEDFILEFIELD1TS_HXX__ #define __MEDFILEFIELD1TS_HXX__ +#include "MEDCouplingRefCountObject.hxx" +#include "MCType.hxx" +#include "MEDCouplingMemArray.hxx" +#include "MCAuto.hxx" +#include "MEDCouplingTraits.hxx" +#include "MEDFileUtilities.txx" #include "MEDLoaderDefines.hxx" #include "MEDFileFieldGlobs.hxx" #include "MEDFileFieldInternal.hxx" #include "MEDLoaderTraits.hxx" +#include "NormalizedGeometricTypes" #include "med.h" +#include +#include +#include +#include +#include +#include namespace MEDCoupling { @@ -84,8 +97,8 @@ namespace MEDCoupling MEDLOADER_EXPORT void keepOnlyOnSE(const std::string& seName); MEDLOADER_EXPORT void getMeshSENames(std::vector< std::pair >& ps) const; MEDLOADER_EXPORT void setInfo(const std::vector& infos); - MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; - MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const; + MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const override; + MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const override; MEDLOADER_EXPORT mcIdType copyTinyInfoFrom(const TimeHolder *th, const MEDCouplingFieldTemplate *field, const DataArray *arr); MEDLOADER_EXPORT void setFieldNoProfileSBT(const TimeHolder *th, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc); MEDLOADER_EXPORT void setFieldProfile(const TimeHolder *th, const MEDCouplingFieldTemplate *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayIdType *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc, bool smartPflKiller=true); @@ -153,15 +166,15 @@ namespace MEDCoupling MEDFileField1TSTemplateWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order):MEDFileAnyTypeField1TSWithoutSDA(fieldName,meshName,csit,iteration,order) { } MEDFileField1TSTemplateWithoutSDA() { } public: - MEDLOADER_EXPORT void setArray(DataArray *arr); - MEDLOADER_EXPORT DataArray *createNewEmptyDataArrayInstance() const; + MEDLOADER_EXPORT void setArray(DataArray *arr) override; + MEDLOADER_EXPORT DataArray *createNewEmptyDataArrayInstance() const override; MEDLOADER_EXPORT typename Traits::ArrayType *getOrCreateAndGetArrayTemplate(); MEDLOADER_EXPORT typename Traits::ArrayType const *getOrCreateAndGetArrayTemplate() const; MEDLOADER_EXPORT typename Traits::ArrayType *getUndergroundDataArrayTemplate() const; MEDLOADER_EXPORT typename Traits::ArrayType *getUndergroundDataArrayTemplateExt(std::vector< std::pair,std::pair > >& entries) const; - MEDLOADER_EXPORT DataArray *getOrCreateAndGetArray(); - MEDLOADER_EXPORT const DataArray *getOrCreateAndGetArray() const; - MEDLOADER_EXPORT DataArray *getUndergroundDataArray() const; + MEDLOADER_EXPORT DataArray *getOrCreateAndGetArray() override; + MEDLOADER_EXPORT const DataArray *getOrCreateAndGetArray() const override; + MEDLOADER_EXPORT DataArray *getUndergroundDataArray() const override; MEDLOADER_EXPORT void aggregate(const typename std::vector< typename MLFieldTraits::F1TSWSDAType const * >& f1tss, const std::vector< std::vector< std::pair > >& dts); MEDLOADER_EXPORT void copyTimeInfoFrom(const typename Traits::FieldType *mcf); protected: @@ -174,9 +187,9 @@ namespace MEDCoupling class MEDFileField1TSWithoutSDA : public MEDFileField1TSTemplateWithoutSDA { public: - MEDLOADER_EXPORT const char *getTypeStr() const; + MEDLOADER_EXPORT const char *getTypeStr() const override; MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileField1TSWithoutSDA"); } - MEDLOADER_EXPORT DataArray *getUndergroundDataArrayExt(std::vector< std::pair,std::pair > >& entries) const; + MEDLOADER_EXPORT DataArray *getUndergroundDataArrayExt(std::vector< std::pair,std::pair > >& entries) const override; MEDLOADER_EXPORT std::vector< std::vector > getFieldSplitedByType2(const std::string& mname, std::vector& types, std::vector< std::vector >& typesF, std::vector< std::vector >& pfls, std::vector< std::vector >& locs) const; MEDLOADER_EXPORT static void CheckMeshDimRel(int meshDimRelToMax); MEDLOADER_EXPORT static std::vector CheckSBTMesh(const MEDCouplingMesh *mesh); @@ -184,8 +197,8 @@ namespace MEDCoupling public: MEDLOADER_EXPORT MEDFileField1TSWithoutSDA(); MEDLOADER_EXPORT MEDFileField1TSWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector& infos); - MEDLOADER_EXPORT MEDFileField1TSWithoutSDA *shallowCpy() const; - MEDLOADER_EXPORT MEDFileField1TSWithoutSDA *deepCopy() const; + MEDLOADER_EXPORT MEDFileField1TSWithoutSDA *shallowCpy() const override; + MEDLOADER_EXPORT MEDFileField1TSWithoutSDA *deepCopy() const override; MEDLOADER_EXPORT MEDFileInt32Field1TSWithoutSDA *convertToInt() const; MEDLOADER_EXPORT MEDFileInt64Field1TSWithoutSDA *convertToInt64() const; MEDLOADER_EXPORT MEDFileFloatField1TSWithoutSDA *convertToFloat() const; @@ -200,7 +213,7 @@ namespace MEDCoupling MEDLOADER_EXPORT MEDFileField1TSWithoutSDA *convertToDouble() const; protected: MEDFileField1TSNDTemplateWithoutSDA() { } - MEDFileField1TSNDTemplateWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector& infos):MEDFileField1TSTemplateWithoutSDA(fieldName,meshName,csit,iteration,order) { } + MEDFileField1TSNDTemplateWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector& /*infos*/):MEDFileField1TSTemplateWithoutSDA(fieldName,meshName,csit,iteration,order) { } }; /*! @@ -212,10 +225,10 @@ namespace MEDCoupling MEDLOADER_EXPORT MEDFileInt32Field1TSWithoutSDA(); MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileInt32Field1TSWithoutSDA"); } MEDLOADER_EXPORT static MEDFileInt32Field1TSWithoutSDA *New(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector& infos); - MEDLOADER_EXPORT MEDFileInt32Field1TSWithoutSDA *deepCopy() const; - MEDLOADER_EXPORT MEDFileInt32Field1TSWithoutSDA *shallowCpy() const; - MEDLOADER_EXPORT const char *getTypeStr() const; - MEDLOADER_EXPORT DataArray *getUndergroundDataArrayExt(std::vector< std::pair,std::pair > >& entries) const; + MEDLOADER_EXPORT MEDFileInt32Field1TSWithoutSDA *deepCopy() const override; + MEDLOADER_EXPORT MEDFileInt32Field1TSWithoutSDA *shallowCpy() const override; + MEDLOADER_EXPORT const char *getTypeStr() const override; + MEDLOADER_EXPORT DataArray *getUndergroundDataArrayExt(std::vector< std::pair,std::pair > >& entries) const override; MEDLOADER_EXPORT DataArrayInt32 *getUndergroundDataArrayIntExt(std::vector< std::pair,std::pair > >& entries) const; protected: MEDFileInt32Field1TSWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector& infos); @@ -232,10 +245,10 @@ namespace MEDCoupling MEDLOADER_EXPORT MEDFileInt64Field1TSWithoutSDA(); MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileInt64Field1TSWithoutSDA"); } MEDLOADER_EXPORT static MEDFileInt64Field1TSWithoutSDA *New(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector& infos); - MEDLOADER_EXPORT MEDFileInt64Field1TSWithoutSDA *deepCopy() const; - MEDLOADER_EXPORT MEDFileInt64Field1TSWithoutSDA *shallowCpy() const; - MEDLOADER_EXPORT const char *getTypeStr() const; - MEDLOADER_EXPORT DataArray *getUndergroundDataArrayExt(std::vector< std::pair,std::pair > >& entries) const; + MEDLOADER_EXPORT MEDFileInt64Field1TSWithoutSDA *deepCopy() const override; + MEDLOADER_EXPORT MEDFileInt64Field1TSWithoutSDA *shallowCpy() const override; + MEDLOADER_EXPORT const char *getTypeStr() const override; + MEDLOADER_EXPORT DataArray *getUndergroundDataArrayExt(std::vector< std::pair,std::pair > >& entries) const override; MEDLOADER_EXPORT DataArrayInt64 *getUndergroundDataArrayIntExt(std::vector< std::pair,std::pair > >& entries) const; protected: MEDFileInt64Field1TSWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector& infos); @@ -252,10 +265,10 @@ namespace MEDCoupling MEDLOADER_EXPORT MEDFileFloatField1TSWithoutSDA(); MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileFloatField1TSWithoutSDA"); } MEDLOADER_EXPORT static MEDFileFloatField1TSWithoutSDA *New(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector& infos); - MEDLOADER_EXPORT MEDFileFloatField1TSWithoutSDA *deepCopy() const; - MEDLOADER_EXPORT MEDFileFloatField1TSWithoutSDA *shallowCpy() const; - MEDLOADER_EXPORT const char *getTypeStr() const; - MEDLOADER_EXPORT DataArray *getUndergroundDataArrayExt(std::vector< std::pair,std::pair > >& entries) const; + MEDLOADER_EXPORT MEDFileFloatField1TSWithoutSDA *deepCopy() const override; + MEDLOADER_EXPORT MEDFileFloatField1TSWithoutSDA *shallowCpy() const override; + MEDLOADER_EXPORT const char *getTypeStr() const override; + MEDLOADER_EXPORT DataArray *getUndergroundDataArrayExt(std::vector< std::pair,std::pair > >& entries) const override; MEDLOADER_EXPORT DataArrayFloat *getUndergroundDataArrayFloatExt(std::vector< std::pair,std::pair > >& entries) const; protected: MEDFileFloatField1TSWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector& infos); @@ -270,9 +283,9 @@ namespace MEDCoupling { protected: MEDLOADER_EXPORT MEDFileAnyTypeField1TS(); - MEDLOADER_EXPORT MEDFileAnyTypeField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities=0); - MEDLOADER_EXPORT MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities=0); - MEDLOADER_EXPORT MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities=0); + MEDLOADER_EXPORT MEDFileAnyTypeField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities=nullptr); + MEDLOADER_EXPORT MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities=nullptr); + MEDLOADER_EXPORT MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities=nullptr); MEDLOADER_EXPORT MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent); MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileAnyTypeField1TS"); } MEDLOADER_EXPORT static MEDFileAnyTypeField1TS *BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c); @@ -282,7 +295,7 @@ namespace MEDCoupling MEDLOADER_EXPORT static MEDFileAnyTypeField1TSWithoutSDA *BuildContentFrom(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities); MEDLOADER_EXPORT static MEDFileAnyTypeField1TSWithoutSDA *BuildContentFrom(med_idt fid, const std::string& fieldName, int iteration, int order, const PartDefinition *pd, const MEDFileEntities *entities); MEDLOADER_EXPORT static MEDFileAnyTypeField1TSWithoutSDA *AllocateContentFrom(med_idt fid, const std::string& fieldName, int iteration=-1, int order=-1); - MEDLOADER_EXPORT void writeLL(med_idt fid) const; + MEDLOADER_EXPORT void writeLL(med_idt fid) const override; // direct forwarding to MEDFileAnyTypeField1TSWithoutSDA instance _content public: MEDLOADER_EXPORT static MEDFileAnyTypeField1TS *New(const std::string& fileName, bool loadAll=true); @@ -347,14 +360,14 @@ namespace MEDCoupling MEDLOADER_EXPORT void setProfileNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob=false); //! underground method see MEDFileField1TSWithoutSDA::setLocNameOnLeaf MEDLOADER_EXPORT void setLocNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob=false); - MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; - MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const; - MEDLOADER_EXPORT std::vector getPflsReallyUsed() const; - MEDLOADER_EXPORT std::vector getLocsReallyUsed() const; - MEDLOADER_EXPORT std::vector getPflsReallyUsedMulti() const; - MEDLOADER_EXPORT std::vector getLocsReallyUsedMulti() const; - MEDLOADER_EXPORT void changePflsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif); - MEDLOADER_EXPORT void changeLocsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif); + MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const override; + MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const override; + MEDLOADER_EXPORT std::vector getPflsReallyUsed() const override; + MEDLOADER_EXPORT std::vector getLocsReallyUsed() const override; + MEDLOADER_EXPORT std::vector getPflsReallyUsedMulti() const override; + MEDLOADER_EXPORT std::vector getLocsReallyUsedMulti() const override; + MEDLOADER_EXPORT void changePflsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif) override; + MEDLOADER_EXPORT void changeLocsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif) override; public: MEDLOADER_EXPORT static int LocateField2(med_idt fid, int fieldIdCFormat, bool checkFieldId, std::string& fieldName, med_field_type& typcha, std::vector& infos, std::string& dtunitOut, std::string& meshName); MEDLOADER_EXPORT static int LocateField(med_idt fid, const std::string& fieldName, int& posCFormat, med_field_type& typcha, std::vector& infos, std::string& dtunitOut, std::string& meshName); @@ -402,9 +415,9 @@ namespace MEDCoupling MEDLOADER_EXPORT void setFieldProfile(const typename Traits::FieldType *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayIdType *profile); MEDLOADER_EXPORT void setFieldProfileFlatly(const typename Traits::FieldType *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayIdType *profile); MEDLOADER_EXPORT typename MLFieldTraits::F1TSType *extractPartImpl(const std::map >& extractDef, MEDFileMesh *mm) const; - MEDLOADER_EXPORT MEDFileAnyTypeField1TS *extractPart(const std::map >& extractDef, MEDFileMesh *mm) const { return this->extractPartImpl(extractDef,mm); } + MEDLOADER_EXPORT MEDFileAnyTypeField1TS *extractPart(const std::map >& extractDef, MEDFileMesh *mm) const override { return this->extractPartImpl(extractDef,mm); } protected: - ~MEDFileTemplateField1TS() { } + ~MEDFileTemplateField1TS() override = default; MEDFileTemplateField1TS(); MEDFileTemplateField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms):MEDFileAnyTypeField1TS(fid,loadAll,ms) { } MEDFileTemplateField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms):MEDFileAnyTypeField1TS(fid,fieldName,loadAll,ms) { } @@ -425,16 +438,16 @@ namespace MEDCoupling MEDLOADER_EXPORT MEDFileInt32Field1TS *convertToInt(bool isDeepCpyGlobs=true) const; MEDLOADER_EXPORT MEDFileInt64Field1TS *convertToInt64(bool isDeepCpyGlobs=true) const; public: - MEDLOADER_EXPORT MCAuto buildNewEmpty() const; - MEDLOADER_EXPORT MEDFileField1TS *shallowCpy() const; + MEDLOADER_EXPORT MCAuto buildNewEmpty() const override; + MEDLOADER_EXPORT MEDFileField1TS *shallowCpy() const override; MEDLOADER_EXPORT std::vector< std::vector > getFieldSplitedByType2(const std::string& mname, std::vector& types, std::vector< std::vector >& typesF, std::vector< std::vector >& pfls, std::vector< std::vector >& locs) const; MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileField1TS"); } public: private: - med_field_type getMEDFileFieldType() const { return MED_FLOAT64; } + med_field_type getMEDFileFieldType() const override { return MED_FLOAT64; } private: - ~MEDFileField1TS() { } + ~MEDFileField1TS() override = default; MEDFileField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms); MEDFileField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms); MEDFileField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms); @@ -450,7 +463,7 @@ namespace MEDCoupling MEDLOADER_EXPORT MEDFileField1TS *convertToInt(bool isDeepCpyGlobs=true) const; MEDLOADER_EXPORT MEDFileField1TS *convertToInt64(bool isDeepCpyGlobs=true) const; protected: - ~MEDFileNDTemplateField1TS() { } + ~MEDFileNDTemplateField1TS() override = default; MEDFileNDTemplateField1TS() { } MEDFileNDTemplateField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms):MEDFileTemplateField1TS(fid,loadAll,ms) { } MEDFileNDTemplateField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms):MEDFileTemplateField1TS(fid,fieldName,loadAll,ms) { } @@ -462,15 +475,15 @@ namespace MEDCoupling { friend class MEDFileTemplateField1TS; public: - MEDLOADER_EXPORT MCAuto buildNewEmpty() const; - MEDLOADER_EXPORT MEDFileInt32Field1TS *shallowCpy() const { return new MEDFileInt32Field1TS(*this); } + MEDLOADER_EXPORT MCAuto buildNewEmpty() const override; + MEDLOADER_EXPORT MEDFileInt32Field1TS *shallowCpy() const override { return new MEDFileInt32Field1TS(*this); } MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileInt32Field1TS"); } public: MEDLOADER_EXPORT static MCAuto ConvertFieldIntToFieldDouble(const MEDCouplingFieldInt32 *f); private: - med_field_type getMEDFileFieldType() const { return MED_INT32; } + med_field_type getMEDFileFieldType() const override { return MED_INT32; } private: - ~MEDFileInt32Field1TS() { } + ~MEDFileInt32Field1TS() override = default; MEDFileInt32Field1TS() { } MEDFileInt32Field1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms):MEDFileNDTemplateField1TS(fid,loadAll,ms) { } MEDFileInt32Field1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms):MEDFileNDTemplateField1TS(fid,fieldName,loadAll,ms) { } @@ -488,15 +501,15 @@ namespace MEDCoupling { friend class MEDFileTemplateField1TS; public: - MEDLOADER_EXPORT MCAuto buildNewEmpty() const; - MEDLOADER_EXPORT MEDFileInt64Field1TS *shallowCpy() const { return new MEDFileInt64Field1TS(*this); } + MEDLOADER_EXPORT MCAuto buildNewEmpty() const override; + MEDLOADER_EXPORT MEDFileInt64Field1TS *shallowCpy() const override { return new MEDFileInt64Field1TS(*this); } MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileInt64Field1TS"); } public: MEDLOADER_EXPORT static MCAuto ConvertFieldIntToFieldDouble(const MEDCouplingFieldInt64 *f); private: - med_field_type getMEDFileFieldType() const { return MED_INT64; } + med_field_type getMEDFileFieldType() const override { return MED_INT64; } private: - ~MEDFileInt64Field1TS() { } + ~MEDFileInt64Field1TS() override = default; MEDFileInt64Field1TS() { } MEDFileInt64Field1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms):MEDFileNDTemplateField1TS(fid,loadAll,ms) { } MEDFileInt64Field1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms):MEDFileNDTemplateField1TS(fid,fieldName,loadAll,ms) { } @@ -514,12 +527,12 @@ namespace MEDCoupling { friend class MEDFileTemplateField1TS; private: - med_field_type getMEDFileFieldType() const { return MED_FLOAT32; } - MEDLOADER_EXPORT MEDFileFloatField1TS *shallowCpy() const { return new MEDFileFloatField1TS(*this); } + med_field_type getMEDFileFieldType() const override { return MED_FLOAT32; } + MEDLOADER_EXPORT MEDFileFloatField1TS *shallowCpy() const override { return new MEDFileFloatField1TS(*this); } MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileFloatField1TS"); } - MEDLOADER_EXPORT MCAuto buildNewEmpty() const; + MEDLOADER_EXPORT MCAuto buildNewEmpty() const override; private: - ~MEDFileFloatField1TS() { } + ~MEDFileFloatField1TS() override = default; MEDFileFloatField1TS() { } MEDFileFloatField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms):MEDFileNDTemplateField1TS(fid,loadAll,ms) { } MEDFileFloatField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms):MEDFileNDTemplateField1TS(fid,fieldName,loadAll,ms) { } diff --git a/src/MEDLoader/MEDFileFieldGlobs.cxx b/src/MEDLoader/MEDFileFieldGlobs.cxx index f8e2a9bc1..f3772e81d 100644 --- a/src/MEDLoader/MEDFileFieldGlobs.cxx +++ b/src/MEDLoader/MEDFileFieldGlobs.cxx @@ -19,24 +19,33 @@ // Author : Anthony Geay (EDF R&D) #include "MEDFileFieldGlobs.hxx" -#include "MEDFileField.txx" +#include "MCAuto.hxx" +#include "MEDFileBasis.hxx" +#include "MEDCouplingRefCountObject.hxx" #include "MEDFileMesh.hxx" #include "MEDLoaderBase.hxx" -#include "MEDLoaderTraits.hxx" #include "MEDFileSafeCaller.txx" #include "MEDFileFieldOverView.hxx" -#include "MEDFileBlowStrEltUp.hxx" -#include "MEDFileFieldVisitor.hxx" +#include "MEDFileFieldInternal.hxx" -#include "MEDCouplingMemArray.txx" #include "MEDCouplingFieldDiscretization.hxx" #include "MCType.hxx" #include "InterpKernelAutoPtr.hxx" -#include "CellModel.hxx" +#include "med.h" +#include "medprofile.h" +#include "medlocalization.h" +#include "NormalizedGeometricTypes" #include +#include #include +#include +#include +#include +#include +#include +#include using namespace MEDCoupling; @@ -45,7 +54,7 @@ void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const std::string if(id>=(int)_pfls.size()) _pfls.resize(id+1); MCAuto miPfl=DataArrayMedInt::New(); - med_int lgth(MEDprofileSizeByName(fid,pflName.c_str())); + med_int const lgth(MEDprofileSizeByName(fid,pflName.c_str())); miPfl->setName(pflName); miPfl->alloc(lgth,1); MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName.c_str(),miPfl->getPointer())); @@ -58,7 +67,7 @@ void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i) INTERP_KERNEL::AutoPtr pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); med_int sz; MEDFILESAFECALLERRD0(MEDprofileInfo,(fid,i+1,pflName,&sz)); - std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE); + std::string const pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE); if(i>=(int)_pfls.size()) _pfls.resize(i+1); MCAuto miPfl=DataArrayMedInt::New(); @@ -71,7 +80,7 @@ void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i) void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const { - std::size_t nbOfPfls=_pfls.size(); + std::size_t const nbOfPfls=_pfls.size(); for(std::size_t i=0;i cpy=DataArrayMedInt_Copy((const DataArrayIdType*)_pfls[i]); @@ -81,7 +90,7 @@ void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) co MEDFILESAFECALLERWR0(MEDprofileWr,(fid,pflName,ToMedInt(_pfls[i]->getNumberOfTuples()),cpy->getConstPointer())); } // - std::size_t nbOfLocs=_locs.size(); + std::size_t const nbOfLocs=_locs.size(); for(std::size_t i=0;iwriteLL(fid); } @@ -89,37 +98,37 @@ void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) co void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps) { std::vector pfls=getPfls(); - for(std::vector< MCAuto >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++) + for(const auto & _pfl : other._pfls) { - std::vector::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName()); + auto const it2=std::find(pfls.begin(),pfls.end(),_pfl->getName()); if(it2==pfls.end()) { - _pfls.push_back(*it); + _pfls.push_back(_pfl); } else { - std::size_t id=std::distance(pfls.begin(),it2); - if(!(*it)->isEqual(*_pfls[id])) + std::size_t const id=std::distance(pfls.begin(),it2); + if(!_pfl->isEqual(*_pfls[id])) { - std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !"; + std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << _pfl->getName() << "\" already exists and is different from those expecting to be append !"; throw INTERP_KERNEL::Exception(oss.str()); } } } std::vector locs=getLocs(); - for(std::vector< MCAuto >::const_iterator it=other._locs.begin();it!=other._locs.end();it++) + for(const auto & _loc : other._locs) { - std::vector::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName()); + auto const it2=std::find(locs.begin(),locs.end(),_loc->getName()); if(it2==locs.end()) { - _locs.push_back(*it); + _locs.push_back(_loc); } else { - std::size_t id=std::distance(locs.begin(),it2); - if(!(*it)->isEqual(*_locs[id],eps)) + std::size_t const id=std::distance(locs.begin(),it2); + if(!_loc->isEqual(*_locs[id],eps)) { - std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !"; + std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << _loc->getName() << "\" already exists and is different from those expecting to be append !"; throw INTERP_KERNEL::Exception(oss.str()); } } @@ -128,14 +137,14 @@ void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps) void MEDFileFieldGlobs::checkGlobsPflsPartCoherency(const std::vector& pflsUsed) const { - for(std::vector::const_iterator it=pflsUsed.begin();it!=pflsUsed.end();it++) - getProfile((*it).c_str()); + for(const auto & it : pflsUsed) + getProfile(it.c_str()); } void MEDFileFieldGlobs::checkGlobsLocsPartCoherency(const std::vector& locsUsed) const { - for(std::vector::const_iterator it=locsUsed.begin();it!=locsUsed.end();it++) - getLocalization((*it).c_str()); + for(const auto & it : locsUsed) + getLocalization(it.c_str()); } void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real) @@ -146,7 +155,7 @@ void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& re for(unsigned int i=0;i locs=real.getLocsReallyUsed(); + std::vector const locs=real.getLocsReallyUsed(); sz=locs.size(); _locs.resize(sz); for(std::size_t i=0;i MEDFileFieldGlobs::getDirectChildrenWithNull() const { std::vector ret; - for(std::vector< MCAuto< DataArrayIdType > >::const_iterator it=_pfls.begin();it!=_pfls.end();it++) - ret.push_back((const DataArrayIdType *)*it); - for(std::vector< MCAuto >::const_iterator it=_locs.begin();it!=_locs.end();it++) - ret.push_back((const MEDFileFieldLoc *)*it); + for(const auto & _pfl : _pfls) + ret.push_back((const DataArrayIdType *)_pfl); + for(const auto & _loc : _locs) + ret.push_back((const MEDFileFieldLoc *)_loc); return ret; } @@ -195,13 +204,13 @@ MEDFileFieldGlobs *MEDFileFieldGlobs::deepCopy() const { MCAuto ret=new MEDFileFieldGlobs(*this); std::size_t i=0; - for(std::vector< MCAuto >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++) + for(auto it=_pfls.begin();it!=_pfls.end();it++,i++) { if((const DataArrayIdType *)*it) ret->_pfls[i]=(*it)->deepCopy(); } i=0; - for(std::vector< MCAuto >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++) + for(auto it=_locs.begin();it!=_locs.end();it++,i++) { if((const MEDFileFieldLoc*)*it) ret->_locs[i]=(*it)->deepCopy(); @@ -217,22 +226,22 @@ MEDFileFieldGlobs *MEDFileFieldGlobs::deepCopy() const MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(const std::vector& pfls, const std::vector& locs) const { MCAuto ret=MEDFileFieldGlobs::New(); - for(std::vector::const_iterator it1=pfls.begin();it1!=pfls.end();it1++) + for(const auto & it1 : pfls) { - DataArrayIdType *pfl=const_cast(getProfile((*it1).c_str())); + DataArrayIdType *pfl=const_cast(getProfile(it1.c_str())); if(!pfl) throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! pfl null !"); pfl->incrRef(); - MCAuto pfl2(pfl); + MCAuto const pfl2(pfl); ret->_pfls.push_back(pfl2); } - for(std::vector::const_iterator it2=locs.begin();it2!=locs.end();it2++) + for(const auto & it2 : locs) { - MEDFileFieldLoc *loc=const_cast(&getLocalization((*it2).c_str())); + MEDFileFieldLoc *loc=const_cast(&getLocalization(it2.c_str())); if(!loc) throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! loc null !"); loc->incrRef(); - MCAuto loc2(loc); + MCAuto const loc2(loc); ret->_locs.push_back(loc2); } ret->setFileName(getFileName()); @@ -247,16 +256,16 @@ MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(const std::vector& pfls, const std::vector& locs) const { MCAuto ret=MEDFileFieldGlobs::New(); - for(std::vector::const_iterator it1=pfls.begin();it1!=pfls.end();it1++) + for(const auto & it1 : pfls) { - DataArrayIdType *pfl=const_cast(getProfile((*it1).c_str())); + DataArrayIdType *pfl=const_cast(getProfile(it1.c_str())); if(!pfl) throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! pfl null !"); ret->_pfls.push_back(pfl->deepCopy()); } - for(std::vector::const_iterator it2=locs.begin();it2!=locs.end();it2++) + for(const auto & it2 : locs) { - MEDFileFieldLoc *loc=const_cast(&getLocalization((*it2).c_str())); + MEDFileFieldLoc *loc=const_cast(&getLocalization(it2.c_str())); if(!loc) throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! loc null !"); ret->_locs.push_back(loc->deepCopy()); @@ -270,12 +279,10 @@ MEDFileFieldGlobs::MEDFileFieldGlobs(med_idt fid):_file_name(MEDFileWritable::Fi } MEDFileFieldGlobs::MEDFileFieldGlobs() -{ -} += default; MEDFileFieldGlobs::~MEDFileFieldGlobs() -{ -} += default; void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const { @@ -305,17 +312,17 @@ void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair, std::string > >& mapOfModif) { - for(std::vector< MCAuto >::iterator it=_pfls.begin();it!=_pfls.end();it++) + for(auto & _pfl : _pfls) { - DataArrayIdType *elt(*it); + DataArrayIdType *elt(_pfl); if(elt) { - std::string name(elt->getName()); - for(std::vector< std::pair, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++) + std::string const name(elt->getName()); + for(const auto & it2 : mapOfModif) { - if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end()) + if(std::find(it2.first.begin(),it2.first.end(),name)!=it2.first.end()) { - elt->setName((*it2).second.c_str()); + elt->setName(it2.second.c_str()); return; } } @@ -325,17 +332,17 @@ void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair, std::string > >& mapOfModif) { - for(std::vector< MCAuto >::iterator it=_locs.begin();it!=_locs.end();it++) + for(auto & _loc : _locs) { - MEDFileFieldLoc *elt(*it); + MEDFileFieldLoc *elt(_loc); if(elt) { - std::string name(elt->getName()); - for(std::vector< std::pair, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++) + std::string const name(elt->getName()); + for(const auto & it2 : mapOfModif) { - if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end()) + if(std::find(it2.first.begin(),it2.first.end(),name)!=it2.first.end()) { - elt->setName((*it2).second.c_str()); + elt->setName(it2.second.c_str()); return; } } @@ -387,7 +394,7 @@ namespace MEDCouplingImpl int MEDFileFieldGlobs::getLocalizationId(const std::string& loc) const { - std::vector< MCAuto >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),MEDCouplingImpl::LocFinder(loc)); + auto it=std::find_if(_locs.begin(),_locs.end(),MEDCouplingImpl::LocFinder(loc)); if(it==_locs.end()) { std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : "; @@ -400,7 +407,7 @@ int MEDFileFieldGlobs::getLocalizationId(const std::string& loc) const int MEDFileFieldGlobs::getProfileId(const std::string& pfl) const { - std::vector< MCAuto >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pfl)); + auto it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pfl)); if(it==_pfls.end()) { std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfileId : no such profile name : \"" << pfl << "\" Possible localizations are : "; @@ -443,8 +450,8 @@ MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName) */ DataArrayIdType *MEDFileFieldGlobs::getProfile(const std::string& pflName) { - std::string pflNameCpp(pflName); - std::vector< MCAuto >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp)); + std::string const pflNameCpp(pflName); + auto it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp)); if(it==_pfls.end()) { std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : "; @@ -489,19 +496,19 @@ void MEDFileFieldGlobs::killLocalizationIds(const std::vector& locIds) void MEDFileFieldGlobs::killStructureElementsInGlobs() { std::vector< MCAuto > newLocs; - for(std::vector< MCAuto >::iterator it=_locs.begin();it!=_locs.end();it++) + for(auto & _loc : _locs) { - if((*it).isNull()) + if(_loc.isNull()) continue; - if(!(*it)->isOnStructureElement()) - newLocs.push_back(*it); + if(!_loc->isOnStructureElement()) + newLocs.push_back(_loc); } _locs=newLocs; } std::vector MEDFileFieldGlobs::getPfls() const { - std::size_t sz=_pfls.size(); + std::size_t const sz=_pfls.size(); std::vector ret(sz); for(std::size_t i=0;igetName(); @@ -510,7 +517,7 @@ std::vector MEDFileFieldGlobs::getPfls() const std::vector MEDFileFieldGlobs::getLocs() const { - std::size_t sz=_locs.size(); + std::size_t const sz=_locs.size(); std::vector ret(sz); for(std::size_t i=0;igetName(); @@ -520,14 +527,14 @@ std::vector MEDFileFieldGlobs::getLocs() const bool MEDFileFieldGlobs::existsPfl(const std::string& pflName) const { std::vector v=getPfls(); - std::string s(pflName); + std::string const s(pflName); return std::find(v.begin(),v.end(),s)!=v.end(); } bool MEDFileFieldGlobs::existsLoc(const std::string& locName) const { std::vector v=getLocs(); - std::string s(locName); + std::string const s(locName); return std::find(v.begin(),v.end(),s)!=v.end(); } @@ -535,7 +542,7 @@ std::vector< std::vector > MEDFileFieldGlobs::whichAreEqualProfiles() const { std::map > m; int i=0; - for(std::vector< MCAuto >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++) + for(auto it=_pfls.begin();it!=_pfls.end();it++,i++) { const DataArrayIdType *tmp=(*it); if(tmp) @@ -550,9 +557,9 @@ std::vector< std::vector > MEDFileFieldGlobs::whichAreEqualProfiles() const { std::vector ret0; bool equalityOrNot=false; - for(std::vector::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++) + for(auto it3=(*it2).second.begin();it3!=(*it2).second.end();it3++) { - std::vector::const_iterator it4=it3; it4++; + auto it4=it3; it4++; for(;it4!=(*it2).second.end();it4++) { if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4])) @@ -571,20 +578,20 @@ std::vector< std::vector > MEDFileFieldGlobs::whichAreEqualProfiles() const return ret; } -std::vector< std::vector > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const +std::vector< std::vector > MEDFileFieldGlobs::whichAreEqualLocs(double /*eps*/) const { throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !"); } void MEDFileFieldGlobs::appendProfile(DataArrayIdType *pfl) { - std::string name(pfl->getName()); + std::string const name(pfl->getName()); if(name.empty()) throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !"); - for(std::vector< MCAuto >::const_iterator it=_pfls.begin();it!=_pfls.end();it++) - if(name==(*it)->getName()) + for(const auto & _pfl : _pfls) + if(name==_pfl->getName()) { - if(!pfl->isEqual(*(*it))) + if(!pfl->isEqual(*_pfl)) { std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !"; throw INTERP_KERNEL::Exception(oss.str()); @@ -596,14 +603,14 @@ void MEDFileFieldGlobs::appendProfile(DataArrayIdType *pfl) void MEDFileFieldGlobs::appendLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector& refCoo, const std::vector& gsCoo, const std::vector& w) { - std::string name(locName); + std::string const name(locName); if(name.empty()) throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !"); MCAuto obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w); - for(std::vector< MCAuto >::const_iterator it=_locs.begin();it!=_locs.end();it++) - if((*it)->isName(locName)) + for(const auto & _loc : _locs) + if(_loc->isName(locName)) { - if(!(*it)->isEqual(*obj,1e-12)) + if(!_loc->isEqual(*obj,1e-12)) { std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !"; throw INTERP_KERNEL::Exception(oss.str()); @@ -614,13 +621,13 @@ void MEDFileFieldGlobs::appendLoc(const std::string& locName, INTERP_KERNEL::Nor std::string MEDFileFieldGlobs::createNewNameOfPfl() const { - std::vector names=getPfls(); + std::vector const names=getPfls(); return CreateNewNameNotIn("NewPfl_",names); } std::string MEDFileFieldGlobs::createNewNameOfLoc() const { - std::vector names=getLocs(); + std::vector const names=getLocs(); return CreateNewNameNotIn("NewLoc_",names); } @@ -671,7 +678,7 @@ void MEDFileFieldGlobsReal::simpleReprGlobs(std::ostream& oss) const { const MEDFileFieldGlobs *glob=_globals; std::ostringstream oss2; oss2 << glob; - std::string stars(oss2.str().length(),'*'); + std::string const stars(oss2.str().length(),'*'); oss << "Globals information on fields (at " << oss2.str() << "):" << "\n************************************" << stars << "\n\n"; if(glob) glob->simpleRepr(oss); @@ -690,8 +697,7 @@ void MEDFileFieldGlobsReal::killStructureElementsInGlobs() } MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal() -{ -} += default; /*! * Copies references to profiles and Gauss points from another MEDFileFieldGlobsReal. @@ -945,7 +951,7 @@ void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair, std::string > > mapOfModif(1); - std::pair, std::string > p(std::vector(1,std::string(oldName)),std::string(newName)); + std::pair, std::string > const p(std::vector(1,std::string(oldName)),std::string(newName)); mapOfModif[0]=p; changePflsNames(mapOfModif); } @@ -959,7 +965,7 @@ void MEDFileFieldGlobsReal::changePflName(const std::string& oldName, const std: void MEDFileFieldGlobsReal::changeLocName(const std::string& oldName, const std::string& newName) { std::vector< std::pair, std::string > > mapOfModif(1); - std::pair, std::string > p(std::vector(1,std::string(oldName)),std::string(newName)); + std::pair, std::string > const p(std::vector(1,std::string(oldName)),std::string(newName)); mapOfModif[0]=p; changeLocsNames(mapOfModif); } @@ -983,11 +989,11 @@ std::vector< std::pair, std::string > > MEDFileFieldGlo { std::vector< std::string > tmp((*it).size()); int j=0; - for(std::vector::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++) + for(auto it2=(*it).begin();it2!=(*it).end();it2++,j++) tmp[j]=std::string(getProfileFromId(*it2)->getName()); - std::pair, std::string > p(tmp,tmp.front()); + std::pair, std::string > const p(tmp,tmp.front()); ret[i]=p; - std::vector tmp2((*it).begin()+1,(*it).end()); + std::vector const tmp2((*it).begin()+1,(*it).end()); killProfileIds(tmp2); } changePflsRefsNamesGen(ret); @@ -1014,11 +1020,11 @@ std::vector< std::pair, std::string > > MEDFileFieldGlo { std::vector< std::string > tmp((*it).size()); int j=0; - for(std::vector::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++) + for(auto it2=(*it).begin();it2!=(*it).end();it2++,j++) tmp[j]=std::string(getLocalizationFromId(*it2).getName()); - std::pair, std::string > p(tmp,tmp.front()); + std::pair, std::string > const p(tmp,tmp.front()); ret[i]=p; - std::vector tmp2((*it).begin()+1,(*it).end()); + std::vector const tmp2((*it).begin()+1,(*it).end()); killLocalizationIds(tmp2); } changeLocsRefsNamesGen(ret); @@ -1223,8 +1229,7 @@ const MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() const //= MEDFileFieldNameScope MEDFileFieldNameScope::MEDFileFieldNameScope() -{ -} += default; MEDFileFieldNameScope::MEDFileFieldNameScope(const std::string& fieldName, const std::string& meshName):_name(fieldName),_mesh_name(meshName) { diff --git a/src/MEDLoader/MEDFileFieldGlobs.hxx b/src/MEDLoader/MEDFileFieldGlobs.hxx index a4d509cd3..ef148b440 100644 --- a/src/MEDLoader/MEDFileFieldGlobs.hxx +++ b/src/MEDLoader/MEDFileFieldGlobs.hxx @@ -21,13 +21,19 @@ #ifndef __MEDFILEFIELDGLOBS_HXX__ #define __MEDFILEFIELDGLOBS_HXX__ +#include "MEDCouplingRefCountObject.hxx" +#include "MCType.hxx" #include "MEDLoaderDefines.hxx" #include "NormalizedGeometricTypes" -#include "MEDCouplingMemArray.hxx" #include "MCAuto.hxx" #include "med.h" +#include +#include +#include +#include +#include namespace MEDCoupling { @@ -42,8 +48,8 @@ namespace MEDCoupling static MEDFileFieldGlobs *New(med_idt fid); static MEDFileFieldGlobs *New(); std::string getClassName() const override { return std::string("MEDFileFieldGlobs"); } - std::size_t getHeapMemorySizeWithoutChildren() const; - std::vector getDirectChildrenWithNull() const; + std::size_t getHeapMemorySizeWithoutChildren() const override; + std::vector getDirectChildrenWithNull() const override; MEDFileFieldGlobs *deepCopy() const; MEDFileFieldGlobs *shallowCpyPart(const std::vector& pfls, const std::vector& locs) const; MEDFileFieldGlobs *deepCpyPart(const std::vector& pfls, const std::vector& locs) const; @@ -90,7 +96,7 @@ namespace MEDCoupling protected: MEDFileFieldGlobs(med_idt fid); MEDFileFieldGlobs(); - ~MEDFileFieldGlobs(); + ~MEDFileFieldGlobs() override; protected: std::vector< MCAuto > _pfls; std::vector< MCAuto > _locs; @@ -128,7 +134,7 @@ namespace MEDCoupling MEDLOADER_EXPORT void loadProfileInFile(med_idt fid, int id, const std::string& pflName); MEDLOADER_EXPORT void loadProfileInFile(med_idt fid, int id); MEDLOADER_EXPORT void loadGlobals(med_idt fid); - MEDLOADER_EXPORT void loadAllGlobals(med_idt fid, const MEDFileEntities *entities=0); + MEDLOADER_EXPORT void loadAllGlobals(med_idt fid, const MEDFileEntities *entities=nullptr); MEDLOADER_EXPORT void writeGlobals(med_idt fid, const MEDFileWritable& opt) const; MEDLOADER_EXPORT std::vector getPfls() const; MEDLOADER_EXPORT std::vector getLocs() const; diff --git a/src/MEDLoader/MEDFileFieldInternal.cxx b/src/MEDLoader/MEDFileFieldInternal.cxx index 84eb086ac..10d084714 100644 --- a/src/MEDLoader/MEDFileFieldInternal.cxx +++ b/src/MEDLoader/MEDFileFieldInternal.cxx @@ -19,6 +19,15 @@ // Author : Anthony Geay (EDF R&D) #include "MEDFileFieldInternal.hxx" +#include "InterpKernelAutoPtr.hxx" +#include "MEDFileBasis.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include "MCType.hxx" +#include "MEDCouplingMemArray.hxx" +#include "MCAuto.hxx" +#include "MCIdType.hxx" +#include "MEDCouplingFieldDiscretization.hxx" +#include "MEDCouplingPartDefinition.hxx" #include "MEDFileField.hxx" #include "MEDFileFieldVisitor.hxx" #include "MEDFileStructureElement.hxx" @@ -33,6 +42,23 @@ #include "MEDFilterEntity.hxx" #include "CellModel.hxx" +#include "med.h" +#include "NormalizedGeometricTypes" +#include +#include +#include +#include "medlocalization.h" +#include +#include +#include "medmesh.h" +#include +#include +#include +#include "medfield.h" +#include +#include +#include +#include // From MEDLOader.cxx TU extern med_geometry_type typmai[MED_N_CELL_FIXED_GEO]; @@ -42,8 +68,7 @@ extern med_geometry_type typmai3[INTERP_KERNEL::NORM_MAXTYPE]; using namespace MEDCoupling; MEDFileGTKeeper::~MEDFileGTKeeper() -{ -} += default; MEDFileGTKeeper *MEDFileGTKeeperSta::deepCopy() const { @@ -62,7 +87,7 @@ std::string MEDFileGTKeeperSta::getRepr() const bool MEDFileGTKeeperSta::isEqual(const MEDFileGTKeeper *other) const { - const MEDFileGTKeeperSta *otherC(dynamic_cast(other)); + const auto *otherC(dynamic_cast(other)); if(!otherC) return false; return _geo_type==otherC->_geo_type; @@ -99,7 +124,7 @@ std::string MEDFileGTKeeperDyn::getRepr() const bool MEDFileGTKeeperDyn::isEqual(const MEDFileGTKeeper *other) const { - const MEDFileGTKeeperDyn *otherC(dynamic_cast(other)); + const auto *otherC(dynamic_cast(other)); if(!otherC) return false; return this==otherC; @@ -151,7 +176,7 @@ MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, int id, const MEDFileEntities *ent _dim=FromMedInt(dim); _nb_gauss_pt=FromMedInt(nb_gauss_pt); _name=locName; - std::string sectionName(MEDLoaderBase::buildStringFromFortran(sectionmeshname,MED_NAME_SIZE)); + std::string const sectionName(MEDLoaderBase::buildStringFromFortran(sectionmeshname,MED_NAME_SIZE)); if(sectionName.empty()) { _gt=new MEDFileGTKeeperSta((INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+INTERP_KERNEL::NORM_MAXTYPE,geotype)))); @@ -160,7 +185,7 @@ MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, int id, const MEDFileEntities *ent } else { - const MEDFileAllStaticEntitiesPlusDyn *entities2(dynamic_cast(entities)); + const auto *entities2(dynamic_cast(entities)); if(!entities2) { std::ostringstream oss; oss << "MEDFileFieldLoc cstr : for loc \"" << _name << "\" presence of non static type ! Expect entities !"; @@ -206,8 +231,8 @@ bool MEDFileFieldLoc::isOnStructureElement() const const MEDFileGTKeeper *gt(_gt); if(!gt) throw INTERP_KERNEL::Exception("MEDFileFieldLoc::isOnStructureElement : null pointer !"); - const MEDFileGTKeeperDyn *gt2(dynamic_cast(gt)); - return gt2!=NULL; + const auto *gt2(dynamic_cast(gt)); + return gt2!=nullptr; } std::size_t MEDFileFieldLoc::getHeapMemorySizeWithoutChildren() const @@ -276,7 +301,7 @@ std::string MEDFileFieldLoc::repr() const std::size_t sz=_ref_coo.size(); if(sz%_dim==0) { - std::size_t nbOfTuples=sz/_dim; + std::size_t const nbOfTuples=sz/_dim; for(std::size_t i=0;igetDiscretization()); const MEDCouplingGaussLocalization& gsLoc(field->getGaussLocalization(FromIdType(_loc_id))); - const MEDCouplingFieldDiscretizationGauss *disc2(dynamic_cast(disc)); + const auto *disc2(dynamic_cast(disc)); if(!disc2) throw INTERP_KERNEL::Exception("assignFieldNoProfile : invalid call to this method ! Internal Error !"); const DataArrayIdType *dai(disc2->getArrayOfDiscIds()); MCAuto dai2(disc2->getOffsetArr(field->getMesh())); const mcIdType *dai2Ptr(dai2->getConstPointer()); - mcIdType nbi(ToIdType(gsLoc.getWeights().size())); + mcIdType const nbi(ToIdType(gsLoc.getWeights().size())); MCAuto da2(dai->selectByTupleIdSafeSlice(offset,offset+nbOfCells,1)); MCAuto da3(da2->findIdsEqual(_loc_id)); const mcIdType *da3Ptr(da3->getConstPointer()); @@ -355,7 +380,7 @@ void MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile(mcIdType& start, mc mcIdType *da4Ptr(da4->getPointer()); for(mcIdType i=0;i<_nval;i++) { - mcIdType ref=dai2Ptr[offset+da3Ptr[i]]; + mcIdType const ref=dai2Ptr[offset+da3Ptr[i]]; for(mcIdType j=0;jgetTypeOfField(); - std::string pflName(multiTypePfl->getName()); + std::string const pflName(multiTypePfl->getName()); std::ostringstream oss; oss << pflName; if(_type!=ON_NODES) { @@ -430,7 +455,7 @@ void MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile(bool isPflAlone, mcId MCAuto arr3=arr2->selectByTupleId(multiTypePfl->begin(),multiTypePfl->end()); arr3->computeOffsetsFull(); MCAuto tmp=idsInPfl->buildExplicitArrByRanges(arr3); - mcIdType trueNval=tmp->getNumberOfTuples(); + mcIdType const trueNval=tmp->getNumberOfTuples(); _nval=idsInPfl->getNumberOfTuples(); getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp); _end=_start+trueNval; @@ -438,7 +463,7 @@ void MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile(bool isPflAlone, mcId } case ON_GAUSS_PT: { - const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast(field->getDiscretization()); + const auto *disc2=dynamic_cast(field->getDiscretization()); if(!disc2) throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !"); const DataArrayIdType *da1=disc2->getArrayOfDiscIds(); @@ -491,7 +516,7 @@ void MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile(bool isPflAlone, mcId start=_end; } -void MEDFileFieldPerMeshPerTypePerDisc::assignNodeFieldNoProfile(mcIdType& start, const MEDCouplingFieldTemplate *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob) +void MEDFileFieldPerMeshPerTypePerDisc::assignNodeFieldNoProfile(mcIdType& start, const MEDCouplingFieldTemplate * /*field*/, const DataArray *arrr, MEDFileFieldGlobsReal& /*glob*/) { _start=start; _nval=arrr->getNumberOfTuples(); @@ -545,15 +570,15 @@ catch(INTERP_KERNEL::Exception& e) throw e; } -MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, mcIdType locId, const std::string& dummy):_type(type),_father(fath),_loc_id(locId) +MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, mcIdType locId, const std::string& /*dummy*/):_type(type),_father(fath),_loc_id(locId) { } -MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(const MEDFileFieldPerMeshPerTypePerDisc& other):RefCountObject(other),_type(other._type),_father(0),_start(other._start),_end(other._end),_nval(other._nval),_profile(other._profile),_localization(other._localization),_loc_id(other._loc_id),_profile_it(other._profile_it),_pd(other._pd),_tmp_work1(other._tmp_work1) +MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(const MEDFileFieldPerMeshPerTypePerDisc& other):RefCountObject(other),_type(other._type),_father(nullptr),_start(other._start),_end(other._end),_nval(other._nval),_profile(other._profile),_localization(other._localization),_loc_id(other._loc_id),_profile_it(other._profile_it),_pd(other._pd),_tmp_work1(other._tmp_work1) { } -MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc():_type(ON_CELLS),_father(0),_start(-std::numeric_limits::max()),_end(-std::numeric_limits::max()), +MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc():_type(ON_CELLS),_father(nullptr),_start(-std::numeric_limits::max()),_end(-std::numeric_limits::max()), _nval(-std::numeric_limits::max()),_loc_id(-std::numeric_limits::max()) { } @@ -592,7 +617,7 @@ void MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile(med_idt fid, const throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile : not implemented !"); INTERP_KERNEL::AutoPtr pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)),locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)); med_int profilesize,nbi; - med_int overallNval(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,FromIdType(_profile_it+1),MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi)); + med_int const overallNval(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,FromIdType(_profile_it+1),MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi)); {//TODO : manage int32 ! pd->checkConsistencyLight(); @@ -616,17 +641,17 @@ void MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively(med_i INTERP_KERNEL::AutoPtr pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)); std::string fieldName(nasc.getName()),meshName(getMeshName()); med_int iteration(getIteration()),order(getOrder()),profilesize,nbi; - TypeOfField type(getType()); + TypeOfField const type(getType()); med_geometry_type mgeoti; med_entity_type menti; _father->entriesForMEDfile(type,mgeoti,menti); med_int zeNVal(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,FromIdType(_profile_it+1),MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi)); if(zeNVal==0 && type==ON_CELLS) {//eheh maybe there's a surprise :) - med_int zeNVal1(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,MED_DESCENDING_FACE,mgeoti,FromIdType(_profile_it+1),MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi)); + med_int const zeNVal1(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,MED_DESCENDING_FACE,mgeoti,FromIdType(_profile_it+1),MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi)); if(zeNVal1==0) { - med_int zeNVal2(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,MED_DESCENDING_EDGE,mgeoti,FromIdType(_profile_it+1),MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi)); + med_int const zeNVal2(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,MED_DESCENDING_EDGE,mgeoti,FromIdType(_profile_it+1),MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi)); if(zeNVal2!=0) zeNVal=zeNVal2; } @@ -667,7 +692,7 @@ void MEDFileFieldPerMeshPerTypePerDisc::loadBigArray(med_idt fid, const MEDFileF { std::string fieldName(nasc.getName()),meshName(getMeshName()); int iteration(getIteration()),order(getOrder()); - TypeOfField type(getType()); + TypeOfField const type(getType()); med_geometry_type mgeoti; med_entity_type menti; _father->entriesForMEDfile(type,mgeoti,menti); @@ -686,29 +711,29 @@ void MEDFileFieldPerMeshPerTypePerDisc::loadBigArray(med_idt fid, const MEDFileF std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << "] !"; throw INTERP_KERNEL::Exception(oss.str()); } - int nbOfCompo((int)arr->getNumberOfComponents()); - DataArrayDouble *arrD(dynamic_cast(arr)); + int const nbOfCompo((int)arr->getNumberOfComponents()); + auto *arrD(dynamic_cast(arr)); if(arrD) { double *startFeeding(arrD->getPointer()+_start*nbOfCompo); goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast(startFeeding)); return ; } - DataArrayInt32 *arrI(dynamic_cast(arr)); + auto *arrI(dynamic_cast(arr)); if(arrI) { Int32 *startFeeding(arrI->getPointer()+_start*nbOfCompo); goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast(startFeeding)); return ; } - DataArrayInt64 *arrI64(dynamic_cast(arr)); + auto *arrI64(dynamic_cast(arr)); if(arrI64) { Int64 *startFeeding(arrI64->getPointer()+_start*nbOfCompo); goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast(startFeeding)); return ; } - DataArrayFloat *arrF(dynamic_cast(arr)); + auto *arrF(dynamic_cast(arr)); if(arrF) { float *startFeeding(arrF->getPointer()+_start*nbOfCompo); @@ -724,7 +749,7 @@ void MEDFileFieldPerMeshPerTypePerDisc::loadBigArray(med_idt fid, const MEDFileF */ void MEDFileFieldPerMeshPerTypePerDisc::setNewStart(mcIdType newValueOfStart) { - mcIdType delta=_end-_start; + mcIdType const delta=_end-_start; _start=newValueOfStart; _end=_start+delta; } @@ -799,7 +824,7 @@ mcIdType MEDFileFieldPerMeshPerTypePerDisc::getNumberOfTuples() const void MEDFileFieldPerMeshPerTypePerDisc::incrementNbOfVals(mcIdType deltaNbVal) { - mcIdType nbi((_end-_start)/_nval); + mcIdType const nbi((_end-_start)/_nval); _nval+=deltaNbVal; _end+=nbi*deltaNbVal; } @@ -842,11 +867,11 @@ void MEDFileFieldPerMeshPerTypePerDisc::setLocalization(const std::string& newLo void MEDFileFieldPerMeshPerTypePerDisc::changePflsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif) { - for(std::vector< std::pair, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++) + for(const auto & it2 : mapOfModif) { - if(std::find((*it2).first.begin(),(*it2).first.end(),_profile)!=(*it2).first.end()) + if(std::find(it2.first.begin(),it2.first.end(),_profile)!=it2.first.end()) { - _profile=(*it2).second; + _profile=it2.second; return; } } @@ -854,11 +879,11 @@ void MEDFileFieldPerMeshPerTypePerDisc::changePflsRefsNamesGen(const std::vector void MEDFileFieldPerMeshPerTypePerDisc::changeLocsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif) { - for(std::vector< std::pair, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++) + for(const auto & it2 : mapOfModif) { - if(std::find((*it2).first.begin(),(*it2).first.end(),_localization)!=(*it2).first.end()) + if(std::find(it2.first.begin(),it2.first.end(),_localization)!=it2.first.end()) { - _localization=(*it2).second; + _localization=it2.second; return; } } @@ -871,7 +896,7 @@ void MEDFileFieldPerMeshPerTypePerDisc::getFieldAtLevel(TypeOfField type, const dads.push_back(std::pair(_start,_end)); geoTypes.push_back(getGeoType()); if(_profile.empty()) - pfls.push_back(0); + pfls.push_back(nullptr); else { pfls.push_back(glob->getProfile(_profile.c_str())); @@ -900,11 +925,11 @@ void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid, const MEDFileFieldN throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : no array set !"); if(!arr->isAllocated()) throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : the array to be written is not allocated !"); - const DataArrayDouble *arrD(dynamic_cast(arr)); - const DataArrayInt32 *arrI(dynamic_cast(arr)); - const DataArrayInt64 *arrI64(dynamic_cast(arr)); - const DataArrayFloat *arrF(dynamic_cast(arr)); - const unsigned char *locToWrite=0; + const auto *arrD(dynamic_cast(arr)); + const auto *arrI(dynamic_cast(arr)); + const auto *arrI64(dynamic_cast(arr)); + const auto *arrF(dynamic_cast(arr)); + const unsigned char *locToWrite=nullptr; if(arrD) locToWrite=reinterpret_cast(arrD->getConstPointer()+_start*arr->getNumberOfComponents()); else if(arrI) @@ -938,7 +963,7 @@ mcIdType MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode(mcIdType offset, { _loc_id=FromIdType(offset); std::ostringstream oss; - std::size_t nbOfType=codeOfMesh.size()/3; + std::size_t const nbOfType=codeOfMesh.size()/3; int found=-1; for(std::size_t i=0;igetNumberOfTuples() << " whereas the number of ids is set to " << _nval << " for this geometric type !"; throw INTERP_KERNEL::Exception(oss.str()); } - mcIdType offset2=codeOfMesh[3*found+2]; - for(const mcIdType *pflId=pfl->begin();pflId!=pfl->end();pflId++) + mcIdType const offset2=codeOfMesh[3*found+2]; + for(long const pflId : *pfl) { - if(*pflId > MEDFileFi int id=0; std::map,int> m; std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > ret; - for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++) - if(m.find(std::pair((*it)->getLocalization(),(*it)->getType()))==m.end()) - m[std::pair((*it)->getLocalization(),(*it)->getType())]=id++; + for(auto entrie : entries) + if(m.find(std::pair(entrie->getLocalization(),entrie->getType()))==m.end()) + m[std::pair(entrie->getLocalization(),entrie->getType())]=id++; ret.resize(id); - for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++) - ret[m[std::pair((*it)->getLocalization(),(*it)->getType())]].push_back(*it); + for(auto entrie : entries) + ret[m[std::pair(entrie->getLocalization(),entrie->getType())]].push_back(entrie); return ret; } @@ -1039,11 +1064,11 @@ bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(mcIdType offset, const st { if(entriesOnSameDisc.empty()) return false; - TypeOfField type=entriesOnSameDisc[0]->getType(); + TypeOfField const type=entriesOnSameDisc[0]->getType(); mcIdType szEntities=0,szTuples=0; - for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++) - { szEntities+=(*it)->_nval; szTuples+=(*it)->_end-(*it)->_start; } - mcIdType nbi=szTuples/szEntities; + for(auto it : entriesOnSameDisc) + { szEntities+=it->_nval; szTuples+=it->_end-it->_start; } + mcIdType const nbi=szTuples/szEntities; if(szTuples%szEntities!=0) throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks : internal error the splitting into same dicretization failed !"); MCAuto renumTuples=DataArrayIdType::New(); renumTuples->alloc(szTuples,1); @@ -1054,9 +1079,9 @@ bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(mcIdType offset, const st std::vector< const DataArrayIdType * > newGeoTypesPerChunk3(entriesOnSameDisc.size()); MCAuto newGeoTypesPerChunk4=DataArrayIdType::New(); newGeoTypesPerChunk4->alloc(szEntities,nbi); int id=0; - for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++,id++) + for(auto it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++,id++) { - mcIdType startOfEltIdOfChunk=(*it)->_start; + mcIdType const startOfEltIdOfChunk=(*it)->_start; MCAuto newEltIds=explicitIdsInMesh->subArray(startOfEltIdOfChunk,startOfEltIdOfChunk+(*it)->_nval); MCAuto rangeIdsForChunk=newEltIds->findRangeIdForEachTuple(ranges); MCAuto idsInRrangeForChunk=newEltIds->findIdInRangeForEachTuple(ranges); @@ -1070,7 +1095,7 @@ bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(mcIdType offset, const st MCAuto newGeoTypesEltIdsAllGather=DataArrayIdType::Aggregate(newGeoTypesPerChunk2); newGeoTypesPerChunk.clear(); newGeoTypesPerChunk2.clear(); MCAuto newGeoTypesEltIdsAllGather2=DataArrayIdType::Aggregate(newGeoTypesPerChunk3); newGeoTypesPerChunk_bis.clear(); newGeoTypesPerChunk3.clear(); MCAuto diffVals=newGeoTypesEltIdsAllGather->getDifferentValues(); - MCAuto renumEltIds=newGeoTypesEltIdsAllGather->buildPermArrPerLevel(); + MCAuto const renumEltIds=newGeoTypesEltIdsAllGather->buildPermArrPerLevel(); // MCAuto renumTupleIds=newGeoTypesPerChunk4->buildPermArrPerLevel(); // @@ -1085,9 +1110,9 @@ bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(mcIdType offset, const st { MCAuto ids=newGeoTypesEltIdsAllGather->findIdsEqual(*idIt); MCAuto subIds=newGeoTypesEltIdsAllGather2->selectByTupleId(ids->begin(),ids->end()); - mcIdType nbEntityElts=subIds->getNumberOfTuples(); + mcIdType const nbEntityElts=subIds->getNumberOfTuples(); bool ret2; - MCAuto eltToAdd=MEDFileFieldPerMeshPerTypePerDisc:: + MCAuto const eltToAdd=MEDFileFieldPerMeshPerTypePerDisc:: NewObjectOnSameDiscThanPool(type,(INTERP_KERNEL::NormalizedCellType)newCode[3*(*idIt)],subIds,!subIds->isIota(newCode[3*(*idIt)+1]),nbi, offset+offset2, li,glob,ret2); @@ -1119,8 +1144,8 @@ MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewObjectO MEDFileFieldGlobsReal& glob, bool ¬InExisting) { - mcIdType nbMeshEntities=idsOfMeshElt->getNumberOfTuples(); - std::list< const MEDFileFieldPerMeshPerTypePerDisc *>::iterator it=entriesOnSameDisc.begin(); + mcIdType const nbMeshEntities=idsOfMeshElt->getNumberOfTuples(); + auto it=entriesOnSameDisc.begin(); for(;it!=entriesOnSameDisc.end();it++) { if(((INTERP_KERNEL::NormalizedCellType)(*it)->_loc_id)==geoType && (*it)->_nval==nbMeshEntities) @@ -1142,7 +1167,7 @@ MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewObjectO if(it==entriesOnSameDisc.end()) { notInExisting=true; - MEDFileFieldPerMeshPerTypePerDisc *ret=new MEDFileFieldPerMeshPerTypePerDisc; + auto *ret=new MEDFileFieldPerMeshPerTypePerDisc; ret->_type=typeF; ret->_loc_id=(int)geoType; ret->_nval=nbMeshEntities; @@ -1172,8 +1197,7 @@ MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewObjectO //////////////////////////////////// MEDFileFieldPerMeshPerTypeCommon::~MEDFileFieldPerMeshPerTypeCommon() -{ -} += default; void MEDFileFieldPerMeshPerTypeCommon::setFather(MEDFileFieldPerMesh *father) { @@ -1182,10 +1206,10 @@ void MEDFileFieldPerMeshPerTypeCommon::setFather(MEDFileFieldPerMesh *father) void MEDFileFieldPerMeshPerTypeCommon::accept(MEDFileFieldVisitor& visitor) const { - for(std::vector< MCAuto >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++) - if((*it).isNotNull()) + for(const auto & it : _field_pm_pt_pd) + if(it.isNotNull()) { - visitor.newPerMeshPerTypePerDisc(*it); + visitor.newPerMeshPerTypePerDisc(it); } } @@ -1207,16 +1231,16 @@ std::size_t MEDFileFieldPerMeshPerTypeCommon::getHeapMemorySizeWithoutChildren() std::vector MEDFileFieldPerMeshPerTypeCommon::getDirectChildrenWithNull() const { std::vector ret; - for(std::vector< MCAuto >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++) - ret.push_back((const MEDFileFieldPerMeshPerTypePerDisc *)*it); + for(const auto & it : _field_pm_pt_pd) + ret.push_back((const MEDFileFieldPerMeshPerTypePerDisc *)it); return ret; } void MEDFileFieldPerMeshPerTypeCommon::assignFieldNoProfile(mcIdType& start, mcIdType offset, mcIdType nbOfCells, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) { - std::vector pos=addNewEntryIfNecessary(field,offset,nbOfCells); - for(std::vector::const_iterator it=pos.begin();it!=pos.end();it++) - _field_pm_pt_pd[*it]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc); + std::vector const pos=addNewEntryIfNecessary(field,offset,nbOfCells); + for(long const po : pos) + _field_pm_pt_pd[po]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc); } /*! @@ -1230,9 +1254,9 @@ void MEDFileFieldPerMeshPerTypeCommon::assignFieldNoProfile(mcIdType& start, mcI */ void MEDFileFieldPerMeshPerTypeCommon::assignFieldProfile(bool isPflAlone, mcIdType& start, const DataArrayIdType *multiTypePfl, const DataArrayIdType *idsInPfl, DataArrayIdType *locIds, mcIdType nbOfEltsInWholeMesh, const MEDCouplingFieldTemplate *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) { - std::vector pos=addNewEntryIfNecessary(field,idsInPfl); - for(std::vector::const_iterator it=pos.begin();it!=pos.end();it++) - _field_pm_pt_pd[*it]->assignFieldProfile(isPflAlone,start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,arr,mesh,glob,nasc); + std::vector const pos=addNewEntryIfNecessary(field,idsInPfl); + for(long const po : pos) + _field_pm_pt_pd[po]->assignFieldProfile(isPflAlone,start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,arr,mesh,glob,nasc); } void MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldNoProfile(mcIdType& start, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob) @@ -1249,16 +1273,16 @@ void MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldProfile(mcIdType& start, c throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldProfile : input array is null, or not allocated !"); _field_pm_pt_pd.resize(1); _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3); - _field_pm_pt_pd[0]->assignFieldProfile(true,start,pfl,pfl2,pfl2,-1,field,arr,0,glob,nasc);//mesh is not requested so 0 is send. + _field_pm_pt_pd[0]->assignFieldProfile(true,start,pfl,pfl2,pfl2,-1,field,arr,nullptr,glob,nasc);//mesh is not requested so 0 is send. } std::vector MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(const MEDCouplingFieldTemplate *field, mcIdType offset, mcIdType nbOfCells) { - TypeOfField type=field->getTypeOfField(); + TypeOfField const type=field->getTypeOfField(); if(type!=ON_GAUSS_PT) { - int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0); - std::size_t sz=_field_pm_pt_pd.size(); + int const locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0); + std::size_t const sz=_field_pm_pt_pd.size(); bool found=false; for(std::size_t j=0;j MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(c else { std::vector ret2=addNewEntryIfNecessaryGauss(field,offset,nbOfCells); - std::size_t sz2=ret2.size(); + std::size_t const sz2=ret2.size(); std::vector ret3(sz2); mcIdType k=0; for(std::size_t i=0;i MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(c std::vector MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessaryGauss(const MEDCouplingFieldTemplate *field, mcIdType offset, mcIdType nbOfCells) { const MEDCouplingFieldDiscretization *disc=field->getDiscretization(); - const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast(disc); + const auto *disc2=dynamic_cast(disc); if(!disc2) throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !"); const DataArrayIdType *da=disc2->getArrayOfDiscIds(); @@ -1326,11 +1350,11 @@ std::vector MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessaryGa std::vector MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(const MEDCouplingFieldTemplate *field, const DataArrayIdType *subCells) { - TypeOfField type=field->getTypeOfField(); + TypeOfField const type=field->getTypeOfField(); if(type!=ON_GAUSS_PT) { - int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0); - std::size_t sz=_field_pm_pt_pd.size(); + int const locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0); + std::size_t const sz=_field_pm_pt_pd.size(); bool found=false; for(std::size_t j=0;j MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(c else { std::vector ret2=addNewEntryIfNecessaryGauss(field,subCells); - std::size_t sz2=ret2.size(); + std::size_t const sz2=ret2.size(); std::vector ret3(sz2); mcIdType k=0; for(std::size_t i=0;i MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(c std::vector MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessaryGauss(const MEDCouplingFieldTemplate *field, const DataArrayIdType *subCells) { const MEDCouplingFieldDiscretization *disc=field->getDiscretization(); - const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast(disc); + const auto *disc2=dynamic_cast(disc); if(!disc2) throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !"); const DataArrayIdType *da=disc2->getArrayOfDiscIds(); @@ -1404,7 +1428,7 @@ const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerTypeCommon::getFather() const bool MEDFileFieldPerMeshPerTypeCommon::isUniqueLevel(int& dim) const { const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(getGeoType())); - int curDim((int)cm.getDimension()); + int const curDim((int)cm.getDimension()); if(dim!=std::numeric_limits::max()) { if(dim!=curDim) @@ -1417,15 +1441,15 @@ bool MEDFileFieldPerMeshPerTypeCommon::isUniqueLevel(int& dim) const void MEDFileFieldPerMeshPerTypeCommon::fillTypesOfFieldAvailable(std::set& types) const { - for(std::vector< MCAuto >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++) + for(const auto & it : _field_pm_pt_pd) { - (*it)->fillTypesOfFieldAvailable(types); + it->fillTypesOfFieldAvailable(types); } } void MEDFileFieldPerMeshPerTypeCommon::fillFieldSplitedByType(std::vector< std::pair >& dads, std::vector& types, std::vector& pfls, std::vector& locs) const { - std::size_t sz=_field_pm_pt_pd.size(); + std::size_t const sz=_field_pm_pt_pd.size(); dads.resize(sz); types.resize(sz); pfls.resize(sz); locs.resize(sz); for(std::size_t i=0;i >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++) + for(const auto & it : _field_pm_pt_pd) { - globalSz+=(*it)->getNumberOfTuples(); + globalSz+=it->getNumberOfTuples(); } nbOfEntries+=(mcIdType)_field_pm_pt_pd.size(); } @@ -1470,9 +1494,9 @@ std::size_t MEDFileFieldPerMeshPerTypeCommon::getNumberOfComponents() const bool MEDFileFieldPerMeshPerTypeCommon::presenceOfMultiDiscPerGeoType() const { std::size_t nb(0); - for(std::vector< MCAuto >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++) + for(const auto & it : _field_pm_pt_pd) { - const MEDFileFieldPerMeshPerTypePerDisc *fmtd(*it); + const MEDFileFieldPerMeshPerTypePerDisc *fmtd(it); if(fmtd) nb++; } @@ -1506,9 +1530,9 @@ std::vector MEDFileFieldPerMeshPerTypeCommon::getPflsReallyUsed() c { std::vector ret; std::set ret2; - for(std::vector< MCAuto >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++) + for(const auto & it1 : _field_pm_pt_pd) { - std::string tmp=(*it1)->getProfile(); + std::string const tmp=it1->getProfile(); if(!tmp.empty()) if(ret2.find(tmp)==ret2.end()) { @@ -1523,9 +1547,9 @@ std::vector MEDFileFieldPerMeshPerTypeCommon::getLocsReallyUsed() c { std::vector ret; std::set ret2; - for(std::vector< MCAuto >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++) + for(const auto & it1 : _field_pm_pt_pd) { - std::string tmp=(*it1)->getLocalization(); + std::string const tmp=it1->getLocalization(); if(!tmp.empty() && tmp!=MED_GAUSS_ELNO) if(ret2.find(tmp)==ret2.end()) { @@ -1539,10 +1563,10 @@ std::vector MEDFileFieldPerMeshPerTypeCommon::getLocsReallyUsed() c std::vector MEDFileFieldPerMeshPerTypeCommon::getPflsReallyUsedMulti() const { std::vector ret; - std::set ret2; - for(std::vector< MCAuto >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++) + std::set const ret2; + for(const auto & it1 : _field_pm_pt_pd) { - std::string tmp=(*it1)->getProfile(); + std::string const tmp=it1->getProfile(); if(!tmp.empty()) ret.push_back(tmp); } @@ -1552,9 +1576,9 @@ std::vector MEDFileFieldPerMeshPerTypeCommon::getPflsReallyUsedMult std::vector MEDFileFieldPerMeshPerTypeCommon::getLocsReallyUsedMulti() const { std::vector ret; - for(std::vector< MCAuto >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++) + for(const auto & it1 : _field_pm_pt_pd) { - std::string tmp=(*it1)->getLocalization(); + std::string const tmp=it1->getLocalization(); if(!tmp.empty() && tmp!=MED_GAUSS_ELNO) ret.push_back(tmp); } @@ -1563,14 +1587,14 @@ std::vector MEDFileFieldPerMeshPerTypeCommon::getLocsReallyUsedMult void MEDFileFieldPerMeshPerTypeCommon::changePflsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif) { - for(std::vector< MCAuto >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++) - (*it1)->changePflsRefsNamesGen(mapOfModif); + for(auto & it1 : _field_pm_pt_pd) + it1->changePflsRefsNamesGen(mapOfModif); } void MEDFileFieldPerMeshPerTypeCommon::changeLocsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif) { - for(std::vector< MCAuto >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++) - (*it1)->changeLocsRefsNamesGen(mapOfModif); + for(auto & it1 : _field_pm_pt_pd) + it1->changeLocsRefsNamesGen(mapOfModif); } MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId(mcIdType locId) @@ -1585,7 +1609,7 @@ MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypeCommon::getLeafGive std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no such locId available (" << locId; oss2 << ") for geometric type \"" << getGeoTypeRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !"; throw INTERP_KERNEL::Exception(oss2.str().c_str()); - return static_cast(0); + return static_cast(nullptr); } const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId(mcIdType locId) const @@ -1600,13 +1624,13 @@ const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypeCommon::getLe std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no such locId available (" << locId; oss2 << ") for geometric type \"" << getGeoTypeRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !"; throw INTERP_KERNEL::Exception(oss2.str().c_str()); - return static_cast(0); + return static_cast(nullptr); } int MEDFileFieldPerMeshPerTypeCommon::locIdOfLeaf(const MEDFileFieldPerMeshPerTypePerDisc *leaf) const { int ret(0); - for(std::vector< MCAuto >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,ret++) + for(auto it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,ret++) { const MEDFileFieldPerMeshPerTypePerDisc *cand(*it); if(cand==leaf) @@ -1618,7 +1642,7 @@ int MEDFileFieldPerMeshPerTypeCommon::locIdOfLeaf(const MEDFileFieldPerMeshPerTy void MEDFileFieldPerMeshPerTypeCommon::fillValues(mcIdType& startEntryId, std::vector< std::pair,std::pair > >& entries) const { int i=0; - for(std::vector< MCAuto >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++) + for(auto it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++) { (*it)->fillValues(i,startEntryId,entries); } @@ -1627,8 +1651,8 @@ void MEDFileFieldPerMeshPerTypeCommon::fillValues(mcIdType& startEntryId, std::v void MEDFileFieldPerMeshPerTypeCommon::setLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves) { _field_pm_pt_pd=leaves; - for(std::vector< MCAuto >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++) - (*it)->setFather(this); + for(auto & it : _field_pm_pt_pd) + it->setFather(this); } /*! @@ -1640,13 +1664,13 @@ bool MEDFileFieldPerMeshPerTypeCommon::keepOnlySpatialDiscretization(TypeOfField { bool ret(false); std::vector< MCAuto > newPmPtPd; - for(std::vector< MCAuto >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++) - if((*it)->getType()==tof) + for(auto & it : _field_pm_pt_pd) + if(it->getType()==tof) { - newPmPtPd.push_back(*it); - std::pair bgEnd; bgEnd.first=(*it)->getStart(); bgEnd.second=(*it)->getEnd(); - (*it)->setNewStart(globalNum); - globalNum=(*it)->getEnd(); + newPmPtPd.push_back(it); + std::pair bgEnd; bgEnd.first=it->getStart(); bgEnd.second=it->getEnd(); + it->setNewStart(globalNum); + globalNum=it->getEnd(); its.push_back(bgEnd); ret=true; } @@ -1665,7 +1689,7 @@ bool MEDFileFieldPerMeshPerTypeCommon::keepOnlyGaussDiscretization(std::size_t i if(_field_pm_pt_pd.size()<=idOfDisc) return false; MCAuto elt(_field_pm_pt_pd[idOfDisc]); - std::vector< MCAuto > newPmPtPd(1,elt); + std::vector< MCAuto > const newPmPtPd(1,elt); std::pair bgEnd; bgEnd.first=_field_pm_pt_pd[idOfDisc]->getStart(); bgEnd.second=_field_pm_pt_pd[idOfDisc]->getEnd(); elt->setNewStart(globalNum); globalNum=elt->getEnd(); @@ -1676,22 +1700,22 @@ bool MEDFileFieldPerMeshPerTypeCommon::keepOnlyGaussDiscretization(std::size_t i void MEDFileFieldPerMeshPerTypeCommon::loadOnlyStructureOfDataRecursively(med_idt fid, mcIdType &start, const MEDFileFieldNameScope& nasc) { - for(std::vector< MCAuto >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++) - (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc); + for(auto & it : _field_pm_pt_pd) + it->loadOnlyStructureOfDataRecursively(fid,start,nasc); } void MEDFileFieldPerMeshPerTypeCommon::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) { - for(std::vector< MCAuto >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++) - (*it)->loadBigArray(fid,nasc); + for(auto & it : _field_pm_pt_pd) + it->loadBigArray(fid,nasc); } void MEDFileFieldPerMeshPerTypeCommon::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const { - for(std::vector< MCAuto >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++) + for(const auto & it : _field_pm_pt_pd) { - (*it)->copyOptionsFrom(*this); - (*it)->writeLL(fid,nasc); + it->copyOptionsFrom(*this); + it->writeLL(fid,nasc); } } @@ -1745,8 +1769,8 @@ void MEDFileFieldPerMeshPerType::getFieldAtLevel(int meshDim, TypeOfField type, if(meshDim!=(int)cm.getDimension()) return ; } - for(std::vector< MCAuto >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++) - (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes); + for(const auto & it : _field_pm_pt_pd) + it->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes); } INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const @@ -1767,14 +1791,14 @@ void MEDFileFieldPerMeshPerType::entriesForMEDfile(TypeOfField mct, med_geometry void MEDFileFieldPerMeshPerType::getDimension(int& dim) const { const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type)); - int curDim((int)cm.getDimension()); + int const curDim((int)cm.getDimension()); dim=std::max(dim,curDim); } void MEDFileFieldPerMeshPerType::simpleRepr(int bkOffset, std::ostream& oss, int id) const { const char startLine[]=" ## "; - std::string startLine2(bkOffset,' '); + std::string const startLine2(bkOffset,' '); std::string startLine3(startLine2); startLine3+=startLine; if(_geo_type!=INTERP_KERNEL::NORM_ERROR) @@ -1786,7 +1810,7 @@ void MEDFileFieldPerMeshPerType::simpleRepr(int bkOffset, std::ostream& oss, int oss << startLine3 << "Entry geometry type #" << id << " is lying on NODES." << std::endl; oss << startLine3 << "Entry is defined on " << _field_pm_pt_pd.size() << " localizations." << std::endl; int i=0; - for(std::vector< MCAuto >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++) + for(auto it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++) { const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it); if(cur) @@ -1822,7 +1846,7 @@ MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileField } if(type==ON_CELLS) { - med_int nbProfiles2(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,mgeoti,pflName,locName)); + med_int const nbProfiles2(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,mgeoti,pflName,locName)); for(int i=0;i=nbProfiles2?MED_DESCENDING_FACE:MED_DESCENDING_EDGE;//not enough words to describe the beauty @@ -1846,14 +1870,14 @@ MCAuto MEDFileFieldPerMeshPerType::Aggregate(mcIdTyp { MCAuto ret(MEDFileFieldPerMeshPerType::New(father,gt)); std::map > > m; - for(std::vector >::const_iterator it=pms.begin();it!=pms.end();it++) + for(const auto & pm : pms) { - for(std::vector< MCAuto >::const_iterator it2=(*it).second->_field_pm_pt_pd.begin();it2!=(*it).second->_field_pm_pt_pd.end();it2++) - m[(*it2)->getType()].push_back(std::pair((*it).first,*it2)); + for(auto it2=pm.second->_field_pm_pt_pd.begin();it2!=pm.second->_field_pm_pt_pd.end();it2++) + m[(*it2)->getType()].push_back(std::pair(pm.first,*it2)); } for(std::map > >::const_iterator it=m.begin();it!=m.end();it++) { - MCAuto agg(MEDFileFieldPerMeshPerTypePerDisc::Aggregate(start,(*it).second,dts,(*it).first,ret,extractInfo)); + MCAuto const agg(MEDFileFieldPerMeshPerTypePerDisc::Aggregate(start,(*it).second,dts,(*it).first,ret,extractInfo)); ret->_field_pm_pt_pd.push_back(agg); } return ret; @@ -1865,7 +1889,7 @@ MEDFileFieldPerMeshPerTypeDyn *MEDFileFieldPerMeshPerTypeDyn::NewOnRead(med_idt { if(!entities) throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeDyn::NewOnRead : null pointer !"); - const MEDFileAllStaticEntitiesPlusDyn *entities2(dynamic_cast(entities)); + const auto *entities2(dynamic_cast(entities)); if(!entities2) throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeDyn::NewOnRead : invalid type of entities !"); const MEDFileStructureElement *se(entities2->getWithGT(idGT)); @@ -1877,11 +1901,11 @@ MEDFileFieldPerMeshPerTypeDyn::MEDFileFieldPerMeshPerTypeDyn(med_idt fid, MEDFil _se.takeRef(se); INTERP_KERNEL::AutoPtr pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); INTERP_KERNEL::AutoPtr locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); - med_int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_STRUCT_ELEMENT,_se->getDynGT(),pflName,locName)); + med_int const nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_STRUCT_ELEMENT,_se->getDynGT(),pflName,locName)); _field_pm_pt_pd.resize(nbProfiles); for(int i=0;igetEntity(),i,NULL); + _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,_se->getEntity(),i,nullptr); } } @@ -1895,12 +1919,12 @@ std::string MEDFileFieldPerMeshPerTypeDyn::getModelName() const return _se->getName(); } -void MEDFileFieldPerMeshPerTypeDyn::getDimension(int& dim) const +void MEDFileFieldPerMeshPerTypeDyn::getDimension(int& /*dim*/) const { throw INTERP_KERNEL::Exception("not implemented yet !"); } -void MEDFileFieldPerMeshPerTypeDyn::entriesForMEDfile(TypeOfField mct, med_geometry_type& gt, med_entity_type& ent) const +void MEDFileFieldPerMeshPerTypeDyn::entriesForMEDfile(TypeOfField /*mct*/, med_geometry_type& gt, med_entity_type& ent) const { gt=getDynGT(); ent=MED_STRUCT_ELEMENT; @@ -1919,13 +1943,13 @@ INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypeDyn::getGeoTypeStati void MEDFileFieldPerMeshPerTypeDyn::simpleRepr(int bkOffset, std::ostream& oss, int id) const { const char startLine[]=" ## "; - std::string startLine2(bkOffset,' '); + std::string const startLine2(bkOffset,' '); std::string startLine3(startLine2); startLine3+=startLine; oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry STRUCTURE_ELEMENT type " << getDynGT() << "." << std::endl; oss << startLine3 << "Entry is defined on " << _field_pm_pt_pd.size() << " localizations." << std::endl; int i=0; - for(std::vector< MCAuto >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++) + for(auto it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++) { if((*it).isNotNull()) (*it)->simpleRepr(bkOffset,oss,i); @@ -1949,7 +1973,7 @@ MEDFileFieldPerMeshPerTypeDyn *MEDFileFieldPerMeshPerTypeDyn::deepCopy(MEDFileFi return ret.retn(); } -void MEDFileFieldPerMeshPerTypeDyn::getFieldAtLevel(int meshDim, TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair >& dads, std::vector& pfls, std::vector& locs, std::vector& geoTypes) const +void MEDFileFieldPerMeshPerTypeDyn::getFieldAtLevel(int /*meshDim*/, TypeOfField /*type*/, const MEDFileFieldGlobsReal * /*glob*/, std::vector< std::pair >& /*dads*/, std::vector& /*pfls*/, std::vector& /*locs*/, std::vector& /*geoTypes*/) const { throw INTERP_KERNEL::Exception("not implemented yet !"); } @@ -1979,8 +2003,8 @@ std::size_t MEDFileFieldPerMesh::getHeapMemorySizeWithoutChildren() const std::vector MEDFileFieldPerMesh::getDirectChildrenWithNull() const { std::vector ret; - for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++) - ret.push_back(*it); + for(const auto & it : _field_pm_pt) + ret.push_back(it); return ret; } @@ -1989,7 +2013,7 @@ MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCopy(MEDFileAnyTypeField1TSWithout MCAuto< MEDFileFieldPerMesh > ret=new MEDFileFieldPerMesh(*this); ret->_father=father; std::size_t i=0; - for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++) + for(auto it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++) { if((*it).isNotNull()) ret->_field_pm_pt[i]=(*it)->deepCopy((MEDFileFieldPerMesh *)(ret)); @@ -1999,11 +2023,11 @@ MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCopy(MEDFileAnyTypeField1TSWithout void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const { - std::string startLine(bkOffset,' '); + std::string const startLine(bkOffset,' '); oss << startLine << "## Field part (" << id << ") lying on mesh \"" << getMeshName() << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl; oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl; int i=0; - for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++) + for(auto it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++) { if((*it).isNotNull()) (*it)->simpleRepr(bkOffset,oss,i); @@ -2021,13 +2045,13 @@ void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh) void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(mcIdType& start, const std::vector& code, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) { - std::size_t nbOfTypes=code.size()/3; + std::size_t const nbOfTypes=code.size()/3; mcIdType offset=0; for(std::size_t i=0;iassignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc); offset+=nbOfCells; } @@ -2044,15 +2068,15 @@ void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(mcIdType& start, const std */ void MEDFileFieldPerMesh::assignFieldProfile(mcIdType& start, const DataArrayIdType *multiTypePfl, const std::vector& code, const std::vector& code2, const std::vector& idsInPflPerType, const std::vector& idsPerType, const MEDCouplingFieldTemplate *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) { - std::size_t nbOfTypes(code.size()/3); + std::size_t const nbOfTypes(code.size()/3); for(std::size_t i=0;iassignNodeFieldNoProfile(start,field,arr,glob); } void MEDFileFieldPerMesh::assignNodeFieldProfile(mcIdType& start, const DataArrayIdType *pfl, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) { - mcIdType pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR); + mcIdType const pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR); _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,arr,glob,nasc); } void MEDFileFieldPerMesh::loadOnlyStructureOfDataRecursively(med_idt fid, mcIdType& start, const MEDFileFieldNameScope& nasc) { - for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++) - (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc); + for(auto & it : _field_pm_pt) + it->loadOnlyStructureOfDataRecursively(fid,start,nasc); } void MEDFileFieldPerMesh::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) { - for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++) - (*it)->loadBigArraysRecursively(fid,nasc); + for(auto & it : _field_pm_pt) + it->loadBigArraysRecursively(fid,nasc); } void MEDFileFieldPerMesh::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const { - std::size_t nbOfTypes=_field_pm_pt.size(); + std::size_t const nbOfTypes=_field_pm_pt.size(); for(std::size_t i=0;icopyOptionsFrom(*this); @@ -2099,27 +2123,27 @@ void MEDFileFieldPerMesh::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc void MEDFileFieldPerMesh::getDimension(int& dim) const { - for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++) - (*it)->getDimension(dim); + for(const auto & it : _field_pm_pt) + it->getDimension(dim); } bool MEDFileFieldPerMesh::isUniqueLevel(int& dim) const { - for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++) - if(!(*it)->isUniqueLevel(dim)) + for(const auto & it : _field_pm_pt) + if(!it->isUniqueLevel(dim)) return false; return true; } void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set& types) const { - for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++) - (*it)->fillTypesOfFieldAvailable(types); + for(const auto & it : _field_pm_pt) + it->fillTypesOfFieldAvailable(types); } std::vector< std::vector< std::pair > > MEDFileFieldPerMesh::getFieldSplitedByType(std::vector& types, std::vector< std::vector >& typesF, std::vector< std::vector >& pfls, std::vector< std::vector > & locs) const { - std::size_t sz=_field_pm_pt.size(); + std::size_t const sz=_field_pm_pt.size(); std::vector< std::vector > > ret(sz); types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz); for(std::size_t i=0;i >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++) + for(const auto & it : _field_pm_pt) { - if((*it).isNull()) + if(it.isNull()) continue; - if((*it)->presenceOfMultiDiscPerGeoType()) + if(it->presenceOfMultiDiscPerGeoType()) return true; } return false; @@ -2175,10 +2199,10 @@ bool MEDFileFieldPerMesh::presenceOfMultiDiscPerGeoType() const bool MEDFileFieldPerMesh::presenceOfStructureElements() const { - for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++) - if((*it).isNotNull()) + for(const auto & it : _field_pm_pt) + if(it.isNotNull()) { - const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast((const MEDFileFieldPerMeshPerTypeCommon *)*it)); + const auto *pt(dynamic_cast((const MEDFileFieldPerMeshPerTypeCommon *)it)); if(pt) return true; } @@ -2187,10 +2211,10 @@ bool MEDFileFieldPerMesh::presenceOfStructureElements() const bool MEDFileFieldPerMesh::onlyStructureElements() const { - for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++) - if((*it).isNotNull()) + for(const auto & it : _field_pm_pt) + if(it.isNotNull()) { - const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast((const MEDFileFieldPerMeshPerTypeCommon *)*it)); + const auto *pt(dynamic_cast((const MEDFileFieldPerMeshPerTypeCommon *)it)); if(!pt) return false; } @@ -2200,13 +2224,13 @@ bool MEDFileFieldPerMesh::onlyStructureElements() const void MEDFileFieldPerMesh::killStructureElements() { std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > res; - for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++) + for(auto & it : _field_pm_pt) { - if((*it).isNotNull()) + if(it.isNotNull()) { - const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast((const MEDFileFieldPerMeshPerTypeCommon *)*it)); + const auto *pt(dynamic_cast((const MEDFileFieldPerMeshPerTypeCommon *)it)); if(!pt) - res.push_back(*it); + res.push_back(it); } } _field_pm_pt=res; @@ -2215,13 +2239,13 @@ void MEDFileFieldPerMesh::killStructureElements() void MEDFileFieldPerMesh::keepOnlyStructureElements() { std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > res; - for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++) + for(auto & it : _field_pm_pt) { - if((*it).isNotNull()) + if(it.isNotNull()) { - const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast((const MEDFileFieldPerMeshPerTypeCommon *)*it)); + const auto *pt(dynamic_cast((const MEDFileFieldPerMeshPerTypeCommon *)it)); if(pt) - res.push_back(*it); + res.push_back(it); } } _field_pm_pt=res; @@ -2230,15 +2254,15 @@ void MEDFileFieldPerMesh::keepOnlyStructureElements() void MEDFileFieldPerMesh::keepOnlyOnSE(const std::string& seName) { std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > res; - for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++) + for(auto & it : _field_pm_pt) { - if((*it).isNotNull()) + if(it.isNotNull()) { - const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast((const MEDFileFieldPerMeshPerTypeCommon *)*it)); + const auto *pt(dynamic_cast((const MEDFileFieldPerMeshPerTypeCommon *)it)); if(!pt) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::keepOnlyOnSE : presence of non SE !"); if(pt->getModelName()==seName) - res.push_back(*it); + res.push_back(it); } } _field_pm_pt=res; @@ -2246,11 +2270,11 @@ void MEDFileFieldPerMesh::keepOnlyOnSE(const std::string& seName) void MEDFileFieldPerMesh::getMeshSENames(std::vector< std::pair >& ps) const { - for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++) + for(const auto & it : _field_pm_pt) { - if((*it).isNotNull()) + if(it.isNotNull()) { - const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast((const MEDFileFieldPerMeshPerTypeCommon *)*it)); + const auto *pt(dynamic_cast((const MEDFileFieldPerMeshPerTypeCommon *)it)); if(pt) { ps.push_back(std::pair(getMeshName(),pt->getModelName())); @@ -2291,20 +2315,20 @@ const std::vector& MEDFileFieldPerMesh::getInfo() const void MEDFileFieldPerMesh::SortArraysPerType(const MEDFileFieldGlobsReal *glob, TypeOfField type, const std::vector& geoTypes, const std::vector< std::pair >& dads, const std::vector& pfls, const std::vector& locs, std::vector& code, std::vector& notNullPfls) { int notNullPflsSz=0; - std::size_t nbOfArrs=geoTypes.size(); + std::size_t const nbOfArrs=geoTypes.size(); for(std::size_t i=0;i geoTypes3(geoTypes.begin(),geoTypes.end()); - std::size_t nbOfDiffGeoTypes=geoTypes3.size(); + std::set const geoTypes3(geoTypes.begin(),geoTypes.end()); + std::size_t const nbOfDiffGeoTypes=geoTypes3.size(); code.resize(3*nbOfDiffGeoTypes); notNullPfls.resize(notNullPflsSz); notNullPflsSz=0; std::size_t j=0; for(std::size_t i=0;i notNullTmp; if(pfls[j]) notNullTmp.push_back(pfls[j]); @@ -2317,11 +2341,11 @@ void MEDFileFieldPerMesh::SortArraysPerType(const MEDFileFieldGlobsReal *glob, T } else break; - std::vector< std::pair > tmpDads(dads.begin()+startZone,dads.begin()+j); - std::vector tmpPfls(pfls.begin()+startZone,pfls.begin()+j); - std::vector tmpLocs(locs.begin()+startZone,locs.begin()+j); + std::vector< std::pair > const tmpDads(dads.begin()+startZone,dads.begin()+j); + std::vector const tmpPfls(pfls.begin()+startZone,pfls.begin()+j); + std::vector const tmpLocs(locs.begin()+startZone,locs.begin()+j); code[3*i]=(mcIdType)refType; - std::vector refType2(1,refType); + std::vector const refType2(1,refType); code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs); if(notNullTmp.empty()) code[3*i+2]=-1; @@ -2338,7 +2362,7 @@ void MEDFileFieldPerMesh::SortArraysPerType(const MEDFileFieldGlobsReal *glob, T */ mcIdType MEDFileFieldPerMesh::ComputeNbOfElems(const MEDFileFieldGlobsReal *glob, TypeOfField type, const std::vector& geoTypes, const std::vector< std::pair >& dads, const std::vector& locs) { - std::size_t sz=dads.size(); + std::size_t const sz=dads.size(); mcIdType ret=0; for(std::size_t i=0;igetNbOfGaussPtPerCell(locs[i]); + int const nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]); ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell; } } @@ -2365,14 +2389,14 @@ std::vector MEDFileFieldPerMesh::getPflsReallyUsed() const { std::vector ret; std::set ret2; - for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++) + for(const auto & it : _field_pm_pt) { - std::vector tmp=(*it)->getPflsReallyUsed(); - for(std::vector::const_iterator it2=tmp.begin();it2!=tmp.end();it2++) - if(ret2.find(*it2)==ret2.end()) + std::vector const tmp=it->getPflsReallyUsed(); + for(const auto & it2 : tmp) + if(ret2.find(it2)==ret2.end()) { - ret.push_back(*it2); - ret2.insert(*it2); + ret.push_back(it2); + ret2.insert(it2); } } return ret; @@ -2381,9 +2405,9 @@ std::vector MEDFileFieldPerMesh::getPflsReallyUsed() const std::vector MEDFileFieldPerMesh::getPflsReallyUsedMulti() const { std::vector ret; - for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++) + for(const auto & it : _field_pm_pt) { - std::vector tmp=(*it)->getPflsReallyUsedMulti(); + std::vector tmp=it->getPflsReallyUsedMulti(); ret.insert(ret.end(),tmp.begin(),tmp.end()); } return ret; @@ -2393,14 +2417,14 @@ std::vector MEDFileFieldPerMesh::getLocsReallyUsed() const { std::vector ret; std::set ret2; - for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++) + for(const auto & it : _field_pm_pt) { - std::vector tmp=(*it)->getLocsReallyUsed(); - for(std::vector::const_iterator it2=tmp.begin();it2!=tmp.end();it2++) - if(ret2.find(*it2)==ret2.end()) + std::vector const tmp=it->getLocsReallyUsed(); + for(const auto & it2 : tmp) + if(ret2.find(it2)==ret2.end()) { - ret.push_back(*it2); - ret2.insert(*it2); + ret.push_back(it2); + ret2.insert(it2); } } return ret; @@ -2409,9 +2433,9 @@ std::vector MEDFileFieldPerMesh::getLocsReallyUsed() const std::vector MEDFileFieldPerMesh::getLocsReallyUsedMulti() const { std::vector ret; - for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++) + for(const auto & it : _field_pm_pt) { - std::vector tmp=(*it)->getLocsReallyUsedMulti(); + std::vector tmp=it->getLocsReallyUsedMulti(); ret.insert(ret.end(),tmp.begin(),tmp.end()); } return ret; @@ -2419,11 +2443,11 @@ std::vector MEDFileFieldPerMesh::getLocsReallyUsedMulti() const bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair >& modifTab) { - for(std::vector< std::pair >::const_iterator it=modifTab.begin();it!=modifTab.end();it++) + for(const auto & it : modifTab) { - if((*it).first==getMeshName()) + if(it.first==getMeshName()) { - setMeshName((*it).second); + setMeshName(it.second); return true; } } @@ -2436,7 +2460,7 @@ void MEDFileFieldPerMesh::convertMedBallIntoClassic() throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : Only managed for single mesh !"); if(_field_pm_pt[0].isNull()) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : null pointer !"); - MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast((MEDFileFieldPerMeshPerTypeCommon *)_field_pm_pt[0])); + auto *pt(dynamic_cast((MEDFileFieldPerMeshPerTypeCommon *)_field_pm_pt[0])); if(!pt) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : this is expected to be marked as structure element !"); if(pt->getNumberOfLoc()!=1) @@ -2467,21 +2491,21 @@ bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const std::string& meshNam DataArray *arr0(getOrCreateAndGetArray());//tony if(!arr0) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values of field is null !"); - DataArrayDouble *arr(dynamic_cast(arr0));//tony + auto *arr(dynamic_cast(arr0));//tony if(!arr0) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values is double ! Not managed for the moment !"); mcIdType sz=0; if(!arr) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !"); - for(std::vector< std::pair,std::pair > >::const_iterator it=entries.begin();it!=entries.end();it++) + for(const auto & entrie : entries) { - if(typesToKeep.find((*it).first.first)!=typesToKeep.end()) + if(typesToKeep.find(entrie.first.first)!=typesToKeep.end()) { - entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second)); - sz+=(*it).second.second-(*it).second.first; + entriesKept.push_back(getLeafGivenTypeAndLocId(entrie.first.first,entrie.first.second)); + sz+=entrie.second.second-entrie.second.first; } else - otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second)); + otherEntries.push_back(getLeafGivenTypeAndLocId(entrie.first.first,entrie.first.second)); } MCAuto renumDefrag=DataArrayIdType::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero(); //////////////////// @@ -2495,34 +2519,34 @@ bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const std::string& meshNam // tupleIdOfStartOfNewChuncksV[sid-1]=sz2; MCAuto explicitIdsOldInArr=DataArrayIdType::New(); explicitIdsOldInArr->alloc(sz,1); mcIdType *workI=explicitIdsOldInArr->getPointer(); - for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++) + for(auto itL2 : *itL1) { - mcIdType delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1; - (*itL2)->setLocId(sz2); - (*itL2)->_tmp_work1=(*itL2)->getStart(); - mcIdType delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2; + mcIdType const delta1=itL2->fillTupleIds(workI); workI+=delta1; sz1+=delta1; + itL2->setLocId(sz2); + itL2->_tmp_work1=itL2->getStart(); + mcIdType const delta2=itL2->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2; } renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1); } explicitIdsOldInMesh->reAlloc(sz2); - mcIdType tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2; + mcIdType const tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2; //////////////////// - MCAuto permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0; + MCAuto permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=nullptr; // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc std::vector< MCAuto > otherEntriesNew; - for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++) + for(auto otherEntrie : otherEntries) { - otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it))); - otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0)); - otherEntriesNew.back()->setLocId((*it)->getGeoType()); + otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*otherEntrie)); + otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ(otherEntrie->getStart(),0)); + otherEntriesNew.back()->setLocId(otherEntrie->getGeoType()); } std::vector< MCAuto > entriesKeptNew; std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2; - for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++) + for(auto it : entriesKept) { - MCAuto elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)); - mcIdType newStart=elt->getLocId(); - elt->setLocId((*it)->getGeoType()); + MCAuto elt=MEDFileFieldPerMeshPerTypePerDisc::New(*it); + mcIdType const newStart=elt->getLocId(); + elt->setLocId(it->getGeoType()); elt->setNewStart(newStart); elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0); entriesKeptNew.push_back(elt); @@ -2531,9 +2555,9 @@ bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const std::string& meshNam MCAuto arr2=arr->renumber(permArrDefrag->getConstPointer()); // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2 MCAuto explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end()); - std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2); + std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > const entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2); bool ret=false; - for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++) + for(const auto & it4 : entriesKeptPerDisc) { sid=0; /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++) @@ -2541,7 +2565,7 @@ bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const std::string& meshNam MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast(*itL2); curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]); }*/ - ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode, + ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,it4,explicitIdsNewInMesh,newCode, glob,arr2,otherEntriesNew) || ret; } if(!ret) @@ -2559,12 +2583,12 @@ bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const std::string& meshNam void MEDFileFieldPerMesh::keepOnlySpatialDiscretization(TypeOfField tof, mcIdType &globalNum, std::vector< std::pair >& its) { std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > ret; - for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++) + for(auto & it : _field_pm_pt) { std::vector< std::pair > its2; - if((*it)->keepOnlySpatialDiscretization(tof,globalNum,its2)) + if(it->keepOnlySpatialDiscretization(tof,globalNum,its2)) { - ret.push_back(*it); + ret.push_back(it); its.insert(its.end(),its2.begin(),its2.end()); } } @@ -2578,12 +2602,12 @@ void MEDFileFieldPerMesh::keepOnlySpatialDiscretization(TypeOfField tof, mcIdTyp void MEDFileFieldPerMesh::keepOnlyGaussDiscretization(std::size_t idOfDisc, mcIdType &globalNum, std::vector< std::pair >& its) { std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > ret; - for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++) + for(auto & it : _field_pm_pt) { std::vector< std::pair > its2; - if((*it)->keepOnlyGaussDiscretization(idOfDisc,globalNum,its2)) + if(it->keepOnlyGaussDiscretization(idOfDisc,globalNum,its2)) { - ret.push_back(*it); + ret.push_back(it); its.insert(its.end(),its2.begin(),its2.end()); } } @@ -2593,17 +2617,17 @@ void MEDFileFieldPerMesh::keepOnlyGaussDiscretization(std::size_t idOfDisc, mcId void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves) { std::map > > types; - for( std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++) - types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it); + for(const auto & leave : leaves) + types[(INTERP_KERNEL::NormalizedCellType)leave->getLocId()].push_back(leave); // std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > fieldPmPt(types.size()); std::map > >::const_iterator it1=types.begin(); - std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it2=fieldPmPt.begin(); + auto it2=fieldPmPt.begin(); for(;it1!=types.end();it1++,it2++) { MCAuto elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId())); elt->setLeaves((*it1).second); - MCAuto elt2(DynamicCast(elt)); + MCAuto const elt2(DynamicCast(elt)); *it2=elt2; } _field_pm_pt=fieldPmPt; @@ -2611,14 +2635,14 @@ void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MCAuto< MEDFileFiel void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif) { - for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++) - (*it)->changePflsRefsNamesGen(mapOfModif); + for(auto & it : _field_pm_pt) + it->changePflsRefsNamesGen(mapOfModif); } void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif) { - for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++) - (*it)->changeLocsRefsNamesGen(mapOfModif); + for(auto & it : _field_pm_pt) + it->changeLocsRefsNamesGen(mapOfModif); } /*! @@ -2635,8 +2659,8 @@ MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField t std::vector locs; std::vectorcode; std::vector geoTypes; - for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++) - (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes); + for(const auto & it : _field_pm_pt) + it->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes); // Sort by types SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType); if(code.empty()) @@ -2645,7 +2669,7 @@ MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField t throw INTERP_KERNEL::Exception(oss.str()); } // - std::vector< MCAuto > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end()); + std::vector< MCAuto > const notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end()); std::vector< const DataArrayIdType *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end()); if(type!=ON_NODES) { @@ -2654,7 +2678,7 @@ MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField t return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc); else { - MCAuto arr2(arr); + MCAuto const arr2(arr); return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl,arrOut,nasc); } } @@ -2662,7 +2686,7 @@ MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField t { if(code.size()!=3) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !"); - mcIdType nb=code[1]; + mcIdType const nb=code[1]; if(code[2]==-1) { if(nb!=mesh->getNumberOfNodes()) @@ -2689,8 +2713,8 @@ DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, c std::vector locs; std::vector code; std::vector geoTypes; - for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++) - (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes); + for(const auto & it : _field_pm_pt) + it->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes); // Sort by types SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType); if(code.empty()) @@ -2698,7 +2722,7 @@ DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, c std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !"; throw INTERP_KERNEL::Exception(oss.str()); } - std::vector< MCAuto > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end()); + std::vector< MCAuto > const notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end()); std::vector< const DataArrayIdType *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end()); if(type!=ON_NODES) { @@ -2709,7 +2733,7 @@ DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, c { if(code.size()!=3) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !"); - mcIdType nb=code[1]; + mcIdType const nb=code[1]; if(code[2]==-1) { if(nb!=mesh->getNumberOfNodes()) @@ -2719,20 +2743,20 @@ DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, c throw INTERP_KERNEL::Exception(oss.str()); } } - return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl); + return finishField4(dads,code[2]==-1?nullptr:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl); } // - return 0; + return nullptr; } void MEDFileFieldPerMesh::accept(MEDFileFieldVisitor& visitor) const { - for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++) - if((*it).isNotNull()) + for(const auto & it : _field_pm_pt) + if(it.isNotNull()) { - visitor.newPerMeshPerTypeEntry(*it); - (*it)->accept(visitor); - visitor.endPerMeshPerTypeEntry(*it); + visitor.newPerMeshPerTypeEntry(it); + it->accept(visitor); + visitor.endPerMeshPerTypeEntry(it); } } @@ -2740,31 +2764,31 @@ void MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++) + for(const auto & it : _field_pm_pt) { - (*it)->getSizes(globalSz,nbOfEntries); + it->getSizes(globalSz,nbOfEntries); } entries.resize(nbOfEntries); nbOfEntries=0; - for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++) + for(const auto & it : _field_pm_pt) { - (*it)->fillValues(nbOfEntries,entries); + it->fillValues(nbOfEntries,entries); } } MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, mcIdType locId) { - for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++) + for(auto & it : _field_pm_pt) { - if((*it)->getGeoType()==typ) - return (*it)->getLeafGivenLocId(locId); + if(it->getGeoType()==typ) + return it->getLeafGivenLocId(locId); } const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ); std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl; oss << "Possibilities are : "; - for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++) + for(const auto & it : _field_pm_pt) { - const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType()); + const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel(it->getGeoType()); oss << "\"" << cm2.getRepr() << "\", "; } throw INTERP_KERNEL::Exception(oss.str()); @@ -2772,17 +2796,17 @@ MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, mcIdType locId) const { - for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++) + for(const auto & it : _field_pm_pt) { - if((*it)->getGeoType()==typ) - return (*it)->getLeafGivenLocId(locId); + if(it->getGeoType()==typ) + return it->getLeafGivenLocId(locId); } const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ); std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl; oss << "Possibilities are : "; - for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++) + for(const auto & it : _field_pm_pt) { - const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType()); + const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel(it->getGeoType()); oss << "\"" << cm2.getRepr() << "\", "; } throw INTERP_KERNEL::Exception(oss.str()); @@ -2799,25 +2823,25 @@ MCAuto MEDFileFieldPerMeshPerTypePerDisc::Agg MCAuto ret(new MEDFileFieldPerMeshPerTypePerDisc(father,tof)); if(pms.empty()) throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : empty input vector !"); - for(std::vector >::const_iterator it=pms.begin();it!=pms.end();it++) + for(const auto & pm : pms) { - if(!(*it).second) + if(!pm.second) throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : presence of null pointer !"); - if(!(*it).second->getProfile().empty()) + if(!pm.second->getProfile().empty()) throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for profiles !"); - if(!(*it).second->getLocalization().empty()) + if(!pm.second->getLocalization().empty()) throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for gauss pts !"); } - INTERP_KERNEL::NormalizedCellType gt(pms[0].second->getGeoType()); + INTERP_KERNEL::NormalizedCellType const gt(pms[0].second->getGeoType()); std::size_t i(0); std::vector< std::pair > filteredDTS; - for(std::vector< std::vector< std::pair > >::const_iterator it=dts.begin();it!=dts.end();it++,i++) - for(std::vector< std::pair >::const_iterator it2=(*it).begin();it2!=(*it).end();it2++) - if((*it2).first==gt) - filteredDTS.push_back(std::pair(i,(*it2).second)); + for(auto it=dts.begin();it!=dts.end();it++,i++) + for(const auto & it2 : *it) + if(it2.first==gt) + filteredDTS.push_back(std::pair(i,it2.second)); if(pms.size()!=filteredDTS.size()) throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for generated profiles !"); - std::vector >::const_iterator it1(pms.begin()); + auto it1(pms.begin()); std::vector< std::pair >::const_iterator it2(filteredDTS.begin()); mcIdType zeStart(start),nval(0); for(;it1!=pms.end();it1++,it2++) @@ -2838,13 +2862,13 @@ MCAuto MEDFileFieldPerMesh::Aggregate(mcIdType &start, cons MCAuto ret(new MEDFileFieldPerMesh(father,pms[0]->getMeshName(),pms[0]->getMeshIteration(),pms[0]->getMeshOrder())); std::map > > m; std::size_t i(0); - for(std::vector::const_iterator it=pms.begin();it!=pms.end();it++,i++) + for(auto it=pms.begin();it!=pms.end();it++,i++) { const std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >& v((*it)->_field_pm_pt); - for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it2=v.begin();it2!=v.end();it2++) + for(const auto & it2 : v) { - INTERP_KERNEL::NormalizedCellType gt((*it2)->getGeoType()); - const MEDFileFieldPerMeshPerType *elt(dynamic_cast((const MEDFileFieldPerMeshPerTypeCommon *)(*it2))); + INTERP_KERNEL::NormalizedCellType const gt(it2->getGeoType()); + const auto *elt(dynamic_cast((const MEDFileFieldPerMeshPerTypeCommon *)it2)); if(!elt) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::Aggregate : not managed for structelement !"); m[gt].push_back(std::pair(i,elt)); @@ -2853,7 +2877,7 @@ MCAuto MEDFileFieldPerMesh::Aggregate(mcIdType &start, cons for(std::map > >::const_iterator it=m.begin();it!=m.end();it++) { MCAuto agg(MEDFileFieldPerMeshPerType::Aggregate(start,(*it).second,dts,(*it).first,ret,extractInfo)); - MCAuto agg2(DynamicCast(agg)); + MCAuto const agg2(DynamicCast(agg)); ret->_field_pm_pt.push_back(agg2); } return ret; @@ -2862,21 +2886,21 @@ MCAuto MEDFileFieldPerMesh::Aggregate(mcIdType &start, cons int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type) { int i=0; - std::size_t pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type)); - std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it2=_field_pm_pt.begin(); - for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++) + std::size_t const pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type)); + auto it2=_field_pm_pt.begin(); + for(auto it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++) { - INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType(); + INTERP_KERNEL::NormalizedCellType const curType=(*it)->getGeoType(); if(type==curType) return i; else { - std::size_t pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType)); + std::size_t const pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType)); if(pos>pos2) it2=it+1; } } - std::size_t ret=std::distance(_field_pm_pt.begin(),it2); + std::size_t const ret=std::distance(_field_pm_pt.begin(),it2); _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type)); return (int)ret; } @@ -2899,12 +2923,12 @@ MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const if(type==ON_GAUSS_PT) { mcIdType offset=0; - std::size_t nbOfArrs=dads.size(); + std::size_t const nbOfArrs=dads.size(); for(std::size_t i=0;i > dads2(1,dads[i]); const std::vector locs2(1,locs[i]); + std::vector > const dads2(1,dads[i]); const std::vector locs2(1,locs[i]); const std::vector geoTypes2(1,INTERP_KERNEL::NORM_ERROR); - mcIdType nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2); + mcIdType const nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2); MCAuto di=DataArrayIdType::New(); di->alloc(nbOfElems,1); di->iota(offset); @@ -2926,7 +2950,7 @@ MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const */ MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob, const std::vector >& dads, const std::vector& locs, - const std::vector& geoTypes, + const std::vector& /*geoTypes*/, const MEDCouplingMesh *mesh, const DataArrayIdType *da, bool& isPfl, MCAuto& arrOut, const MEDFileFieldNameScope& nasc) const { if(da->isIota(mesh->getNumberOfCells())) @@ -2948,15 +2972,15 @@ MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileField if(da->isIota(mesh->getNumberOfNodes())) return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc); // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1. - const MEDCouplingUMesh *meshu=dynamic_cast(mesh); + const auto *meshu=dynamic_cast(mesh); if(meshu) { - if(meshu->getNodalConnectivity()==0) + if(meshu->getNodalConnectivity()==nullptr) { MCAuto ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl,arrOut,nasc); - mcIdType nb=da->getNbOfElems(); + mcIdType const nb=da->getNbOfElems(); const mcIdType *ptr=da->getConstPointer(); - MEDCouplingUMesh *meshuc=const_cast(meshu); + auto *meshuc=const_cast(meshu); meshuc->allocateCells(nb); for(mcIdType i=0;iinsertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i); @@ -2971,11 +2995,11 @@ MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileField // MCAuto ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc); isPfl=true; - DataArrayIdType *arr2=0; + DataArrayIdType *arr2=nullptr; MCAuto cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems()); MCAuto mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2); - MCAuto arr3(arr2); - mcIdType nnodes=mesh2->getNumberOfNodes(); + MCAuto const arr3(arr2); + mcIdType const nnodes=mesh2->getNumberOfNodes(); if(nnodes==(mcIdType)da->getNbOfElems()) { MCAuto da3=da->transformWithIndArrR(arr2->begin(),arr2->end()); @@ -2994,7 +3018,7 @@ MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileField oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !"; throw INTERP_KERNEL::Exception(oss.str()); } - return 0; + return nullptr; } /*! @@ -3016,7 +3040,7 @@ DataArray *MEDFileFieldPerMesh::finishField4(const std::vector safePfl(pflOut); MCAuto da=getOrCreateAndGetArray()->selectByTupleRanges(dads); const std::vector& infos=getInfo(); - std::size_t nbOfComp=infos.size(); + std::size_t const nbOfComp=infos.size(); for(std::size_t i=0;isetInfoOnComponent(i,infos[i].c_str()); safePfl->incrRef(); @@ -3031,7 +3055,7 @@ class MFFPMIter // MEDFileFieldPerMeshIterator public: static MFFPMIter *NewCell(const MEDFileEntities *entities); static bool IsPresenceOfNode(const MEDFileEntities *entities); - virtual ~MFFPMIter() { } + virtual ~MFFPMIter() = default; virtual void begin() = 0; virtual bool finished() const = 0; virtual void next() = 0; @@ -3041,23 +3065,23 @@ public: class MFFPMIterSimple : public MFFPMIter { public: - MFFPMIterSimple():_pos(0) { } - void begin() { _pos=0; } - bool finished() const { return _pos>=MED_N_CELL_FIXED_GEO; } - void next() { _pos++; } - int current() const { return _pos; } + MFFPMIterSimple() = default; + void begin() override { _pos=0; } + bool finished() const override { return _pos>=MED_N_CELL_FIXED_GEO; } + void next() override { _pos++; } + int current() const override { return _pos; } private: - int _pos; + int _pos{0}; }; class MFFPMIter2 : public MFFPMIter { public: MFFPMIter2(const std::vector& cts); - void begin() { _it=_ids.begin(); } - bool finished() const { return _it==_ids.end(); } - void next() { _it++; } - int current() const { return *_it; } + void begin() override { _it=_ids.begin(); } + bool finished() const override { return _it==_ids.end(); } + void next() override { _it++; } + int current() const override { return *_it; } private: std::vector _ids; std::vector::const_iterator _it; @@ -3069,15 +3093,15 @@ MFFPMIter *MFFPMIter::NewCell(const MEDFileEntities *entities) return new MFFPMIterSimple; else { - const MEDFileStaticEntities *entities2(dynamic_cast(entities)); + const auto *entities2(dynamic_cast(entities)); if(entities2) { std::vector tmp; const std::vector< std::pair >& myEnt(entities2->getEntries()); - for(std::vector< std::pair >::const_iterator it=myEnt.begin();it!=myEnt.end();it++) + for(const auto & it : myEnt) { - if((*it).first==ON_CELLS || (*it).first==ON_GAUSS_NE || (*it).first==ON_GAUSS_PT) - tmp.push_back((*it).second); + if(it.first==ON_CELLS || it.first==ON_GAUSS_NE || it.first==ON_GAUSS_PT) + tmp.push_back(it.second); } return new MFFPMIter2(tmp); } @@ -3091,12 +3115,12 @@ bool MFFPMIter::IsPresenceOfNode(const MEDFileEntities *entities) return true; else { - const MEDFileStaticEntities *entities2(dynamic_cast(entities)); + const auto *entities2(dynamic_cast(entities)); if(entities2) { const std::vector< std::pair >& myEnt(entities2->getEntries()); - for(std::vector< std::pair >::const_iterator it=myEnt.begin();it!=myEnt.end();it++) - if((*it).first==ON_NODES) + for(const auto & it : myEnt) + if(it.first==ON_NODES) return true; return false; } @@ -3106,7 +3130,7 @@ bool MFFPMIter::IsPresenceOfNode(const MEDFileEntities *entities) MFFPMIter2::MFFPMIter2(const std::vector& cts) { - std::size_t sz(cts.size()); + std::size_t const sz(cts.size()); _ids.resize(sz); for(std::size_t i=0;i meshName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)); INTERP_KERNEL::AutoPtr pflName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)); INTERP_KERNEL::AutoPtr locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)); - const MEDFileUMesh *mmu(dynamic_cast(mm)); + const auto *mmu(dynamic_cast(mm)); INTERP_KERNEL::AutoCppPtr iter0(MFFPMIter::NewCell(entities)); // for each geometric type inside my mesh, check if there is a field profile ie if the field is defined on this type of cells (whether the discretization is on cells or on gauss_ne) // and if this is the case, retrieve the part to be read and build a new MedFileField from it for(iter0->begin();!iter0->finished();iter0->next()) { - med_int nbProfile (MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL ,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName)); - std::string name0(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1)); - med_int nbProfile2(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName)); - std::string name1(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1)); + med_int const nbProfile (MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL ,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName)); + std::string const name0(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1)); + med_int const nbProfile2(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName)); + std::string const name1(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1)); if(nbProfile>0 || nbProfile2>0) { - const PartDefinition *pd(0); + const PartDefinition *pd(nullptr); if(mmu) pd=mmu->getPartDefAtLevel(mmu->getRelativeLevOnGeoType(typmai2[iter0->current()]),typmai2[iter0->current()]); _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[iter0->current()],nasc,pd)); @@ -3156,10 +3180,10 @@ MEDFileFieldPerMesh::MEDFileFieldPerMesh(med_idt fid, MEDFileAnyTypeField1TSWith if(MFFPMIter::IsPresenceOfNode(entities)) { // if there is a profile on nodes for the current field, retrieve the part to be read and build a new MedFileField from it - med_int nbProfile(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,meshCsit+1,meshName,pflName,locName)); + med_int const nbProfile(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,meshCsit+1,meshName,pflName,locName)); if(nbProfile>0) { - const PartDefinition *pd(0); + const PartDefinition *pd(nullptr); if(mmu) pd=mmu->getPartDefAtLevel(1,INTERP_KERNEL::NORM_ERROR); _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc,pd)); @@ -3168,13 +3192,13 @@ MEDFileFieldPerMesh::MEDFileFieldPerMesh(med_idt fid, MEDFileAnyTypeField1TSWith } if(!entities) return ; - std::vector dynGT(entities->getDynGTAvail()); - for(std::vector::const_iterator it=dynGT.begin();it!=dynGT.end();it++) + std::vector const dynGT(entities->getDynGTAvail()); + for(int const it : dynGT) { - med_int nbPfl(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_STRUCT_ELEMENT,*it,pflName,locName)); + med_int const nbPfl(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_STRUCT_ELEMENT,it,pflName,locName)); if(nbPfl>0) { - _field_pm_pt.push_back(MEDFileFieldPerMeshPerTypeDyn::NewOnRead(fid,this,entities,*it,nasc)); + _field_pm_pt.push_back(MEDFileFieldPerMeshPerTypeDyn::NewOnRead(fid,this,entities,it,nasc)); setMeshName(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE)); } } @@ -3184,13 +3208,13 @@ MEDFileFieldPerMesh::MEDFileFieldPerMesh(med_idt fid, MEDFileAnyTypeField1TSWith iter0=MFFPMIter::NewCell(entities); for(iter0->begin();!iter0->finished();iter0->next()) { - med_int nbProfile (MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_DESCENDING_FACE,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName)); - std::string name0(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1)); - med_int nbProfile2(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_DESCENDING_EDGE,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName)); - std::string name1(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1)); + med_int const nbProfile (MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_DESCENDING_FACE,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName)); + std::string const name0(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1)); + med_int const nbProfile2(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_DESCENDING_EDGE,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName)); + std::string const name1(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1)); if(nbProfile>0 || nbProfile2>0) { - _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[iter0->current()],nasc,NULL)); + _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[iter0->current()],nasc,nullptr)); if(nbProfile>0) setMeshName(name0); else @@ -3208,10 +3232,10 @@ MEDFileFieldPerMesh::MEDFileFieldPerMesh(med_idt fid, MEDFileAnyTypeField1TSWith INTERP_KERNEL::AutoCppPtr iter0(MFFPMIter::NewCell(entities)); for(iter0->begin();!iter0->finished();iter0->next()) { - med_int nbProfile (MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL ,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName)); - std::string name0(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1)); - med_int nbProfile2(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName)); - std::string name1(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1)); + med_int const nbProfile (MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL ,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName)); + std::string const name0(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1)); + med_int const nbProfile2(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName)); + std::string const name1(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1)); if(nbProfile>0 || nbProfile2>0) { _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[iter0->current()],nasc,pd)); @@ -3224,7 +3248,7 @@ MEDFileFieldPerMesh::MEDFileFieldPerMesh(med_idt fid, MEDFileAnyTypeField1TSWith if(MFFPMIter::IsPresenceOfNode(entities)) { - med_int nbProfile(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,meshCsit+1,meshName,pflName,locName)); + med_int const nbProfile(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,meshCsit+1,meshName,pflName,locName)); if(nbProfile>0) { _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc,pd)); diff --git a/src/MEDLoader/MEDFileFieldInternal.hxx b/src/MEDLoader/MEDFileFieldInternal.hxx index e2270e5dd..b0c9619e4 100644 --- a/src/MEDLoader/MEDFileFieldInternal.hxx +++ b/src/MEDLoader/MEDFileFieldInternal.hxx @@ -21,6 +21,10 @@ #ifndef __MEDFILEFIELDINTERNAL_HXX__ #define __MEDFILEFIELDINTERNAL_HXX__ +#include "MEDCouplingRefCountObject.hxx" +#include "MEDCouplingMemArray.hxx" +#include "MCType.hxx" +#include "MEDCouplingTraits.hxx" #include "MEDLoaderDefines.hxx" #include "MEDFileUtilities.hxx" #include "NormalizedGeometricTypes" @@ -29,8 +33,13 @@ #include "med.h" +#include +#include +#include #include #include +#include +#include namespace MEDCoupling { @@ -48,10 +57,10 @@ namespace MEDCoupling { public: MEDFileGTKeeperSta(INTERP_KERNEL::NormalizedCellType gt):_geo_type(gt) { } - MEDFileGTKeeper *deepCopy() const; - INTERP_KERNEL::NormalizedCellType getGeoType() const; - std::string getRepr() const; - bool isEqual(const MEDFileGTKeeper *other) const; + MEDFileGTKeeper *deepCopy() const override; + INTERP_KERNEL::NormalizedCellType getGeoType() const override; + std::string getRepr() const override; + bool isEqual(const MEDFileGTKeeper *other) const override; private: INTERP_KERNEL::NormalizedCellType _geo_type; }; @@ -64,10 +73,10 @@ namespace MEDCoupling { public: MEDFileGTKeeperDyn(const MEDFileUMesh *mesh, const MEDFileUMesh *section, const MEDFileStructureElement *se); - MEDFileGTKeeper *deepCopy() const; - INTERP_KERNEL::NormalizedCellType getGeoType() const; - std::string getRepr() const; - bool isEqual(const MEDFileGTKeeper *other) const; + MEDFileGTKeeper *deepCopy() const override; + INTERP_KERNEL::NormalizedCellType getGeoType() const override; + std::string getRepr() const override; + bool isEqual(const MEDFileGTKeeper *other) const override; const MEDFileUMesh *getMesh() const { return _mesh; } const MEDFileUMesh *getSection() const { return _section; } const MEDFileStructureElement *getSE() const { return _se; } @@ -89,8 +98,8 @@ namespace MEDCoupling static MEDFileFieldLoc *New(med_idt fid, const std::string& locName); static MEDFileFieldLoc *New(med_idt fid, int i, const MEDFileEntities *entities); static MEDFileFieldLoc *New(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector& refCoo, const std::vector& gsCoo, const std::vector& w); - std::size_t getHeapMemorySizeWithoutChildren() const; - std::vector getDirectChildrenWithNull() const; + std::size_t getHeapMemorySizeWithoutChildren() const override; + std::vector getDirectChildrenWithNull() const override; MEDFileFieldLoc *deepCopy() const; bool isOnStructureElement() const; const MEDFileGTKeeper *getUndergroundGTKeeper() const { return _gt; } @@ -137,8 +146,8 @@ namespace MEDCoupling static MEDFileFieldPerMeshPerTypePerDisc *New(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, mcIdType locId); static MEDFileFieldPerMeshPerTypePerDisc *New(const MEDFileFieldPerMeshPerTypePerDisc& other); std::string getClassName() const override { return std::string("MEDFileFieldPerMeshPerTypePerDisc"); } - std::size_t getHeapMemorySizeWithoutChildren() const; - std::vector getDirectChildrenWithNull() const; + std::size_t getHeapMemorySizeWithoutChildren() const override; + std::vector getDirectChildrenWithNull() const override; MEDFileFieldPerMeshPerTypePerDisc *deepCopy(MEDFileFieldPerMeshPerTypeCommon *father) const; void assignFieldNoProfile(mcIdType& start, mcIdType offset, mcIdType nbOfCells, const MEDCouplingFieldTemplate *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc); void assignFieldProfile(bool isPflAlone, mcIdType& start, const DataArrayIdType *multiTypePfl, const DataArrayIdType *idsInPfl, DataArrayIdType *locIds, mcIdType nbOfEltsInWholeMesh, const MEDCouplingFieldTemplate *field, const DataArray *arrr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc); @@ -224,8 +233,8 @@ namespace MEDCoupling { public: std::string getClassName() const override { return std::string("MEDFileFieldPerMeshPerTypeCommon"); } - std::size_t getHeapMemorySizeWithoutChildren() const; - std::vector getDirectChildrenWithNull() const; + std::size_t getHeapMemorySizeWithoutChildren() const override; + std::vector getDirectChildrenWithNull() const override; void assignFieldNoProfile(mcIdType& start, mcIdType offset, mcIdType nbOfCells, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc); void assignFieldProfile(bool isPflAlone, mcIdType& start, const DataArrayIdType *multiTypePfl, const DataArrayIdType *idsInPfl, DataArrayIdType *locIds, mcIdType nbOfEltsInWholeMesh, const MEDCouplingFieldTemplate *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc); void assignNodeFieldNoProfile(mcIdType& start, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob); @@ -267,7 +276,7 @@ namespace MEDCoupling void setFather(MEDFileFieldPerMesh *father); void accept(MEDFileFieldVisitor& visitor) const; public: - virtual ~MEDFileFieldPerMeshPerTypeCommon(); + ~MEDFileFieldPerMeshPerTypeCommon() override; virtual void getDimension(int& dim) const = 0; virtual INTERP_KERNEL::NormalizedCellType getGeoType() const = 0; virtual INTERP_KERNEL::NormalizedCellType getGeoTypeStatic() const = 0; @@ -296,14 +305,14 @@ namespace MEDCoupling static MEDFileFieldPerMeshPerType *NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd); static MCAuto Aggregate(mcIdType &start, const std::vector< std::pair >& pms, const std::vector< std::vector< std::pair > >& dts, INTERP_KERNEL::NormalizedCellType gt, MEDFileFieldPerMesh *father, std::vector > >& extractInfo); public:// overload of abstract methods - void getDimension(int& dim) const; + void getDimension(int& dim) const override; INTERP_KERNEL::NormalizedCellType getGeoType() const override; INTERP_KERNEL::NormalizedCellType getGeoTypeStatic() const override; - void entriesForMEDfile(TypeOfField mct, med_geometry_type& gt, med_entity_type& ent) const; - void simpleRepr(int bkOffset, std::ostream& oss, int id) const; - std::string getGeoTypeRepr() const; - MEDFileFieldPerMeshPerType *deepCopy(MEDFileFieldPerMesh *father) const; - void getFieldAtLevel(int meshDim, TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair >& dads, std::vector& pfls, std::vector& locs, std::vector& geoTypes) const; + void entriesForMEDfile(TypeOfField mct, med_geometry_type& gt, med_entity_type& ent) const override; + void simpleRepr(int bkOffset, std::ostream& oss, int id) const override; + std::string getGeoTypeRepr() const override; + MEDFileFieldPerMeshPerType *deepCopy(MEDFileFieldPerMesh *father) const override; + void getFieldAtLevel(int meshDim, TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair >& dads, std::vector& pfls, std::vector& locs, std::vector& geoTypes) const override; private: MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd); MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *father, INTERP_KERNEL::NormalizedCellType gt); @@ -319,14 +328,14 @@ namespace MEDCoupling int getDynGT() const; std::string getModelName() const; public: - void getDimension(int& dim) const; + void getDimension(int& dim) const override; INTERP_KERNEL::NormalizedCellType getGeoType() const override; INTERP_KERNEL::NormalizedCellType getGeoTypeStatic() const override; - void entriesForMEDfile(TypeOfField mct, med_geometry_type& gt, med_entity_type& ent) const; - void simpleRepr(int bkOffset, std::ostream& oss, int id) const; - std::string getGeoTypeRepr() const; - MEDFileFieldPerMeshPerTypeDyn *deepCopy(MEDFileFieldPerMesh *father) const; - void getFieldAtLevel(int meshDim, TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair >& dads, std::vector& pfls, std::vector& locs, std::vector& geoTypes) const; + void entriesForMEDfile(TypeOfField mct, med_geometry_type& gt, med_entity_type& ent) const override; + void simpleRepr(int bkOffset, std::ostream& oss, int id) const override; + std::string getGeoTypeRepr() const override; + MEDFileFieldPerMeshPerTypeDyn *deepCopy(MEDFileFieldPerMesh *father) const override; + void getFieldAtLevel(int meshDim, TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair >& dads, std::vector& pfls, std::vector& locs, std::vector& geoTypes) const override; private: MEDFileFieldPerMeshPerTypeDyn(med_idt fid, MEDFileFieldPerMesh *fath, const MEDFileStructureElement *se, const MEDFileFieldNameScope& nasc); private: @@ -344,8 +353,8 @@ namespace MEDCoupling static MEDFileFieldPerMesh *NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const MEDFileEntities *entities); static MEDFileFieldPerMesh *NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const PartDefinition *pd, const MEDFileEntities *entities); std::string getClassName() const override { return std::string("MEDFileFieldPerMesh"); } - std::size_t getHeapMemorySizeWithoutChildren() const; - std::vector getDirectChildrenWithNull() const; + std::size_t getHeapMemorySizeWithoutChildren() const override; + std::vector getDirectChildrenWithNull() const override; MEDFileFieldPerMesh *deepCopy(MEDFileAnyTypeField1TSWithoutSDA *father) const; void simpleRepr(int bkOffset,std::ostream& oss, int id) const; void copyTinyInfoFrom(const MEDCouplingMesh *mesh); @@ -416,7 +425,7 @@ namespace MEDCoupling MEDFileFieldPerMesh(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const MEDFileEntities *entities); MEDFileFieldPerMesh(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const PartDefinition *pd, const MEDFileEntities *entities); MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh); - MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const std::string& meshName, int meshIt, int meshOrd):_mesh_iteration(meshIt),_mesh_order(meshOrd),_father(fath) { } + MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const std::string& /*meshName*/, int meshIt, int meshOrd):_mesh_iteration(meshIt),_mesh_order(meshOrd),_father(fath) { } private: int _mesh_iteration; int _mesh_order; diff --git a/src/MEDLoader/MEDFileFieldMultiTS.cxx b/src/MEDLoader/MEDFileFieldMultiTS.cxx index fc243e844..46dd6b150 100644 --- a/src/MEDLoader/MEDFileFieldMultiTS.cxx +++ b/src/MEDLoader/MEDFileFieldMultiTS.cxx @@ -19,15 +19,43 @@ // Author : Anthony Geay (EDF R&D) #include "MEDFileFieldMultiTS.hxx" +#include "MEDFileField.txx" +#include "MCType.hxx" +#include "MEDFileFieldGlobs.hxx" +#include "MEDFileEntities.hxx" +#include "InterpKernelException.hxx" +#include "MCAuto.hxx" +#include "MEDFileField1TS.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include "MEDCouplingMemArray.hxx" +#include "InterpKernelAutoPtr.hxx" +#include "MEDFileBasis.hxx" +#include "MCIdType.hxx" +#include "MEDFileFieldOverView.hxx" #include "MEDFileFieldVisitor.hxx" #include "MEDFileSafeCaller.txx" +#include "MEDFileUtilities.hxx" #include "MEDLoaderBase.hxx" -#include "MEDFileField.txx" #include "MEDCouplingFieldDouble.hxx" #include "MEDCouplingFieldTemplate.hxx" - +#include "NormalizedGeometricTypes" +#include "med.h" +#include "medfield.h" +#include "MEDLoaderTraits.hxx" + +#include +#include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include using namespace MEDCoupling; @@ -51,8 +79,7 @@ extern INTERP_KERNEL::NormalizedCellType ConvertGeometryType(med_geometry_type g //= MEDFileAnyTypeFieldMultiTSWithoutSDA MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA() -{ -} += default; MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const std::string& fieldName, const std::string& meshName):MEDFileFieldNameScope(fieldName,meshName) { @@ -65,7 +92,7 @@ MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_i { med_field_type typcha; std::string dtunitOut,meshName; - int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,fieldId,false,_name,typcha,_infos,dtunitOut,meshName)); + int const nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,fieldId,false,_name,typcha,_infos,dtunitOut,meshName)); setMeshName(meshName); setDtUnit(dtunitOut.c_str()); loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll,ms,entities); @@ -85,16 +112,16 @@ catch(INTERP_KERNEL::Exception& e) std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySizeWithoutChildren() const { std::size_t ret(_mesh_name.capacity()+_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MCAuto)); - for(std::vector::const_iterator it=_infos.begin();it!=_infos.end();it++) - ret+=(*it).capacity(); + for(const auto & _info : _infos) + ret+=_info.capacity(); return ret; } std::vector MEDFileAnyTypeFieldMultiTSWithoutSDA::getDirectChildrenWithNull() const { std::vector ret; - for(std::vector< MCAuto >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++) - ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)*it); + for(const auto & _time_step : _time_steps) + ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)_time_step); return ret; } @@ -106,7 +133,7 @@ MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buil { MCAuto ret=createNew(); ret->setInfo(_infos); - int sz=(int)_time_steps.size(); + int const sz=(int)_time_steps.size(); for(const int *id=startIds;id!=endIds;id++) { if(*id>=0 && *id ret=createNew(); ret->setInfo(_infos); - std::size_t sz=_time_steps.size(); + std::size_t const sz=_time_steps.size(); std::size_t j=bg; for(int i=0;i ids=DataArrayInt::New(); ids->alloc(0,1); - for(std::vector< MCAuto >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++) + for(auto it=_time_steps.begin();it!=_time_steps.end();it++,id++) { const MEDFileAnyTypeField1TSWithoutSDA *cur(*it); if(!cur) continue; - std::pair p(cur->getIteration(),cur->getOrder()); + std::pair const p(cur->getIteration(),cur->getOrder()); if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end()) ids->pushBackSilent(id); } @@ -191,12 +218,12 @@ MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::part { int id=0; MCAuto ids=DataArrayInt::New(); ids->alloc(0,1); - for(std::vector< MCAuto >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++) + for(auto it=_time_steps.begin();it!=_time_steps.end();it++,id++) { const MEDFileAnyTypeField1TSWithoutSDA *cur(*it); if(!cur) continue; - std::pair p(cur->getIteration(),cur->getOrder()); + std::pair const p(cur->getIteration(),cur->getOrder()); if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end()) ids->pushBackSilent(id); } @@ -205,18 +232,18 @@ MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::part bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfStructureElements() const { - for(std::vector< MCAuto >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++) - if((*it).isNotNull()) - if((*it)->presenceOfStructureElements()) + for(const auto & _time_step : _time_steps) + if(_time_step.isNotNull()) + if(_time_step->presenceOfStructureElements()) return true; return false; } bool MEDFileAnyTypeFieldMultiTSWithoutSDA::onlyStructureElements() const { - for(std::vector< MCAuto >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++) - if((*it).isNotNull()) - if(!(*it)->onlyStructureElements()) + for(const auto & _time_step : _time_steps) + if(_time_step.isNotNull()) + if(!_time_step->onlyStructureElements()) return false; return true; } @@ -224,20 +251,20 @@ bool MEDFileAnyTypeFieldMultiTSWithoutSDA::onlyStructureElements() const void MEDFileAnyTypeFieldMultiTSWithoutSDA::killStructureElements() { std::vector< MCAuto > ret; - for(std::vector< MCAuto >::iterator it=_time_steps.begin();it!=_time_steps.end();it++) - if((*it).isNotNull()) + for(auto & _time_step : _time_steps) + if(_time_step.isNotNull()) { - if((*it)->presenceOfStructureElements()) + if(_time_step->presenceOfStructureElements()) { - if(!(*it)->onlyStructureElements()) + if(!_time_step->onlyStructureElements()) { - (*it)->killStructureElements(); - ret.push_back(*it); + _time_step->killStructureElements(); + ret.push_back(_time_step); } } else { - ret.push_back(*it); + ret.push_back(_time_step); } } _time_steps=ret; @@ -246,14 +273,14 @@ void MEDFileAnyTypeFieldMultiTSWithoutSDA::killStructureElements() void MEDFileAnyTypeFieldMultiTSWithoutSDA::keepOnlyStructureElements() { std::vector< MCAuto > ret; - for(std::vector< MCAuto >::iterator it=_time_steps.begin();it!=_time_steps.end();it++) - if((*it).isNotNull()) + for(auto & _time_step : _time_steps) + if(_time_step.isNotNull()) { - if((*it)->presenceOfStructureElements()) + if(_time_step->presenceOfStructureElements()) { - if(!(*it)->onlyStructureElements()) - (*it)->keepOnlyStructureElements(); - ret.push_back(*it); + if(!_time_step->onlyStructureElements()) + _time_step->keepOnlyStructureElements(); + ret.push_back(_time_step); } } _time_steps=ret; @@ -261,44 +288,44 @@ void MEDFileAnyTypeFieldMultiTSWithoutSDA::keepOnlyStructureElements() void MEDFileAnyTypeFieldMultiTSWithoutSDA::keepOnlyOnSE(const std::string& seName) { - std::vector< MCAuto > ret; - for(std::vector< MCAuto >::iterator it=_time_steps.begin();it!=_time_steps.end();it++) - if((*it).isNotNull()) - (*it)->keepOnlyOnSE(seName); + std::vector< MCAuto > const ret; + for(auto & _time_step : _time_steps) + if(_time_step.isNotNull()) + _time_step->keepOnlyOnSE(seName); } void MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames(std::vector< std::pair >& ps) const { std::vector< std::pair > ps2; - for(std::vector< MCAuto >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++) - if((*it).isNotNull()) + for(const auto & _time_step : _time_steps) + if(_time_step.isNotNull()) { - (*it)->getMeshSENames(ps2); + _time_step->getMeshSENames(ps2); break; } if(ps2.empty()) throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames : this appears to not contain SE only !"); - for(std::vector< MCAuto >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++) - if((*it).isNotNull()) + for(const auto & _time_step : _time_steps) + if(_time_step.isNotNull()) { std::vector< std::pair > ps3; - (*it)->getMeshSENames(ps3); + _time_step->getMeshSENames(ps3); if(ps2!=ps3) throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames : For the moment only homogeneous SE def through time managed !"); } - for(std::vector< std::pair >::const_iterator it=ps2.begin();it!=ps2.end();it++) + for(const auto & it : ps2) { - std::vector< std::pair >::iterator it2(std::find(ps.begin(),ps.end(),*it)); + auto const it2(std::find(ps.begin(),ps.end(),it)); if(it2==ps.end()) - ps.push_back(*it); + ps.push_back(it); } } bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfMultiDiscPerGeoType() const { - for(std::vector< MCAuto >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++) + for(const auto & _time_step : _time_steps) { - const MEDFileAnyTypeField1TSWithoutSDA *cur(*it); + const MEDFileAnyTypeField1TSWithoutSDA *cur(_time_step); if(!cur) continue; if(cur->presenceOfMultiDiscPerGeoType()) @@ -320,16 +347,16 @@ void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++) + for(auto it=_time_steps.begin();it!=_time_steps.end();it++,ret++) { const MEDFileAnyTypeField1TSWithoutSDA *pt(*it); if(pt->isDealingTS(iteration,order)) return ret; } std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n"; - std::vector< std::pair > vp=getIterations(); - for(std::vector< std::pair >::const_iterator it2=vp.begin();it2!=vp.end();it2++) - oss << "(" << (*it2).first << "," << (*it2).second << ") "; + std::vector< std::pair > const vp=getIterations(); + for(const auto & it2 : vp) + oss << "(" << it2.first << "," << it2.second << ") "; throw INTERP_KERNEL::Exception(oss.str()); } @@ -346,17 +373,17 @@ MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeS bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair >& modifTab) { bool ret(false); - for(std::vector< std::pair >::const_iterator it=modifTab.begin();it!=modifTab.end();it++) + for(const auto & it : modifTab) { - if((*it).first==getMeshName()) + if(it.first==getMeshName()) { - setMeshName((*it).second); + setMeshName(it.second); ret=true; } } - for(std::vector< MCAuto >::iterator it=_time_steps.begin();it!=_time_steps.end();it++) + for(auto & _time_step : _time_steps) { - MEDFileAnyTypeField1TSWithoutSDA *cur(*it); + MEDFileAnyTypeField1TSWithoutSDA *cur(_time_step); if(cur) ret=cur->changeMeshNames(modifTab) || ret; } @@ -383,9 +410,9 @@ bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const std MEDFileFieldGlobsReal& glob) { bool ret=false; - for(std::vector< MCAuto >::iterator it=_time_steps.begin();it!=_time_steps.end();it++) + for(auto & _time_step : _time_steps) { - MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it); + MEDFileAnyTypeField1TSWithoutSDA *f1ts(_time_step); if(f1ts) ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret; } @@ -394,31 +421,31 @@ bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const std void MEDFileAnyTypeFieldMultiTSWithoutSDA::accept(MEDFileFieldVisitor& visitor) const { - for(std::vector< MCAuto >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++) - if((*it).isNotNull()) + for(const auto & _time_step : _time_steps) + if(_time_step.isNotNull()) { - visitor.newTimeStepEntry(*it); - (*it)->accept(visitor); - visitor.endTimeStepEntry(*it); + visitor.newTimeStepEntry(_time_step); + _time_step->accept(visitor); + visitor.endTimeStepEntry(_time_step); } } void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const { - std::string startLine(bkOffset,' '); + std::string const startLine(bkOffset,' '); oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]"; if(fmtsId>=0) oss << " (" << fmtsId << ")"; oss << " has the following name: \"" << _name << "\"." << std::endl; oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl; - for(std::vector::const_iterator it=_infos.begin();it!=_infos.end();it++) + for(const auto & _info : _infos) { - oss << startLine << " - \"" << *it << "\"" << std::endl; + oss << startLine << " - \"" << _info << "\"" << std::endl; } int i=0; - for(std::vector< MCAuto >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++) + for(auto it=_time_steps.begin();it!=_time_steps.end();it++,i++) { - std::string chapter(17,(char)('0'+i)); + std::string const chapter(17,(char)('0'+i)); oss << startLine << chapter << std::endl; const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it); if(cur) @@ -431,7 +458,7 @@ void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream std::vector< std::pair > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector& ret1) const { - std::size_t sz=_time_steps.size(); + std::size_t const sz=_time_steps.size(); std::vector< std::pair > ret(sz); ret1.resize(sz); for(std::size_t i=0;i >::iterator it=_time_steps.begin();it!=_time_steps.end();it++) + std::size_t const nbOfCompo=_infos.size(); + for(auto & _time_step : _time_steps) { - MEDFileAnyTypeField1TSWithoutSDA *cur=(*it); + MEDFileAnyTypeField1TSWithoutSDA *cur=_time_step; if(cur) { if((cur->getInfo()).size()!=nbOfCompo) @@ -493,23 +520,23 @@ void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysR // INTERP_KERNEL::AutoCppPtr entitiesFast; const MEDFileEntities *entitiesForSubInstances(entities); - MEDFileCapability mfcap(fid); + MEDFileCapability const mfcap(fid); if( ( !entities || entities->areAllStaticPresentAndNoDyn() ) && mfcap.isFastReader()) {// no entities - med_int nentitype(MEDfieldnEntityType(fid,_name.c_str(),MED_ALL_DT,MED_ALL_IT)); + med_int const nentitype(MEDfieldnEntityType(fid,_name.c_str(),MED_ALL_DT,MED_ALL_IT)); INTERP_KERNEL::AutoPtr types(new med_entity_type[nentitype]); med_int usedbyncs; MEDFILESAFECALLERRD0(MEDfieldEntityType,(fid,_name.c_str(),MED_ALL_DT,MED_ALL_IT,types,&usedbyncs)); std::vector< std::pair > entitiesFastP; for(int i=0;i geotypes(new med_geometry_type[ngeotype]); med_int geousedbyncs; MEDFILESAFECALLERRD0(MEDfieldGeometryType,(fid,_name.c_str(),MED_ALL_DT,MED_ALL_IT,types[i],geotypes,&geousedbyncs)); for(med_int j=0;j p(MEDFileMesh::ConvertFromMEDFileEntity(types[i]),ConvertGeometryType(geotypes[j])); + std::pair const p(MEDFileMesh::ConvertFromMEDFileEntity(types[i]),ConvertGeometryType(geotypes[j])); entitiesFastP.push_back(p); } } @@ -518,7 +545,7 @@ void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysR } for(int i=0;i > ts; + std::vector< std::pair > const ts; med_int numdt=0,numo=0; med_float dt=0.0; MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,_name.c_str(),i+1,&numdt,&numo,&dt)); @@ -569,12 +596,12 @@ void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWri throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !"); checkThatNbOfCompoOfTSMatchThis(); std::vector infos(getInfo()); - std::size_t nbComp=infos.size(); + std::size_t const nbComp=infos.size(); INTERP_KERNEL::AutoPtr comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE); INTERP_KERNEL::AutoPtr unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE); for(unsigned int i=0;iwriteLL(fid,opts,*this); } void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) { - for(std::vector< MCAuto >::iterator it=_time_steps.begin();it!=_time_steps.end();it++) + for(auto & _time_step : _time_steps) { - MEDFileAnyTypeField1TSWithoutSDA *elt(*it); + MEDFileAnyTypeField1TSWithoutSDA *elt(_time_step); if(elt) elt->loadBigArraysRecursively(fid,nasc); } @@ -600,9 +627,9 @@ void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc) { - for(std::vector< MCAuto >::iterator it=_time_steps.begin();it!=_time_steps.end();it++) + for(auto & _time_step : _time_steps) { - MEDFileAnyTypeField1TSWithoutSDA *elt(*it); + MEDFileAnyTypeField1TSWithoutSDA *elt(_time_step); if(elt) elt->loadBigArraysRecursivelyIfNecessary(fid,nasc); } @@ -610,9 +637,9 @@ void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(m void MEDFileAnyTypeFieldMultiTSWithoutSDA::unloadArrays() { - for(std::vector< MCAuto >::iterator it=_time_steps.begin();it!=_time_steps.end();it++) + for(auto & _time_step : _time_steps) { - MEDFileAnyTypeField1TSWithoutSDA *elt(*it); + MEDFileAnyTypeField1TSWithoutSDA *elt(_time_step); if(elt) elt->unloadArrays(); } @@ -626,11 +653,11 @@ int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS() { std::vector< MCAuto > newTS; - for(std::vector< MCAuto >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++) + for(const auto & _time_step : _time_steps) { - const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it); + const MEDFileAnyTypeField1TSWithoutSDA *tmp=_time_step; if(tmp) - newTS.push_back(*it); + newTS.push_back(_time_step); } _time_steps=newTS; } @@ -638,7 +665,7 @@ void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS() void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds) { std::vector< MCAuto > newTS; - int maxId=(int)_time_steps.size(); + int const maxId=(int)_time_steps.size(); int ii=0; std::set idsToDel; for(const int *id=startIds;id!=endIds;id++,ii++) @@ -662,10 +689,10 @@ void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step) { static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2"; - mcIdType nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg); + mcIdType const nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg); if(nbOfEntriesToKill==0) return ; - std::size_t sz=_time_steps.size(); + std::size_t const sz=_time_steps.size(); std::vector b(sz,true); int j=bg; for(mcIdType i=0;i >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++) + for(auto it=_time_steps.begin();it!=_time_steps.end();it++,ret++) { const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it); if(tmp) @@ -702,13 +729,13 @@ int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double ep int ret=0; std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : "; oss.precision(15); - for(std::vector< MCAuto >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++) + for(auto it=_time_steps.begin();it!=_time_steps.end();it++,ret++) { const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it); if(tmp) { int it2,ord; - double ti=tmp->getTime(it2,ord); + double const ti=tmp->getTime(it2,ord); if(fabs(time-ti) > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const { - std::size_t lgth=_time_steps.size(); + std::size_t const lgth=_time_steps.size(); std::vector< std::pair > ret(lgth); for(std::size_t i=0;ifillIteration(ret[i]); @@ -771,7 +798,7 @@ const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::ge throw INTERP_KERNEL::Exception(oss.str()); } const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos]; - if(item==0) + if(item==nullptr) { std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !"; oss << "\nTry to use following method eraseEmptyTS !"; @@ -788,7 +815,7 @@ MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeS throw INTERP_KERNEL::Exception(oss.str()); } MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos]; - if(item==0) + if(item==nullptr) { std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !"; oss << "\nTry to use following method eraseEmptyTS !"; @@ -801,14 +828,14 @@ std::vector MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed { std::vector ret; std::set ret2; - for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++) + for(const auto & _time_step : _time_steps) { - std::vector tmp=(*it)->getPflsReallyUsed2(); - for(std::vector::const_iterator it2=tmp.begin();it2!=tmp.end();it2++) - if(ret2.find(*it2)==ret2.end()) + std::vector const tmp=_time_step->getPflsReallyUsed2(); + for(const auto & it2 : tmp) + if(ret2.find(it2)==ret2.end()) { - ret.push_back(*it2); - ret2.insert(*it2); + ret.push_back(it2); + ret2.insert(it2); } } return ret; @@ -818,14 +845,14 @@ std::vector MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed { std::vector ret; std::set ret2; - for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++) + for(const auto & _time_step : _time_steps) { - std::vector tmp=(*it)->getLocsReallyUsed2(); - for(std::vector::const_iterator it2=tmp.begin();it2!=tmp.end();it2++) - if(ret2.find(*it2)==ret2.end()) + std::vector const tmp=_time_step->getLocsReallyUsed2(); + for(const auto & it2 : tmp) + if(ret2.find(it2)==ret2.end()) { - ret.push_back(*it2); - ret2.insert(*it2); + ret.push_back(it2); + ret2.insert(it2); } } return ret; @@ -834,9 +861,9 @@ std::vector MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed std::vector MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const { std::vector ret; - for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++) + for(const auto & _time_step : _time_steps) { - std::vector tmp=(*it)->getPflsReallyUsedMulti2(); + std::vector tmp=_time_step->getPflsReallyUsedMulti2(); ret.insert(ret.end(),tmp.begin(),tmp.end()); } return ret; @@ -845,9 +872,9 @@ std::vector MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed std::vector MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const { std::vector ret; - for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++) + for(const auto & _time_step : _time_steps) { - std::vector tmp=(*it)->getLocsReallyUsedMulti2(); + std::vector tmp=_time_step->getLocsReallyUsedMulti2(); ret.insert(ret.end(),tmp.begin(),tmp.end()); } return ret; @@ -855,19 +882,19 @@ std::vector MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair, std::string > >& mapOfModif) { - for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++) - (*it)->changePflsRefsNamesGen2(mapOfModif); + for(auto & _time_step : _time_steps) + _time_step->changePflsRefsNamesGen2(mapOfModif); } void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair, std::string > >& mapOfModif) { - for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++) - (*it)->changeLocsRefsNamesGen2(mapOfModif); + for(auto & _time_step : _time_steps) + _time_step->changeLocsRefsNamesGen2(mapOfModif); } std::vector< std::vector > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const { - std::size_t lgth=_time_steps.size(); + std::size_t const lgth=_time_steps.size(); std::vector< std::vector > ret(lgth); for(std::size_t i=0;ifillTypesOfFieldAvailable(ret[i]); @@ -886,7 +913,7 @@ MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deep { MCAuto ret=shallowCpy(); std::size_t i=0; - for(std::vector< MCAuto >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++) + for(auto it=_time_steps.begin();it!=_time_steps.end();it++,i++) { if((const MEDFileAnyTypeField1TSWithoutSDA *)*it) ret->_time_steps[i]=(*it)->deepCopy(); @@ -906,7 +933,7 @@ std::vector< MCAuto > MEDFileAnyTypeFieldM } for(std::size_t i=0;i > ret1=_time_steps[i]->splitComponents(); + std::vector< MCAuto > const ret1=_time_steps[i]->splitComponents(); if(ret1.size()!=sz) { std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !"; @@ -926,7 +953,7 @@ std::vector< MCAuto > MEDFileAnyTypeFieldM */ std::vector< MCAuto > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations() const { - std::size_t sz(_time_steps.size()); + std::size_t const sz(_time_steps.size()); std::vector< std::vector< MCAuto > > items(sz); for(std::size_t i=0;i > MEDFileAnyTypeFieldM std::vector< MCAuto > ret; std::vector< std::vector< MCAuto > > ret2; std::vector< TypeOfField > types; - for(std::vector< std::vector< MCAuto > >::const_iterator it0=items.begin();it0!=items.end();it0++) - for(std::vector< MCAuto >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++) + for(const auto & item : items) + for(const auto & it1 : item) { - std::vector ts=(*it1)->getTypesOfFieldAvailable(); + std::vector ts=it1->getTypesOfFieldAvailable(); if(ts.size()!=1) throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : it appears that the splitting of MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations has returned invalid result !"); - std::vector< TypeOfField >::iterator it2=std::find(types.begin(),types.end(),ts[0]); + auto const it2=std::find(types.begin(),types.end(),ts[0]); if(it2==types.end()) types.push_back(ts[0]); } ret.resize(types.size()); ret2.resize(types.size()); - for(std::vector< std::vector< MCAuto > >::const_iterator it0=items.begin();it0!=items.end();it0++) - for(std::vector< MCAuto >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++) + for(const auto & item : items) + for(const auto & it1 : item) { - TypeOfField typ=(*it1)->getTypesOfFieldAvailable()[0]; - std::size_t pos=std::distance(types.begin(),std::find(types.begin(),types.end(),typ)); - ret2[pos].push_back(*it1); + TypeOfField const typ=it1->getTypesOfFieldAvailable()[0]; + std::size_t const pos=std::distance(types.begin(),std::find(types.begin(),types.end(),typ)); + ret2[pos].push_back(it1); } for(std::size_t i=0;i elt(createNew()); - for(std::vector< MCAuto >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++) - elt->pushBackTimeStep(*it1);//also updates infos in elt + for(auto & it1 : ret2[i]) + elt->pushBackTimeStep(it1);//also updates infos in elt ret[i]=elt; elt->MEDFileFieldNameScope::operator=(*this); } @@ -976,7 +1003,7 @@ std::vector< MCAuto > MEDFileAnyTypeFieldM */ std::vector< MCAuto > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes() const { - std::size_t sz(_time_steps.size()); + std::size_t const sz(_time_steps.size()); std::vector< std::vector< MCAuto > > items(sz); std::size_t szOut(std::numeric_limits::max()); for(std::size_t i=0;i >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++) + for(auto it=_time_steps.begin();it!=_time_steps.end();it++,j++) { const MEDFileAnyTypeField1TSWithoutSDA *elt(*it); if(elt) @@ -1104,7 +1131,7 @@ void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingF void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MCAuto ts) { - int sz=(int)_time_steps.size(); + int const sz=(int)_time_steps.size(); if(i<0 || i>=sz) { std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !"; @@ -1131,7 +1158,7 @@ void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MCAuto > MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2(int iteration, int order, const std::string& mname, std::vector& types, std::vector< std::vector >& typesF, std::vector< std::vector >& pfls, std::vector< std::vector >& locs) const { const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order); - const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast(&myF1TS); + const auto *myF1TSC=dynamic_cast(&myF1TS); if(!myF1TSC) throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !"); return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs); @@ -1142,15 +1169,15 @@ MEDFileInt32FieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt( MCAuto ret(new MEDFileInt32FieldMultiTSWithoutSDA); ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this); int i=0; - for(std::vector< MCAuto >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++) + for(auto it=_time_steps.begin();it!=_time_steps.end();it++,i++) { const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it); if(eltToConv) { - const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast(eltToConv); + const auto *eltToConvC=dynamic_cast(eltToConv); if(!eltToConvC) throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !"); - MCAuto elt=eltToConvC->convertToInt(); + MCAuto const elt=eltToConvC->convertToInt(); ret->setIteration(i,elt); } } @@ -1190,8 +1217,7 @@ MCAuto MEDFileFloatFieldMultiTSWithoutSDA::createNew //= MEDFileAnyTypeFieldMultiTS MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS() -{ -} += default; MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms) try:MEDFileFieldGlobsReal(fid) @@ -1266,29 +1292,29 @@ MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFr { case MED_FLOAT64: { - ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0); + ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll,ms,nullptr); break; } case MED_INT32: { - ret=new MEDFileInt32FieldMultiTSWithoutSDA(fid,0,loadAll,ms,0); + ret=new MEDFileInt32FieldMultiTSWithoutSDA(fid,0,loadAll,ms,nullptr); break; } case MED_INT64: { - ret=new MEDFileInt64FieldMultiTSWithoutSDA(fid,0,loadAll,ms,0); + ret=new MEDFileInt64FieldMultiTSWithoutSDA(fid,0,loadAll,ms,nullptr); break; } case MED_FLOAT32: { - ret=new MEDFileFloatFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0); + ret=new MEDFileFloatFieldMultiTSWithoutSDA(fid,0,loadAll,ms,nullptr); break; } case MED_INT: { if(sizeof(med_int)==sizeof(int)) { - ret=new MEDFileInt32FieldMultiTSWithoutSDA(fid,0,loadAll,ms,0); + ret=new MEDFileInt32FieldMultiTSWithoutSDA(fid,0,loadAll,ms,nullptr); break; } } @@ -1337,7 +1363,7 @@ MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromCont MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, med_idt fid) { MEDFileAnyTypeFieldMultiTS *ret(BuildNewInstanceFromContent(c)); - std::string fileName(FileNameFromFID(fid)); + std::string const fileName(FileNameFromFID(fid)); ret->setFileName(fileName); return ret; } @@ -1365,13 +1391,13 @@ catch(INTERP_KERNEL::Exception& e) */ MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, bool loadAll) { - MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + MEDFileUtilities::AutoFid const fid(OpenMEDFileForRead(fileName)); return New(fid,loadAll); } MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, bool loadAll) { - MCAuto c(BuildContentFrom(fid,loadAll,0)); + MCAuto c(BuildContentFrom(fid,loadAll,nullptr)); MCAuto ret(BuildNewInstanceFromContent(c,fid)); ret->loadGlobals(fid); return ret.retn(); @@ -1389,13 +1415,13 @@ MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, bool lo */ MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll) { - MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + MEDFileUtilities::AutoFid const fid(OpenMEDFileForRead(fileName)); return New(fid,fieldName,loadAll); } MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll) { - MCAuto c(BuildContentFrom(fid,fieldName,loadAll,0,0)); + MCAuto c(BuildContentFrom(fid,fieldName,loadAll,nullptr,nullptr)); MCAuto ret(BuildNewInstanceFromContent(c,fid)); ret->loadGlobals(fid); return ret.retn(); @@ -1489,7 +1515,7 @@ void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step) MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const { - MCAuto c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds); + MCAuto const c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds); MCAuto ret=shallowCpy(); ret->_content=c; return ret.retn(); @@ -1497,7 +1523,7 @@ MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int * MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const { - MCAuto c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step); + MCAuto const c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step); MCAuto ret=shallowCpy(); ret->_content=c; return ret.retn(); @@ -1510,15 +1536,15 @@ std::vector< std::pair > MEDFileAnyTypeFieldMultiTS::getIterations() co void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector& f1ts) { - for(std::vector::const_iterator it=f1ts.begin();it!=f1ts.end();it++) - pushBackTimeStep(*it); + for(auto f1t : f1ts) + pushBackTimeStep(f1t); } void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(MEDFileAnyTypeFieldMultiTS *fmts) { if(!fmts) throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps : Input fmts is NULL !"); - int nbOfTS(fmts->getNumberOfTS()); + int const nbOfTS(fmts->getNumberOfTS()); for(int i=0;i elt(fmts->getTimeStepAtPos(i)); @@ -1532,7 +1558,7 @@ void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts) throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !"); checkCoherencyOfType(f1ts); f1ts->incrRef(); - MCAuto f1tsSafe(f1ts); + MCAuto const f1tsSafe(f1ts); MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase(); c->incrRef(); MCAuto cSafe(c); @@ -1655,7 +1681,7 @@ void MEDFileAnyTypeFieldMultiTS::loadArrays() { if(getFileName().empty()) throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::loadArrays : the structure does not come from a file !"); - MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName())); + MEDFileUtilities::AutoFid const fid(OpenMEDFileForRead(getFileName())); contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase()); } @@ -1670,7 +1696,7 @@ void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary() { if(!getFileName().empty()) { - MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName())); + MEDFileUtilities::AutoFid const fid(OpenMEDFileForRead(getFileName())); contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase()); } } @@ -1731,7 +1757,7 @@ std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS:: if(!content) throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !"); std::vector< MCAuto > contentsSplit=content->splitComponents(); - std::size_t sz(contentsSplit.size()); + std::size_t const sz(contentsSplit.size()); std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz); for(std::size_t i=0;i > MEDFileAnyTypeFieldMultiTS:: if(!content) throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !"); std::vector< MCAuto > contentsSplit(content->splitDiscretizations()); - std::size_t sz(contentsSplit.size()); + std::size_t const sz(contentsSplit.size()); std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz); for(std::size_t i=0;i > MEDFileAnyTypeFieldMultiTS:: if(!content) throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretizations !"); std::vector< MCAuto > contentsSplit(content->splitMultiDiscrPerGeoTypes()); - std::size_t sz(contentsSplit.size()); + std::size_t const sz(contentsSplit.size()); std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz); for(std::size_t i=0;i MEDFileAnyTypeFieldMultiTS::getCont */ MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const { - int pos=getPosOfTimeStep(iteration,order); + int const pos=getPosOfTimeStep(iteration,order); return getTimeStepAtPos(pos); } @@ -1819,7 +1845,7 @@ MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, i */ MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const { - int pos=getPosGivenTime(time,eps); + int const pos=getPosGivenTime(time,eps); return getTimeStepAtPos(pos); } @@ -1838,11 +1864,11 @@ std::vector< std::vector > MEDFileAnyTypeFieldMult std::list lstFMTS(vectFMTS.begin(),vectFMTS.end()); while(!lstFMTS.empty()) { - std::list::iterator it(lstFMTS.begin()); + auto it(lstFMTS.begin()); MEDFileAnyTypeFieldMultiTS *curIt(*it); if(!curIt) throw INTERP_KERNEL::Exception(msg); - std::vector< std::pair > refIts=curIt->getIterations(); + std::vector< std::pair > const refIts=curIt->getIterations(); std::vector elt; elt.push_back(curIt); it=lstFMTS.erase(it); while(it!=lstFMTS.end()) @@ -1850,7 +1876,7 @@ std::vector< std::vector > MEDFileAnyTypeFieldMult curIt=*it; if(!curIt) throw INTERP_KERNEL::Exception(msg); - std::vector< std::pair > curIts=curIt->getIterations(); + std::vector< std::pair > const curIts=curIt->getIterations(); if(refIts==curIts) { elt.push_back(curIt); it=lstFMTS.erase(it); } else @@ -1891,7 +1917,7 @@ std::vector< std::vector > MEDFileAnyTypeFieldMult std::vector< std::vector > ret; if(vectFMTS.empty()) return ret; - std::vector::const_iterator it(vectFMTS.begin()); + auto it(vectFMTS.begin()); MEDFileAnyTypeFieldMultiTS *frstElt(*it); if(!frstElt) throw INTERP_KERNEL::Exception(msg); @@ -1916,7 +1942,7 @@ std::vector< std::vector > MEDFileAnyTypeFieldMult std::vector< MCAuto > cmps; std::vector< std::vector > retCell=SplitPerCommonSupportNotNodesAlg(vectFMTSNotNodes,mesh,cmps); ret=retCell; - for(std::vector::const_iterator it2=vectFMTSNodes.begin();it2!=vectFMTSNodes.end();it2++) + for(auto vectFMTSNode : vectFMTSNodes) { i=0; bool isFetched(false); @@ -1924,14 +1950,14 @@ std::vector< std::vector > MEDFileAnyTypeFieldMult { if((*it0).empty()) throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : internal error !"); - if(cmps[i]->isCompatibleWithNodesDiscr(*it2)) - { ret[i].push_back(*it2); isFetched=true; } + if(cmps[i]->isCompatibleWithNodesDiscr(vectFMTSNode)) + { ret[i].push_back(vectFMTSNode); isFetched=true; } } if(!isFetched) { - std::vector tmp(1,*it2); + std::vector const tmp(1,vectFMTSNode); MCAuto tmp2(MEDFileMeshStruct::New(mesh)); - ret.push_back(tmp); retCell.push_back(tmp); cmps.push_back(MEDFileFastCellSupportComparator::New(tmp2,*it2)); + ret.push_back(tmp); retCell.push_back(tmp); cmps.push_back(MEDFileFastCellSupportComparator::New(tmp2,vectFMTSNode)); } } fsc=cmps; @@ -1948,7 +1974,7 @@ std::vector< std::vector > MEDFileAnyTypeFieldMult std::list lstFMTS(vectFMTS.begin(),vectFMTS.end()); while(!lstFMTS.empty()) { - std::list::iterator it(lstFMTS.begin()); + auto it(lstFMTS.begin()); MEDFileAnyTypeFieldMultiTS *ref(*it); std::vector elt; elt.push_back(ref); it=lstFMTS.erase(it); @@ -1995,7 +2021,7 @@ int MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiT std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh \""<< f1->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !"; throw INTERP_KERNEL::Exception(oss.str()); } - int nts=f0->getNumberOfTS(); + int const nts=f0->getNumberOfTS(); if(nts!=f1->getNumberOfTS()) throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : number of time steps are not the same !"); if(nts==0) @@ -2041,14 +2067,14 @@ MCAuto AggregateHelperF1TS(const std::vector< typename M throw INTERP_KERNEL::Exception("AggregateHelperF1TS : empty vector !"); std::size_t sz(f1tss.size()),i(0); std::vector< typename MLFieldTraits::F1TSWSDAType const *> f1tsw(sz); - for(typename std::vector< typename MLFieldTraits::F1TSType const *>::const_iterator it=f1tss.begin();it!=f1tss.end();it++,i++) + for(auto it=f1tss.begin();it!=f1tss.end();it++,i++) { typename MLFieldTraits::F1TSType const *elt(*it); if(!elt) throw INTERP_KERNEL::Exception("AggregateHelperF1TS : presence of a null pointer !"); f1tsw[i]=dynamic_cast::F1TSWSDAType const *>(elt->contentNotNullBase()); } - typename MLFieldTraits::F1TSWSDAType *retc(dynamic_cast::F1TSWSDAType *>(ret->contentNotNullBase())); + auto *retc(dynamic_cast::F1TSWSDAType *>(ret->contentNotNullBase())); if(!retc) throw INTERP_KERNEL::Exception("AggregateHelperF1TS : internal error 1 !"); retc->aggregate(f1tsw,dts); @@ -2062,15 +2088,15 @@ MCAuto< MEDFileAnyTypeFieldMultiTS > AggregateHelperFMTS(const std::vector< type MCAuto< typename MLFieldTraits::FMTSType > ret(MLFieldTraits::FMTSType::New()); if(fmtss.empty()) throw INTERP_KERNEL::Exception("AggregateHelperFMTS : empty vector !"); - std::size_t sz(fmtss.size()); - for(typename std::vector< typename MLFieldTraits::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++) + std::size_t const sz(fmtss.size()); + for(auto it=fmtss.begin();it!=fmtss.end();it++) { typename MLFieldTraits::FMTSType const *elt(*it); if(!elt) throw INTERP_KERNEL::Exception("AggregateHelperFMTS : presence of null pointer !"); } - int nbTS(fmtss[0]->getNumberOfTS()); - for(typename std::vector< typename MLFieldTraits::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++) + int const nbTS(fmtss[0]->getNumberOfTS()); + for(auto it=fmtss.begin();it!=fmtss.end();it++) if((*it)->getNumberOfTS()!=nbTS) throw INTERP_KERNEL::Exception("AggregateHelperFMTS : all fields must have the same number of TS !"); for(int iterTS=0;iterTS AggregateHelperFMTS(const std::vector< type std::size_t i(0); std::vector< typename MLFieldTraits::F1TSType const *> f1tss(sz); std::vector< MCAuto::F1TSType> > f1tss2(sz); - for(typename std::vector< typename MLFieldTraits::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++,i++) + for(auto it=fmtss.begin();it!=fmtss.end();it++,i++) { f1tss2[i]=(*it)->getTimeStepAtPos(iterTS); f1tss[i]=f1tss2[i]; } MCAuto f1ts(AggregateHelperF1TS(f1tss,dts)); ret->pushBackTimeStep(f1ts); @@ -2095,27 +2121,27 @@ MCAuto MEDFileAnyTypeFieldMultiTS::Aggregate(const s { if(fmtss.empty()) throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : input vector is empty !"); - std::size_t sz(fmtss.size()); + std::size_t const sz(fmtss.size()); std::vector fmtss1; std::vector fmtss2; std::vector fmtss3; - for(std::vector::const_iterator it=fmtss.begin();it!=fmtss.end();it++) + for(auto fmts : fmtss) { - if(!(*it)) + if(!fmts) throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : presence of null instance in input vector !"); - const MEDFileFieldMultiTS *elt1(dynamic_cast(*it)); + const auto *elt1(dynamic_cast(fmts)); if(elt1) { fmtss1.push_back(elt1); continue; } - const MEDFileInt32FieldMultiTS *elt2(dynamic_cast(*it)); + const auto *elt2(dynamic_cast(fmts)); if(elt2) { fmtss2.push_back(elt2); continue; } - const MEDFileInt64FieldMultiTS *elt3(dynamic_cast(*it)); + const auto *elt3(dynamic_cast(fmts)); if(elt3) { fmtss3.push_back(elt3); @@ -2160,7 +2186,7 @@ MEDFileInt32FieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool isDeepCpyGlobs) const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content); if(content) { - const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast(content); + const auto *contc=dynamic_cast(content); if(!contc) throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !"); MCAuto newc(contc->convertToInt()); @@ -2210,8 +2236,7 @@ MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAn } MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator() -{ -} += default; MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt() { @@ -2221,10 +2246,10 @@ MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt() if(fmts) return fmts->getTimeStepAtPos(_iter_id++); else - return 0; + return nullptr; } else - return 0; + return nullptr; } //= MEDFileInt32FieldMultiTS diff --git a/src/MEDLoader/MEDFileFieldMultiTS.hxx b/src/MEDLoader/MEDFileFieldMultiTS.hxx index 3de1e84f8..a954e9696 100644 --- a/src/MEDLoader/MEDFileFieldMultiTS.hxx +++ b/src/MEDLoader/MEDFileFieldMultiTS.hxx @@ -20,11 +20,24 @@ #pragma once +#include "MEDCouplingRefCountObject.hxx" +#include "MCAuto.hxx" +#include "MEDCouplingTraits.hxx" +#include "MEDCouplingMemArray.hxx" +#include "MCType.hxx" #include "MEDLoaderDefines.hxx" #include "MEDFileField1TS.hxx" #include "MEDFileFieldGlobs.hxx" #include "MEDLoaderTraits.hxx" -#include "MEDFileUtilities.hxx" +#include "MEDFileUtilities.txx" +#include +#include "med.h" +#include +#include +#include +#include +#include "NormalizedGeometricTypes" +#include namespace MEDCoupling { @@ -45,8 +58,8 @@ namespace MEDCoupling MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, const std::string& meshName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities); public: MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileAnyTypeFieldMultiTSWithoutSDA"); } - MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; - MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const; + MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const override; + MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const override; MEDLOADER_EXPORT virtual MEDFileAnyTypeFieldMultiTSWithoutSDA *deepCopy() const; MEDLOADER_EXPORT virtual std::vector< MCAuto > splitComponents() const; MEDLOADER_EXPORT virtual std::vector< MCAuto > splitDiscretizations() const; @@ -127,9 +140,9 @@ namespace MEDCoupling { public: MEDLOADER_EXPORT static typename MLFieldTraits::FMTSWSDAType *New(med_idt fid, const std::string& fieldName, const std::string& meshName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities); - MEDLOADER_EXPORT const char *getTypeStr() const; - MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTSWithoutSDA *createNew() const; - MEDLOADER_EXPORT MEDFileAnyTypeField1TSWithoutSDA *createNew1TSWithoutSDAEmptyInstance() const; + MEDLOADER_EXPORT const char *getTypeStr() const override; + MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTSWithoutSDA *createNew() const override; + MEDLOADER_EXPORT MEDFileAnyTypeField1TSWithoutSDA *createNew1TSWithoutSDAEmptyInstance() const override; MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileTemplateFieldMultiTSWithoutSDA"); } protected: MEDFileTemplateFieldMultiTSWithoutSDA() { } @@ -137,7 +150,7 @@ namespace MEDCoupling /** \param [in] fieldId field id in C mode */ MEDFileTemplateFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities):MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities) { } MEDFileTemplateFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, const std::string& meshName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities):MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,meshName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities) { } - void checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const; + void checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const override; }; class MEDFileFieldMultiTSWithoutSDA : public MEDFileTemplateFieldMultiTSWithoutSDA @@ -147,15 +160,15 @@ namespace MEDCoupling MEDLOADER_EXPORT MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities):MEDFileTemplateFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities) { } MEDLOADER_EXPORT std::vector< std::vector > getFieldSplitedByType2(int iteration, int order, const std::string& mname, std::vector& types, std::vector< std::vector >& typesF, std::vector< std::vector >& pfls, std::vector< std::vector >& locs) const; MEDLOADER_EXPORT MEDFileInt32FieldMultiTSWithoutSDA *convertToInt() const; - MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTSWithoutSDA *shallowCpy() const { return new MEDFileFieldMultiTSWithoutSDA(*this); } + MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTSWithoutSDA *shallowCpy() const override { return new MEDFileFieldMultiTSWithoutSDA(*this); } MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileFieldMultiTSWithoutSDA"); } MEDLOADER_EXPORT MCAuto createNewWithSDA() const override; protected: MEDFileFieldMultiTSWithoutSDA(const std::string& fieldName, const std::string& meshName):MEDFileTemplateFieldMultiTSWithoutSDA(fieldName,meshName) { } MEDFileFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, const std::string& meshName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities):MEDFileTemplateFieldMultiTSWithoutSDA(fid,fieldName,meshName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities) { } - med_field_type getMEDFileFieldType() const { return MED_FLOAT64; } + med_field_type getMEDFileFieldType() const override { return MED_FLOAT64; } public: - MEDLOADER_EXPORT MEDFileFieldMultiTSWithoutSDA() { } + MEDLOADER_EXPORT MEDFileFieldMultiTSWithoutSDA() = default; }; template @@ -175,15 +188,15 @@ namespace MEDCoupling friend class MEDFileTemplateFieldMultiTSWithoutSDA; public: MEDLOADER_EXPORT MEDFileInt32FieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities):MEDFileNDTemplateFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities) { } - MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTSWithoutSDA *shallowCpy() const { return new MEDFileInt32FieldMultiTSWithoutSDA(*this); } + MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTSWithoutSDA *shallowCpy() const override { return new MEDFileInt32FieldMultiTSWithoutSDA(*this); } MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileInt32FieldMultiTSWithoutSDA"); } MEDLOADER_EXPORT MCAuto createNewWithSDA() const override; protected: MEDFileInt32FieldMultiTSWithoutSDA(const std::string& fieldName, const std::string& meshName):MEDFileNDTemplateFieldMultiTSWithoutSDA(fieldName,meshName) { } MEDFileInt32FieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, const std::string& meshName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities):MEDFileNDTemplateFieldMultiTSWithoutSDA(fid,fieldName,meshName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities) { } - med_field_type getMEDFileFieldType() const { return MED_INT32; } + med_field_type getMEDFileFieldType() const override { return MED_INT32; } public: - MEDLOADER_EXPORT MEDFileInt32FieldMultiTSWithoutSDA() { } + MEDLOADER_EXPORT MEDFileInt32FieldMultiTSWithoutSDA() = default; }; class MEDFileInt64FieldMultiTSWithoutSDA : public MEDFileNDTemplateFieldMultiTSWithoutSDA @@ -191,15 +204,15 @@ namespace MEDCoupling friend class MEDFileTemplateFieldMultiTSWithoutSDA; public: MEDLOADER_EXPORT MEDFileInt64FieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities):MEDFileNDTemplateFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities) { } - MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTSWithoutSDA *shallowCpy() const { return new MEDFileInt64FieldMultiTSWithoutSDA(*this); } + MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTSWithoutSDA *shallowCpy() const override { return new MEDFileInt64FieldMultiTSWithoutSDA(*this); } MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileInt64FieldMultiTSWithoutSDA"); } MEDLOADER_EXPORT MCAuto createNewWithSDA() const override; protected: MEDFileInt64FieldMultiTSWithoutSDA(const std::string& fieldName, const std::string& meshName):MEDFileNDTemplateFieldMultiTSWithoutSDA(fieldName,meshName) { } MEDFileInt64FieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, const std::string& meshName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities):MEDFileNDTemplateFieldMultiTSWithoutSDA(fid,fieldName,meshName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities) { } - med_field_type getMEDFileFieldType() const { return MED_INT64; } + med_field_type getMEDFileFieldType() const override { return MED_INT64; } public: - MEDLOADER_EXPORT MEDFileInt64FieldMultiTSWithoutSDA() { } + MEDLOADER_EXPORT MEDFileInt64FieldMultiTSWithoutSDA() = default; }; class MEDFileFloatFieldMultiTSWithoutSDA : public MEDFileNDTemplateFieldMultiTSWithoutSDA @@ -207,15 +220,15 @@ namespace MEDCoupling friend class MEDFileTemplateFieldMultiTSWithoutSDA; public: MEDLOADER_EXPORT MEDFileFloatFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities):MEDFileNDTemplateFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities) { } - MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTSWithoutSDA *shallowCpy() const { return new MEDFileFloatFieldMultiTSWithoutSDA(*this); } + MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTSWithoutSDA *shallowCpy() const override { return new MEDFileFloatFieldMultiTSWithoutSDA(*this); } MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileFloatFieldMultiTSWithoutSDA"); } MEDLOADER_EXPORT MCAuto createNewWithSDA() const override; protected: MEDFileFloatFieldMultiTSWithoutSDA(const std::string& fieldName, const std::string& meshName):MEDFileNDTemplateFieldMultiTSWithoutSDA(fieldName,meshName) { } MEDFileFloatFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, const std::string& meshName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities):MEDFileNDTemplateFieldMultiTSWithoutSDA(fid,fieldName,meshName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities) { } - med_field_type getMEDFileFieldType() const { return MED_FLOAT32; } + med_field_type getMEDFileFieldType() const override { return MED_FLOAT32; } public: - MEDLOADER_EXPORT MEDFileFloatFieldMultiTSWithoutSDA() { } + MEDLOADER_EXPORT MEDFileFloatFieldMultiTSWithoutSDA() = default; }; class MEDFileAnyTypeFieldMultiTSIterator; @@ -228,7 +241,7 @@ namespace MEDCoupling protected: MEDFileAnyTypeFieldMultiTS(); MEDFileAnyTypeFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms); - MEDFileAnyTypeFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities=0); + MEDFileAnyTypeFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities=nullptr); MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent); static MEDFileAnyTypeFieldMultiTS *BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, med_idt fid); static MEDFileAnyTypeFieldMultiTSWithoutSDA *BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms); @@ -244,9 +257,9 @@ namespace MEDCoupling MEDLOADER_EXPORT void loadArraysIfNecessary(); MEDLOADER_EXPORT void unloadArrays(); MEDLOADER_EXPORT void unloadArraysWithoutDataLoss(); - MEDLOADER_EXPORT void writeLL(med_idt fid) const; - MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; - MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const; + MEDLOADER_EXPORT void writeLL(med_idt fid) const override; + MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const override; + MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const override; MEDLOADER_EXPORT virtual MEDFileAnyTypeFieldMultiTS *deepCopy() const; MEDLOADER_EXPORT std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > splitComponents() const; MEDLOADER_EXPORT std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > splitDiscretizations() const; @@ -298,12 +311,12 @@ namespace MEDCoupling MEDLOADER_EXPORT virtual MEDFileAnyTypeFieldMultiTS *extractPart(const std::map >& extractDef, MEDFileMesh *mm) const = 0; MEDLOADER_EXPORT static MCAuto Aggregate(const std::vector& fmtss, const std::vector< std::vector< std::pair > >& dts); public: - MEDLOADER_EXPORT std::vector getPflsReallyUsed() const; - MEDLOADER_EXPORT std::vector getLocsReallyUsed() const; - MEDLOADER_EXPORT std::vector getPflsReallyUsedMulti() const; - MEDLOADER_EXPORT std::vector getLocsReallyUsedMulti() const; - MEDLOADER_EXPORT void changePflsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif); - MEDLOADER_EXPORT void changeLocsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif); + MEDLOADER_EXPORT std::vector getPflsReallyUsed() const override; + MEDLOADER_EXPORT std::vector getLocsReallyUsed() const override; + MEDLOADER_EXPORT std::vector getPflsReallyUsedMulti() const override; + MEDLOADER_EXPORT std::vector getLocsReallyUsedMulti() const override; + MEDLOADER_EXPORT void changePflsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif) override; + MEDLOADER_EXPORT void changeLocsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif) override; protected: MEDFileAnyTypeFieldMultiTSWithoutSDA *contentNotNullBase(); const MEDFileAnyTypeFieldMultiTSWithoutSDA *contentNotNullBase() const; @@ -326,7 +339,7 @@ namespace MEDCoupling MEDLOADER_EXPORT static typename MLFieldTraits::FMTSType *New(const typename MLFieldTraits::FMTSWSDAType& other, bool shallowCopyOfContent); MEDLOADER_EXPORT static typename MLFieldTraits::FMTSType *LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair >& entities, bool loadAll=true); MEDLOADER_EXPORT typename MLFieldTraits::FMTSType *extractPartImpl(const std::map >& extractDef, MEDFileMesh *mm) const; - MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTS *extractPart(const std::map >& extractDef, MEDFileMesh *mm) const { return this->extractPartImpl(extractDef,mm); } + MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTS *extractPart(const std::map >& extractDef, MEDFileMesh *mm) const override { return this->extractPartImpl(extractDef,mm); } // MEDLOADER_EXPORT typename Traits::FieldType *field(int iteration, int order, const MEDFileMesh *mesh) const; MEDLOADER_EXPORT typename Traits::FieldType *getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol=0) const; @@ -340,21 +353,21 @@ namespace MEDCoupling MEDLOADER_EXPORT void appendFieldProfile(const typename Traits::FieldType *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayIdType *profile); MEDLOADER_EXPORT void appendFieldProfileFlatly(const typename Traits::FieldType *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayIdType *profile); // - MEDLOADER_EXPORT typename MLFieldTraits::F1TSType *getTimeStepAtPos(int pos) const; + MEDLOADER_EXPORT typename MLFieldTraits::F1TSType *getTimeStepAtPos(int pos) const override; MEDLOADER_EXPORT typename Traits::ArrayType *getUndergroundDataArray(int iteration, int order) const; MEDLOADER_EXPORT typename Traits::ArrayType *getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair,std::pair > >& entries) const; MEDLOADER_EXPORT typename MLFieldTraits::FMTSType *buildNewEmptyImpl() const; - MEDLOADER_EXPORT void checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const; + MEDLOADER_EXPORT void checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const override; protected: const typename MLFieldTraits::FMTSWSDAType *contentNotNull() const; typename MLFieldTraits::FMTSWSDAType *contentNotNull(); void appendFieldProfileGeneral(const typename Traits::FieldType *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayIdType *profile, bool smartPflKiller); protected: - ~MEDFileTemplateFieldMultiTS() { } + ~MEDFileTemplateFieldMultiTS() override = default; MEDFileTemplateFieldMultiTS(); MEDFileTemplateFieldMultiTS(const typename MLFieldTraits::FMTSWSDAType& other, bool shallowCopyOfContent); MEDFileTemplateFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms); - MEDFileTemplateFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities=0); + MEDFileTemplateFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities=nullptr); }; class MEDFileIntFieldMultiTS; @@ -366,19 +379,19 @@ namespace MEDCoupling { friend class MEDFileTemplateFieldMultiTS; public: - MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTS *shallowCpy() const; + MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTS *shallowCpy() const override; MEDLOADER_EXPORT MEDFileInt32FieldMultiTS *convertToInt(bool isDeepCpyGlobs=true) const; MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileFieldMultiTS"); } // MEDLOADER_EXPORT std::vector< std::vector > getFieldSplitedByType2(int iteration, int order, const std::string& mname, std::vector& types, std::vector< std::vector >& typesF, std::vector< std::vector >& pfls, std::vector< std::vector >& locs) const; - MEDLOADER_EXPORT MEDFileFieldMultiTS *buildNewEmpty() const { return buildNewEmptyImpl(); } + MEDLOADER_EXPORT MEDFileFieldMultiTS *buildNewEmpty() const override { return buildNewEmptyImpl(); } public: private: - ~MEDFileFieldMultiTS() { } + ~MEDFileFieldMultiTS() override = default; MEDFileFieldMultiTS() { } MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent); MEDFileFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms); - MEDFileFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities=0); + MEDFileFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities=nullptr); }; template @@ -387,7 +400,7 @@ namespace MEDCoupling public: MEDLOADER_EXPORT MEDFileFieldMultiTS *convertToDouble(bool isDeepCpyGlobs=true) const; protected: - ~MEDFileNDTemplateFieldMultiTS() { } + ~MEDFileNDTemplateFieldMultiTS() override = default; MEDFileNDTemplateFieldMultiTS() { } MEDFileNDTemplateFieldMultiTS(const typename MLFieldTraits::FMTSWSDAType& other, bool shallowCopyOfContent):MEDFileTemplateFieldMultiTS(other,shallowCopyOfContent) { } MEDFileNDTemplateFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms):MEDFileTemplateFieldMultiTS(fid,loadAll,ms) { } @@ -401,15 +414,15 @@ namespace MEDCoupling { friend class MEDFileTemplateFieldMultiTS; public: - MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTS *shallowCpy() const { return new MEDFileInt32FieldMultiTS(*this); } - MEDLOADER_EXPORT MEDFileInt32FieldMultiTS *buildNewEmpty() const { return buildNewEmptyImpl(); } + MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTS *shallowCpy() const override { return new MEDFileInt32FieldMultiTS(*this); } + MEDLOADER_EXPORT MEDFileInt32FieldMultiTS *buildNewEmpty() const override { return buildNewEmptyImpl(); } MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileInt32FieldMultiTS"); } private: - ~MEDFileInt32FieldMultiTS() { } + ~MEDFileInt32FieldMultiTS() override = default; MEDFileInt32FieldMultiTS() { } MEDFileInt32FieldMultiTS(const MEDFileInt32FieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileNDTemplateFieldMultiTS(other,shallowCopyOfContent) { } MEDFileInt32FieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms):MEDFileNDTemplateFieldMultiTS(fid,loadAll,ms) { } - MEDFileInt32FieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities=0):MEDFileNDTemplateFieldMultiTS(fid,fieldName,loadAll,ms,entities) { } + MEDFileInt32FieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities=nullptr):MEDFileNDTemplateFieldMultiTS(fid,fieldName,loadAll,ms,entities) { } }; /*! @@ -419,15 +432,15 @@ namespace MEDCoupling { friend class MEDFileTemplateFieldMultiTS; public: - MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTS *shallowCpy() const { return new MEDFileInt64FieldMultiTS(*this); } - MEDLOADER_EXPORT MEDFileInt64FieldMultiTS *buildNewEmpty() const { return buildNewEmptyImpl(); } + MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTS *shallowCpy() const override { return new MEDFileInt64FieldMultiTS(*this); } + MEDLOADER_EXPORT MEDFileInt64FieldMultiTS *buildNewEmpty() const override { return buildNewEmptyImpl(); } MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileInt64FieldMultiTS"); } private: - ~MEDFileInt64FieldMultiTS() { } + ~MEDFileInt64FieldMultiTS() override = default; MEDFileInt64FieldMultiTS() { } MEDFileInt64FieldMultiTS(const MEDFileInt64FieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileNDTemplateFieldMultiTS(other,shallowCopyOfContent) { } MEDFileInt64FieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms):MEDFileNDTemplateFieldMultiTS(fid,loadAll,ms) { } - MEDFileInt64FieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities=0):MEDFileNDTemplateFieldMultiTS(fid,fieldName,loadAll,ms,entities) { } + MEDFileInt64FieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities=nullptr):MEDFileNDTemplateFieldMultiTS(fid,fieldName,loadAll,ms,entities) { } }; /*! @@ -437,15 +450,15 @@ namespace MEDCoupling { friend class MEDFileTemplateFieldMultiTS; public: - MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTS *shallowCpy() const { return new MEDFileFloatFieldMultiTS(*this); } - MEDLOADER_EXPORT MEDFileFloatFieldMultiTS *buildNewEmpty() const { return buildNewEmptyImpl(); } + MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTS *shallowCpy() const override { return new MEDFileFloatFieldMultiTS(*this); } + MEDLOADER_EXPORT MEDFileFloatFieldMultiTS *buildNewEmpty() const override { return buildNewEmptyImpl(); } MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileFloatFieldMultiTS"); } private: - ~MEDFileFloatFieldMultiTS() { } + ~MEDFileFloatFieldMultiTS() override = default; MEDFileFloatFieldMultiTS() { } MEDFileFloatFieldMultiTS(const MEDFileFloatFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileNDTemplateFieldMultiTS(other,shallowCopyOfContent) { } MEDFileFloatFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms):MEDFileNDTemplateFieldMultiTS(fid,loadAll,ms) { } - MEDFileFloatFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities=0):MEDFileNDTemplateFieldMultiTS(fid,fieldName,loadAll,ms,entities) { } + MEDFileFloatFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities=nullptr):MEDFileNDTemplateFieldMultiTS(fid,fieldName,loadAll,ms,entities) { } }; class MEDFileAnyTypeFieldMultiTSIterator diff --git a/src/MEDLoader/MEDFileFieldOverView.cxx b/src/MEDLoader/MEDFileFieldOverView.cxx index 038ee1954..f310a75d4 100644 --- a/src/MEDLoader/MEDFileFieldOverView.cxx +++ b/src/MEDLoader/MEDFileFieldOverView.cxx @@ -19,11 +19,32 @@ // Author : Anthony Geay (CEA/DEN) #include "MEDFileFieldOverView.hxx" +#include "MCType.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include "MCIdType.hxx" +#include "MCAuto.hxx" +#include "MEDCouplingPartDefinition.hxx" +#include "MEDCoupling1GTUMesh.hxx" +#include "MEDCouplingPointSet.hxx" +#include "MEDCouplingMemArray.hxx" +#include "MEDCouplingStructuredMesh.hxx" #include "MEDFileField.hxx" +#include "MEDFileFieldInternal.hxx" #include "MEDFileMesh.hxx" #include "MEDCouplingFieldDiscretization.hxx" #include "CellModel.hxx" +#include +#include +#include +#include "NormalizedGeometricTypes" +#include +#include +#include +#include +#include +#include +#include using namespace MEDCoupling; @@ -41,8 +62,8 @@ MEDFileMeshStruct *MEDFileMeshStruct::New(const MEDFileMesh *mesh) std::size_t MEDFileMeshStruct::getHeapMemorySizeWithoutChildren() const { std::size_t ret(0); - for(std::vector< std::vector >::const_iterator it0=_geo_types_distrib.begin();it0!=_geo_types_distrib.end();it0++) - ret+=(*it0).capacity()*sizeof(int); + for(const auto & it0 : _geo_types_distrib) + ret+=it0.capacity()*sizeof(int); ret+=_geo_types_distrib.capacity()*sizeof(std::vector); return ret; } @@ -60,20 +81,20 @@ MEDFileMeshStruct::MEDFileMeshStruct(const MEDFileMesh *mesh):_mesh(mesh) if(!levs.empty()) { _geo_types_distrib.resize(-(*std::min_element(levs.begin(),levs.end()))+1); - for(std::vector::const_iterator lev=levs.begin();lev!=levs.end();lev++) - _geo_types_distrib[-(*lev)]=mesh->getDistributionOfTypes(*lev); + for(int const lev : levs) + _geo_types_distrib[-lev]=mesh->getDistributionOfTypes(lev); } } int MEDFileMeshStruct::getLevelOfGeoType(INTERP_KERNEL::NormalizedCellType t) const { int j=0; - for(std::vector< std::vector >::const_iterator it1=_geo_types_distrib.begin();it1!=_geo_types_distrib.end();it1++,j--) + for(auto it1=_geo_types_distrib.begin();it1!=_geo_types_distrib.end();it1++,j--) { - std::size_t sz=(*it1).size(); + std::size_t const sz=(*it1).size(); if(sz%3!=0) throw INTERP_KERNEL::Exception("MEDFileMeshStruct::getLevelOfGeoType : internal error in code !"); - std::size_t nbGeo=sz/3; + std::size_t const nbGeo=sz/3; for(std::size_t i=0;i >::const_iterator it1=_geo_types_distrib.begin();it1!=_geo_types_distrib.end();it1++) + for(const auto & it1 : _geo_types_distrib) { - std::size_t sz=(*it1).size(); + std::size_t const sz=it1.size(); if(sz%3!=0) throw INTERP_KERNEL::Exception("MEDFileMeshStruct::getNumberOfElemsOfGeoType : internal error in code !"); - std::size_t nbGeo=sz/3; + std::size_t const nbGeo=sz/3; for(std::size_t i=0;i >::const_iterator it1=_geo_types_distrib.begin();it1!=_geo_types_distrib.end();it1++) + for(const auto & it1 : _geo_types_distrib) { - std::size_t sz=(*it1).size(); + std::size_t const sz=it1.size(); if(sz%3!=0) throw INTERP_KERNEL::Exception("MEDFileMeshStruct::doesManageGeoType : internal error in code !"); - std::size_t nbGeo=sz/3; + std::size_t const nbGeo=sz/3; for(std::size_t i=0;i arr(3); arr[0]=(mcIdType)t; arr[1]=_mesh->buildImplicitPartIfAny(t); arr[2]=-1; @@ -142,10 +163,10 @@ int MEDFileMeshStruct::getNumberOfLevs() const int MEDFileMeshStruct::getNumberOfGeoTypesInLev(int relativeLev) const { - int pos(-relativeLev); + int const pos(-relativeLev); if(pos<0 || pos>=(int)_geo_types_distrib.size()) throw INTERP_KERNEL::Exception("MEDFileMeshStruct::getNumberOfGeoTypesInLev : invalid level specified !"); - std::size_t sz=_geo_types_distrib[pos].size(); + std::size_t const sz=_geo_types_distrib[pos].size(); if(sz%3!=0) throw INTERP_KERNEL::Exception("MEDFileMeshStruct::getNumberOfGeoTypesInLev : internal error in code !"); return (int)(sz/3); @@ -167,13 +188,13 @@ MEDMeshMultiLev *MEDMeshMultiLev::New(const MEDFileMesh *m, const std::vector(m)); + const auto *um(dynamic_cast(m)); if(um) return MEDUMeshMultiLev::New(um,levs); - const MEDFileCMesh *cm(dynamic_cast(m)); + const auto *cm(dynamic_cast(m)); if(cm) return MEDCMeshMultiLev::New(cm,levs); - const MEDFileCurveLinearMesh *clm(dynamic_cast(m)); + const auto *clm(dynamic_cast(m)); if(clm) return MEDCurveLinearMeshMultiLev::New(clm,levs); throw INTERP_KERNEL::Exception("MEDMeshMultiLev::New : unrecognized type of mesh ! Must be in [MEDFileUMesh,MEDFileCMesh,MEDFileCurveLinearMesh] !"); @@ -183,13 +204,13 @@ MEDMeshMultiLev *MEDMeshMultiLev::New(const MEDFileMesh *m, const std::vector(m)); + const auto *um(dynamic_cast(m)); if(um) return MEDUMeshMultiLev::New(um,gts,pfls,nbEntities); - const MEDFileCMesh *cm(dynamic_cast(m)); + const auto *cm(dynamic_cast(m)); if(cm) return MEDCMeshMultiLev::New(cm,gts,pfls,nbEntities); - const MEDFileCurveLinearMesh *clm(dynamic_cast(m)); + const auto *clm(dynamic_cast(m)); if(clm) return MEDCurveLinearMeshMultiLev::New(clm,gts,pfls,nbEntities); throw INTERP_KERNEL::Exception("MEDMeshMultiLev::New 2 : unrecognized type of mesh ! Must be in [MEDFileUMesh,MEDFileCMesh,MEDFileCurveLinearMesh] !"); @@ -218,14 +239,14 @@ void MEDMeshMultiLev::setCellReduction(const DataArrayIdType *cr) cr->incrRef(); } -bool MEDMeshMultiLev::isFastlyTheSameStruct(const MEDFileField1TSStructItem& fst, const MEDFileFieldGlobsReal *globs) const +bool MEDMeshMultiLev::isFastlyTheSameStruct(const MEDFileField1TSStructItem& fst, const MEDFileFieldGlobsReal * /*globs*/) const { if(fst.getType()==ON_NODES) { if(fst.getNumberOfItems()!=1) throw INTERP_KERNEL::Exception("MEDMeshMultiLev::isFastlyTheSameStruct : unexpected situation for nodes !"); const MEDFileField1TSStructItem2& p(fst[0]); - std::string pflName(p.getPflName()); + std::string const pflName(p.getPflName()); const DataArrayIdType *nr(_node_reduction); if(pflName.empty() && !nr) return true; @@ -237,7 +258,7 @@ bool MEDMeshMultiLev::isFastlyTheSameStruct(const MEDFileField1TSStructItem& fst } else { - std::size_t sz(fst.getNumberOfItems()); + std::size_t const sz(fst.getNumberOfItems()); if(sz!=_geo_types.size()) return false; mcIdType strt(0); @@ -268,8 +289,8 @@ void MEDMeshMultiLev::retrieveFamilyIdsOnCells(DataArrayIdType *& famIds, bool& { const DataArrayIdType *fids(_cell_fam_ids); if(!fids) - { famIds=0; isWithoutCopy=true; return ; } - std::size_t sz(_geo_types.size()); + { famIds=nullptr; isWithoutCopy=true; return ; } + std::size_t const sz(_geo_types.size()); bool presenceOfPfls(false); for(std::size_t i=0;i tmp(fids->selectByTupleIdSafeSlice(start,start+lgth,1)); @@ -311,8 +332,8 @@ void MEDMeshMultiLev::retrieveNumberIdsOnCells(DataArrayIdType *& numIds, bool& { const DataArrayIdType *nids(_cell_num_ids); if(!nids) - { numIds=0; isWithoutCopy=true; return ; } - std::size_t sz(_geo_types.size()); + { numIds=nullptr; isWithoutCopy=true; return ; } + std::size_t const sz(_geo_types.size()); bool presenceOfPfls(false); for(std::size_t i=0;i tmp(nids->selectByTupleIdSafeSlice(start,start+lgth,1)); @@ -354,7 +375,7 @@ void MEDMeshMultiLev::retrieveFamilyIdsOnNodes(DataArrayIdType *& famIds, bool& { const DataArrayIdType *fids(_node_fam_ids); if(!fids) - { famIds=0; isWithoutCopy=true; return ; } + { famIds=nullptr; isWithoutCopy=true; return ; } const DataArrayIdType *nr(_node_reduction); if(nr) { @@ -376,7 +397,7 @@ void MEDMeshMultiLev::retrieveNumberIdsOnNodes(DataArrayIdType *& numIds, bool& { const DataArrayIdType *fids(_node_num_ids); if(!fids) - { numIds=0; isWithoutCopy=true; return ; } + { numIds=nullptr; isWithoutCopy=true; return ; } const DataArrayIdType *nr(_node_reduction); if(nr) { @@ -396,7 +417,7 @@ void MEDMeshMultiLev::retrieveNumberIdsOnNodes(DataArrayIdType *& numIds, bool& */ DataArrayIdType *MEDMeshMultiLev::retrieveGlobalNodeIdsIfAny() const { - const MEDFileUMesh *umesh(dynamic_cast(_mesh)); + const auto *umesh(dynamic_cast(_mesh)); if(!umesh) return nullptr; const PartDefinition *pd(umesh->getPartDefAtLevel(1)); @@ -454,7 +475,7 @@ void MEDMeshMultiLev::setNumberIdsOnNodes(DataArrayIdType *numIds) std::string MEDMeshMultiLev::getPflNameOfId(int id) const { - std::size_t sz(_pfls.size()); + std::size_t const sz(_pfls.size()); if(id<0 || id>=(int)sz) throw INTERP_KERNEL::Exception("MEDMeshMultiLev::getPflNameOfId : invalid input id !"); const DataArrayIdType *pfl(_pfls[id]); @@ -469,7 +490,7 @@ std::string MEDMeshMultiLev::getPflNameOfId(int id) const */ mcIdType MEDMeshMultiLev::getNumberOfCells(INTERP_KERNEL::NormalizedCellType t) const { - std::size_t sz(_nb_entities.size()); + std::size_t const sz(_nb_entities.size()); for(std::size_t i=0;ideepCopy(); @@ -520,16 +541,16 @@ DataArray *MEDMeshMultiLev::constructDataArray(const MEDFileField1TSStructItem& } else { - std::size_t sz(fst.getNumberOfItems()); - std::set s(_geo_types.begin(),_geo_types.end()); + std::size_t const sz(fst.getNumberOfItems()); + std::set const s(_geo_types.begin(),_geo_types.end()); if(s.size()!=_geo_types.size()) throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for cells 2 !"); std::vector< const DataArray *> arr(s.size()); std::vector< MCAuto > arrSafe(s.size()); int iii(0); - mcIdType nc(ToIdType(vals->getNumberOfComponents())); - std::vector compInfo(vals->getInfoOnComponents()); - for(std::vector< INTERP_KERNEL::NormalizedCellType >::const_iterator it=_geo_types.begin();it!=_geo_types.end();it++,iii++) + mcIdType const nc(ToIdType(vals->getNumberOfComponents())); + std::vector const compInfo(vals->getInfoOnComponents()); + for(auto it=_geo_types.begin();it!=_geo_types.end();it++,iii++) { const DataArrayIdType *thisP(_pfls[iii]); std::vector ps; @@ -543,7 +564,7 @@ DataArray *MEDMeshMultiLev::constructDataArray(const MEDFileField1TSStructItem& throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for cells 1 !"); if(ps.size()==1) { - int nbi(ps[0]->getNbOfIntegrationPts(globs)); + int const nbi(ps[0]->getNbOfIntegrationPts(globs)); const DataArrayIdType *otherP(ps[0]->getPfl(globs)); const std::pair& strtStop(ps[0]->getStartStop()); MCAuto ret(vals->selectByTupleIdSafeSlice(strtStop.first,strtStop.second,1)); @@ -585,7 +606,7 @@ DataArray *MEDMeshMultiLev::constructDataArray(const MEDFileField1TSStructItem& int jj(0); for(std::vector::const_iterator it2=ps.begin();it2!=ps.end();it2++,jj++) { - int nbi((*it2)->getNbOfIntegrationPts(globs)); + int const nbi((*it2)->getNbOfIntegrationPts(globs)); const DataArrayIdType *otherPfl((*it2)->getPfl(globs)); const std::pair& strtStop((*it2)->getStartStop()); MCAuto ret2(vals->selectByTupleIdSafeSlice(strtStop.first,strtStop.second,1)); @@ -633,8 +654,8 @@ DataArray *MEDMeshMultiLev::constructDataArray(const MEDFileField1TSStructItem& */ void MEDMeshMultiLev::appendVertices(const DataArrayIdType *verticesToAdd, DataArrayIdType *nr) { - mcIdType nbOfVertices(verticesToAdd->getNumberOfTuples()); - std::size_t sz(_pfls.size()); + mcIdType const nbOfVertices(verticesToAdd->getNumberOfTuples()); + std::size_t const sz(_pfls.size()); _pfls.resize(sz+1); _geo_types.resize(sz+1,INTERP_KERNEL::NORM_POINT1); _nb_entities.resize(sz+1,nbOfVertices); @@ -677,7 +698,7 @@ MEDMeshMultiLev::MEDMeshMultiLev(const MEDFileMesh *mesh):_mesh(mesh),_nb_nodes( MEDMeshMultiLev::MEDMeshMultiLev(const MEDFileMesh *mesh, mcIdType nbNodes, const std::vector& gts, const std::vector& pfls, const std::vector& nbEntities):_mesh(mesh),_geo_types(gts),_nb_entities(nbEntities),_nb_nodes(nbNodes) { - std::size_t sz(_geo_types.size()); + std::size_t const sz(_geo_types.size()); if(sz!=pfls.size() || sz!=nbEntities.size()) throw INTERP_KERNEL::Exception("MEDMeshMultiLev::MEDMeshMultiLev : input vector must have the same size !"); _pfls.resize(sz); @@ -689,9 +710,8 @@ MEDMeshMultiLev::MEDMeshMultiLev(const MEDFileMesh *mesh, mcIdType nbNodes, cons } } -MEDMeshMultiLev::MEDMeshMultiLev(const MEDMeshMultiLev& other):RefCountObject(other),_mesh(other._mesh),_pfls(other._pfls),_geo_types(other._geo_types),_nb_entities(other._nb_entities),_node_reduction(other._node_reduction),_nb_nodes(other._nb_nodes),_cell_fam_ids(other._cell_fam_ids),_cell_num_ids(other._cell_num_ids),_node_fam_ids(other._node_fam_ids),_node_num_ids(other._node_num_ids) -{ -} +MEDMeshMultiLev::MEDMeshMultiLev(const MEDMeshMultiLev& other) += default; //= @@ -705,12 +725,12 @@ MEDUMeshMultiLev::MEDUMeshMultiLev(const MEDFileUMesh *m, const std::vector if(!m) throw INTERP_KERNEL::Exception("MEDUMeshMultiLev constructor : null input pointer !"); std::vector v; - for(std::vector::const_iterator it=levs.begin();it!=levs.end();it++) + for(int const lev : levs) { - std::vector vTmp(m->getDirectUndergroundSingleGeoTypeMeshes(*it)); + std::vector vTmp(m->getDirectUndergroundSingleGeoTypeMeshes(lev)); v.insert(v.end(),vTmp.begin(),vTmp.end()); } - std::size_t sz(v.size()); + std::size_t const sz(v.size()); if(v.empty()) { _coords=m->getCoords(); _coords->incrRef(); @@ -731,7 +751,7 @@ MEDUMeshMultiLev::MEDUMeshMultiLev(const MEDFileUMesh *m, const std::vector _nb_entities[i]=obj->getNumberOfCells(); } // ids fields management - bool cellFamIdsNoCpy(levs.size()==1); + bool const cellFamIdsNoCpy(levs.size()==1); if(cellFamIdsNoCpy) { const DataArrayIdType *tmp(m->getFamilyFieldAtLevel(levs[0])); @@ -754,7 +774,7 @@ MEDUMeshMultiLev::MEDUMeshMultiLev(const MEDFileUMesh *m, const std::vector if(f && !tmps.empty()) _cell_fam_ids=DataArrayIdType::Aggregate(tmps); } - bool cellNumIdsNoCpy(levs.size()==1); + bool const cellNumIdsNoCpy(levs.size()==1); if(cellNumIdsNoCpy) { const DataArrayIdType *tmp(m->getNumberFieldAtLevel(levs[0])); @@ -803,10 +823,10 @@ MEDUMeshMultiLev *MEDUMeshMultiLev::New(const MEDFileUMesh *m, const std::vector MEDUMeshMultiLev::MEDUMeshMultiLev(const MEDFileUMesh *m, const std::vector& gts, const std::vector& pfls, const std::vector& nbEntities):MEDMeshMultiLev(m,m->getNumberOfNodes(),gts,pfls,nbEntities) { - std::size_t sz(gts.size()); + std::size_t const sz(gts.size()); if(sz<1) throw INTERP_KERNEL::Exception("constructor of MEDUMeshMultiLev : number of different geo type must be >= 1 !"); - unsigned dim(INTERP_KERNEL::CellModel::GetCellModel(gts[0]).getDimension()); + unsigned const dim(INTERP_KERNEL::CellModel::GetCellModel(gts[0]).getDimension()); _parts.resize(sz); bool isSameDim(true),isNoPfl(true); for(std::size_t i=0;igetMeshDimension()); + int const lev((int)dim-m->getMeshDimension()); if(isSameDim && isNoPfl && m->getGeoTypesAtLevel(lev)==gts)//optimized part { const DataArrayIdType *famIds(m->getFamilyFieldAtLevel(lev)); @@ -876,7 +896,7 @@ void MEDUMeshMultiLev::selectPartOfNodes(const DataArrayIdType *pflNodes) { if(!pflNodes || !pflNodes->isAllocated()) return ; - std::size_t sz(_parts.size()); + std::size_t const sz(_parts.size()); std::vector< MCAuto > a(sz); std::vector< const DataArrayIdType *> aa(sz); for(std::size_t i=0;i m(_parts[i]); if(pfl) m=dynamic_cast(_parts[i]->buildPartOfMySelfKeepCoords(pfl->begin(),pfl->end())); - DataArrayIdType *cellIds=0; + DataArrayIdType *cellIds=nullptr; m->fillCellIdsToKeepFromNodeIds(pflNodes->begin(),pflNodes->end(),true,cellIds); - MCAuto cellIdsSafe(cellIds); + MCAuto const cellIdsSafe(cellIds); MCAuto m2(m->buildPartOfMySelfKeepCoords(cellIds->begin(),cellIds->end())); mcIdType tmp=-1; MCAuto o2n(m2->getNodeIdsInUse(tmp)); @@ -919,9 +939,8 @@ MEDMeshMultiLev *MEDUMeshMultiLev::prepare() const return new MEDUMeshMultiLev(*this); } -MEDUMeshMultiLev::MEDUMeshMultiLev(const MEDUMeshMultiLev& other):MEDMeshMultiLev(other),_parts(other._parts),_coords(other._coords) -{ -} +MEDUMeshMultiLev::MEDUMeshMultiLev(const MEDUMeshMultiLev& other) += default; MEDUMeshMultiLev::MEDUMeshMultiLev(const MEDStructuredMeshMultiLev& other, const MCAuto& part):MEDMeshMultiLev(other) { @@ -929,7 +948,7 @@ MEDUMeshMultiLev::MEDUMeshMultiLev(const MEDStructuredMeshMultiLev& other, const _parts[0]=part; _geo_types.resize(1); _geo_types[0]=part->getCellModelEnum(); _nb_entities.resize(1); _nb_entities[0]=part->getNumberOfCells(); - _pfls.resize(1); _pfls[0]=0; + _pfls.resize(1); _pfls[0]=nullptr; } /*! @@ -939,7 +958,7 @@ MEDUMeshMultiLev::MEDUMeshMultiLev(const MEDStructuredMeshMultiLev& other, const */ bool MEDUMeshMultiLev::buildVTUArrays(DataArrayDouble *& coords, DataArrayByte *&types, DataArrayIdType *&cellLocations, DataArrayIdType *& cells, DataArrayIdType *&faceLocations, DataArrayIdType *&faces) const { - const DataArrayDouble *tmp(0); + const DataArrayDouble *tmp(nullptr); if(_parts.empty()) tmp=_coords; else @@ -950,7 +969,7 @@ bool MEDUMeshMultiLev::buildVTUArrays(DataArrayDouble *& coords, DataArrayByte * mcIdType szBCE(0),szD(0),szF(0); bool isPolyh(false); int iii(0); - for(std::vector< MCAuto >::const_iterator it=_parts.begin();it!=_parts.end();it++,iii++) + for(auto it=_parts.begin();it!=_parts.end();it++,iii++) { const MEDCoupling1GTUMesh *cur(*it); if(!cur) @@ -963,7 +982,7 @@ bool MEDUMeshMultiLev::buildVTUArrays(DataArrayDouble *& coords, DataArrayByte * else { cur2=dynamic_cast(cur->buildPartOfMySelfKeepCoords(pfl->begin(),pfl->end())); cur=cur2; } // - mcIdType curNbCells(cur->getNumberOfCells()); + mcIdType const curNbCells(cur->getNumberOfCells()); szBCE+=curNbCells; if((*it)->getCellModelEnum()!=INTERP_KERNEL::NORM_POLYHED) szD+=cur->getNodalConnectivity()->getNumberOfTuples()+curNbCells; @@ -978,12 +997,12 @@ bool MEDUMeshMultiLev::buildVTUArrays(DataArrayDouble *& coords, DataArrayByte * MCAuto b(DataArrayByte::New()); b->alloc(szBCE,1); char *bPtr(b->getPointer()); MCAuto c(DataArrayIdType::New()); c->alloc(szBCE,1); mcIdType *cPtr(c->getPointer()); MCAuto d(DataArrayIdType::New()); d->alloc(szD,1); mcIdType *dPtr(d->getPointer()); - MCAuto e(DataArrayIdType::New()),f(DataArrayIdType::New()); mcIdType *ePtr(0),*fPtr(0); + MCAuto e(DataArrayIdType::New()),f(DataArrayIdType::New()); mcIdType *ePtr(nullptr),*fPtr(nullptr); if(isPolyh) { e->alloc(szBCE,1); ePtr=e->getPointer(); f->alloc(szF,1); fPtr=f->getPointer(); } mcIdType k(0); iii=0; - for(std::vector< MCAuto >::const_iterator it=_parts.begin();it!=_parts.end();it++,iii++) + for(auto it=_parts.begin();it!=_parts.end();it++,iii++) { const MEDCoupling1GTUMesh *cur(*it); // @@ -994,16 +1013,16 @@ bool MEDUMeshMultiLev::buildVTUArrays(DataArrayDouble *& coords, DataArrayByte * else { cur2=dynamic_cast(cur->buildPartOfMySelfKeepCoords(pfl->begin(),pfl->end())); cur=cur2; } // - mcIdType curNbCells(cur->getNumberOfCells()); - int gt((int)cur->getCellModelEnum()); + mcIdType const curNbCells(cur->getNumberOfCells()); + int const gt((int)cur->getCellModelEnum()); if(gt<0 || gt>=PARAMEDMEM_2_VTKTYPE_LGTH) throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::getVTUArrays : invalid geometric type !"); - unsigned char gtvtk(PARAMEDMEM_2_VTKTYPE[gt]); + unsigned char const gtvtk(PARAMEDMEM_2_VTKTYPE[gt]); if(gtvtk==255) throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::getVTUArrays : no VTK type for the requested INTERP_KERNEL geometric type !"); std::fill(bPtr,bPtr+curNbCells,gtvtk); bPtr+=curNbCells; - const MEDCoupling1SGTUMesh *scur(dynamic_cast(cur)); - const MEDCoupling1DGTUMesh *dcur(dynamic_cast(cur)); + const auto *scur(dynamic_cast(cur)); + const auto *dcur(dynamic_cast(cur)); const mcIdType *connPtr(cur->getNodalConnectivity()->begin()); if(!scur && !dcur) throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::getVTUArrays : internal error !"); @@ -1011,7 +1030,7 @@ bool MEDUMeshMultiLev::buildVTUArrays(DataArrayDouble *& coords, DataArrayByte * { if(cur->getCellModelEnum()!=INTERP_KERNEL::NORM_HEXA27) { - mcIdType nnpc(scur->getNumberOfNodesPerCell()); + mcIdType const nnpc(scur->getNumberOfNodesPerCell()); for(mcIdType i=0;igetNumberOfComponents()!=3) a=a->changeNbOfComponents(3,0.); coords=a.retn(); types=b.retn(); cellLocations=c.retn(); cells=d.retn(); if(!isPolyh) - { faceLocations=0; faces=0; } + { faceLocations=nullptr; faces=nullptr; } else { faceLocations=e.retn(); faces=f.retn(); } return _mesh->isObjectInTheProgeny(coords); @@ -1104,12 +1123,12 @@ void MEDUMeshMultiLev::reorderNodesIfNecessary(MCAuto& coords, coords=(coords->selectByTupleIdSafe(nr->begin(),nr->end())); return ; } - mcIdType sz(coords->getNumberOfTuples()); + mcIdType const sz(coords->getNumberOfTuples()); std::vector b(sz,false); const mcIdType *work(nodalConnVTK->begin()),*endW(nodalConnVTK->end()); while(work!=endW) { - mcIdType nb(*work++); + mcIdType const nb(*work++); for(mcIdType i=0;i=0 && *work& coords, work=polyhedNodalConnVTK->begin(); endW=polyhedNodalConnVTK->end(); while(work!=endW) { - mcIdType nb(*work++); + mcIdType const nb(*work++); for(mcIdType i=0;i=0 && *work& coords, } } } - std::size_t szExp(std::count(b.begin(),b.end(),true)); + std::size_t const szExp(std::count(b.begin(),b.end(),true)); if(ToIdType(szExp)!=nr->getNumberOfTuples()) throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::reorderNodesIfNecessary : internal error #3 !"); // Go renumbering ! @@ -1153,7 +1172,7 @@ void MEDUMeshMultiLev::reorderNodesIfNecessary(MCAuto& coords, mcIdType *work2(nodalConnVTK->getPointer()),*endW2(nodalConnVTK->getPointer()+nodalConnVTK->getNumberOfTuples()); while(work2!=endW2) { - mcIdType nb(*work2++); + mcIdType const nb(*work2++); for(mcIdType i=0;i& coords, work2=polyhedNodalConnVTK->getPointer(); endW2=polyhedNodalConnVTK->getPointer()+polyhedNodalConnVTK->getNumberOfTuples(); while(work2!=endW2) { - mcIdType nb(*work2++); + mcIdType const nb(*work2++); for(mcIdType i=0;i& coords, void MEDUMeshMultiLev::appendVertices(const DataArrayIdType *verticesToAdd, DataArrayIdType *nr) { - mcIdType nbOfCells(verticesToAdd->getNumberOfTuples());//it is not a bug cells are NORM_POINT1 + mcIdType const nbOfCells(verticesToAdd->getNumberOfTuples());//it is not a bug cells are NORM_POINT1 MEDMeshMultiLev::appendVertices(verticesToAdd,nr); MCAuto elt(MEDCoupling1SGTUMesh::New("",INTERP_KERNEL::NORM_POINT1)); elt->allocateCells(nbOfCells); @@ -1195,7 +1214,7 @@ void MEDUMeshMultiLev::appendVertices(const DataArrayIdType *verticesToAdd, Data //= -MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev(const MEDFileStructuredMesh *m, const std::vector& lev):MEDMeshMultiLev(m),_is_internal(true) +MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev(const MEDFileStructuredMesh *m, const std::vector& /*lev*/):MEDMeshMultiLev(m),_is_internal(true) { initStdFieldOfIntegers(m); } @@ -1212,7 +1231,7 @@ MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev(const MEDStructuredMeshMult void MEDStructuredMeshMultiLev::initStdFieldOfIntegers(const MEDFileStructuredMesh *m) { // ids fields management - const DataArrayIdType *tmp(0); + const DataArrayIdType *tmp(nullptr); tmp=m->getFamilyFieldAtLevel(0); if(tmp) { @@ -1226,7 +1245,7 @@ void MEDStructuredMeshMultiLev::initStdFieldOfIntegers(const MEDFileStructuredMe _cell_num_ids=const_cast(tmp); } // - tmp=0; + tmp=nullptr; tmp=m->getFamilyFieldAtLevel(1); if(tmp) { @@ -1256,27 +1275,27 @@ void MEDStructuredMeshMultiLev::initStdFieldOfIntegers(const MEDFileStructuredMe void MEDStructuredMeshMultiLev::moveFaceToCell() const { - const_cast(this)->_cell_fam_ids=_face_fam_ids; const_cast(this)->_face_fam_ids=0; - const_cast(this)->_cell_num_ids=_face_num_ids; const_cast(this)->_face_num_ids=0; + const_cast(this)->_cell_fam_ids=_face_fam_ids; const_cast(this)->_face_fam_ids=nullptr; + const_cast(this)->_cell_num_ids=_face_num_ids; const_cast(this)->_face_num_ids=nullptr; } bool MEDStructuredMeshMultiLev::prepareForImplicitUnstructuredMeshCase(MEDMeshMultiLev *&ret) const { - ret=0; + ret=nullptr; if(_geo_types.empty()) return false; if(_geo_types.size()!=1) throw INTERP_KERNEL::Exception("MEDStructuredMeshMultiLev::prepareForImplicitUnstructuredMeshCase only one geo types supported at most supported for the moment !"); - INTERP_KERNEL::NormalizedCellType gt(MEDCouplingStructuredMesh::GetGeoTypeGivenMeshDimension(_mesh->getMeshDimension())); + INTERP_KERNEL::NormalizedCellType const gt(MEDCouplingStructuredMesh::GetGeoTypeGivenMeshDimension(_mesh->getMeshDimension())); if(_geo_types[0]==gt) return false; MEDCoupling1GTUMesh *facesIfPresent((static_cast(_mesh))->getImplicitFaceMesh()); if(!facesIfPresent) return false; - const DataArrayIdType *pfl(0),*nr(_node_reduction); + const DataArrayIdType *pfl(nullptr),*nr(_node_reduction); if(!_pfls.empty()) pfl=_pfls[0]; - MCAuto facesIfPresent2(facesIfPresent); facesIfPresent->incrRef(); + MCAuto const facesIfPresent2(facesIfPresent); facesIfPresent->incrRef(); moveFaceToCell(); MCAuto ret2(new MEDUMeshMultiLev(*this,facesIfPresent2)); if(pfl) @@ -1289,7 +1308,7 @@ bool MEDStructuredMeshMultiLev::prepareForImplicitUnstructuredMeshCase(MEDMeshMu void MEDStructuredMeshMultiLev::dealWithImplicitUnstructuredMesh(const MEDFileMesh *m) { - const DataArrayIdType *tmp(0); + const DataArrayIdType *tmp(nullptr); tmp=m->getFamilyFieldAtLevel(-1); if(tmp) { @@ -1317,9 +1336,9 @@ void MEDStructuredMeshMultiLev::selectPartOfNodes(const DataArrayIdType *pflNode { m=dynamic_cast(m->buildPartOfMySelfKeepCoords(pfl->begin(),pfl->end())); } - DataArrayIdType *cellIds=0; + DataArrayIdType *cellIds=nullptr; m->fillCellIdsToKeepFromNodeIds(pflNodes->begin(),pflNodes->end(),true,cellIds); - MCAuto cellIdsSafe(cellIds); + MCAuto const cellIdsSafe(cellIds); MCAuto m2(m->buildPartOfMySelfKeepCoords(cellIds->begin(),cellIds->end())); mcIdType tmp=-1; _node_reduction=m2->getNodeIdsInUse(tmp); @@ -1347,11 +1366,11 @@ MEDCMeshMultiLev::MEDCMeshMultiLev(const MEDFileCMesh *m, const std::vector throw INTERP_KERNEL::Exception("MEDCMeshMultiLev constructor : null input pointer !"); if(levs.size()!=1 || levs[0]!=0) throw INTERP_KERNEL::Exception("MEDCMeshMultiLev constructor : levels supported is 0 only !"); - int sdim(m->getSpaceDimension()); + int const sdim(m->getSpaceDimension()); _coords.resize(sdim); for(int i=0;i(m->getMesh()->getCoordsAt(i))); + auto *elt(const_cast(m->getMesh()->getCoordsAt(i))); if(!elt) throw INTERP_KERNEL::Exception("MEDCMeshMultiLev constructor 2 : presence of null pointer for an vector of double along an axis !"); elt->incrRef(); @@ -1365,14 +1384,14 @@ MEDCMeshMultiLev::MEDCMeshMultiLev(const MEDFileCMesh *m, const std::vectorgetMeshDimension()); - INTERP_KERNEL::NormalizedCellType gt(MEDCouplingStructuredMesh::GetGeoTypeGivenMeshDimension(mdim)); + int const mdim(m->getMeshDimension()); + INTERP_KERNEL::NormalizedCellType const gt(MEDCouplingStructuredMesh::GetGeoTypeGivenMeshDimension(mdim)); if(gt==gts[0]) { _coords.resize(mdim); for(int i=0;i(m->getMesh()->getCoordsAt(i))); + auto *elt(const_cast(m->getMesh()->getCoordsAt(i))); if(!elt) throw INTERP_KERNEL::Exception("MEDCMeshMultiLev constructor 2 : presence of null pointer for an vector of double along an axis !"); _coords[i]=elt; _coords[i]->incrRef(); @@ -1382,9 +1401,8 @@ MEDCMeshMultiLev::MEDCMeshMultiLev(const MEDFileCMesh *m, const std::vector MEDCMeshMultiLev::getNodeGridStructure() const { @@ -1396,10 +1414,10 @@ std::vector MEDCMeshMultiLev::getNodeGridStructure() const MEDMeshMultiLev *MEDCMeshMultiLev::prepare() const { - MEDMeshMultiLev *retSpecific(0); + MEDMeshMultiLev *retSpecific(nullptr); if(prepareForImplicitUnstructuredMeshCase(retSpecific)) return retSpecific; - const DataArrayIdType *pfl(0),*nr(_node_reduction); + const DataArrayIdType *pfl(nullptr),*nr(_node_reduction); if(!_pfls.empty()) pfl=_pfls[0]; MCAuto nnr; @@ -1417,7 +1435,7 @@ MEDMeshMultiLev *MEDCMeshMultiLev::prepare() const if(nr) { nnr=nr->deepCopy(); nnr->sort(true); ret->setNodeReduction(nnr); } ret->_nb_entities[0]=pfl->getNumberOfTuples(); - ret->_pfls[0]=0; + ret->_pfls[0]=nullptr; std::vector< MCAuto > coords(_coords.size()); for(std::size_t i=0;i<_coords.size();i++) coords[i]=_coords[i]->selectByTupleIdSafeSlice(cellParts[i].first,cellParts[i].second+1,1); @@ -1465,7 +1483,7 @@ MEDMeshMultiLev *MEDCMeshMultiLev::prepare() const std::vector< DataArrayDouble * > MEDCMeshMultiLev::buildVTUArrays(bool& isInternal) const { isInternal=_is_internal; - std::size_t sz(_coords.size()); + std::size_t const sz(_coords.size()); std::vector< DataArrayDouble * > ret(sz); for(std::size_t i=0;i(m->getMesh()->getCoords())); + auto *coords(const_cast(m->getMesh()->getCoords())); if(!coords) throw INTERP_KERNEL::Exception("MEDCurveLinearMeshMultiLev constructor 2 : no coords set !"); coords->incrRef(); @@ -1507,10 +1525,10 @@ MEDCurveLinearMeshMultiLev::MEDCurveLinearMeshMultiLev(const MEDFileCurveLinearM throw INTERP_KERNEL::Exception("MEDCurveLinearMeshMultiLev constructor 2 : null input pointer !"); if(gts.size()!=1 || pfls.size()!=1) throw INTERP_KERNEL::Exception("MEDCurveLinearMeshMultiLev constructor 2 : lengths of gts and pfls must be equal to one !"); - INTERP_KERNEL::NormalizedCellType gt(MEDCouplingStructuredMesh::GetGeoTypeGivenMeshDimension(m->getMeshDimension())); + INTERP_KERNEL::NormalizedCellType const gt(MEDCouplingStructuredMesh::GetGeoTypeGivenMeshDimension(m->getMeshDimension())); if(gt==gts[0]) { - DataArrayDouble *coords(const_cast(m->getMesh()->getCoords())); + auto *coords(const_cast(m->getMesh()->getCoords())); if(!coords) throw INTERP_KERNEL::Exception("MEDCurveLinearMeshMultiLev constructor 2 : no coords set !"); coords->incrRef(); @@ -1521,9 +1539,8 @@ MEDCurveLinearMeshMultiLev::MEDCurveLinearMeshMultiLev(const MEDFileCurveLinearM dealWithImplicitUnstructuredMesh(m); } -MEDCurveLinearMeshMultiLev::MEDCurveLinearMeshMultiLev(const MEDCurveLinearMeshMultiLev& other):MEDStructuredMeshMultiLev(other),_coords(other._coords),_structure(other._structure) -{ -} +MEDCurveLinearMeshMultiLev::MEDCurveLinearMeshMultiLev(const MEDCurveLinearMeshMultiLev& other) += default; std::vector MEDCurveLinearMeshMultiLev::getNodeGridStructure() const { @@ -1532,10 +1549,10 @@ std::vector MEDCurveLinearMeshMultiLev::getNodeGridStructure() const MEDMeshMultiLev *MEDCurveLinearMeshMultiLev::prepare() const { - MEDMeshMultiLev *retSpecific(0); + MEDMeshMultiLev *retSpecific(nullptr); if(prepareForImplicitUnstructuredMeshCase(retSpecific)) return retSpecific; - const DataArrayIdType *pfl(0),*nr(_node_reduction); + const DataArrayIdType *pfl(nullptr),*nr(_node_reduction); if(!_pfls.empty()) pfl=_pfls[0]; MCAuto nnr; @@ -1561,7 +1578,7 @@ MEDMeshMultiLev *MEDCurveLinearMeshMultiLev::prepare() const if(nr) { nnr=nr->deepCopy(); nnr->sort(true); ret->setNodeReduction(nnr); } ret->_nb_entities[0]=pfl->getNumberOfTuples(); - ret->_pfls[0]=0; + ret->_pfls[0]=nullptr; ret->_coords=_coords->selectByTupleIdSafe(p->begin(),p->end()); ret->_structure=st; ret2=(MEDCurveLinearMeshMultiLev *)ret; ret2->incrRef(); @@ -1612,8 +1629,7 @@ void MEDCurveLinearMeshMultiLev::buildVTUArrays(DataArrayDouble *&coords, std::v //= MEDFileField1TSStructItem2::MEDFileField1TSStructItem2() -{ -} += default; MEDFileField1TSStructItem2::MEDFileField1TSStructItem2(INTERP_KERNEL::NormalizedCellType a, const std::pair& b, const std::string& c, const std::string& d):_geo_type(a),_start_end(b),_pfl(DataArrayIdType::New()),_loc(d),_nb_of_entity(-1) { @@ -1624,16 +1640,16 @@ void MEDFileField1TSStructItem2::checkWithMeshStructForCells(const MEDFileMeshSt { if(!mst->doesManageGeoType(_geo_type)) { - MEDFileMeshStruct *mstUnConstCasted(const_cast(mst)); + auto *mstUnConstCasted(const_cast(mst)); mstUnConstCasted->appendIfImplicitType(_geo_type); } - mcIdType nbOfEnt=mst->getNumberOfElemsOfGeoType(_geo_type); + mcIdType const nbOfEnt=mst->getNumberOfElemsOfGeoType(_geo_type); checkInRange(nbOfEnt,1,globs); } void MEDFileField1TSStructItem2::checkWithMeshStructForGaussNE(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs) { - mcIdType nbOfEnt=mst->getNumberOfElemsOfGeoType(_geo_type); + mcIdType const nbOfEnt=mst->getNumberOfElemsOfGeoType(_geo_type); const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type); checkInRange(nbOfEnt,(int)cm.getNumberOfNodes(),globs); } @@ -1645,7 +1661,7 @@ void MEDFileField1TSStructItem2::checkWithMeshStructForGaussPT(const MEDFileMesh if(_loc.empty()) throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::checkWithMeshStructForGaussPT : no localization specified !"); const MEDFileFieldLoc& loc=globs->getLocalization(_loc.c_str()); - mcIdType nbOfEnt=mst->getNumberOfElemsOfGeoType(_geo_type); + mcIdType const nbOfEnt=mst->getNumberOfElemsOfGeoType(_geo_type); checkInRange(nbOfEnt,loc.getNumberOfGaussPoints(),globs); } @@ -1675,7 +1691,7 @@ const DataArrayIdType *MEDFileField1TSStructItem2::getPfl(const MEDFileFieldGlob if(!_pfl->isAllocated()) { if(_pfl->getName().empty()) - return 0; + return nullptr; else return globs->getProfile(_pfl->getName().c_str()); } @@ -1754,9 +1770,9 @@ MEDFileField1TSStructItem2 MEDFileField1TSStructItem2::BuildAggregationOf(const throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::BuildAggregationOf : empty input !"); if(objs.size()==1) return MEDFileField1TSStructItem2(*objs[0]); - INTERP_KERNEL::NormalizedCellType gt(objs[0]->_geo_type); - mcIdType nbEntityRef(objs[0]->_nb_of_entity); - std::size_t sz(objs.size()); + INTERP_KERNEL::NormalizedCellType const gt(objs[0]->_geo_type); + mcIdType const nbEntityRef(objs[0]->_nb_of_entity); + std::size_t const sz(objs.size()); std::vector arrs(sz); for(std::size_t i=0;i arr(DataArrayIdType::Aggregate(arrs)); arr->sort(); - mcIdType oldNbTuples(arr->getNumberOfTuples()); + mcIdType const oldNbTuples(arr->getNumberOfTuples()); arr=arr->buildUnique(); if(oldNbTuples!=arr->getNumberOfTuples()) throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::BuildAggregationOf : some entities are present several times !"); if(arr->isIota(nbEntityRef)) { - std::pair p(0,nbEntityRef); + std::pair const p(0,nbEntityRef); std::string a,b; MEDFileField1TSStructItem2 ret(gt,p,a,b); ret._nb_of_entity=nbEntityRef; @@ -1786,7 +1802,7 @@ MEDFileField1TSStructItem2 MEDFileField1TSStructItem2::BuildAggregationOf(const else { arr->setName(NEWLY_CREATED_PFL_NAME); - std::pair p(0,oldNbTuples); + std::pair const p(0,oldNbTuples); std::string a,b; MEDFileField1TSStructItem2 ret(gt,p,a,b); ret._nb_of_entity=nbEntityRef; @@ -1797,7 +1813,7 @@ MEDFileField1TSStructItem2 MEDFileField1TSStructItem2::BuildAggregationOf(const std::size_t MEDFileField1TSStructItem2::getHeapMemorySizeWithoutChildren() const { - std::size_t ret(_loc.capacity()); + std::size_t const ret(_loc.capacity()); return ret; } @@ -1820,7 +1836,7 @@ void MEDFileField1TSStructItem::checkWithMeshStruct(const MEDFileMeshStruct *mst { case ON_NODES: { - mcIdType nbOfEnt=mst->getNumberOfNodes(); + mcIdType const nbOfEnt=mst->getNumberOfNodes(); if(_items.size()!=1) throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::checkWithMeshStruct : for nodes field only one subdivision supported !"); _items[0].checkInRange(nbOfEnt,1,globs); @@ -1828,20 +1844,20 @@ void MEDFileField1TSStructItem::checkWithMeshStruct(const MEDFileMeshStruct *mst } case ON_CELLS: { - for(std::vector< MEDFileField1TSStructItem2 >::iterator it=_items.begin();it!=_items.end();it++) - (*it).checkWithMeshStructForCells(mst,globs); + for(auto & _item : _items) + _item.checkWithMeshStructForCells(mst,globs); break; } case ON_GAUSS_NE: { - for(std::vector< MEDFileField1TSStructItem2 >::iterator it=_items.begin();it!=_items.end();it++) - (*it).checkWithMeshStructForGaussNE(mst,globs); + for(auto & _item : _items) + _item.checkWithMeshStructForGaussNE(mst,globs); break; } case ON_GAUSS_PT: { - for(std::vector< MEDFileField1TSStructItem2 >::iterator it=_items.begin();it!=_items.end();it++) - (*it).checkWithMeshStructForGaussPT(mst,globs); + for(auto & _item : _items) + _item.checkWithMeshStructForGaussPT(mst,globs); break; } default: @@ -1908,9 +1924,9 @@ MEDFileField1TSStructItem MEDFileField1TSStructItem::simplifyMeOnCellEntity(cons throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::simplifyMeOnCellEntity : must be on ON_CELLS, ON_GAUSS_NE or ON_GAUSS_PT !"); std::vector< std::pair< INTERP_KERNEL::NormalizedCellType, std::vector > > m; std::size_t i=0; - for(std::vector< MEDFileField1TSStructItem2 >::const_iterator it=_items.begin();it!=_items.end();it++,i++) + for(auto it=_items.begin();it!=_items.end();it++,i++) { - std::vector< std::pair< INTERP_KERNEL::NormalizedCellType, std::vector > >::iterator it0(std::find_if(m.begin(),m.end(),CmpGeo((*it).getGeo()))); + auto const it0(std::find_if(m.begin(),m.end(),CmpGeo((*it).getGeo()))); if(it0==m.end()) m.push_back(std::pair< INTERP_KERNEL::NormalizedCellType, std::vector >((*it).getGeo(),std::vector(1,i))); else @@ -1922,7 +1938,7 @@ MEDFileField1TSStructItem MEDFileField1TSStructItem::simplifyMeOnCellEntity(cons ret._type=ON_CELLS; return ret; } - std::size_t sz(m.size()); + std::size_t const sz(m.size()); std::vector< MEDFileField1TSStructItem2 > items(sz); for(i=0;igetNumberOfNodes()); + mcIdType const nbOfNodes(meshSt->getNumberOfNodes()); if(otherNodeIt.getPflName().empty()) {//on all nodes if(!ret0) @@ -1984,21 +2000,21 @@ bool MEDFileField1TSStructItem::isFullyOnOneLev(const MEDFileMeshStruct *meshSt, throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::isFullyOnOneLev : works only for ON_CELLS discretization !"); if(_items.empty()) throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::isFullyOnOneLev : items vector is empty !"); - int nbOfLevs(meshSt->getNumberOfLevs()); + int const nbOfLevs(meshSt->getNumberOfLevs()); if(nbOfLevs==0) throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::isFullyOnOneLev : no levels in input mesh structure !"); std::vector levs(nbOfLevs); theFirstLevFull=1; std::set gts; - for(std::vector< MEDFileField1TSStructItem2 >::const_iterator it=_items.begin();it!=_items.end();it++) + for(const auto & _item : _items) { - if(!(*it).getPflName().empty()) + if(!_item.getPflName().empty()) return false; - INTERP_KERNEL::NormalizedCellType gt((*it).getGeo()); + INTERP_KERNEL::NormalizedCellType const gt(_item.getGeo()); if(gts.find(gt)!=gts.end()) throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem::isFullyOnOneLev : internal error !"); gts.insert(gt); - int pos(meshSt->getLevelOfGeoType((*it).getGeo())); + int const pos(meshSt->getLevelOfGeoType(_item.getGeo())); levs[-pos]++; } for(int i=0;i MEDFileField1TSStructItem::getDirectChildrenWithNull() const { std::vector ret; - for(std::vector< MEDFileField1TSStructItem2 >::const_iterator it=_items.begin();it!=_items.end();it++) - ret.push_back(&(*it)); + for(const auto & _item : _items) + ret.push_back(&_item); return ret; } MEDMeshMultiLev *MEDFileField1TSStructItem::buildFromScratchDataSetSupportOnCells(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs) const { - std::size_t sz(_items.size()); + std::size_t const sz(_items.size()); std::vector a0(sz); std::vector a1(sz); std::vector a2(sz); std::size_t i(0); - for(std::vector< MEDFileField1TSStructItem2 >::const_iterator it=_items.begin();it!=_items.end();it++,i++) + for(auto it=_items.begin();it!=_items.end();it++,i++) { a0[i]=(*it).getGeo(); a1[i]=(*it).getPfl(globs); @@ -2059,10 +2075,10 @@ std::vector MEDFileField1TSStructItem::getGeo else return ret; } - for(std::vector< MEDFileField1TSStructItem2 >::const_iterator it=_items.begin();it!=_items.end();it++) + for(const auto & _item : _items) { - INTERP_KERNEL::NormalizedCellType elt((*it).getGeo()); - std::vector::iterator it2(std::find(ret.begin(),ret.end(),elt)); + INTERP_KERNEL::NormalizedCellType const elt(_item.getGeo()); + auto const it2(std::find(ret.begin(),ret.end(),elt)); if(it2==ret.end()) ret.push_back(elt); } @@ -2077,15 +2093,15 @@ MEDFileField1TSStructItem MEDFileField1TSStructItem::BuildItemFrom(const MEDFile std::vector< std::vector > typesF; std::vector geoTypes; std::vector< std::vector > > strtEnds=ref->getFieldSplitedByType(std::string(),geoTypes,typesF,pfls,locs); - std::size_t nbOfGeoTypes(geoTypes.size()); + std::size_t const nbOfGeoTypes(geoTypes.size()); if(nbOfGeoTypes==0) throw INTERP_KERNEL::Exception("MEDFileField1TSStruct : not null by empty ref !"); if(typesF[0].empty()) throw INTERP_KERNEL::Exception("MEDFileField1TSStruct : internal error #1 bis !"); - TypeOfField atype(typesF[0][0]); + TypeOfField const atype(typesF[0][0]); for(std::size_t i=0;i::const_iterator it=_already_checked.begin();it!=_already_checked.end();it++) + MEDFileField1TSStructItem const b(MEDFileField1TSStructItem::BuildItemFrom(other,mst)); + for(const auto & it : _already_checked) { - if((*it)==b) + if(it==b) return true; } return false; @@ -2147,10 +2163,10 @@ bool MEDFileField1TSStruct::isSupportSameAs(const MEDFileAnyTypeField1TS *other, { if(_already_checked.empty()) throw INTERP_KERNEL::Exception("MEDFileField1TSStruct::isSupportSameAs : no ref !"); - MEDFileField1TSStructItem b(MEDFileField1TSStructItem::BuildItemFrom(other,meshSt)); + MEDFileField1TSStructItem const b(MEDFileField1TSStructItem::BuildItemFrom(other,meshSt)); if(!_already_checked[0].isEntityCell() || !b.isEntityCell()) throw INTERP_KERNEL::Exception("MEDFileField1TSStruct::isSupportSameAs : only available on cell entities !"); - MEDFileField1TSStructItem other1(b.simplifyMeOnCellEntity(other)); + MEDFileField1TSStructItem const other1(b.simplifyMeOnCellEntity(other)); int found=-1,i=0; for(std::vector::const_iterator it=_already_checked.begin();it!=_already_checked.end();it++,i++) if((*it).isComputed()) @@ -2158,7 +2174,7 @@ bool MEDFileField1TSStruct::isSupportSameAs(const MEDFileAnyTypeField1TS *other, bool ret(false); if(found==-1) { - MEDFileField1TSStructItem this1(_already_checked[0].simplifyMeOnCellEntity(other)); + MEDFileField1TSStructItem const this1(_already_checked[0].simplifyMeOnCellEntity(other)); ret=this1.isCellSupportEqual(other1,other); if(ret) _already_checked.push_back(this1); @@ -2177,7 +2193,7 @@ bool MEDFileField1TSStruct::isCompatibleWithNodesDiscr(const MEDFileAnyTypeField { if(_already_checked.empty()) throw INTERP_KERNEL::Exception("MEDFileField1TSStruct::isCompatibleWithNodesDiscr : no ref !"); - MEDFileField1TSStructItem other1(MEDFileField1TSStructItem::BuildItemFrom(other,meshSt)); + MEDFileField1TSStructItem const other1(MEDFileField1TSStructItem::BuildItemFrom(other,meshSt)); if(_already_checked[0].isEntityCell()) { int found=-1,i=0; @@ -2187,7 +2203,7 @@ bool MEDFileField1TSStruct::isCompatibleWithNodesDiscr(const MEDFileAnyTypeField bool ret(false); if(found==-1) { - MEDFileField1TSStructItem this1(_already_checked[0].simplifyMeOnCellEntity(other)); + MEDFileField1TSStructItem const this1(_already_checked[0].simplifyMeOnCellEntity(other)); ret=this1.isCompatibleWithNodesDiscr(other1,meshSt,other); if(ret) _already_checked.push_back(this1); @@ -2204,15 +2220,15 @@ bool MEDFileField1TSStruct::isCompatibleWithNodesDiscr(const MEDFileAnyTypeField std::size_t MEDFileField1TSStruct::getHeapMemorySizeWithoutChildren() const { - std::size_t ret(_already_checked.capacity()*sizeof(MEDFileField1TSStructItem)); + std::size_t const ret(_already_checked.capacity()*sizeof(MEDFileField1TSStructItem)); return ret; } std::vector MEDFileField1TSStruct::getDirectChildrenWithNull() const { std::vector ret; - for(std::vector::const_iterator it=_already_checked.begin();it!=_already_checked.end();it++) - ret.push_back(&(*it)); + for(const auto & it : _already_checked) + ret.push_back(&it); return ret; } @@ -2259,16 +2275,16 @@ bool MEDFileField1TSStruct::isDataSetSupportFastlyEqualTo(const MEDFileField1TSS std::vector MEDFileField1TSStruct::getGeoTypes(const MEDFileMesh *m) const { std::vector ret; - for(std::vector::const_iterator it=_already_checked.begin();it!=_already_checked.end();it++) + for(const auto & it : _already_checked) { - std::vector ret2((*it).getGeoTypes(m)); - for(std::vector::const_iterator it2=ret2.begin();it2!=ret2.end();it2++) + std::vector const ret2(it.getGeoTypes(m)); + for(auto it2 : ret2) { - if(*it2==INTERP_KERNEL::NORM_ERROR) + if(it2==INTERP_KERNEL::NORM_ERROR) continue; - std::vector::iterator it3(std::find(ret.begin(),ret.end(),*it2)); + auto const it3(std::find(ret.begin(),ret.end(),it2)); if(it3==ret.end()) - ret.push_back(*it2); + ret.push_back(it2); } } return ret; @@ -2283,12 +2299,12 @@ bool MEDFileField1TSStruct::presenceOfCellDiscr(int& pos) const std::size_t refSz(std::numeric_limits::max()); bool ret(false); int i(0); - for(std::vector::const_iterator it=_already_checked.begin();it!=_already_checked.end();it++,i++) + for(auto it=_already_checked.begin();it!=_already_checked.end();it++,i++) { if((*it).getType()!=ON_NODES) { ret=true; - std::size_t sz((*it).getNumberOfItems()); + std::size_t const sz((*it).getNumberOfItems()); if(refSz>sz) { pos=i; refSz=sz; } } @@ -2305,11 +2321,11 @@ bool MEDFileField1TSStruct::presenceOfCellDiscr(int& pos) const bool MEDFileField1TSStruct::presenceOfPartialNodeDiscr(int& pos) const { int i(0); - for(std::vector::const_iterator it=_already_checked.begin();it!=_already_checked.end();it++,i++) + for(auto it=_already_checked.begin();it!=_already_checked.end();it++,i++) { if((*it).getType()==ON_NODES) { - std::size_t sz((*it).getNumberOfItems()); + std::size_t const sz((*it).getNumberOfItems()); if(sz==1) { if(!(*it)[0].getPflName().empty()) @@ -2334,7 +2350,7 @@ MEDFileFastCellSupportComparator::MEDFileFastCellSupportComparator(const MEDFile if(!m) throw INTERP_KERNEL::Exception("MEDFileFastCellSupportComparator constructor : null input mesh struct !"); _mesh_comp=const_cast(m); _mesh_comp->incrRef(); - int nbPts=ref->getNumberOfTS(); + int const nbPts=ref->getNumberOfTS(); _f1ts_cmps.resize(nbPts); for(int i=0;i)); + std::size_t const ret(_f1ts_cmps.capacity()*sizeof(MCAuto)); return ret; } @@ -2365,14 +2381,14 @@ std::vector MEDFileFastCellSupportComparator::getDirect const MEDFileMeshStruct *mst(_mesh_comp); if(mst) ret.push_back(mst); - for(std::vector< MCAuto >::const_iterator it=_f1ts_cmps.begin();it!=_f1ts_cmps.end();it++) - ret.push_back((const MEDFileField1TSStruct *)*it); + for(const auto & _f1ts_cmp : _f1ts_cmps) + ret.push_back((const MEDFileField1TSStruct *)_f1ts_cmp); return ret; } bool MEDFileFastCellSupportComparator::isEqual(const MEDFileAnyTypeFieldMultiTS *other) { - int nbPts=other->getNumberOfTS(); + int const nbPts=other->getNumberOfTS(); if(nbPts!=(int)_f1ts_cmps.size()) { std::ostringstream oss; oss << "MEDFileFastCellSupportComparator::isEqual : unexpected nb of time steps in input ! Should be " << _f1ts_cmps.size() << " it is in reality " << nbPts << " !"; @@ -2390,7 +2406,7 @@ bool MEDFileFastCellSupportComparator::isEqual(const MEDFileAnyTypeFieldMultiTS bool MEDFileFastCellSupportComparator::isCompatibleWithNodesDiscr(const MEDFileAnyTypeFieldMultiTS *other) { - int nbPts=other->getNumberOfTS(); + int const nbPts=other->getNumberOfTS(); if(nbPts!=(int)_f1ts_cmps.size()) { std::ostringstream oss; oss << "MEDFileFastCellSupportComparator::isCompatibleWithNodesDiscr : unexpected nb of time steps in input ! Should be " << _f1ts_cmps.size() << " it is in reality " << nbPts << " !"; diff --git a/src/MEDLoader/MEDFileFieldOverView.hxx b/src/MEDLoader/MEDFileFieldOverView.hxx index 466f73b72..d6b4a6275 100644 --- a/src/MEDLoader/MEDFileFieldOverView.hxx +++ b/src/MEDLoader/MEDFileFieldOverView.hxx @@ -21,15 +21,20 @@ #ifndef __MEDFILEFIELDOVERVIEW_HXX__ #define __MEDFILEFIELDOVERVIEW_HXX__ +#include "MCType.hxx" +#include "MEDCouplingMemArray.hxx" +#include "CellModel.hxx" #include "MEDLoaderDefines.hxx" #include "MCAuto.hxx" #include "MEDCouplingRefCountObject.hxx" #include "MEDCoupling1GTUMesh.hxx" -#include "NormalizedUnstructuredMesh.hxx" -#include "InterpKernelException.hxx" +#include "NormalizedGeometricTypes" +#include +#include +#include #include namespace MEDCoupling @@ -51,8 +56,8 @@ namespace MEDCoupling public: MEDLOADER_EXPORT static MEDFileMeshStruct *New(const MEDFileMesh *mesh); std::string getClassName() const override { return std::string("MEDFileMeshStruct"); } - std::size_t getHeapMemorySizeWithoutChildren() const; - std::vector getDirectChildrenWithNull() const; + std::size_t getHeapMemorySizeWithoutChildren() const override; + std::vector getDirectChildrenWithNull() const override; const MEDFileMesh *getTheMesh() const { return _mesh; } mcIdType getNumberOfNodes() const { return _nb_nodes; } bool doesManageGeoType(INTERP_KERNEL::NormalizedCellType t) const; @@ -76,8 +81,8 @@ namespace MEDCoupling class MEDMeshMultiLev : public RefCountObject { public: - std::size_t getHeapMemorySizeWithoutChildren() const; - std::vector getDirectChildrenWithNull() const; + std::size_t getHeapMemorySizeWithoutChildren() const override; + std::vector getDirectChildrenWithNull() const override; std::string getClassName() const override { return std::string("MEDMeshMultiLev"); } public: static MEDMeshMultiLev *New(const MEDFileMesh *m, const std::vector& gts, const std::vector& pfls, const std::vector& nbEntities); @@ -134,13 +139,13 @@ namespace MEDCoupling public: static MEDUMeshMultiLev *New(const MEDFileUMesh *m, const std::vector& levs); static MEDUMeshMultiLev *New(const MEDFileUMesh *m, const std::vector& gts, const std::vector& pfls, const std::vector& nbEntities); - void selectPartOfNodes(const DataArrayIdType *pflNodes); + void selectPartOfNodes(const DataArrayIdType *pflNodes) override; std::string getClassName() const override { return std::string("MEDUMeshMultiLev"); } - MEDMeshMultiLev *prepare() const; + MEDMeshMultiLev *prepare() const override; MEDUMeshMultiLev(const MEDStructuredMeshMultiLev& other, const MCAuto& part); MEDLOADER_EXPORT bool buildVTUArrays(DataArrayDouble *& coords, DataArrayByte *&types, DataArrayIdType *&cellLocations, DataArrayIdType *& cells, DataArrayIdType *&faceLocations, DataArrayIdType *&faces) const; protected: - void appendVertices(const DataArrayIdType *verticesToAdd, DataArrayIdType *nr); + void appendVertices(const DataArrayIdType *verticesToAdd, DataArrayIdType *nr) override; private: void reorderNodesIfNecessary(MCAuto& coords, DataArrayIdType *nodalConnVTK, DataArrayIdType *polyhedNodalConnVTK) const; private: @@ -156,7 +161,7 @@ namespace MEDCoupling class MEDStructuredMeshMultiLev : public MEDMeshMultiLev { public: - void selectPartOfNodes(const DataArrayIdType *pflNodes); + void selectPartOfNodes(const DataArrayIdType *pflNodes) override; virtual std::vector getNodeGridStructure() const = 0; std::string getClassName() const override { return std::string("MEDStructuredMeshMultiLev"); } protected: @@ -180,9 +185,9 @@ namespace MEDCoupling public: static MEDCMeshMultiLev *New(const MEDFileCMesh *m, const std::vector& levs); static MEDCMeshMultiLev *New(const MEDFileCMesh *m, const std::vector& gts, const std::vector& pfls, const std::vector& nbEntities); - std::vector getNodeGridStructure() const; + std::vector getNodeGridStructure() const override; std::string getClassName() const override { return std::string("MEDCMeshMultiLev"); } - MEDMeshMultiLev *prepare() const; + MEDMeshMultiLev *prepare() const override; MEDLOADER_EXPORT std::vector< DataArrayDouble * > buildVTUArrays(bool& isInternal) const; private: MEDCMeshMultiLev(const MEDCMeshMultiLev& other); @@ -198,8 +203,8 @@ namespace MEDCoupling static MEDCurveLinearMeshMultiLev *New(const MEDFileCurveLinearMesh *m, const std::vector& levs); static MEDCurveLinearMeshMultiLev *New(const MEDFileCurveLinearMesh *m, const std::vector& gts, const std::vector& pfls , const std::vector& nbEntities); std::string getClassName() const override { return std::string("MEDCurveLinearMeshMultiLev"); } - std::vector getNodeGridStructure() const; - MEDMeshMultiLev *prepare() const; + std::vector getNodeGridStructure() const override; + MEDMeshMultiLev *prepare() const override; MEDLOADER_EXPORT void buildVTUArrays(DataArrayDouble *&coords, std::vector& nodeStrct, bool& isInternal) const; private: MEDCurveLinearMeshMultiLev(const MEDCurveLinearMeshMultiLev& other); @@ -220,8 +225,8 @@ namespace MEDCoupling void checkWithMeshStructForGaussNE(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs); void checkWithMeshStructForGaussPT(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs); // - MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; - MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const; + MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const override; + MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const override; // const DataArrayIdType *getPfl(const MEDFileFieldGlobsReal *globs) const; INTERP_KERNEL::NormalizedCellType getGeo() const { return _geo_type; } @@ -254,8 +259,8 @@ namespace MEDCoupling void checkWithMeshStruct(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs); bool operator==(const MEDFileField1TSStructItem& other) const; std::string getClassName() const override { return std::string("MEDFileField1TSStructItem"); } - MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; - MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const; + MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const override; + MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const override; bool isEntityCell() const; bool isComputed() const { return _computed; } TypeOfField getType() const { return _type; } @@ -281,9 +286,9 @@ namespace MEDCoupling public: static MEDFileField1TSStruct *New(const MEDFileAnyTypeField1TS *ref, MEDFileMeshStruct *mst); void checkWithMeshStruct(MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs); - std::size_t getHeapMemorySizeWithoutChildren() const; + std::size_t getHeapMemorySizeWithoutChildren() const override; std::string getClassName() const override { return std::string("MEDFileField1TSStruct"); } - std::vector getDirectChildrenWithNull() const; + std::vector getDirectChildrenWithNull() const override; bool isEqualConsideringThePast(const MEDFileAnyTypeField1TS *other, const MEDFileMeshStruct *mst) const; bool isSupportSameAs(const MEDFileAnyTypeField1TS *other, const MEDFileMeshStruct *meshSt); bool isCompatibleWithNodesDiscr(const MEDFileAnyTypeField1TS *other, const MEDFileMeshStruct *meshSt); @@ -309,8 +314,8 @@ namespace MEDCoupling MEDLOADER_EXPORT std::vector getGeoTypesAt(int timeStepId, const MEDFileMesh *m) const; bool isEqual(const MEDFileAnyTypeFieldMultiTS *other); bool isCompatibleWithNodesDiscr(const MEDFileAnyTypeFieldMultiTS *other); - std::size_t getHeapMemorySizeWithoutChildren() const; - std::vector getDirectChildrenWithNull() const; + std::size_t getHeapMemorySizeWithoutChildren() const override; + std::vector getDirectChildrenWithNull() const override; private: MEDFileFastCellSupportComparator(const MEDFileMeshStruct *m, const MEDFileAnyTypeFieldMultiTS *ref); private: diff --git a/src/MEDLoader/MEDFileFieldVisitor.hxx b/src/MEDLoader/MEDFileFieldVisitor.hxx index 24fa4b9a5..64eddf036 100644 --- a/src/MEDLoader/MEDFileFieldVisitor.hxx +++ b/src/MEDLoader/MEDFileFieldVisitor.hxx @@ -21,7 +21,6 @@ #ifndef __MEDFILEFIELDVISITOR_HXX__ #define __MEDFILEFIELDVISITOR_HXX__ -#include "MEDLoaderDefines.hxx" #include "MEDFileField.hxx" namespace MEDCoupling @@ -48,7 +47,7 @@ namespace MEDCoupling virtual void endPerMeshPerTypeEntry(const MEDFileFieldPerMeshPerTypeCommon *pmpt) = 0; // virtual void newPerMeshPerTypePerDisc(const MEDFileFieldPerMeshPerTypePerDisc *pmptpd) = 0; - virtual ~MEDFileFieldVisitor() { } + virtual ~MEDFileFieldVisitor() = default; }; } diff --git a/src/MEDLoader/MEDFileJoint.cxx b/src/MEDLoader/MEDFileJoint.cxx index 678babc17..d9dfc0bb5 100644 --- a/src/MEDLoader/MEDFileJoint.cxx +++ b/src/MEDLoader/MEDFileJoint.cxx @@ -18,13 +18,28 @@ // #include "MEDFileJoint.hxx" +#include "MCAuto.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include "MCType.hxx" #include "MEDFileBasis.hxx" -#include "MEDLoader.hxx" +#include "MEDFileUtilities.hxx" #include "MEDLoaderBase.hxx" #include "MEDFileSafeCaller.txx" #include "CellModel.hxx" #include "InterpKernelAutoPtr.hxx" +#include "med.h" +#include "NormalizedGeometricTypes" +#include +#include +#include +#include "medfile.h" +#include +#include "medsubdomain.h" +#include +#include +#include +#include // From MEDLOader.cxx TU extern med_geometry_type typmai[MED_N_CELL_FIXED_GEO]; @@ -106,8 +121,8 @@ MEDFileJointCorrespondence *MEDFileJointCorrespondence::New() */ void MEDFileJointCorrespondence::write(const std::string& fileName, int mode, const std::string& localMeshName, const std::string& jointName, int order, int iteration) const { - med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode); - MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod); + med_access_mode const medmod=MEDFileUtilities::TraduceWriteMode(mode); + MEDFileUtilities::AutoFid const fid=MEDfileOpen(fileName.c_str(),medmod); std::ostringstream oss; oss << "MEDFileJointCorrespondence : error on attempt to write in file : \"" << fileName << "\""; MEDFileUtilities::CheckMEDCode((int)fid,fid,oss.str()); @@ -206,8 +221,8 @@ std::string MEDFileJointCorrespondence::simpleRepr() const const DataArrayIdType* tmp=getCorrespondence(); oss << "- Correspondence : <<"; - for(const mcIdType *it=tmp->begin();it!=tmp->end();it++) - oss<< *it << " "; + for(long const it : *tmp) + oss<< it << " "; } else { @@ -234,7 +249,7 @@ std::vector MEDFileJointOneStep::getDirectChildrenWithN MEDFileJointOneStep *MEDFileJointOneStep::New(int dt, int it) { - MEDFileJointOneStep* j = new MEDFileJointOneStep(); + auto* j = new MEDFileJointOneStep(); j->setOrder( dt ); j->setIteration( it ); return j; @@ -253,7 +268,7 @@ MEDFileJointOneStep *MEDFileJointOneStep::New(int dt, int it) MEDFileJointOneStep *MEDFileJointOneStep::New(const std::string& fileName, const std::string& mName, const std::string& jointName, int num) { MEDFileUtilities::CheckFileForRead(fileName); - MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(), MED_ACC_RDONLY); + MEDFileUtilities::AutoFid const fid=MEDfileOpen(fileName.c_str(), MED_ACC_RDONLY); return new MEDFileJointOneStep(fid, mName, jointName, num); } @@ -303,8 +318,8 @@ MEDFileJointOneStep::MEDFileJointOneStep(med_idt fid, const std::string& mName, */ void MEDFileJointOneStep::write(const std::string& fileName, int mode, const std::string& localMeshName, const std::string& jointName) const { - med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode); - MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod); + med_access_mode const medmod=MEDFileUtilities::TraduceWriteMode(mode); + MEDFileUtilities::AutoFid const fid=MEDfileOpen(fileName.c_str(),medmod); std::ostringstream oss; oss << "MEDFileJointOneStep : error on attempt to write in file : \"" << fileName << "\""; MEDFileUtilities::CheckMEDCode((int)fid,fid,oss.str()); if ( _correspondences.empty() ) @@ -314,9 +329,9 @@ void MEDFileJointOneStep::write(const std::string& fileName, int mode, const std void MEDFileJointOneStep::writeLL(med_idt fid, const std::string& localMeshName, const std::string& jointName) const { - for(std::vector< MCAuto >::const_iterator it=_correspondences.begin();it!=_correspondences.end();it++) + for(const auto & _correspondence : _correspondences) { - (*it)->writeLL(fid, localMeshName, jointName, getOrder(), getIteration()); + _correspondence->writeLL(fid, localMeshName, jointName, getOrder(), getIteration()); } } @@ -387,7 +402,7 @@ MEDFileJointOneStep *MEDFileJointOneStep::deepCopy() const { std::vector< MCAuto > correspondences(_correspondences.size()); std::size_t i=0; - for(std::vector< MCAuto >::const_iterator it=_correspondences.begin();it!=_correspondences.end();it++,i++) + for(auto it=_correspondences.begin();it!=_correspondences.end();it++,i++) if((const MEDFileJointCorrespondence *)*it) correspondences[i]=(*it)->deepCopy(); MCAuto ret= new MEDFileJointOneStep; @@ -411,9 +426,9 @@ std::string MEDFileJointOneStep::simpleRepr() const std::ostringstream oss; oss << "(*************************************)\n(* JOINT_ONE_STEP INFORMATION: *)\n(*************************************)\n"; oss << "- Number of the correspondences : <<" << _correspondences.size() << ">>\n"; - for(std::vector< MCAuto >::const_iterator it=_correspondences.begin();it!=_correspondences.end();it++) + for(const auto & _correspondence : _correspondences) { - oss << (*it)->simpleRepr(); + oss << _correspondence->simpleRepr(); } return oss.str(); } @@ -450,7 +465,7 @@ MEDFileJoint *MEDFileJoint::New() MEDFileJoint *MEDFileJoint::New(const std::string& fileName, const std::string& mName, int curJoint) { MEDFileUtilities::CheckFileForRead(fileName); - MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(), MED_ACC_RDONLY); + MEDFileUtilities::AutoFid const fid=MEDfileOpen(fileName.c_str(), MED_ACC_RDONLY); return new MEDFileJoint(fid,mName,curJoint); } @@ -461,7 +476,7 @@ MEDFileJoint *MEDFileJoint::New(med_idt fid, const std::string& mName, int curJo MEDFileJoint *MEDFileJoint::New(const std::string& jointName, const std::string& locMeshName, const std::string& remoteMeshName, int remoteMeshNum) { - MEDFileJoint* j = new MEDFileJoint(); + auto* j = new MEDFileJoint(); j->setJointName( jointName ); j->setLocalMeshName( locMeshName ); j->setRemoteMeshName( remoteMeshName ); @@ -470,8 +485,7 @@ MEDFileJoint *MEDFileJoint::New(const std::string& jointName, const std::string& } MEDFileJoint::MEDFileJoint() -{ -} += default; /*! * Returns a new MEDFileJoint holding the mesh data that has been read from a given MED @@ -507,8 +521,8 @@ void MEDFileJoint::writeLL(med_idt fid) const // if ( _loc_mesh_name.empty() ) // throw INTERP_KERNEL::Exception("MEDFileJoint::write : name of a local mesh not defined!"); MEDFILESAFECALLERWR0(MEDsubdomainJointCr,(fid,getLocalMeshName().c_str(),getJointName().c_str(),getDescription().c_str(),getDomainNumber(),getRemoteMeshName().c_str())); - for(std::vector< MCAuto >::const_iterator it=_joint.begin();it!=_joint.end();it++) - (*it)->writeLL(fid, getLocalMeshName(),getJointName()); + for(const auto & it : _joint) + it->writeLL(fid, getLocalMeshName(),getJointName()); } void MEDFileJoint::pushStep(MEDFileJointOneStep* step) @@ -553,7 +567,7 @@ bool MEDFileJoint::isEqual(const MEDFileJoint *other) const return false; if(_domain_number!=other->_domain_number) return false; - int nbTS(getNumberOfSteps()); + int const nbTS(getNumberOfSteps()); if(nbTS!=other->getNumberOfSteps()) return false; std::vector found(nbTS,false); @@ -578,7 +592,7 @@ MEDFileJoint *MEDFileJoint::deepCopy() const { std::vector< MCAuto > joint(_joint.size()); std::size_t i=0; - for(std::vector< MCAuto >::const_iterator it=_joint.begin();it!=_joint.end();it++,i++) + for(auto it=_joint.begin();it!=_joint.end();it++,i++) if((const MEDFileJointOneStep *)*it) joint[i]=(*it)->deepCopy(); MCAuto ret=new MEDFileJoint(*this); @@ -594,11 +608,11 @@ MEDFileJoint *MEDFileJoint::shallowCpy() const bool MEDFileJoint::changeJointNames(const std::vector< std::pair >& modifTab) { - for(std::vector< std::pair >::const_iterator it=modifTab.begin();it!=modifTab.end();it++) + for(const auto & it : modifTab) { - if((*it).first==_joint_name) + if(it.first==_joint_name) { - _joint_name=(*it).second; + _joint_name=it.second; return true; } } @@ -619,9 +633,9 @@ std::string MEDFileJoint::simpleRepr() const oss << "- Description : <<" << getDescription() << ">>\n"; oss << "- Joint name : <<" << getJointName() << ">>\n"; oss << "- Domain number : " << getDomainNumber() << "\n"; - for(std::vector< MCAuto >::const_iterator it=_joint.begin();it!=_joint.end();it++) + for(const auto & it : _joint) { - oss << (*it)->simpleRepr(); + oss << it->simpleRepr(); } return oss.str(); } @@ -634,7 +648,7 @@ MEDFileJoints *MEDFileJoints::New() MEDFileJoints *MEDFileJoints::New(const std::string& fileName, const std::string& meshName) { MEDFileUtilities::CheckFileForRead(fileName); - MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(), MED_ACC_RDONLY); + MEDFileUtilities::AutoFid const fid=MEDfileOpen(fileName.c_str(), MED_ACC_RDONLY); return new MEDFileJoints( fid, meshName ); } @@ -645,8 +659,8 @@ MEDFileJoints *MEDFileJoints::New(med_idt fid, const std::string& meshName) void MEDFileJoints::writeLL(med_idt fid) const { - for(std::vector< MCAuto >::const_iterator it=_joints.begin();it!=_joints.end();it++) - (*it)->writeLL(fid); + for(const auto & _joint : _joints) + _joint->writeLL(fid); } std::string MEDFileJoints::getMeshName() const @@ -680,7 +694,7 @@ MEDFileJoint *MEDFileJoints::getJointAtPos(int i) const MEDFileJoint *MEDFileJoints::getJointWithName(const std::string& jname) const { std::vector js=getJointsNames(); - std::vector::iterator it=std::find(js.begin(),js.end(),jname); + auto const it=std::find(js.begin(),js.end(),jname); if(it==js.end()) { std::ostringstream oss; oss << "MEDFileJoints::getJointWithName : Joint \"" << jname << "\" does not exist in this ! Existing are : "; @@ -694,7 +708,7 @@ std::vector MEDFileJoints::getJointsNames() const { std::vector ret(_joints.size()); int i=0; - for(std::vector< MCAuto >::const_iterator it=_joints.begin();it!=_joints.end();it++,i++) + for(auto it=_joints.begin();it!=_joints.end();it++,i++) { const MEDFileJoint *f=(*it); if(f) @@ -713,9 +727,9 @@ std::vector MEDFileJoints::getJointsNames() const bool MEDFileJoints::changeJointNames(const std::vector< std::pair >& modifTab) { bool ret=false; - for(std::vector< MCAuto >::iterator it=_joints.begin();it!=_joints.end();it++) + for(auto & _joint : _joints) { - MEDFileJoint *cur(*it); + MEDFileJoint *cur(_joint); if(cur) ret=cur->changeJointNames(modifTab) || ret; } @@ -760,12 +774,11 @@ void MEDFileJoints::destroyJointAtPos(int i) } MEDFileJoints::MEDFileJoints() -{ -} += default; MEDFileJoints::MEDFileJoints(med_idt fid, const std::string& meshName) { - med_int num_joint=MEDnSubdomainJoint(fid, meshName.c_str() ); + med_int const num_joint=MEDnSubdomainJoint(fid, meshName.c_str() ); for(int i = 1; i <= num_joint; i++) _joints.push_back(MEDFileJoint::New(fid,meshName,i)); } @@ -774,7 +787,7 @@ MEDFileJoints *MEDFileJoints::deepCopy() const { std::vector< MCAuto > joints(_joints.size()); std::size_t i=0; - for(std::vector< MCAuto >::const_iterator it=_joints.begin();it!=_joints.end();it++,i++) + for(auto it=_joints.begin();it!=_joints.end();it++,i++) if((const MEDFileJoint *)*it) joints[i]=(*it)->deepCopy(); MCAuto ret=MEDFileJoints::New(); @@ -790,8 +803,8 @@ std::size_t MEDFileJoints::getHeapMemorySizeWithoutChildren() const std::vector MEDFileJoints::getDirectChildrenWithNull() const { std::vector ret; - for(std::vector< MCAuto >::const_iterator it=_joints.begin();it!=_joints.end();it++) - ret.push_back((const MEDFileJoint *)*it); + for(const auto & _joint : _joints) + ret.push_back((const MEDFileJoint *)_joint); return ret; } @@ -805,13 +818,13 @@ std::string MEDFileJoints::simpleRepr() const void MEDFileJoints::simpleReprWithoutHeader(std::ostream& oss) const { - int nbOfJoints=getNumberOfJoints(); + int const nbOfJoints=getNumberOfJoints(); oss << "There are " << nbOfJoints << " joints with the following names : \n"; std::vector jns=getJointsNames(); for(int i=0;i >::const_iterator it=_joints.begin();it!=_joints.end();it++) + for(const auto & _joint : _joints) { - oss << (*it)->simpleRepr(); + oss << _joint->simpleRepr(); } } diff --git a/src/MEDLoader/MEDFileJoint.hxx b/src/MEDLoader/MEDFileJoint.hxx index 29882107f..fe81ecd60 100644 --- a/src/MEDLoader/MEDFileJoint.hxx +++ b/src/MEDLoader/MEDFileJoint.hxx @@ -20,12 +20,19 @@ #ifndef __MEDFILEJOINT_HXX__ #define __MEDFILEJOINT_HXX__ +#include "MEDCouplingRefCountObject.hxx" +#include "MEDFileUtilities.hxx" +#include "MCType.hxx" #include "MEDLoaderDefines.hxx" -#include "MEDFileUtilities.txx" -#include "MEDCouplingMemArray.hxx" #include "MCAuto.hxx" #include "NormalizedGeometricTypes" +#include +#include +#include +#include "med.h" +#include +#include namespace MEDCoupling { @@ -44,8 +51,8 @@ public: INTERP_KERNEL::NormalizedCellType loc_geo_type, INTERP_KERNEL::NormalizedCellType rem_geo_type); MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileJointCorrespondence"); } - MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; - MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const; + MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const override; + MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const override; MEDLOADER_EXPORT MEDFileJointCorrespondence *deepCopy() const; MEDLOADER_EXPORT MEDFileJointCorrespondence *shallowCpy() const; MEDLOADER_EXPORT bool isEqual(const MEDFileJointCorrespondence *other) const; @@ -84,8 +91,8 @@ public: MEDLOADER_EXPORT static MEDFileJointOneStep *New(const std::string& fileName, const std::string& mName, const std::string& jointName, int number=1); MEDLOADER_EXPORT static MEDFileJointOneStep *New(med_idt fid, const std::string& mName, const std::string& jointName, int number=1); MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileJointOneStep"); } - MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; - MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const; + MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const override; + MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const override; MEDLOADER_EXPORT MEDFileJointOneStep *deepCopy() const; MEDLOADER_EXPORT MEDFileJointOneStep *shallowCpy() const; MEDLOADER_EXPORT bool isEqual(const MEDFileJointOneStep *other) const; @@ -125,8 +132,8 @@ public: MEDLOADER_EXPORT static MEDFileJoint *New(med_idt fid, const std::string& mName, int num); MEDLOADER_EXPORT static MEDFileJoint *New(const std::string& jointName, const std::string& locMeshName, const std::string& remoteMeshName, int remoteMeshNum ); MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileJoint"); } - MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; - MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const; + MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const override; + MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const override; MEDLOADER_EXPORT MEDFileJoint *deepCopy() const; MEDLOADER_EXPORT MEDFileJoint *shallowCpy() const; MEDLOADER_EXPORT bool isEqual(const MEDFileJoint *other) const; @@ -145,7 +152,7 @@ public: MEDLOADER_EXPORT int getNumberOfSteps() const; MEDLOADER_EXPORT MEDFileJointOneStep *getStepAtPos(int i) const; - MEDLOADER_EXPORT void writeLL(med_idt fid) const; + MEDLOADER_EXPORT void writeLL(med_idt fid) const override; MEDLOADER_EXPORT std::string simpleRepr() const; private: @@ -171,11 +178,11 @@ public: MEDLOADER_EXPORT static MEDFileJoints *New(med_idt fid, const std::string& meshName); MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileJoints"); } MEDLOADER_EXPORT MEDFileJoints *deepCopy() const; - MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; - MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const; + MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const override; + MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const override; MEDLOADER_EXPORT std::string simpleRepr() const; MEDLOADER_EXPORT void simpleReprWithoutHeader(std::ostream& oss) const; - MEDLOADER_EXPORT void writeLL(med_idt fid) const; + MEDLOADER_EXPORT void writeLL(med_idt fid) const override; MEDLOADER_EXPORT std::string getMeshName() const; MEDLOADER_EXPORT int getNumberOfJoints() const; MEDLOADER_EXPORT MEDFileJoint *getJointAtPos(int i) const; @@ -188,7 +195,7 @@ public: MEDLOADER_EXPORT void setJointAtPos(int i, MEDFileJoint *joint); MEDLOADER_EXPORT void destroyJointAtPos(int i); private: - ~MEDFileJoints() { } + ~MEDFileJoints() override = default; MEDFileJoints(); MEDFileJoints(med_idt fid, const std::string& meshName); private: diff --git a/src/MEDLoader/MEDFileMesh.cxx b/src/MEDLoader/MEDFileMesh.cxx index 57a21ceb1..72dea91d7 100644 --- a/src/MEDLoader/MEDFileMesh.cxx +++ b/src/MEDLoader/MEDFileMesh.cxx @@ -19,25 +19,58 @@ // Author : Anthony Geay (CEA/DEN) #include "MEDFileMesh.hxx" +#include "MEDCouplingMemArray.hxx" +#include "MCType.hxx" +#include "MEDCouplingMesh.hxx" +#include "MCAuto.hxx" +#include "MEDFileEquivalence.hxx" +#include "MCIdType.hxx" +#include "MEDCouplingPartDefinition.hxx" +#include "CellModel.hxx" +#include "MEDCouplingPointSet.hxx" +#include "MEDCouplingStructuredMesh.hxx" +#include "MEDFileBasis.hxx" +#include "MEDCouplingCurveLinearMesh.hxx" +#include "InterpKernelException.hxx" +#include "MEDCouplingRefCountObject.hxx" #include "MEDFileFieldOverView.hxx" #include "MEDFileField.hxx" +#include "MEDFileMeshReadSelector.hxx" +#include "MEDFileUtilities.hxx" +#include "MEDFileMeshLL.hxx" +#include "MEDFileJoint.hxx" #include "MEDLoader.hxx" -#include "MEDLoaderNS.hxx" #include "MEDFileSafeCaller.txx" #include "MEDLoaderBase.hxx" #include "CrackAlgo.hxx" +#include "MEDLoaderNS.hxx" #include "MEDCouplingUMesh.hxx" #include "MEDCouplingMappedExtrudedMesh.hxx" #include "MEDCouplingMemArray.txx" +// #include "MEDFileMeshElt.hxx" #include "InterpKernelAutoPtr.hxx" +#include "med.h" +#include "NormalizedGeometricTypes" +#include "MEDLoaderTraits.hxx" +#include "medfile.h" +#include "medmesh.h" +#include #include +#include +#include #include #include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include // From MEDLOader.cxx TU extern med_geometry_type typmai[MED_N_CELL_FIXED_GEO]; @@ -57,14 +90,14 @@ MEDFileMesh::MEDFileMesh():_order(-1),_iteration(-1),_time(0.),_univ_wr_status(t std::size_t MEDFileMesh::getHeapMemorySizeWithoutChildren() const { std::size_t ret(_dt_unit.capacity()+_name.capacity()+_univ_name.capacity()+_desc_name.capacity()); - for(std::map >::const_iterator it=_groups.begin();it!=_groups.end();it++) + for(const auto & _group : _groups) { - ret+=(*it).first.capacity()+(*it).second.capacity()*sizeof(std::string); - for(std::vector::const_iterator it2=(*it).second.begin();it2!=(*it).second.end();it2++) - ret+=(*it2).capacity(); + ret+=_group.first.capacity()+_group.second.capacity()*sizeof(std::string); + for(const auto & it2 : _group.second) + ret+=it2.capacity(); } - for(std::map::const_iterator it=_families.begin();it!=_families.end();it++) - ret+=(*it).first.capacity()+sizeof(mcIdType); + for(const auto & _familie : _families) + ret+=_familie.first.capacity()+sizeof(mcIdType); return ret; } @@ -87,13 +120,13 @@ std::vector MEDFileMesh::getDirectChildrenWithNull() co */ MEDFileMesh *MEDFileMesh::New(const std::string& fileName, MEDFileMeshReadSelector *mrs) { - MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + MEDFileUtilities::AutoFid const fid(OpenMEDFileForRead(fileName)); return New(fid,mrs); } MEDFileMesh *MEDFileMesh::New(med_idt fid, MEDFileMeshReadSelector *mrs) { - std::vector ms(MEDLoaderNS::getMeshNamesFid(fid)); + std::vector ms((MEDLoaderNS::getMeshNamesFid(fid))); if(ms.empty()) { std::ostringstream oss; oss << "MEDFileMesh::New : no meshes in file \"" << FileNameFromFID(fid) << "\" !"; @@ -151,11 +184,11 @@ MEDFileMesh *MEDFileMesh::New(med_idt fid, MEDFileMeshReadSelector *mrs) */ MEDFileMesh *MEDFileMesh::New(const std::string& fileName, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs, MEDFileJoints* joints) { - MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + MEDFileUtilities::AutoFid const fid(OpenMEDFileForRead(fileName)); return New(fid,mName,dt,it,mrs,joints); } -MEDFileMesh *MEDFileMesh::New(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs, MEDFileJoints* joints) +MEDFileMesh *MEDFileMesh::New(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs, MEDFileJoints* /*joints*/) { MEDCoupling::MEDCouplingMeshType meshType; int dummy0,dummy1; @@ -274,11 +307,11 @@ void MEDFileMesh::clearNonDiscrAttributes() const bool MEDFileMesh::changeNames(const std::vector< std::pair >& modifTab) { - for(std::vector< std::pair >::const_iterator it=modifTab.begin();it!=modifTab.end();it++) + for(const auto & it : modifTab) { - if((*it).first==_name) + if(it.first==_name) { - _name=(*it).second; + _name=it.second; return true; } } @@ -342,8 +375,8 @@ void MEDFileMesh::clearFamGrpMaps() */ std::vector MEDFileMesh::getFamiliesOnGroup(const std::string& name) const { - std::string oname(name); - std::map >::const_iterator it=_groups.find(oname); + std::string const oname(name); + auto const it=_groups.find(oname); if(it==_groups.end()) { std::vector grps=getGroupsNames(); @@ -363,12 +396,12 @@ std::vector MEDFileMesh::getFamiliesOnGroup(const std::string& name std::vector MEDFileMesh::getFamiliesOnGroups(const std::vector& grps) const { std::set fams; - for(std::vector::const_iterator it=grps.begin();it!=grps.end();it++) + for(const auto & grp : grps) { - std::map >::const_iterator it2=_groups.find(*it); + auto const it2=_groups.find(grp); if(it2==_groups.end()) { - std::ostringstream oss; oss << "No such group in mesh \"" << _name << "\" : " << *it; + std::ostringstream oss; oss << "No such group in mesh \"" << _name << "\" : " << grp; std::vector grps2=getGroupsNames(); oss << "\" !\nAvailable groups are :"; std::copy(grps2.begin(),grps2.end(),std::ostream_iterator(oss," ")); throw INTERP_KERNEL::Exception(oss.str().c_str()); @@ -387,8 +420,8 @@ std::vector MEDFileMesh::getFamiliesOnGroups(const std::vector MEDFileMesh::getFamiliesIdsOnGroup(const std::string& name) const { - std::string oname(name); - std::map >::const_iterator it=_groups.find(oname); + std::string const oname(name); + auto const it=_groups.find(oname); std::vector grps=getGroupsNames(); if(it==_groups.end()) { @@ -408,13 +441,13 @@ std::vector MEDFileMesh::getFamiliesIdsOnGroup(const std::string& name */ void MEDFileMesh::setFamiliesOnGroup(const std::string& name, const std::vector& fams) { - std::string oname(name); + std::string const oname(name); _groups[oname]=fams; - for(std::vector::const_iterator it1=fams.begin();it1!=fams.end();it1++) + for(const auto & fam : fams) { - std::map::iterator it2=_families.find(*it1); + auto const it2=_families.find(fam); if(it2==_families.end()) - _families[*it1]=0; + _families[fam]=0; } } @@ -428,12 +461,12 @@ void MEDFileMesh::setFamiliesOnGroup(const std::string& name, const std::vector< */ void MEDFileMesh::setFamiliesIdsOnGroup(const std::string& name, const std::vector& famIds) { - std::string oname(name); + std::string const oname(name); std::vector fams(famIds.size()); int i=0; - for(std::vector::const_iterator it1=famIds.begin();it1!=famIds.end();it1++,i++) + for(auto it1=famIds.begin();it1!=famIds.end();it1++,i++) { - std::string name2=getFamilyNameGivenId(*it1); + std::string const name2=getFamilyNameGivenId(*it1); fams[i]=name2; } _groups[oname]=fams; @@ -447,12 +480,12 @@ void MEDFileMesh::setFamiliesIdsOnGroup(const std::string& name, const std::vect std::vector MEDFileMesh::getGroupsOnFamily(const std::string& name) const { std::vector ret; - for(std::map >::const_iterator it1=_groups.begin();it1!=_groups.end();it1++) + for(const auto & _group : _groups) { - for(std::vector::const_iterator it2=(*it1).second.begin();it2!=(*it1).second.end();it2++) + for(auto it2=_group.second.begin();it2!=_group.second.end();it2++) if((*it2)==name) { - ret.push_back((*it1).first); + ret.push_back(_group.first); break; } } @@ -467,7 +500,7 @@ std::vector MEDFileMesh::getGroupsOnFamily(const std::string& name) */ void MEDFileMesh::setGroupsOnFamily(const std::string& famName, const std::vector& grps) { - std::string fName(famName); + std::string const fName(famName); const std::map::const_iterator it=_families.find(fName); if(it==_families.end()) { @@ -476,15 +509,15 @@ void MEDFileMesh::setGroupsOnFamily(const std::string& famName, const std::vecto std::copy(fams.begin(),fams.end(),std::ostream_iterator(oss," ")); throw INTERP_KERNEL::Exception(oss.str().c_str()); } - for(std::vector::const_iterator it3=grps.begin();it3!=grps.end();it3++) + for(const auto & grp : grps) { - std::map< std::string, std::vector >::iterator it2=_groups.find(*it3); + auto const it2=_groups.find(grp); if(it2!=_groups.end()) (*it2).second.push_back(fName); else { - std::vector grps2(1,fName); - _groups[*it3]=grps2; + std::vector const grps2(1,fName); + _groups[grp]=grps2; } } } @@ -497,7 +530,7 @@ std::vector MEDFileMesh::getGroupsNames() const { std::vector ret(_groups.size()); int i=0; - for(std::map >::const_iterator it=_groups.begin();it!=_groups.end();it++,i++) + for(auto it=_groups.begin();it!=_groups.end();it++,i++) ret[i]=(*it).first; return ret; } @@ -510,7 +543,7 @@ std::vector MEDFileMesh::getFamiliesNames() const { std::vector ret(_families.size()); int i=0; - for(std::map::const_iterator it=_families.begin();it!=_families.end();it++,i++) + for(auto it=_families.begin();it!=_families.end();it++,i++) ret[i]=(*it).first; return ret; } @@ -537,7 +570,7 @@ std::vector MEDFileMesh::getFamiliesNamesWithFilePointOfView() cons std::vector MEDFileMesh::getGroupsOnSpecifiedLev(int meshDimRelToMaxExt) const { std::vector ret; - std::vector allGrps(getGroupsNames()); + std::vector const allGrps(getGroupsNames()); const DataArrayIdType *arr=getFamilyFieldAtLevel(meshDimRelToMaxExt); if(!arr) return ret; @@ -548,7 +581,7 @@ std::vector MEDFileMesh::getGroupsOnSpecifiedLev(int meshDimRelToMa for(auto it2 : it.second) { auto it3 = _families.find( it2 ); - mcIdType famIdToTest = (*it3).second; + mcIdType const famIdToTest = (*it3).second; if( famIdsInUse.find(famIdToTest) != famIdsInUse.end() ) { ret.push_back( it.first ); @@ -566,7 +599,7 @@ std::vector MEDFileMesh::getGroupsOnSpecifiedLev(int meshDimRelToMa */ std::vector MEDFileMesh::getGrpNonEmptyLevelsExt(const std::string& grp) const { - std::vector fams(getFamiliesOnGroup(grp)); + std::vector const fams(getFamiliesOnGroup(grp)); return getFamsNonEmptyLevelsExt(fams); } @@ -578,7 +611,7 @@ std::vector MEDFileMesh::getGrpNonEmptyLevelsExt(const std::string& gr */ std::vector MEDFileMesh::getGrpsNonEmptyLevels(const std::vector& grps) const { - std::vector fams(getFamiliesOnGroups(grps)); + std::vector const fams(getFamiliesOnGroups(grps)); return getFamsNonEmptyLevels(fams); } @@ -589,7 +622,7 @@ std::vector MEDFileMesh::getGrpsNonEmptyLevels(const std::vector MEDFileMesh::getGrpsNonEmptyLevelsExt(const std::vector& grps) const { - std::vector fams(getFamiliesOnGroups(grps)); + std::vector const fams(getFamiliesOnGroups(grps)); return getFamsNonEmptyLevelsExt(fams); } @@ -601,7 +634,7 @@ std::vector MEDFileMesh::getGrpsNonEmptyLevelsExt(const std::vector MEDFileMesh::getGrpNonEmptyLevels(const std::string& grp) const { - std::vector fams(getFamiliesOnGroup(grp)); + std::vector const fams(getFamiliesOnGroup(grp)); return getFamsNonEmptyLevels(fams); } @@ -613,7 +646,7 @@ std::vector MEDFileMesh::getGrpNonEmptyLevels(const std::string& grp) */ std::vector MEDFileMesh::getFamNonEmptyLevels(const std::string& fam) const { - std::vector fams(1,std::string(fam)); + std::vector const fams(1,std::string(fam)); return getFamsNonEmptyLevels(fams); } @@ -624,7 +657,7 @@ std::vector MEDFileMesh::getFamNonEmptyLevels(const std::string& fam) */ std::vector MEDFileMesh::getFamNonEmptyLevelsExt(const std::string& fam) const { - std::vector fams(1,std::string(fam)); + std::vector const fams(1,std::string(fam)); return getFamsNonEmptyLevelsExt(fams); } @@ -653,7 +686,7 @@ void MEDFileMesh::assignFamilyNameWithGroupName() } newFams[grps[0]]=(*it).second; std::vector& grps2=groups[grps[0]]; - std::size_t pos=std::distance(grps2.begin(),std::find(grps2.begin(),grps2.end(),(*it).first)); + std::size_t const pos=std::distance(grps2.begin(),std::find(grps2.begin(),grps2.end(),(*it).first)); grps2[pos]=grps[0]; } else @@ -693,7 +726,7 @@ std::vector MEDFileMesh::removeEmptyGroups() void MEDFileMesh::removeGroupAtLevel(int meshDimRelToMaxExt, const std::string& name) { - std::map >::iterator it(_groups.find(name)); + auto const it(_groups.find(name)); std::vector grps(getGroupsNames()); if(it==_groups.end()) { @@ -702,7 +735,7 @@ void MEDFileMesh::removeGroupAtLevel(int meshDimRelToMaxExt, const std::string& throw INTERP_KERNEL::Exception(oss.str().c_str()); } const std::vector &famsOnGrp((*it).second); - std::vector famIds(getFamiliesIdsOnGroup(name)); + std::vector const famIds(getFamiliesIdsOnGroup(name)); const DataArrayIdType *famArr(getFamilyFieldAtLevel(meshDimRelToMaxExt)); if(!famArr) return ; @@ -712,10 +745,10 @@ void MEDFileMesh::removeGroupAtLevel(int meshDimRelToMaxExt, const std::string& if(idsToKill->empty()) return ; std::vector newFamsOnGrp; - for(std::vector::const_iterator itt=famsOnGrp.begin();itt!=famsOnGrp.end();itt++) + for(const auto & itt : famsOnGrp) { - if(!idsToKill->presenceOfValue(getFamilyId(*itt))) - newFamsOnGrp.push_back(*itt); + if(!idsToKill->presenceOfValue(getFamilyId(itt))) + newFamsOnGrp.push_back(itt); } (*it).second=newFamsOnGrp; } @@ -727,7 +760,7 @@ void MEDFileMesh::removeGroupAtLevel(int meshDimRelToMaxExt, const std::string& */ void MEDFileMesh::removeGroup(const std::string& name) { - std::map >::iterator it=_groups.find(name); + auto const it=_groups.find(name); std::vector grps(getGroupsNames()); if(it==_groups.end()) { @@ -745,8 +778,8 @@ void MEDFileMesh::removeGroup(const std::string& name) */ void MEDFileMesh::removeFamily(const std::string& name) { - std::string oname(name); - std::map::iterator it=_families.find(oname); + std::string const oname(name); + auto const it=_families.find(oname); std::vector fams=getFamiliesNames(); if(it==_families.end()) { @@ -755,10 +788,10 @@ void MEDFileMesh::removeFamily(const std::string& name) throw INTERP_KERNEL::Exception(oss.str().c_str()); } _families.erase(it); - for(std::map >::iterator it3=_groups.begin();it3!=_groups.end();it3++) + for(auto & _group : _groups) { - std::vector& v=(*it3).second; - std::vector::iterator it4=std::find(v.begin(),v.end(),oname); + std::vector& v=_group.second; + auto const it4=std::find(v.begin(),v.end(),oname); if(it4!=v.end()) v.erase(it4); } @@ -805,12 +838,12 @@ std::vector MEDFileMesh::removeOrphanFamilies() else { ret.push_back((*it).first); - std::vector grpsOnEraseFam=getGroupsOnFamily((*it).first); - for(std::vector::const_iterator it2=grpsOnEraseFam.begin();it2!=grpsOnEraseFam.end();it2++) + std::vector const grpsOnEraseFam=getGroupsOnFamily((*it).first); + for(const auto & it2 : grpsOnEraseFam) { - std::map >::iterator it3=grps.find(*it2);//it3!=grps.empty() thanks to copy + auto const it3=grps.find(it2);//it3!=grps.empty() thanks to copy std::vector& famv=(*it3).second; - std::vector::iterator it4=std::find(famv.begin(),famv.end(),(*it).first);//it4!=famv.end() thanks to copy + auto const it4=std::find(famv.begin(),famv.end(),(*it).first);//it4!=famv.end() thanks to copy famv.erase(it4); } } @@ -829,16 +862,16 @@ std::vector MEDFileMesh::removeOrphanFamilies() */ void MEDFileMesh::removeFamiliesReferedByNoGroups() { - std::map fams; + std::map const fams; std::set sfams; for(std::map::const_iterator it=_families.begin();it!=_families.end();it++) sfams.insert((*it).first); for(std::map >::const_iterator it0=_groups.begin();it0!=_groups.end();it0++) - for(std::vector::const_iterator it1=(*it0).second.begin();it1!=(*it0).second.end();it1++) - sfams.erase(*it1); - for(std::set::const_iterator it=sfams.begin();it!=sfams.end();it++) - if(*it!=DFT_FAM_NAME) - _families.erase(*it); + for(const auto & it1 : (*it0).second) + sfams.erase(it1); + for(const auto & sfam : sfams) + if(sfam!=DFT_FAM_NAME) + _families.erase(sfam); } /*! @@ -855,7 +888,7 @@ void MEDFileMesh::rearrangeFamilies() checkOrphanFamilyZero(); removeFamiliesReferedByNoGroups(); // - std::vector levels(getNonEmptyLevelsExt()); + std::vector const levels(getNonEmptyLevelsExt()); std::set idsRefed; for(std::map::const_iterator it=_families.begin();it!=_families.end();it++) { @@ -869,25 +902,25 @@ void MEDFileMesh::rearrangeFamilies() } } } - for(std::vector::const_iterator it=levels.begin();it!=levels.end();it++) + for(int const level : levels) { - const DataArrayIdType *fams(0); + const DataArrayIdType *fams(nullptr); try { - fams=getFamilyFieldAtLevel(*it); + fams=getFamilyFieldAtLevel(level); } catch(INTERP_KERNEL::Exception& ) { } if(!fams) continue; std::vector v(fams->getNumberOfTuples(),false); - for(std::set::const_iterator pt=idsRefed.begin();pt!=idsRefed.end();pt++) - fams->switchOnTupleEqualTo(*pt,v); + for(long const pt : idsRefed) + fams->switchOnTupleEqualTo(pt,v); MCAuto unfetchedIds(DataArrayIdType::BuildListOfSwitchedOff(v)); if(!unfetchedIds->empty()) { MCAuto newFams(fams->deepCopy()); newFams->setPartOfValuesSimple3(0,unfetchedIds->begin(),unfetchedIds->end(),0,1,1); - setFamilyFieldArr(*it,newFams); + setFamilyFieldArr(level,newFams); } } removeOrphanFamilies(); @@ -908,13 +941,13 @@ void MEDFileMesh::zipFamilies() for(auto fam : _families) { std::vector grps( this->getGroupsOnFamily( fam.first ) ); - std::set sgrps(grps.begin(),grps.end()); + std::set const sgrps(grps.begin(),grps.end()); setOfFamilies[sgrps].push_back(fam.first); } // std::map > newGroups(_groups); std::map newFams(_families); - std::vector levels(getNonEmptyLevelsExt()); + std::vector const levels(getNonEmptyLevelsExt()); std::map > famIdsToSubstitute; // iterate on all different set of groups std::set familiesToKill; @@ -930,7 +963,7 @@ void MEDFileMesh::zipFamilies() { if( setOfCommonGrp.second.size()<=1 ) continue; - std::string newFamName(setOfCommonGrp.second[0]); + std::string const newFamName(setOfCommonGrp.second[0]); auto newFamID(_families[newFamName]); for(auto grpToBeModified : setOfCommonGrp.first) { @@ -952,12 +985,12 @@ void MEDFileMesh::zipFamilies() // apply modifications in datastructure for(auto famIdsSubstSession : famIdsToSubstitute) { - for(std::vector::const_iterator it=levels.begin();it!=levels.end();it++) + for(int const level : levels) { DataArrayIdType *fams(nullptr); try { - fams=getFamilyFieldAtLevel(*it); + fams=getFamilyFieldAtLevel(level); } catch(INTERP_KERNEL::Exception& ) { } if(!fams) @@ -975,11 +1008,11 @@ void MEDFileMesh::zipFamilies() */ void MEDFileMesh::checkOrphanFamilyZero() const { - for(std::map >::const_iterator it=_groups.begin();it!=_groups.end();it++) + for(const auto & _group : _groups) { - if(std::find((*it).second.begin(),(*it).second.end(),DFT_FAM_NAME)!=(*it).second.end()) + if(std::find(_group.second.begin(),_group.second.end(),DFT_FAM_NAME)!=_group.second.end()) { - std::ostringstream oss; oss << "MEDFileMesh::rearrangeFamilies : Groups \"" << (*it).first << "\" is lying on family \"" << DFT_FAM_NAME << "\" !"; + std::ostringstream oss; oss << "MEDFileMesh::rearrangeFamilies : Groups \"" << _group.first << "\" is lying on family \"" << DFT_FAM_NAME << "\" !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } } @@ -994,8 +1027,8 @@ void MEDFileMesh::checkOrphanFamilyZero() const */ void MEDFileMesh::changeGroupName(const std::string& oldName, const std::string& newName) { - std::string oname(oldName); - std::map >::iterator it=_groups.find(oname); + std::string const oname(oldName); + auto const it=_groups.find(oname); std::vector grps=getGroupsNames(); if(it==_groups.end()) { @@ -1003,14 +1036,14 @@ void MEDFileMesh::changeGroupName(const std::string& oldName, const std::string& std::copy(grps.begin(),grps.end(),std::ostream_iterator(oss," ")); throw INTERP_KERNEL::Exception(oss.str().c_str()); } - std::string nname(newName); - std::map >::iterator it2=_groups.find(nname); + std::string const nname(newName); + auto const it2=_groups.find(nname); if(it2!=_groups.end()) { std::ostringstream oss; oss << "Such groupname \"" << newName << "\" already exists ! Kill it before !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - std::vector cpy=(*it).second; + std::vector const cpy=(*it).second; _groups.erase(it); _groups[newName]=cpy; } @@ -1044,8 +1077,8 @@ void MEDFileMesh::changeFamilyId(mcIdType oldId, mcIdType newId) */ void MEDFileMesh::changeFamilyName(const std::string& oldName, const std::string& newName) { - std::string oname(oldName); - std::map::iterator it=_families.find(oname); + std::string const oname(oldName); + auto const it=_families.find(oname); std::vector fams=getFamiliesNames(); if(it==_families.end()) { @@ -1053,20 +1086,20 @@ void MEDFileMesh::changeFamilyName(const std::string& oldName, const std::string std::copy(fams.begin(),fams.end(),std::ostream_iterator(oss," ")); throw INTERP_KERNEL::Exception(oss.str().c_str()); } - std::string nname(newName); - std::map::iterator it2=_families.find(nname); + std::string const nname(newName); + auto const it2=_families.find(nname); if(it2!=_families.end()) { std::ostringstream oss; oss << "Such familyname \"" << newName << " already exists ! Kill it before !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - mcIdType cpy=(*it).second; + mcIdType const cpy=(*it).second; _families.erase(it); _families[newName]=cpy; - for(std::map >::iterator it3=_groups.begin();it3!=_groups.end();it3++) + for(auto & _group : _groups) { - std::vector& v=(*it3).second; - std::vector::iterator it4=std::find(v.begin(),v.end(),oname); + std::vector& v=_group.second; + auto const it4=std::find(v.begin(),v.end(),oname); if(it4!=v.end()) (*it4)=nname; } @@ -1079,18 +1112,18 @@ void MEDFileMesh::changeFamilyName(const std::string& oldName, const std::string * \return bool - \c true if number of families and their ids are the same in the two * meshes. Families with the id == \c 0 are not considered. */ -bool MEDFileMesh::areFamsEqual(const MEDFileMesh *other, std::string& what) const +bool MEDFileMesh::areFamsEqual(const MEDFileMesh *other, std::string& /*what*/) const { if(_families==other->_families) return true; std::map fam0; std::map fam1; - for(std::map::const_iterator it=_families.begin();it!=_families.end();it++) - if((*it).second!=0) - fam0[(*it).first]=(*it).second; - for(std::map::const_iterator it=other->_families.begin();it!=other->_families.end();it++) - if((*it).second!=0) - fam1[(*it).first]=(*it).second; + for(const auto & _familie : _families) + if(_familie.second!=0) + fam0[_familie.first]=_familie.second; + for(const auto & _familie : other->_families) + if(_familie.second!=0) + fam1[_familie.first]=_familie.second; return fam0==fam1; } @@ -1107,7 +1140,7 @@ bool MEDFileMesh::areGrpsEqual(const MEDFileMesh *other, std::string& what) cons if(_groups==other->_groups) return true; bool ret=true; - std::size_t sz=_groups.size(); + std::size_t const sz=_groups.size(); if(sz!=other->_groups.size()) { what="Groups differ because not same number !\n"; @@ -1115,14 +1148,14 @@ bool MEDFileMesh::areGrpsEqual(const MEDFileMesh *other, std::string& what) cons } if(ret) { - std::map >::const_iterator it1=_groups.begin(); + auto it1=_groups.begin(); for(std::size_t i=0;i >::const_iterator it2=other->_groups.find((*it1).first); + auto const it2=other->_groups.find((*it1).first); if(it2!=other->_groups.end()) { - std::set s1((*it1).second.begin(),(*it1).second.end()); - std::set s2((*it2).second.begin(),(*it2).second.end()); + std::set const s1((*it1).second.begin(),(*it1).second.end()); + std::set const s2((*it2).second.begin(),(*it2).second.end()); ret=(s1==s2); } else @@ -1136,18 +1169,18 @@ bool MEDFileMesh::areGrpsEqual(const MEDFileMesh *other, std::string& what) cons { std::ostringstream oss; oss << "Groups description differs :\n"; oss << "First group description :\n"; - for(std::map >::const_iterator it=_groups.begin();it!=_groups.end();it++) + for(const auto & _group : _groups) { - oss << " Group \"" << (*it).first << "\" on following families :\n"; - for(std::vector::const_iterator it2=(*it).second.begin();it2!=(*it).second.end();it2++) - oss << " \"" << *it2 << "\n"; + oss << " Group \"" << _group.first << "\" on following families :\n"; + for(const auto & it2 : _group.second) + oss << " \"" << it2 << "\n"; } oss << "Second group description :\n"; - for(std::map >::const_iterator it=other->_groups.begin();it!=other->_groups.end();it++) + for(const auto & _group : other->_groups) { - oss << " Group \"" << (*it).first << "\" on following families :\n"; - for(std::vector::const_iterator it2=(*it).second.begin();it2!=(*it).second.end();it2++) - oss << " \"" << *it2 << "\n"; + oss << " Group \"" << _group.first << "\" on following families :\n"; + for(const auto & it2 : _group.second) + oss << " \"" << it2 << "\n"; } what+=oss.str(); } @@ -1161,7 +1194,7 @@ bool MEDFileMesh::areGrpsEqual(const MEDFileMesh *other, std::string& what) cons */ bool MEDFileMesh::existsGroup(const std::string& groupName) const { - std::string grpName(groupName); + std::string const grpName(groupName); return _groups.find(grpName)!=_groups.end(); } @@ -1172,8 +1205,8 @@ bool MEDFileMesh::existsGroup(const std::string& groupName) const */ bool MEDFileMesh::existsFamily(mcIdType famId) const { - for(std::map::const_iterator it2=_families.begin();it2!=_families.end();it2++) - if((*it2).second==famId) + for(const auto & _familie : _families) + if(_familie.second==famId) return true; return false; } @@ -1185,7 +1218,7 @@ bool MEDFileMesh::existsFamily(mcIdType famId) const */ bool MEDFileMesh::existsFamily(const std::string& familyName) const { - std::string fname(familyName); + std::string const fname(familyName); return _families.find(fname)!=_families.end(); } @@ -1196,13 +1229,13 @@ bool MEDFileMesh::existsFamily(const std::string& familyName) const */ void MEDFileMesh::setFamilyId(const std::string& familyName, mcIdType id) { - std::string fname(familyName); + std::string const fname(familyName); _families[fname]=id; } void MEDFileMesh::setFamilyIdUnique(const std::string& familyName, mcIdType id) { - std::string fname(familyName); + std::string const fname(familyName); for(std::map::const_iterator it=_families.begin();it!=_families.end();it++) if((*it).second==id) { @@ -1223,8 +1256,8 @@ void MEDFileMesh::setFamilyIdUnique(const std::string& familyName, mcIdType id) */ void MEDFileMesh::addFamily(const std::string& familyName, mcIdType famId) { - std::string fname(familyName); - std::map::const_iterator it=_families.find(fname); + std::string const fname(familyName); + std::map::const_iterator const it=_families.find(fname); if(it==_families.end()) { for(std::map::const_iterator it2=_families.begin();it2!=_families.end();it2++) @@ -1262,7 +1295,7 @@ void MEDFileMesh::addFamily(const std::string& familyName, mcIdType famId) */ void MEDFileMesh::createGroupOnAll(int meshDimRelToMaxExt, const std::string& groupName) { - std::string grpName(groupName); + std::string const grpName(groupName); std::vector levs=getNonEmptyLevelsExt(); if(std::find(levs.begin(),levs.end(),meshDimRelToMaxExt)==levs.end()) { @@ -1280,14 +1313,14 @@ void MEDFileMesh::createGroupOnAll(int meshDimRelToMaxExt, const std::string& gr throw INTERP_KERNEL::Exception(oss.str().c_str()); } const DataArrayIdType *fieldFamIds=getFamilyFieldAtLevel(meshDimRelToMaxExt); - if(fieldFamIds==0) + if(fieldFamIds==nullptr) throw INTERP_KERNEL::Exception("MEDFileMesh::createGroupOnAll : Family field arr ids is not defined for this level !"); MCAuto famIds=fieldFamIds->getDifferentValues(); std::vector familiesOnWholeGroup; - for(const mcIdType *it=famIds->begin();it!=famIds->end();it++) + for(long const it : *famIds) { bool tmp; - familiesOnWholeGroup.push_back(findOrCreateAndGiveFamilyWithId(*it,tmp)); + familiesOnWholeGroup.push_back(findOrCreateAndGiveFamilyWithId(it,tmp)); } _groups[grpName]=familiesOnWholeGroup; } @@ -1303,34 +1336,34 @@ void MEDFileMesh::createGroupOnAll(int meshDimRelToMaxExt, const std::string& gr */ bool MEDFileMesh::keepFamIdsOnlyOnLevs(const std::vector& famIds, const std::vector& vMeshDimRelToMaxExt) { - std::set levsInput(vMeshDimRelToMaxExt.begin(),vMeshDimRelToMaxExt.end()); + std::set const levsInput(vMeshDimRelToMaxExt.begin(),vMeshDimRelToMaxExt.end()); std::vector levs=getNonEmptyLevelsExt(); - std::set levs2(levs.begin(),levs.end()); + std::set const levs2(levs.begin(),levs.end()); std::vector levsToTest; std::set_difference(levs2.begin(),levs2.end(),levsInput.begin(),levsInput.end(),std::back_insert_iterator< std::vector >(levsToTest)); - std::set famIds2(famIds.begin(),famIds.end()); + std::set const famIds2(famIds.begin(),famIds.end()); bool ret=true; mcIdType maxFamId=1; if(!_families.empty()) maxFamId=getMaxFamilyId()+1; - std::vector allFams=getFamiliesNames(); - for(std::vector::const_iterator it=levsToTest.begin();it!=levsToTest.end();it++) + std::vector const allFams=getFamiliesNames(); + for(int const it : levsToTest) { - const DataArrayIdType *fieldFamIds=getFamilyFieldAtLevel(*it); + const DataArrayIdType *fieldFamIds=getFamilyFieldAtLevel(it); if(fieldFamIds) { - MCAuto famIds3=fieldFamIds->getDifferentValues(); + MCAuto const famIds3=fieldFamIds->getDifferentValues(); std::vector tmp; std::set_intersection(famIds3->begin(),famIds3->end(),famIds2.begin(),famIds2.end(),std::back_insert_iterator< std::vector >(tmp)); - for(std::vector::const_iterator it2=tmp.begin();it2!=tmp.end();it2++) + for(long const it2 : tmp) { ret=false; - std::string famName=getFamilyNameGivenId(*it2); + std::string const famName=getFamilyNameGivenId(it2); std::ostringstream oss; oss << "Family_" << maxFamId; - std::string zeName=CreateNameNotIn(oss.str(),allFams); + std::string const zeName=CreateNameNotIn(oss.str(),allFams); addFamilyOnAllGroupsHaving(famName,zeName); _families[zeName]=maxFamId; - (const_cast(fieldFamIds))->changeValue(*it2,maxFamId); + (const_cast(fieldFamIds))->changeValue(it2,maxFamId); maxFamId++; } } @@ -1348,8 +1381,8 @@ bool MEDFileMesh::keepFamIdsOnlyOnLevs(const std::vector& famIds, cons */ void MEDFileMesh::addFamilyOnGrp(const std::string& grpName, const std::string& famName) { - std::string grpn(grpName); - std::string famn(famName); + std::string const grpn(grpName); + std::string const famn(famName); if(grpn.empty() || famn.empty()) throw INTERP_KERNEL::Exception("MEDFileMesh::addFamilyOnGrp : input strings must be non null !"); std::vector fams=getFamiliesNames(); @@ -1360,14 +1393,14 @@ void MEDFileMesh::addFamilyOnGrp(const std::string& grpName, const std::string& std::copy(fams.begin(),fams.end(),std::ostream_iterator(oss," ")); oss << "."; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - std::map >::iterator it=_groups.find(grpn); + auto const it=_groups.find(grpn); if(it==_groups.end()) { _groups[grpn].push_back(famn); } else { - std::vector::iterator it2=std::find((*it).second.begin(),(*it).second.end(),famn); + auto const it2=std::find((*it).second.begin(),(*it).second.end(),famn); if(it2==(*it).second.end()) (*it).second.push_back(famn); } @@ -1380,11 +1413,11 @@ void MEDFileMesh::addFamilyOnGrp(const std::string& grpName, const std::string& */ void MEDFileMesh::addFamilyOnAllGroupsHaving(const std::string& famName, const std::string& otherFamName) { - std::string famNameCpp(famName); - std::string otherCpp(otherFamName); - for(std::map >::iterator it=_groups.begin();it!=_groups.end();it++) + std::string const famNameCpp(famName); + std::string const otherCpp(otherFamName); + for(auto & _group : _groups) { - std::vector& v=(*it).second; + std::vector& v=_group.second; if(std::find(v.begin(),v.end(),famNameCpp)!=v.end()) { v.push_back(otherCpp); @@ -1397,7 +1430,7 @@ void MEDFileMesh::checkNoGroupClash(const DataArrayIdType *famArr, const std::st std::vector grpsNames(getGroupsNames()); if(std::find(grpsNames.begin(),grpsNames.end(),grpName)==grpsNames.end()) return ; - std::vector famIds(getFamiliesIdsOnGroup(grpName)); + std::vector const famIds(getFamiliesIdsOnGroup(grpName)); if(famArr->presenceOfValue(famIds)) { std::ostringstream oss; oss << "MEDFileUMesh::addGroup : Group with name \"" << grpName << "\" already exists at specified level ! Destroy it before calling this method !"; @@ -1413,7 +1446,7 @@ void MEDFileMesh::addGroupUnderground(bool isNodeGroup, const DataArrayIdType *i { if(!ids) throw INTERP_KERNEL::Exception("MEDFileUMesh::addGroup : NULL pointer in input !"); - std::string grpName(ids->getName()); + std::string const grpName(ids->getName()); if(grpName.empty()) throw INTERP_KERNEL::Exception("MEDFileUMesh::addGroup : empty group name ! MED file format do not accept empty group name !"); ids->checkStrictlyMonotonic(true); @@ -1446,11 +1479,11 @@ void MEDFileMesh::addGroupUnderground(bool isNodeGroup, const DataArrayIdType *i else { familyIds.push_back(isNodeGroup?maxVal:-maxVal); idsPerfamiliyIds.push_back(ids2); - std::string locFamName=FindOrCreateAndGiveFamilyWithId(families,isNodeGroup?maxVal:-maxVal,created); + std::string const locFamName=FindOrCreateAndGiveFamilyWithId(families,isNodeGroup?maxVal:-maxVal,created); fams.push_back(locFamName); if(existsFamily(*famId)) { - std::string locFamName2=getFamilyNameGivenId(*famId); std::vector v(2); v[0]=locFamName2; v[1]=locFamName; + std::string const locFamName2=getFamilyNameGivenId(*famId); std::vector v(2); v[0]=locFamName2; v[1]=locFamName; ChangeAllGroupsContainingFamily(groups,getFamilyNameGivenId(*famId),v); } maxVal++; @@ -1460,10 +1493,10 @@ void MEDFileMesh::addGroupUnderground(bool isNodeGroup, const DataArrayIdType *i { familyIds.push_back(isNodeGroup?maxVal:-maxVal); idsPerfamiliyIds.push_back(ret0); // modifying all other groups on *famId to lie on maxVal and on maxVal+1 familyIds.push_back(isNodeGroup?maxVal+1:-maxVal-1); idsPerfamiliyIds.push_back(ids2);//grp lie only on maxVal+1 - std::string n2(FindOrCreateAndGiveFamilyWithId(families,isNodeGroup?maxVal+1:-maxVal-1,created)); fams.push_back(n2); + std::string const n2(FindOrCreateAndGiveFamilyWithId(families,isNodeGroup?maxVal+1:-maxVal-1,created)); fams.push_back(n2); if(existsFamily(*famId)) { - std::string n1(FindOrCreateAndGiveFamilyWithId(families,isNodeGroup?maxVal:-maxVal,created)); std::vector v(2); v[0]=n1; v[1]=n2; + std::string const n1(FindOrCreateAndGiveFamilyWithId(families,isNodeGroup?maxVal:-maxVal,created)); std::vector v(2); v[0]=n1; v[1]=n2; ChangeAllGroupsContainingFamily(groups,getFamilyNameGivenId(*famId),v); } maxVal+=2; @@ -1475,7 +1508,7 @@ void MEDFileMesh::addGroupUnderground(bool isNodeGroup, const DataArrayIdType *i famArr->setPartOfValuesSimple3(familyIds[i],da->begin(),da->end(),0,1,1); } _families=families; - std::map >::iterator itt(groups.find(grpName)); + auto const itt(groups.find(grpName)); if(itt!=groups.end()) { std::vector& famsOnGrp((*itt).second); @@ -1493,11 +1526,11 @@ void MEDFileMesh::changeAllGroupsContainingFamily(const std::string& familyNameT void MEDFileMesh::ChangeAllGroupsContainingFamily(std::map >& groups, const std::string& familyNameToChange, const std::vector& newFamiliesNames) { - std::string fam(familyNameToChange); - for(std::map >::iterator it=groups.begin();it!=groups.end();it++) + std::string const fam(familyNameToChange); + for(auto & group : groups) { - std::vector& fams((*it).second); - std::vector::iterator it2=std::find(fams.begin(),fams.end(),fam); + std::vector& fams(group.second); + auto const it2=std::find(fams.begin(),fams.end(),fam); if(it2!=fams.end()) { fams.erase(it2); @@ -1577,7 +1610,7 @@ void MEDFileMesh::setGroupInfo(const std::map::const_iterator it=_families.find(name); + auto const it=_families.find(name); if(it==_families.end()) { std::vector fams(getFamiliesNames()); @@ -1598,9 +1631,9 @@ std::vector MEDFileMesh::getFamiliesIds(const std::vector { std::vector ret(fams.size()); int i=0; - for(std::vector::const_iterator it=fams.begin();it!=fams.end();it++,i++) + for(auto it=fams.begin();it!=fams.end();it++,i++) { - std::map::const_iterator it2=_families.find(*it); + auto const it2=_families.find(*it); if(it2==_families.end()) { std::vector fams2=getFamiliesNames(); @@ -1623,9 +1656,9 @@ mcIdType MEDFileMesh::getMaxAbsFamilyId() const if(_families.empty()) throw INTERP_KERNEL::Exception("MEDFileMesh::getMaxFamilyId : no families set !"); mcIdType ret=-std::numeric_limits::max(); - for(std::map::const_iterator it=_families.begin();it!=_families.end();it++) + for(const auto & _familie : _families) { - ret=std::max(std::abs((*it).second),ret); + ret=std::max(std::abs(_familie.second),ret); } return ret; } @@ -1640,9 +1673,9 @@ mcIdType MEDFileMesh::getMaxFamilyId() const if(_families.empty()) throw INTERP_KERNEL::Exception("MEDFileMesh::getMaxFamilyId : no families set !"); mcIdType ret=-std::numeric_limits::max(); - for(std::map::const_iterator it=_families.begin();it!=_families.end();it++) + for(const auto & _familie : _families) { - ret=std::max((*it).second,ret); + ret=std::max(_familie.second,ret); } return ret; } @@ -1657,9 +1690,9 @@ mcIdType MEDFileMesh::getMinFamilyId() const if(_families.empty()) throw INTERP_KERNEL::Exception("MEDFileMesh::getMinFamilyId : no families set !"); mcIdType ret=std::numeric_limits::max(); - for(std::map::const_iterator it=_families.begin();it!=_families.end();it++) + for(const auto & _familie : _families) { - ret=std::min((*it).second,ret); + ret=std::min(_familie.second,ret); } return ret; } @@ -1672,9 +1705,9 @@ mcIdType MEDFileMesh::getMinFamilyId() const mcIdType MEDFileMesh::getTheMaxAbsFamilyId() const { mcIdType m1=-std::numeric_limits::max(); - for(std::map::const_iterator it=_families.begin();it!=_families.end();it++) - m1=std::max(std::abs((*it).second),m1); - mcIdType m2=getMaxAbsFamilyIdInArrays(); + for(const auto & _familie : _families) + m1=std::max(std::abs(_familie.second),m1); + mcIdType const m2=getMaxAbsFamilyIdInArrays(); return std::max(m1,m2); } @@ -1686,9 +1719,9 @@ mcIdType MEDFileMesh::getTheMaxAbsFamilyId() const mcIdType MEDFileMesh::getTheMaxFamilyId() const { mcIdType m1=-std::numeric_limits::max(); - for(std::map::const_iterator it=_families.begin();it!=_families.end();it++) - m1=std::max((*it).second,m1); - mcIdType m2=getMaxFamilyIdInArrays(); + for(const auto & _familie : _families) + m1=std::max(_familie.second,m1); + mcIdType const m2=getMaxFamilyIdInArrays(); return std::max(m1,m2); } @@ -1700,9 +1733,9 @@ mcIdType MEDFileMesh::getTheMaxFamilyId() const mcIdType MEDFileMesh::getTheMinFamilyId() const { mcIdType m1=std::numeric_limits::max(); - for(std::map::const_iterator it=_families.begin();it!=_families.end();it++) - m1=std::min((*it).second,m1); - mcIdType m2=getMinFamilyIdInArrays(); + for(const auto & _familie : _families) + m1=std::min(_familie.second,m1); + mcIdType const m2=getMinFamilyIdInArrays(); return std::min(m1,m2); } @@ -1715,8 +1748,8 @@ DataArrayIdType *MEDFileMesh::getAllFamiliesIdsReferenced() const { MCAuto ret=DataArrayIdType::New(); std::set v; - for(std::map::const_iterator it=_families.begin();it!=_families.end();it++) - v.insert((*it).second); + for(const auto & _familie : _families) + v.insert(_familie.second); ret->alloc((mcIdType)v.size(),1); std::copy(v.begin(),v.end(),ret->getPointer()); return ret.retn(); @@ -1729,11 +1762,11 @@ DataArrayIdType *MEDFileMesh::getAllFamiliesIdsReferenced() const */ DataArrayIdType *MEDFileMesh::computeAllFamilyIdsInUse() const { - std::vector famLevs=getFamArrNonEmptyLevelsExt(); + std::vector const famLevs=getFamArrNonEmptyLevelsExt(); MCAuto ret; - for(std::vector::const_iterator it=famLevs.begin();it!=famLevs.end();it++) + for(int const famLev : famLevs) { - const DataArrayIdType *arr=getFamilyFieldAtLevel(*it);//arr not null due to spec of getFamArrNonEmptyLevelsExt + const DataArrayIdType *arr=getFamilyFieldAtLevel(famLev);//arr not null due to spec of getFamArrNonEmptyLevelsExt MCAuto dv=arr->getDifferentValues(); if((DataArrayIdType *) ret) ret=dv->buildUnion(ret); @@ -1749,20 +1782,20 @@ DataArrayIdType *MEDFileMesh::computeAllFamilyIdsInUse() const */ bool MEDFileMesh::ensureDifferentFamIdsPerLevel() { - std::vector levs=getNonEmptyLevelsExt(); - std::set allFamIds; + std::vector const levs=getNonEmptyLevelsExt(); + std::set const allFamIds; mcIdType maxId=getMaxFamilyId()+1; std::map > famIdsToRenum; - for(std::vector::const_iterator it=levs.begin();it!=levs.end();it++) + for(int const lev : levs) { - const DataArrayIdType *fam=getFamilyFieldAtLevel(*it); + const DataArrayIdType *fam=getFamilyFieldAtLevel(lev); if(fam) { MCAuto tmp=fam->getDifferentValues(); std::set r2; std::set_intersection(tmp->begin(),tmp->end(),allFamIds.begin(),allFamIds.end(),std::inserter(r2,r2.end())); if(!r2.empty()) - famIdsToRenum[*it].insert(famIdsToRenum[*it].end(),r2.begin(),r2.end()); + famIdsToRenum[lev].insert(famIdsToRenum[lev].end(),r2.begin(),r2.end()); std::set r3; std::set_union(tmp->begin(),tmp->end(),allFamIds.begin(),allFamIds.end(),std::inserter(r3,r3.end())); } @@ -1772,25 +1805,25 @@ bool MEDFileMesh::ensureDifferentFamIdsPerLevel() MCAuto allIds=getAllFamiliesIdsReferenced(); for(std::map >::const_iterator it2=famIdsToRenum.begin();it2!=famIdsToRenum.end();it2++) { - DataArrayIdType *fam=const_cast(getFamilyFieldAtLevel((*it2).first)); + auto *fam=const_cast(getFamilyFieldAtLevel((*it2).first)); mcIdType *famIdsToChange=fam->getPointer(); std::map ren; - for(std::vector::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++,maxId++) + for(auto it3=(*it2).second.begin();it3!=(*it2).second.end();it3++,maxId++) { if(allIds->presenceOfValue(*it3)) { - std::string famName=getFamilyNameGivenId(*it3); - std::vector grps=getGroupsOnFamily(famName); + std::string const famName=getFamilyNameGivenId(*it3); + std::vector const grps=getGroupsOnFamily(famName); ren[*it3]=maxId; bool dummy; - std::string newFam=findOrCreateAndGiveFamilyWithId(maxId,dummy); - for(std::vector::const_iterator it4=grps.begin();it4!=grps.end();it4++) - addFamilyOnGrp((*it4),newFam); + std::string const newFam=findOrCreateAndGiveFamilyWithId(maxId,dummy); + for(const auto & grp : grps) + addFamilyOnGrp(grp,newFam); } } MCAuto ids=fam->findIdsEqualList(&(*it2).second[0],&(*it2).second[0]+(*it2).second.size()); - for(const mcIdType *id=ids->begin();id!=ids->end();id++) - famIdsToChange[*id]=ren[famIdsToChange[*id]]; + for(long const id : *ids) + famIdsToChange[id]=ren[famIdsToChange[id]]; } return false; } @@ -1821,7 +1854,7 @@ void MEDFileMesh::normalizeFamIdsTrio() std::map ren; for(const mcIdType *it=tmp->begin();it!=tmp->end();it++,refId++) ren[*it]=refId; - mcIdType nbOfTuples=fam->getNumberOfTuples(); + mcIdType const nbOfTuples=fam->getNumberOfTuples(); mcIdType *start=const_cast(fam)->getPointer(); for(mcIdType *w=start;w!=start+nbOfTuples;w++) *w=ren[*w]; @@ -1829,7 +1862,7 @@ void MEDFileMesh::normalizeFamIdsTrio() { if(allIds->presenceOfValue(*it)) { - std::string famName=getFamilyNameGivenId(*it); + std::string const famName=getFamilyNameGivenId(*it); families[famName]=ren[*it]; famsFetched.insert(famName); } @@ -1847,7 +1880,7 @@ void MEDFileMesh::normalizeFamIdsTrio() std::map ren; for(const mcIdType *it=tmp->begin();it!=tmp->end();it++,refId--) ren[*it]=refId; - mcIdType nbOfTuples=fam->getNumberOfTuples(); + mcIdType const nbOfTuples=fam->getNumberOfTuples(); mcIdType *start=const_cast(fam)->getPointer(); for(mcIdType *w=start;w!=start+nbOfTuples;w++) *w=ren[*w]; @@ -1855,16 +1888,16 @@ void MEDFileMesh::normalizeFamIdsTrio() { if(allIds->presenceOfValue(*it)) { - std::string famName=getFamilyNameGivenId(*it); + std::string const famName=getFamilyNameGivenId(*it); families[famName]=ren[*it]; famsFetched.insert(famName); } } } } - for(std::set::const_iterator it2=levsS.begin();it2!=levsS.end();it2++) + for(int const it2 : levsS) { - DataArrayIdType *fam=const_cast(getFamilyFieldAtLevel(*it2)); + auto *fam=const_cast(getFamilyFieldAtLevel(it2)); if(fam) { MCAuto tmp=fam->getDifferentValues(); @@ -1872,7 +1905,7 @@ void MEDFileMesh::normalizeFamIdsTrio() for(const mcIdType *it3=tmp->begin();it3!=tmp->end();it3++) if(allIds->presenceOfValue(*it3)) { - std::string famName=getFamilyNameGivenId(*it3); + std::string const famName=getFamilyNameGivenId(*it3); families[famName]=0; famsFetched.insert(famName); } @@ -1880,11 +1913,11 @@ void MEDFileMesh::normalizeFamIdsTrio() } // std::vector allFams=getFamiliesNames(); - std::set allFamsS(allFams.begin(),allFams.end()); + std::set const allFamsS(allFams.begin(),allFams.end()); std::set unFetchedIds; std::set_difference(allFamsS.begin(),allFamsS.end(),famsFetched.begin(),famsFetched.end(),std::inserter(unFetchedIds,unFetchedIds.end())); - for(std::set::const_iterator it4=unFetchedIds.begin();it4!=unFetchedIds.end();it4++) - families[*it4]=_families[*it4]; + for(const auto & unFetchedId : unFetchedIds) + families[unFetchedId]=_families[unFetchedId]; _families=families; } @@ -1913,7 +1946,7 @@ void MEDFileMesh::normalizeFamIdsMEDFile() std::map ren; for(const mcIdType *it=tmp->begin();it!=tmp->end();it++,refId++) ren[*it]=refId; - mcIdType nbOfTuples=fam->getNumberOfTuples(); + mcIdType const nbOfTuples=fam->getNumberOfTuples(); mcIdType *start=const_cast(fam)->getPointer(); for(mcIdType *w=start;w!=start+nbOfTuples;w++) *w=ren[*w]; @@ -1921,7 +1954,7 @@ void MEDFileMesh::normalizeFamIdsMEDFile() { if(allIds->presenceOfValue(*it)) { - std::string famName=getFamilyNameGivenId(*it); + std::string const famName=getFamilyNameGivenId(*it); families[famName]=ren[*it]; famsFetched.insert(famName); } @@ -1929,7 +1962,7 @@ void MEDFileMesh::normalizeFamIdsMEDFile() } } refId=-1; - for(std::set::const_reverse_iterator it2=levsS.rbegin();it2!=levsS.rend();it2++) + for(auto it2=levsS.rbegin();it2!=levsS.rend();it2++) { const DataArrayIdType *fam=getFamilyFieldAtLevel(*it2); if(fam) @@ -1938,7 +1971,7 @@ void MEDFileMesh::normalizeFamIdsMEDFile() std::map ren; for(const mcIdType *it=tmp->begin();it!=tmp->end();it++,refId--) ren[*it]=refId; - mcIdType nbOfTuples=fam->getNumberOfTuples(); + mcIdType const nbOfTuples=fam->getNumberOfTuples(); mcIdType *start=const_cast(fam)->getPointer(); for(mcIdType *w=start;w!=start+nbOfTuples;w++) *w=ren[*w]; @@ -1946,7 +1979,7 @@ void MEDFileMesh::normalizeFamIdsMEDFile() { if(allIds->presenceOfValue(*it)) { - std::string famName=getFamilyNameGivenId(*it); + std::string const famName=getFamilyNameGivenId(*it); families[famName]=ren[*it]; famsFetched.insert(famName); } @@ -1955,11 +1988,11 @@ void MEDFileMesh::normalizeFamIdsMEDFile() } // std::vector allFams=getFamiliesNames(); - std::set allFamsS(allFams.begin(),allFams.end()); + std::set const allFamsS(allFams.begin(),allFams.end()); std::set unFetchedIds; std::set_difference(allFamsS.begin(),allFamsS.end(),famsFetched.begin(),famsFetched.end(),std::inserter(unFetchedIds,unFetchedIds.end())); - for(std::set::const_iterator it4=unFetchedIds.begin();it4!=unFetchedIds.end();it4++) - families[*it4]=_families[*it4]; + for(const auto & unFetchedId : unFetchedIds) + families[unFetchedId]=_families[unFetchedId]; _families=families; } @@ -1972,9 +2005,9 @@ void MEDFileMesh::normalizeFamIdsMEDFile() */ std::string MEDFileMesh::getFamilyNameGivenId(mcIdType id) const { - for(std::map::const_iterator it=_families.begin();it!=_families.end();it++) - if((*it).second==id) - return (*it).first; + for(const auto & _familie : _families) + if(_familie.second==id) + return _familie.first; std::ostringstream oss; oss << "MEDFileUMesh::getFamilyNameGivenId : no such family id : " << id; throw INTERP_KERNEL::Exception(oss.str().c_str()); } @@ -2057,7 +2090,7 @@ DataArrayIdType *MEDFileMesh::getGroupArr(int meshDimRelToMaxExt, const std::str */ DataArrayIdType *MEDFileMesh::getGroupsArr(int meshDimRelToMaxExt, const std::vector& grps, bool renum) const { - std::vector fams2=getFamiliesOnGroups(grps); + std::vector const fams2=getFamiliesOnGroups(grps); return getFamiliesArr(meshDimRelToMaxExt,fams2,renum); } @@ -2173,7 +2206,7 @@ void MEDFileMesh::setGroupsAtLevel(int meshDimRelToMaxExt, const std::vector grpsName2(grps.size()); int i=0; - for(std::vector::const_iterator it=grps.begin();it!=grps.end();it++,i++) + for(auto it=grps.begin();it!=grps.end();it++,i++) { grpsName.insert((*it)->getName()); grpsName2[i]=(*it)->getName(); @@ -2182,7 +2215,7 @@ void MEDFileMesh::setGroupsAtLevel(int meshDimRelToMaxExt, const std::vector fam; std::vector< std::vector > fidsOfGroups; if(!renum) @@ -2197,14 +2230,14 @@ void MEDFileMesh::setGroupsAtLevel(int meshDimRelToMaxExt, const std::vectorsetName(grps[ii]->getName()); } - std::vector grps3(grps2.begin(),grps2.end()); + std::vector const grps3(grps2.begin(),grps2.end()); fam=DataArrayIdType::MakePartition(grps3,sz,fidsOfGroups); } mcIdType offset=1; if(!_families.empty()) offset=getMaxAbsFamilyId()+1; TranslateFamilyIds(meshDimRelToMaxExt==1?offset:-offset,fam,fidsOfGroups); - MCAuto ids=fam->getDifferentValues(); + MCAuto const ids=fam->getDifferentValues(); appendFamilyEntries(ids,fidsOfGroups,grpsName2); setFamilyFieldArr(meshDimRelToMaxExt,fam); } @@ -2217,30 +2250,30 @@ void MEDFileMesh::setGroupsAtLevel(int meshDimRelToMaxExt, const std::vector >& fidsOfGrps, const std::vector& grpNames) { std::map famInv; - for(const mcIdType *it=famIds->begin();it!=famIds->end();it++) + for(long const famId : *famIds) { std::ostringstream oss; - oss << "Family_" << (*it); - _families[oss.str()]=(*it); - famInv[*it]=oss.str(); + oss << "Family_" << famId; + _families[oss.str()]=famId; + famInv[famId]=oss.str(); } int i=0; - for(std::vector< std::vector >::const_iterator it1=fidsOfGrps.begin();it1!=fidsOfGrps.end();it1++,i++) + for(auto it1=fidsOfGrps.begin();it1!=fidsOfGrps.end();it1++,i++) { - for(std::vector::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++) + for(long const it2 : *it1) { - _groups[grpNames[i]].push_back(famInv[*it2]); + _groups[grpNames[i]].push_back(famInv[it2]); } } } std::vector MEDFileMesh::getAllGeoTypes() const { - std::vector levs(getNonEmptyLevels()); + std::vector const levs(getNonEmptyLevels()); std::vector ret; - for(std::vector::const_iterator it=levs.begin();it!=levs.end();it++) + for(int const lev : levs) { - std::vector elts(getGeoTypesAtLevel(*it)); + std::vector elts(getGeoTypesAtLevel(lev)); ret.insert(ret.end(),elts.begin(),elts.end()); } return ret; @@ -2265,11 +2298,11 @@ void MEDFileMesh::loadLLWithAdditionalItems(med_idt fid, const std::string& mNam void MEDFileMesh::TranslateFamilyIds(mcIdType offset, DataArrayIdType *famArr, std::vector< std::vector >& famIdsPerGrp) { famArr->applyLin(offset>0?1:-1,offset,0); - for(std::vector< std::vector >::iterator it1=famIdsPerGrp.begin();it1!=famIdsPerGrp.end();it1++) + for(auto & it1 : famIdsPerGrp) { if(offset<0) - std::transform((*it1).begin(),(*it1).end(),(*it1).begin(),std::negate()); - std::transform((*it1).begin(),(*it1).end(),(*it1).begin(),std::bind(std::plus(),std::placeholders::_1,offset)); + std::transform(it1.begin(),it1.end(),it1.begin(),std::negate()); + std::transform(it1.begin(),it1.end(),it1.begin(),std::bind(std::plus(),std::placeholders::_1,offset)); } } @@ -2284,7 +2317,7 @@ std::string MEDFileMesh::CreateNameNotIn(const std::string& nameTry, const std:: if(std::find(namesToAvoid.begin(),namesToAvoid.end(),nameTry)==namesToAvoid.end()) return nameTry; //attempt #1 - std::size_t len=nameTry.length(); + std::size_t const len=nameTry.length(); for(std::size_t ii=1;ii::const_iterator it2=namesToAvoid.begin();it2!=namesToAvoid.end();it2++) - tmp2+=(*it2); + for(const auto & it2 : namesToAvoid) + tmp2+=it2; if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tmp2)==namesToAvoid.end()) return tmp2; throw INTERP_KERNEL::Exception("MEDFileMesh::CreateNameNotIn : impossible to find a not already used name !"); @@ -2313,7 +2346,7 @@ std::string MEDFileMesh::CreateNameNotIn(const std::string& nameTry, const std:: mcIdType MEDFileMesh::PutInThirdComponentOfCodeOffset(std::vector& code, mcIdType strt) { - std::size_t nbOfChunks=code.size()/3; + std::size_t const nbOfChunks=code.size()/3; if(code.size()%3!=0) throw INTERP_KERNEL::Exception("MEDFileMesh::PutInThirdComponentOfCodeOffset : code has invalid size : should be of size 3*x !"); mcIdType ret=strt; @@ -2339,7 +2372,7 @@ void MEDFileMesh::dealWithTinyInfo(const MEDCouplingMesh *m) _name=m->getName(); else { - std::string name(m->getName()); + std::string const name(m->getName()); if(!name.empty()) { if(_name!=name) @@ -2354,7 +2387,7 @@ void MEDFileMesh::dealWithTinyInfo(const MEDCouplingMesh *m) _desc_name=m->getDescription(); else { - std::string name(m->getDescription()); + std::string const name(m->getDescription()); if(!name.empty()) { if(_desc_name!=name) @@ -2370,11 +2403,11 @@ void MEDFileMesh::dealWithTinyInfo(const MEDCouplingMesh *m) void MEDFileMesh::getFamilyRepr(std::ostream& oss) const { oss << "(**************************)\n(* FAMILIES OF THE MESH : *)\n(**************************)\n"; - for(std::map::const_iterator it=_families.begin();it!=_families.end();it++) + for(const auto & _familie : _families) { - oss << "- Family with name \"" << (*it).first << "\" with number " << (*it).second << std::endl; + oss << "- Family with name \"" << _familie.first << "\" with number " << _familie.second << std::endl; oss << " - Groups lying on this family : "; - std::vector grps=getGroupsOnFamily((*it).first); + std::vector grps=getGroupsOnFamily(_familie.first); std::copy(grps.begin(),grps.end(),std::ostream_iterator(oss," ")); oss << std::endl << std::endl; } @@ -2396,7 +2429,7 @@ void MEDFileMesh::getFamilyRepr(std::ostream& oss) const */ MEDFileUMesh *MEDFileUMesh::New(const std::string& fileName, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs) { - MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + MEDFileUtilities::AutoFid const fid(OpenMEDFileForRead(fileName)); return New(fid,mName,dt,it,mrs); } @@ -2417,14 +2450,14 @@ MEDFileUMesh *MEDFileUMesh::New(med_idt fid, const std::string& mName, int dt, i */ MEDFileUMesh *MEDFileUMesh::New(const std::string& fileName, MEDFileMeshReadSelector *mrs) { - MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + MEDFileUtilities::AutoFid const fid(OpenMEDFileForRead(fileName)); return New(fid,mrs); } template T *NewForTheFirstMeshInFile(med_idt fid, MEDFileMeshReadSelector *mrs) { - std::vector ms(MEDLoaderNS::getMeshNamesFid(fid)); + std::vector ms((MEDLoaderNS::getMeshNamesFid(fid))); if(ms.empty()) { std::ostringstream oss; oss << MLMeshTraits::ClassName << "::New : no meshes in file \"" << MEDFileWritable::FileNameFromFID(fid) << "\" !"; @@ -2503,7 +2536,7 @@ MCAuto MEDFileUMesh::LoadConnectivityOnlyPartOf(med_idt fid, const MCAuto MEDFileUMesh::LoadConnectivityOnlyPartOf(const std::string& fileName, const std::string& mName, const std::vector& types, const std::vector& slicPerTyp, int dt, int it, MEDFileMeshReadSelector *mrs) { MEDFileUtilities::CheckFileForRead(fileName); - MEDFileUtilities::AutoFid fid(MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY)); + MEDFileUtilities::AutoFid const fid(MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY)); return MEDFileUMesh::LoadConnectivityOnlyPartOf(fid,mName,types,slicPerTyp,dt,it,mrs); } @@ -2527,7 +2560,7 @@ MCAuto MEDFileUMesh::LoadConnectivityOnlyPartOf(const std::string& MEDFileUMesh *MEDFileUMesh::LoadPartOf(const std::string& fileName, const std::string& mName, const std::vector& types, const std::vector& slicPerTyp, int dt, int it, MEDFileMeshReadSelector *mrs) { MEDFileUtilities::CheckFileForRead(fileName); - MEDFileUtilities::AutoFid fid(MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY)); + MEDFileUtilities::AutoFid const fid(MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY)); return MEDFileUMesh::LoadPartOf(fid,mName,types,slicPerTyp,dt,it,mrs); } @@ -2583,7 +2616,7 @@ MEDFileUMesh *MEDFileUMesh::LoadPartOfFromUserDistrib(med_idt fid, const std::st void MEDFileUMesh::LoadPartCoords(const std::string& fileName, const std::string& mName, int dt, int it, const std::vector& infosOnComp, mcIdType startNodeId, mcIdType stopNodeId, MCAuto& coords, MCAuto& partCoords, MCAuto& famCoords, MCAuto& numCoords, MCAuto& nameCoords) { - MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + MEDFileUtilities::AutoFid const fid(OpenMEDFileForRead(fileName)); MEDFileUMeshL2::LoadPartCoords(fid,infosOnComp,mName,dt,it,startNodeId,stopNodeId,coords,partCoords,famCoords,numCoords,nameCoords); } @@ -2604,10 +2637,10 @@ std::vector MEDFileUMesh::getDirectChildrenWithNull() c ret.push_back((const DataArrayIdType *)_rev_num_coords); ret.push_back((const DataArrayAsciiChar *)_name_coords); ret.push_back((const PartDefinition *)_part_coords); - for(std::vector< MCAuto >::const_iterator it=_ms.begin();it!=_ms.end();it++) - ret.push_back((const MEDFileUMeshSplitL1*) *it); - for(std::vector< MCAuto >::const_iterator it=_elt_str.begin();it!=_elt_str.end();it++) - ret.push_back((const MEDFileEltStruct4Mesh *)*it); + for(const auto & _m : _ms) + ret.push_back((const MEDFileUMeshSplitL1*) _m); + for(const auto & it : _elt_str) + ret.push_back((const MEDFileEltStruct4Mesh *)it); return ret; } @@ -2639,7 +2672,7 @@ MEDFileUMesh *MEDFileUMesh::deepCopy() const if(_name_coords.isNotNull()) ret->_name_coords=_name_coords->deepCopy(); std::size_t i=0; - for(std::vector< MCAuto >::const_iterator it=_ms.begin();it!=_ms.end();it++,i++) + for(auto it=_ms.begin();it!=_ms.end();it++,i++) { if((const MEDFileUMeshSplitL1 *)(*it)) ret->_ms[i]=(*it)->deepCopy(ret->_coords); @@ -2660,7 +2693,7 @@ bool MEDFileUMesh::isEqual(const MEDFileMesh *other, double eps, std::string& wh { if(!MEDFileMesh::isEqual(other,eps,what)) return false; - const MEDFileUMesh *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) { what="Mesh types differ ! This is unstructured and other is NOT !"; @@ -2670,14 +2703,14 @@ bool MEDFileUMesh::isEqual(const MEDFileMesh *other, double eps, std::string& wh otherC->clearNonDiscrAttributes(); const DataArrayDouble *coo1=_coords; const DataArrayDouble *coo2=otherC->_coords; - if((coo1==0 && coo2!=0) || (coo1!=0 && coo2==0)) + if((coo1==nullptr && coo2!=nullptr) || (coo1!=nullptr && coo2==nullptr)) { what="Mismatch of coordinates ! One is defined and not other !"; return false; } if(coo1) { - bool ret=coo1->isEqual(*coo2,eps); + bool const ret=coo1->isEqual(*coo2,eps); if(!ret) { what="Coords differ !"; @@ -2686,14 +2719,14 @@ bool MEDFileUMesh::isEqual(const MEDFileMesh *other, double eps, std::string& wh } { const DataArrayIdType *famc1(_fam_coords),*famc2(otherC->_fam_coords); - if((famc1==0 && famc2!=0) || (famc1!=0 && famc2==0)) + if((famc1==nullptr && famc2!=nullptr) || (famc1!=nullptr && famc2==nullptr)) { what="Mismatch of families arr on nodes ! One is defined and not other !"; return false; } if(famc1) { - bool ret=famc1->isEqual(*famc2); + bool const ret=famc1->isEqual(*famc2); if(!ret) { what="Families arr on node differ !"; @@ -2703,14 +2736,14 @@ bool MEDFileUMesh::isEqual(const MEDFileMesh *other, double eps, std::string& wh } { const DataArrayIdType *numc1(_num_coords),*numc2(otherC->_num_coords); - if((numc1==0 && numc2!=0) || (numc1!=0 && numc2==0)) + if((numc1==nullptr && numc2!=nullptr) || (numc1!=nullptr && numc2==nullptr)) { what="Mismatch of numbering arr on nodes ! One is defined and not other !"; return false; } if(numc1) { - bool ret=numc1->isEqual(*numc2); + bool const ret=numc1->isEqual(*numc2); if(!ret) { what="Numbering arr on node differ !"; @@ -2720,14 +2753,14 @@ bool MEDFileUMesh::isEqual(const MEDFileMesh *other, double eps, std::string& wh } { const DataArrayIdType *gnumc1(_global_num_coords),*gnumc2(otherC->_global_num_coords); - if((gnumc1==0 && gnumc2!=0) || (gnumc1!=0 && gnumc2==0)) + if((gnumc1==nullptr && gnumc2!=nullptr) || (gnumc1!=nullptr && gnumc2==nullptr)) { what="Mismatch of numbering arr on nodes ! One is defined and not other !"; return false; } if(gnumc1) { - bool ret=gnumc1->isEqual(*gnumc2); + bool const ret=gnumc1->isEqual(*gnumc2); if(!ret) { what="Global numbering arr on node differ !"; @@ -2737,14 +2770,14 @@ bool MEDFileUMesh::isEqual(const MEDFileMesh *other, double eps, std::string& wh } { const DataArrayAsciiChar *namec1(_name_coords),*namec2(otherC->_name_coords); - if((namec1==0 && namec2!=0) || (namec1!=0 && namec2==0)) + if((namec1==nullptr && namec2!=nullptr) || (namec1!=nullptr && namec2==nullptr)) { what="Mismatch of naming arr on nodes ! One is defined and not other !"; return false; } if(namec1) { - bool ret=namec1->isEqual(*namec2); + bool const ret=namec1->isEqual(*namec2); if(!ret) { what="Names arr on node differ !"; @@ -2757,19 +2790,19 @@ bool MEDFileUMesh::isEqual(const MEDFileMesh *other, double eps, std::string& wh what="Number of levels differs !"; return false; } - std::size_t sz=_ms.size(); + std::size_t const sz=_ms.size(); for(std::size_t i=0;i_ms[i]; - if((s1==0 && s2!=0) || (s1!=0 && s2==0)) + if((s1==nullptr && s2!=nullptr) || (s1!=nullptr && s2==nullptr)) { what="Mismatch of presence of sub levels !"; return false; } if(s1) { - bool ret=s1->isEqual(s2,eps,what); + bool const ret=s1->isEqual(s2,eps,what); if(!ret) return false; } @@ -2805,14 +2838,14 @@ void MEDFileUMesh::checkConsistency() const } else { - mcIdType nbCoo = _coords->getNumberOfTuples(); + mcIdType const nbCoo = _coords->getNumberOfTuples(); if (_fam_coords.isNotNull()) _fam_coords->checkNbOfTuplesAndComp(nbCoo,1,"MEDFileUMesh::checkConsistency(): inconsistent internal node family array!"); if (_num_coords.isNotNull()) { _num_coords->checkNbOfTuplesAndComp(nbCoo,1,"MEDFileUMesh::checkConsistency(): inconsistent internal node numbering array!"); mcIdType pos; - mcIdType maxValue=_num_coords->getMaxValue(pos); + mcIdType const maxValue=_num_coords->getMaxValue(pos); if (!_rev_num_coords || _rev_num_coords->getNumberOfTuples() != (maxValue+1)) throw INTERP_KERNEL::Exception("MEDFileUMesh::checkConsistency(): inconsistent internal revert node numbering array!"); } @@ -2827,9 +2860,8 @@ void MEDFileUMesh::checkConsistency() const if (_name_coords) _name_coords->checkNbOfTuplesAndComp(nbCoo,MED_SNAME_SIZE,"MEDFileUMesh::checkConsistency(): inconsistent internal coord name array!"); // Now sub part check: - for (std::vector< MCAuto >::const_iterator it=_ms.begin(); - it != _ms.end(); it++) - (*it)->checkConsistency(); + for (const auto & _m : _ms) + _m->checkConsistency(); } } @@ -2845,11 +2877,11 @@ void MEDFileUMesh::checkSMESHConsistency() const // For all sub-levels, numbering is either always null or with void intersection: if (_ms.size()) { - std::vector< MCAuto >::const_iterator it=_ms.begin(); + auto it=_ms.begin(); std::vector< const DataArrayIdType * > v; - bool voidOrNot = ((*it)->_num == 0); + bool const voidOrNot = ((*it)->_num == nullptr); for (it++; it != _ms.end(); it++) - if( ((*it)->_num == 0) != voidOrNot ) + if( ((*it)->_num == nullptr) != voidOrNot ) throw INTERP_KERNEL::Exception("MEDFileUMesh::checkConsistency(): inconsistent numbering between mesh sub-levels!"); else if (!voidOrNot) v.push_back((*it)->_num); @@ -2873,11 +2905,11 @@ void MEDFileUMesh::clearNodeAndCellNumbers() _num_coords.nullify(); _rev_num_coords.nullify(); _global_num_coords.nullify(); - for (std::vector< MCAuto >::iterator it=_ms.begin(); it != _ms.end(); it++) + for (auto & _m : _ms) { - (*it)->_num.nullify(); - (*it)->_rev_num.nullify(); - (*it)->_global_num.nullify(); + _m->_num.nullify(); + _m->_rev_num.nullify(); + _m->_global_num.nullify(); } } @@ -2895,24 +2927,23 @@ void MEDFileUMesh::clearNonDiscrAttributes() const _num_coords.iAmATrollConstCast()->setName("");//This parameter is not discriminant for comparison if(_name_coords.isNotNull()) _name_coords.iAmATrollConstCast()->setName("");//This parameter is not discriminant for comparison - for(std::vector< MCAuto >::const_iterator it=_ms.begin();it!=_ms.end();it++) + for(const auto & _m : _ms) { - if((*it).isNotNull()) - (*it)->clearNonDiscrAttributes(); + if(_m.isNotNull()) + _m->clearNonDiscrAttributes(); } } void MEDFileUMesh::setName(const std::string& name) { - for(std::vector< MCAuto >::iterator it=_ms.begin();it!=_ms.end();it++) - if((*it).isNotNull()) - (*it)->setName(name); + for(auto & _m : _ms) + if(_m.isNotNull()) + _m->setName(name); MEDFileMesh::setName(name); } MEDFileUMesh::MEDFileUMesh() -{ -} += default; MEDFileUMesh::MEDFileUMesh(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs) try @@ -3006,7 +3037,7 @@ void MEDFileMesh::loadJointsFromFile(med_idt fid, MEDFileJoints* toUseInstedOfRe void MEDFileMesh::loadEquivalences(med_idt fid) { - int nbOfEq(MEDFileEquivalences::PresenceOfEquivalences(fid,_name)); + int const nbOfEq(MEDFileEquivalences::PresenceOfEquivalences(fid,_name)); if(nbOfEq>0) _equiv=MEDFileEquivalences::Load(fid,nbOfEq,this); } @@ -3115,14 +3146,14 @@ void MEDFileUMesh::loadLL(med_idt fid, const std::string& mName, int dt, int it, void MEDFileUMesh::dispatchLoadedPart(med_idt fid, const MEDFileUMeshL2& loaderl2, const std::string& mName, MEDFileMeshReadSelector *mrs) { - int lev=loaderl2.getNumberOfLevels(); + int const lev=loaderl2.getNumberOfLevels(); _ms.resize(lev); for(int i=0;i desc=MEDLoaderBase::buildEmptyString(MED_COMMENT_SIZE); MEDLoaderBase::safeStrCpy(_name.c_str(),MED_NAME_SIZE,maa,_too_long_str); MEDLoaderBase::safeStrCpy(_desc_name.c_str(),MED_COMMENT_SIZE,desc,_too_long_str); - int spaceDim=(int)(coo?coo->getNumberOfComponents():0); + int const spaceDim=(int)(coo?coo->getNumberOfComponents():0); int mdim(0); if(!_ms.empty()) mdim=getMeshDimension(); @@ -3164,7 +3194,7 @@ void MEDFileUMesh::writeMeshLL(med_idt fid) const INTERP_KERNEL::AutoPtr unit=MEDLoaderBase::buildEmptyString(spaceDim*MED_SNAME_SIZE); for(int i=0;igetInfoOnComponent(i); + std::string const info=coo->getInfoOnComponent(i); std::string c,u; MEDLoaderBase::splitIntoNameAndUnit(info,c,u); MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);//MED_TAILLE_PNOM-1 to avoid to write '\0' on next compo @@ -3173,13 +3203,13 @@ void MEDFileUMesh::writeMeshLL(med_idt fid) const MEDFILESAFECALLERWR0(MEDmeshCr,(fid,maa,spaceDim,mdim,MED_UNSTRUCTURED_MESH,desc,"",MED_SORT_DTIT,MEDFileMeshL2::TraduceAxisTypeRev(getAxisType()),comp,unit)); if(_univ_wr_status) MEDFILESAFECALLERWR0(MEDmeshUniversalNameWr,(fid,maa)); - std::string meshName(MEDLoaderBase::buildStringFromFortran(maa,MED_NAME_SIZE)); + std::string const meshName(MEDLoaderBase::buildStringFromFortran(maa,MED_NAME_SIZE)); MEDFileUMeshL2::WriteCoords(fid,meshName,_iteration,_order,_time,_coords,_fam_coords,_num_coords,_name_coords,_global_num_coords); - for(std::vector< MCAuto >::const_iterator it=_ms.begin();it!=_ms.end();it++) - if(it->isNotNull()) + for(const auto & _m : _ms) + if(_m.isNotNull()) { - (*it)->checkCoordsConsistency(coo); - (*it)->write(fid,meshName,mdim); + _m->checkCoordsConsistency(coo); + _m->write(fid,meshName,mdim); } MEDFileUMeshL2::WriteFamiliesAndGrps(fid,meshName,_families,_groups,_too_long_str); } @@ -3192,8 +3222,8 @@ std::vector MEDFileUMesh::getNonEmptyLevels() const { std::vector ret; int lev=0; - for(std::vector< MCAuto >::const_iterator it=_ms.begin();it!=_ms.end();it++,lev--) - if((const MEDFileUMeshSplitL1 *)(*it)!=0) + for(auto it=_ms.begin();it!=_ms.end();it++,lev--) + if((const MEDFileUMeshSplitL1 *)(*it)!=nullptr) if(!(*it)->empty()) ret.push_back(lev); return ret; @@ -3223,7 +3253,7 @@ std::vector MEDFileUMesh::getFamArrNonEmptyLevelsExt() const if(famCoo) ret.push_back(1); int lev=0; - for(std::vector< MCAuto >::const_iterator it=_ms.begin();it!=_ms.end();it++,lev--) + for(auto it=_ms.begin();it!=_ms.end();it++,lev--) { const MEDFileUMeshSplitL1 *cur(*it); if(cur) @@ -3239,7 +3269,7 @@ std::vector MEDFileUMesh::getNumArrNonEmptyLevelsExt() const if(_num_coords.isNotNull()) ret.push_back(1); int lev=0; - for(std::vector< MCAuto >::const_iterator it=_ms.begin();it!=_ms.end();it++,lev--) + for(auto it=_ms.begin();it!=_ms.end();it++,lev--) { const MEDFileUMeshSplitL1 *cur(*it); if(cur) @@ -3256,7 +3286,7 @@ std::vector MEDFileUMesh::getNameArrNonEmptyLevelsExt() const if(nameCoo) ret.push_back(1); int lev=0; - for(std::vector< MCAuto >::const_iterator it=_ms.begin();it!=_ms.end();it++,lev--) + for(auto it=_ms.begin();it!=_ms.end();it++,lev--) { const MEDFileUMeshSplitL1 *cur(*it); if(cur) @@ -3275,11 +3305,11 @@ std::vector MEDFileUMesh::getNameArrNonEmptyLevelsExt() const std::vector MEDFileUMesh::getFamsNonEmptyLevels(const std::vector& fams) const { std::vector ret; - std::vector levs(getNonEmptyLevels()); - std::vector famIds(getFamiliesIds(fams)); - for(std::vector::const_iterator it=levs.begin();it!=levs.end();it++) - if(_ms[-(*it)]->presenceOfOneFams(famIds)) - ret.push_back(*it); + std::vector const levs(getNonEmptyLevels()); + std::vector const famIds(getFamiliesIds(fams)); + for(int lev : levs) + if(_ms[-lev]->presenceOfOneFams(famIds)) + ret.push_back(lev); return ret; } @@ -3294,7 +3324,7 @@ std::vector MEDFileUMesh::getFamsNonEmptyLevelsExt(const std::vector famIds(getFamiliesIds(fams)); + std::vector const famIds(getFamiliesIds(fams)); if(famCoords->presenceOfValue(famIds)) { std::vector ret(ret0.size()+1); @@ -3311,17 +3341,17 @@ mcIdType MEDFileUMesh::getMaxAbsFamilyIdInArrays() const mcIdType ret=-std::numeric_limits::max(),tmp=-1; if((const DataArrayIdType *)_fam_coords) { - mcIdType val=_fam_coords->getMaxValue(tmp); + mcIdType const val=_fam_coords->getMaxValue(tmp); ret=std::max(ret,std::abs(val)); } - for(std::vector< MCAuto >::const_iterator it=_ms.begin();it!=_ms.end();it++) + for(const auto & _m : _ms) { - if((const MEDFileUMeshSplitL1 *)(*it)) + if((const MEDFileUMeshSplitL1 *)_m) { - const DataArrayIdType *da=(*it)->getFamilyField(); + const DataArrayIdType *da=_m->getFamilyField(); if(da) { - mcIdType val=da->getMaxValue(tmp); + mcIdType const val=da->getMaxValue(tmp); ret=std::max(ret,std::abs(val)); } } @@ -3334,17 +3364,17 @@ mcIdType MEDFileUMesh::getMaxFamilyIdInArrays() const mcIdType ret=-std::numeric_limits::max(),tmp=-1; if((const DataArrayIdType *)_fam_coords) { - mcIdType val=_fam_coords->getMaxValue(tmp); + mcIdType const val=_fam_coords->getMaxValue(tmp); ret=std::max(ret,val); } - for(std::vector< MCAuto >::const_iterator it=_ms.begin();it!=_ms.end();it++) + for(const auto & _m : _ms) { - if((const MEDFileUMeshSplitL1 *)(*it)) + if((const MEDFileUMeshSplitL1 *)_m) { - const DataArrayIdType *da=(*it)->getFamilyField(); + const DataArrayIdType *da=_m->getFamilyField(); if(da) { - mcIdType val=da->getMaxValue(tmp); + mcIdType const val=da->getMaxValue(tmp); ret=std::max(ret,val); } } @@ -3357,17 +3387,17 @@ mcIdType MEDFileUMesh::getMinFamilyIdInArrays() const mcIdType ret=std::numeric_limits::max(),tmp=-1; if((const DataArrayIdType *)_fam_coords) { - mcIdType val=_fam_coords->getMinValue(tmp); + mcIdType const val=_fam_coords->getMinValue(tmp); ret=std::min(ret,val); } - for(std::vector< MCAuto >::const_iterator it=_ms.begin();it!=_ms.end();it++) + for(const auto & _m : _ms) { - if((const MEDFileUMeshSplitL1 *)(*it)) + if((const MEDFileUMeshSplitL1 *)_m) { - const DataArrayIdType *da=(*it)->getFamilyField(); + const DataArrayIdType *da=_m->getFamilyField(); if(da) { - mcIdType val=da->getMinValue(tmp); + mcIdType const val=da->getMinValue(tmp); ret=std::min(ret,val); } } @@ -3383,8 +3413,8 @@ mcIdType MEDFileUMesh::getMinFamilyIdInArrays() const int MEDFileUMesh::getMeshDimension() const { int lev=0; - for(std::vector< MCAuto >::const_iterator it=_ms.begin();it!=_ms.end();it++,lev++) - if((const MEDFileUMeshSplitL1 *)(*it)!=0) + for(auto it=_ms.begin();it!=_ms.end();it++,lev++) + if((const MEDFileUMeshSplitL1 *)(*it)!=nullptr) return (*it)->getMeshDimension()+lev; throw INTERP_KERNEL::Exception("MEDFileUMesh::getMeshDimension : impossible to find a mesh dimension !"); } @@ -3425,7 +3455,7 @@ std::string MEDFileUMesh::simpleRepr() const oss << _coords->getNumberOfTuples() << std::endl; else oss << MSG1 << std::endl; - std::size_t nbOfLev=_ms.size(); + std::size_t const nbOfLev=_ms.size(); oss << "- Number of levels allocated : " << nbOfLev << std::endl; for(std::size_t i=0;i& nodesFetched) const { - std::size_t sz(st.getNumberOfItems()); + std::size_t const sz(st.getNumberOfItems()); for(std::size_t i=0;icomputeNodeIdsAlg(nodesFetched); @@ -3608,9 +3638,9 @@ MEDFileMesh *MEDFileUMesh::cartesianize() const if(!coords) throw INTERP_KERNEL::Exception("MEDFileUMesh::cartesianize : coordinates are null !"); MCAuto coordsCart(_coords->cartesianize(getAxisType())); - for(std::vector< MCAuto >::iterator it=ret->_ms.begin();it!=ret->_ms.end();it++) - if((const MEDFileUMeshSplitL1 *)(*it)) - *it=(*it)->shallowCpyUsingCoords(coordsCart); + for(auto & _m : ret->_ms) + if((const MEDFileUMeshSplitL1 *)_m) + _m=_m->shallowCpyUsingCoords(coordsCart); ret->_coords=coordsCart; ret->setAxisType(AX_CART); return ret.retn(); @@ -3619,8 +3649,8 @@ MEDFileMesh *MEDFileUMesh::cartesianize() const bool MEDFileUMesh::presenceOfStructureElements() const { - for(std::vector< MCAuto >::const_iterator it=_elt_str.begin();it!=_elt_str.end();it++) - if((*it).isNotNull()) + for(const auto & it : _elt_str) + if(it.isNotNull()) return true; return false; } @@ -3662,7 +3692,7 @@ DataArrayDouble *MEDFileUMesh::getCoords() const { return tmp; } - return 0; + return nullptr; } /*! @@ -3706,7 +3736,7 @@ MEDCouplingUMesh *MEDFileUMesh::getGroups(int meshDimRelToMaxExt, const std::vec { checkCartesian(); synchronizeTinyInfoOnLeaves(); - std::vector fams2=getFamiliesOnGroups(grps); + std::vector const fams2=getFamiliesOnGroups(grps); MCAuto zeRet=getFamilies(meshDimRelToMaxExt,fams2,renum); if(grps.size()==1 && ((MEDCouplingUMesh *)zeRet)) zeRet->setName(grps[0]); @@ -3768,7 +3798,7 @@ MEDCouplingUMesh *MEDFileUMesh::getFamilies(int meshDimRelToMaxExt, const std::v if(!famIds.empty()) zeRet=l1->getFamilyPart(&famIds[0],&famIds[0]+famIds.size(),renum); else - zeRet=l1->getFamilyPart(0,0,renum); + zeRet=l1->getFamilyPart(nullptr,nullptr,renum); if(fams.size()==1 && ((MEDCouplingUMesh *)zeRet)) zeRet->setName(fams[0]); return zeRet.retn(); @@ -3797,7 +3827,7 @@ DataArrayIdType *MEDFileUMesh::getFamiliesArr(int meshDimRelToMaxExt, const std: if(!famIds.empty()) da=_fam_coords->findIdsEqualList(&famIds[0],&famIds[0]+famIds.size()); else - da=_fam_coords->findIdsEqualList(0,0); + da=_fam_coords->findIdsEqualList(nullptr,nullptr); if(renum) return MEDFileUMeshSplitL1::Renumber(_num_coords,da); else @@ -3814,7 +3844,7 @@ DataArrayIdType *MEDFileUMesh::getFamiliesArr(int meshDimRelToMaxExt, const std: if(!famIds.empty()) return l1->getFamilyPartArr(&famIds[0],&famIds[0]+famIds.size(),renum); else - return l1->getFamilyPartArr(0,0,renum); + return l1->getFamilyPartArr(nullptr,nullptr,renum); } /*! @@ -3839,7 +3869,7 @@ MEDCouplingUMesh *MEDFileUMesh::getMeshAtLevel(int meshDimRelToMaxExt, bool renu if(!renum) { MEDCouplingUMesh *umesh=MEDCouplingUMesh::New(); - MCAuto cc=_coords->deepCopy(); + MCAuto const cc=_coords->deepCopy(); umesh->setCoords(cc); MEDFileUMeshSplitL1::ClearNonDiscrAttributes(umesh); umesh->setName(getName()); @@ -3914,9 +3944,9 @@ MEDCouplingUMesh *MEDFileUMesh::getLevelM3Mesh(bool renum) const */ void MEDFileUMesh::declarePartsUpdated() const { - for(std::vector< MCAuto >::const_iterator it=_ms.begin();it!=_ms.end();it++) + for(const auto & _m : _ms) { - const MEDFileUMeshSplitL1 *elt(*it); + const MEDFileUMeshSplitL1 *elt(_m); if(elt) elt->declarePartsUpdated(); } @@ -3932,9 +3962,9 @@ void MEDFileUMesh::declarePartsUpdated() const */ void MEDFileUMesh::forceComputationOfParts() const { - for(std::vector< MCAuto >::const_iterator it=_ms.begin();it!=_ms.end();it++) + for(const auto & _m : _ms) { - const MEDFileUMeshSplitL1 *elt(*it); + const MEDFileUMeshSplitL1 *elt(_m); if(elt) elt->forceComputationOfParts(); } @@ -3962,7 +3992,7 @@ MEDCoupling1GTUMesh *MEDFileUMesh::getDirectUndergroundSingleGeoTypeMesh(INTERP_ { checkCartesian(); const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(gt)); - int lev=(int)cm.getDimension()-getMeshDimension(); + int const lev=(int)cm.getDimension()-getMeshDimension(); const MEDFileUMeshSplitL1 *sp(getMeshAtLevSafe(lev)); return sp->getDirectUndergroundSingleGeoTypeMesh(gt); } @@ -3978,13 +4008,13 @@ std::vector< std::pair > MEDFileUMesh::getAllDistributionOfTypes() { std::vector< std::pair > ret; std::vector nel(getNonEmptyLevels()); - for(std::vector::reverse_iterator it=nel.rbegin();it!=nel.rend();it++) + for(auto it=nel.rbegin();it!=nel.rend();it++) { - std::vector gt(getGeoTypesAtLevel(*it)); - for(std::vector::const_iterator it1=gt.begin();it1!=gt.end();it1++) + std::vector const gt(getGeoTypesAtLevel(*it)); + for(auto it1 : gt) { - mcIdType nbCells(getNumberOfCellsWithType(*it1)); - ret.push_back(std::pair(*it1,nbCells)); + mcIdType const nbCells(getNumberOfCellsWithType(it1)); + ret.push_back(std::pair(it1,nbCells)); } } ret.push_back(std::pair(INTERP_KERNEL::NORM_ERROR,getNumberOfNodes())); @@ -4018,7 +4048,7 @@ mcIdType MEDFileUMesh::getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellTyp DataArrayIdType *MEDFileUMesh::extractFamilyFieldOnGeoType(INTERP_KERNEL::NormalizedCellType gt) const { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(gt); - int lev=(int)cm.getDimension()-getMeshDimension(); + int const lev=(int)cm.getDimension()-getMeshDimension(); const MEDFileUMeshSplitL1 *sp(getMeshAtLevSafe(lev)); return sp->extractFamilyFieldOnGeoType(gt); } @@ -4033,7 +4063,7 @@ DataArrayIdType *MEDFileUMesh::extractFamilyFieldOnGeoType(INTERP_KERNEL::Normal DataArrayIdType *MEDFileUMesh::extractNumberFieldOnGeoType(INTERP_KERNEL::NormalizedCellType gt) const { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(gt); - int lev=(int)cm.getDimension()-getMeshDimension(); + int const lev=(int)cm.getDimension()-getMeshDimension(); const MEDFileUMeshSplitL1 *sp(getMeshAtLevSafe(lev)); return sp->extractNumberFieldOnGeoType(gt); } @@ -4045,7 +4075,7 @@ DataArrayIdType *MEDFileUMesh::extractNumberFieldOnGeoType(INTERP_KERNEL::Normal int MEDFileUMesh::getRelativeLevOnGeoType(INTERP_KERNEL::NormalizedCellType gt) const { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(gt); - int ret((int)cm.getDimension()-getMeshDimension()); + int const ret((int)cm.getDimension()-getMeshDimension()); getMeshAtLevSafe(ret);//To test that returned value corresponds to a valid level. return ret; } @@ -4056,10 +4086,10 @@ const MEDFileUMeshSplitL1 *MEDFileUMesh::getMeshAtLevSafe(int meshDimRelToMaxExt throw INTERP_KERNEL::Exception("Dimension request is invalid : asking for node level (1) !"); if(meshDimRelToMaxExt>1) throw INTERP_KERNEL::Exception("Dimension request is invalid (>1) !"); - int tracucedRk=-meshDimRelToMaxExt; + int const tracucedRk=-meshDimRelToMaxExt; if(tracucedRk>=(int)_ms.size()) throw INTERP_KERNEL::Exception("Invalid mesh dim relative to max given ! Too low !"); - if((const MEDFileUMeshSplitL1 *)_ms[tracucedRk]==0) + if((const MEDFileUMeshSplitL1 *)_ms[tracucedRk]==nullptr) throw INTERP_KERNEL::Exception("On specified lev (or entity) no cells exists !"); return _ms[tracucedRk]; } @@ -4070,10 +4100,10 @@ MEDFileUMeshSplitL1 *MEDFileUMesh::getMeshAtLevSafe(int meshDimRelToMaxExt) throw INTERP_KERNEL::Exception("Dimension request is invalid : asking for node level (1) !"); if(meshDimRelToMaxExt>1) throw INTERP_KERNEL::Exception("Dimension request is invalid (>1) !"); - int tracucedRk=-meshDimRelToMaxExt; + int const tracucedRk=-meshDimRelToMaxExt; if(tracucedRk>=(int)_ms.size()) throw INTERP_KERNEL::Exception("Invalid mesh dim relative to max given ! Too low !"); - if((const MEDFileUMeshSplitL1 *)_ms[tracucedRk]==0) + if((const MEDFileUMeshSplitL1 *)_ms[tracucedRk]==nullptr) throw INTERP_KERNEL::Exception("On specified lev (or entity) no cells exists !"); return _ms[tracucedRk]; } @@ -4083,11 +4113,11 @@ void MEDFileUMesh::checkMeshDimCoherency(int meshDim, int meshDimRelToMax) const if(-meshDimRelToMax>=(int)_ms.size()) throw INTERP_KERNEL::Exception("MEDFileUMesh::checkMeshDimCoherency : The meshdim of mesh is not managed by 'this' !"); int i=0; - for(std::vector< MCAuto >::const_iterator it=_ms.begin();it!=_ms.end();it++,i++) + for(auto it=_ms.begin();it!=_ms.end();it++,i++) { - if(((const MEDFileUMeshSplitL1*) (*it))!=0) + if(((const MEDFileUMeshSplitL1*) (*it))!=nullptr) { - int ref=(*it)->getMeshDimension(); + int const ref=(*it)->getMeshDimension(); if(ref+i!=meshDim-meshDimRelToMax) throw INTERP_KERNEL::Exception("MEDFileUMesh::checkMeshDimCoherency : no coherency between levels !"); } @@ -4106,15 +4136,15 @@ void MEDFileUMesh::setCoords(DataArrayDouble *coords) if(coords==(DataArrayDouble *)_coords) return ; coords->checkAllocated(); - mcIdType nbOfTuples(coords->getNumberOfTuples()); + mcIdType const nbOfTuples(coords->getNumberOfTuples()); _coords.takeRef(coords); _fam_coords=DataArrayIdType::New(); _fam_coords->alloc(nbOfTuples,1); _fam_coords->fillWithZero(); _num_coords.nullify(); _rev_num_coords.nullify(); _name_coords.nullify(); _global_num_coords.nullify(); - for(std::vector< MCAuto >::iterator it=_ms.begin();it!=_ms.end();it++) - if((MEDFileUMeshSplitL1 *)(*it)) - (*it)->setCoords(coords); + for(auto & _m : _ms) + if((MEDFileUMeshSplitL1 *)_m) + _m->setCoords(coords); } /*! @@ -4127,7 +4157,7 @@ void MEDFileUMesh::setCoordsForced(DataArrayDouble *coords) if(coords==(DataArrayDouble *)_coords) return ; coords->checkAllocated(); - mcIdType nbOfTuples(coords->getNumberOfTuples()); + mcIdType const nbOfTuples(coords->getNumberOfTuples()); if(_coords.isNull()) { _coords=coords; @@ -4135,15 +4165,15 @@ void MEDFileUMesh::setCoordsForced(DataArrayDouble *coords) } else { - mcIdType oldNbTuples(_coords->getNumberOfTuples()); + mcIdType const oldNbTuples(_coords->getNumberOfTuples()); if(oldNbTuples!=nbOfTuples) throw INTERP_KERNEL::Exception("MEDFileUMesh::setCoordsForced : number of tuples is not the same -> invoke setCoords instead !"); _coords=coords; coords->incrRef(); } - for(std::vector< MCAuto >::iterator it=_ms.begin();it!=_ms.end();it++) - if((MEDFileUMeshSplitL1 *)(*it)) - (*it)->setCoords(coords); + for(auto & _m : _ms) + if((MEDFileUMeshSplitL1 *)_m) + _m->setCoords(coords); } /*! @@ -4169,11 +4199,11 @@ void MEDFileUMesh::eraseGroupsAtLevel(int meshDimRelToMaxExt) */ void MEDFileUMesh::optimizeFamilies() { - std::vector levs=getNonEmptyLevelsExt(); + std::vector const levs=getNonEmptyLevelsExt(); std::set allFamsIds; - for(std::vector::const_iterator it=levs.begin();it!=levs.end();it++) + for(int const lev : levs) { - const DataArrayIdType *ffield=getFamilyFieldAtLevel(*it); + const DataArrayIdType *ffield=getFamilyFieldAtLevel(lev); MCAuto ids=ffield->getDifferentValues(); std::set res; std::set_union(ids->begin(),ids->end(),allFamsIds.begin(),allFamsIds.end(),std::inserter(res,res.begin())); @@ -4185,24 +4215,24 @@ void MEDFileUMesh::optimizeFamilies() if(allFamsIds.find((*it).second)!=allFamsIds.end()) famNamesToKill.insert((*it).first); } - for(std::set::const_iterator it=famNamesToKill.begin();it!=famNamesToKill.end();it++) - _families.erase(*it); - std::vector grpNamesToKill; - for(std::map >::iterator it=_groups.begin();it!=_groups.end();it++) + for(const auto & it : famNamesToKill) + _families.erase(it); + std::vector const grpNamesToKill; + for(auto & _group : _groups) { std::vector tmp; - for(std::vector::const_iterator it2=(*it).second.begin();it2!=(*it).second.end();it2++) + for(const auto & it2 : _group.second) { - if(famNamesToKill.find(*it2)==famNamesToKill.end()) - tmp.push_back(*it2); + if(famNamesToKill.find(it2)==famNamesToKill.end()) + tmp.push_back(it2); } if(!tmp.empty()) - (*it).second=tmp; + _group.second=tmp; else - tmp.push_back((*it).first); + tmp.push_back(_group.first); } - for(std::vector::const_iterator it=grpNamesToKill.begin();it!=grpNamesToKill.end();it++) - _groups.erase(*it); + for(const auto & it : grpNamesToKill) + _groups.erase(it); } /** @@ -4284,9 +4314,9 @@ void MEDFileUMesh::buildInnerBoundaryAlongM1Group(const std::string& grpNameM1, throw INTERP_KERNEL::Exception("MEDFileUMesh::buildInnerBoundaryAlongM1Group : This method works only for mesh defined on level 0 and -1 !"); MUMesh m0=getMeshAtLevel(0); MUMesh m1=getMeshAtLevel(-1); - mcIdType nbNodes=m0->getNumberOfNodes(); + mcIdType const nbNodes=m0->getNumberOfNodes(); MUMesh m11=getGroup(-1,grpNameM1); - DataArrayIdType *tmp00=0, *tmp11=0,*tmp22=0; + DataArrayIdType *tmp00=nullptr, *tmp11=nullptr,*tmp22=nullptr; // !!! The core of the duplication logic is in these 2 methods: // !!! @@ -4300,10 +4330,10 @@ void MEDFileUMesh::buildInnerBoundaryAlongM1Group(const std::string& grpNameM1, // node renumbering of cells in m1 impacted by duplication of node but not in group 'grpNameM1' on level -1 DAInt descTmp0=DataArrayIdType::New(),descITmp0=DataArrayIdType::New(),revDescTmp0=DataArrayIdType::New(),revDescITmp0=DataArrayIdType::New(); MUMesh tmp0Desc=tmp0->buildDescendingConnectivity(descTmp0,descITmp0,revDescTmp0,revDescITmp0); - descTmp0=0; descITmp0=0; revDescTmp0=0; revDescITmp0=0; + descTmp0=nullptr; descITmp0=nullptr; revDescTmp0=nullptr; revDescITmp0=nullptr; DAInt cellsInM1ToRenumW2=tmp0Desc->getCellIdsLyingOnNodes(nodeIdsToDuplicate->begin(),nodeIdsToDuplicate->end(),false); MUMesh cellsInM1ToRenumW3=static_cast(tmp0Desc->buildPartOfMySelf(cellsInM1ToRenumW2->begin(),cellsInM1ToRenumW2->end(),true)); - DataArrayIdType *cellsInM1ToRenumW4Tmp=0; + DataArrayIdType *cellsInM1ToRenumW4Tmp=nullptr; m1->areCellsIncludedIn(cellsInM1ToRenumW3,2,cellsInM1ToRenumW4Tmp); DAInt cellsInM1ToRenumW4(cellsInM1ToRenumW4Tmp); DAInt cellsInM1ToRenumW5=cellsInM1ToRenumW4->findIdsInRange(0,m1->getNumberOfCells()); @@ -4345,7 +4375,7 @@ void MEDFileUMesh::buildInnerBoundaryAlongM1Group(const std::string& grpNameM1, else idd=getMinFamilyId()-1; mcIdType globStart=0,start=0,end,globEnd; - mcIdType nbOfChunks=szOfCellGrpOfSameType->getNumberOfTuples(); + mcIdType const nbOfChunks=szOfCellGrpOfSameType->getNumberOfTuples(); for(mcIdType i=0;igetIJ(i,0); @@ -4372,7 +4402,7 @@ void MEDFileUMesh::buildInnerBoundaryAlongM1Group(const std::string& grpNameM1, fam=_fam_coords; if(fam) { - mcIdType newNbOfNodes=getCoords()->getNumberOfTuples(); + mcIdType const newNbOfNodes=getCoords()->getNumberOfTuples(); newFam=DataArrayIdType::New(); newFam->alloc(newNbOfNodes,1); newFam->setPartOfValues1(fam,0,nbNodes,1,0,1,1,true); newFam->setPartOfValuesSimple1(0,nbNodes,newNbOfNodes,1,0,1,1); @@ -4381,11 +4411,10 @@ void MEDFileUMesh::buildInnerBoundaryAlongM1Group(const std::string& grpNameM1, _num_coords.nullify(); _rev_num_coords.nullify(); _global_num_coords.nullify(); - for (std::vector< MCAuto >::iterator it=_ms.begin(); - it != _ms.end(); it++) + for (auto & _m : _ms) { - (*it)->_num = 0; - (*it)->_rev_num = 0; + _m->_num = nullptr; + _m->_rev_num = nullptr; } nodesDuplicated=nodeIdsToDuplicate.retn(); cellsModified=cellsToModifyConn0.retn(); @@ -4405,21 +4434,21 @@ void MEDFileUMesh::buildInnerBoundaryAlongM1Group(const std::string& grpNameM1, */ bool MEDFileUMesh::unPolyze(std::vector& oldCode, std::vector& newCode, DataArrayIdType *& o2nRenumCell) { - o2nRenumCell=0; oldCode.clear(); newCode.clear(); + o2nRenumCell=nullptr; oldCode.clear(); newCode.clear(); std::vector levs=getNonEmptyLevels(); bool ret=false; std::vector< const DataArrayIdType* > renumCellsSplited;//same than memorySaverIfThrow std::vector< MCAuto > memorySaverIfThrow;//same than renumCellsSplited only in case of throw mcIdType start=0; mcIdType end=0; - for(std::vector::reverse_iterator it=levs.rbegin();it!=levs.rend();it++) + for(auto it=levs.rbegin();it!=levs.rend();it++) { MCAuto m=getMeshAtLevel(*it); std::vector code1=m->getDistributionOfTypes(); end=PutInThirdComponentOfCodeOffset(code1,start); oldCode.insert(oldCode.end(),code1.begin(),code1.end()); - bool hasChanged=m->unPolyze(); - DataArrayIdType *fake=0; + bool const hasChanged=m->unPolyze(); + DataArrayIdType *fake=nullptr; MCAuto o2nCellsPart=m->getLevArrPerCellTypes(MEDCouplingUMesh::MEDMEM_ORDER, MEDCouplingUMesh::MEDMEM_ORDER+MEDCouplingUMesh::N_MEDMEM_ORDER,fake); fake->decrRef(); @@ -4468,9 +4497,9 @@ bool MEDFileUMesh::unPolyze(std::vector& oldCode, std::vectorgetNumberOfTuples()); + mcIdType const nbOfNodes(coo->getNumberOfTuples()); std::vector nodeIdsInUse(nbOfNodes,false); - std::vector neLevs(getNonEmptyLevels()); - for(std::vector::const_iterator lev=neLevs.begin();lev!=neLevs.end();lev++) + std::vector const neLevs(getNonEmptyLevels()); + for(int const neLev : neLevs) { - const MEDFileUMeshSplitL1 *zeLev(getMeshAtLevSafe(*lev)); + const MEDFileUMeshSplitL1 *zeLev(getMeshAtLevSafe(neLev)); if(zeLev->isMeshStoredSplitByType()) { - std::vector ms(zeLev->getDirectUndergroundSingleGeoTypeMeshes()); - for(std::vector::const_iterator it=ms.begin();it!=ms.end();it++) - if(*it) - (*it)->computeNodeIdsAlg(nodeIdsInUse); + std::vector const ms(zeLev->getDirectUndergroundSingleGeoTypeMeshes()); + for(auto m : ms) + if(m) + m->computeNodeIdsAlg(nodeIdsInUse); } else { @@ -4509,13 +4538,13 @@ DataArrayIdType *MEDFileUMesh::zipCoords() mesh->computeNodeIdsAlg(nodeIdsInUse); } } - mcIdType nbrOfNodesInUse((mcIdType)std::count(nodeIdsInUse.begin(),nodeIdsInUse.end(),true)); + auto nbrOfNodesInUse((mcIdType)std::count(nodeIdsInUse.begin(),nodeIdsInUse.end(),true)); if(nbrOfNodesInUse==nbOfNodes) - return 0;//no need to update _part_coords + return nullptr;//no need to update _part_coords MCAuto ret(DataArrayIdType::New()); ret->alloc(nbOfNodes,1); std::transform(nodeIdsInUse.begin(),nodeIdsInUse.end(),ret->getPointer(),MEDLoaderAccVisit1()); MCAuto ret2(ret->invertArrayO2N2N2OBis(nbrOfNodesInUse)); - MCAuto newCoords(coo->selectByTupleIdSafe(ret2->begin(),ret2->end())); + MCAuto const newCoords(coo->selectByTupleIdSafe(ret2->begin(),ret2->end())); MCAuto newFamCoords; MCAuto newNameCoords; if((const DataArrayIdType *)_fam_coords) @@ -4528,12 +4557,12 @@ DataArrayIdType *MEDFileUMesh::zipCoords() if(_name_coords.isNotNull()) newNameCoords=static_cast(_name_coords->selectByTupleIdSafe(ret2->begin(),ret2->end())); _coords=newCoords; _fam_coords=newFamCoords; _num_coords=newNumCoords; _global_num_coords=newGlobalNumCoords; _name_coords=newNameCoords; _rev_num_coords.nullify(); - for(std::vector< MCAuto >::iterator it=_ms.begin();it!=_ms.end();it++) + for(auto & _m : _ms) { - if((MEDFileUMeshSplitL1*)*it) + if((MEDFileUMeshSplitL1*)_m) { - (*it)->renumberNodesInConn(ret->begin()); - (*it)->setCoords(_coords); + _m->renumberNodesInConn(ret->begin()); + _m->setCoords(_coords); } } // updates _part_coords @@ -4553,7 +4582,7 @@ DataArrayIdType *MEDFileUMesh::zipCoords() */ DataArrayIdType *MEDFileUMesh::computeFetchedNodeIds() const { - std::vector neLevs(this->getNonEmptyLevels()); + std::vector const neLevs(this->getNonEmptyLevels()); std::vector nodesHighlighted(this->getNumberOfNodes(),false); for(auto lev : neLevs) { @@ -4575,21 +4604,21 @@ DataArrayIdType *MEDFileUMesh::deduceNodeSubPartFromCellSubPart(const std::map levs(getNonEmptyLevels()); std::vector fetchedNodes(getNumberOfNodes(),false); - for(std::map >::const_iterator it=extractDef.begin();it!=extractDef.end();it++) + for(const auto & it : extractDef) { - if((*it).first>1) + if(it.first>1) throw INTERP_KERNEL::Exception("MEDFileUMesh::deduceNodeSubPartFromCellSubPart : invalid key ! Must be <=1 !"); - if((*it).second.isNull()) + if(it.second.isNull()) throw INTERP_KERNEL::Exception("MEDFileUMesh::deduceNodeSubPartFromCellSubPart : presence of a value with null pointer !"); - if((*it).first==1) + if(it.first==1) continue; - if(std::find(levs.begin(),levs.end(),(*it).first)==levs.end()) + if(std::find(levs.begin(),levs.end(),it.first)==levs.end()) { - std::ostringstream oss; oss << "MEDFileUMesh::deduceNodeSubPartFromCellSubPart : invalid level " << (*it).first << " ! Not present in this !"; + std::ostringstream oss; oss << "MEDFileUMesh::deduceNodeSubPartFromCellSubPart : invalid level " << it.first << " ! Not present in this !"; throw INTERP_KERNEL::Exception(oss.str()); } - MCAuto m(getMeshAtLevel((*it).first)); - MCAuto mPart(m->buildPartOfMySelf((*it).second->begin(),(*it).second->end(),true)); + MCAuto m(getMeshAtLevel(it.first)); + MCAuto mPart(m->buildPartOfMySelf(it.second->begin(),it.second->end(),true)); mPart->computeNodeIdsAlg(fetchedNodes); } return DataArrayIdType::BuildListOfSwitchedOn(fetchedNodes); @@ -4605,35 +4634,35 @@ MEDFileUMesh *MEDFileUMesh::extractPart(const std::map ret(MEDFileUMesh::New()); ret->setName(getName()); ret->copyFamGrpMapsFrom(*this); std::vector levs(getNonEmptyLevels()); - for(std::map >::const_iterator it=extractDef.begin();it!=extractDef.end();it++) + for(const auto & it : extractDef) { - if((*it).first>1) + if(it.first>1) throw INTERP_KERNEL::Exception("MEDFileUMesh::extractPart : invalid key ! Must be <=1 !"); - if((*it).second.isNull()) + if(it.second.isNull()) throw INTERP_KERNEL::Exception("MEDFileUMesh::extractPart : presence of a value with null pointer !"); - if((*it).first==1) + if(it.first==1) continue; - if(std::find(levs.begin(),levs.end(),(*it).first)==levs.end()) + if(std::find(levs.begin(),levs.end(),it.first)==levs.end()) { - std::ostringstream oss; oss << "MEDFileUMesh::extractPart : invalid level " << (*it).first << " ! Not present in this !"; + std::ostringstream oss; oss << "MEDFileUMesh::extractPart : invalid level " << it.first << " ! Not present in this !"; throw INTERP_KERNEL::Exception(oss.str()); } - MCAuto m(getMeshAtLevel((*it).first)); - MCAuto mPart(m->buildPartOfMySelf((*it).second->begin(),(*it).second->end(),true)); - ret->setMeshAtLevel((*it).first,mPart); - const DataArrayIdType *fam(getFamilyFieldAtLevel((*it).first)),*num(getNumberFieldAtLevel((*it).first)); + MCAuto m(getMeshAtLevel(it.first)); + MCAuto mPart(m->buildPartOfMySelf(it.second->begin(),it.second->end(),true)); + ret->setMeshAtLevel(it.first,mPart); + const DataArrayIdType *fam(getFamilyFieldAtLevel(it.first)),*num(getNumberFieldAtLevel(it.first)); if(fam) { - MCAuto famPart(fam->selectByTupleIdSafe((*it).second->begin(),(*it).second->end())); - ret->setFamilyFieldArr((*it).first,famPart); + MCAuto famPart(fam->selectByTupleIdSafe(it.second->begin(),it.second->end())); + ret->setFamilyFieldArr(it.first,famPart); } if(num) { - MCAuto numPart(num->selectByTupleIdSafe((*it).second->begin(),(*it).second->end())); - ret->setFamilyFieldArr((*it).first,numPart); + MCAuto numPart(num->selectByTupleIdSafe(it.second->begin(),it.second->end())); + ret->setFamilyFieldArr(it.first,numPart); } } - std::map >::const_iterator it2(extractDef.find(1)); + auto const it2(extractDef.find(1)); if(it2!=extractDef.end()) { const DataArrayDouble *coo(ret->getCoords()); @@ -4653,13 +4682,13 @@ MEDFileUMesh *MEDFileUMesh::extractPart(const std::map numPart(num->selectByTupleIdSafe((*it2).second->begin(),(*it2).second->end())); ret->setFamilyFieldArr(1,numPart); } - for(std::map >::const_iterator it3=extractDef.begin();it3!=extractDef.end();it3++) + for(const auto & it3 : extractDef) { - if((*it3).first==1) + if(it3.first==1) continue; - MCAuto m(ret->getMeshAtLevel((*it3).first)); + MCAuto m(ret->getMeshAtLevel(it3.first)); m->renumberNodesInConn(o2nNodes->begin()); - ret->setMeshAtLevel((*it3).first,m); + ret->setMeshAtLevel(it3.first,m); } } return ret.retn(); @@ -4688,35 +4717,35 @@ MEDFileUMesh *MEDFileUMesh::buildExtrudedMesh(const MEDCouplingUMesh *m1D, int p m1D->checkConsistencyLight(); if(m1D->getMeshDimension()!=1) throw INTERP_KERNEL::Exception("MEDFileUMesh::buildExtrudedMesh : input mesh must have a mesh dimension equal to one !"); - mcIdType nbRep(m1D->getNumberOfCells()); + mcIdType const nbRep(m1D->getNumberOfCells()); std::vector levs(getNonEmptyLevels()); - std::vector grps(getGroupsNames()); + std::vector const grps(getGroupsNames()); std::vector< MCAuto > zeList; - DataArrayDouble *coords(0); - std::size_t nbOfLevsOut(levs.size()+1); + DataArrayDouble *coords(nullptr); + std::size_t const nbOfLevsOut(levs.size()+1); std::vector< MCAuto > o2ns(nbOfLevsOut); - for(std::vector::const_iterator lev=levs.begin();lev!=levs.end();lev++) + for(int const lev : levs) { - MCAuto item(getMeshAtLevel(*lev)); + MCAuto item(getMeshAtLevel(lev)); item=item->clone(false); - item->changeSpaceDimension(3+(*lev),0.);//no problem non const but change DataArrayDouble for coordinates do not alter data + item->changeSpaceDimension(3+lev,0.);//no problem non const but change DataArrayDouble for coordinates do not alter data MCAuto tmp(static_cast(m1D->deepCopy())); - tmp->changeSpaceDimension(3+(*lev),0.); + tmp->changeSpaceDimension(3+lev,0.); MCAuto elt(item->buildExtrudedMesh(tmp,policy)); zeList.push_back(elt); - if(*lev==0) + if(lev==0) coords=elt->getCoords(); } if(!coords) throw INTERP_KERNEL::Exception("MEDFileUMesh::buildExtrudedMesh : internal error !"); - for(std::vector< MCAuto >::iterator it=zeList.begin();it!=zeList.end();it++) + for(auto & it : zeList) { - (*it)->setName(getName()); - (*it)->setCoords(coords); + it->setName(getName()); + it->setCoords(coords); } for(std::size_t ii=0;ii!=zeList.size();ii++) { - int lev(levs[ii]); + int const lev(levs[ii]); MCAuto elt(zeList[ii]); if(lev<=-1) { @@ -4747,19 +4776,19 @@ MEDFileUMesh *MEDFileUMesh::buildExtrudedMesh(const MEDCouplingUMesh *m1D, int p // for(std::size_t ii=0;ii!=zeList.size();ii++) { - int lev(levs[ii]); + int const lev(levs[ii]); std::vector< MCAuto > outGrps; std::vector< const DataArrayIdType * > outGrps2; if(lev<=-1) { - for(std::vector::const_iterator grp=grps.begin();grp!=grps.end();grp++) + for(const auto & grp : grps) { - MCAuto grpArr(getGroupArr(lev+1,*grp)); + MCAuto grpArr(getGroupArr(lev+1,grp)); if(!grpArr->empty()) { MCAuto grpArr1(grpArr->deepCopy()),grpArr2(grpArr->deepCopy()); - mcIdType offset0(zeList[ii]->getNumberOfCells()); - mcIdType offset1(offset0+getNumberOfCellsAtLevel(lev+1)); + mcIdType const offset0(zeList[ii]->getNumberOfCells()); + mcIdType const offset1(offset0+getNumberOfCellsAtLevel(lev+1)); grpArr1->applyLin(1,offset0); grpArr2->applyLin(1,offset1); std::ostringstream oss; oss << grpArr2->getName() << "_top"; grpArr2->setName(oss.str()); @@ -4771,12 +4800,12 @@ MEDFileUMesh *MEDFileUMesh::buildExtrudedMesh(const MEDCouplingUMesh *m1D, int p } } // - for(std::vector::const_iterator grp=grps.begin();grp!=grps.end();grp++) + for(const auto & grp : grps) { - MCAuto grpArr(getGroupArr(lev,*grp)); + MCAuto grpArr(getGroupArr(lev,grp)); if(!grpArr->empty()) { - mcIdType nbCellsB4Extrusion(getNumberOfCellsAtLevel(lev)); + mcIdType const nbCellsB4Extrusion(getNumberOfCellsAtLevel(lev)); std::vector< MCAuto > grpArrs(nbRep); std::vector< const DataArrayIdType *> grpArrs2(nbRep); for(int iii=0;iii grpArrExt(DataArrayIdType::Aggregate(grpArrs2)); grpArrExt->transformWithIndArr(o2ns[ii]->begin(),o2ns[ii]->end()); - std::ostringstream grpName; grpName << *grp << "_extruded"; + std::ostringstream grpName; grpName << grp << "_extruded"; grpArrExt->setName(grpName.str()); outGrps.push_back(grpArrExt); outGrps2.push_back(grpArrExt); @@ -4796,13 +4825,13 @@ MEDFileUMesh *MEDFileUMesh::buildExtrudedMesh(const MEDCouplingUMesh *m1D, int p } std::vector< MCAuto > outGrps; std::vector< const DataArrayIdType * > outGrps2; - for(std::vector::const_iterator grp=grps.begin();grp!=grps.end();grp++) + for(const auto & grp : grps) { - MCAuto grpArr1(getGroupArr(levs.back(),*grp)); + MCAuto grpArr1(getGroupArr(levs.back(),grp)); if(grpArr1->empty()) continue; MCAuto grpArr2(grpArr1->deepCopy()); - std::ostringstream grpName; grpName << *grp << "_top"; + std::ostringstream grpName; grpName << grp << "_top"; grpArr2->setName(grpName.str()); grpArr2->applyLin(1,getNumberOfCellsAtLevel(levs.back())); outGrps.push_back(grpArr1); outGrps.push_back(grpArr2); @@ -4828,15 +4857,15 @@ MEDFileUMesh *MEDFileUMesh::linearToQuadratic(int conversionType, double eps) co { checkCartesian(); MCAuto ret(MEDFileUMesh::New()); - mcIdType initialNbNodes(getNumberOfNodes()); + mcIdType const initialNbNodes(getNumberOfNodes()); MCAuto m0Tmp(getMeshAtLevel(0)); MCAuto m0(dynamic_cast(m0Tmp->deepCopy())); { - MCAuto notUsed(m0->convertLinearCellsToQuadratic(conversionType)); + MCAuto const notUsed(m0->convertLinearCellsToQuadratic(conversionType)); } DataArrayDouble *zeCoords(m0->getCoords()); ret->setMeshAtLevel(0,m0); - std::vector levs(getNonEmptyLevels()); + std::vector const levs(getNonEmptyLevels()); const DataArrayIdType *famField(getFamilyFieldAtLevel(0)); if(famField) { @@ -4853,24 +4882,24 @@ MEDFileUMesh *MEDFileUMesh::linearToQuadratic(int conversionType, double eps) co } ret->copyFamGrpMapsFrom(*this); MCAuto partZeCoords(zeCoords->selectByTupleIdSafeSlice(initialNbNodes,zeCoords->getNumberOfTuples(),1)); - for(std::vector::const_iterator lev=levs.begin();lev!=levs.end();lev++) + for(int const lev : levs) { - if(*lev==0) + if(lev==0) continue; - MCAuto m1Tmp(getMeshAtLevel(*lev)); + MCAuto m1Tmp(getMeshAtLevel(lev)); MCAuto m1(dynamic_cast(m1Tmp->deepCopy())); if(m1->getMeshDimension()!=0) { { - MCAuto notUsed(m1->convertLinearCellsToQuadratic(conversionType)); + MCAuto const notUsed(m1->convertLinearCellsToQuadratic(conversionType)); }//kill unused notUsed var MCAuto m1Coords(m1->getCoords()->selectByTupleIdSafeSlice(initialNbNodes,m1->getNumberOfNodes(),1)); - DataArrayIdType *b(0); - bool a(partZeCoords->areIncludedInMe(m1Coords,eps,b)); - MCAuto bSafe(b); + DataArrayIdType *b(nullptr); + bool const a(partZeCoords->areIncludedInMe(m1Coords,eps,b)); + MCAuto const bSafe(b); if(!a) { - std::ostringstream oss; oss << "MEDFileUMesh::linearCellsToQuadratic : for level " << *lev << " problem to identify nodes generated !"; + std::ostringstream oss; oss << "MEDFileUMesh::linearCellsToQuadratic : for level " << lev << " problem to identify nodes generated !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } b->applyLin(1,initialNbNodes); @@ -4880,12 +4909,12 @@ MEDFileUMesh *MEDFileUMesh::linearToQuadratic(int conversionType, double eps) co m1->renumberNodesInConn(renum->begin()); } m1->setCoords(zeCoords); - ret->setMeshAtLevel(*lev,m1); - famField=getFamilyFieldAtLevel(*lev); + ret->setMeshAtLevel(lev,m1); + famField=getFamilyFieldAtLevel(lev); if(famField) { MCAuto famFieldCpy(famField->deepCopy()); - ret->setFamilyFieldArr(*lev,famFieldCpy); + ret->setFamilyFieldArr(lev,famFieldCpy); } } return ret.retn(); @@ -4911,7 +4940,7 @@ MEDFileUMesh *MEDFileUMesh::quadraticToLinear(double eps) const m0->zipCoords(); DataArrayDouble *zeCoords(m0->getCoords()); ret->setMeshAtLevel(0,m0); - std::vector levs(getNonEmptyLevels()); + std::vector const levs(getNonEmptyLevels()); const DataArrayIdType *famField(getFamilyFieldAtLevel(0)); if(famField) { @@ -4925,30 +4954,30 @@ MEDFileUMesh *MEDFileUMesh::quadraticToLinear(double eps) const ret->setFamilyFieldArr(1,fam); } ret->copyFamGrpMapsFrom(*this); - for(std::vector::const_iterator lev=levs.begin();lev!=levs.end();lev++) + for(int const lev : levs) { - if(*lev==0) + if(lev==0) continue; - MCAuto m1Tmp(getMeshAtLevel(*lev)); + MCAuto m1Tmp(getMeshAtLevel(lev)); MCAuto m1(dynamic_cast(m1Tmp->deepCopy())); m1->convertQuadraticCellsToLinear(); m1->zipCoords(); - DataArrayIdType *b(0); - bool a(zeCoords->areIncludedInMe(m1->getCoords(),eps,b)); - MCAuto bSafe(b); + DataArrayIdType *b(nullptr); + bool const a(zeCoords->areIncludedInMe(m1->getCoords(),eps,b)); + MCAuto const bSafe(b); if(!a) { - std::ostringstream oss; oss << "MEDFileUMesh::quadraticToLinear : for level " << *lev << " problem to identify nodes generated !"; + std::ostringstream oss; oss << "MEDFileUMesh::quadraticToLinear : for level " << lev << " problem to identify nodes generated !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } m1->renumberNodesInConn(b->begin()); m1->setCoords(zeCoords); - ret->setMeshAtLevel(*lev,m1); - famField=getFamilyFieldAtLevel(*lev); + ret->setMeshAtLevel(lev,m1); + famField=getFamilyFieldAtLevel(lev); if(famField) { MCAuto famFieldCpy(famField->deepCopy()); - ret->setFamilyFieldArr(*lev,famFieldCpy); + ret->setFamilyFieldArr(lev,famFieldCpy); } } return ret.retn(); @@ -4992,7 +5021,7 @@ MCAuto MEDFileUMesh::Aggregate(const std::vectorgetSpaceDimension()),meshDim(ref->getMeshDimension()); - std::vector levs(ref->getNonEmptyLevels()); + std::vector const levs(ref->getNonEmptyLevels()); std::map > m_fam,m_renum; std::map > > m_mesh2; std::map > m_mesh; @@ -5027,7 +5056,7 @@ MCAuto MEDFileUMesh::Aggregate(const std::vector MEDFileUMesh::Aggregate(const std::vector MEDFileUMesh::Aggregate(const std::vector locMesh(msh->getMeshAtLevel(level)); + MCAuto const locMesh(msh->getMeshAtLevel(level)); m_mesh[level].push_back(locMesh); m_mesh2[level].push_back(locMesh); m_renum[level].push_back(msh->getNumberFieldAtLevel(level)); @@ -5132,12 +5161,12 @@ MCAuto MEDFileUMesh::Aggregate(const std::vector ret(MEDFileUMesh::New()); MCAuto coo(DataArrayDouble::Aggregate(coos)); ret->setCoords(coo); - if(std::find(fam_coos.begin(),fam_coos.end(),(const DataArrayIdType *)0)==fam_coos.end()) + if(std::find(fam_coos.begin(),fam_coos.end(),(const DataArrayIdType *)nullptr)==fam_coos.end()) { MCAuto fam_coo(DataArrayIdType::Aggregate(fam_coos)); ret->setFamilyFieldArr(1,fam_coo); } - if(std::find(num_coos.begin(),num_coos.end(),(const DataArrayIdType *)0)==num_coos.end()) + if(std::find(num_coos.begin(),num_coos.end(),(const DataArrayIdType *)nullptr)==num_coos.end()) { MCAuto num_coo(DataArrayIdType::Aggregate(num_coos)); ret->setRenumFieldArr(1,num_coo); @@ -5188,7 +5217,7 @@ MEDCouplingMappedExtrudedMesh *MEDFileUMesh::convertToExtrudedMesh() const MCAuto m3D(getMeshAtLevel(0)),m2D(getMeshAtLevel(-1)); if(m3D.isNull() || m2D.isNull()) throw INTERP_KERNEL::Exception("MEDFileUMesh::convertToExtrudedMesh : this must be defined both at level 0 and level -1 !"); - mcIdType zeId(std::numeric_limits::max()-getFamilyId(GetSpeStr4ExtMesh())); + mcIdType const zeId(std::numeric_limits::max()-getFamilyId(GetSpeStr4ExtMesh())); MCAuto ret(MEDCouplingMappedExtrudedMesh::New(m3D,m2D,zeId)); return ret.retn(); } @@ -5197,7 +5226,7 @@ void MEDFileUMesh::serialize(std::vector& tinyDouble, std::vector layer0; layer0.push_back(getAxisType());//0 i layer0.push_back(_order); //1 i @@ -5302,7 +5331,7 @@ void MEDFileUMesh::unserialize(std::vector& tinyDouble, std::vector& tinyDouble, std::vectorgetNumberOfTuples()); + mcIdType const nbOfNodes(coords->getNumberOfTuples()); if(_fam_coords.isNull()) { _fam_coords=DataArrayIdType::New(); _fam_coords->alloc(nbOfNodes,1); _fam_coords->fillWithZero(); } // @@ -5390,7 +5419,7 @@ void MEDFileUMesh::addGroup(int meshDimRelToMaxExt, const DataArrayIdType *ids) */ void MEDFileUMesh::setFamilyNameAttachedOnId(mcIdType id, const std::string& newFamName) { - std::string oldName=getFamilyNameGivenId(id); + std::string const oldName=getFamilyNameGivenId(id); _families.erase(oldName); _families[newFamName]=id; } @@ -5406,8 +5435,8 @@ void MEDFileUMesh::removeMeshAtLevel(int meshDimRelToMax) std::vector::const_iterator it=std::find(levSet.begin(),levSet.end(),meshDimRelToMax); if(it==levSet.end()) throw INTERP_KERNEL::Exception("MEDFileUMesh::removeMeshAtLevel : the requested level is not existing !"); - int pos=(-meshDimRelToMax); - _ms[pos]=0; + int const pos=(-meshDimRelToMax); + _ms[pos]=nullptr; } /*! @@ -5423,7 +5452,7 @@ void MEDFileUMesh::removeMeshAtLevel(int meshDimRelToMax) */ void MEDFileUMesh::setMeshAtLevel(int meshDimRelToMax, MEDCoupling1GTUMesh *m) { - MCAuto elt(new MEDFileUMeshSplitL1(m)); + MCAuto const elt(new MEDFileUMeshSplitL1(m)); checkAndGiveEntryInSplitL1(meshDimRelToMax,m)=elt; } @@ -5442,7 +5471,7 @@ void MEDFileUMesh::setMeshAtLevel(int meshDimRelToMax, MEDCoupling1GTUMesh *m) */ void MEDFileUMesh::setMeshAtLevel(int meshDimRelToMax, MEDCouplingUMesh *m, bool newOrOld) { - MCAuto elt(new MEDFileUMeshSplitL1(m,newOrOld)); + MCAuto const elt(new MEDFileUMeshSplitL1(m,newOrOld)); checkAndGiveEntryInSplitL1(meshDimRelToMax,m)=elt; } @@ -5452,7 +5481,7 @@ MCAuto& MEDFileUMesh::checkAndGiveEntryInSplitL1(int meshDi std::vector levSet=getNonEmptyLevels(); if(std::find(levSet.begin(),levSet.end(),meshDimRelToMax)==levSet.end()) { - if((DataArrayDouble *)_coords==0) + if((DataArrayDouble *)_coords==nullptr) { DataArrayDouble *c=m->getCoords(); if(c) @@ -5461,7 +5490,7 @@ MCAuto& MEDFileUMesh::checkAndGiveEntryInSplitL1(int meshDi } if(m->getCoords()!=_coords) throw INTERP_KERNEL::Exception("MEDFileUMesh::setMeshAtLevel : Invalid Given Mesh ! The coordinates are not the same ! try to use tryToShareSameCoords !"); - int sz=(-meshDimRelToMax)+1; + int const sz=(-meshDimRelToMax)+1; if(sz>=(int)_ms.size()) _ms.resize(sz); checkMeshDimCoherency(m->getMeshDimension(),meshDimRelToMax); @@ -5489,7 +5518,7 @@ void MEDFileUMesh::setMeshes(const std::vector& ms, bo const MEDCouplingUMesh *mRef=ms[0]; if(!mRef) throw INTERP_KERNEL::Exception("MEDFileUMesh::setMeshes : null instance in the first element of input meshes !"); - std::string name(mRef->getName()); + std::string const name(mRef->getName()); const DataArrayDouble *coo(mRef->getCoords()); std::set s; int zeDim=-1; @@ -5535,12 +5564,12 @@ void MEDFileUMesh::setGroupsFromScratch(int meshDimRelToMax, const std::vector=(int)_ms.size()) _ms.resize(sz); checkMeshDimCoherency(ms[0]->getMeshDimension(),meshDimRelToMax); DataArrayDouble *coo=checkMultiMesh(ms); - if((DataArrayDouble *)_coords==0) + if((DataArrayDouble *)_coords==nullptr) { coo->incrRef(); _coords=coo; @@ -5579,12 +5608,12 @@ void MEDFileUMesh::setGroupsOnSetMesh(int meshDimRelToMax, const std::vector=(int)_ms.size()) _ms.resize(sz); checkMeshDimCoherency(ms[0]->getMeshDimension(),meshDimRelToMax); DataArrayDouble *coo=checkMultiMesh(ms); - if((DataArrayDouble *)_coords==0) + if((DataArrayDouble *)_coords==nullptr) { coo->incrRef(); _coords=coo; @@ -5597,7 +5626,7 @@ void MEDFileUMesh::setGroupsOnSetMesh(int meshDimRelToMax, const std::vector::const_iterator it=ms.begin();it!=ms.end();it++,i++) { - DataArrayIdType *arr=0; + DataArrayIdType *arr=nullptr; bool test=m->areCellsIncludedIn(*it,_zipconn_pol,arr); corr[i]=arr; if(!test) @@ -5639,7 +5668,7 @@ void MEDFileUMesh::setFamilyFieldArr(int meshDimRelToMaxExt, DataArrayIdType *fa { if(!famArr) { - _fam_coords=0; + _fam_coords=nullptr; return ; } DataArrayDouble *coo(_coords); @@ -5651,10 +5680,10 @@ void MEDFileUMesh::setFamilyFieldArr(int meshDimRelToMaxExt, DataArrayIdType *fa } if(meshDimRelToMaxExt>1) throw INTERP_KERNEL::Exception("MEDFileUMesh::setFamilyFieldArr : Dimension request is invalid (>1) !"); - int traducedRk=-meshDimRelToMaxExt; + int const traducedRk=-meshDimRelToMaxExt; if(traducedRk>=(int)_ms.size()) throw INTERP_KERNEL::Exception("Invalid mesh dim relative to max given ! Too low !"); - if((MEDFileUMeshSplitL1 *)_ms[traducedRk]==0) + if((MEDFileUMeshSplitL1 *)_ms[traducedRk]==nullptr) throw INTERP_KERNEL::Exception("On specified lev (or entity) no cells exists !"); return _ms[traducedRk]->setFamilyArr(famArr); } @@ -5684,10 +5713,10 @@ void MEDFileUMesh::setRenumFieldArr(int meshDimRelToMaxExt, DataArrayIdType *ren } if(meshDimRelToMaxExt>1) throw INTERP_KERNEL::Exception("MEDFileUMesh::setRenumArr : Dimension request is invalid (>1) !"); - int traducedRk=-meshDimRelToMaxExt; + int const traducedRk=-meshDimRelToMaxExt; if(traducedRk>=(int)_ms.size()) throw INTERP_KERNEL::Exception("Invalid mesh dim relative to max given ! Too low !"); - if((MEDFileUMeshSplitL1 *)_ms[traducedRk]==0) + if((MEDFileUMeshSplitL1 *)_ms[traducedRk]==nullptr) throw INTERP_KERNEL::Exception("On specified lev (or entity) no cells exists !"); return _ms[traducedRk]->setRenumArr(renumArr); } @@ -5705,7 +5734,7 @@ void MEDFileUMesh::setNameFieldAtLevel(int meshDimRelToMaxExt, DataArrayAsciiCha { if(!nameArr) { - _name_coords=0; + _name_coords=nullptr; return ; } DataArrayDouble *coo(_coords); @@ -5717,10 +5746,10 @@ void MEDFileUMesh::setNameFieldAtLevel(int meshDimRelToMaxExt, DataArrayAsciiCha } if(meshDimRelToMaxExt>1) throw INTERP_KERNEL::Exception("MEDFileUMesh::setNameFieldAtLevel : Dimension request is invalid (>1) !"); - int traducedRk=-meshDimRelToMaxExt; + int const traducedRk=-meshDimRelToMaxExt; if(traducedRk>=(int)_ms.size()) throw INTERP_KERNEL::Exception("Invalid mesh dim relative to max given ! Too low !"); - if((MEDFileUMeshSplitL1 *)_ms[traducedRk]==0) + if((MEDFileUMeshSplitL1 *)_ms[traducedRk]==nullptr) throw INTERP_KERNEL::Exception("On specified lev (or entity) no cells exists !"); return _ms[traducedRk]->setNameArr(nameArr); } @@ -5783,7 +5812,7 @@ void MEDFileUMesh::computeRevNum() const if(_num_coords.isNotNull()) { mcIdType pos; - mcIdType maxValue=_num_coords->getMaxValue(pos); + mcIdType const maxValue=_num_coords->getMaxValue(pos); _rev_num_coords=_num_coords->invertArrayN2O2O2N(maxValue+1); } } @@ -5816,17 +5845,17 @@ mcIdType MEDFileStructuredMesh::getMaxAbsFamilyIdInArrays() const mcIdType ret=-std::numeric_limits::max(),tmp=-1; if((const DataArrayIdType *)_fam_nodes) { - mcIdType val=_fam_nodes->getMaxValue(tmp); + mcIdType const val=_fam_nodes->getMaxValue(tmp); ret=std::max(ret,std::abs(val)); } if((const DataArrayIdType *)_fam_cells) { - mcIdType val=_fam_cells->getMaxValue(tmp); + mcIdType const val=_fam_cells->getMaxValue(tmp); ret=std::max(ret,std::abs(val)); } if((const DataArrayIdType *)_fam_faces) { - mcIdType val=_fam_faces->getMaxValue(tmp); + mcIdType const val=_fam_faces->getMaxValue(tmp); ret=std::max(ret,std::abs(val)); } return ret; @@ -5837,17 +5866,17 @@ mcIdType MEDFileStructuredMesh::getMaxFamilyIdInArrays() const mcIdType ret=-std::numeric_limits::max(),tmp=-1; if((const DataArrayIdType *)_fam_nodes) { - mcIdType val=_fam_nodes->getMaxValue(tmp); + mcIdType const val=_fam_nodes->getMaxValue(tmp); ret=std::max(ret,val); } if((const DataArrayIdType *)_fam_cells) { - mcIdType val=_fam_cells->getMaxValue(tmp); + mcIdType const val=_fam_cells->getMaxValue(tmp); ret=std::max(ret,val); } if((const DataArrayIdType *)_fam_faces) { - mcIdType val=_fam_faces->getMaxValue(tmp); + mcIdType const val=_fam_faces->getMaxValue(tmp); ret=std::max(ret,val); } return ret; @@ -5858,17 +5887,17 @@ mcIdType MEDFileStructuredMesh::getMinFamilyIdInArrays() const mcIdType ret=std::numeric_limits::max(),tmp=-1; if((const DataArrayIdType *)_fam_nodes) { - mcIdType val=_fam_nodes->getMinValue(tmp); + mcIdType const val=_fam_nodes->getMinValue(tmp); ret=std::min(ret,val); } if((const DataArrayIdType *)_fam_cells) { - mcIdType val=_fam_cells->getMinValue(tmp); + mcIdType const val=_fam_cells->getMinValue(tmp); ret=std::min(ret,val); } if((const DataArrayIdType *)_fam_faces) { - mcIdType val=_fam_faces->getMinValue(tmp); + mcIdType const val=_fam_faces->getMinValue(tmp); ret=std::min(ret,val); } return ret; @@ -5878,7 +5907,7 @@ bool MEDFileStructuredMesh::isEqual(const MEDFileMesh *other, double eps, std::s { if(!MEDFileMesh::isEqual(other,eps,what)) return false; - const MEDFileStructuredMesh *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) { what="Mesh types differ ! This is structured and other is NOT !"; @@ -5886,14 +5915,14 @@ bool MEDFileStructuredMesh::isEqual(const MEDFileMesh *other, double eps, std::s } const DataArrayIdType *famc1=_fam_nodes; const DataArrayIdType *famc2=otherC->_fam_nodes; - if((famc1==0 && famc2!=0) || (famc1!=0 && famc2==0)) + if((famc1==nullptr && famc2!=nullptr) || (famc1!=nullptr && famc2==nullptr)) { what="Mismatch of families arr on nodes ! One is defined and not other !"; return false; } if(famc1) { - bool ret=famc1->isEqual(*famc2); + bool const ret=famc1->isEqual(*famc2); if(!ret) { what="Families arr on nodes differ !"; @@ -5902,14 +5931,14 @@ bool MEDFileStructuredMesh::isEqual(const MEDFileMesh *other, double eps, std::s } famc1=_fam_cells; famc2=otherC->_fam_cells; - if((famc1==0 && famc2!=0) || (famc1!=0 && famc2==0)) + if((famc1==nullptr && famc2!=nullptr) || (famc1!=nullptr && famc2==nullptr)) { what="Mismatch of families arr on cells ! One is defined and not other !"; return false; } if(famc1) { - bool ret=famc1->isEqual(*famc2); + bool const ret=famc1->isEqual(*famc2); if(!ret) { what="Families arr on cells differ !"; @@ -5918,14 +5947,14 @@ bool MEDFileStructuredMesh::isEqual(const MEDFileMesh *other, double eps, std::s } famc1=_fam_faces; famc2=otherC->_fam_faces; - if((famc1==0 && famc2!=0) || (famc1!=0 && famc2==0)) + if((famc1==nullptr && famc2!=nullptr) || (famc1!=nullptr && famc2==nullptr)) { what="Mismatch of families arr on faces ! One is defined and not other !"; return false; } if(famc1) { - bool ret=famc1->isEqual(*famc2); + bool const ret=famc1->isEqual(*famc2); if(!ret) { what="Families arr on faces differ !"; @@ -5934,14 +5963,14 @@ bool MEDFileStructuredMesh::isEqual(const MEDFileMesh *other, double eps, std::s } famc1=_num_nodes; famc2=otherC->_num_nodes; - if((famc1==0 && famc2!=0) || (famc1!=0 && famc2==0)) + if((famc1==nullptr && famc2!=nullptr) || (famc1!=nullptr && famc2==nullptr)) { what="Mismatch of numbering arr on nodes ! One is defined and not other !"; return false; } if(famc1) { - bool ret=famc1->isEqual(*famc2); + bool const ret=famc1->isEqual(*famc2); if(!ret) { what="Numbering arr on nodes differ !"; @@ -5950,14 +5979,14 @@ bool MEDFileStructuredMesh::isEqual(const MEDFileMesh *other, double eps, std::s } famc1=_num_cells; famc2=otherC->_num_cells; - if((famc1==0 && famc2!=0) || (famc1!=0 && famc2==0)) + if((famc1==nullptr && famc2!=nullptr) || (famc1!=nullptr && famc2==nullptr)) { what="Mismatch of numbering arr on cells ! One is defined and not other !"; return false; } if(famc1) { - bool ret=famc1->isEqual(*famc2); + bool const ret=famc1->isEqual(*famc2); if(!ret) { what="Numbering arr on cells differ !"; @@ -5966,14 +5995,14 @@ bool MEDFileStructuredMesh::isEqual(const MEDFileMesh *other, double eps, std::s } famc1=_num_faces; famc2=otherC->_num_faces; - if((famc1==0 && famc2!=0) || (famc1!=0 && famc2==0)) + if((famc1==nullptr && famc2!=nullptr) || (famc1!=nullptr && famc2==nullptr)) { what="Mismatch of numbering arr on faces ! One is defined and not other !"; return false; } if(famc1) { - bool ret=famc1->isEqual(*famc2); + bool const ret=famc1->isEqual(*famc2); if(!ret) { what="Numbering arr on faces differ !"; @@ -5982,14 +6011,14 @@ bool MEDFileStructuredMesh::isEqual(const MEDFileMesh *other, double eps, std::s } const DataArrayAsciiChar *d1=_names_cells; const DataArrayAsciiChar *d2=otherC->_names_cells; - if((d1==0 && d2!=0) || (d1!=0 && d2==0)) + if((d1==nullptr && d2!=nullptr) || (d1!=nullptr && d2==nullptr)) { what="Mismatch of naming arr on cells ! One is defined and not other !"; return false; } if(d1) { - bool ret=d1->isEqual(*d2); + bool const ret=d1->isEqual(*d2); if(!ret) { what="Naming arr on cells differ !"; @@ -5998,14 +6027,14 @@ bool MEDFileStructuredMesh::isEqual(const MEDFileMesh *other, double eps, std::s } d1=_names_faces; d2=otherC->_names_faces; - if((d1==0 && d2!=0) || (d1!=0 && d2==0)) + if((d1==nullptr && d2!=nullptr) || (d1!=nullptr && d2==nullptr)) { what="Mismatch of naming arr on faces ! One is defined and not other !"; return false; } if(d1) { - bool ret=d1->isEqual(*d2); + bool const ret=d1->isEqual(*d2); if(!ret) { what="Naming arr on faces differ !"; @@ -6014,14 +6043,14 @@ bool MEDFileStructuredMesh::isEqual(const MEDFileMesh *other, double eps, std::s } d1=_names_nodes; d2=otherC->_names_nodes; - if((d1==0 && d2!=0) || (d1!=0 && d2==0)) + if((d1==nullptr && d2!=nullptr) || (d1!=nullptr && d2==nullptr)) { what="Mismatch of naming arr on nodes ! One is defined and not other !"; return false; } if(d1) { - bool ret=d1->isEqual(*d2); + bool const ret=d1->isEqual(*d2); if(!ret) { what="Naming arr on nodes differ !"; @@ -6079,7 +6108,7 @@ DataArrayIdType *MEDFileStructuredMesh::getFamiliesArr(int meshDimRelToMaxExt, c if(!famIds.empty()) da=_fam_nodes->findIdsEqualList(&famIds[0],&famIds[0]+famIds.size()); else - da=_fam_nodes->findIdsEqualList(0,0); + da=_fam_nodes->findIdsEqualList(nullptr,nullptr); if(renum) return MEDFileUMeshSplitL1::Renumber(_num_nodes,da); else @@ -6097,7 +6126,7 @@ DataArrayIdType *MEDFileStructuredMesh::getFamiliesArr(int meshDimRelToMaxExt, c if(!famIds.empty()) da=_fam_cells->findIdsEqualList(&famIds[0],&famIds[0]+famIds.size()); else - da=_fam_cells->findIdsEqualList(0,0); + da=_fam_cells->findIdsEqualList(nullptr,nullptr); if(renum) return MEDFileUMeshSplitL1::Renumber(_num_cells,da); else @@ -6115,7 +6144,7 @@ DataArrayIdType *MEDFileStructuredMesh::getFamiliesArr(int meshDimRelToMaxExt, c if(!famIds.empty()) da=_fam_faces->findIdsEqualList(&famIds[0],&famIds[0]+famIds.size()); else - da=_fam_faces->findIdsEqualList(0,0); + da=_fam_faces->findIdsEqualList(nullptr,nullptr); if(renum) return MEDFileUMeshSplitL1::Renumber(_num_faces,da); else @@ -6149,7 +6178,7 @@ void MEDFileStructuredMesh::setFamilyFieldArr(int meshDimRelToMaxExt, DataArrayI { case 0: { - mcIdType nbCells(mesh->getNumberOfCells()); + mcIdType const nbCells(mesh->getNumberOfCells()); if(famArr) famArr->checkNbOfTuplesAndComp(nbCells,1,"MEDFileStructuredMesh::setFamilyFieldArr : Problem in size of Family arr ! Mismatch with number of cells of mesh !"); _fam_cells=famArr; @@ -6157,7 +6186,7 @@ void MEDFileStructuredMesh::setFamilyFieldArr(int meshDimRelToMaxExt, DataArrayI } case 1: { - mcIdType nbNodes(mesh->getNumberOfNodes()); + mcIdType const nbNodes(mesh->getNumberOfNodes()); if(famArr) famArr->checkNbOfTuplesAndComp(nbNodes,1,"MEDFileStructuredMesh::setFamilyFieldArr : Problem in size of Family arr ! Mismatch with number of nodes of mesh !"); _fam_nodes=famArr; @@ -6165,7 +6194,7 @@ void MEDFileStructuredMesh::setFamilyFieldArr(int meshDimRelToMaxExt, DataArrayI } case -1: { - mcIdType nbCells(mesh->getNumberOfCellsOfSubLevelMesh()); + mcIdType const nbCells(mesh->getNumberOfCellsOfSubLevelMesh()); if(famArr) famArr->checkNbOfTuplesAndComp(nbCells,1,"MEDFileStructuredMesh::setFamilyFieldArr : Problem in size of Family arr ! Mismatch with number of faces of mesh !"); _fam_faces=famArr; @@ -6195,21 +6224,21 @@ void MEDFileStructuredMesh::setRenumFieldArr(int meshDimRelToMaxExt, DataArrayId { case 0: { - mcIdType nbCells=mesh->getNumberOfCells(); + mcIdType const nbCells=mesh->getNumberOfCells(); renumArr->checkNbOfTuplesAndComp(nbCells,1,"MEDFileStructuredMesh::setRenumFieldArr : Problem in size of Renum arr ! Mismatch with number of cells of mesh !"); _num_cells=renumArr; break; } case 1: { - mcIdType nbNodes=mesh->getNumberOfNodes(); + mcIdType const nbNodes=mesh->getNumberOfNodes(); renumArr->checkNbOfTuplesAndComp(nbNodes,1,"MEDFileStructuredMesh::setRenumFieldArr : Problem in size of Family arr ! Mismatch with number of nodes of mesh !"); _num_nodes=renumArr; break; } case -1: { - mcIdType nbCells=mesh->getNumberOfCellsOfSubLevelMesh(); + mcIdType const nbCells=mesh->getNumberOfCellsOfSubLevelMesh(); renumArr->checkNbOfTuplesAndComp(nbCells,1,"MEDFileStructuredMesh::setRenumFieldArr : Problem in size of Renum arr ! Mismatch with number of faces of mesh !"); _num_faces=renumArr; break; @@ -6237,21 +6266,21 @@ void MEDFileStructuredMesh::setNameFieldAtLevel(int meshDimRelToMaxExt, DataArra { case 0: { - mcIdType nbCells=mesh->getNumberOfCells(); + mcIdType const nbCells=mesh->getNumberOfCells(); nameArr->checkNbOfTuplesAndComp(nbCells,MED_SNAME_SIZE,"MEDFileStructuredMesh::setNameFieldAtLevel : Problem in size of names arr ! Mismatch with number of cells of mesh !"); _names_cells=nameArr; break; } case 1: { - mcIdType nbNodes=mesh->getNumberOfNodes(); + mcIdType const nbNodes=mesh->getNumberOfNodes(); nameArr->checkNbOfTuplesAndComp(nbNodes,MED_SNAME_SIZE,"MEDFileStructuredMesh::setNameFieldAtLevel : Problem in size of names arr ! Mismatch with number of nodes of mesh !"); _names_nodes=nameArr; break; } case -1: { - mcIdType nbCells=mesh->getNumberOfCellsOfSubLevelMesh(); + mcIdType const nbCells=mesh->getNumberOfCellsOfSubLevelMesh(); nameArr->checkNbOfTuplesAndComp(nbCells,MED_SNAME_SIZE,"MEDFileStructuredMesh::setNameFieldAtLevel : Problem in size of names arr ! Mismatch with number of faces of mesh !"); _names_faces=nameArr; break; @@ -6263,7 +6292,7 @@ void MEDFileStructuredMesh::setNameFieldAtLevel(int meshDimRelToMaxExt, DataArra nameArr->incrRef(); } -void MEDFileStructuredMesh::setGlobalNumFieldAtLevel(int meshDimRelToMaxExt, DataArrayIdType *globalNumArr) +void MEDFileStructuredMesh::setGlobalNumFieldAtLevel(int /*meshDimRelToMaxExt*/, DataArrayIdType * /*globalNumArr*/) { throw INTERP_KERNEL::Exception("MEDFileStructuredMesh::setGlobalNumFieldAtLevel : not implemented yet !"); } @@ -6393,7 +6422,7 @@ const DataArrayIdType *MEDFileStructuredMesh::getRevNumberFieldAtLevel(int meshD if((const DataArrayIdType *)_num_cells) { mcIdType pos; - mcIdType maxValue=_num_cells->getMaxValue(pos); + mcIdType const maxValue=_num_cells->getMaxValue(pos); _rev_num_cells=_num_cells->invertArrayN2O2O2N(maxValue+1); return _rev_num_cells; } @@ -6405,7 +6434,7 @@ const DataArrayIdType *MEDFileStructuredMesh::getRevNumberFieldAtLevel(int meshD if((const DataArrayIdType *)_num_nodes) { mcIdType pos; - mcIdType maxValue=_num_nodes->getMaxValue(pos); + mcIdType const maxValue=_num_nodes->getMaxValue(pos); _rev_num_nodes=_num_nodes->invertArrayN2O2O2N(maxValue+1); return _rev_num_nodes; } @@ -6429,7 +6458,7 @@ const DataArrayAsciiChar *MEDFileStructuredMesh::getNameFieldAtLevel(int meshDim } } -MCAuto MEDFileStructuredMesh::getGlobalNumFieldAtLevel(int meshDimRelToMaxExt) const +MCAuto MEDFileStructuredMesh::getGlobalNumFieldAtLevel(int /*meshDimRelToMaxExt*/) const { throw INTERP_KERNEL::Exception("MEDFileStructuredMesh::getGlobalNumFieldAtLevel : not implemented yet for structured mesh !"); } @@ -6508,7 +6537,7 @@ std::vector MEDFileStructuredMesh::getNameArrNonEmptyLevelsExt() const */ bool MEDFileStructuredMesh::unPolyze(std::vector& oldCode, std::vector& newCode, DataArrayIdType *& o2nRenumCell) { - oldCode.clear(); newCode.clear(); o2nRenumCell=0; + oldCode.clear(); newCode.clear(); o2nRenumCell=nullptr; return false; } @@ -6735,7 +6764,7 @@ void MEDFileStructuredMesh::buildImplicitPart() const void MEDFileStructuredMesh::releaseImplicitPartIfAny() const { - _faces_if_necessary=0; + _faces_if_necessary=nullptr; } /*! @@ -6764,7 +6793,7 @@ std::vector MEDFileStructuredMesh::getGeoType } case -1: { - int mdim(cmesh->getMeshDimension()); + int const mdim(cmesh->getMeshDimension()); if(mdim<1) throw INTERP_KERNEL::Exception("MEDFileStructuredMesh::getGeoTypesAtLevel : only one level available for structured meshes ! Input 0 is mandatory or 0D mesh !"); std::vector ret(1,MEDCouplingStructuredMesh::GetGeoTypeGivenMeshDimension(mdim-1)); @@ -6799,10 +6828,10 @@ void MEDFileStructuredMesh::whichAreNodesFetched(const MEDFileField1TSStructItem const DataArrayIdType *arr(globs->getProfile(st[0].getPflName())); const MEDCouplingStructuredMesh *cmesh=getStructuredMesh();//cmesh not null because getNumberOfNodes called before mcIdType sz(ToIdType(nodesFetched.size())); - for(const mcIdType *work=arr->begin();work!=arr->end();work++) + for(long const work : *arr) { std::vector conn; - cmesh->getNodeIdsOfCell(*work,conn); + cmesh->getNodeIdsOfCell(work,conn); for(std::vector::const_iterator it=conn.begin();it!=conn.end();it++) if(*it>=0 && *it& famCells, MCAuto& numCells, MCAuto& namesCells) { med_bool chgt=MED_FALSE,trsf=MED_FALSE; - med_geometry_type geoTypeReq=MEDFileStructuredMesh::GetGeoTypeFromMeshDim(meshDim); + med_geometry_type const geoTypeReq=MEDFileStructuredMesh::GetGeoTypeFromMeshDim(meshDim); mcIdType nbOfElt(0); nbOfElt=MEDmeshnEntity(fid,mName.c_str(),dt,it,MED_CELL,geoTypeReq,MED_FAMILY_NUMBER,MED_NODAL,&chgt,&trsf); if(nbOfElt>0) @@ -6874,7 +6903,7 @@ void MEDFileStructuredMesh::loadStrMeshFromFile(MEDFileStrMeshL2 *strm, med_idt { if(!mrs || mrs->isNodeFamilyFieldReading()) { - mcIdType nbNodes(getNumberOfNodes()); + mcIdType const nbNodes(getNumberOfNodes()); if(nbOfElt>nbNodes) throw INTERP_KERNEL::Exception("MEDFileStructuredMesh::loadStrMeshFromFile : invalid size of family node array regarding number of nodes in this ! File seems to be corrupted !"); MCAuto miFamNodes=DataArrayMedInt::New(); @@ -6907,7 +6936,7 @@ void MEDFileStructuredMesh::loadStrMeshFromFile(MEDFileStrMeshL2 *strm, med_idt _names_nodes->reAlloc(nbOfElt);//not a bug to avoid the memory corruption due to last \0 at the end } } - int meshDim(getStructuredMesh()->getMeshDimension()); + int const meshDim(getStructuredMesh()->getMeshDimension()); LoadStrMeshDAFromFile(fid,meshDim,dt,it,mName,mrs,_fam_cells,_num_cells,_names_cells); if(meshDim>=1) LoadStrMeshDAFromFile(fid,meshDim-1,dt,it,mName,mrs,_fam_faces,_num_faces,_names_faces); @@ -6915,7 +6944,7 @@ void MEDFileStructuredMesh::loadStrMeshFromFile(MEDFileStrMeshL2 *strm, med_idt void MEDFileStructuredMesh::writeStructuredLL(med_idt fid, const std::string& maa) const { - int meshDim(getStructuredMesh()->getMeshDimension()); + int const meshDim(getStructuredMesh()->getMeshDimension()); med_geometry_type geoTypeReq(GetGeoTypeFromMeshDim(meshDim)),geoTypeReq2(GetGeoTypeFromMeshDim(meshDim-1)); // if((const DataArrayIdType *)_fam_cells) @@ -6986,7 +7015,7 @@ MEDFileCMesh *MEDFileCMesh::New() */ MEDFileCMesh *MEDFileCMesh::New(const std::string& fileName, MEDFileMeshReadSelector *mrs) { - MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + MEDFileUtilities::AutoFid const fid(OpenMEDFileForRead(fileName)); return New(fid,mrs); } @@ -7011,7 +7040,7 @@ MEDFileCMesh *MEDFileCMesh::New(med_idt fid, MEDFileMeshReadSelector *mrs) */ MEDFileCMesh *MEDFileCMesh::New(const std::string& fileName, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs) { - MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + MEDFileUtilities::AutoFid const fid(OpenMEDFileForRead(fileName)); return New(fid,mName,dt,it,mrs); } @@ -7106,7 +7135,7 @@ bool MEDFileCMesh::isEqual(const MEDFileMesh *other, double eps, std::string& wh { if(!MEDFileStructuredMesh::isEqual(other,eps,what)) return false; - const MEDFileCMesh *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) { what="Mesh types differ ! This is cartesian and other is NOT !"; @@ -7116,14 +7145,14 @@ bool MEDFileCMesh::isEqual(const MEDFileMesh *other, double eps, std::string& wh otherC->clearNonDiscrAttributes(); const MEDCouplingCMesh *coo1=_cmesh; const MEDCouplingCMesh *coo2=otherC->_cmesh; - if((coo1==0 && coo2!=0) || (coo1!=0 && coo2==0)) + if((coo1==nullptr && coo2!=nullptr) || (coo1!=nullptr && coo2==nullptr)) { what="Mismatch of cartesian meshes ! One is defined and not other !"; return false; } if(coo1) { - bool ret=coo1->isEqual(coo2,eps); + bool const ret=coo1->isEqual(coo2,eps); if(!ret) { what="cartesian meshes differ !"; @@ -7143,8 +7172,7 @@ void MEDFileCMesh::clearNonDiscrAttributes() const } MEDFileCMesh::MEDFileCMesh() -{ -} += default; MEDFileCMesh::MEDFileCMesh(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs) try @@ -7238,12 +7266,12 @@ void MEDFileCMesh::writeMeshLL(med_idt fid) const MEDLoaderBase::safeStrCpy(_name.c_str(),MED_NAME_SIZE,maa,_too_long_str); MEDLoaderBase::safeStrCpy(_desc_name.c_str(),MED_COMMENT_SIZE,desc,_too_long_str); MEDLoaderBase::safeStrCpy(_dt_unit.c_str(),MED_LNAME_SIZE,dtunit,_too_long_str); - int spaceDim(_cmesh->getSpaceDimension()); + int const spaceDim(_cmesh->getSpaceDimension()); INTERP_KERNEL::AutoPtr comp=MEDLoaderBase::buildEmptyString(spaceDim*MED_SNAME_SIZE); INTERP_KERNEL::AutoPtr unit=MEDLoaderBase::buildEmptyString(spaceDim*MED_SNAME_SIZE); for(int i=0;igetCoordsAt(i)->getInfoOnComponent(0)); + std::string const info(_cmesh->getCoordsAt(i)->getInfoOnComponent(0)); std::string c,u; MEDLoaderBase::splitIntoNameAndUnit(info,c,u); MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE-1,comp+i*MED_SNAME_SIZE,_too_long_str);//MED_TAILLE_PNOM-1 to avoid to write '\0' on next compo @@ -7259,7 +7287,7 @@ void MEDFileCMesh::writeMeshLL(med_idt fid) const MEDFILESAFECALLERWR0(MEDmeshGridIndexCoordinateWr,(fid,maa,_iteration,_order,_time,i+1,ToMedInt(da->getNumberOfTuples()),da->getConstPointer())); } // - std::string meshName(MEDLoaderBase::buildStringFromFortran(maa,MED_NAME_SIZE)); + std::string const meshName(MEDLoaderBase::buildStringFromFortran(maa,MED_NAME_SIZE)); MEDFileStructuredMesh::writeStructuredLL(fid,meshName); } @@ -7286,13 +7314,13 @@ MEDFileCurveLinearMesh *MEDFileCurveLinearMesh::New(med_idt fid, MEDFileMeshRead MEDFileCurveLinearMesh *MEDFileCurveLinearMesh::New(const std::string& fileName, MEDFileMeshReadSelector *mrs) { - MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + MEDFileUtilities::AutoFid const fid(OpenMEDFileForRead(fileName)); return New(fid,mrs); } MEDFileCurveLinearMesh *MEDFileCurveLinearMesh::New(const std::string& fileName, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs) { - MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + MEDFileUtilities::AutoFid const fid(OpenMEDFileForRead(fileName)); return New(fid,mName,dt,it,mrs); } @@ -7362,7 +7390,7 @@ bool MEDFileCurveLinearMesh::isEqual(const MEDFileMesh *other, double eps, std:: { if(!MEDFileStructuredMesh::isEqual(other,eps,what)) return false; - const MEDFileCurveLinearMesh *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) { what="Mesh types differ ! This is curve linear and other is NOT !"; @@ -7372,14 +7400,14 @@ bool MEDFileCurveLinearMesh::isEqual(const MEDFileMesh *other, double eps, std:: otherC->clearNonDiscrAttributes(); const MEDCouplingCurveLinearMesh *coo1=_clmesh; const MEDCouplingCurveLinearMesh *coo2=otherC->_clmesh; - if((coo1==0 && coo2!=0) || (coo1!=0 && coo2==0)) + if((coo1==nullptr && coo2!=nullptr) || (coo1!=nullptr && coo2==nullptr)) { what="Mismatch of curve linear meshes ! One is defined and not other !"; return false; } if(coo1) { - bool ret=coo1->isEqual(coo2,eps); + bool const ret=coo1->isEqual(coo2,eps); if(!ret) { what="curve linear meshes differ !"; @@ -7452,8 +7480,7 @@ const MEDCouplingStructuredMesh *MEDFileCurveLinearMesh::getStructuredMesh() con } MEDFileCurveLinearMesh::MEDFileCurveLinearMesh() -{ -} += default; MEDFileCurveLinearMesh::MEDFileCurveLinearMesh(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs) try @@ -7473,8 +7500,8 @@ void MEDFileCurveLinearMesh::writeMeshLL(med_idt fid) const MEDLoaderBase::safeStrCpy(_name.c_str(),MED_NAME_SIZE,maa,_too_long_str); MEDLoaderBase::safeStrCpy(_desc_name.c_str(),MED_COMMENT_SIZE,desc,_too_long_str); MEDLoaderBase::safeStrCpy(_dt_unit.c_str(),MED_LNAME_SIZE,dtunit,_too_long_str); - int spaceDim=_clmesh->getSpaceDimension(); - int meshDim=_clmesh->getMeshDimension(); + int const spaceDim=_clmesh->getSpaceDimension(); + int const meshDim=_clmesh->getMeshDimension(); INTERP_KERNEL::AutoPtr comp=MEDLoaderBase::buildEmptyString(spaceDim*MED_SNAME_SIZE); INTERP_KERNEL::AutoPtr unit=MEDLoaderBase::buildEmptyString(spaceDim*MED_SNAME_SIZE); const DataArrayDouble *coords=_clmesh->getCoords(); @@ -7482,7 +7509,7 @@ void MEDFileCurveLinearMesh::writeMeshLL(med_idt fid) const throw INTERP_KERNEL::Exception("MEDFileCurveLinearMesh::writeMeshLL : no coordinates set !"); for(int i=0;igetCoords()->getInfoOnComponent(i)); + std::string const info(_clmesh->getCoords()->getInfoOnComponent(i)); std::string c,u; MEDLoaderBase::splitIntoNameAndUnit(info,c,u); MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE-1,comp+i*MED_SNAME_SIZE,_too_long_str);//MED_TAILLE_PNOM-1 to avoid to write '\0' on next compo @@ -7497,7 +7524,7 @@ void MEDFileCurveLinearMesh::writeMeshLL(med_idt fid) const MEDFILESAFECALLERWR0(MEDmeshNodeCoordinateWr,(fid,maa,_iteration,_order,_time,MED_FULL_INTERLACE,ToMedInt(coords->getNumberOfTuples()),coords->begin())); // - std::string meshName(MEDLoaderBase::buildStringFromFortran(maa,MED_NAME_SIZE)); + std::string const meshName(MEDLoaderBase::buildStringFromFortran(maa,MED_NAME_SIZE)); MEDFileStructuredMesh::writeStructuredLL(fid,meshName); } @@ -7534,7 +7561,7 @@ MEDFileMeshMultiTS *MEDFileMeshMultiTS::New(med_idt fid) MEDFileMeshMultiTS *MEDFileMeshMultiTS::New(const std::string& fileName) { - MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + MEDFileUtilities::AutoFid const fid(OpenMEDFileForRead(fileName)); return New(fid); } @@ -7545,7 +7572,7 @@ MEDFileMeshMultiTS *MEDFileMeshMultiTS::New(med_idt fid, const std::string& mNam MEDFileMeshMultiTS *MEDFileMeshMultiTS::New(const std::string& fileName, const std::string& mName) { - MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + MEDFileUtilities::AutoFid const fid(OpenMEDFileForRead(fileName)); return New(fid,mName); } @@ -7635,7 +7662,7 @@ MEDFileJoints * MEDFileMeshMultiTS::getJoints() const { if ( MEDFileMesh* m = getOneTimeStep() ) return m->getJoints(); - return 0; + return nullptr; } /*! @@ -7673,7 +7700,7 @@ void MEDFileMeshMultiTS::writeLL(med_idt fid) const for(std::vector< MCAuto >::const_iterator it=_mesh_one_ts.begin();it!=_mesh_one_ts.end();it++) { if ( jointsWritten ) - const_cast(**it).setJoints( 0 ); + const_cast(**it).setJoints( nullptr ); else jointsWritten = true; @@ -7686,19 +7713,18 @@ void MEDFileMeshMultiTS::writeLL(med_idt fid) const void MEDFileMeshMultiTS::loadFromFile(med_idt fid, const std::string& mName) { - MEDFileJoints *joints(0); + MEDFileJoints *joints(nullptr); if ( !_mesh_one_ts.empty() && getOneTimeStep() ) { // joints of mName already read, pass them to MEDFileMesh::New() to prevent repeated reading joints = getOneTimeStep()->getJoints(); } _mesh_one_ts.clear(); //for the moment to be improved - _mesh_one_ts.push_back( MEDFileMesh::New(fid,mName,-1,-1,0, joints )); + _mesh_one_ts.push_back( MEDFileMesh::New(fid,mName,-1,-1,nullptr, joints )); } MEDFileMeshMultiTS::MEDFileMeshMultiTS() -{ -} += default; MEDFileMeshMultiTS::MEDFileMeshMultiTS(med_idt fid) try @@ -7743,7 +7769,7 @@ MEDFileMeshes *MEDFileMeshes::New(med_idt fid) MEDFileMeshes *MEDFileMeshes::New(const std::string& fileName) { - MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + MEDFileUtilities::AutoFid const fid(OpenMEDFileForRead(fileName)); return New(fid); } @@ -7881,8 +7907,7 @@ void MEDFileMeshes::loadFromFile(med_idt fid) } MEDFileMeshes::MEDFileMeshes() -{ -} += default; MEDFileMeshes::MEDFileMeshes(med_idt fid) try @@ -7928,7 +7953,7 @@ std::string MEDFileMeshes::simpleRepr() const void MEDFileMeshes::simpleReprWithoutHeader(std::ostream& oss) const { - int nbOfMeshes=getNumberOfMeshes(); + int const nbOfMeshes=getNumberOfMeshes(); oss << "There are " << nbOfMeshes << " meshes with the following names : \n"; std::vector mns=getMeshesNames(); for(int i=0;igetMeshAtPos(_iter_id++); else - return 0; + return nullptr; } else - return 0; + return nullptr; } INTERP_KERNEL::NormalizedCellType MEDFileMesh::ConvertFromMEDFileGeoType(med_geometry_type geoType) diff --git a/src/MEDLoader/MEDFileMesh.hxx b/src/MEDLoader/MEDFileMesh.hxx index 043073d97..7312faff5 100644 --- a/src/MEDLoader/MEDFileMesh.hxx +++ b/src/MEDLoader/MEDFileMesh.hxx @@ -21,15 +21,34 @@ #ifndef __MEDFILEMESH_HXX__ #define __MEDFILEMESH_HXX__ +#include "MEDCouplingRefCountObject.hxx" +#include "MEDFileUtilities.txx" +#include "MEDCouplingMemArray.hxx" +#include "MCType.hxx" +#include "MEDCouplingMesh.hxx" +#include "MCAuto.hxx" +#include "MEDCouplingUMesh.hxx" +#include "MEDCoupling1GTUMesh.hxx" +#include "MEDCouplingPointSet.hxx" +#include "MEDCouplingStructuredMesh.hxx" +#include "MEDCouplingCMesh.hxx" +#include "MEDCouplingCurveLinearMesh.hxx" #include "MEDLoaderDefines.hxx" #include "MEDFileMeshLL.hxx" -#include "MEDFileUtilities.txx" #include "MEDCouplingPartDefinition.hxx" #include "MEDFileMeshReadSelector.hxx" #include "MEDFileJoint.hxx" #include "MEDFileEquivalence.hxx" +#include "med.h" +#include "NormalizedGeometricTypes" +#include +#include #include +#include +#include +#include +#include #include #include #include @@ -42,14 +61,14 @@ namespace MEDCoupling class MEDFileMesh : public RefCountObject, public MEDFileWritableStandAlone { public: - MEDLOADER_EXPORT static MEDFileMesh *New(const std::string& fileName, MEDFileMeshReadSelector *mrs=0); - MEDLOADER_EXPORT static MEDFileMesh *New(med_idt fid, MEDFileMeshReadSelector *mrs=0); + MEDLOADER_EXPORT static MEDFileMesh *New(const std::string& fileName, MEDFileMeshReadSelector *mrs=nullptr); + MEDLOADER_EXPORT static MEDFileMesh *New(med_idt fid, MEDFileMeshReadSelector *mrs=nullptr); MEDLOADER_EXPORT static MEDFileMesh *New(DataArrayByte *db) { return BuildFromMemoryChunk(db); } - MEDLOADER_EXPORT static MEDFileMesh *New(const std::string& fileName, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0, MEDFileJoints* joints=0); - MEDLOADER_EXPORT static MEDFileMesh *New(med_idt fid, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0, MEDFileJoints* joints=0); - MEDLOADER_EXPORT void writeLL(med_idt fid) const; - MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; - MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const; + MEDLOADER_EXPORT static MEDFileMesh *New(const std::string& fileName, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=nullptr, MEDFileJoints* joints=nullptr); + MEDLOADER_EXPORT static MEDFileMesh *New(med_idt fid, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=nullptr, MEDFileJoints* joints=nullptr); + MEDLOADER_EXPORT void writeLL(med_idt fid) const override; + MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const override; + MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const override; MEDLOADER_EXPORT virtual MEDFileMesh *createNewEmpty() const = 0; MEDLOADER_EXPORT virtual MEDFileMesh *deepCopy() const = 0; MEDLOADER_EXPORT virtual MEDFileMesh *shallowCpy() const = 0; @@ -203,7 +222,7 @@ namespace MEDCoupling MEDLOADER_EXPORT void setJoints( MEDFileJoints* joints ); MEDFileEquivalences *getEquivalences() { return _equiv; } const MEDFileEquivalences *getEquivalences() const { return _equiv; } - void killEquivalences() { _equiv=(MEDFileEquivalences *)0; } + void killEquivalences() { _equiv=(MEDFileEquivalences *)nullptr; } void initializeEquivalences() { _equiv=MEDFileEquivalences::New(this); } MEDLOADER_EXPORT static INTERP_KERNEL::NormalizedCellType ConvertFromMEDFileGeoType(med_geometry_type geoType); MEDLOADER_EXPORT static med_geometry_type ConvertToMEDFileGeoType(INTERP_KERNEL::NormalizedCellType geoType); @@ -228,7 +247,7 @@ namespace MEDCoupling static std::string CreateNameNotIn(const std::string& nameTry, const std::vector& namesToAvoid); static mcIdType PutInThirdComponentOfCodeOffset(std::vector& code, mcIdType strt); void writeJoints(med_idt fid) const; - void loadJointsFromFile(med_idt fid, MEDFileJoints *toUseInstedOfReading=0); + void loadJointsFromFile(med_idt fid, MEDFileJoints *toUseInstedOfReading=nullptr); void loadEquivalences(med_idt fid); void deepCpyEquivalences(const MEDFileMesh& other); bool areEquivalencesEqual(const MEDFileMesh *other, std::string& what) const; @@ -263,10 +282,10 @@ namespace MEDCoupling { friend class MEDFileMesh; public: - MEDLOADER_EXPORT static MEDFileUMesh *New(const std::string& fileName, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0); - MEDLOADER_EXPORT static MEDFileUMesh *New(med_idt fid, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0); - MEDLOADER_EXPORT static MEDFileUMesh *New(const std::string& fileName, MEDFileMeshReadSelector *mrs=0); - MEDLOADER_EXPORT static MEDFileUMesh *New(med_idt fid, MEDFileMeshReadSelector *mrs=0); + MEDLOADER_EXPORT static MEDFileUMesh *New(const std::string& fileName, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=nullptr); + MEDLOADER_EXPORT static MEDFileUMesh *New(med_idt fid, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=nullptr); + MEDLOADER_EXPORT static MEDFileUMesh *New(const std::string& fileName, MEDFileMeshReadSelector *mrs=nullptr); + MEDLOADER_EXPORT static MEDFileUMesh *New(med_idt fid, MEDFileMeshReadSelector *mrs=nullptr); MEDLOADER_EXPORT static MEDFileUMesh *New(DataArrayByte *db) { return BuildFromMemoryChunk(db); } MEDLOADER_EXPORT static MEDFileUMesh *New(const MEDCouplingMappedExtrudedMesh *mem); MEDLOADER_EXPORT static MEDFileUMesh *New(); @@ -275,64 +294,64 @@ namespace MEDCoupling MEDLOADER_EXPORT static MCAuto LoadConnectivityOnlyPartOf(med_idt fid, const std::string& mName, const std::vector& types, const std::vector& slicPerTyp, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=nullptr); MEDLOADER_EXPORT static MEDFileUMesh *LoadPartOf(const std::string& fileName, const std::string& mName, const std::vector& types, const std::vector& slicPerTyp, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=nullptr); MEDLOADER_EXPORT static MEDFileUMesh *LoadPartOf(med_idt fid, const std::string& mName, const std::vector& types, const std::vector& slicPerTyp, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=nullptr); - MEDLOADER_EXPORT static MEDFileUMesh *LoadPartOfFromUserDistrib(med_idt fid, const std::string& mName, const std::map>& distrib, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0); + MEDLOADER_EXPORT static MEDFileUMesh *LoadPartOfFromUserDistrib(med_idt fid, const std::string& mName, const std::map>& distrib, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=nullptr); MEDLOADER_EXPORT static void LoadPartCoords(const std::string& fileName, const std::string& mName, int dt, int it, const std::vector& infosOnComp, mcIdType startNodeId, mcIdType stopNodeId, MCAuto& coords, MCAuto& partCoords, MCAuto& famCoords, MCAuto& numCoords, MCAuto& nameCoords); MEDLOADER_EXPORT static const char *GetSpeStr4ExtMesh() { return SPE_FAM_STR_EXTRUDED_MESH; } - MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; - MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const; - MEDLOADER_EXPORT MEDFileMesh *createNewEmpty() const; - MEDLOADER_EXPORT MEDFileUMesh *deepCopy() const; - MEDLOADER_EXPORT MEDFileUMesh *shallowCpy() const; - MEDLOADER_EXPORT bool isEqual(const MEDFileMesh *other, double eps, std::string& what) const; + MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const override; + MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const override; + MEDLOADER_EXPORT MEDFileMesh *createNewEmpty() const override; + MEDLOADER_EXPORT MEDFileUMesh *deepCopy() const override; + MEDLOADER_EXPORT MEDFileUMesh *shallowCpy() const override; + MEDLOADER_EXPORT bool isEqual(const MEDFileMesh *other, double eps, std::string& what) const override; MEDLOADER_EXPORT void checkConsistency() const; MEDLOADER_EXPORT void checkSMESHConsistency() const; MEDLOADER_EXPORT void clearNodeAndCellNumbers(); - MEDLOADER_EXPORT void clearNonDiscrAttributes() const; - MEDLOADER_EXPORT void setName(const std::string& name); + MEDLOADER_EXPORT void clearNonDiscrAttributes() const override; + MEDLOADER_EXPORT void setName(const std::string& name) override; MEDLOADER_EXPORT const std::vector< MCAuto >& getAccessOfUndergroundEltStrs() const { return _elt_str; } // - MEDLOADER_EXPORT mcIdType getMaxAbsFamilyIdInArrays() const; - MEDLOADER_EXPORT mcIdType getMaxFamilyIdInArrays() const; - MEDLOADER_EXPORT mcIdType getMinFamilyIdInArrays() const; - MEDLOADER_EXPORT int getMeshDimension() const; - MEDLOADER_EXPORT int getSpaceDimension() const; - MEDLOADER_EXPORT std::string simpleRepr() const; - MEDLOADER_EXPORT std::string advancedRepr() const; - MEDLOADER_EXPORT mcIdType getSizeAtLevel(int meshDimRelToMaxExt) const; - MEDLOADER_EXPORT const DataArrayIdType *getFamilyFieldAtLevel(int meshDimRelToMaxExt) const; - MEDLOADER_EXPORT DataArrayIdType *getFamilyFieldAtLevel(int meshDimRelToMaxExt); - MEDLOADER_EXPORT const DataArrayIdType *getNumberFieldAtLevel(int meshDimRelToMaxExt) const; - MEDLOADER_EXPORT const DataArrayIdType *getRevNumberFieldAtLevel(int meshDimRelToMaxExt) const; - MEDLOADER_EXPORT const DataArrayAsciiChar *getNameFieldAtLevel(int meshDimRelToMaxExt) const; - MEDLOADER_EXPORT MCAuto getGlobalNumFieldAtLevel(int meshDimRelToMaxExt) const; + MEDLOADER_EXPORT mcIdType getMaxAbsFamilyIdInArrays() const override; + MEDLOADER_EXPORT mcIdType getMaxFamilyIdInArrays() const override; + MEDLOADER_EXPORT mcIdType getMinFamilyIdInArrays() const override; + MEDLOADER_EXPORT int getMeshDimension() const override; + MEDLOADER_EXPORT int getSpaceDimension() const override; + MEDLOADER_EXPORT std::string simpleRepr() const override; + MEDLOADER_EXPORT std::string advancedRepr() const override; + MEDLOADER_EXPORT mcIdType getSizeAtLevel(int meshDimRelToMaxExt) const override; + MEDLOADER_EXPORT const DataArrayIdType *getFamilyFieldAtLevel(int meshDimRelToMaxExt) const override; + MEDLOADER_EXPORT DataArrayIdType *getFamilyFieldAtLevel(int meshDimRelToMaxExt) override; + MEDLOADER_EXPORT const DataArrayIdType *getNumberFieldAtLevel(int meshDimRelToMaxExt) const override; + MEDLOADER_EXPORT const DataArrayIdType *getRevNumberFieldAtLevel(int meshDimRelToMaxExt) const override; + MEDLOADER_EXPORT const DataArrayAsciiChar *getNameFieldAtLevel(int meshDimRelToMaxExt) const override; + MEDLOADER_EXPORT MCAuto getGlobalNumFieldAtLevel(int meshDimRelToMaxExt) const override; MEDLOADER_EXPORT const PartDefinition *getPartDefAtLevel(int meshDimRelToMaxExt, INTERP_KERNEL::NormalizedCellType gt=INTERP_KERNEL::NORM_ERROR) const; - MEDLOADER_EXPORT mcIdType getNumberOfNodes() const; - MEDLOADER_EXPORT mcIdType getNumberOfCellsAtLevel(int meshDimRelToMaxExt) const; - MEDLOADER_EXPORT bool hasImplicitPart() const; - MEDLOADER_EXPORT mcIdType buildImplicitPartIfAny(INTERP_KERNEL::NormalizedCellType gt) const; - MEDLOADER_EXPORT void releaseImplicitPartIfAny() const; - MEDLOADER_EXPORT std::vector getGeoTypesAtLevel(int meshDimRelToMax) const; - MEDLOADER_EXPORT mcIdType getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType ct) const; - MEDLOADER_EXPORT void whichAreNodesFetched(const MEDFileField1TSStructItem& st, const MEDFileFieldGlobsReal *globs, std::vector& nodesFetched) const; - MEDLOADER_EXPORT MEDFileMesh *cartesianize() const; - MEDLOADER_EXPORT bool presenceOfStructureElements() const; - MEDLOADER_EXPORT void killStructureElements(); - MEDLOADER_EXPORT std::vector getNonEmptyLevels() const; - MEDLOADER_EXPORT std::vector getNonEmptyLevelsExt() const; - MEDLOADER_EXPORT std::vector getFamArrNonEmptyLevelsExt() const; - MEDLOADER_EXPORT std::vector getNumArrNonEmptyLevelsExt() const; - MEDLOADER_EXPORT std::vector getNameArrNonEmptyLevelsExt() const; - MEDLOADER_EXPORT std::vector getFamsNonEmptyLevels(const std::vector& fams) const; - MEDLOADER_EXPORT std::vector getFamsNonEmptyLevelsExt(const std::vector& fams) const; + MEDLOADER_EXPORT mcIdType getNumberOfNodes() const override; + MEDLOADER_EXPORT mcIdType getNumberOfCellsAtLevel(int meshDimRelToMaxExt) const override; + MEDLOADER_EXPORT bool hasImplicitPart() const override; + MEDLOADER_EXPORT mcIdType buildImplicitPartIfAny(INTERP_KERNEL::NormalizedCellType gt) const override; + MEDLOADER_EXPORT void releaseImplicitPartIfAny() const override; + MEDLOADER_EXPORT std::vector getGeoTypesAtLevel(int meshDimRelToMax) const override; + MEDLOADER_EXPORT mcIdType getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType ct) const override; + MEDLOADER_EXPORT void whichAreNodesFetched(const MEDFileField1TSStructItem& st, const MEDFileFieldGlobsReal *globs, std::vector& nodesFetched) const override; + MEDLOADER_EXPORT MEDFileMesh *cartesianize() const override; + MEDLOADER_EXPORT bool presenceOfStructureElements() const override; + MEDLOADER_EXPORT void killStructureElements() override; + MEDLOADER_EXPORT std::vector getNonEmptyLevels() const override; + MEDLOADER_EXPORT std::vector getNonEmptyLevelsExt() const override; + MEDLOADER_EXPORT std::vector getFamArrNonEmptyLevelsExt() const override; + MEDLOADER_EXPORT std::vector getNumArrNonEmptyLevelsExt() const override; + MEDLOADER_EXPORT std::vector getNameArrNonEmptyLevelsExt() const override; + MEDLOADER_EXPORT std::vector getFamsNonEmptyLevels(const std::vector& fams) const override; + MEDLOADER_EXPORT std::vector getFamsNonEmptyLevelsExt(const std::vector& fams) const override; MEDLOADER_EXPORT DataArrayDouble *getCoords() const; MEDLOADER_EXPORT MEDCouplingUMesh *getGroup(int meshDimRelToMaxExt, const std::string& grp, bool renum=false) const; MEDLOADER_EXPORT MEDCouplingUMesh *getGroups(int meshDimRelToMaxExt, const std::vector& grps, bool renum=false) const; MEDLOADER_EXPORT MEDCouplingUMesh *getFamily(int meshDimRelToMaxExt, const std::string& fam, bool renum=false) const; MEDLOADER_EXPORT MEDCouplingUMesh *getFamilies(int meshDimRelToMaxExt, const std::vector& fams, bool renum=false) const; - MEDLOADER_EXPORT DataArrayIdType *getFamiliesArr(int meshDimRelToMaxExt, const std::vector& fams, bool renum=false) const; - MEDLOADER_EXPORT MEDCouplingUMesh *getMeshAtLevel(int meshDimRelToMax, bool renum=false) const; - MEDLOADER_EXPORT std::vector getDistributionOfTypes(int meshDimRelToMax) const; + MEDLOADER_EXPORT DataArrayIdType *getFamiliesArr(int meshDimRelToMaxExt, const std::vector& fams, bool renum=false) const override; + MEDLOADER_EXPORT MEDCouplingUMesh *getMeshAtLevel(int meshDimRelToMax, bool renum=false) const override; + MEDLOADER_EXPORT std::vector getDistributionOfTypes(int meshDimRelToMax) const override; MEDLOADER_EXPORT std::vector< std::pair > getAllDistributionOfTypes() const; MEDLOADER_EXPORT MEDCouplingUMesh *getLevel0Mesh(bool renum=false) const; MEDLOADER_EXPORT MEDCouplingUMesh *getLevelM1Mesh(bool renum=false) const; @@ -351,12 +370,12 @@ MCAuto& coords, MCAuto& partCoords, MCAuto& coords, MCAuto& partCoords, MCAuto> crackAlong(const std::string &grpNameM1, bool grpMustBeFullyDup=true); MEDLOADER_EXPORT void openCrack(const std::map> & c2o2nN, const double & factor); MEDLOADER_EXPORT void buildInnerBoundaryAlongM1Group(const std::string& grpNameM1, DataArrayIdType *&nodesDuplicated, DataArrayIdType *&cellsModified, DataArrayIdType *&cellsNotModified); - MEDLOADER_EXPORT bool unPolyze(std::vector& oldCode, std::vector& newCode, DataArrayIdType *& o2nRenumCell); + MEDLOADER_EXPORT bool unPolyze(std::vector& oldCode, std::vector& newCode, DataArrayIdType *& o2nRenumCell) override; MEDLOADER_EXPORT DataArrayIdType *zipCoords(); MEDLOADER_EXPORT DataArrayIdType *computeFetchedNodeIds() const; MEDLOADER_EXPORT DataArrayIdType *deduceNodeSubPartFromCellSubPart(const std::map >& extractDef) const; @@ -386,21 +405,21 @@ MCAuto& coords, MCAuto& partCoords, MCAuto& tinyDouble, std::vector& tinyInt, std::vector& tinyStr, std::vector< MCAuto >& bigArraysI, MCAuto& bigArrayD); private: - MEDLOADER_EXPORT ~MEDFileUMesh(); - void writeMeshLL(med_idt fid) const; + MEDLOADER_EXPORT ~MEDFileUMesh() override; + void writeMeshLL(med_idt fid) const override; MEDFileUMesh(); MEDFileUMesh(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs); - void loadPartUMeshFromFile(med_idt fid, const std::string& mName, const std::vector& types, const std::vector& slicPerTyp, std::function& types, const std::vector&,int,int,MEDFileMeshReadSelector *)> functorOnUMeshL2, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0); - void loadPartUMeshFromFileFromUserDistrib(med_idt fid, const std::string& mName, const std::map>& distrib, std::function>&,int,int,MEDFileMeshReadSelector *)> functorOnUMeshL2, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0); - void loadLL(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs); + void loadPartUMeshFromFile(med_idt fid, const std::string& mName, const std::vector& types, const std::vector& slicPerTyp, std::function& types, const std::vector&,int,int,MEDFileMeshReadSelector *)> functorOnUMeshL2, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=nullptr); + void loadPartUMeshFromFileFromUserDistrib(med_idt fid, const std::string& mName, const std::map>& distrib, std::function>&,int,int,MEDFileMeshReadSelector *)> functorOnUMeshL2, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=nullptr); + void loadLL(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs) override; void dispatchLoadedPart(med_idt fid, const MEDFileUMeshL2& loaderl2, const std::string& mName, MEDFileMeshReadSelector *mrs); const MEDFileUMeshSplitL1 *getMeshAtLevSafe(int meshDimRelToMaxExt) const; MEDFileUMeshSplitL1 *getMeshAtLevSafe(int meshDimRelToMaxExt); void checkMeshDimCoherency(int meshDim, int meshDimRelToMax) const; DataArrayDouble *checkMultiMesh(const std::vector& ms) const; - void synchronizeTinyInfoOnLeaves() const; - void changeFamilyIdArr(mcIdType oldId, mcIdType newId); - std::list< MCAuto > getAllNonNullFamilyIds() const; + void synchronizeTinyInfoOnLeaves() const override; + void changeFamilyIdArr(mcIdType oldId, mcIdType newId) override; + std::list< MCAuto > getAllNonNullFamilyIds() const override; MCAuto& checkAndGiveEntryInSplitL1(int meshDimRelToMax, MEDCouplingPointSet *m); static std::vector>> findConnectedComponents( @@ -432,52 +451,52 @@ MCAuto& coords, MCAuto& partCoords, MCAuto getDirectChildrenWithNull() const; - MEDLOADER_EXPORT mcIdType getMaxAbsFamilyIdInArrays() const; - MEDLOADER_EXPORT mcIdType getMaxFamilyIdInArrays() const; - MEDLOADER_EXPORT mcIdType getMinFamilyIdInArrays() const; - MEDLOADER_EXPORT bool isEqual(const MEDFileMesh *other, double eps, std::string& what) const; - MEDLOADER_EXPORT void clearNonDiscrAttributes() const; - MEDLOADER_EXPORT DataArrayIdType *getFamiliesArr(int meshDimRelToMaxExt, const std::vector& fams, bool renum=false) const; - MEDLOADER_EXPORT const DataArrayIdType *getFamilyFieldAtLevel(int meshDimRelToMaxExt) const; - MEDLOADER_EXPORT DataArrayIdType *getFamilyFieldAtLevel(int meshDimRelToMaxExt); - MEDLOADER_EXPORT void setFamilyFieldArr(int meshDimRelToMaxExt, DataArrayIdType *famArr); - MEDLOADER_EXPORT void setRenumFieldArr(int meshDimRelToMaxExt, DataArrayIdType *renumArr); - MEDLOADER_EXPORT void setNameFieldAtLevel(int meshDimRelToMaxExt, DataArrayAsciiChar *nameArr); - MEDLOADER_EXPORT void setGlobalNumFieldAtLevel(int meshDimRelToMaxExt, DataArrayIdType *globalNumArr); - MEDLOADER_EXPORT void addNodeGroup(const DataArrayIdType *ids); - MEDLOADER_EXPORT void addGroup(int meshDimRelToMaxExt, const DataArrayIdType *ids); - MEDLOADER_EXPORT const DataArrayIdType *getNumberFieldAtLevel(int meshDimRelToMaxExt) const; - MEDLOADER_EXPORT const DataArrayIdType *getRevNumberFieldAtLevel(int meshDimRelToMaxExt) const; - MEDLOADER_EXPORT const DataArrayAsciiChar *getNameFieldAtLevel(int meshDimRelToMaxExt) const; - MEDLOADER_EXPORT MCAuto getGlobalNumFieldAtLevel(int meshDimRelToMaxExt) const; - MEDLOADER_EXPORT std::vector getNonEmptyLevels() const; - MEDLOADER_EXPORT std::vector getNonEmptyLevelsExt() const; - MEDLOADER_EXPORT std::vector getFamArrNonEmptyLevelsExt() const; - MEDLOADER_EXPORT std::vector getNumArrNonEmptyLevelsExt() const; - MEDLOADER_EXPORT std::vector getNameArrNonEmptyLevelsExt() const; - MEDLOADER_EXPORT MEDCouplingMesh *getMeshAtLevel(int meshDimRelToMax, bool renum=false) const; - MEDLOADER_EXPORT std::vector getFamsNonEmptyLevels(const std::vector& fams) const; - MEDLOADER_EXPORT std::vector getFamsNonEmptyLevelsExt(const std::vector& fams) const; - MEDLOADER_EXPORT mcIdType getSizeAtLevel(int meshDimRelToMaxExt) const; - MEDLOADER_EXPORT mcIdType getNumberOfNodes() const; - MEDLOADER_EXPORT mcIdType getNumberOfCellsAtLevel(int meshDimRelToMaxExt) const; - MEDLOADER_EXPORT bool hasImplicitPart() const; - MEDLOADER_EXPORT mcIdType buildImplicitPartIfAny(INTERP_KERNEL::NormalizedCellType gt) const; - MEDLOADER_EXPORT void releaseImplicitPartIfAny() const; + MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const override; + MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const override; + MEDLOADER_EXPORT mcIdType getMaxAbsFamilyIdInArrays() const override; + MEDLOADER_EXPORT mcIdType getMaxFamilyIdInArrays() const override; + MEDLOADER_EXPORT mcIdType getMinFamilyIdInArrays() const override; + MEDLOADER_EXPORT bool isEqual(const MEDFileMesh *other, double eps, std::string& what) const override; + MEDLOADER_EXPORT void clearNonDiscrAttributes() const override; + MEDLOADER_EXPORT DataArrayIdType *getFamiliesArr(int meshDimRelToMaxExt, const std::vector& fams, bool renum=false) const override; + MEDLOADER_EXPORT const DataArrayIdType *getFamilyFieldAtLevel(int meshDimRelToMaxExt) const override; + MEDLOADER_EXPORT DataArrayIdType *getFamilyFieldAtLevel(int meshDimRelToMaxExt) override; + MEDLOADER_EXPORT void setFamilyFieldArr(int meshDimRelToMaxExt, DataArrayIdType *famArr) override; + MEDLOADER_EXPORT void setRenumFieldArr(int meshDimRelToMaxExt, DataArrayIdType *renumArr) override; + MEDLOADER_EXPORT void setNameFieldAtLevel(int meshDimRelToMaxExt, DataArrayAsciiChar *nameArr) override; + MEDLOADER_EXPORT void setGlobalNumFieldAtLevel(int meshDimRelToMaxExt, DataArrayIdType *globalNumArr) override; + MEDLOADER_EXPORT void addNodeGroup(const DataArrayIdType *ids) override; + MEDLOADER_EXPORT void addGroup(int meshDimRelToMaxExt, const DataArrayIdType *ids) override; + MEDLOADER_EXPORT const DataArrayIdType *getNumberFieldAtLevel(int meshDimRelToMaxExt) const override; + MEDLOADER_EXPORT const DataArrayIdType *getRevNumberFieldAtLevel(int meshDimRelToMaxExt) const override; + MEDLOADER_EXPORT const DataArrayAsciiChar *getNameFieldAtLevel(int meshDimRelToMaxExt) const override; + MEDLOADER_EXPORT MCAuto getGlobalNumFieldAtLevel(int meshDimRelToMaxExt) const override; + MEDLOADER_EXPORT std::vector getNonEmptyLevels() const override; + MEDLOADER_EXPORT std::vector getNonEmptyLevelsExt() const override; + MEDLOADER_EXPORT std::vector getFamArrNonEmptyLevelsExt() const override; + MEDLOADER_EXPORT std::vector getNumArrNonEmptyLevelsExt() const override; + MEDLOADER_EXPORT std::vector getNameArrNonEmptyLevelsExt() const override; + MEDLOADER_EXPORT MEDCouplingMesh *getMeshAtLevel(int meshDimRelToMax, bool renum=false) const override; + MEDLOADER_EXPORT std::vector getFamsNonEmptyLevels(const std::vector& fams) const override; + MEDLOADER_EXPORT std::vector getFamsNonEmptyLevelsExt(const std::vector& fams) const override; + MEDLOADER_EXPORT mcIdType getSizeAtLevel(int meshDimRelToMaxExt) const override; + MEDLOADER_EXPORT mcIdType getNumberOfNodes() const override; + MEDLOADER_EXPORT mcIdType getNumberOfCellsAtLevel(int meshDimRelToMaxExt) const override; + MEDLOADER_EXPORT bool hasImplicitPart() const override; + MEDLOADER_EXPORT mcIdType buildImplicitPartIfAny(INTERP_KERNEL::NormalizedCellType gt) const override; + MEDLOADER_EXPORT void releaseImplicitPartIfAny() const override; MEDLOADER_EXPORT MEDCoupling1SGTUMesh *getImplicitFaceMesh() const; - MEDLOADER_EXPORT std::vector getGeoTypesAtLevel(int meshDimRelToMax) const; - MEDLOADER_EXPORT mcIdType getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType ct) const; - MEDLOADER_EXPORT void whichAreNodesFetched(const MEDFileField1TSStructItem& st, const MEDFileFieldGlobsReal *globs, std::vector& nodesFetched) const; - MEDLOADER_EXPORT bool presenceOfStructureElements() const { return false; } + MEDLOADER_EXPORT std::vector getGeoTypesAtLevel(int meshDimRelToMax) const override; + MEDLOADER_EXPORT mcIdType getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType ct) const override; + MEDLOADER_EXPORT void whichAreNodesFetched(const MEDFileField1TSStructItem& st, const MEDFileFieldGlobsReal *globs, std::vector& nodesFetched) const override; + MEDLOADER_EXPORT bool presenceOfStructureElements() const override { return false; } MEDLOADER_EXPORT virtual const MEDCouplingStructuredMesh *getStructuredMesh() const = 0; // tools - MEDLOADER_EXPORT bool unPolyze(std::vector& oldCode, std::vector& newCode, DataArrayIdType *& o2nRenumCell); + MEDLOADER_EXPORT bool unPolyze(std::vector& oldCode, std::vector& newCode, DataArrayIdType *& o2nRenumCell) override; protected: - ~MEDFileStructuredMesh() { } - void changeFamilyIdArr(mcIdType oldId, mcIdType newId); - std::list< MCAuto > getAllNonNullFamilyIds() const; + ~MEDFileStructuredMesh() override = default; + void changeFamilyIdArr(mcIdType oldId, mcIdType newId) override; + std::list< MCAuto > getAllNonNullFamilyIds() const override; void deepCpyAttributes(); void loadStrMeshFromFile(MEDFileStrMeshL2 *strm, med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs); void writeStructuredLL(med_idt fid, const std::string& maa) const; @@ -507,34 +526,34 @@ MCAuto& coords, MCAuto& partCoords, MCAuto(db); } - MEDLOADER_EXPORT static MEDFileCMesh *New(const std::string& fileName, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0); - MEDLOADER_EXPORT static MEDFileCMesh *New(med_idt fid, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0); + MEDLOADER_EXPORT static MEDFileCMesh *New(const std::string& fileName, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=nullptr); + MEDLOADER_EXPORT static MEDFileCMesh *New(med_idt fid, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=nullptr); MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileCMesh"); } - MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; - MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const; - MEDLOADER_EXPORT MEDFileMesh *createNewEmpty() const; - MEDLOADER_EXPORT MEDFileCMesh *deepCopy() const; - MEDLOADER_EXPORT MEDFileCMesh *shallowCpy() const; - MEDLOADER_EXPORT bool isEqual(const MEDFileMesh *other, double eps, std::string& what) const; - MEDLOADER_EXPORT int getMeshDimension() const; - MEDLOADER_EXPORT int getSpaceDimension() const; - MEDLOADER_EXPORT std::string simpleRepr() const; - MEDLOADER_EXPORT std::string advancedRepr() const; - MEDLOADER_EXPORT void clearNonDiscrAttributes() const; + MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const override; + MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const override; + MEDLOADER_EXPORT MEDFileMesh *createNewEmpty() const override; + MEDLOADER_EXPORT MEDFileCMesh *deepCopy() const override; + MEDLOADER_EXPORT MEDFileCMesh *shallowCpy() const override; + MEDLOADER_EXPORT bool isEqual(const MEDFileMesh *other, double eps, std::string& what) const override; + MEDLOADER_EXPORT int getMeshDimension() const override; + MEDLOADER_EXPORT int getSpaceDimension() const override; + MEDLOADER_EXPORT std::string simpleRepr() const override; + MEDLOADER_EXPORT std::string advancedRepr() const override; + MEDLOADER_EXPORT void clearNonDiscrAttributes() const override; MEDLOADER_EXPORT const MEDCouplingCMesh *getMesh() const; MEDLOADER_EXPORT void setMesh(MEDCouplingCMesh *m); - MEDLOADER_EXPORT MEDFileMesh *cartesianize() const; + MEDLOADER_EXPORT MEDFileMesh *cartesianize() const override; private: - ~MEDFileCMesh() { } - const MEDCouplingStructuredMesh *getStructuredMesh() const; - void writeMeshLL(med_idt fid) const; + ~MEDFileCMesh() override = default; + const MEDCouplingStructuredMesh *getStructuredMesh() const override; + void writeMeshLL(med_idt fid) const override; MEDFileCMesh(); - void synchronizeTinyInfoOnLeaves() const; + void synchronizeTinyInfoOnLeaves() const override; MEDFileCMesh(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs); - void loadLL(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs); + void loadLL(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs) override; private: MCAuto _cmesh; }; @@ -544,34 +563,34 @@ MCAuto& coords, MCAuto& partCoords, MCAuto(db); } - MEDLOADER_EXPORT static MEDFileCurveLinearMesh *New(const std::string& fileName, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0); - MEDLOADER_EXPORT static MEDFileCurveLinearMesh *New(med_idt fid, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0); + MEDLOADER_EXPORT static MEDFileCurveLinearMesh *New(const std::string& fileName, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=nullptr); + MEDLOADER_EXPORT static MEDFileCurveLinearMesh *New(med_idt fid, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=nullptr); MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileCurveLinearMesh"); } - MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; - MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const; - MEDLOADER_EXPORT MEDFileMesh *createNewEmpty() const; - MEDLOADER_EXPORT MEDFileCurveLinearMesh *deepCopy() const; - MEDLOADER_EXPORT MEDFileCurveLinearMesh *shallowCpy() const; - MEDLOADER_EXPORT bool isEqual(const MEDFileMesh *other, double eps, std::string& what) const; - MEDLOADER_EXPORT int getMeshDimension() const; - MEDLOADER_EXPORT int getSpaceDimension() const; - MEDLOADER_EXPORT std::string simpleRepr() const; - MEDLOADER_EXPORT std::string advancedRepr() const; - MEDLOADER_EXPORT void clearNonDiscrAttributes() const; + MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const override; + MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const override; + MEDLOADER_EXPORT MEDFileMesh *createNewEmpty() const override; + MEDLOADER_EXPORT MEDFileCurveLinearMesh *deepCopy() const override; + MEDLOADER_EXPORT MEDFileCurveLinearMesh *shallowCpy() const override; + MEDLOADER_EXPORT bool isEqual(const MEDFileMesh *other, double eps, std::string& what) const override; + MEDLOADER_EXPORT int getMeshDimension() const override; + MEDLOADER_EXPORT int getSpaceDimension() const override; + MEDLOADER_EXPORT std::string simpleRepr() const override; + MEDLOADER_EXPORT std::string advancedRepr() const override; + MEDLOADER_EXPORT void clearNonDiscrAttributes() const override; MEDLOADER_EXPORT const MEDCouplingCurveLinearMesh *getMesh() const; MEDLOADER_EXPORT void setMesh(MEDCouplingCurveLinearMesh *m); - MEDLOADER_EXPORT MEDFileMesh *cartesianize() const; + MEDLOADER_EXPORT MEDFileMesh *cartesianize() const override; private: - ~MEDFileCurveLinearMesh() { } + ~MEDFileCurveLinearMesh() override = default; MEDFileCurveLinearMesh(); MEDFileCurveLinearMesh(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs); - const MEDCouplingStructuredMesh *getStructuredMesh() const; - void synchronizeTinyInfoOnLeaves() const; - void writeMeshLL(med_idt fid) const; - void loadLL(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs);//to imp + const MEDCouplingStructuredMesh *getStructuredMesh() const override; + void synchronizeTinyInfoOnLeaves() const override; + void writeMeshLL(med_idt fid) const override; + void loadLL(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs) override;//to imp private: MCAuto _clmesh; }; @@ -586,21 +605,21 @@ MCAuto& coords, MCAuto& partCoords, MCAuto getDirectChildrenWithNull() const; + MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const override; + MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const override; MEDLOADER_EXPORT std::string getName() const; MEDLOADER_EXPORT void setName(const std::string& newMeshName); MEDLOADER_EXPORT bool changeNames(const std::vector< std::pair >& modifTab); MEDLOADER_EXPORT void cartesianizeMe(); MEDLOADER_EXPORT MEDFileMesh *getOneTimeStep() const; - MEDLOADER_EXPORT void writeLL(med_idt fid) const; + MEDLOADER_EXPORT void writeLL(med_idt fid) const override; MEDLOADER_EXPORT void setOneTimeStep(MEDFileMesh *mesh1TimeStep); MEDLOADER_EXPORT MEDFileJoints *getJoints() const; MEDLOADER_EXPORT void setJoints(MEDFileJoints* joints); MEDLOADER_EXPORT bool presenceOfStructureElements() const; MEDLOADER_EXPORT void killStructureElements(); private: - ~MEDFileMeshMultiTS() { } + ~MEDFileMeshMultiTS() override = default; void loadFromFile(med_idt fid, const std::string& mName); MEDFileMeshMultiTS(); MEDFileMeshMultiTS(med_idt fid); @@ -620,11 +639,11 @@ MCAuto& coords, MCAuto& partCoords, MCAuto getDirectChildrenWithNull() const; + MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const override; + MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const override; MEDLOADER_EXPORT std::string simpleRepr() const; MEDLOADER_EXPORT void simpleReprWithoutHeader(std::ostream& oss) const; - MEDLOADER_EXPORT void writeLL(med_idt fid) const; + MEDLOADER_EXPORT void writeLL(med_idt fid) const override; MEDLOADER_EXPORT int getNumberOfMeshes() const; MEDLOADER_EXPORT MEDFileMeshesIterator *iterator(); MEDLOADER_EXPORT MEDFileMesh *getMeshAtPos(int i) const; @@ -640,7 +659,7 @@ MCAuto& coords, MCAuto& partCoords, MCAuto +#include +#include #include +#include +#include +#include // From MEDLOader.cxx TU @@ -48,7 +64,7 @@ void MEDFileUMeshPerTypeCommon::loadCommonPart(med_idt fid, const char *mName, i med_entity_type entity, MEDFileMeshReadSelector *mrs) { med_bool changement,transformation; - _fam=0; + _fam=nullptr; if(MEDmeshnEntity(fid,mName,dt,it,entity,geoElt,MED_FAMILY_NUMBER,MED_NODAL,&changement,&transformation)>0) { if(!mrs || mrs->isCellFamilyFieldReading()) @@ -60,7 +76,7 @@ void MEDFileUMeshPerTypeCommon::loadCommonPart(med_idt fid, const char *mName, i _fam=FromMedIntArray( miFam ); } } - _num=0; + _num=nullptr; if(MEDmeshnEntity(fid,mName,dt,it,entity,geoElt,MED_NUMBER,MED_NODAL,&changement,&transformation)>0) { if(!mrs || mrs->isCellNumFieldReading()) @@ -68,11 +84,11 @@ void MEDFileUMeshPerTypeCommon::loadCommonPart(med_idt fid, const char *mName, i MCAuto miNum=DataArrayMedInt::New(); miNum->alloc(curNbOfElem,1); if(MEDmeshEntityNumberRd(fid,mName,dt,it,entity,geoElt,miNum->getPointer())!=0) - miNum=0; + miNum=nullptr; _num=FromMedIntArray(miNum); } } - _names=0; + _names=nullptr; if(MEDmeshnEntity(fid,mName,dt,it,entity,geoElt,MED_NAME,MED_NODAL,&changement,&transformation)>0) { if(!mrs || mrs->isCellNameFieldReading()) @@ -80,7 +96,7 @@ void MEDFileUMeshPerTypeCommon::loadCommonPart(med_idt fid, const char *mName, i _names=DataArrayAsciiChar::New(); _names->alloc(curNbOfElem+1,MED_SNAME_SIZE);//not a bug to avoid the memory corruption due to last \0 at the end if(MEDmeshEntityNameRd(fid,mName,dt,it,entity,geoElt,_names->getPointer())!=0) - _names=0; + _names=nullptr; else _names->reAlloc(curNbOfElem);//not a bug to avoid the memory corruption due to last \0 at the end } @@ -105,17 +121,17 @@ MEDFileUMeshPerType *MEDFileUMeshPerType::New(med_idt fid, const char *mName, in { med_entity_type whichEntity; if(!isExisting(fid,mName,dt,it,geoElt,whichEntity)) - return 0; + return nullptr; return new MEDFileUMeshPerType(fid,mName,dt,it,mdim,geoElt,geoElt2,whichEntity,mrs); } MEDFileUMeshPerType *MEDFileUMeshPerType::NewPart(med_idt fid, const char *mName, int dt, int it, int mdim, INTERP_KERNEL::NormalizedCellType geoElt2, mcIdType strt, mcIdType stp, mcIdType step, MEDFileMeshReadSelector *mrs) { - int geoElt2i((int)geoElt2); + int const geoElt2i((int)geoElt2); if(geoElt2i<0 || geoElt2i>=INTERP_KERNEL::NORM_MAXTYPE) throw INTERP_KERNEL::Exception("MEDFileUMeshPerType::NewPart : Not recognized MEDCoupling/MEDLoader geometric type !"); - med_geometry_type geoElt(typmai3[geoElt2]); + med_geometry_type const geoElt(typmai3[geoElt2]); med_entity_type whichEntity; if(!isExisting(fid,mName,dt,it,geoElt,whichEntity)) throw INTERP_KERNEL::Exception("MEDFileUMeshPerType::NewPart : The specified geo type is not present in the specified mesh !"); @@ -126,10 +142,10 @@ MEDFileUMeshPerType *MEDFileUMeshPerType::NewPart(med_idt fid, const char *mName MEDFileUMeshPerType *MEDFileUMeshPerType::NewPart(med_idt fid, const char *mName, int dt, int it, int mdim, INTERP_KERNEL::NormalizedCellType geoElt2, const std::vector& distrib, MEDFileMeshReadSelector *mrs) { - int geoElt2i((int)geoElt2); + int const geoElt2i((int)geoElt2); if(geoElt2i<0 || geoElt2i>=INTERP_KERNEL::NORM_MAXTYPE) throw INTERP_KERNEL::Exception("MEDFileUMeshPerType::NewPart : Not recognized MEDCoupling/MEDLoader geometric type !"); - med_geometry_type geoElt(typmai3[geoElt2]); + med_geometry_type const geoElt(typmai3[geoElt2]); med_entity_type whichEntity; if(!isExisting(fid,mName,dt,it,geoElt,whichEntity)) throw INTERP_KERNEL::Exception("MEDFileUMeshPerType::NewPart : The specified geo type is not present in the specified mesh !"); @@ -157,7 +173,7 @@ bool MEDFileUMeshPerType::isExisting(med_idt fid, const char *mName, int dt, int for(int i=0;i<3;i++) { med_bool changement,transformation; - mcIdType tmp(MEDmeshnEntity(fid,mName,dt,it,entities[i],geoElt,MED_CONNECTIVITY,MED_NODAL,&changement,&transformation)); + mcIdType const tmp(MEDmeshnEntity(fid,mName,dt,it,entities[i],geoElt,MED_CONNECTIVITY,MED_NODAL,&changement,&transformation)); if(tmp>nbOfElt) { nbOfElt=tmp; @@ -175,14 +191,13 @@ int MEDFileUMeshPerType::getDim() const } MEDFileUMeshPerType::MEDFileUMeshPerType() -{ -} += default; MEDFileUMeshPerType::MEDFileUMeshPerType(med_idt fid, const char *mName, int dt, int it, int mdim, med_geometry_type geoElt, INTERP_KERNEL::NormalizedCellType type, med_entity_type entity, MEDFileMeshReadSelector *mrs) { med_bool changement,transformation; - mcIdType curNbOfElem(MEDmeshnEntity(fid,mName,dt,it,entity,geoElt,MED_CONNECTIVITY,MED_NODAL,&changement,&transformation)); + mcIdType const curNbOfElem(MEDmeshnEntity(fid,mName,dt,it,entity,geoElt,MED_CONNECTIVITY,MED_NODAL,&changement,&transformation)); const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(type)); if(!cm.isDynamic()) { @@ -202,7 +217,7 @@ void MEDFileUMeshPerType::loadPart(med_idt fid, const char *mName, int dt, int i med_entity_type entity, const std::vector& distrib, MEDFileMeshReadSelector *mrs) { med_bool changement,transformation; - mcIdType curNbOfElem(MEDmeshnEntity(fid,mName,dt,it,entity,geoElt,MED_CONNECTIVITY,MED_NODAL,&changement,&transformation)); + mcIdType const curNbOfElem(MEDmeshnEntity(fid,mName,dt,it,entity,geoElt,MED_CONNECTIVITY,MED_NODAL,&changement,&transformation)); const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(type)); MCAuto listOfIds=DataArrayIdType::New(); listOfIds->useArray(distrib.data(),false,DeallocType::C_DEALLOC,distrib.size(),1); @@ -219,7 +234,7 @@ void MEDFileUMeshPerType::loadPart(med_idt fid, const char *mName, int dt, int i med_entity_type entity, mcIdType strt, mcIdType end, mcIdType step, MEDFileMeshReadSelector *mrs) { med_bool changement,transformation; - mcIdType curNbOfElem(MEDmeshnEntity(fid,mName,dt,it,entity,geoElt,MED_CONNECTIVITY,MED_NODAL,&changement,&transformation)); + mcIdType const curNbOfElem(MEDmeshnEntity(fid,mName,dt,it,entity,geoElt,MED_CONNECTIVITY,MED_NODAL,&changement,&transformation)); const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(type)); _pd=PartDefinition::New(strt,end,step); if(!cm.isDynamic()) @@ -231,13 +246,13 @@ void MEDFileUMeshPerType::loadPart(med_idt fid, const char *mName, int dt, int i } -void MEDFileUMeshPerType::loadFromStaticType(med_idt fid, const char *mName, int dt, int it, int mdim, mcIdType curNbOfElem, med_geometry_type geoElt, INTERP_KERNEL::NormalizedCellType type, +void MEDFileUMeshPerType::loadFromStaticType(med_idt fid, const char *mName, int dt, int it, int /*mdim*/, mcIdType curNbOfElem, med_geometry_type geoElt, INTERP_KERNEL::NormalizedCellType type, med_entity_type entity, MEDFileMeshReadSelector *mrs) { _m=MEDCoupling1SGTUMesh::New(mName,type); - MEDCoupling1SGTUMesh *mc(dynamic_cast((MEDCoupling1GTUMesh *)_m)); + auto *mc(dynamic_cast((MEDCoupling1GTUMesh *)_m)); MCAuto conn(DataArrayMedInt::New()); - mcIdType nbOfNodesPerCell(mc->getNumberOfNodesPerCell()); + mcIdType const nbOfNodesPerCell(mc->getNumberOfNodesPerCell()); conn->alloc(nbOfNodesPerCell*curNbOfElem,1); MEDFILESAFECALLERRD0(MEDmeshElementConnectivityRd,(fid,mName,dt,it,entity,geoElt,MED_NODAL,MED_FULL_INTERLACE,conn->getPointer())); std::transform(conn->begin(),conn->end(),conn->getPointer(),std::bind(std::plus(),std::placeholders::_1,-1)); @@ -249,12 +264,12 @@ void MEDFileUMeshPerType::loadPartStaticType(med_idt fid, const char *mName, int med_entity_type entity, MEDFileMeshReadSelector *mrs) { _m=MEDCoupling1SGTUMesh::New(mName,type); - MEDCoupling1SGTUMesh *mc(dynamic_cast((MEDCoupling1GTUMesh *)_m)); + auto *mc(dynamic_cast((MEDCoupling1GTUMesh *)_m)); MCAuto conn(DataArrayMedInt::New()); - mcIdType nbOfNodesPerCell(mc->getNumberOfNodesPerCell()); + mcIdType const nbOfNodesPerCell(mc->getNumberOfNodesPerCell()); if(!_pd) throw INTERP_KERNEL::Exception("MEDFileUMeshPerType::loadPartStaticType : no part definition !"); - mcIdType nbOfEltsToLoad(_pd->getNumberOfElems()); + mcIdType const nbOfEltsToLoad(_pd->getNumberOfElems()); conn->alloc(nbOfNodesPerCell*nbOfEltsToLoad,1); { MEDFilterEntity filter; @@ -269,13 +284,13 @@ void MEDFileUMeshPerType::loadPartStaticType(med_idt fid, const char *mName, int } -void MEDFileUMeshPerType::loadPartOfCellCommonPart(med_idt fid, const char *mName, int dt, int it, int mdim, mcIdType curNbOfElem, med_geometry_type geoElt, med_entity_type entity, MEDFileMeshReadSelector *mrs) +void MEDFileUMeshPerType::loadPartOfCellCommonPart(med_idt fid, const char *mName, int dt, int it, int /*mdim*/, mcIdType curNbOfElem, med_geometry_type geoElt, med_entity_type entity, MEDFileMeshReadSelector *mrs) { med_bool changement,transformation; if(!_pd) throw INTERP_KERNEL::Exception("MEDFileUMeshPerType::loadPartOfCellCommonPart : no part definition !"); - mcIdType nbOfEltsToLoad(_pd->getNumberOfElems()); - _fam=0; + mcIdType const nbOfEltsToLoad(_pd->getNumberOfElems()); + _fam=nullptr; if(MEDmeshnEntity(fid,mName,dt,it,entity,geoElt,MED_FAMILY_NUMBER,MED_NODAL,&changement,&transformation)>0) { if(!mrs || mrs->isCellFamilyFieldReading()) @@ -291,7 +306,7 @@ void MEDFileUMeshPerType::loadPartOfCellCommonPart(med_idt fid, const char *mNam _fam=FromMedIntArray(miFam); } } - _num=0; + _num=nullptr; if(MEDmeshnEntity(fid,mName,dt,it,entity,geoElt,MED_NUMBER,MED_NODAL,&changement,&transformation)>0) { if(!mrs || mrs->isCellNumFieldReading()) @@ -307,7 +322,7 @@ void MEDFileUMeshPerType::loadPartOfCellCommonPart(med_idt fid, const char *mNam _num=FromMedIntArray(miNum); } } - _names=0; + _names=nullptr; if(MEDmeshnEntity(fid,mName,dt,it,entity,geoElt,MED_NAME,MED_NODAL,&changement,&transformation)>0) { if(!mrs || mrs->isCellNameFieldReading()) @@ -319,18 +334,18 @@ void MEDFileUMeshPerType::loadPartOfCellCommonPart(med_idt fid, const char *mNam MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE, _pd); if(MEDmeshEntityAttributeAdvancedRd(fid,mName,MED_NAME,dt,it,entity,geoElt,filter.getPtr(),_names->getPointer())!=0) - _names=0; + _names=nullptr; else _names->reAlloc(nbOfEltsToLoad);//not a bug to avoid the memory corruption due to last \0 at the end } } } -void MEDFileUMeshPerType::loadPolyg(med_idt fid, const char *mName, int dt, int it, int mdim, mcIdType arraySize, med_geometry_type geoElt, +void MEDFileUMeshPerType::loadPolyg(med_idt fid, const char *mName, int dt, int it, int /*mdim*/, mcIdType arraySize, med_geometry_type geoElt, med_entity_type entity, MEDFileMeshReadSelector *mrs) { med_bool changement,transformation; - mcIdType curNbOfElem(MEDmeshnEntity(fid,mName,dt,it,entity,geoElt,MED_INDEX_NODE,MED_NODAL,&changement,&transformation)-1); + mcIdType const curNbOfElem(MEDmeshnEntity(fid,mName,dt,it,entity,geoElt,MED_INDEX_NODE,MED_NODAL,&changement,&transformation)-1); _m=MEDCoupling1DGTUMesh::New(mName,geoElt==MED_POLYGON?INTERP_KERNEL::NORM_POLYGON:INTERP_KERNEL::NORM_QPOLYG); MCAuto mc(DynamicCast(_m)); MCAuto conn(DataArrayMedInt::New()),connI(DataArrayMedInt::New()); @@ -342,12 +357,12 @@ void MEDFileUMeshPerType::loadPolyg(med_idt fid, const char *mName, int dt, int loadCommonPart(fid,mName,dt,it,curNbOfElem,geoElt,entity,mrs); } -void MEDFileUMeshPerType::loadPolyh(med_idt fid, const char *mName, int dt, int it, int mdim, mcIdType connFaceLgth, med_geometry_type geoElt, +void MEDFileUMeshPerType::loadPolyh(med_idt fid, const char *mName, int dt, int it, int /*mdim*/, mcIdType connFaceLgth, med_geometry_type /*geoElt*/, med_entity_type entity, MEDFileMeshReadSelector *mrs) { med_bool changement,transformation; - med_int indexFaceLgth(MEDmeshnEntity(fid,mName,dt,it,MED_CELL,MED_POLYHEDRON,MED_INDEX_NODE,MED_NODAL,&changement,&transformation)); - mcIdType curNbOfElem(MEDmeshnEntity(fid,mName,dt,it,MED_CELL,MED_POLYHEDRON,MED_INDEX_FACE,MED_NODAL,&changement,&transformation)-1); + med_int const indexFaceLgth(MEDmeshnEntity(fid,mName,dt,it,MED_CELL,MED_POLYHEDRON,MED_INDEX_NODE,MED_NODAL,&changement,&transformation)); + mcIdType const curNbOfElem(MEDmeshnEntity(fid,mName,dt,it,MED_CELL,MED_POLYHEDRON,MED_INDEX_FACE,MED_NODAL,&changement,&transformation)-1); _m=MEDCoupling1DGTUMesh::New(mName,INTERP_KERNEL::NORM_POLYHED); MCAuto mc(DynamicCastSafe(_m)); INTERP_KERNEL::AutoPtr index=new med_int[curNbOfElem+1]; @@ -378,19 +393,19 @@ void MEDFileUMeshPerType::loadPolyh(med_idt fid, const char *mName, int dt, int loadCommonPart(fid,mName,dt,it,curNbOfElem,MED_POLYHEDRON,entity,mrs); } -void MEDFileUMeshPerType::Write(med_idt fid, const std::string& mname, int mdim, const MEDCoupling1GTUMesh *m, const DataArrayIdType *fam, const DataArrayIdType *num, const DataArrayAsciiChar *names) +void MEDFileUMeshPerType::Write(med_idt fid, const std::string& mname, int /*mdim*/, const MEDCoupling1GTUMesh *m, const DataArrayIdType *fam, const DataArrayIdType *num, const DataArrayAsciiChar *names) { - mcIdType nbOfCells=m->getNumberOfCells(); + mcIdType const nbOfCells=m->getNumberOfCells(); if(nbOfCells<1) return ; int dt,it; - double timm=m->getTime(dt,it); - INTERP_KERNEL::NormalizedCellType ikt=m->getTypeOfCell(0); + double const timm=m->getTime(dt,it); + INTERP_KERNEL::NormalizedCellType const ikt=m->getTypeOfCell(0); const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(ikt); - med_geometry_type curMedType=typmai3[(int)ikt]; + med_geometry_type const curMedType=typmai3[(int)ikt]; if(!cm.isDynamic()) { - const MEDCoupling1SGTUMesh *m0(dynamic_cast(m)); + const auto *m0(dynamic_cast(m)); if(!m0) throw INTERP_KERNEL::Exception("MEDFileUMeshPerType::Write : internal error #1 !"); MCAuto arr(DataArrayMedInt_Copy(m0->getNodalConnectivity())); @@ -399,7 +414,7 @@ void MEDFileUMeshPerType::Write(med_idt fid, const std::string& mname, int mdim, } else { - const MEDCoupling1DGTUMesh *m0(dynamic_cast(m)); + const auto *m0(dynamic_cast(m)); if(!m0) throw INTERP_KERNEL::Exception("MEDFileUMeshPerType::Write : internal error #2 !"); if(ikt==INTERP_KERNEL::NORM_POLYGON || ikt==INTERP_KERNEL::NORM_QPOLYG) @@ -412,8 +427,8 @@ void MEDFileUMeshPerType::Write(med_idt fid, const std::string& mname, int mdim, else { const mcIdType *conn(m0->getNodalConnectivity()->begin()),*connI(m0->getNodalConnectivityIndex()->begin()); - mcIdType meshLgth=m0->getNodalConnectivityLength(); - mcIdType nbOfFaces=ToIdType(std::count(conn,conn+meshLgth,-1)+nbOfCells); + mcIdType const meshLgth=m0->getNodalConnectivityLength(); + mcIdType const nbOfFaces=ToIdType(std::count(conn,conn+meshLgth,-1)+nbOfCells); INTERP_KERNEL::AutoPtr tab1=new med_int[nbOfCells+1]; med_int *w1=tab1; *w1=1; INTERP_KERNEL::AutoPtr tab2=new med_int[nbOfFaces+1]; @@ -427,7 +442,7 @@ void MEDFileUMeshPerType::Write(med_idt fid, const std::string& mname, int mdim, { const mcIdType *wend=std::find(w,conn+connI[i+1],-1); bt=std::transform(w,wend,bt,std::bind(std::plus(),std::placeholders::_1,1)); - std::size_t nbOfNode=std::distance(w,wend); + std::size_t const nbOfNode=std::distance(w,wend); w2[1]=w2[0]+(med_int)nbOfNode; if(wend!=conn+connI[i+1]) w=wend+1; diff --git a/src/MEDLoader/MEDFileMeshElt.hxx b/src/MEDLoader/MEDFileMeshElt.hxx index 7975553b0..5258aef7a 100644 --- a/src/MEDLoader/MEDFileMeshElt.hxx +++ b/src/MEDLoader/MEDFileMeshElt.hxx @@ -21,14 +21,19 @@ #ifndef __MEDFILEMESHELT_HXX__ #define __MEDFILEMESHELT_HXX__ +#include "MCType.hxx" #include "MEDCouplingMemArray.hxx" #include "MEDCoupling1GTUMesh.hxx" #include "MEDCouplingPartDefinition.hxx" #include "MCAuto.hxx" -#include "NormalizedUnstructuredMesh.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include "NormalizedGeometricTypes" #include "med.h" +#include +#include +#include namespace MEDCoupling { @@ -42,8 +47,8 @@ namespace MEDCoupling std::string getClassName() const override { return std::string("MEDFileUMeshPerTypeCommon"); } void loadCommonPart(med_idt fid, const char *mName, int dt, int it, mcIdType curNbOfElem, med_geometry_type geoElt, med_entity_type entity, MEDFileMeshReadSelector *mrs); - std::size_t getHeapMemorySizeWithoutChildren() const; - std::vector getDirectChildrenWithNull() const; + std::size_t getHeapMemorySizeWithoutChildren() const override; + std::vector getDirectChildrenWithNull() const override; const DataArrayIdType *getFam() const { return _fam; } const DataArrayIdType *getNum() const { return _num; } const DataArrayAsciiChar *getNames() const { return _names; } @@ -62,8 +67,8 @@ namespace MEDCoupling std::string getClassName() const override { return std::string("MEDFileUMeshPerType"); } static bool isExisting(med_idt fid, const char *mName, int dt, int it, med_geometry_type geoElt, med_entity_type& whichEntity); - std::size_t getHeapMemorySizeWithoutChildren() const; - std::vector getDirectChildrenWithNull() const; + std::size_t getHeapMemorySizeWithoutChildren() const override; + std::vector getDirectChildrenWithNull() const override; int getDim() const; MEDCoupling1GTUMesh *getMesh() const { return const_cast((const MEDCoupling1GTUMesh *)_m); } const PartDefinition *getPartDef() const { return _pd; } diff --git a/src/MEDLoader/MEDFileMeshLL.cxx b/src/MEDLoader/MEDFileMeshLL.cxx index 5baacd48a..f2341131f 100644 --- a/src/MEDLoader/MEDFileMeshLL.cxx +++ b/src/MEDLoader/MEDFileMeshLL.cxx @@ -19,7 +19,19 @@ // Author : Anthony Geay (CEA/DEN) #include "MEDFileMeshLL.hxx" +#include "MEDCouplingCurveLinearMesh.hxx" +#include "MEDCouplingMesh.hxx" +#include "MEDCouplingMemArray.txx" +#include "MEDFileBasis.hxx" +#include "MCType.hxx" +#include "MCAuto.hxx" +#include "MEDCouplingMap.txx" +#include "MEDCouplingPartDefinition.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include "MCIdType.hxx" +#include "MEDCoupling1GTUMesh.hxx" #include "MEDFileMesh.hxx" +#include "MEDFileMeshElt.hxx" #include "MEDLoaderBase.hxx" #include "MEDFileSafeCaller.txx" #include "MEDFileMeshReadSelector.hxx" @@ -32,7 +44,22 @@ #include "CellModel.hxx" #include "MEDFilterEntity.hxx" +#include "med.h" +#include "NormalizedGeometricTypes" +#include "medmesh.h" +#include +#include +#include "medfamily.h" +#include "medstructelement.h" +#include +#include +#include +#include #include +#include +#include +#include +#include #include // From MEDLOader.cxx TU @@ -52,11 +79,11 @@ std::vector MeshCls::getAxisInfoOnMesh(med_idt fid, const std::stri med_int spaceDim, meshDim, nbSteps; med_sorting_type stype; med_axis_type axistype; - med_int naxis(MEDmeshnAxis(fid,getID())); + med_int const naxis(MEDmeshnAxis(fid,getID())); INTERP_KERNEL::AutoPtr nameTmp(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)); INTERP_KERNEL::AutoPtr axisname(MEDLoaderBase::buildEmptyString(naxis*MED_SNAME_SIZE)); INTERP_KERNEL::AutoPtr axisunit(MEDLoaderBase::buildEmptyString(naxis*MED_SNAME_SIZE)); - INTERP_KERNEL::AutoPtr univTmp(MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE)); + INTERP_KERNEL::AutoPtr const univTmp(MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE)); if(MEDmeshInfo(fid,getID(),nameTmp,&spaceDim,&meshDim,&type_maillage,description.getPointer(),dtunit.getPointer(), &stype,&nbSteps,&axistype,axisname,axisunit)!=0) throw INTERP_KERNEL::Exception("A problem has been detected when trying to get info on mesh !"); @@ -96,7 +123,7 @@ std::vector MeshCls::getAxisInfoOnMesh(med_idt fid, const std::stri std::vector infosOnComp(naxis); for(int i=0;i StructMeshCls::getAxisInfoOnMesh(med_idt fid, const std::string& mName, MEDCoupling::MEDCouplingMeshType& meshType, MEDCoupling::MEDCouplingAxisType& axType, int& nstep, int& Mdim, MEDFileString& description, MEDFileString& dtunit, MEDFileString& univName) const +std::vector StructMeshCls::getAxisInfoOnMesh(med_idt fid, const std::string& /*mName*/, MEDCoupling::MEDCouplingMeshType& meshType, MEDCoupling::MEDCouplingAxisType& axType, int& nstep, int& /*Mdim*/, MEDFileString& description, MEDFileString& dtunit, MEDFileString& univName) const { INTERP_KERNEL::AutoPtr msn(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)); INTERP_KERNEL::AutoPtr zeDescription(MEDLoaderBase::buildEmptyString(MED_COMMENT_SIZE)); med_axis_type medAxType; - med_int nAxis(MEDsupportMeshnAxis(fid,getID())); + med_int const nAxis(MEDsupportMeshnAxis(fid,getID())); INTERP_KERNEL::AutoPtr axisName(new char[MED_SNAME_SIZE*nAxis+1]),axisUnit(new char[MED_SNAME_SIZE*nAxis+1]); med_int spaceDim(0),meshDim(0); MEDFILESAFECALLERRD0(MEDsupportMeshInfo,(fid,getID(),msn,&spaceDim,&meshDim,zeDescription,&medAxType,axisName,axisUnit)); - std::string descriptionCpp(MEDLoaderBase::buildStringFromFortran(zeDescription,MED_COMMENT_SIZE)); + std::string const descriptionCpp(MEDLoaderBase::buildStringFromFortran(zeDescription,MED_COMMENT_SIZE)); description.set(descriptionCpp.c_str()); dtunit.clear(); univName.clear(); meshType=UNSTRUCTURED; nstep=1; axType=MEDFileMeshL2::TraduceAxisType(medAxType); @@ -145,14 +172,14 @@ std::vector StructMeshCls::getAxisInfoOnMesh(med_idt fid, const std std::vector ret; for(int i=0;i MEDFileMeshL2::GetMeshIdFromName( char dtunit[MED_LNAME_SIZE+1]; med_int spaceDim,dim; char nommaa[MED_NAME_SIZE+1]; - med_int n=MEDnMesh(fid); + med_int const n=MEDnMesh(fid); char found(0); int ret=-1; med_sorting_type stype; @@ -187,11 +214,11 @@ INTERP_KERNEL::AutoCppPtr MEDFileMeshL2::GetMeshIdFromName( med_axis_type axistype=MED_UNDEF_AXIS_TYPE; for(int i=0;i axisname(MEDLoaderBase::buildEmptyString(naxis*MED_SNAME_SIZE)),axisunit(MEDLoaderBase::buildEmptyString(naxis*MED_SNAME_SIZE)); MEDFILESAFECALLERRD0(MEDmeshInfo,(fid,i+1,nommaa,&spaceDim,&dim,&type_maillage,maillage_description,dtunit,&stype,&nstep,&axistype,axisname,axisunit)); dtunit1=MEDLoaderBase::buildStringFromFortran(dtunit,sizeof(dtunit)); - std::string cur(MEDLoaderBase::buildStringFromFortran(nommaa,sizeof(nommaa))); + std::string const cur(MEDLoaderBase::buildStringFromFortran(nommaa,sizeof(nommaa))); ms.push_back(cur); if(cur==mName) { @@ -201,13 +228,13 @@ INTERP_KERNEL::AutoCppPtr MEDFileMeshL2::GetMeshIdFromName( } if(found==0) {//last chance ! Is it a support mesh ? - med_int nbSM(MEDnSupportMesh(fid)); + med_int const nbSM(MEDnSupportMesh(fid)); for(int i=0;i axisname(MEDLoaderBase::buildEmptyString(naxis*MED_SNAME_SIZE)),axisunit(MEDLoaderBase::buildEmptyString(naxis*MED_SNAME_SIZE)); MEDFILESAFECALLERRD0(MEDsupportMeshInfo,(fid,i+1,nommaa,&spaceDim,&dim,maillage_description,&axistype,axisname,axisunit)); - std::string cur(MEDLoaderBase::buildStringFromFortran(nommaa,sizeof(nommaa))); + std::string const cur(MEDLoaderBase::buildStringFromFortran(nommaa,sizeof(nommaa))); ms.push_back(cur); if(cur==mName) { @@ -288,29 +315,29 @@ void MEDFileMeshL2::ReadFamiliesAndGrps(med_idt fid, const std::string& meshName return ; char nomfam[MED_NAME_SIZE+1]; med_int numfam; - med_int nfam=MEDnFamily(fid,meshName.c_str()); + med_int const nfam=MEDnFamily(fid,meshName.c_str()); std::vector< std::pair > > > crudeFams(nfam); for(int i=0;i attide=new med_int[natt]; INTERP_KERNEL::AutoPtr attval=new med_int[natt]; INTERP_KERNEL::AutoPtr attdes=new char[MED_COMMENT_SIZE*natt+1]; INTERP_KERNEL::AutoPtr gro=new char[MED_LNAME_SIZE*ngro+1]; MEDfamily23Info(fid,meshName.c_str(),i+1,nomfam,attide,attval,attdes,&numfam,gro); - std::string famName(MEDLoaderBase::buildStringFromFortran(nomfam,MED_NAME_SIZE)); + std::string const famName(MEDLoaderBase::buildStringFromFortran(nomfam,MED_NAME_SIZE)); std::vector grps2(ngro); for(int j=0;j > >(famName,std::pair >(numfam,grps2)); } RenameFamiliesFromFileToMemInternal(crudeFams); - for(std::vector< std::pair > > >::const_iterator it0=crudeFams.begin();it0!=crudeFams.end();it0++) + for(const auto & crudeFam : crudeFams) { - fams[(*it0).first]=(*it0).second.first; - for(std::vector::const_iterator it1=(*it0).second.second.begin();it1!=(*it0).second.second.end();it1++) - grps[*it1].push_back((*it0).first); + fams[crudeFam.first]=crudeFam.second.first; + for(auto it1=crudeFam.second.second.begin();it1!=crudeFam.second.second.end();it1++) + grps[*it1].push_back(crudeFam.first); } } @@ -318,27 +345,27 @@ void MEDFileMeshL2::WriteFamiliesAndGrps(med_idt fid, const std::string& mname, { std::vector< std::pair > > > crudeFams(fams.size()); std::size_t ii(0); - for(std::map::const_iterator it=fams.begin();it!=fams.end();it++,ii++) + for(auto it=fams.begin();it!=fams.end();it++,ii++) { std::vector grpsOfFam; - for(std::map >::const_iterator it1=grps.begin();it1!=grps.end();it1++) + for(const auto & grp : grps) { - if(std::find((*it1).second.begin(),(*it1).second.end(),(*it).first)!=(*it1).second.end()) - grpsOfFam.push_back((*it1).first); + if(std::find(grp.second.begin(),grp.second.end(),(*it).first)!=grp.second.end()) + grpsOfFam.push_back(grp.first); } crudeFams[ii]=std::pair > >((*it).first,std::pair >((*it).second,grpsOfFam)); } RenameFamiliesFromMemToFileInternal(crudeFams); - for(std::vector< std::pair > > >::const_iterator it=crudeFams.begin();it!=crudeFams.end();it++) + for(const auto & crudeFam : crudeFams) { - std::size_t ngro((*it).second.second.size()); + std::size_t const ngro(crudeFam.second.second.size()); INTERP_KERNEL::AutoPtr groName=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE*ngro); int i=0; - for(std::vector::const_iterator it2=(*it).second.second.begin();it2!=(*it).second.second.end();it2++,i++) + for(auto it2=crudeFam.second.second.begin();it2!=crudeFam.second.second.end();it2++,i++) MEDLoaderBase::safeStrCpy2((*it2).c_str(),MED_LNAME_SIZE,groName+i*MED_LNAME_SIZE,tooLongStrPol); INTERP_KERNEL::AutoPtr famName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); - MEDLoaderBase::safeStrCpy((*it).first.c_str(),MED_NAME_SIZE,famName,tooLongStrPol); - med_int ret=MEDfamilyCr(fid,mname.c_str(),famName,ToMedInt((*it).second.first),ToMedInt(ngro),groName); + MEDLoaderBase::safeStrCpy(crudeFam.first.c_str(),MED_NAME_SIZE,famName,tooLongStrPol); + med_int ret=MEDfamilyCr(fid,mname.c_str(),famName,ToMedInt(crudeFam.second.first),ToMedInt(ngro),groName); ret++; } } @@ -352,7 +379,7 @@ void MEDFileMeshL2::RenameFamiliesPatternInternal(std::vector< std::pair > > >::iterator it=crudeFams.begin();it!=crudeFams.end();it++,ii++) + for(auto it=crudeFams.begin();it!=crudeFams.end();it++,ii++) (*it).first=fams[ii]; } @@ -369,21 +396,21 @@ bool MEDFileMeshL2::RenameFamiliesFromFileToMem(std::vector< std::string >& famN { std::map m; std::set s; - for(std::vector< std::string >::const_iterator it=famNames.begin();it!=famNames.end();it++) + for(const auto & famName : famNames) { - if(s.find(*it)!=s.end()) - m[*it]=0; - s.insert(*it); + if(s.find(famName)!=s.end()) + m[famName]=0; + s.insert(famName); } if(m.empty()) return false;// the general case ! - for(std::vector< std::string >::iterator it=famNames.begin();it!=famNames.end();it++) + for(auto & famName : famNames) { - std::map::iterator it2(m.find(*it)); + auto const it2(m.find(famName)); if(it2!=m.end()) { - std::ostringstream oss; oss << *it << ZE_SEP_FOR_FAMILY_KILLERS << std::setfill('0') << std::setw(ZE_SEP2_FOR_FAMILY_KILLERS) << (*it2).second++; - *it=oss.str(); + std::ostringstream oss; oss << famName << ZE_SEP_FOR_FAMILY_KILLERS << std::setfill('0') << std::setw(ZE_SEP2_FOR_FAMILY_KILLERS) << (*it2).second++; + famName=oss.str(); } } return true; @@ -401,9 +428,9 @@ void MEDFileMeshL2::RenameFamiliesFromMemToFileInternal(std::vector< std::pair& famNames) { bool isSmthingStrange(false); - for(std::vector< std::string >::const_iterator it=famNames.begin();it!=famNames.end();it++) + for(const auto & famName : famNames) { - std::size_t found((*it).find(ZE_SEP_FOR_FAMILY_KILLERS)); + std::size_t const found(famName.find(ZE_SEP_FOR_FAMILY_KILLERS)); if(found!=std::string::npos) isSmthingStrange=true; } @@ -411,22 +438,22 @@ bool MEDFileMeshL2::RenameFamiliesFromMemToFile(std::vector< std::string >& famN return false; // pattern matching std::map< std::string, std::vector > m; - for(std::vector< std::string >::const_iterator it=famNames.begin();it!=famNames.end();it++) + for(const auto & famName : famNames) { - std::size_t found((*it).find(ZE_SEP_FOR_FAMILY_KILLERS)); + std::size_t const found(famName.find(ZE_SEP_FOR_FAMILY_KILLERS)); if(found!=std::string::npos && found>=1) { - std::string s1((*it).substr(found+sizeof(ZE_SEP_FOR_FAMILY_KILLERS)-1)); + std::string const s1(famName.substr(found+sizeof(ZE_SEP_FOR_FAMILY_KILLERS)-1)); if((int)s1.size()!=ZE_SEP2_FOR_FAMILY_KILLERS) continue; int k(-1); std::istringstream iss(s1); iss >> k; - bool isOK((iss.rdstate() & ( std::istream::failbit | std::istream::eofbit)) == std::istream::eofbit); + bool const isOK((iss.rdstate() & ( std::istream::failbit | std::istream::eofbit)) == std::istream::eofbit); if(isOK && k>=0) { - std::string s0((*it).substr(0,found)); - m[s0].push_back(*it); + std::string const s0(famName.substr(0,found)); + m[s0].push_back(famName); } } } @@ -438,17 +465,17 @@ bool MEDFileMeshL2::RenameFamiliesFromMemToFile(std::vector< std::string >& famN { if((*it).second.size()==1) continue; - for(std::vector::const_iterator it1=(*it).second.begin();it1!=(*it).second.end();it1++) + for(auto it1=(*it).second.begin();it1!=(*it).second.end();it1++) zeMap[*it1]=(*it).first; } if(zeMap.empty()) return false; // traduce - for(std::vector< std::string >::iterator it=famNames.begin();it!=famNames.end();it++) + for(auto & famName : famNames) { - std::map::iterator it1(zeMap.find(*it)); + auto const it1(zeMap.find(famName)); if(it1!=zeMap.end()) - *it=(*it1).second; + famName=(*it1).second; } return true; } @@ -514,8 +541,7 @@ med_grid_type MEDFileMeshL2::TraduceAxisTypeRevStruct(MEDCoupling::MEDCouplingAx } MEDFileUMeshL2::MEDFileUMeshL2() -{ -} += default; std::vector MEDFileUMeshL2::loadCommonPart(med_idt fid, const MeshOrStructMeshCls *mId, const std::string& mName, int dt, int it, int& Mdim) { @@ -541,7 +567,7 @@ std::vector MEDFileUMeshL2::loadCommonPart(med_idt fid, const MeshO void MEDFileUMeshL2::loadAll(med_idt fid, const MeshOrStructMeshCls *mId, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs) { int Mdim; - std::vector infosOnComp(loadCommonPart(fid,mId,mName,dt,it,Mdim)); + std::vector const infosOnComp(loadCommonPart(fid,mId,mName,dt,it,Mdim)); if(Mdim==-4) return ; loadConnectivity(fid,Mdim,mName,dt,it,mrs);//to improve check (dt,it) coherency @@ -554,32 +580,32 @@ void MEDFileUMeshL2::loadAll(med_idt fid, const MeshOrStructMeshCls *mId, const * - dealing with optimized load of coordinates (loading only points fetched by the already loaded cells) * - update the connectivity in \a this to fit the coordinates loaded just above */ -void MEDFileUMeshL2::dealWithCoordsInLoadPart(med_idt fid, const MeshOrStructMeshCls *mId, const std::string& mName, const std::vector& infosOnComp, const std::vector& types, const std::vector& slicPerTyp, int dt, int it, MEDFileMeshReadSelector *mrs) +void MEDFileUMeshL2::dealWithCoordsInLoadPart(med_idt fid, const MeshOrStructMeshCls * /*mId*/, const std::string& mName, const std::vector& infosOnComp, const std::vector& /*types*/, const std::vector& /*slicPerTyp*/, int dt, int it, MEDFileMeshReadSelector *mrs) { med_bool changement,transformation; - mcIdType nCoords(MEDmeshnEntity(fid,mName.c_str(),dt,it,MED_NODE,MED_NONE,MED_COORDINATE,MED_NO_CMODE,&changement,&transformation)); + mcIdType const nCoords(MEDmeshnEntity(fid,mName.c_str(),dt,it,MED_NODE,MED_NONE,MED_COORDINATE,MED_NO_CMODE,&changement,&transformation)); std::vector fetchedNodeIds(nCoords,false); - for(std::vector< std::vector< MCAuto > >::const_iterator it0=_per_type_mesh.begin();it0!=_per_type_mesh.end();it0++) - for(std::vector< MCAuto >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++) - (*it1)->getMesh()->computeNodeIdsAlg(fetchedNodeIds); + for(const auto & it0 : _per_type_mesh) + for(const auto & it1 : it0) + it1->getMesh()->computeNodeIdsAlg(fetchedNodeIds); if(!mrs || mrs->getNumberOfCoordsLoadSessions()==1) { - mcIdType nMin(ToIdType(std::distance(fetchedNodeIds.begin(),std::find(fetchedNodeIds.begin(),fetchedNodeIds.end(),true)))); + mcIdType const nMin(ToIdType(std::distance(fetchedNodeIds.begin(),std::find(fetchedNodeIds.begin(),fetchedNodeIds.end(),true)))); mcIdType nMax(ToIdType(std::distance(fetchedNodeIds.rbegin(),std::find(fetchedNodeIds.rbegin(),fetchedNodeIds.rend(),true)))); nMax=nCoords-nMax; - for(std::vector< std::vector< MCAuto > >::const_iterator it0=_per_type_mesh.begin();it0!=_per_type_mesh.end();it0++) - for(std::vector< MCAuto >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++) - (*it1)->getMesh()->renumberNodesWithOffsetInConn(-nMin); + for(const auto & it0 : _per_type_mesh) + for(const auto & it1 : it0) + it1->getMesh()->renumberNodesWithOffsetInConn(-nMin); this->loadPartCoords(fid,infosOnComp,mName,dt,it,nMin,nMax); } else { - mcIdType nbOfCooLS(mrs->getNumberOfCoordsLoadSessions()); + mcIdType const nbOfCooLS(mrs->getNumberOfCoordsLoadSessions()); MCAuto fni(DataArrayIdType::BuildListOfSwitchedOn(fetchedNodeIds)); MCAuto< MapKeyVal > o2n(fni->invertArrayN2O2O2NOptimized()); - for(std::vector< std::vector< MCAuto > >::const_iterator it0=_per_type_mesh.begin();it0!=_per_type_mesh.end();it0++) - for(std::vector< MCAuto >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++) - (*it1)->getMesh()->renumberNodesInConn(o2n->data()); + for(const auto & it0 : _per_type_mesh) + for(const auto & it1 : it0) + it1->getMesh()->renumberNodesInConn(o2n->data()); this->loadPartCoordsSlice(fid,infosOnComp,mName,dt,it,fni,nbOfCooLS); } } @@ -596,7 +622,7 @@ std::vector MEDFileUMeshL2::loadPartConnectivityOnly(med_idt fid, c void MEDFileUMeshL2::loadPart(med_idt fid, const MeshOrStructMeshCls *mId, const std::string& mName, const std::vector& types, const std::vector& slicPerTyp, int dt, int it, MEDFileMeshReadSelector *mrs) { int Mdim; - std::vector infosOnComp(loadPartConnectivityOnly(fid,mId,mName,types,slicPerTyp,dt,it,mrs,Mdim)); + std::vector const infosOnComp(loadPartConnectivityOnly(fid,mId,mName,types,slicPerTyp,dt,it,mrs,Mdim)); if(Mdim==-4) return ; loadPartOfConnectivity(fid,Mdim,mName,types,slicPerTyp,dt,it,mrs); @@ -612,7 +638,7 @@ void MEDFileUMeshL2::loadPart(med_idt fid, const MeshOrStructMeshCls *mId, const void MEDFileUMeshL2::loadPartFromUserDistrib(med_idt fid, const MeshOrStructMeshCls *mId, const std::string& mName, const std::map>& distrib, int dt, int it, MEDFileMeshReadSelector *mrs) { int Mdim; - std::vector infosOnComp(loadCommonPart(fid,mId,mName,dt,it,Mdim)); + std::vector const infosOnComp(loadCommonPart(fid,mId,mName,dt,it,Mdim)); if(Mdim==-4) return ; @@ -621,11 +647,11 @@ void MEDFileUMeshL2::loadPartFromUserDistrib(med_idt fid, const MeshOrStructMesh /* Second step : loading nodes */ med_bool changement,transformation; - mcIdType nCoords(MEDmeshnEntity(fid,mName.c_str(),dt,it,MED_NODE,MED_NONE,MED_COORDINATE,MED_NO_CMODE,&changement,&transformation)); + mcIdType const nCoords(MEDmeshnEntity(fid,mName.c_str(),dt,it,MED_NODE,MED_NONE,MED_COORDINATE,MED_NO_CMODE,&changement,&transformation)); std::vector fetchedNodeIds(nCoords,false); - for(std::vector< std::vector< MCAuto > >::const_iterator it0=_per_type_mesh.begin();it0!=_per_type_mesh.end();it0++) - for(std::vector< MCAuto >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++) - (*it1)->getMesh()->computeNodeIdsAlg(fetchedNodeIds); // for each node in the original mesh, which ones are laying on the current single geometrical type partial mesh + for(const auto & it0 : _per_type_mesh) + for(const auto & it1 : it0) + it1->getMesh()->computeNodeIdsAlg(fetchedNodeIds); // for each node in the original mesh, which ones are laying on the current single geometrical type partial mesh if(!mrs || mrs->getNumberOfCoordsLoadSessions()==1) { @@ -635,9 +661,9 @@ void MEDFileUMeshL2::loadPartFromUserDistrib(med_idt fid, const MeshOrStructMesh // thus we want each node to be renumbered so that the sequence of their numbers form a range MCAuto fni(DataArrayIdType::BuildListOfSwitchedOn(fetchedNodeIds)); MCAuto< MapKeyVal > o2n(fni->invertArrayN2O2O2NOptimized()); - for(std::vector< std::vector< MCAuto > >::const_iterator it0=_per_type_mesh.begin();it0!=_per_type_mesh.end();it0++) - for(std::vector< MCAuto >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++) - (*it1)->getMesh()->renumberNodesInConn(o2n->data()); + for(const auto & it0 : _per_type_mesh) + for(const auto & it1 : it0) + it1->getMesh()->renumberNodesInConn(o2n->data()); // loading coordinates of fetched nodes std::vector distribNodes; @@ -664,10 +690,10 @@ void MEDFileUMeshL2::loadConnectivity(med_idt fid, int mdim, const std::string& void MEDFileUMeshL2::loadPartOfConnectivity(med_idt fid, int mdim, const std::string& mName, const std::vector& types, const std::vector& slicPerTyp, int dt, int it, MEDFileMeshReadSelector *mrs) { - std::size_t nbOfTypes(types.size()); + std::size_t const nbOfTypes(types.size()); if(slicPerTyp.size()!=3*nbOfTypes) throw INTERP_KERNEL::Exception("MEDFileUMeshL2::loadPartOfConnectivity : The size of slicPerTyp array is expected to be equal to 3 times size of array types !"); - std::set types2(types.begin(),types.end()); + std::set const types2(types.begin(),types.end()); if(types2.size()!=nbOfTypes) throw INTERP_KERNEL::Exception("MEDFileUMeshL2::loadPartOfConnectivity : the geometric types in types array must appear once !"); _per_type_mesh.resize(1); @@ -675,7 +701,7 @@ void MEDFileUMeshL2::loadPartOfConnectivity(med_idt fid, int mdim, const std::st for(std::size_t ii=0;ii tmp(MEDFileUMeshPerType::NewPart(fid,mName.c_str(),dt,it,mdim,types[ii],strt,stp,step,mrs)); + MCAuto const tmp(MEDFileUMeshPerType::NewPart(fid,mName.c_str(),dt,it,mdim,types[ii],strt,stp,step,mrs)); _per_type_mesh[0].push_back(tmp); } sortTypes(); @@ -692,7 +718,7 @@ void MEDFileUMeshL2::loadPartOfConnectivityFromUserDistrib(med_idt fid, int mdim std::map>::const_iterator iter; for (iter = distrib.begin(); iter != distrib.end(); iter++) { - MCAuto tmp(MEDFileUMeshPerType::NewPart(fid,mName.c_str(),dt,it,mdim,iter->first/*type*/,iter->second/*distrib over the current type*/,mrs)); + MCAuto const tmp(MEDFileUMeshPerType::NewPart(fid,mName.c_str(),dt,it,mdim,iter->first/*type*/,iter->second/*distrib over the current type*/,mrs)); _per_type_mesh[0].push_back(tmp); } sortTypes(); @@ -700,9 +726,9 @@ void MEDFileUMeshL2::loadPartOfConnectivityFromUserDistrib(med_idt fid, int mdim void MEDFileUMeshL2::loadCoords(med_idt fid, const std::vector& infosOnComp, const std::string& mName, int dt, int it) { - int spaceDim((int)infosOnComp.size()); + int const spaceDim((int)infosOnComp.size()); med_bool changement,transformation; - med_int nCoords(MEDmeshnEntity(fid,mName.c_str(),dt,it,MED_NODE,MED_NONE,MED_COORDINATE,MED_NO_CMODE,&changement,&transformation)); + med_int const nCoords(MEDmeshnEntity(fid,mName.c_str(),dt,it,MED_NODE,MED_NONE,MED_COORDINATE,MED_NO_CMODE,&changement,&transformation)); _coords=DataArrayDouble::New(); _coords->alloc(nCoords,spaceDim); double *coordsPtr(_coords->getPointer()); @@ -716,7 +742,7 @@ void MEDFileUMeshL2::loadCoords(med_idt fid, const std::vector& inf _fam_coords=FromMedIntArray(miFamCoord); } else - _fam_coords=0; + _fam_coords=nullptr; if(MEDmeshnEntity(fid,mName.c_str(),dt,it,MED_NODE,MED_NO_GEOTYPE,MED_NUMBER,MED_NODAL,&changement,&transformation)>0) { MCAuto miNumCoord=DataArrayMedInt::New(); @@ -725,7 +751,7 @@ void MEDFileUMeshL2::loadCoords(med_idt fid, const std::vector& inf _num_coords=FromMedIntArray(miNumCoord); } else - _num_coords=0; + _num_coords=nullptr; if(MEDmeshnEntity(fid,mName.c_str(),dt,it,MED_NODE,MED_NO_GEOTYPE,MED_NAME,MED_NODAL,&changement,&transformation)>0) { _name_coords=DataArrayAsciiChar::New(); @@ -734,7 +760,7 @@ void MEDFileUMeshL2::loadCoords(med_idt fid, const std::vector& inf _name_coords->reAlloc(nCoords);//not a bug to avoid the memory corruption due to last \0 at the end } else - _name_coords=0; + _name_coords=nullptr; if(MEDmeshnEntity(fid,mName.c_str(),dt,it,MED_NODE,MED_NO_GEOTYPE,MED_GLOBAL_NUMBER,MED_NODAL,&changement,&transformation)>0) { MCAuto miNumCoord=DataArrayMedInt::New(); @@ -750,7 +776,7 @@ void MEDFileUMeshL2::loadCoords(med_idt fid, const std::vector& inf void MEDFileUMeshL2::LoadPartCoords(med_idt fid, const std::vector& infosOnComp, const std::string& mName, int dt, int it, const std::vector& distribNodes, MCAuto& _coords, MCAuto& _part_coords, MCAuto& _fam_coords, MCAuto& _num_coords, MCAuto& _name_coords) { - med_int spaceDim((int)infosOnComp.size()); + med_int const spaceDim((int)infosOnComp.size()); allocCoordsPartCoords(spaceDim,distribNodes,_coords,_part_coords); _coords->setInfoOnComponents(infosOnComp); fillPartCoords(fid,spaceDim,mName,dt,it,_part_coords,_coords,_fam_coords,_num_coords,_name_coords); @@ -759,7 +785,7 @@ MCAuto& _coords, MCAuto& _part_coords, MCAuto& infosOnComp, const std::string& mName, int dt, int it, mcIdType nMin, mcIdType nMax, MCAuto& _coords, MCAuto& _part_coords, MCAuto& _fam_coords, MCAuto& _num_coords, MCAuto& _name_coords) { - med_int spaceDim((int)infosOnComp.size()); + med_int const spaceDim((int)infosOnComp.size()); allocCoordsPartCoords(spaceDim,nMin,nMax,_coords,_part_coords); _coords->setInfoOnComponents(infosOnComp); fillPartCoords(fid,spaceDim,mName,dt,it,_part_coords,_coords,_fam_coords,_num_coords,_name_coords); @@ -770,7 +796,7 @@ MCAuto& _coords, MCAuto& _part_coords, MCAuto& nodeIds, MCAuto& _coords, MCAuto& _part_coords) { - mcIdType nbNodesToLoad(nodeIds.size()); + mcIdType const nbNodesToLoad(nodeIds.size()); _coords=DataArrayDouble::New(); _coords->alloc(nbNodesToLoad,spaceDim); @@ -785,7 +811,7 @@ void MEDFileUMeshL2::allocCoordsPartCoords(mcIdType spaceDim, const std::vector< void MEDFileUMeshL2::allocCoordsPartCoords(mcIdType spaceDim, mcIdType nMin, mcIdType nMax, MCAuto& _coords, MCAuto& _part_coords) { _coords=DataArrayDouble::New(); - mcIdType nbNodesToLoad(nMax-nMin); + mcIdType const nbNodesToLoad(nMax-nMin); _coords->alloc(nbNodesToLoad,spaceDim); _part_coords=PartDefinition::New(nMin,nMax,1); @@ -798,8 +824,8 @@ void MEDFileUMeshL2::fillPartCoords(med_idt fid, mcIdType spaceDim, const std::s MCAuto& _coords, MCAuto& _fam_coords, MCAuto& _num_coords, MCAuto& _name_coords) { med_bool changement,transformation; - med_int nCoords(MEDmeshnEntity(fid,mName.c_str(),dt,it,MED_NODE,MED_NONE,MED_COORDINATE,MED_NO_CMODE,&changement,&transformation)); - mcIdType nbNodesToLoad = partCoords->getNumberOfElems(); + med_int const nCoords(MEDmeshnEntity(fid,mName.c_str(),dt,it,MED_NODE,MED_NONE,MED_COORDINATE,MED_NO_CMODE,&changement,&transformation)); + mcIdType const nbNodesToLoad = partCoords->getNumberOfElems(); // Based on the ids in \a partCoords, defining the appropriate med_filter (filter of block if the ids form a slice, a generic filter otherwise) { @@ -906,7 +932,7 @@ void MEDFileUMeshL2::loadPartCoordsSlice(med_idt fid, const std::vector idsNodeIdsToKeep(nodeIds->findIdsInRange(partStart,partStop)); - MCAuto nodeIdsToKeep( nodeIds->selectByTupleIdSafe(idsNodeIdsToKeep->begin(),idsNodeIdsToKeep->end()) ); + MCAuto const nodeIdsToKeep( nodeIds->selectByTupleIdSafe(idsNodeIdsToKeep->begin(),idsNodeIdsToKeep->end()) ); LoadPartCoordsArray(fid,infosOnComp,mName,dt,it,nodeIdsToKeep,coords[ipart],famCoords[ipart],numCoords[ipart],nameCoords[ipart]); } _coords = DataArrayDouble::Aggregate(ToConstVect(coords)); @@ -927,25 +953,25 @@ void MEDFileUMeshL2::loadPartCoordsSlice(med_idt fid, const std::vector mdims; - std::vector< MCAuto > tmp(_per_type_mesh[0]); + std::vector< MCAuto > const tmp(_per_type_mesh[0]); _per_type_mesh.clear(); - for(std::vector< MCAuto >::const_iterator it=tmp.begin();it!=tmp.end();it++) - mdims.insert((*it)->getDim()); + for(const auto & it : tmp) + mdims.insert(it->getDim()); if(mdims.empty()) return; - int mdim=*mdims.rbegin(); + int const mdim=*mdims.rbegin(); _per_type_mesh.resize(mdim+1); for(int dim=mdim+1;dim!=0;dim--) { std::vector< MCAuto >& elt=_per_type_mesh[mdim+1-dim]; - for(std::vector< MCAuto >::const_iterator it=tmp.begin();it!=tmp.end();it++) - if((*it)->getDim()==dim-1) - elt.push_back(*it); + for(const auto & it : tmp) + if(it->getDim()==dim-1) + elt.push_back(it); } // suppression of contiguous empty levels at the end of _per_type_mesh. int nbOfUselessLev=0; bool isFirst=true; - for(std::vector< std::vector< MCAuto > >::reverse_iterator it2=_per_type_mesh.rbegin();it2!=_per_type_mesh.rend();it2++) + for(auto it2=_per_type_mesh.rbegin();it2!=_per_type_mesh.rend();it2++) { if((*it2).empty() && isFirst) { @@ -982,24 +1008,24 @@ void MEDFileUMeshL2::WriteCoords(med_idt fid, const std::string& mname, int dt, bool MEDFileUMeshL2::isFamDefinedOnLev(int levId) const { - for(std::vector< MCAuto >::const_iterator it=_per_type_mesh[levId].begin();it!=_per_type_mesh[levId].end();it++) - if((*it)->getFam()==0) + for(const auto & it : _per_type_mesh[levId]) + if(it->getFam()==nullptr) return false; return true; } bool MEDFileUMeshL2::isNumDefinedOnLev(int levId) const { - for(std::vector< MCAuto >::const_iterator it=_per_type_mesh[levId].begin();it!=_per_type_mesh[levId].end();it++) - if((*it)->getNum()==0) + for(const auto & it : _per_type_mesh[levId]) + if(it->getNum()==nullptr) return false; return true; } bool MEDFileUMeshL2::isNamesDefinedOnLev(int levId) const { - for(std::vector< MCAuto >::const_iterator it=_per_type_mesh[levId].begin();it!=_per_type_mesh[levId].end();it++) - if((*it)->getNames()==0) + for(const auto & it : _per_type_mesh[levId]) + if(it->getNames()==nullptr) return false; return true; } @@ -1030,9 +1056,9 @@ void MEDFileCMeshL2::loadAll(med_idt fid, const MeshOrStructMeshCls *mId, const _cmesh=MEDCouplingCMesh::New(); for(int i=0;i da=DataArrayDouble::New(); da->alloc(nbOfElt,1); da->setInfoOnComponent(0,infosOnComp[i]); @@ -1057,8 +1083,7 @@ med_data_type MEDFileCMeshL2::GetDataTypeCorrespondingToSpaceId(int id) } MEDFileCLMeshL2::MEDFileCLMeshL2() -{ -} += default; void MEDFileCLMeshL2::loadAll(med_idt fid, const MeshOrStructMeshCls *mId, const std::string& mName, int dt, int it) { @@ -1067,7 +1092,7 @@ void MEDFileCLMeshL2::loadAll(med_idt fid, const MeshOrStructMeshCls *mId, const int Mdim; MEDCoupling::MEDCouplingMeshType meshType; MEDCoupling::MEDCouplingAxisType dummy3; - std::vector infosOnComp(getAxisInfoOnMesh(fid,mId,mName,meshType,dummy3,nstep,Mdim)); + std::vector const infosOnComp(getAxisInfoOnMesh(fid,mId,mName,meshType,dummy3,nstep,Mdim)); if(meshType!=CURVE_LINEAR) throw INTERP_KERNEL::Exception("Invalid mesh type ! You are expected a structured one whereas in file it is not a structured !"); _time=mId->checkMeshTimeStep(fid,mName,nstep,dt,it); @@ -1081,7 +1106,7 @@ void MEDFileCLMeshL2::loadAll(med_idt fid, const MeshOrStructMeshCls *mId, const MCAuto stGrid=FromMedIntArray(miStGrid); _clmesh->setNodeGridStructure(stGrid->begin(),stGrid->end()); med_bool chgt=MED_FALSE,trsf=MED_FALSE; - med_int nbNodes(MEDmeshnEntity(fid,mName.c_str(),dt,it,MED_NODE,MED_NONE,MED_COORDINATE,MED_NO_CMODE,&chgt,&trsf)); + med_int const nbNodes(MEDmeshnEntity(fid,mName.c_str(),dt,it,MED_NODE,MED_NONE,MED_COORDINATE,MED_NO_CMODE,&chgt,&trsf)); MCAuto da=DataArrayDouble::New(); da->alloc(nbNodes,infosOnComp.size()); da->setInfoOnComponents(infosOnComp); @@ -1099,7 +1124,7 @@ MEDFileUMeshPermCompute::MEDFileUMeshPermCompute(const MEDFileUMeshSplitL1* st): MEDFileUMeshPermCompute::operator MEDCouplingUMesh *() const { _st->_num->updateTime(); - if((MEDCouplingUMesh *)_m==0) + if((MEDCouplingUMesh *)_m==nullptr) { updateTime(); _m=static_cast(_st->_m_by_types.getUmesh()->deepCopy()); @@ -1147,12 +1172,12 @@ MEDFileUMeshSplitL1::MEDFileUMeshSplitL1(const MEDFileUMeshSplitL1& other):RefCo { } -MEDFileUMeshSplitL1::MEDFileUMeshSplitL1(const MEDFileUMeshL2& l2, const std::string& mName, int id):_m(this) +MEDFileUMeshSplitL1::MEDFileUMeshSplitL1(const MEDFileUMeshL2& l2, const std::string& /*mName*/, int id):_m(this) { const std::vector< MCAuto >& v=l2.getLev(id); if(v.empty()) return; - std::size_t sz=v.size(); + std::size_t const sz=v.size(); std::vector ms(sz); std::vector fams(sz),nums(sz); std::vector names(sz); @@ -1266,12 +1291,12 @@ void MEDFileUMeshSplitL1::checkConsistency() const { if (!_fam || _fam->getNumberOfTuples() != getSize()) throw INTERP_KERNEL::Exception("MEDFileUMeshSplitL1::checkConsistency(): internal family array has an invalid size!"); - mcIdType nbCells = getSize(); + mcIdType const nbCells = getSize(); if (_num) { _num->checkNbOfTuplesAndComp(nbCells,1,"MEDFileUMeshSplitL1::checkConsistency(): inconsistent internal node numbering array!"); mcIdType pos; - mcIdType maxValue=_num->getMaxValue(pos); + mcIdType const maxValue=_num->getMaxValue(pos); if (!_rev_num || _rev_num->getNumberOfTuples() != (maxValue+1)) throw INTERP_KERNEL::Exception("MEDFileUMeshSplitL1::checkConsistency(): inconsistent internal revert node numbering array!"); } @@ -1291,7 +1316,7 @@ bool MEDFileUMeshSplitL1::isEqual(const MEDFileUMeshSplitL1 *other, double eps, return false; const DataArrayIdType *d1=_fam; const DataArrayIdType *d2=other->_fam; - if((d1==0 && d2!=0) || (d1!=0 && d2==0)) + if((d1==nullptr && d2!=nullptr) || (d1!=nullptr && d2==nullptr)) { what="Presence of family arr in one sublevel and not in other!"; return false; @@ -1304,7 +1329,7 @@ bool MEDFileUMeshSplitL1::isEqual(const MEDFileUMeshSplitL1 *other, double eps, } d1=_num; d2=other->_num; - if((d1==0 && d2!=0) || (d1!=0 && d2==0)) + if((d1==nullptr && d2!=nullptr) || (d1!=nullptr && d2==nullptr)) { what="Presence of cell numbering arr in one sublevel and not in other!"; return false; @@ -1317,7 +1342,7 @@ bool MEDFileUMeshSplitL1::isEqual(const MEDFileUMeshSplitL1 *other, double eps, } const DataArrayAsciiChar *e1=_names; const DataArrayAsciiChar *e2=other->_names; - if((e1==0 && e2!=0) || (e1!=0 && e2==0)) + if((e1==nullptr && e2!=nullptr) || (e1!=nullptr && e2==nullptr)) { what="Presence of cell names arr in one sublevel and not in other!"; return false; @@ -1430,10 +1455,10 @@ int MEDFileUMeshSplitL1::getMeshDimension() const void MEDFileUMeshSplitL1::simpleRepr(std::ostream& oss) const { std::vector code=_m_by_types.getDistributionOfTypes(); - std::size_t nbOfTypes=code.size()/3; + std::size_t const nbOfTypes=code.size()/3; for(std::size_t i=0;i eltsToKeep=_fam->findIdsEqualList(idsBg,idsEnd); - MEDCouplingUMesh *m=(MEDCouplingUMesh *)_m_by_types.getUmesh()->buildPartOfMySelf(eltsToKeep->begin(),eltsToKeep->end(),true); + auto *m=(MEDCouplingUMesh *)_m_by_types.getUmesh()->buildPartOfMySelf(eltsToKeep->begin(),eltsToKeep->end(),true); if(renum) return renumIfNeeded(m,eltsToKeep->begin()); return m; @@ -1489,7 +1514,7 @@ DataArrayIdType *MEDFileUMeshSplitL1::extractFamilyFieldOnGeoType(INTERP_KERNEL: { const DataArrayIdType *fam(_fam); if(!fam) - return 0; + return nullptr; mcIdType start(0),stop(0); _m_by_types.getStartStopOfGeoTypeWithoutComputation(gt,start,stop); return fam->selectByTupleIdSafeSlice(start,stop,1); @@ -1499,7 +1524,7 @@ DataArrayIdType *MEDFileUMeshSplitL1::extractNumberFieldOnGeoType(INTERP_KERNEL: { const DataArrayIdType *num(_num); if(!num) - return 0; + return nullptr; mcIdType start(0),stop(0); _m_by_types.getStartStopOfGeoTypeWithoutComputation(gt,start,stop); return num->selectByTupleIdSafeSlice(start,stop,1); @@ -1509,7 +1534,7 @@ DataArrayIdType *MEDFileUMeshSplitL1::getOrCreateAndGetFamilyField() { if((DataArrayIdType *)_fam) return _fam; - mcIdType nbOfTuples=_m_by_types.getSize(); + mcIdType const nbOfTuples=_m_by_types.getSize(); _fam=DataArrayIdType::New(); _fam->alloc(nbOfTuples,1); _fam->fillWithZero(); return _fam; } @@ -1548,15 +1573,15 @@ void MEDFileUMeshSplitL1::eraseFamilyField() * This method ignores _m and _m_by_types. */ void MEDFileUMeshSplitL1::setGroupsFromScratch(const std::vector& ms, std::map& familyIds, - std::map >& groups) + std::map >& /*groups*/) { std::vector< DataArrayIdType * > corr; _m=MEDCouplingUMesh::FuseUMeshesOnSameCoords(ms,0,corr); - std::vector< MCAuto > corrMSafe(corr.begin(),corr.end()); + std::vector< MCAuto > const corrMSafe(corr.begin(),corr.end()); std::vector< std::vector > fidsOfGroups; - std::vector< const DataArrayIdType * > corr2(corr.begin(),corr.end()); + std::vector< const DataArrayIdType * > const corr2(corr.begin(),corr.end()); _fam=DataArrayIdType::MakePartition(corr2,((MEDCouplingUMesh *)_m)->getNumberOfCells(),fidsOfGroups); - mcIdType nbOfCells=((MEDCouplingUMesh *)_m)->getNumberOfCells(); + mcIdType const nbOfCells=((MEDCouplingUMesh *)_m)->getNumberOfCells(); std::map newfams; std::map famIdTrad; TraduceFamilyNumber(fidsOfGroups,familyIds,famIdTrad,newfams); @@ -1567,7 +1592,7 @@ void MEDFileUMeshSplitL1::setGroupsFromScratch(const std::vector ms(_m_by_types.getParts()); + std::vector const ms(_m_by_types.getParts()); for(auto mesh : ms) { if(mesh) @@ -1578,12 +1603,12 @@ void MEDFileUMeshSplitL1::checkCoordsConsistency(const DataArrayDouble *coords) void MEDFileUMeshSplitL1::write(med_idt fid, const std::string& mName, int mdim) const { - std::vector ms(_m_by_types.getParts()); + std::vector const ms(_m_by_types.getParts()); mcIdType start=0; - for(std::vector::const_iterator it=ms.begin();it!=ms.end();it++) + for(auto m : ms) { - mcIdType nbCells=(*it)->getNumberOfCells(); - mcIdType end=start+nbCells; + mcIdType const nbCells=m->getNumberOfCells(); + mcIdType const end=start+nbCells; MCAuto fam,num; MCAuto names; if((const DataArrayIdType *)_fam) @@ -1592,7 +1617,7 @@ void MEDFileUMeshSplitL1::write(med_idt fid, const std::string& mName, int mdim) num=_num->subArray(start,end); if((const DataArrayAsciiChar *)_names) names=static_cast(_names->subArray(start,end)); - MEDFileUMeshPerType::Write(fid,mName,mdim,(*it),fam,num,names); + MEDFileUMeshPerType::Write(fid,mName,mdim,m,fam,num,names); start=end; } } @@ -1627,10 +1652,10 @@ void MEDFileUMeshSplitL1::setFamilyArr(DataArrayIdType *famArr) { if(!famArr) { - _fam=0; + _fam=nullptr; return ; } - mcIdType sz(_m_by_types.getSize()); + mcIdType const sz(_m_by_types.getSize()); famArr->checkNbOfTuplesAndComp(sz,1,"MEDFileUMeshSplitL1::setFamilyArr : Problem in size of Family arr ! "); famArr->incrRef(); _fam=famArr; @@ -1645,11 +1670,11 @@ void MEDFileUMeshSplitL1::setRenumArr(DataArrayIdType *renumArr) { if(!renumArr) { - _num=0; - _rev_num=0; + _num=nullptr; + _rev_num=nullptr; return ; } - mcIdType sz(_m_by_types.getSize()); + mcIdType const sz(_m_by_types.getSize()); renumArr->checkNbOfTuplesAndComp(sz,1,"MEDFileUMeshSplitL1::setRenumArr : Problem in size of numbering arr ! "); renumArr->incrRef(); _num=renumArr; @@ -1660,10 +1685,10 @@ void MEDFileUMeshSplitL1::setNameArr(DataArrayAsciiChar *nameArr) { if(!nameArr) { - _names=0; + _names=nullptr; return ; } - mcIdType sz(_m_by_types.getSize()); + mcIdType const sz(_m_by_types.getSize()); nameArr->checkNbOfTuplesAndComp(sz,MED_SNAME_SIZE,"MEDFileUMeshSplitL1::setNameArr : Problem in size of name arr ! "); nameArr->incrRef(); _names=nameArr; @@ -1671,9 +1696,9 @@ void MEDFileUMeshSplitL1::setNameArr(DataArrayAsciiChar *nameArr) MEDCouplingUMesh *MEDFileUMeshSplitL1::Renumber2(const DataArrayIdType *renum, MEDCouplingUMesh *m, const mcIdType *cellIds) { - if(renum==0) + if(renum==nullptr) return m; - if(cellIds==0) + if(cellIds==nullptr) m->renumberCells(renum->begin(),true); else { @@ -1697,7 +1722,7 @@ MEDCouplingUMesh *MEDFileUMeshSplitL1::renumIfNeeded(MEDCouplingUMesh *m, const DataArrayIdType *MEDFileUMeshSplitL1::Renumber(const DataArrayIdType *renum, const DataArrayIdType *da) { - if((const DataArrayIdType *)renum==0) + if((const DataArrayIdType *)renum==nullptr) { da->incrRef(); return const_cast(da); @@ -1713,8 +1738,8 @@ DataArrayIdType *MEDFileUMeshSplitL1::renumIfNeededArr(const DataArrayIdType *da std::vector MEDFileUMeshSplitL1::GetNewFamiliesNumber(mcIdType nb, const std::map& families) { mcIdType id=-1; - for(std::map::const_iterator it=families.begin();it!=families.end();it++) - id=std::max(id,(*it).second); + for(const auto & familie : families) + id=std::max(id,familie.second); if(id==-1) id=0; std::vector ret(nb); @@ -1723,10 +1748,10 @@ std::vector MEDFileUMeshSplitL1::GetNewFamiliesNumber(mcIdType nb, con return ret; } -void MEDFileUMeshSplitL1::TraduceFamilyNumber(const std::vector< std::vector >& fidsGrps, std::map& familyIds, - std::map& famIdTrad, std::map& newfams) +void MEDFileUMeshSplitL1::TraduceFamilyNumber(const std::vector< std::vector >& /*fidsGrps*/, std::map& /*familyIds*/, + std::map& /*famIdTrad*/, std::map& /*newfams*/) { - std::set allfids; + std::set const allfids; //tony } @@ -1735,7 +1760,7 @@ void MEDFileUMeshSplitL1::computeRevNum() const mcIdType pos; if(!_num->empty()) { - mcIdType maxValue=_num->getMaxValue(pos); + mcIdType const maxValue=_num->getMaxValue(pos); _rev_num=_num->invertArrayN2O2O2N(maxValue+1); } else @@ -1762,9 +1787,9 @@ void MEDFileUMeshAggregateCompute::setName(const std::string& name) } if(_mp_time>=_m_time) { - for(std::vector< MCAuto >::iterator it=_m_parts.begin();it!=_m_parts.end();it++) + for(auto & _m_part : _m_parts) { - MEDCoupling1GTUMesh *tmp(*it); + MEDCoupling1GTUMesh *tmp(_m_part); if(tmp) tmp->setName(name); } @@ -1773,7 +1798,7 @@ void MEDFileUMeshAggregateCompute::setName(const std::string& name) void MEDFileUMeshAggregateCompute::assignParts(const std::vector< const MEDCoupling1GTUMesh * >& mParts) { - std::size_t sz(mParts.size()); + std::size_t const sz(mParts.size()); std::vector< MCAuto > ret(sz); for(std::size_t i=0;i& partDefs) { if(_mp_time<_m_time) throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::assignDefParts : the parts require a computation !"); - std::size_t sz(partDefs.size()); + std::size_t const sz(partDefs.size()); if(_part_def.size()!=partDefs.size() || _part_def.size()!=_m_parts.size()) throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::assignDefParts : sizes of vectors of part definition mismatch !"); for(std::size_t i=0;igetNumberOfCells(); mcIdType ret(0); - for(std::vector< MCAuto >::const_iterator it=_m_parts.begin();it!=_m_parts.end();it++) - ret+=(*it)->getNumberOfCells(); + for(const auto & _m_part : _m_parts) + ret+=_m_part->getNumberOfCells(); return ret; } @@ -1837,7 +1862,7 @@ std::vector MEDFileUMeshAggregateCompute::get { if(_mp_time>=_m_time) { - std::size_t sz(_m_parts.size()); + std::size_t const sz(_m_parts.size()); std::vector ret(sz); for(std::size_t i=0;igetCellModelEnum(); @@ -1851,9 +1876,9 @@ mcIdType MEDFileUMeshAggregateCompute::getNumberOfCellsWithType(INTERP_KERNEL::N { if(_mp_time>=_m_time) { - for(std::vector< MCAuto >::const_iterator it=_m_parts.begin();it!=_m_parts.end();it++) + for(const auto & _m_part : _m_parts) { - const MEDCoupling1GTUMesh *elt(*it); + const MEDCoupling1GTUMesh *elt(_m_part); if(elt && elt->getCellModelEnum()==ct) return elt->getNumberOfCells(); } @@ -1898,7 +1923,7 @@ void MEDFileUMeshAggregateCompute::highlightUsedNodes(std::vector& nodesTo MEDCoupling1GTUMesh *MEDFileUMeshAggregateCompute::retrievePartWithoutComputation(INTERP_KERNEL::NormalizedCellType gt) const { std::vector v(retrievePartsWithoutComputation()); - std::size_t sz(v.size()); + std::size_t const sz(v.size()); for(std::size_t i=0;i v(retrievePartsWithoutComputation()); - std::size_t sz(v.size()); + std::size_t const sz(v.size()); for(std::size_t i=0;i_m_time) { - for(std::vector< MCAuto >::iterator it=_m_parts.begin();it!=_m_parts.end();it++) + for(auto & _m_part : _m_parts) { - MEDCoupling1GTUMesh *m(*it); + MEDCoupling1GTUMesh *m(_m_part); if(m) m->renumberNodesInConn(newNodeNumbersO2N); } @@ -1963,8 +1988,8 @@ void MEDFileUMeshAggregateCompute::forceComputationOfPartsFromUMesh() const return ;// no needs to compte parts they are already here ! } std::vector ms(m->splitByType()); - std::vector< MCAuto > msMSafe(ms.begin(),ms.end()); - std::size_t sz(msMSafe.size()); + std::vector< MCAuto > const msMSafe(ms.begin(),ms.end()); + std::size_t const sz(msMSafe.size()); _m_parts.resize(sz); for(std::size_t i=0;i& tinyInt, std { if(_mp_time<_m_time) throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::serialize : the parts require a computation !"); - std::size_t sz(_m_parts.size()); + std::size_t const sz(_m_parts.size()); tinyInt.push_back((mcIdType)sz); for(std::size_t i=0;i& tinyInt, std if(!mesh) throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::serialize : one part is empty !"); tinyInt.push_back(mesh->getCellModelEnum()); - const MEDCoupling1SGTUMesh *mesh1(dynamic_cast(mesh)); - const MEDCoupling1DGTUMesh *mesh2(dynamic_cast(mesh)); + const auto *mesh1(dynamic_cast(mesh)); + const auto *mesh2(dynamic_cast(mesh)); if(mesh1) { DataArrayIdType *elt(mesh1->getNodalConnectivity()); if(elt) elt->incrRef(); - MCAuto elt1(elt); + MCAuto const elt1(elt); bigArraysI.push_back(elt1); } else if(mesh2) @@ -2045,16 +2070,16 @@ void MEDFileUMeshAggregateCompute::serialize(std::vector& tinyInt, std void MEDFileUMeshAggregateCompute::unserialize(const std::string& name, DataArrayDouble *coo, std::vector& tinyInt, std::vector< MCAuto >& bigArraysI) { - mcIdType nbParts(tinyInt.back()); tinyInt.pop_back(); + mcIdType const nbParts(tinyInt.back()); tinyInt.pop_back(); _part_def.clear(); _part_def.resize(nbParts); _m_parts.clear(); _m_parts.resize(nbParts); for(mcIdType i=0;i mesh(MEDCoupling1GTUMesh::New(name,tp)); mesh->setCoords(coo); - MEDCoupling1SGTUMesh *mesh1(dynamic_cast((MEDCoupling1GTUMesh *) mesh)); - MEDCoupling1DGTUMesh *mesh2(dynamic_cast((MEDCoupling1GTUMesh *) mesh)); + auto *mesh1(dynamic_cast((MEDCoupling1GTUMesh *) mesh)); + auto *mesh2(dynamic_cast((MEDCoupling1GTUMesh *) mesh)); if(mesh1) { mesh1->setNodalConnectivity(bigArraysI.back()); bigArraysI.pop_back(); @@ -2069,7 +2094,7 @@ void MEDFileUMeshAggregateCompute::unserialize(const std::string& name, DataArra else throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::unserialize : unrecognized single geo type mesh !"); _m_parts[i]=mesh; - mcIdType pdid(tinyInt.back()); tinyInt.pop_back(); + mcIdType const pdid(tinyInt.back()); tinyInt.pop_back(); if(pdid!=-1) _part_def[i]=PartDefinition::Unserialize(tinyInt,bigArraysI); _mp_time=std::max(_mp_time,_m_time)+1; @@ -2096,9 +2121,9 @@ std::size_t MEDFileUMeshAggregateCompute::getTimeOfThis() const std::size_t MEDFileUMeshAggregateCompute::getTimeOfParts() const { std::size_t ret(0); - for(std::vector< MCAuto >::const_iterator it=_m_parts.begin();it!=_m_parts.end();it++) + for(const auto & _m_part : _m_parts) { - const MEDCoupling1GTUMesh *elt(*it); + const MEDCoupling1GTUMesh *elt(_m_part); if(!elt) throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getTimeOfParts : null obj in parts !"); ret=std::max(ret,elt->getTimeOfThis()); @@ -2118,15 +2143,15 @@ std::size_t MEDFileUMeshAggregateCompute::getTimeOfUMesh() const std::size_t MEDFileUMeshAggregateCompute::getHeapMemorySizeWithoutChildren() const { - std::size_t ret(_m_parts.size()*sizeof(MCAuto)); + std::size_t const ret(_m_parts.size()*sizeof(MCAuto)); return ret; } std::vector MEDFileUMeshAggregateCompute::getDirectChildrenWithNull() const { std::vector ret; - for(std::vector< MCAuto >::const_iterator it=_m_parts.begin();it!=_m_parts.end();it++) - ret.push_back((const MEDCoupling1GTUMesh *)*it); + for(const auto & _m_part : _m_parts) + ret.push_back((const MEDCoupling1GTUMesh *)_m_part); ret.push_back((const MEDCouplingUMesh *)_m); return ret; } @@ -2150,7 +2175,7 @@ MEDFileUMeshAggregateCompute MEDFileUMeshAggregateCompute::deepCopy(DataArrayDou ret._m=static_cast(_m->deepCopy()); ret._m->setCoords(coords); } - std::size_t sz(_part_def.size()); + std::size_t const sz(_part_def.size()); ret._part_def.clear(); ret._part_def.resize(sz); for(std::size_t i=0;i >::iterator it=_m_parts.begin();it!=_m_parts.end();it++) + for(auto & _m_part : _m_parts) { - const MEDCoupling1GTUMesh *elt(*it); + const MEDCoupling1GTUMesh *elt(_m_part); if(elt) { MCAuto elt2(elt->clone(false)); - *it=DynamicCastSafe(elt2); + _m_part=DynamicCastSafe(elt2); } } const MEDCouplingUMesh *m(_m); @@ -2181,7 +2206,7 @@ bool MEDFileUMeshAggregateCompute::isEqual(const MEDFileUMeshAggregateCompute& o { const MEDCouplingUMesh *m1(getUmesh()); const MEDCouplingUMesh *m2(other.getUmesh()); - if((m1==0 && m2!=0) || (m1!=0 && m2==0)) + if((m1==nullptr && m2!=nullptr) || (m1!=nullptr && m2==nullptr)) { what="Presence of mesh in one sublevel and not in other!"; return false; @@ -2195,7 +2220,7 @@ bool MEDFileUMeshAggregateCompute::isEqual(const MEDFileUMeshAggregateCompute& o return false; } } - std::size_t sz(_part_def.size()); + std::size_t const sz(_part_def.size()); if(sz!=other._part_def.size()) { what=std::string("number of subdivision per geo type for part definition is not the same !"); @@ -2211,7 +2236,7 @@ bool MEDFileUMeshAggregateCompute::isEqual(const MEDFileUMeshAggregateCompute& o what=std::string("a cell part def is defined only for one among this or other !"); return false; } - bool ret(pd0->isEqual(pd1,what)); + bool const ret(pd0->isEqual(pd1,what)); if(!ret) return false; } @@ -2221,25 +2246,24 @@ bool MEDFileUMeshAggregateCompute::isEqual(const MEDFileUMeshAggregateCompute& o void MEDFileUMeshAggregateCompute::checkConsistency() const { if(_mp_time >= _m_time) - for(std::vector< MCAuto >::const_iterator it=_m_parts.begin(); - it!=_m_parts.end(); it++) - (*it)->checkConsistency(); + for(const auto & _m_part : _m_parts) + _m_part->checkConsistency(); else _m->checkConsistency(); } void MEDFileUMeshAggregateCompute::clearNonDiscrAttributes() const { - for(std::vector< MCAuto >::const_iterator it=_m_parts.begin();it!=_m_parts.end();it++) - MEDFileUMeshSplitL1::ClearNonDiscrAttributes(*it); + for(const auto & _m_part : _m_parts) + MEDFileUMeshSplitL1::ClearNonDiscrAttributes(_m_part); MEDFileUMeshSplitL1::ClearNonDiscrAttributes(_m); } void MEDFileUMeshAggregateCompute::synchronizeTinyInfo(const MEDFileMesh& master) const { - for(std::vector< MCAuto >::const_iterator it=_m_parts.begin();it!=_m_parts.end();it++) + for(const auto & _m_part : _m_parts) { - const MEDCoupling1GTUMesh *tmp(*it); + const MEDCoupling1GTUMesh *tmp(_m_part); if(tmp) { (const_cast(tmp))->setName(master.getName().c_str()); @@ -2261,7 +2285,7 @@ void MEDFileUMeshAggregateCompute::synchronizeTinyInfo(const MEDFileMesh& master bool MEDFileUMeshAggregateCompute::empty() const { if(_mp_time<_m_time) - return ((const MEDCouplingUMesh *)_m)==0; + return ((const MEDCouplingUMesh *)_m)==nullptr; //else _mp_time>=_m_time) return _m_parts.empty(); } @@ -2298,9 +2322,9 @@ std::vector MEDFileUMeshAggregateCompute::getDistributionOfTypes() con else { std::vector ret; - for(std::vector< MCAuto >::const_iterator it=_m_parts.begin();it!=_m_parts.end();it++) + for(const auto & _m_part : _m_parts) { - const MEDCoupling1GTUMesh *tmp(*it); + const MEDCoupling1GTUMesh *tmp(_m_part); if(!tmp) throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getDistributionOfTypes : part mesh contains null instance !"); std::vector ret0(tmp->getDistributionOfTypes()); @@ -2322,9 +2346,9 @@ mcIdType MEDFileUMeshAggregateCompute::getSize() const else { mcIdType ret=0; - for(std::vector< MCAuto >::const_iterator it=_m_parts.begin();it!=_m_parts.end();it++) + for(const auto & _m_part : _m_parts) { - const MEDCoupling1GTUMesh *m(*it); + const MEDCoupling1GTUMesh *m(_m_part); if(!m) throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getSize : part mesh contains null instance !"); ret+=m->getNumberOfCells(); @@ -2335,11 +2359,11 @@ mcIdType MEDFileUMeshAggregateCompute::getSize() const void MEDFileUMeshAggregateCompute::setCoords(DataArrayDouble *coords) { - for(std::vector< MCAuto >::iterator it=_m_parts.begin();it!=_m_parts.end();it++) + for(auto & _m_part : _m_parts) { - MEDCoupling1GTUMesh *tmp(*it); + MEDCoupling1GTUMesh *tmp(_m_part); if(tmp) - (*it)->setCoords(coords); + _m_part->setCoords(coords); } MEDCouplingUMesh *m(_m); if(m) @@ -2361,8 +2385,8 @@ std::vector MEDFileEltStruct4Mesh::getDirec std::vector ret; ret.push_back(_conn); ret.push_back(_common); - for(std::vector< MCAuto >::const_iterator it=_vars.begin();it!=_vars.end();it++) - ret.push_back(*it); + for(const auto & _var : _vars) + ret.push_back(_var); return ret; } @@ -2380,7 +2404,7 @@ MEDFileEltStruct4Mesh::MEDFileEltStruct4Mesh(med_idt fid, const std::string& mNa } MCAuto mss(MEDFileMeshSupports::New(fid)); MCAuto mse(MEDFileStructureElements::New(fid,mss)); - mcIdType nbEntities(mse->getNumberOfNodesPerSE(_geo_type_name)); + mcIdType const nbEntities(mse->getNumberOfNodesPerSE(_geo_type_name)); MCAuto miConn=DataArrayMedInt::New(); miConn->alloc(nCells*nbEntities); MEDFILESAFECALLERRD0(MEDmeshElementConnectivityRd,(fid,mName.c_str(),dt,it,MED_STRUCT_ELEMENT,_geo_type,MED_NODAL,MED_FULL_INTERLACE,miConn->getPointer())); _conn=FromMedIntArray(miConn); @@ -2389,7 +2413,7 @@ MEDFileEltStruct4Mesh::MEDFileEltStruct4Mesh(med_idt fid, const std::string& mNa _common=MEDFileUMeshPerTypeCommon::New(); _common->loadCommonPart(fid,mName.c_str(),dt,it,nCells,geoType,MED_STRUCT_ELEMENT,mrs); std::vector vns(mse->getVarAttsOf(_geo_type_name)); - std::size_t sz(vns.size()); + std::size_t const sz(vns.size()); _vars.resize(sz); for(std::size_t i=0;i #include +#include +#include +#include +#include namespace MEDCoupling { @@ -46,7 +56,7 @@ namespace MEDCoupling protected: MeshOrStructMeshCls(int mid):_mid(mid) { } public: - virtual ~MeshOrStructMeshCls() {} + virtual ~MeshOrStructMeshCls() = default; int getID() const { return _mid; } virtual std::vector getAxisInfoOnMesh(med_idt fid, const std::string& mName, MEDCoupling::MEDCouplingMeshType& meshType, MEDCoupling::MEDCouplingAxisType& axType, int& nstep, int& Mdim, MEDFileString& description, MEDFileString& dtunit, MEDFileString& univName) const = 0; virtual double checkMeshTimeStep(med_idt fid, const std::string& mName, int nstep, int dt, int it) const = 0; @@ -58,24 +68,24 @@ namespace MEDCoupling { public: MeshCls(int mid):MeshOrStructMeshCls(mid) { } - std::vector getAxisInfoOnMesh(med_idt fid, const std::string& mName, MEDCoupling::MEDCouplingMeshType& meshType, MEDCoupling::MEDCouplingAxisType& axType, int& nstep, int& Mdim, MEDFileString& description, MEDFileString& dtunit, MEDFileString& univName) const; - double checkMeshTimeStep(med_idt fid, const std::string& mName, int nstep, int dt, int it) const; + std::vector getAxisInfoOnMesh(med_idt fid, const std::string& mName, MEDCoupling::MEDCouplingMeshType& meshType, MEDCoupling::MEDCouplingAxisType& axType, int& nstep, int& Mdim, MEDFileString& description, MEDFileString& dtunit, MEDFileString& univName) const override; + double checkMeshTimeStep(med_idt fid, const std::string& mName, int nstep, int dt, int it) const override; }; class StructMeshCls : public MeshOrStructMeshCls { public: StructMeshCls(int mid):MeshOrStructMeshCls(mid) { } - std::vector getAxisInfoOnMesh(med_idt fid, const std::string& mName, MEDCoupling::MEDCouplingMeshType& meshType, MEDCoupling::MEDCouplingAxisType& axType, int& nstep, int& Mdim, MEDFileString& description, MEDFileString& dtunit, MEDFileString& univName) const; - double checkMeshTimeStep(med_idt fid, const std::string& mName, int nstep, int dt, int it) const; + std::vector getAxisInfoOnMesh(med_idt fid, const std::string& mName, MEDCoupling::MEDCouplingMeshType& meshType, MEDCoupling::MEDCouplingAxisType& axType, int& nstep, int& Mdim, MEDFileString& description, MEDFileString& dtunit, MEDFileString& univName) const override; + double checkMeshTimeStep(med_idt fid, const std::string& mName, int nstep, int dt, int it) const override; }; class MEDFileMeshL2 : public RefCountObject { public: MEDFileMeshL2(); - std::size_t getHeapMemorySizeWithoutChildren() const; - std::vector getDirectChildrenWithNull() const; + std::size_t getHeapMemorySizeWithoutChildren() const override; + std::vector getDirectChildrenWithNull() const override; const char *getName() const { return _name.getReprForWrite(); } const char *getDescription() const { return _description.getReprForWrite(); } const char *getUnivName() const { return _univ_name.getReprForWrite(); } @@ -205,8 +215,8 @@ MCAuto& _coords, MCAuto& _fam_coords, MCAuto getDirectChildrenWithNull() const; - std::size_t getHeapMemorySizeWithoutChildren() const; + std::vector getDirectChildrenWithNull() const override; + std::size_t getHeapMemorySizeWithoutChildren() const override; private: const MEDFileUMeshSplitL1 *_st; mutable std::size_t _mpt_time; @@ -235,8 +245,8 @@ MCAuto& _coords, MCAuto& _fam_coords, MCAuto getDirectChildrenWithNull() const; + std::size_t getHeapMemorySizeWithoutChildren() const override; + std::vector getDirectChildrenWithNull() const override; MEDFileUMeshAggregateCompute deepCopy(DataArrayDouble *coords) const; void shallowCpyMeshes(); bool isEqual(const MEDFileUMeshAggregateCompute& other, double eps, std::string& what) const; @@ -276,8 +286,8 @@ MCAuto& _coords, MCAuto& _fam_coords, MCAuto getDirectChildrenWithNull() const; + std::size_t getHeapMemorySizeWithoutChildren() const override; + std::vector getDirectChildrenWithNull() const override; MEDFileUMeshSplitL1 *shallowCpyUsingCoords(DataArrayDouble *coords) const; MEDFileUMeshSplitL1 *deepCopy(DataArrayDouble *coords) const; void checkConsistency() const; @@ -363,10 +373,10 @@ MCAuto& _coords, MCAuto& _fam_coords, MCAuto getMeshDef() const { return _common; } const std::vector< MCAuto >& getVars() const { return _vars; } private: - std::size_t getHeapMemorySizeWithoutChildren() const; - std::vector getDirectChildrenWithNull() const; + std::size_t getHeapMemorySizeWithoutChildren() const override; + std::vector getDirectChildrenWithNull() const override; private: - ~MEDFileEltStruct4Mesh() { } + ~MEDFileEltStruct4Mesh() override = default; private: MEDFileEltStruct4Mesh(med_idt fid, const std::string& mName, int dt, int it, int iterOnStEltOfMesh, MEDFileMeshReadSelector *mrs); private: diff --git a/src/MEDLoader/MEDFileMeshReadSelector.cxx b/src/MEDLoader/MEDFileMeshReadSelector.cxx index 235ffa282..fda219370 100644 --- a/src/MEDLoader/MEDFileMeshReadSelector.cxx +++ b/src/MEDLoader/MEDFileMeshReadSelector.cxx @@ -21,8 +21,10 @@ #include "MEDFileMeshReadSelector.hxx" #include "InterpKernelException.hxx" +#include "MCIdType.hxx" -#include +#include +#include using namespace MEDCoupling; @@ -89,7 +91,7 @@ bool MEDFileMeshReadSelector::isGlobalNodeNumFieldReading() const void MEDFileMeshReadSelector::setCellFamilyFieldReading(bool b) { unsigned int code(_code & 0xFFFFFFFE); - unsigned int b2=b?1:0; + unsigned int const b2=b?1:0; //b2<<=0; code+=b2; _code=code; diff --git a/src/MEDLoader/MEDFileMeshReadSelector.hxx b/src/MEDLoader/MEDFileMeshReadSelector.hxx index a1f1e3205..f88075294 100644 --- a/src/MEDLoader/MEDFileMeshReadSelector.hxx +++ b/src/MEDLoader/MEDFileMeshReadSelector.hxx @@ -24,6 +24,7 @@ #include "MCIdType.hxx" +#include #include namespace MEDCoupling diff --git a/src/MEDLoader/MEDFileMeshSupport.cxx b/src/MEDLoader/MEDFileMeshSupport.cxx index b6e9a605c..15c280db9 100644 --- a/src/MEDLoader/MEDFileMeshSupport.cxx +++ b/src/MEDLoader/MEDFileMeshSupport.cxx @@ -19,17 +19,31 @@ // Author : Anthony Geay (EDF R&D) #include "MEDFileMeshSupport.hxx" +#include "MCAuto.hxx" +#include "MEDFileUtilities.hxx" +#include "MCIdType.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include "CellModel.hxx" #include "MEDLoaderBase.hxx" #include "MEDFileMeshLL.hxx" #include "MEDFileSafeCaller.txx" #include "InterpKernelAutoPtr.hxx" +#include +#include +#include +#include "med.h" +#include "medmesh.h" +#include +#include +#include +#include "NormalizedGeometricTypes" using namespace MEDCoupling; MEDFileMeshSupports *MEDFileMeshSupports::New(const std::string& fileName) { - MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + MEDFileUtilities::AutoFid const fid(OpenMEDFileForRead(fileName)); return New(fid); } @@ -45,33 +59,31 @@ MEDFileMeshSupports *MEDFileMeshSupports::New() MEDFileMeshSupports::MEDFileMeshSupports(med_idt fid) { - med_int nbSM(MEDnSupportMesh(fid)); + med_int const nbSM(MEDnSupportMesh(fid)); _supports.resize(nbSM); for(int i=0;i msn(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)); INTERP_KERNEL::AutoPtr description(MEDLoaderBase::buildEmptyString(MED_COMMENT_SIZE)); med_axis_type axType; - med_int nAxis(MEDsupportMeshnAxis(fid,i+1)); + med_int const nAxis(MEDsupportMeshnAxis(fid,i+1)); INTERP_KERNEL::AutoPtr axisName(new char[MED_SNAME_SIZE*nAxis+1]),axisUnit(new char[MED_SNAME_SIZE*nAxis+1]); med_int spaceDim(0),meshDim(0); MEDFILESAFECALLERRD0(MEDsupportMeshInfo,(fid,i+1,msn,&spaceDim,&meshDim,description,&axType,axisName,axisUnit)); - std::string name(MEDLoaderBase::buildStringFromFortran(msn,MED_NAME_SIZE)); + std::string const name(MEDLoaderBase::buildStringFromFortran(msn,MED_NAME_SIZE)); _supports[i]=MEDFileUMesh::New(fid,name); } } MEDFileMeshSupports::MEDFileMeshSupports() -{ -} += default; MEDFileMeshSupports::~MEDFileMeshSupports() -{ -} += default; std::vector MEDFileMeshSupports::getDirectChildrenWithNull() const { - std::size_t sz(_supports.size()); + std::size_t const sz(_supports.size()); std::vector ret(sz); for(std::size_t i=0;i >::const_iterator it=_supports.begin();it!=_supports.end();it++) - if((*it).isNotNull()) - (*it)->writeLL(fid); + for(const auto & _support : _supports) + if(_support.isNotNull()) + _support->writeLL(fid); } std::vector MEDFileMeshSupports::getSupMeshNames() const { std::vector ret; - for(std::vector< MCAuto >::const_iterator it=_supports.begin();it!=_supports.end();it++) - if((*it).isNotNull()) - ret.push_back((*it)->getName()); + for(const auto & _support : _supports) + if(_support.isNotNull()) + ret.push_back(_support->getName()); return ret; } const MEDFileUMesh *MEDFileMeshSupports::getSupMeshWithName(const std::string& name) const { std::vector mns; - for(std::vector< MCAuto >::const_iterator it=_supports.begin();it!=_supports.end();it++) + for(const auto & _support : _supports) { - if((*it).isNotNull()) + if(_support.isNotNull()) { - std::string na((*it)->getName()); + std::string const na(_support->getName()); if(na==name) - return *it; + return _support; else mns.push_back(na); } diff --git a/src/MEDLoader/MEDFileMeshSupport.hxx b/src/MEDLoader/MEDFileMeshSupport.hxx index 7291e7ea0..b51ed45e0 100644 --- a/src/MEDLoader/MEDFileMeshSupport.hxx +++ b/src/MEDLoader/MEDFileMeshSupport.hxx @@ -21,11 +21,18 @@ #ifndef __MEDFILEMESHSUPPORT_HXX__ #define __MEDFILEMESHSUPPORT_HXX__ +#include "MCAuto.hxx" +#include "MEDFileUtilities.hxx" +#include "MCType.hxx" #include "MEDLoaderDefines.hxx" -#include "MEDFileUtilities.txx" #include "MEDFileMesh.hxx" #include "MEDCouplingRefCountObject.hxx" +#include +#include "med.h" +#include +#include +#include "NormalizedGeometricTypes" namespace MEDCoupling { @@ -37,16 +44,16 @@ namespace MEDCoupling MEDLOADER_EXPORT static MEDFileMeshSupports *New(); MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileMeshSupports"); } public: - MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const; - MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; - MEDLOADER_EXPORT void writeLL(med_idt fid) const; + MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const override; + MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const override; + MEDLOADER_EXPORT void writeLL(med_idt fid) const override; MEDLOADER_EXPORT std::vector getSupMeshNames() const; MEDLOADER_EXPORT const MEDFileUMesh *getSupMeshWithName(const std::string& name) const; MEDLOADER_EXPORT mcIdType getNumberOfNodesInConnOf(TypeOfField entity, INTERP_KERNEL::NormalizedCellType gt, const std::string& name) const; private: MEDFileMeshSupports(med_idt fid); MEDFileMeshSupports(); - ~MEDFileMeshSupports(); + ~MEDFileMeshSupports() override; private: std::vector< MCAuto > _supports; }; diff --git a/src/MEDLoader/MEDFileParameter.cxx b/src/MEDLoader/MEDFileParameter.cxx index 0c8473f16..c8de1c530 100644 --- a/src/MEDLoader/MEDFileParameter.cxx +++ b/src/MEDLoader/MEDFileParameter.cxx @@ -19,13 +19,29 @@ // Author : Anthony Geay (CEA/DEN) #include "MEDFileParameter.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include "MCAuto.hxx" #include "MEDFileSafeCaller.txx" +#include "MEDFileUtilities.hxx" #include "MEDLoaderBase.hxx" #include "MEDFileBasis.hxx" #include "InterpKernelAutoPtr.hxx" - +#include "med.h" +#include "medparameter.h" +#include "medfile.h" + +#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include using namespace MEDCoupling; @@ -60,7 +76,7 @@ bool MEDFileParameterDouble1TSWTI::isEqual(const MEDFileParameter1TS *other, dou { if(!MEDFileParameter1TS::isEqual(other,eps,what)) return false; - const MEDFileParameterDouble1TSWTI *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) { what="IsEqual fails because this is double parameter other no !"; return false; } if(fabs(_arr-otherC->_arr)>eps) @@ -87,7 +103,7 @@ std::string MEDFileParameterDouble1TSWTI::simpleRepr() const void MEDFileParameterDouble1TSWTI::simpleRepr2(int bkOffset, std::ostream& oss) const { - std::string startOfLine(bkOffset,' '); + std::string const startOfLine(bkOffset,' '); oss << startOfLine << "ParameterDoubleItem with (iteration,order) = (" << _iteration << "," << _order << ")" << std::endl; oss << startOfLine << "Time associacited = " << _time << std::endl; oss << startOfLine << "The value is ***** " << _arr << " *****" << std::endl; @@ -179,7 +195,7 @@ void MEDFileParameterTinyInfo::writeLLHeader(med_idt fid, med_parameter_type typ void MEDFileParameterTinyInfo::mainRepr(int bkOffset, std::ostream& oss) const { - std::string startOfLine(bkOffset,' '); + std::string const startOfLine(bkOffset,' '); oss << startOfLine << "Parameter with name \"" << _name << "\"" << std::endl; oss << startOfLine << "Parameter with description \"" << _desc_name << "\"" << std::endl; oss << startOfLine << "Parameter with unit name \"" << _dt_unit << "\"" << std::endl; @@ -206,14 +222,13 @@ MEDFileParameterDouble1TS *MEDFileParameterDouble1TS::New(const std::string& fil } MEDFileParameterDouble1TS::MEDFileParameterDouble1TS() -{ -} += default; MEDFileParameterDouble1TS::MEDFileParameterDouble1TS(const std::string& fileName, const std::string& paramName, int dt, int it) { MEDFileUtilities::CheckFileForRead(fileName); - MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY); - med_int nbPar=MEDnParameter(fid); + MEDFileUtilities::AutoFid const fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY); + med_int const nbPar=MEDnParameter(fid); std::ostringstream oss; oss << "MEDFileParameterDouble1TS : no double param name \"" << paramName << "\" ! Double Parameters available are : "; INTERP_KERNEL::AutoPtr pName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); INTERP_KERNEL::AutoPtr descName=MEDLoaderBase::buildEmptyString(MED_COMMENT_SIZE); @@ -223,7 +238,7 @@ MEDFileParameterDouble1TS::MEDFileParameterDouble1TS(const std::string& fileName { med_int nbOfSteps; MEDFILESAFECALLERRD0(MEDparameterInfo,(fid,i+1,pName,¶mType,descName,unitName,&nbOfSteps)); - std::string paramNameCpp=MEDLoaderBase::buildStringFromFortran(pName,MED_NAME_SIZE); + std::string const paramNameCpp=MEDLoaderBase::buildStringFromFortran(pName,MED_NAME_SIZE); if(paramNameCpp==paramName && paramType==MED_FLOAT64) { _dt_unit=MEDLoaderBase::buildStringFromFortran(unitName,MED_SNAME_SIZE); @@ -244,8 +259,8 @@ MEDFileParameterDouble1TS::MEDFileParameterDouble1TS(const std::string& fileName MEDFileParameterDouble1TS::MEDFileParameterDouble1TS(const std::string& fileName, const std::string& paramName) { MEDFileUtilities::CheckFileForRead(fileName); - MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY); - med_int nbPar=MEDnParameter(fid); + MEDFileUtilities::AutoFid const fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY); + med_int const nbPar=MEDnParameter(fid); std::ostringstream oss; oss << "MEDFileParameterDouble1TS : no double param name \"" << paramName << "\" ! Double Parameters available are : "; INTERP_KERNEL::AutoPtr pName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); INTERP_KERNEL::AutoPtr descName=MEDLoaderBase::buildEmptyString(MED_COMMENT_SIZE); @@ -255,7 +270,7 @@ MEDFileParameterDouble1TS::MEDFileParameterDouble1TS(const std::string& fileName { med_int nbOfSteps; MEDFILESAFECALLERRD0(MEDparameterInfo,(fid,i+1,pName,¶mType,descName,unitName,&nbOfSteps)); - std::string paramNameCpp=MEDLoaderBase::buildStringFromFortran(pName,MED_NAME_SIZE); + std::string const paramNameCpp=MEDLoaderBase::buildStringFromFortran(pName,MED_NAME_SIZE); if(paramNameCpp==paramName && paramType==MED_FLOAT64) { if(nbOfSteps>0) @@ -284,8 +299,8 @@ MEDFileParameterDouble1TS::MEDFileParameterDouble1TS(const std::string& fileName MEDFileParameterDouble1TS::MEDFileParameterDouble1TS(const std::string& fileName) { MEDFileUtilities::CheckFileForRead(fileName); - MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY); - med_int nbPar=MEDnParameter(fid); + MEDFileUtilities::AutoFid const fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY); + med_int const nbPar=MEDnParameter(fid); if(nbPar<1) { std::ostringstream oss2; oss2 << "No parameter in file \"" << fileName << "\" !"; @@ -297,7 +312,7 @@ MEDFileParameterDouble1TS::MEDFileParameterDouble1TS(const std::string& fileName med_parameter_type paramType; med_int nbOfSteps; MEDFILESAFECALLERRD0(MEDparameterInfo,(fid,1,pName,¶mType,descName,unitName,&nbOfSteps)); - std::string paramNameCpp=MEDLoaderBase::buildStringFromFortran(pName,MED_NAME_SIZE); + std::string const paramNameCpp=MEDLoaderBase::buildStringFromFortran(pName,MED_NAME_SIZE); if(paramType==MED_FLOAT64) { if(nbOfSteps>0) @@ -325,7 +340,7 @@ bool MEDFileParameterDouble1TS::isEqual(const MEDFileParameter1TS *other, double { if(!MEDFileParameterDouble1TSWTI::isEqual(other,eps,what)) return false; - const MEDFileParameterDouble1TS *otherC=dynamic_cast(other); + const auto *otherC=dynamic_cast(other); if(!otherC) { what="Other is not of type MEDFileParameterDouble1TS as this"; return false; } if(!isEqualStrings(*otherC,what)) @@ -358,8 +373,8 @@ std::vector MEDFileParameterDouble1TS::getDirectChildre void MEDFileParameterDouble1TS::write(const std::string& fileName, int mode) const { - med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode); - MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod); + med_access_mode const medmod=MEDFileUtilities::TraduceWriteMode(mode); + MEDFileUtilities::AutoFid const fid=MEDfileOpen(fileName.c_str(),medmod); MEDFileParameterTinyInfo::writeLLHeader(fid,MED_FLOAT64); MEDFileParameterDouble1TSWTI::writeAdvanced(fid,_name,*this); } @@ -371,7 +386,7 @@ MEDFileParameterMultiTS *MEDFileParameterMultiTS::New() MEDFileParameterMultiTS *MEDFileParameterMultiTS::New(const std::string& fileName) { - MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + MEDFileUtilities::AutoFid const fid(OpenMEDFileForRead(fileName)); return New(fid); } @@ -382,7 +397,7 @@ MEDFileParameterMultiTS *MEDFileParameterMultiTS::New(med_idt fid) MEDFileParameterMultiTS *MEDFileParameterMultiTS::New(const std::string& fileName, const std::string& paramName) { - MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + MEDFileUtilities::AutoFid const fid(OpenMEDFileForRead(fileName)); return New(fid,paramName); } @@ -392,23 +407,22 @@ MEDFileParameterMultiTS *MEDFileParameterMultiTS::New(med_idt fid, const std::st } MEDFileParameterMultiTS::MEDFileParameterMultiTS() -{ -} += default; MEDFileParameterMultiTS::MEDFileParameterMultiTS(const MEDFileParameterMultiTS& other, bool deepCopy):MEDFileParameterTinyInfo(other),_param_per_ts(other._param_per_ts) { if(deepCopy) - for(std::size_t i=0;i<_param_per_ts.size();i++) + for(auto & _param_per_t : _param_per_ts) { - const MEDFileParameter1TS *elt=_param_per_ts[i]; + const MEDFileParameter1TS *elt=_param_per_t; if(elt) - _param_per_ts[i]=elt->deepCopy(); + _param_per_t=elt->deepCopy(); } } MEDFileParameterMultiTS::MEDFileParameterMultiTS(med_idt fid) { - med_int nbPar(MEDnParameter(fid)); + med_int const nbPar(MEDnParameter(fid)); if(nbPar<1) { std::ostringstream oss; oss << "MEDFileParameterMultiTS : no parameter in file \"" << FileNameFromFID(fid) << "\" !" ; @@ -420,7 +434,7 @@ MEDFileParameterMultiTS::MEDFileParameterMultiTS(med_idt fid) med_parameter_type paramType; med_int nbOfSteps; MEDFILESAFECALLERRD0(MEDparameterInfo,(fid,1,pName,¶mType,descName,unitName,&nbOfSteps)); - std::string paramNameCpp(MEDLoaderBase::buildStringFromFortran(pName,MED_NAME_SIZE)); + std::string const paramNameCpp(MEDLoaderBase::buildStringFromFortran(pName,MED_NAME_SIZE)); _dt_unit=MEDLoaderBase::buildStringFromFortran(unitName,MED_SNAME_SIZE); _name=paramNameCpp; _desc_name=MEDLoaderBase::buildStringFromFortran(descName,MED_COMMENT_SIZE); @@ -429,7 +443,7 @@ MEDFileParameterMultiTS::MEDFileParameterMultiTS(med_idt fid) MEDFileParameterMultiTS::MEDFileParameterMultiTS(med_idt fid, const std::string& paramName) { - med_int nbPar(MEDnParameter(fid)); + med_int const nbPar(MEDnParameter(fid)); std::ostringstream oss; oss << "MEDFileParameterDouble1TS : no double param name \"" << paramName << "\" ! Double Parameters available are : "; INTERP_KERNEL::AutoPtr pName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)); INTERP_KERNEL::AutoPtr descName(MEDLoaderBase::buildEmptyString(MED_COMMENT_SIZE)); @@ -439,7 +453,7 @@ MEDFileParameterMultiTS::MEDFileParameterMultiTS(med_idt fid, const std::string& { med_int nbOfSteps; MEDFILESAFECALLERRD0(MEDparameterInfo,(fid,i+1,pName,¶mType,descName,unitName,&nbOfSteps)); - std::string paramNameCpp(MEDLoaderBase::buildStringFromFortran(pName,MED_NAME_SIZE)); + std::string const paramNameCpp(MEDLoaderBase::buildStringFromFortran(pName,MED_NAME_SIZE)); if(paramNameCpp==paramName) { if(nbOfSteps>0) @@ -498,8 +512,8 @@ std::size_t MEDFileParameterMultiTS::getHeapMemorySizeWithoutChildren() const std::vector MEDFileParameterMultiTS::getDirectChildrenWithNull() const { std::vector ret; - for(std::vector< MCAuto >::const_iterator it=_param_per_ts.begin();it!=_param_per_ts.end();it++) - ret.push_back((const MEDFileParameter1TS *)*it); + for(const auto & _param_per_t : _param_per_ts) + ret.push_back((const MEDFileParameter1TS *)_param_per_t); return ret; } @@ -529,17 +543,17 @@ bool MEDFileParameterMultiTS::isEqual(const MEDFileParameterMultiTS *other, doub void MEDFileParameterMultiTS::write(const std::string& fileName, int mode) const { - med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode); - MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod); + med_access_mode const medmod=MEDFileUtilities::TraduceWriteMode(mode); + MEDFileUtilities::AutoFid const fid=MEDfileOpen(fileName.c_str(),medmod); writeAdvanced(fid,*this); } void MEDFileParameterMultiTS::writeAdvanced(med_idt fid, const MEDFileWritable& mw) const { std::set diffType; - for(std::vector< MCAuto >::const_iterator it=_param_per_ts.begin();it!=_param_per_ts.end();it++) + for(const auto & _param_per_t : _param_per_ts) { - const MEDFileParameter1TS *elt(*it); + const MEDFileParameter1TS *elt(_param_per_t); if(dynamic_cast(elt)) diffType.insert(MED_FLOAT64); } @@ -547,11 +561,11 @@ void MEDFileParameterMultiTS::writeAdvanced(med_idt fid, const MEDFileWritable& throw INTERP_KERNEL::Exception("MEDFileParameterMultiTS::writeAdvanced : impossible to mix type of data in parameters in MED file ! Only float64 or only int32 ..."); if(diffType.empty()) return; - med_parameter_type typ(*diffType.begin()); + med_parameter_type const typ(*diffType.begin()); MEDFileParameterTinyInfo::writeLLHeader(fid,typ); - for(std::vector< MCAuto >::const_iterator it=_param_per_ts.begin();it!=_param_per_ts.end();it++) + for(const auto & _param_per_t : _param_per_ts) { - const MEDFileParameter1TS *elt(*it); + const MEDFileParameter1TS *elt(_param_per_t); if(elt) elt->writeAdvanced(fid,_name,mw); } @@ -567,9 +581,9 @@ std::string MEDFileParameterMultiTS::simpleRepr() const void MEDFileParameterMultiTS::simpleRepr2(int bkOffset, std::ostream& oss) const { MEDFileParameterTinyInfo::mainRepr(bkOffset,oss); - for(std::vector< MCAuto >::const_iterator it=_param_per_ts.begin();it!=_param_per_ts.end();it++) + for(const auto & _param_per_t : _param_per_ts) { - const MEDFileParameter1TS *elt(*it); + const MEDFileParameter1TS *elt(_param_per_t); if(elt) elt->simpleRepr2(bkOffset+2,oss); } @@ -585,7 +599,7 @@ void MEDFileParameterMultiTS::appendValue(int dt, int it, double time, double va double MEDFileParameterMultiTS::getDoubleValue(int iteration, int order) const { - int pos=getPosOfTimeStep(iteration,order); + int const pos=getPosOfTimeStep(iteration,order); const MEDFileParameter1TS *elt=_param_per_ts[pos]; if(!elt) { @@ -593,7 +607,7 @@ double MEDFileParameterMultiTS::getDoubleValue(int iteration, int order) const oss << " exists but elt is empty !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - const MEDFileParameterDouble1TSWTI *eltC=dynamic_cast(elt); + const auto *eltC=dynamic_cast(elt); if(!eltC) { std::ostringstream oss; oss << "MEDFileParameterMultiTS::getDoubleValue : time iteration it=" << iteration << " order=" << order; @@ -606,7 +620,7 @@ int MEDFileParameterMultiTS::getPosOfTimeStep(int iteration, int order) const { int ret=0; std::ostringstream oss; oss << "MEDFileParameterMultiTS::getPosOfTimeStep : no such iteration=" << iteration << " order=" << order << " ! Possibilities are :"; - for(std::vector< MCAuto >::const_iterator it=_param_per_ts.begin();it!=_param_per_ts.end();it++,ret++) + for(auto it=_param_per_ts.begin();it!=_param_per_ts.end();it++,ret++) { const MEDFileParameter1TS *elt(*it); if(elt) @@ -624,7 +638,7 @@ int MEDFileParameterMultiTS::getPosGivenTime(double time, double eps) const { int ret=0; std::ostringstream oss; oss << "MEDFileParameterMultiTS::getPosGivenTime : no such time=" << time << " ! Possibilities are :"; - for(std::vector< MCAuto >::const_iterator it=_param_per_ts.begin();it!=_param_per_ts.end();it++,ret++) + for(auto it=_param_per_ts.begin();it!=_param_per_ts.end();it++,ret++) { const MEDFileParameter1TS *elt(*it); if(elt) @@ -654,7 +668,7 @@ MEDFileParameter1TS *MEDFileParameterMultiTS::getTimeStepAtPos(int posId) const void MEDFileParameterMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds) { std::vector b(_param_per_ts.size(),true); - int len=(int)_param_per_ts.size(); + int const len=(int)_param_per_ts.size(); for(const int *w=startIds;w!=endIds;w++) if(*w>=0 && *w > paramPerTs(newNb); std::size_t j=0; for(std::size_t i=0;i<_param_per_ts.size();i++) @@ -679,9 +693,9 @@ int MEDFileParameterMultiTS::getNumberOfTS() const std::vector< std::pair > MEDFileParameterMultiTS::getIterations() const { std::vector< std::pair > ret; - for(std::vector< MCAuto >::const_iterator it=_param_per_ts.begin();it!=_param_per_ts.end();it++) + for(const auto & _param_per_t : _param_per_ts) { - const MEDFileParameter1TS *elt(*it); + const MEDFileParameter1TS *elt(_param_per_t); if(elt) ret.push_back(std::pair(elt->getIteration(),elt->getOrder())); } @@ -695,9 +709,9 @@ std::vector< std::pair > MEDFileParameterMultiTS::getTimeSteps(std::vec { std::vector< std::pair > ret0; ret1.clear(); - for(std::vector< MCAuto >::const_iterator it=_param_per_ts.begin();it!=_param_per_ts.end();it++) + for(const auto & _param_per_t : _param_per_ts) { - const MEDFileParameter1TS *elt(*it); + const MEDFileParameter1TS *elt(_param_per_t); if(elt) { ret0.push_back(std::pair(elt->getIteration(),elt->getOrder())); @@ -714,7 +728,7 @@ MEDFileParameters *MEDFileParameters::New() MEDFileParameters *MEDFileParameters::New(const std::string& fileName) { - MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + MEDFileUtilities::AutoFid const fid(OpenMEDFileForRead(fileName)); return New(fid); } @@ -725,7 +739,7 @@ MEDFileParameters *MEDFileParameters::New(med_idt fid) MEDFileParameters::MEDFileParameters(med_idt fid) { - med_int nbPar=MEDnParameter(fid); + med_int const nbPar=MEDnParameter(fid); _params.resize(nbPar); INTERP_KERNEL::AutoPtr pName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)); INTERP_KERNEL::AutoPtr descName(MEDLoaderBase::buildEmptyString(MED_COMMENT_SIZE)); @@ -735,14 +749,13 @@ MEDFileParameters::MEDFileParameters(med_idt fid) { med_int nbOfSteps; MEDFILESAFECALLERRD0(MEDparameterInfo,(fid,i+1,pName,¶mType,descName,unitName,&nbOfSteps)); - std::string paramNameCpp(MEDLoaderBase::buildStringFromFortran(pName,MED_NAME_SIZE)); + std::string const paramNameCpp(MEDLoaderBase::buildStringFromFortran(pName,MED_NAME_SIZE)); _params[i]=MEDFileParameterMultiTS::New(fid,paramNameCpp); } } MEDFileParameters::MEDFileParameters() -{ -} += default; std::size_t MEDFileParameters::getHeapMemorySizeWithoutChildren() const { @@ -754,8 +767,8 @@ std::size_t MEDFileParameters::getHeapMemorySizeWithoutChildren() const std::vector MEDFileParameters::getDirectChildrenWithNull() const { std::vector ret; - for(std::vector< MCAuto >::const_iterator it=_params.begin();it!=_params.end();it++) - ret.push_back((const MEDFileParameterMultiTS *)*it); + for(const auto & _param : _params) + ret.push_back((const MEDFileParameterMultiTS *)_param); return ret; } @@ -786,19 +799,19 @@ bool MEDFileParameters::isEqual(const MEDFileParameters *other, double eps, std: MEDFileParameters::MEDFileParameters(const MEDFileParameters& other, bool deepCopy):MEDFileWritableStandAlone(other),_params(other._params) { if(deepCopy) - for(std::size_t i=0;i<_params.size();i++) + for(auto & _param : _params) { - const MEDFileParameterMultiTS *elt=_params[i]; + const MEDFileParameterMultiTS *elt=_param; if(elt) - _params[i]=elt->deepCopy(); + _param=elt->deepCopy(); } } void MEDFileParameters::writeLL(med_idt fid) const { - for(std::vector< MCAuto >::const_iterator it=_params.begin();it!=_params.end();it++) + for(const auto & _param : _params) { - const MEDFileParameterMultiTS *elt(*it); + const MEDFileParameterMultiTS *elt(_param); if(elt) elt->writeAdvanced(fid,*this); } @@ -808,7 +821,7 @@ std::vector MEDFileParameters::getParamsNames() const { std::vector ret(_params.size()); int i=0; - for(std::vector< MCAuto >::const_iterator it=_params.begin();it!=_params.end();it++,i++) + for(auto it=_params.begin();it!=_params.end();it++,i++) { const MEDFileParameterMultiTS *p=(*it); if(p) @@ -833,9 +846,9 @@ std::string MEDFileParameters::simpleRepr() const void MEDFileParameters::simpleReprWithoutHeader(std::ostream& oss) const { - for(std::vector< MCAuto >::const_iterator it=_params.begin();it!=_params.end();it++) + for(const auto & _param : _params) { - const MEDFileParameterMultiTS *elt(*it); + const MEDFileParameterMultiTS *elt(_param); if(elt) elt->simpleRepr2(2,oss); } @@ -852,7 +865,7 @@ void MEDFileParameters::pushParam(MEDFileParameterMultiTS *param) { if(param) param->incrRef(); - MCAuto elt(param); + MCAuto const elt(param); _params.push_back(elt); } @@ -864,7 +877,7 @@ void MEDFileParameters::setParamAtPos(int i, MEDFileParameterMultiTS *param) _params.resize(i+1); if(param) param->incrRef(); - MCAuto elt(param); + MCAuto const elt(param); _params[i]=elt; } @@ -887,7 +900,7 @@ MEDFileParameterMultiTS *MEDFileParameters::getParamAtPos(int i) const */ MEDFileParameterMultiTS *MEDFileParameters::getParamWithName(const std::string& paramName) const { - int pos=getPosFromParamName(paramName); + int const pos=getPosFromParamName(paramName); return getParamAtPos(pos); } @@ -898,14 +911,14 @@ void MEDFileParameters::destroyParamAtPos(int i) std::ostringstream oss; oss << "MEDFileParameters::destroyParamAtPos : should be in [0," << _params.size() << ") !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - _params[i]=MCAuto(0); + _params[i]=MCAuto(nullptr); } int MEDFileParameters::getPosFromParamName(const std::string& paramName) const { std::ostringstream oss; oss << "MEDFileParameters::getPosFromParamName : no such name=" << paramName << " ! Possibilities are :"; int ret=0; - for(std::vector< MCAuto >::const_iterator it=_params.begin();it!=_params.end();it++,ret++) + for(auto it=_params.begin();it!=_params.end();it++,ret++) { const MEDFileParameterMultiTS *elt(*it); if(elt) diff --git a/src/MEDLoader/MEDFileParameter.hxx b/src/MEDLoader/MEDFileParameter.hxx index 42991e8dc..ff8844fa4 100644 --- a/src/MEDLoader/MEDFileParameter.hxx +++ b/src/MEDLoader/MEDFileParameter.hxx @@ -21,10 +21,17 @@ #ifndef __MEDFILEPARAMETER_HXX__ #define __MEDFILEPARAMETER_HXX__ -#include "MEDLoaderDefines.hxx" +#include "MEDCouplingRefCountObject.hxx" #include "MEDFileUtilities.txx" +#include "MEDLoaderDefines.hxx" #include "MEDCouplingMemArray.hxx" #include "MCAuto.hxx" +#include +#include +#include "med.h" +#include +#include +#include namespace MEDCoupling { @@ -59,21 +66,21 @@ namespace MEDCoupling public: MEDLOADER_EXPORT static MEDFileParameterDouble1TSWTI *New(int iteration, int order, double time); MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileParameterDouble1TSWTI"); } - MEDLOADER_EXPORT MEDFileParameter1TS *deepCopy() const; + MEDLOADER_EXPORT MEDFileParameter1TS *deepCopy() const override; MEDLOADER_EXPORT void setValue(double val) { _arr=val; } MEDLOADER_EXPORT double getValue() const { return _arr; } - MEDLOADER_EXPORT bool isEqual(const MEDFileParameter1TS *other, double eps, std::string& what) const; - MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; - MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const; - MEDLOADER_EXPORT void readValue(med_idt fid, const std::string& name); + MEDLOADER_EXPORT bool isEqual(const MEDFileParameter1TS *other, double eps, std::string& what) const override; + MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const override; + MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const override; + MEDLOADER_EXPORT void readValue(med_idt fid, const std::string& name) override; MEDLOADER_EXPORT std::string simpleRepr() const; protected: MEDFileParameterDouble1TSWTI(); MEDFileParameterDouble1TSWTI(int iteration, int order, double time); - void simpleRepr2(int bkOffset, std::ostream& oss) const; + void simpleRepr2(int bkOffset, std::ostream& oss) const override; void finishLoading(med_idt fid, const std::string& name, int dt, int it, int nbOfSteps); void finishLoading(med_idt fid, const std::string& name, int timeStepId); - void writeAdvanced(med_idt fid, const std::string& name, const MEDFileWritable& mw) const; + void writeAdvanced(med_idt fid, const std::string& name, const MEDFileWritable& mw) const override; protected: double _arr; }; @@ -104,11 +111,11 @@ namespace MEDCoupling MEDLOADER_EXPORT static MEDFileParameterDouble1TS *New(const std::string& fileName, const std::string& paramName); MEDLOADER_EXPORT static MEDFileParameterDouble1TS *New(const std::string& fileName, const std::string& paramName, int dt, int it); MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileParameterDouble1TS"); } - MEDLOADER_EXPORT virtual MEDFileParameter1TS *deepCopy() const; - MEDLOADER_EXPORT virtual bool isEqual(const MEDFileParameter1TS *other, double eps, std::string& what) const; + MEDLOADER_EXPORT MEDFileParameter1TS *deepCopy() const override; + MEDLOADER_EXPORT bool isEqual(const MEDFileParameter1TS *other, double eps, std::string& what) const override; MEDLOADER_EXPORT virtual std::string simpleRepr() const; - MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; - MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const; + MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const override; + MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const override; MEDLOADER_EXPORT void setName(const std::string& name) { _name=name; } MEDLOADER_EXPORT std::string getName() const { return _name; } MEDLOADER_EXPORT void write(const std::string& fileName, int mode) const; @@ -130,8 +137,8 @@ namespace MEDCoupling MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileParameterMultiTS"); } MEDLOADER_EXPORT std::string getName() const { return _name; } MEDLOADER_EXPORT void setName(const std::string& name) { _name=name; } - MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; - MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const; + MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const override; + MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const override; MEDLOADER_EXPORT MEDFileParameterMultiTS *deepCopy() const; MEDLOADER_EXPORT bool isEqual(const MEDFileParameterMultiTS *other, double eps, std::string& what) const; MEDLOADER_EXPORT void write(const std::string& fileName, int mode) const; @@ -165,11 +172,11 @@ namespace MEDCoupling MEDLOADER_EXPORT static MEDFileParameters *New(DataArrayByte *db) { return BuildFromMemoryChunk(db); } MEDLOADER_EXPORT static MEDFileParameters *New(const std::string& fileName); MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileParameters"); } - MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; - MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const; + MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const override; + MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const override; MEDLOADER_EXPORT MEDFileParameters *deepCopy() const; MEDLOADER_EXPORT bool isEqual(const MEDFileParameters *other, double eps, std::string& what) const; - MEDLOADER_EXPORT void writeLL(med_idt fid) const; + MEDLOADER_EXPORT void writeLL(med_idt fid) const override; MEDLOADER_EXPORT std::vector getParamsNames() const; MEDLOADER_EXPORT std::string simpleRepr() const; MEDLOADER_EXPORT void simpleReprWithoutHeader(std::ostream& oss) const; diff --git a/src/MEDLoader/MEDFileSafeCaller.txx b/src/MEDLoader/MEDFileSafeCaller.txx index c43ef45cf..6dfd21e7e 100644 --- a/src/MEDLoader/MEDFileSafeCaller.txx +++ b/src/MEDLoader/MEDFileSafeCaller.txx @@ -21,11 +21,8 @@ #ifndef __MEDFILESAFECALLER_TXX__ #define __MEDFILESAFECALLER_TXX__ -#include "med.h" -#include "InterpKernelException.hxx" -#include // TXX extension to avoid to be installed. diff --git a/src/MEDLoader/MEDFileStructureElement.cxx b/src/MEDLoader/MEDFileStructureElement.cxx index 7c3bd5f81..d2d56f5ed 100644 --- a/src/MEDLoader/MEDFileStructureElement.cxx +++ b/src/MEDLoader/MEDFileStructureElement.cxx @@ -19,12 +19,26 @@ // Author : Anthony Geay (EDF R&D) #include "MEDFileStructureElement.hxx" +#include "MCType.hxx" +#include "MCAuto.hxx" +#include "MEDCouplingMemArray.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include "MCIdType.hxx" +#include "MEDFileBasis.hxx" #include "MEDFileMeshSupport.hxx" +#include "MEDFileUtilities.hxx" #include "MEDLoaderBase.hxx" #include "MEDFileMeshLL.hxx" #include "MEDFileSafeCaller.txx" #include "InterpKernelAutoPtr.hxx" +#include +#include +#include "NormalizedGeometricTypes" +#include "med.h" +#include "medstructelement.h" +#include +#include using namespace MEDCoupling; @@ -58,14 +72,14 @@ MEDFileSEConstAtt *MEDFileSEConstAtt::New(med_idt fid, MEDFileStructureElement * MEDFileSEConstAtt::MEDFileSEConstAtt(med_idt fid, MEDFileStructureElement *father, int idCstAtt, const MEDFileUMesh *mesh):MEDFileSEHolder(father) { - std::string modelName(getModelName()); + std::string const modelName(getModelName()); INTERP_KERNEL::AutoPtr constattname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)),profilename(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)); med_attribute_type constatttype; med_int nbCompo; med_entity_type met; med_int miPflSz; MEDFILESAFECALLERRD0(MEDstructElementConstAttInfo,(fid,modelName.c_str(),idCstAtt+1,constattname,&constatttype,&nbCompo,&met,profilename,&miPflSz)); - std::string name(MEDLoaderBase::buildStringFromFortran(constattname,MED_NAME_SIZE)); + std::string const name(MEDLoaderBase::buildStringFromFortran(constattname,MED_NAME_SIZE)); setName(name); setProfile(MEDLoaderBase::buildStringFromFortran(profilename,MED_NAME_SIZE)); _tof=MEDFileMesh::ConvertFromMEDFileEntity(met); @@ -137,7 +151,7 @@ MEDFileSEVarAtt *MEDFileSEVarAtt::New(med_idt fid, MEDFileStructureElement *fath MEDFileSEVarAtt::MEDFileSEVarAtt(med_idt fid, MEDFileStructureElement *father, int idVarAtt):MEDFileSEHolder(father) { - std::string modelName(getModelName()); + std::string const modelName(getModelName()); INTERP_KERNEL::AutoPtr varattname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)),profilename(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)); med_attribute_type varatttype; { @@ -201,10 +215,10 @@ MEDFileStructureElement::MEDFileStructureElement(med_idt fid, int idSE, const ME std::vector MEDFileStructureElement::getDirectChildrenWithNull() const { std::vector ret; - for(std::vector< MCAuto >::const_iterator it=_cst_att.begin();it!=_cst_att.end();it++) - ret.push_back(*it); - for(std::vector< MCAuto >::const_iterator it=_var_att.begin();it!=_var_att.end();it++) - ret.push_back(*it); + for(const auto & it : _cst_att) + ret.push_back(it); + for(const auto & it : _var_att) + ret.push_back(it); return ret; } @@ -280,18 +294,18 @@ std::string MEDFileStructureElement::getMeshName() const std::vector MEDFileStructureElement::getVarAtts() const { std::vector ret; - for(std::vector< MCAuto >::const_iterator it=_var_att.begin();it!=_var_att.end();it++) - if((*it).isNotNull()) - ret.push_back((*it)->getName()); + for(const auto & it : _var_att) + if(it.isNotNull()) + ret.push_back(it->getName()); return ret; } const MEDFileSEVarAtt *MEDFileStructureElement::getVarAtt(const std::string& varName) const { - for(std::vector< MCAuto >::const_iterator it=_var_att.begin();it!=_var_att.end();it++) - if((*it).isNotNull()) - if((*it)->getName()==varName) - return *it; + for(const auto & it : _var_att) + if(it.isNotNull()) + if(it->getName()==varName) + return it; std::ostringstream oss; oss << "MEDFileStructureElement::getVarAtt : no var att with name \"" << varName << "\" !"; throw INTERP_KERNEL::Exception(oss.str()); } @@ -300,7 +314,7 @@ const MEDFileSEVarAtt *MEDFileStructureElement::getVarAtt(const std::string& var MEDFileStructureElements *MEDFileStructureElements::New(const std::string& fileName, const MEDFileMeshSupports *ms) { - MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + MEDFileUtilities::AutoFid const fid(OpenMEDFileForRead(fileName)); return New(fid,ms); } @@ -317,8 +331,8 @@ MEDFileStructureElements *MEDFileStructureElements::New() std::vector MEDFileStructureElements::getDirectChildrenWithNull() const { std::vector ret; - for(std::vector< MCAuto >::const_iterator it=_elems.begin();it!=_elems.end();it++) - ret.push_back(*it); + for(const auto & _elem : _elems) + ret.push_back(_elem); return ret; } @@ -333,7 +347,7 @@ void MEDFileStructureElements::writeLL(med_idt fid) const MEDFileStructureElements::MEDFileStructureElements(med_idt fid, const MEDFileMeshSupports *ms) { - med_int nbSE(MEDnStructElement(fid)); + med_int const nbSE(MEDnStructElement(fid)); _elems.resize(nbSE); for(int i=0;i MEDFileStructureElements::getDynGTAvail() const { std::vector ret; - for(std::vector< MCAuto >::const_iterator it=_elems.begin();it!=_elems.end();it++) + for(const auto & _elem : _elems) { - const MEDFileStructureElement *elt(*it); + const MEDFileStructureElement *elt(_elem); if(elt) ret.push_back(elt->getDynGT()); } @@ -367,11 +379,11 @@ std::vector MEDFileStructureElements::getDynGTAvail() const const MEDFileStructureElement *MEDFileStructureElements::getWithGT(int idGT) const { - for(std::vector< MCAuto >::const_iterator it=_elems.begin();it!=_elems.end();it++) - if((*it).isNotNull()) + for(const auto & _elem : _elems) + if(_elem.isNotNull()) { - if((*it)->getDynGT()==idGT) - return *it; + if(_elem->getDynGT()==idGT) + return _elem; } std::ostringstream oss; oss << "MEDFileStructureElements::getWithGT : no such geo type " << idGT << " !"; throw INTERP_KERNEL::Exception(oss.str()); @@ -382,17 +394,17 @@ mcIdType MEDFileStructureElements::getNumberOfNodesPerSE(const std::string& seNa if(seName=="MED_PARTICLE") return 1; const MEDFileStructureElement *se(getSEWithName(seName)); - std::string meshName(se->getMeshName()); + std::string const meshName(se->getMeshName()); return _sup->getNumberOfNodesInConnOf(se->getEntity(),se->getGeoType(),meshName); } const MEDFileStructureElement *MEDFileStructureElements::getSEWithName(const std::string& seName) const { - for(std::vector< MCAuto >::const_iterator it=_elems.begin();it!=_elems.end();it++) + for(const auto & _elem : _elems) { - if((*it).isNotNull()) - if((*it)->getName()==seName) - return *it; + if(_elem.isNotNull()) + if(_elem->getName()==seName) + return _elem; } std::ostringstream oss; oss << "MEDFileStructureElements::getSEWithName : no such structure element with name " << seName << " !"; throw INTERP_KERNEL::Exception(oss.str()); diff --git a/src/MEDLoader/MEDFileStructureElement.hxx b/src/MEDLoader/MEDFileStructureElement.hxx index 21a0dd5e1..542250950 100644 --- a/src/MEDLoader/MEDFileStructureElement.hxx +++ b/src/MEDLoader/MEDFileStructureElement.hxx @@ -21,11 +21,19 @@ #ifndef __MEDFILESTRUCTUREELEMENT_HXX__ #define __MEDFILESTRUCTUREELEMENT_HXX__ +#include "MEDFileUtilities.hxx" +#include "MCAuto.hxx" +#include "MEDCouplingMemArray.hxx" +#include "MCType.hxx" #include "MEDLoaderDefines.hxx" -#include "MEDFileUtilities.txx" #include "MEDFileMesh.hxx" #include "MEDCouplingRefCountObject.hxx" +#include +#include +#include +#include "med.h" +#include "NormalizedGeometricTypes" namespace MEDCoupling { @@ -53,9 +61,9 @@ class MEDFileSEConstAtt : public RefCountObject, public MEDFileWritableStandAlon static MEDFileSEConstAtt *New(med_idt fid, MEDFileStructureElement *father, int idCstAtt, const MEDFileUMesh *mesh); public: std::string getClassName() const override { return std::string("MEDFileSEConstAtt"); } - std::vector getDirectChildrenWithNull() const; - std::size_t getHeapMemorySizeWithoutChildren() const; - void writeLL(med_idt fid) const; + std::vector getDirectChildrenWithNull() const override; + std::size_t getHeapMemorySizeWithoutChildren() const override; + void writeLL(med_idt fid) const override; void setProfile(const std::string& name); std::string getProfile() const; private: @@ -72,9 +80,9 @@ class MEDFileSEConstAtt : public RefCountObject, public MEDFileWritableStandAlon static MEDFileSEVarAtt *New(med_idt fid, MEDFileStructureElement *father, int idVarAtt); public: std::string getClassName() const override { return std::string("MEDFileSEVarAtt"); } - std::vector getDirectChildrenWithNull() const; - std::size_t getHeapMemorySizeWithoutChildren() const; - void writeLL(med_idt fid) const; + std::vector getDirectChildrenWithNull() const override; + std::size_t getHeapMemorySizeWithoutChildren() const override; + void writeLL(med_idt fid) const override; int getNbOfComponents() const { return _nb_compo; } MCAuto getGenerator() const { return _gen; } private: @@ -97,9 +105,9 @@ class MEDFileSEConstAtt : public RefCountObject, public MEDFileWritableStandAlon MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileStructureElement"); } MEDLOADER_EXPORT INTERP_KERNEL::NormalizedCellType getGeoType() const { return _geo_type; } public: - std::vector getDirectChildrenWithNull() const; - std::size_t getHeapMemorySizeWithoutChildren() const; - void writeLL(med_idt fid) const; + std::vector getDirectChildrenWithNull() const override; + std::size_t getHeapMemorySizeWithoutChildren() const override; + void writeLL(med_idt fid) const override; public: static MCAuto BuildFrom(med_attribute_type mat); static int EffectiveNbCompo(med_attribute_type mat, int nbCompo); @@ -132,13 +140,13 @@ class MEDFileSEConstAtt : public RefCountObject, public MEDFileWritableStandAlon MEDLOADER_EXPORT const MEDFileSEVarAtt *getVarAttOf(const std::string &seName, const std::string& varName) const; MEDLOADER_EXPORT const MEDFileUMesh *getSupMeshWithName(const std::string& name) const; public: - std::vector getDirectChildrenWithNull() const; - std::size_t getHeapMemorySizeWithoutChildren() const; - void writeLL(med_idt fid) const; + std::vector getDirectChildrenWithNull() const override; + std::size_t getHeapMemorySizeWithoutChildren() const override; + void writeLL(med_idt fid) const override; private: MEDFileStructureElements(med_idt fid, const MEDFileMeshSupports *ms); MEDFileStructureElements(); - ~MEDFileStructureElements(); + ~MEDFileStructureElements() override; private: std::vector< MCAuto > _elems; MCConstAuto _sup; diff --git a/src/MEDLoader/MEDFileUtilities.cxx b/src/MEDLoader/MEDFileUtilities.cxx index 2f8beeeae..dbe10697d 100644 --- a/src/MEDLoader/MEDFileUtilities.cxx +++ b/src/MEDLoader/MEDFileUtilities.cxx @@ -19,15 +19,19 @@ // Author : Anthony Geay (CEA/DEN) #include "MEDFileUtilities.hxx" +#include "MCAuto.hxx" +#include "MEDCouplingMemArray.hxx" +#include "MEDCouplingRefCountObject.hxx" #include "MEDFileSafeCaller.txx" #include "MEDLoaderBase.hxx" #include "MEDLoader.hxx" -#include "MEDFileBasis.hxx" #include "InterpKernelAutoPtr.hxx" +#include "med.h" +#include "medfile.h" #include -#include +#include const char MEDCoupling::MEDFileWritableStandAlone::DFT_FILENAME_IN_MEM[]="DftFileNameInMemory"; @@ -67,7 +71,7 @@ const char *MEDFileUtilities::GetReadableMEDFieldType(med_field_type ft) } } -void MEDFileUtilities::CheckMEDCode(int code, med_idt fid, const std::string& msg) +void MEDFileUtilities::CheckMEDCode(int code, med_idt /*fid*/, const std::string& msg) { if(code<0) { @@ -79,7 +83,7 @@ void MEDFileUtilities::CheckMEDCode(int code, med_idt fid, const std::string& ms void MEDFileUtilities::CheckFileForRead(const std::string& fileName) { - int status=MEDLoaderBase::getStatusOfFile(fileName); + int const status=MEDLoaderBase::getStatusOfFile(fileName); std::ostringstream oss; oss << " File : \"" << fileName << "\""; switch(status) @@ -100,7 +104,7 @@ void MEDFileUtilities::CheckFileForRead(const std::string& fileName) throw INTERP_KERNEL::Exception(oss.str().c_str()); } } - AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY); + AutoFid const fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY); if(fid<0) { oss << " has been detected as unreadable by MED file : impossible to read anything !"; @@ -159,7 +163,7 @@ void MEDCoupling::MEDFileWritable::setZipConnPolicy(int newVal) std::string MEDCoupling::MEDFileWritable::FileNameFromFID(med_idt fid) { - med_int lgth(MEDfileName(fid,0,0)); + med_int const lgth(MEDfileName(fid,nullptr,0)); if(lgth<=0) return std::string(); INTERP_KERNEL::AutoPtr tmp(new char[lgth+1]); @@ -186,8 +190,8 @@ MEDFileUtilities::AutoFid MEDCoupling::OpenMEDFileForRead(const std::string& fil */ void MEDCoupling::MEDFileWritableStandAlone::write(const std::string& fileName, int mode) const { - med_access_mode medmod(MEDFileUtilities::TraduceWriteMode(mode)); - MEDFileUtilities::AutoFid fid(MEDfileOpen(fileName.c_str(),medmod)); + med_access_mode const medmod(MEDFileUtilities::TraduceWriteMode(mode)); + MEDFileUtilities::AutoFid const fid(MEDfileOpen(fileName.c_str(),medmod)); std::ostringstream oss; oss << "MEDFileWritableStandAlone : error on attempt to write in file : \"" << fileName << "\""; MEDFileUtilities::CheckMEDCode((int)fid,fid,oss.str()); writeLL(fid); @@ -211,8 +215,8 @@ void MEDCoupling::MEDFileWritableStandAlone::write40(const std::string& fileName void MEDCoupling::MEDFileWritableStandAlone::writeXX(const std::string& fileName, int mode, med_int maj, med_int min, med_int rel) const { #if ( MED_NUM_MAJEUR>4 || ( MED_NUM_MAJEUR==4 && MED_NUM_MINEUR>=1 ) ) - med_access_mode medmod(MEDFileUtilities::TraduceWriteMode(mode)); - MEDFileUtilities::AutoFid fid(MEDfileVersionOpen(fileName.c_str(),medmod,maj,min,rel)); + med_access_mode const medmod(MEDFileUtilities::TraduceWriteMode(mode)); + MEDFileUtilities::AutoFid const fid(MEDfileVersionOpen(fileName.c_str(),medmod,maj,min,rel)); writeLL(fid); #else std::ostringstream oss; oss << "MEDFileWritableStandAlone::write" << maj << min << " : the MED version used to compile medcoupling is " << MEDFileVersionStr() << " ! If you need this feature please use version >= 4.1."; @@ -223,12 +227,12 @@ void MEDCoupling::MEDFileWritableStandAlone::writeXX(const std::string& fileName MEDCoupling::MCAuto MEDCoupling::MEDFileWritableStandAlone::serialize() const { med_memfile memfile=MED_MEMFILE_INIT; - memfile.app_image_ptr=0; + memfile.app_image_ptr=nullptr; memfile.app_image_size=0; // - std::string dftFileName(GenerateUniqueDftFileNameInMem()); + std::string const dftFileName(GenerateUniqueDftFileNameInMem()); {// very important to let this braces ! The AutoFid destructor must be called, to have a "clean" memfile.app_image_ptr pointer embedded in the returned object. - MEDFileUtilities::AutoFid fid(MEDmemFileOpen(dftFileName.c_str(),&memfile,MED_FALSE,MED_ACC_CREAT)); + MEDFileUtilities::AutoFid const fid(MEDmemFileOpen(dftFileName.c_str(),&memfile,MED_FALSE,MED_ACC_CREAT)); writeLL(fid); } // diff --git a/src/MEDLoader/MEDFileUtilities.hxx b/src/MEDLoader/MEDFileUtilities.hxx index bb0568e25..e2cdb0892 100644 --- a/src/MEDLoader/MEDFileUtilities.hxx +++ b/src/MEDLoader/MEDFileUtilities.hxx @@ -21,13 +21,13 @@ #ifndef __MEDFILEUTILITIES_HXX__ #define __MEDFILEUTILITIES_HXX__ -#include "InterpKernelException.hxx" #include "MEDLoaderDefines.hxx" #include "MCAuto.hxx" #include "MEDCouplingMemArray.hxx" #include "med.h" +#include namespace MEDFileUtilities { @@ -53,7 +53,7 @@ namespace MEDCoupling { public: MEDFileWritable(); - virtual ~MEDFileWritable() {} + virtual ~MEDFileWritable() = default; void copyOptionsFrom(const MEDFileWritable& other) const; int getTooLongStrPolicy() const; void setTooLongStrPolicy(int newVal); diff --git a/src/MEDLoader/MEDFileUtilities.txx b/src/MEDLoader/MEDFileUtilities.txx index 772b4fc44..c1b7e6e5c 100644 --- a/src/MEDLoader/MEDFileUtilities.txx +++ b/src/MEDLoader/MEDFileUtilities.txx @@ -21,7 +21,11 @@ #ifndef __MEDFILEUTILITIES_TXX__ #define __MEDFILEUTILITIES_TXX__ +#include "MEDCouplingMemArray.hxx" #include "MEDFileUtilities.hxx" +#include "med.h" +#include +#include "medfile.h" template T *MEDCoupling::MEDFileWritableStandAlone::BuildFromMemoryChunk(MEDCoupling::DataArrayByte *db) @@ -32,7 +36,7 @@ T *MEDCoupling::MEDFileWritableStandAlone::BuildFromMemoryChunk(MEDCoupling::Dat med_memfile memfile=MED_MEMFILE_INIT; memfile.app_image_ptr=db->getPointer(); memfile.app_image_size=db->getNbOfElems(); - std::string dftFileName(MEDCoupling::MEDFileWritableStandAlone::GenerateUniqueDftFileNameInMem()); + std::string const dftFileName(MEDCoupling::MEDFileWritableStandAlone::GenerateUniqueDftFileNameInMem()); MEDFileUtilities::AutoFid fid(MEDmemFileOpen(dftFileName.c_str(),&memfile,MED_FALSE,MED_ACC_RDWR)); return T::New(fid); } diff --git a/src/MEDLoader/MEDFilterEntity.hxx b/src/MEDLoader/MEDFilterEntity.hxx index 3f0d05551..898b15f24 100644 --- a/src/MEDLoader/MEDFilterEntity.hxx +++ b/src/MEDLoader/MEDFilterEntity.hxx @@ -21,9 +21,17 @@ #ifndef __MEDFILTERENTITY_HXX__ #define __MEDFILTERENTITY_HXX__ +#include "MCType.hxx" +#include "MCAuto.hxx" #include "MEDCouplingPartDefinition.hxx" +#include "InterpKernelException.hxx" +#include "MEDFileBasis.hxx" #include "med.h" +#include "medfilter.h" +#include +#include #include +#include namespace MEDCoupling { @@ -66,12 +74,12 @@ namespace MEDCoupling const med_int constituentSelect, const med_switch_mode switchMode, const med_storage_mode storageMode, const char * const profileName, const PartDefinition* pd) { - const SlicePartDefinition *spd(dynamic_cast(pd)); + const auto *spd(dynamic_cast(pd)); if(spd) { //Here, pd contains a slice, so it's more efficient to define a filter of block //(which will load contiguous values) - mcIdType nbOfEltsToLoad = spd->getNumberOfElems(); + mcIdType const nbOfEltsToLoad = spd->getNumberOfElems(); mcIdType strt,end,step; spd->getSlice(strt,end,step); if(strt<0) @@ -84,10 +92,10 @@ namespace MEDCoupling /*lastblocksize=useless because count=1*/0,_filter.get()); return; } - const DataArrayPartDefinition *dpd(dynamic_cast(pd)); + const auto *dpd(dynamic_cast(pd)); if(dpd) { - mcIdType nbOfEltsToLoad = dpd->getNumberOfElems(); + mcIdType const nbOfEltsToLoad = dpd->getNumberOfElems(); //convert to fortran indexing std::vector dpdPlus1; diff --git a/src/MEDLoader/MEDLoader.cxx b/src/MEDLoader/MEDLoader.cxx index 214b19740..91a0de39b 100644 --- a/src/MEDLoader/MEDLoader.cxx +++ b/src/MEDLoader/MEDLoader.cxx @@ -19,6 +19,14 @@ // Author : Anthony Geay (CEA/DEN) #include "MEDLoader.hxx" +#include "MCIdType.hxx" +#include "MCType.hxx" +#include "MEDFileBasis.hxx" +#include "MEDFileFieldMultiTS.hxx" +#include "MEDFileField1TS.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include "MEDCouplingCMesh.hxx" +#include "MEDCouplingCurveLinearMesh.hxx" #include "MEDLoaderBase.hxx" #include "MEDFileUtilities.hxx" #include "MEDLoaderNS.hxx" @@ -38,17 +46,27 @@ #include "InterpKernelAutoPtr.hxx" +#include "NormalizedGeometricTypes" +#include "MEDLoaderTraits.hxx" #include "med.h" +#include "medmesh.h" +#include "medlibrary.h" +#include "medfile.h" +#include "medfield.h" +#include "medfamily.h" +#include +#include +#include +#include +#include #include #include #include #include -#include -#include -#include #include -#include +#include +#include extern med_geometry_type typmai[MED_N_CELL_FIXED_GEO]; extern med_geometry_type typmainoeud[1]; @@ -175,7 +193,7 @@ INTERP_KERNEL::NormalizedCellType ConvertGeometryType(med_geometry_type geotype) int MEDLoaderNS::readUMeshDimFromFile(const std::string& fileName, const std::string& meshName, std::vector& possibilities) { possibilities.clear(); - MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName)); + MEDFileUtilities::AutoFid const fid(MEDCoupling::OpenMEDFileForRead(fileName)); int ret; std::set poss; char nommaa[MED_NAME_SIZE+1]; @@ -183,12 +201,12 @@ int MEDLoaderNS::readUMeshDimFromFile(const std::string& fileName, const std::st med_mesh_type type_maillage; med_int Sdim,Mdim; std::string trueMeshName; - int meshId=FromMedInt(getIdFromMeshName(fid,meshName,trueMeshName)); + int const meshId=FromMedInt(getIdFromMeshName(fid,meshName,trueMeshName)); INTERP_KERNEL::AutoPtr dt_unit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE); med_sorting_type sortingType; med_int nstep; med_axis_type axisType; - med_int naxis(MEDmeshnAxis(fid,meshId)); + med_int const naxis(MEDmeshnAxis(fid,meshId)); INTERP_KERNEL::AutoPtr axisname=MEDLoaderBase::buildEmptyString(naxis*MED_SNAME_SIZE); INTERP_KERNEL::AutoPtr axisunit=MEDLoaderBase::buildEmptyString(naxis*MED_SNAME_SIZE); MEDFILESAFECALLERRD0(MEDmeshInfo,(fid,meshId,nommaa,&Sdim,&Mdim,&type_maillage,maillage_description,dt_unit,&sortingType,&nstep,&axisType,axisname,axisunit)); @@ -203,24 +221,24 @@ int MEDLoaderNS::readUMeshDimFromFile(const std::string& fileName, const std::st // endlimitation for(int i=0;i0) { - INTERP_KERNEL::NormalizedCellType type=typmai2[i]; - int curDim=(int)INTERP_KERNEL::CellModel::GetCellModel(type).getDimension(); + INTERP_KERNEL::NormalizedCellType const type=typmai2[i]; + int const curDim=(int)INTERP_KERNEL::CellModel::GetCellModel(type).getDimension(); poss.insert(curDim); } } if(!poss.empty()) { ret=*poss.rbegin(); - for(std::set::const_reverse_iterator it=poss.rbegin();it!=poss.rend();it++) + for(auto it=poss.rbegin();it!=poss.rend();it++) possibilities.push_back(*it-ret); } else @@ -238,11 +256,11 @@ int MEDLoaderNS::getIdFromMeshName(med_idt fid, const std::string& meshName, std trueMeshName=meshes[0]; return 1; } - std::string meshNameStr(meshName); + std::string const meshNameStr(meshName); std::vector meshes=getMeshNamesFid(fid); if(meshes.empty()) throw INTERP_KERNEL::Exception("No mesh in file"); - std::vector::iterator iter=std::find(meshes.begin(),meshes.end(),meshNameStr); + auto const iter=std::find(meshes.begin(),meshes.end(),meshNameStr); if(iter==meshes.end()) { std::ostringstream os2; @@ -264,16 +282,16 @@ std::vector MEDLoaderNS::getMeshNamesFid(med_idt fid) char nommaa[MED_NAME_SIZE+1]; med_axis_type axistype; med_sorting_type stype; - med_int n=MEDnMesh(fid); + med_int const n=MEDnMesh(fid); std::vector ret(n); for(int i=0;i axisname=MEDLoaderBase::buildEmptyString(naxis*MED_SNAME_SIZE); INTERP_KERNEL::AutoPtr axisunit=MEDLoaderBase::buildEmptyString(naxis*MED_SNAME_SIZE); med_int nstep; MEDFILESAFECALLERRD0(MEDmeshInfo,(fid,i+1,nommaa,&space_dim,&mesh_dim,&type_maillage,maillage_description,dtunit,&stype,&nstep,&axistype,axisname,axisunit)); - std::string cur=MEDLoaderBase::buildStringFromFortran(nommaa,sizeof(nommaa)); + std::string const cur=MEDLoaderBase::buildStringFromFortran(nommaa,sizeof(nommaa)); ret[i]=cur; } return ret; @@ -318,11 +336,11 @@ std::string MEDCoupling::MEDFileVersionStr() char buf[SZ]; std::fill(buf,buf+SZ,'\0'); const char START_EXPECTED[]="MED-"; - med_err ret(MEDlibraryStrVersion(buf)); + med_err const ret(MEDlibraryStrVersion(buf)); if(ret!=0) throw INTERP_KERNEL::Exception("MEDFileVersionStr : fail to find version of MED file ! It looks very bad !"); - std::string zeRet(buf); - std::size_t pos(zeRet.find(START_EXPECTED,0)); + std::string const zeRet(buf); + std::size_t const pos(zeRet.find(START_EXPECTED,0)); if(pos!=0) { std::ostringstream oss; oss << "MEDFileVersionStr : internal error ! The MEDFile returned version (\"" << zeRet << "\") has not the right pattern !"; @@ -334,14 +352,14 @@ std::string MEDCoupling::MEDFileVersionStr() std::string MEDCoupling::MEDFileVersionOfFileStr(const std::string& fileName) { #if MED_NUM_MAJEUR>3 || ( MED_NUM_MAJEUR==3 && ( (MED_NUM_MINEUR==2 && MED_NUM_RELEASE>=1) || MED_NUM_MINEUR>=3) ) - MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName)); + MEDFileUtilities::AutoFid const fid(MEDCoupling::OpenMEDFileForRead(fileName)); const int SZ=20; const char START_EXPECTED[]="MED-"; char buf[SZ]; std::fill(buf,buf+SZ,'\0'); MEDFILESAFECALLERRD0(MEDfileStrVersionRd,(fid,buf)); - std::string ret(buf); - std::size_t pos(ret.find(START_EXPECTED,0)); + std::string const ret(buf); + std::size_t const pos(ret.find(START_EXPECTED,0)); if(pos!=0) { std::ostringstream oss; oss << "MEDFileVersionOfFileStr : internal error ! The MEDFile returned version (\"" << ret << "\") has not the right pattern !"; @@ -357,7 +375,7 @@ std::string MEDCoupling::MEDFileVersionOfFileStr(const std::string& fileName) void MEDCoupling::MEDFileVersion(int& major, int& minor, int& release) { med_int majj,minn,rell; - med_err ret(MEDlibraryNumVersion(&majj,&minn,&rell)); + med_err const ret(MEDlibraryNumVersion(&majj,&minn,&rell)); if(ret!=0) throw INTERP_KERNEL::Exception("MEDFileVersion : fail to call MEDlibraryNumVersion ! It looks very bad !"); major=FromMedInt(majj); @@ -400,18 +418,18 @@ void MEDCoupling::SetTooLongStrPolicy(int val) */ std::vector< std::vector< std::pair > > MEDCoupling::GetUMeshGlobalInfo(const std::string& fileName, const std::string& meshName, int &meshDim, int& spaceDim, mcIdType& numberOfNodes) { - MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName)); - std::set poss; + MEDFileUtilities::AutoFid const fid(MEDCoupling::OpenMEDFileForRead(fileName)); + std::set const poss; char nommaa[MED_NAME_SIZE+1]; char maillage_description[MED_COMMENT_SIZE+1]; med_mesh_type type_maillage; std::string trueMeshName; - int meshId=MEDLoaderNS::getIdFromMeshName(fid,meshName,trueMeshName); + int const meshId=MEDLoaderNS::getIdFromMeshName(fid,meshName,trueMeshName); INTERP_KERNEL::AutoPtr dt_unit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE); med_sorting_type sortingType; med_int nstep, mDim, sDim; med_axis_type axisType; - med_int naxis(MEDmeshnAxis(fid,meshId)); + med_int const naxis(MEDmeshnAxis(fid,meshId)); INTERP_KERNEL::AutoPtr axisname=MEDLoaderBase::buildEmptyString(naxis*MED_SNAME_SIZE); INTERP_KERNEL::AutoPtr axisunit=MEDLoaderBase::buildEmptyString(naxis*MED_SNAME_SIZE); MEDFILESAFECALLERRD0(MEDmeshInfo,(fid,meshId,nommaa,&sDim,&mDim,&type_maillage,maillage_description,dt_unit,&sortingType,&nstep,&axisType,axisname,axisunit)); @@ -435,19 +453,19 @@ std::vector< std::vector< std::pair > > M med_bool changement,transformation; for(int i=0;i0) { - INTERP_KERNEL::NormalizedCellType typp=typmai2[i]; - int mdimCell=INTERP_KERNEL::CellModel::GetCellModel(typp).getDimension(); + INTERP_KERNEL::NormalizedCellType const typp=typmai2[i]; + int const mdimCell=INTERP_KERNEL::CellModel::GetCellModel(typp).getDimension(); dims.push_back(mdimCell); geoTypes.push_back(std::pair(typp,curNbOfElemM)); } } - int maxLev=*std::max_element(dims.begin(),dims.end()); - int lowLev=*std::min_element(dims.begin(),dims.end()); - int nbOfLevels=maxLev-lowLev+1; + int const maxLev=*std::max_element(dims.begin(),dims.end()); + int const lowLev=*std::min_element(dims.begin(),dims.end()); + int const nbOfLevels=maxLev-lowLev+1; std::vector< std::vector< std::pair > > ret(nbOfLevels); for(std::size_t i=0;i MEDCoupling::GetMeshNames(const std::string& fileName) { - MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName)); + MEDFileUtilities::AutoFid const fid(MEDCoupling::OpenMEDFileForRead(fileName)); return MEDLoaderNS::getMeshNamesFid(fid); } std::vector< std::pair > MEDCoupling::GetComponentsNamesOfField(const std::string& fileName, const std::string& fieldName) { - MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName)); - med_int nbFields(MEDnField(fid)); + MEDFileUtilities::AutoFid const fid(MEDCoupling::OpenMEDFileForRead(fileName)); + med_int const nbFields(MEDnField(fid)); std::vector fields(nbFields); med_field_type typcha; for(int i=0;i comp=new char[ncomp*MED_SNAME_SIZE+1]; INTERP_KERNEL::AutoPtr unit=new char[ncomp*MED_SNAME_SIZE+1]; INTERP_KERNEL::AutoPtr dt_unit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE); @@ -485,8 +503,8 @@ std::vector< std::pair > MEDCoupling::GetComponentsName INTERP_KERNEL::AutoPtr maa_ass=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); INTERP_KERNEL::AutoPtr nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,i+1,nomcha,maa_ass,&localmesh,&typcha,comp,unit,dt_unit,&nbPdt)); - std::string meshName=MEDLoaderBase::buildStringFromFortran(maa_ass,MED_NAME_SIZE); - std::string curFieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE+1); + std::string const meshName=MEDLoaderBase::buildStringFromFortran(maa_ass,MED_NAME_SIZE); + std::string const curFieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE+1); if(curFieldName==fieldName) { std::vector< std::pair > ret(ncomp); @@ -518,15 +536,15 @@ public: void MEDCoupling::GetFamiliesGroupsInfo(const std::string& fileName, const std::string& meshName, std::map& families, std::map>& groupsOnFam) { - MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName)); - med_int nbFams(MEDnFamily(fid,meshName.c_str())); + MEDFileUtilities::AutoFid const fid(MEDCoupling::OpenMEDFileForRead(fileName)); + med_int const nbFams(MEDnFamily(fid,meshName.c_str())); char nomfam[MED_NAME_SIZE+1]; for(med_int i=0;i(i+1))),famId; - std::unique_ptr gro{new char[MED_LNAME_SIZE*nbGrps+1]}; + std::unique_ptr const gro{new char[MED_LNAME_SIZE*nbGrps+1]}; MEDFILESAFECALLERRD0(MEDfamilyInfo,(fid,meshName.c_str(),FromMedInt(i+1),nomfam,&famId,gro.get())); - std::string fam(MEDLoaderBase::buildStringFromFortran(nomfam,MED_NAME_SIZE)); + std::string const fam(MEDLoaderBase::buildStringFromFortran(nomfam,MED_NAME_SIZE)); families[fam] = FromMedInt(famId); std::vector v(nbGrps); std::copy(MEDVectorStringIterator(0,gro.get()),MEDVectorStringIterator(nbGrps,gro.get()),v.begin()); @@ -538,8 +556,8 @@ std::vector MEDCoupling::GetMeshNamesOnField(const std::string& fil { std::vector ret; // - MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName)); - med_int nbFields=MEDnField(fid); + MEDFileUtilities::AutoFid const fid(MEDCoupling::OpenMEDFileForRead(fileName)); + med_int const nbFields=MEDnField(fid); // med_field_type typcha; INTERP_KERNEL::AutoPtr dt_unit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE); @@ -548,14 +566,14 @@ std::vector MEDCoupling::GetMeshNamesOnField(const std::string& fil // for(int i=0;i comp=new char[ncomp*MED_SNAME_SIZE+1]; INTERP_KERNEL::AutoPtr unit=new char[ncomp*MED_SNAME_SIZE+1]; med_int nbPdt; INTERP_KERNEL::AutoPtr maa_ass=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,i+1,nomcha,maa_ass,&localmesh,&typcha,comp,unit,dt_unit,&nbPdt)); - std::string meshName=MEDLoaderBase::buildStringFromFortran(maa_ass,MED_NAME_SIZE); - std::string curFieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE+1); + std::string const meshName=MEDLoaderBase::buildStringFromFortran(maa_ass,MED_NAME_SIZE); + std::string const curFieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE+1); if(curFieldName==fieldName) ret.push_back(meshName); } @@ -564,21 +582,21 @@ std::vector MEDCoupling::GetMeshNamesOnField(const std::string& fil std::vector MEDCoupling::GetMeshFamiliesNames(const std::string& fileName, const std::string& meshName) { - MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName)); - med_int nfam=MEDnFamily(fid,meshName.c_str()); + MEDFileUtilities::AutoFid const fid(MEDCoupling::OpenMEDFileForRead(fileName)); + med_int const nfam=MEDnFamily(fid,meshName.c_str()); std::vector ret(nfam); char nomfam[MED_NAME_SIZE+1]; med_int numfam; for(int i=0;i attide=new med_int[natt]; INTERP_KERNEL::AutoPtr attval=new med_int[natt]; INTERP_KERNEL::AutoPtr attdes=new char[MED_COMMENT_SIZE*natt+1]; INTERP_KERNEL::AutoPtr gro=new char[MED_LNAME_SIZE*ngro+1]; MEDfamily23Info(fid,meshName.c_str(),i+1,nomfam,attide,attval,attdes,&numfam,gro); - std::string cur=MEDLoaderBase::buildStringFromFortran(nomfam,sizeof(nomfam)); + std::string const cur=MEDLoaderBase::buildStringFromFortran(nomfam,sizeof(nomfam)); ret[i]=cur; } return ret; @@ -587,24 +605,24 @@ std::vector MEDCoupling::GetMeshFamiliesNames(const std::string& fi std::vector MEDCoupling::GetMeshFamiliesNamesOnGroup(const std::string& fileName, const std::string& meshName, const std::string& grpName) { - MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName)); - med_int nfam=MEDnFamily(fid,meshName.c_str()); + MEDFileUtilities::AutoFid const fid(MEDCoupling::OpenMEDFileForRead(fileName)); + med_int const nfam=MEDnFamily(fid,meshName.c_str()); std::vector ret; char nomfam[MED_NAME_SIZE+1]; med_int numfam; for(int i=0;i attide=new med_int[natt]; INTERP_KERNEL::AutoPtr attval=new med_int[natt]; INTERP_KERNEL::AutoPtr attdes=new char[MED_COMMENT_SIZE*natt+1]; INTERP_KERNEL::AutoPtr gro=new char[MED_LNAME_SIZE*ngro+1]; MEDfamily23Info(fid,meshName.c_str(),i+1,nomfam,attide,attval,attdes,&numfam,gro); - std::string cur=MEDLoaderBase::buildStringFromFortran(nomfam,sizeof(nomfam)); + std::string const cur=MEDLoaderBase::buildStringFromFortran(nomfam,sizeof(nomfam)); for(int j=0;j MEDCoupling::GetMeshFamiliesNamesOnGroup(const std::str std::vector MEDCoupling::GetMeshGroupsNamesOnFamily(const std::string& fileName, const std::string& meshName, const std::string& famName) { - MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName)); - med_int nfam(MEDnFamily(fid,meshName.c_str())); + MEDFileUtilities::AutoFid const fid(MEDCoupling::OpenMEDFileForRead(fileName)); + med_int const nfam(MEDnFamily(fid,meshName.c_str())); std::vector ret; char nomfam[MED_NAME_SIZE+1]; med_int numfam; bool found=false; for(int i=0;i attide=new med_int[natt]; INTERP_KERNEL::AutoPtr attval=new med_int[natt]; INTERP_KERNEL::AutoPtr attdes=new char[MED_COMMENT_SIZE*natt+1]; INTERP_KERNEL::AutoPtr gro=new char[MED_LNAME_SIZE*ngro+1]; MEDfamily23Info(fid,meshName.c_str(),i+1,nomfam,attide,attval,attdes,&numfam,gro); - std::string cur=MEDLoaderBase::buildStringFromFortran(nomfam,sizeof(nomfam)); + std::string const cur=MEDLoaderBase::buildStringFromFortran(nomfam,sizeof(nomfam)); found=(cur==famName); if(found) for(int j=0;j MEDCoupling::GetMeshGroupsNamesOnFamily(const std::stri std::vector MEDCoupling::GetMeshGroupsNames(const std::string& fileName, const std::string& meshName) { - MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName)); - med_int nfam=MEDnFamily(fid,meshName.c_str()); + MEDFileUtilities::AutoFid const fid(MEDCoupling::OpenMEDFileForRead(fileName)); + med_int const nfam=MEDnFamily(fid,meshName.c_str()); std::vector ret; char nomfam[MED_NAME_SIZE+1]; med_int numfam; for(int i=0;i attide=new med_int[natt]; INTERP_KERNEL::AutoPtr attval=new med_int[natt]; INTERP_KERNEL::AutoPtr attdes=new char[MED_COMMENT_SIZE*natt+1]; @@ -666,7 +684,7 @@ std::vector MEDCoupling::GetMeshGroupsNames(const std::string& file MEDfamily23Info(fid,meshName.c_str(),i+1,nomfam,attide,attval,attdes,&numfam,gro); for(int j=0;j MEDCoupling::GetTypesOfField(const std::st oss << " The name of the mesh in file is \"" << fs->getMeshName() << "\"!"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - int nbTS(fs->getNumberOfTS()); + int const nbTS(fs->getNumberOfTS()); if(nbTS==0) return ret; for(int i=0;i f1ts(fs->getTimeStepAtPos(i)); - std::vector tof(f1ts->getTypesOfFieldAvailable()); - for(std::vector::const_iterator it=tof.begin();it!=tof.end();it++) - if(std::find(ret.begin(),ret.end(),*it)==ret.end()) - ret.push_back(*it); + std::vector const tof(f1ts->getTypesOfFieldAvailable()); + for(auto it : tof) + if(std::find(ret.begin(),ret.end(),it)==ret.end()) + ret.push_back(it); } // sort ret to put before ON_NODES then ON_CELLS then the remaining. std::vector ret2; @@ -701,21 +719,21 @@ std::vector MEDCoupling::GetTypesOfField(const std::st ret2.push_back(ON_NODES); if(std::find(ret.begin(),ret.end(),ON_CELLS)!=ret.end()) ret2.push_back(ON_CELLS); - for(std::vector::const_iterator it=ret.begin();it!=ret.end();it++) - if(*it!=ON_NODES && *it!=ON_CELLS) - ret2.push_back(*it); + for(auto it : ret) + if(it!=ON_NODES && it!=ON_CELLS) + ret2.push_back(it); return ret2; } std::vector MEDCoupling::GetAllFieldNames(const std::string& fileName) { std::vector ret; - MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName)); - med_int nbFields=MEDnField(fid); + MEDFileUtilities::AutoFid const fid(MEDCoupling::OpenMEDFileForRead(fileName)); + med_int const nbFields=MEDnField(fid); med_field_type typcha; for(int i=0;i comp=new char[ncomp*MED_SNAME_SIZE+1]; INTERP_KERNEL::AutoPtr unit=new char[ncomp*MED_SNAME_SIZE+1]; INTERP_KERNEL::AutoPtr nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); @@ -732,8 +750,8 @@ std::vector MEDCoupling::GetAllFieldNames(const std::string& fileNa std::vector MEDCoupling::GetAllFieldNamesOnMesh(const std::string& fileName, const std::string& meshName) { std::vector ret; - MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName)); - med_int nbFields=MEDnField(fid); + MEDFileUtilities::AutoFid const fid(MEDCoupling::OpenMEDFileForRead(fileName)); + med_int const nbFields=MEDnField(fid); // med_field_type typcha; char *maa_ass=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); @@ -741,15 +759,15 @@ std::vector MEDCoupling::GetAllFieldNamesOnMesh(const std::string& // for(int i=0;i comp=new char[ncomp*MED_SNAME_SIZE+1]; INTERP_KERNEL::AutoPtr unit=new char[ncomp*MED_SNAME_SIZE+1]; INTERP_KERNEL::AutoPtr dt_unit=new char[MED_LNAME_SIZE+1]; med_int nbPdt; med_bool localmesh; MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,i+1,nomcha,maa_ass,&localmesh,&typcha,comp,unit,dt_unit,&nbPdt)); - std::string curFieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE+1); - std::string curMeshName=MEDLoaderBase::buildStringFromFortran(maa_ass,MED_NAME_SIZE+1); + std::string const curFieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE+1); + std::string const curMeshName=MEDLoaderBase::buildStringFromFortran(maa_ass,MED_NAME_SIZE+1); // if(curMeshName==meshName) ret.push_back(curFieldName); @@ -776,8 +794,8 @@ std::vector MEDCoupling::GetFieldNamesOnMesh(MEDCoupling::TypeOfFie std::vector MEDCoupling::GetCellFieldNamesOnMesh(const std::string& fileName, const std::string& meshName) { std::vector ret; - MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName)); - med_int nbFields=MEDnField(fid); + MEDFileUtilities::AutoFid const fid(MEDCoupling::OpenMEDFileForRead(fileName)); + med_int const nbFields=MEDnField(fid); // med_field_type typcha; //med_int nbpdtnor=0,pflsize,*pflval,lnsize; @@ -793,12 +811,12 @@ std::vector MEDCoupling::GetCellFieldNamesOnMesh(const std::string& // for(int i=0;i comp=new char[ncomp*MED_SNAME_SIZE+1]; INTERP_KERNEL::AutoPtr unit=new char[ncomp*MED_SNAME_SIZE+1]; MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,i+1,nomcha,maa_ass,&localmesh,&typcha,comp,unit,dt_unit,&nbPdt)); - std::string curFieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE+1); - std::string curMeshName=MEDLoaderBase::buildStringFromFortran(maa_ass,MED_NAME_SIZE+1); + std::string const curFieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE+1); + std::string const curMeshName=MEDLoaderBase::buildStringFromFortran(maa_ass,MED_NAME_SIZE+1); med_int profilesize,nbi; if(curMeshName==meshName) { @@ -808,7 +826,7 @@ std::vector MEDCoupling::GetCellFieldNamesOnMesh(const std::string& if(nbPdt>0) { MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,nomcha,1,&numdt,&numo,&dt)); - med_int nbOfVal(MEDfieldnValueWithProfile(fid,nomcha,numdt,numo,MED_CELL,typmai[j],1,MED_COMPACT_PFLMODE, + med_int const nbOfVal(MEDfieldnValueWithProfile(fid,nomcha,numdt,numo,MED_CELL,typmai[j],1,MED_COMPACT_PFLMODE, pflname,&profilesize,locname,&nbi)); if(nbOfVal>0) { @@ -825,8 +843,8 @@ std::vector MEDCoupling::GetCellFieldNamesOnMesh(const std::string& std::vector MEDCoupling::GetNodeFieldNamesOnMesh(const std::string& fileName, const std::string& meshName) { std::vector ret; - MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName)); - med_int nbFields=MEDnField(fid); + MEDFileUtilities::AutoFid const fid(MEDCoupling::OpenMEDFileForRead(fileName)); + med_int const nbFields=MEDnField(fid); char pflname[MED_NAME_SIZE+1]=""; char locname[MED_NAME_SIZE+1]=""; // @@ -840,18 +858,18 @@ std::vector MEDCoupling::GetNodeFieldNamesOnMesh(const std::string& // for(int i=0;i comp=new char[ncomp*MED_SNAME_SIZE+1]; INTERP_KERNEL::AutoPtr unit=new char[ncomp*MED_SNAME_SIZE+1]; med_int nbPdt; MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,i+1,nomcha,maa_ass,&localmesh,&typcha,comp,unit,dt_unit,&nbPdt)); - std::string curFieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE+1); - std::string curMeshName=MEDLoaderBase::buildStringFromFortran(maa_ass,MED_NAME_SIZE+1); + std::string const curFieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE+1); + std::string const curMeshName=MEDLoaderBase::buildStringFromFortran(maa_ass,MED_NAME_SIZE+1); if(nbPdt>0) { med_int profilesize,nbi; MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,nomcha,1,&numdt,&numo,&dt)); - med_int nbOfVal(MEDfieldnValueWithProfile(fid,nomcha,numdt,numo,MED_NODE,MED_NONE,1,MED_COMPACT_PFLMODE, + med_int const nbOfVal(MEDfieldnValueWithProfile(fid,nomcha,numdt,numo,MED_NODE,MED_NONE,1,MED_COMPACT_PFLMODE, pflname,&profilesize,locname,&nbi)); if(curMeshName==meshName && nbOfVal>0) { @@ -865,8 +883,8 @@ std::vector MEDCoupling::GetNodeFieldNamesOnMesh(const std::string& std::vector< std::pair< std::pair, double> > MEDCoupling::GetAllFieldIterations(const std::string& fileName, const std::string& fieldName) { std::vector< std::pair< std::pair, double > > ret; - MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName)); - med_int nbFields=MEDnField(fid); + MEDFileUtilities::AutoFid const fid(MEDCoupling::OpenMEDFileForRead(fileName)); + med_int const nbFields=MEDnField(fid); // med_field_type typcha; med_int numdt=0,numo=0; @@ -879,12 +897,12 @@ std::vector< std::pair< std::pair, double> > MEDCoupling::GetAllFieldIt std::ostringstream oss; oss << "GetAllFieldIterations : No field with name \"" << fieldName<< "\" in file \"" << fileName << "\" ! Possible fields are : "; for(int i=0;i comp=new char[ncomp*MED_SNAME_SIZE+1]; INTERP_KERNEL::AutoPtr unit=new char[ncomp*MED_SNAME_SIZE+1]; med_int nbPdt; MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,i+1,nomcha,maa_ass,&localmesh,&typcha,comp,unit,dt_unit,&nbPdt)); - std::string curFieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE+1); + std::string const curFieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE+1); if(curFieldName==fieldName) { for(int k=0;k, double> > MEDCoupling::GetAllFieldIt double MEDCoupling::GetTimeAttachedOnFieldIteration(const std::string& fileName, const std::string& fieldName, int iteration, int order) { - MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName)); - med_int nbFields=MEDnField(fid); + MEDFileUtilities::AutoFid const fid(MEDCoupling::OpenMEDFileForRead(fileName)); + med_int const nbFields=MEDnField(fid); // med_field_type typcha; med_int numdt=0,numo=0; @@ -922,12 +940,12 @@ double MEDCoupling::GetTimeAttachedOnFieldIteration(const std::string& fileName, double ret=std::numeric_limits::max(); for(int i=0;i comp=new char[ncomp*MED_SNAME_SIZE+1]; INTERP_KERNEL::AutoPtr unit=new char[ncomp*MED_SNAME_SIZE+1]; med_int nbPdt; MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,i+1,nomcha,maa_ass,&local,&typcha,comp,unit,dt_unit,&nbPdt)); - std::string curFieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE+1); + std::string const curFieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE+1); if(curFieldName==fieldName) { found=true; @@ -967,10 +985,10 @@ std::vector< std::pair > MEDCoupling::GetFieldIterations(MEDCoupling::T std::vector< std::pair > MEDCoupling::GetCellFieldIterations(const std::string& fileName, const std::string& meshName, const std::string& fieldName) { - std::string meshNameCpp(meshName); + std::string const meshNameCpp(meshName); std::vector< std::pair > ret; - MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName)); - med_int nbFields=MEDnField(fid); + MEDFileUtilities::AutoFid const fid(MEDCoupling::OpenMEDFileForRead(fileName)); + med_int const nbFields=MEDnField(fid); // med_field_type typcha; med_int numdt=0,numo=0; @@ -986,12 +1004,12 @@ std::vector< std::pair > MEDCoupling::GetCellFieldIterations(const std: std::set s2; for(int i=0;i comp=new char[ncomp*MED_SNAME_SIZE+1]; INTERP_KERNEL::AutoPtr unit=new char[ncomp*MED_SNAME_SIZE+1]; med_int nbPdt; MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,i+1,nomcha,maa_ass,&localmesh,&typcha,comp,unit,dt_unit,&nbPdt)); - std::string curFieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE+1); + std::string const curFieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE+1); if(curFieldName==fieldName) { bool found=false; @@ -1001,9 +1019,9 @@ std::vector< std::pair > MEDCoupling::GetCellFieldIterations(const std: { med_int profilesize,nbi; MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,nomcha,k+1,&numdt,&numo,&dt)); - med_int nbOfVal(MEDfieldnValueWithProfile(fid,nomcha,numdt,numo,MED_CELL,typmai[j],1,MED_COMPACT_PFLMODE, + med_int const nbOfVal(MEDfieldnValueWithProfile(fid,nomcha,numdt,numo,MED_CELL,typmai[j],1,MED_COMPACT_PFLMODE, pflname,&profilesize,locname,&nbi)); - std::string maa_ass_cpp(maa_ass); + std::string const maa_ass_cpp(maa_ass); if(nbOfVal>0) { if(meshNameCpp==maa_ass_cpp) @@ -1038,10 +1056,10 @@ std::vector< std::pair > MEDCoupling::GetCellFieldIterations(const std: std::vector< std::pair > MEDCoupling::GetNodeFieldIterations(const std::string& fileName, const std::string& meshName, const std::string& fieldName) { - std::string meshNameCpp(meshName); + std::string const meshNameCpp(meshName); std::vector< std::pair > ret; - MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName)); - med_int nbFields=MEDnField(fid); + MEDFileUtilities::AutoFid const fid(MEDCoupling::OpenMEDFileForRead(fileName)); + med_int const nbFields=MEDnField(fid); // med_field_type typcha; med_int numdt=0,numo=0; @@ -1057,21 +1075,21 @@ std::vector< std::pair > MEDCoupling::GetNodeFieldIterations(const std: std::set s2; for(int i=0;i comp=new char[ncomp*MED_SNAME_SIZE+1]; INTERP_KERNEL::AutoPtr unit=new char[ncomp*MED_SNAME_SIZE+1]; med_int nbPdt; MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,i+1,nomcha,maa_ass,&localmesh,&typcha,comp,unit,dt_unit,&nbPdt)); - std::string curFieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE+1); + std::string const curFieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE+1); if(curFieldName==fieldName) { for(int k=0;k0) { if(meshNameCpp==maa_ass_cpp) @@ -1105,16 +1123,16 @@ MEDCoupling::MEDCouplingMesh *MEDCoupling::ReadMeshFromFile(const std::string& f MEDCoupling::CheckFileForRead(fileName); MCAuto mm(MEDFileMesh::New(fileName,meshName)); MEDFileMesh *mmPtr(mm); - MEDFileUMesh *mmuPtr=dynamic_cast(mmPtr); + auto *mmuPtr=dynamic_cast(mmPtr); if(mmuPtr) return mmuPtr->getMeshAtLevel(meshDimRelToMax,true); - MEDFileCMesh *mmcPtr=dynamic_cast(mmPtr); + auto *mmcPtr=dynamic_cast(mmPtr); if(mmcPtr) { const MEDCouplingCMesh *ret(mmcPtr->getMesh()); ret->incrRef(); return const_cast(ret); } - MEDFileCurveLinearMesh *mmc2Ptr=dynamic_cast(mmPtr); + auto *mmc2Ptr=dynamic_cast(mmPtr); if(mmc2Ptr) { const MEDCouplingCurveLinearMesh *ret(mmc2Ptr->getMesh()); ret->incrRef(); @@ -1129,16 +1147,16 @@ MEDCoupling::MEDCouplingMesh *MEDCoupling::ReadMeshFromFile(const std::string& f MEDCoupling::CheckFileForRead(fileName); MCAuto mm(MEDFileMesh::New(fileName)); MEDFileMesh *mmPtr(mm); - MEDFileUMesh *mmuPtr=dynamic_cast(mmPtr); + auto *mmuPtr=dynamic_cast(mmPtr); if(mmuPtr) return mmuPtr->getMeshAtLevel(meshDimRelToMax,true); - MEDFileCMesh *mmcPtr=dynamic_cast(mmPtr); + auto *mmcPtr=dynamic_cast(mmPtr); if(mmcPtr) { const MEDCouplingCMesh *ret(mmcPtr->getMesh()); ret->incrRef(); return const_cast(ret); } - MEDFileCurveLinearMesh *mmc2Ptr=dynamic_cast(mmPtr); + auto *mmc2Ptr=dynamic_cast(mmPtr); if(mmc2Ptr) { const MEDCouplingCurveLinearMesh *ret(mmc2Ptr->getMesh()); ret->incrRef(); @@ -1153,7 +1171,7 @@ MEDCoupling::MEDCouplingUMesh *MEDCoupling::ReadUMeshFromFile(const std::string& MEDCoupling::CheckFileForRead(fileName); MCAuto mm(MEDFileMesh::New(fileName,meshName)); MEDFileMesh *mmPtr(mm); - MEDFileUMesh *mmuPtr=dynamic_cast(mmPtr); + auto *mmuPtr=dynamic_cast(mmPtr); if(!mmuPtr) { std::ostringstream oss; oss << "ReadUMeshFromFile : With fileName=\""<< fileName << "\", meshName=\""<< meshName << "\" exists but it is not an unstructured mesh !"; @@ -1167,7 +1185,7 @@ MEDCoupling::MEDCouplingUMesh *MEDCoupling::ReadUMeshFromFile(const std::string& MEDCoupling::CheckFileForRead(fileName); MCAuto mm(MEDFileMesh::New(fileName)); MEDFileMesh *mmPtr(mm); - MEDFileUMesh *mmuPtr=dynamic_cast(mmPtr); + auto *mmuPtr=dynamic_cast(mmPtr); if(!mmuPtr) { std::ostringstream oss; oss << "ReadUMeshFromFile : With fileName=\""<< fileName << "\", meshName (the first) =\""<< mm->getName() << "\" exists but it is not an unstructured mesh !"; @@ -1188,7 +1206,7 @@ MEDCoupling::MEDCouplingUMesh *MEDCoupling::ReadUMeshFromFamilies(const std::str MEDCoupling::CheckFileForRead(fileName); MCAuto mm(MEDFileMesh::New(fileName,meshName)); MEDFileMesh *mmPtr(mm); - MEDFileUMesh *mmuPtr=dynamic_cast(mmPtr); + auto *mmuPtr=dynamic_cast(mmPtr); if(!mmuPtr) { std::ostringstream oss; oss << "ReadUMeshFromFamilies : With fileName=\""<< fileName << "\", meshName (the first) =\""<< mm->getName() << "\" exists but it is not an unstructured mesh !"; @@ -1202,7 +1220,7 @@ MEDCoupling::MEDCouplingUMesh *MEDCoupling::ReadUMeshFromGroups(const std::strin MEDCoupling::CheckFileForRead(fileName); MCAuto mm=MEDFileMesh::New(fileName,meshName); MEDFileMesh *mmPtr(mm); - MEDFileUMesh *mmuPtr=dynamic_cast(mmPtr); + auto *mmuPtr=dynamic_cast(mmPtr); if(!mmuPtr) { std::ostringstream oss; oss << "ReadUMeshFromGroups : With fileName=\""<< fileName << "\", meshName (the first) =\""<< mm->getName() << "\" exists but it is not an unstructured mesh !"; @@ -1214,7 +1232,7 @@ MEDCoupling::MEDCouplingUMesh *MEDCoupling::ReadUMeshFromGroups(const std::strin MCAuto MEDCoupling::ReadField(const std::string& fileName) { std::vector fieldNames(GetAllFieldNames(fileName)); - std::size_t sz(fieldNames.size()); + std::size_t const sz(fieldNames.size()); if(sz==0) { std::ostringstream oss; @@ -1227,8 +1245,8 @@ MCAuto MEDCoupling::ReadField(const std::string& oss << "In file \"" << fileName << "\" there are more than one field !" << std::endl; oss << "You are invited to use ReadField(fileName, fieldName) instead to avoid misleading concerning field you want to read !" << std::endl; oss << "For information, fields available are :" << std::endl; - for(std::vector::const_iterator it=fieldNames.begin();it!=fieldNames.end();it++) - oss << " - \"" << *it << "\"" << std::endl; + for(const auto & fieldName : fieldNames) + oss << " - \"" << fieldName << "\"" << std::endl; throw INTERP_KERNEL::Exception(oss.str()); } return ReadField(fileName,fieldNames[0]); @@ -1237,7 +1255,7 @@ MCAuto MEDCoupling::ReadField(const std::string& MCAuto MEDCoupling::ReadField(const std::string& fileName, const std::string& fieldName) { std::vector< std::pair< std::pair, double> > iterations(GetAllFieldIterations(fileName,fieldName)); - std::size_t sz(iterations.size()); + std::size_t const sz(iterations.size()); if(sz==0) { std::ostringstream oss; @@ -1250,8 +1268,8 @@ MCAuto MEDCoupling::ReadField(const std::string& oss << "In file \"" << fileName << "\" field \"" << fieldName << "\" exists but with more than one time steps !" << std::endl; oss << "You are invited to use ReadField(fileName, fieldName, iteration, order) instead to avoid misleading concerning time steps." << std::endl; oss << "For information, time steps available for field \"" << fieldName << "\" are :" << std::endl; - for(std::vector< std::pair< std::pair, double> >::const_iterator it=iterations.begin();it!=iterations.end();it++) - oss << " - " << (*it).first.first << ", " << (*it).first.second << " (" << (*it).second << ")" << std::endl; + for(const auto & iteration : iterations) + oss << " - " << iteration.first.first << ", " << iteration.first.second << " (" << iteration.second << ")" << std::endl; throw INTERP_KERNEL::Exception(oss.str()); } return ReadField(fileName,fieldName,iterations[0].first.first,iterations[0].first.second); @@ -1328,7 +1346,7 @@ std::vector MEDCoupling::ReadFieldsOnSame //Retrieving mesh of rank 0 and field on rank 0 too. MCAuto mm=MEDFileMesh::New(fileName,meshName); MEDFileMesh *mmPtr(mm); - MEDFileUMesh *mmuPtr=dynamic_cast(mmPtr); + auto *mmuPtr=dynamic_cast(mmPtr); if(!mmuPtr) throw INTERP_KERNEL::Exception("ReadFieldsOnSameMesh : only unstructured mesh is managed !"); MCAuto m=mmuPtr->getMeshAtLevel(meshDimRelToMax); @@ -1337,7 +1355,7 @@ std::vector MEDCoupling::ReadFieldsOnSame if(o2n) m2->renumberCells(o2n->begin(),true); int i=0; - for(std::vector >::const_iterator it=its.begin();it!=its.end();it++,i++) + for(auto it=its.begin();it!=its.end();it++,i++) { MCAuto ff=MEDFileField1TS::New(fileName,fieldName,(*it).first,(*it).second); MCAuto retElt=ff->getFieldOnMeshAtLevel(type,m); @@ -1347,7 +1365,7 @@ std::vector MEDCoupling::ReadFieldsOnSame retSafe[i]=retElt; } i=0; - for(std::vector >::const_iterator it=its.begin();it!=its.end();it++,i++) + for(auto it=its.begin();it!=its.end();it++,i++) ret[i]=retSafe[i].retn(); return ret; } @@ -1379,7 +1397,7 @@ std::vector MEDCoupling::ReadFieldsGaussN namespace MEDCoupling { template - MCAuto::FieldType> ReadFieldCellLikeT(typename MLFieldTraits::F1TSType *ff, MEDCoupling::TypeOfField type, const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order) + MCAuto::FieldType> ReadFieldCellLikeT(typename MLFieldTraits::F1TSType *ff, MEDCoupling::TypeOfField type, const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& /*fieldName*/, int /*iteration*/, int /*order*/) { MCAuto mm(MEDFileMesh::New(fileName,meshName)); MCAuto muPtr(MEDCoupling::DynamicCast(mm)); @@ -1433,7 +1451,7 @@ namespace MEDCoupling } template - MCAuto::FieldType> ReadFieldNodeT(typename MLFieldTraits::F1TSType *ff, const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order) + MCAuto::FieldType> ReadFieldNodeT(typename MLFieldTraits::F1TSType *ff, const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& /*fieldName*/, int /*iteration*/, int /*order*/) { MCAuto mm(MEDFileMesh::New(fileName,meshName)); MCAuto m(mm->getMeshAtLevel(meshDimRelToMax,false)); @@ -1455,7 +1473,7 @@ namespace MEDCoupling MCAuto pflSafe(pfl); MCAuto mp(m->getCellIdsFullyIncludedInNodeIds(pfl->begin(),pfl->end())); MCAuto mzip(static_cast(m->buildPartAndReduceNodes(mp->begin(),mp->end(),arr2))); - MCAuto arr2Safe(arr2); + MCAuto const arr2Safe(arr2); MCAuto arr3(arr2->invertArrayO2N2N2O(mzip->getNumberOfNodes())); MCAuto pflSorted(pflSafe->deepCopy()); pflSorted->sort(true); if(!arr3->isEqualWithoutConsideringStr(*pflSorted)) @@ -1531,14 +1549,14 @@ void MEDCoupling::WriteMesh(const std::string& fileName, const MEDCoupling::MEDC { if(!mesh) throw INTERP_KERNEL::Exception("WriteMesh : input mesh is null !"); - const MEDCouplingUMesh *um(dynamic_cast(mesh)); + const auto *um(dynamic_cast(mesh)); if(um) { WriteUMesh(fileName,um,writeFromScratch); return ; } - int mod=writeFromScratch?2:0; - const MEDCoupling1GTUMesh *um2(dynamic_cast(mesh)); + int const mod=writeFromScratch?2:0; + const auto *um2(dynamic_cast(mesh)); if(um2) { MCAuto mmu(MEDFileUMesh::New()); @@ -1547,7 +1565,7 @@ void MEDCoupling::WriteMesh(const std::string& fileName, const MEDCoupling::MEDC mmu->write(fileName,mod); return ; } - const MEDCouplingCMesh *um3(dynamic_cast(mesh)); + const auto *um3(dynamic_cast(mesh)); if(um3) { MCAuto mmc(MEDFileCMesh::New()); @@ -1556,7 +1574,7 @@ void MEDCoupling::WriteMesh(const std::string& fileName, const MEDCoupling::MEDC mmc->write(fileName,mod); return ; } - const MEDCouplingCurveLinearMesh *um4(dynamic_cast(mesh)); + const auto *um4(dynamic_cast(mesh)); if(um4) { MCAuto mmc(MEDFileCurveLinearMesh::New()); @@ -1572,7 +1590,7 @@ void MEDCoupling::WriteUMesh(const std::string& fileName, const MEDCoupling::MED { if(!mesh) throw INTERP_KERNEL::Exception("WriteUMesh : input mesh is null !"); - int mod=writeFromScratch?2:0; + int const mod=writeFromScratch?2:0; MCAuto m(MEDFileUMesh::New()); AssignStaticWritePropertiesTo(*m); MCAuto mcpy(static_cast(mesh->deepCopy())); @@ -1587,10 +1605,10 @@ void MEDCoupling::WriteUMeshDep(const std::string& fileName, const MEDCoupling:: void MEDCoupling::WriteUMeshesPartition(const std::string& fileName, const std::string& meshNameC, const std::vector& meshes, bool writeFromScratch) { - std::string meshName(meshNameC); + std::string const meshName(meshNameC); if(meshName.empty()) throw INTERP_KERNEL::Exception("Trying to write a unstructured mesh with no name ! MED file format needs a not empty mesh name : change 2nd parameter !"); - int status=MEDLoaderBase::getStatusOfFile(fileName); + int const status=MEDLoaderBase::getStatusOfFile(fileName); if(status!=MEDLoaderBase::EXIST_RW && status!=MEDLoaderBase::NOT_EXIST) { std::ostringstream oss; oss << "File with name \'" << fileName << "\' has not valid permissions !"; @@ -1600,7 +1618,7 @@ void MEDCoupling::WriteUMeshesPartition(const std::string& fileName, const std:: AssignStaticWritePropertiesTo(*m); m->setGroupsFromScratch(0,meshes,true); m->setName(meshNameC); - int mod=writeFromScratch?2:0; + int const mod=writeFromScratch?2:0; m->write(fileName,mod); } @@ -1611,7 +1629,7 @@ void MEDCoupling::WriteUMeshesPartitionDep(const std::string& fileName, const st void MEDCoupling::WriteUMeshes(const std::string& fileName, const std::vector& meshes, bool writeFromScratch) { - int mod(writeFromScratch?2:0); + int const mod(writeFromScratch?2:0); MCAuto m(MEDFileUMesh::New()); AssignStaticWritePropertiesTo(*m); m->setMeshes(meshes,true); @@ -1625,12 +1643,12 @@ void MEDLoaderNS::writeFieldWithoutReadingAndMappingOfMeshInFile(const std::stri AssignStaticWritePropertiesTo(*ff); MCAuto::FieldType> f2(f->deepCopy()); const MEDCouplingMesh *m(f2->getMesh()); - const MEDCouplingUMesh *um(dynamic_cast(m)); - const MEDCoupling1GTUMesh *um2(dynamic_cast(m)); - const MEDCouplingCMesh *um3(dynamic_cast(m)); - const MEDCouplingCurveLinearMesh *um4(dynamic_cast(m)); - MCAuto mm; - int mod(writeFromScratch?2:0); + const auto *um(dynamic_cast(m)); + const auto *um2(dynamic_cast(m)); + const auto *um3(dynamic_cast(m)); + const auto *um4(dynamic_cast(m)); + MCAuto const mm; + int const mod(writeFromScratch?2:0); if(um) { MCAuto mmu(MEDFileUMesh::New()); @@ -1678,7 +1696,7 @@ void WriteFieldT(const std::string& fileName, const typename MEDCoupling::Traits if(!f) throw INTERP_KERNEL::Exception("WriteField : input field is NULL !"); f->checkConsistencyLight(); - int status(MEDLoaderBase::getStatusOfFile(fileName)); + int const status(MEDLoaderBase::getStatusOfFile(fileName)); if(status!=MEDLoaderBase::EXIST_RW && status!=MEDLoaderBase::NOT_EXIST) { std::ostringstream oss; oss << "File with name \'" << fileName << "\' has not valid permissions !"; @@ -1693,7 +1711,7 @@ void WriteFieldT(const std::string& fileName, const typename MEDCoupling::Traits std::vector meshNames(GetMeshNames(fileName)); if(!f->getMesh()) throw INTERP_KERNEL::Exception("WriteField : trying to write a field with no mesh !"); - std::string fileNameCpp(f->getMesh()->getName()); + std::string const fileNameCpp(f->getMesh()->getName()); if(std::find(meshNames.begin(),meshNames.end(),fileNameCpp)==meshNames.end()) MEDLoaderNS::writeFieldWithoutReadingAndMappingOfMeshInFile(fileName,f,false); else @@ -1701,11 +1719,11 @@ void WriteFieldT(const std::string& fileName, const typename MEDCoupling::Traits MCAuto mm(MEDFileMesh::New(fileName,f->getMesh()->getName().c_str())); AssignStaticWritePropertiesTo(*mm); const MEDFileMesh *mmPtr(mm); - const MEDFileUMesh *mmuPtr(dynamic_cast(mmPtr)); + const auto *mmuPtr(dynamic_cast(mmPtr)); if(!mmuPtr) throw INTERP_KERNEL::Exception("WriteField : only umeshes are supported now !"); MCAuto< typename MEDCoupling::Traits::FieldType > f2(f->deepCopy()); - MEDCouplingUMesh *m(dynamic_cast(const_cast(f2->getMesh()))); + auto *m(dynamic_cast(const_cast(f2->getMesh()))); if(!m) throw INTERP_KERNEL::Exception("WriteField : only umesh in input field supported !"); MCAuto o2n(m->getRenumArrForMEDFileFrmt()); @@ -1718,9 +1736,9 @@ void WriteFieldT(const std::string& fileName, const typename MEDCoupling::Traits m->tryToShareSameCoordsPermute(*mread,_EPS_FOR_NODE_COMP); else mread->setCoords(m->getCoords()); - DataArrayIdType *part(NULL); - bool b(mread->areCellsIncludedIn(m,_COMP_FOR_CELL,part)); - MCAuto partSafe(part); + DataArrayIdType *part(nullptr); + bool const b(mread->areCellsIncludedIn(m,_COMP_FOR_CELL,part)); + MCAuto const partSafe(part); if(!b) { std::ostringstream oss; oss << "WriteField : The file \""<< fileName << "\" already contains a mesh named \""<< f->getMesh()->getName() << "\" and this mesh in the file is not compatible (a subpart) with the mesh you intend to write ! This is maybe due to a too strict policy ! Try with to lease it by calling SetCompPolicyForCell !"; @@ -1740,9 +1758,9 @@ void WriteFieldT(const std::string& fileName, const typename MEDCoupling::Traits } else { - DataArrayIdType *part(NULL); - bool b(mread->getCoords()->areIncludedInMe(m->getCoords(),_EPS_FOR_NODE_COMP,part)); - MCAuto partSafe(part); + DataArrayIdType *part(nullptr); + bool const b(mread->getCoords()->areIncludedInMe(m->getCoords(),_EPS_FOR_NODE_COMP,part)); + MCAuto const partSafe(part); if(!b) { std::ostringstream oss; oss << "WriteField : The file \""<< fileName << "\" already contains a mesh named \""<< f->getMesh()->getName() << "\" and this mesh in the file is not compatible (a subpart regarding nodes) with the mesh you intend to write ! This is maybe due to a too strict epsilon ! Try with to lease it by calling SetEpsilonForNodeComp !"; @@ -1768,7 +1786,7 @@ void MEDCoupling::WriteField(const std::string& fileName, const MEDCoupling::MED if(!f) throw INTERP_KERNEL::Exception("WriteField : input field is null !"); { - const MEDCoupling::MEDCouplingFieldDouble *f1(dynamic_cast(f)); + const auto *f1(dynamic_cast(f)); if(f1) { WriteFieldT(fileName,f1,writeFromScratch); @@ -1776,7 +1794,7 @@ void MEDCoupling::WriteField(const std::string& fileName, const MEDCoupling::MED } } { - const MEDCoupling::MEDCouplingFieldInt32 *f1(dynamic_cast(f)); + const auto *f1(dynamic_cast(f)); if(f1) { WriteFieldT(fileName,f1,writeFromScratch); @@ -1784,7 +1802,7 @@ void MEDCoupling::WriteField(const std::string& fileName, const MEDCoupling::MED } } { - const MEDCoupling::MEDCouplingFieldInt64 *f1(dynamic_cast(f)); + const auto *f1(dynamic_cast(f)); if(f1) { WriteFieldT(fileName,f1,writeFromScratch); @@ -1793,7 +1811,7 @@ void MEDCoupling::WriteField(const std::string& fileName, const MEDCoupling::MED } { - const MEDCoupling::MEDCouplingFieldFloat *f1(dynamic_cast(f)); + const auto *f1(dynamic_cast(f)); if(f1) { WriteFieldT(fileName,f1,writeFromScratch); @@ -1814,7 +1832,7 @@ void WriteFieldUsingAlreadyWrittenMeshT(const std::string& fileName, const typen if(!f) throw INTERP_KERNEL::Exception("WriteFieldUsingAlreadyWrittenMeshT : input field is null !"); f->checkConsistencyLight(); - int status(MEDLoaderBase::getStatusOfFile(fileName)); + int const status(MEDLoaderBase::getStatusOfFile(fileName)); if(status!=MEDLoaderBase::EXIST_RW) { std::ostringstream oss; oss << "File with name \'" << fileName << "\' has not valid permissions or not exists !"; @@ -1822,7 +1840,7 @@ void WriteFieldUsingAlreadyWrittenMeshT(const std::string& fileName, const typen } MCAuto< typename MLFieldTraits::F1TSType > f1ts(MLFieldTraits::F1TSType::New()); AssignStaticWritePropertiesTo(*f1ts); - MEDCouplingUMesh *m(dynamic_cast(const_cast(f->getMesh()))); + auto *m(dynamic_cast(const_cast(f->getMesh()))); if(m) { MCAuto o2n(m->getRenumArrForMEDFileFrmt()); @@ -1840,7 +1858,7 @@ void MEDCoupling::WriteFieldUsingAlreadyWrittenMesh(const std::string& fileName, if(!f) throw INTERP_KERNEL::Exception("WriteFieldUsingAlreadyWrittenMesh : input field is null !"); { - const MEDCoupling::MEDCouplingFieldDouble *f1(dynamic_cast(f)); + const auto *f1(dynamic_cast(f)); if(f1) { WriteFieldUsingAlreadyWrittenMeshT(fileName,f1); @@ -1848,7 +1866,7 @@ void MEDCoupling::WriteFieldUsingAlreadyWrittenMesh(const std::string& fileName, } } { - const MEDCoupling::MEDCouplingFieldInt32 *f1(dynamic_cast(f)); + const auto *f1(dynamic_cast(f)); if(f1) { WriteFieldUsingAlreadyWrittenMeshT(fileName,f1); @@ -1856,7 +1874,7 @@ void MEDCoupling::WriteFieldUsingAlreadyWrittenMesh(const std::string& fileName, } } { - const MEDCoupling::MEDCouplingFieldInt64 *f1(dynamic_cast(f)); + const auto *f1(dynamic_cast(f)); if(f1) { WriteFieldUsingAlreadyWrittenMeshT(fileName,f1); @@ -1864,7 +1882,7 @@ void MEDCoupling::WriteFieldUsingAlreadyWrittenMesh(const std::string& fileName, } } { - const MEDCoupling::MEDCouplingFieldFloat *f1(dynamic_cast(f)); + const auto *f1(dynamic_cast(f)); if(f1) { WriteFieldUsingAlreadyWrittenMeshT(fileName,f1); diff --git a/src/MEDLoader/MEDLoader.hxx b/src/MEDLoader/MEDLoader.hxx index a740f6ff3..6e37282e9 100644 --- a/src/MEDLoader/MEDLoader.hxx +++ b/src/MEDLoader/MEDLoader.hxx @@ -21,13 +21,14 @@ #pragma once #include "MEDLoaderDefines.hxx" -#include "InterpKernelException.hxx" #include "MEDCouplingRefCountObject.hxx" -#include "NormalizedUnstructuredMesh.hxx" #include "MCAuto.hxx" #include "MCIdType.hxx" +#include "NormalizedGeometricTypes" -#include +#include +#include +#include #include namespace MEDCoupling diff --git a/src/MEDLoader/MEDLoaderBase.cxx b/src/MEDLoader/MEDLoaderBase.cxx index 97a68347f..37d50a057 100644 --- a/src/MEDLoader/MEDLoaderBase.cxx +++ b/src/MEDLoader/MEDLoaderBase.cxx @@ -21,10 +21,12 @@ #include "MEDLoaderBase.hxx" #include "InterpKernelException.hxx" +#include #include #include #include #include +#include const char MEDLoaderBase::WHITE_SPACES[]=" \n"; @@ -37,7 +39,7 @@ int MEDLoaderBase::getStatusOfFile(const std::string& fileName) ifs.close(); return NOT_EXIST; } - std::ofstream ofs(fileName.c_str(),std::ios_base::app); + std::ofstream const ofs(fileName.c_str(),std::ios_base::app); if((ofs.rdstate() & std::ofstream::failbit)!=0) { return EXIST_RDONLY; @@ -55,7 +57,7 @@ char *MEDLoaderBase::buildEmptyString(std::size_t lgth) void MEDLoaderBase::getDirAndBaseName(const std::string& fullName, std::string& dirName, std::string& baseName) { - std::size_t pos=fullName.find_last_of(getPathSep()); + std::size_t const pos=fullName.find_last_of(getPathSep()); if(pos!=std::string::npos) { dirName=fullName.substr(0,pos); @@ -99,8 +101,8 @@ std::string MEDLoaderBase::buildUnionUnit(const char *name, int nameLgth, const void MEDLoaderBase::splitIntoNameAndUnit(const std::string& s, std::string& name, std::string& unit) { - std::string::size_type f1=s.find_first_of('['); - std::string::size_type f2=s.find_last_of(']'); + std::string::size_type const f1=s.find_first_of('['); + std::string::size_type const f2=s.find_last_of(']'); if(f1!=std::string::npos && f2!=std::string::npos) { if(f1 " << maxLgth << ") : "; std::cerr << "zipping to : " << s << "\n"; strcpy(dest,s.c_str()); @@ -170,25 +172,25 @@ void MEDLoaderBase::safeStrCpy2(const char *src, int maxLgth, char *dest, int be } else if(behaviour==1) { - std::string s=zipString(src,maxLgth); + std::string const s=zipString(src,maxLgth); std::cerr << "A string : \"" << src << "\" has been detected to be too long for MED File ( > " << maxLgth << ") : "; std::cerr << "zipping to : " << s << "\n"; strcpy(dest,s.c_str()); return ; } } - std::size_t n(strlen(src)); + std::size_t const n(strlen(src)); std::fill(dest,dest+maxLgth,' '); strncpy(dest,src,n); } std::string MEDLoaderBase::buildStringFromFortran(const char *expr, int lgth) { - std::string ret(expr,lgth); - std::string whiteSpaces(WHITE_SPACES); - std::size_t lgthReal=strlen(ret.c_str()); + std::string const ret(expr,lgth); + std::string const whiteSpaces(WHITE_SPACES); + std::size_t const lgthReal=strlen(ret.c_str()); std::string ret2=ret.substr(0,lgthReal); - std::size_t found=ret2.find_last_not_of(whiteSpaces); + std::size_t const found=ret2.find_last_not_of(whiteSpaces); if (found!=std::string::npos) ret2.erase(found+1); else @@ -227,7 +229,7 @@ void MEDLoaderBase::zipEqualConsChar(std::string& s, int minConsSmChar) { for(std::string::iterator it=s.begin();it!=s.end();it++) { - char tmp=*it; + char const tmp=*it; int sz=1; for(std::string::iterator it2=it+1;it2!=s.end() && *it2==tmp;it2++) sz++; diff --git a/src/MEDLoader/MEDLoaderBase.hxx b/src/MEDLoader/MEDLoaderBase.hxx index aaa20a453..28c846af6 100644 --- a/src/MEDLoader/MEDLoaderBase.hxx +++ b/src/MEDLoader/MEDLoaderBase.hxx @@ -22,8 +22,8 @@ #define __MEDLOADERBASE_HXX__ #include "MEDLoaderDefines.hxx" -#include "InterpKernelException.hxx" +#include #include class MEDLOADER_EXPORT MEDLoaderBase diff --git a/src/MEDLoader/MEDLoaderNS.hxx b/src/MEDLoader/MEDLoaderNS.hxx index 0194c2fa2..e4919db0a 100644 --- a/src/MEDLoader/MEDLoaderNS.hxx +++ b/src/MEDLoader/MEDLoaderNS.hxx @@ -21,6 +21,7 @@ #ifndef __MEDLOADERNS_HXX__ #define __MEDLOADERNS_HXX__ +#include "MEDCouplingTraits.hxx" #include #include diff --git a/src/MEDLoader/MEDLoaderTraits.hxx b/src/MEDLoader/MEDLoaderTraits.hxx index 43c8f649f..1269d6a6f 100644 --- a/src/MEDLoader/MEDLoaderTraits.hxx +++ b/src/MEDLoader/MEDLoaderTraits.hxx @@ -28,7 +28,7 @@ namespace MEDCoupling template struct MEDLOADER_EXPORT MLFieldTraits { - typedef T EltType; + using EltType = T; }; class MEDFileFieldMultiTS; @@ -51,37 +51,37 @@ namespace MEDCoupling template<> struct MEDLOADER_EXPORT MLFieldTraits { - typedef MEDFileFieldMultiTSWithoutSDA FMTSWSDAType; - typedef MEDFileFieldMultiTS FMTSType; - typedef MEDFileField1TS F1TSType; - typedef MEDFileField1TSWithoutSDA F1TSWSDAType; + using FMTSWSDAType = MEDFileFieldMultiTSWithoutSDA; + using FMTSType = MEDFileFieldMultiTS; + using F1TSType = MEDFileField1TS; + using F1TSWSDAType = MEDFileField1TSWithoutSDA; }; template<> struct MEDLOADER_EXPORT MLFieldTraits { - typedef MEDFileFloatFieldMultiTSWithoutSDA FMTSWSDAType; - typedef MEDFileFloatFieldMultiTS FMTSType; - typedef MEDFileFloatField1TS F1TSType; - typedef MEDFileFloatField1TSWithoutSDA F1TSWSDAType; + using FMTSWSDAType = MEDFileFloatFieldMultiTSWithoutSDA; + using FMTSType = MEDFileFloatFieldMultiTS; + using F1TSType = MEDFileFloatField1TS; + using F1TSWSDAType = MEDFileFloatField1TSWithoutSDA; }; template<> struct MEDLOADER_EXPORT MLFieldTraits { - typedef MEDFileInt32FieldMultiTSWithoutSDA FMTSWSDAType; - typedef MEDFileInt32FieldMultiTS FMTSType; - typedef MEDFileInt32Field1TS F1TSType; - typedef MEDFileInt32Field1TSWithoutSDA F1TSWSDAType; + using FMTSWSDAType = MEDFileInt32FieldMultiTSWithoutSDA; + using FMTSType = MEDFileInt32FieldMultiTS; + using F1TSType = MEDFileInt32Field1TS; + using F1TSWSDAType = MEDFileInt32Field1TSWithoutSDA; }; template<> struct MEDLOADER_EXPORT MLFieldTraits { - typedef MEDFileInt64FieldMultiTSWithoutSDA FMTSWSDAType; - typedef MEDFileInt64FieldMultiTS FMTSType; - typedef MEDFileInt64Field1TS F1TSType; - typedef MEDFileInt64Field1TSWithoutSDA F1TSWSDAType; + using FMTSWSDAType = MEDFileInt64FieldMultiTSWithoutSDA; + using FMTSType = MEDFileInt64FieldMultiTS; + using F1TSType = MEDFileInt64Field1TS; + using F1TSWSDAType = MEDFileInt64Field1TSWithoutSDA; }; template diff --git a/src/MEDLoader/MEDMESHConverterUtilities.cxx b/src/MEDLoader/MEDMESHConverterUtilities.cxx index d8e8c4e5e..407e4ce34 100644 --- a/src/MEDLoader/MEDMESHConverterUtilities.cxx +++ b/src/MEDLoader/MEDMESHConverterUtilities.cxx @@ -19,7 +19,8 @@ #include "MEDMESHConverterUtilities.hxx" -#include "libmesh5.hxx" +#include +#include namespace MeshFormat { @@ -45,7 +46,7 @@ namespace MeshFormat Localizer::Localizer() { - _locale = setlocale(LC_NUMERIC, NULL); + _locale = setlocale(LC_NUMERIC, nullptr); setlocale(LC_NUMERIC, "C"); } diff --git a/src/MEDLoader/MEDMESHConverterUtilities.hxx b/src/MEDLoader/MEDMESHConverterUtilities.hxx index b0667d5e4..d7e9c18f1 100644 --- a/src/MEDLoader/MEDMESHConverterUtilities.hxx +++ b/src/MEDLoader/MEDMESHConverterUtilities.hxx @@ -25,7 +25,6 @@ # include # include #include -# include #include namespace MeshFormat diff --git a/src/MEDLoader/MeshFormatReader.cxx b/src/MEDLoader/MeshFormatReader.cxx index 83eb4232e..34f884904 100644 --- a/src/MEDLoader/MeshFormatReader.cxx +++ b/src/MEDLoader/MeshFormatReader.cxx @@ -19,14 +19,22 @@ #include "MeshFormatReader.hxx" +#include "MCAuto.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include "MCType.hxx" #include "MEDFileMesh.hxx" #include "MEDFileField.hxx" #include "MEDFileData.hxx" #include "MEDCouplingFieldDouble.hxx" +#include "NormalizedGeometricTypes" #include "libmesh5.hxx" #include "MEDMESHConverterUtilities.hxx" +#include #include -#include +#include +#include +#include +#include namespace MEDCoupling { MeshFormatReader::MeshFormatReader():_myMeshName("MESH") @@ -39,12 +47,12 @@ MeshFormatReader::MeshFormatReader(const std::string& meshFileName, {} MeshFormatReader::~MeshFormatReader() -{} += default; MEDCoupling::MCAuto MeshFormatReader::loadInMedFileDS() { _myStatus = perform(); - if(_myStatus != MeshFormat::DRS_OK) return 0; + if(_myStatus != MeshFormat::DRS_OK) return nullptr; if ( !_uMesh->getName().c_str() || strlen( _uMesh->getName().c_str() ) == 0 ) _uMesh->setName( _myMeshName ); @@ -69,9 +77,9 @@ MEDCoupling::MCAuto MeshFormatReader::loadInMedFileDS( MeshFormat::Status MeshFormatReader::perform() { - MeshFormat::Localizer loc; + MeshFormat::Localizer const loc; - MeshFormat::Status status = MeshFormat::DRS_OK; + MeshFormat::Status const status = MeshFormat::DRS_OK; // open the file @@ -99,13 +107,13 @@ MeshFormat::Status MeshFormatReader::perform() setNodes(coordArray); - int nbEdges = _reader.GmfStatKwd(_myCurrentFileId, MeshFormat::GmfEdges); - int nbTria = _reader.GmfStatKwd(_myCurrentFileId, MeshFormat::GmfTriangles); - int nbQuad = _reader.GmfStatKwd(_myCurrentFileId, MeshFormat::GmfQuadrilaterals); - int nbTet = _reader.GmfStatKwd( _myCurrentFileId, MeshFormat::GmfTetrahedra ); - int nbPyr = _reader.GmfStatKwd(_myCurrentFileId, MeshFormat::GmfPyramids); - int nbHex = _reader.GmfStatKwd(_myCurrentFileId, MeshFormat::GmfHexahedra); - int nbPrism = _reader.GmfStatKwd(_myCurrentFileId, MeshFormat::GmfPrisms); + int const nbEdges = _reader.GmfStatKwd(_myCurrentFileId, MeshFormat::GmfEdges); + int const nbTria = _reader.GmfStatKwd(_myCurrentFileId, MeshFormat::GmfTriangles); + int const nbQuad = _reader.GmfStatKwd(_myCurrentFileId, MeshFormat::GmfQuadrilaterals); + int const nbTet = _reader.GmfStatKwd( _myCurrentFileId, MeshFormat::GmfTetrahedra ); + int const nbPyr = _reader.GmfStatKwd(_myCurrentFileId, MeshFormat::GmfPyramids); + int const nbHex = _reader.GmfStatKwd(_myCurrentFileId, MeshFormat::GmfHexahedra); + int const nbPrism = _reader.GmfStatKwd(_myCurrentFileId, MeshFormat::GmfPrisms); _dim1NbEl = nbEdges; _dim2NbEl = nbTria + nbQuad; @@ -210,7 +218,7 @@ MeshFormat::Status MeshFormatReader::perform() MeshFormat::Status MeshFormatReader::performFields() { - MeshFormat::Status status = MeshFormat::DRS_OK; + MeshFormat::Status const status = MeshFormat::DRS_OK; _fields = MEDCoupling::MEDFileFields::New(); @@ -250,7 +258,7 @@ MeshFormat::Status MeshFormatReader::performFields() } - MeshFormat::GmfKwdCod kwd = meshFormatSol[0]; + MeshFormat::GmfKwdCod const kwd = meshFormatSol[0]; int NmbSol, NmbTypes, NmbReals, TypesTab[ GmfMaxTyp ]; NmbSol = _reader.GmfStatKwd( _myCurrentFileId, kwd, &NmbTypes, &NmbReals, TypesTab ); if(NmbSol) @@ -310,9 +318,9 @@ void MeshFormatReader::setFields( MeshFormat::GmfKwdCod kwd, int nmbSol, int nbC double* values = fieldValues->getPointer(); int ref; - double *val = new double[nbComp]; + auto *val = new double[nbComp]; - bool isOnAll = (_uMesh->getNumberOfNodes()== nmbSol); + bool const isOnAll = (_uMesh->getNumberOfNodes()== nmbSol); for(int i = 1; i<= nmbSol; i++) @@ -339,7 +347,7 @@ void MeshFormatReader::setFields( MeshFormat::GmfKwdCod kwd, int nmbSol, int nbC timeStamp->setMesh( dimMesh ); - std::string name = "Field_on_Vertex"; + std::string const name = "Field_on_Vertex"; timeStamp->setName(name); timeStamp->setArray(fieldValues); // set an order @@ -409,8 +417,8 @@ void MeshFormatReader::backward_shift(mcIdType* tab, int size) MeshFormat::Status MeshFormatReader::setNodes( MEDCoupling::DataArrayDouble* coordArray) { - MeshFormat::Status status = MeshFormat::DRS_OK; - int nbNodes = _reader.GmfStatKwd(_myCurrentFileId, MeshFormat::GmfVertices); + MeshFormat::Status const status = MeshFormat::DRS_OK; + int const nbNodes = _reader.GmfStatKwd(_myCurrentFileId, MeshFormat::GmfVertices); if ( nbNodes < 1 ) return addMessage( "No nodes in the mesh", /*fatal=*/true ); @@ -436,7 +444,7 @@ MeshFormat::Status MeshFormatReader::setNodes( MEDCoupling::DataArrayDouble* coo nCoords[1] = y; nCoords[2] = z; std::copy(coordPointer, coordPointer+_dim, coordPrt); - MeshFormatElement e(MeshFormat::GmfVertices, i-1); + MeshFormatElement const e(MeshFormat::GmfVertices, i-1); _fams.insert(std::pair (ref, e), 1); coordPrt += _dim; @@ -455,7 +463,7 @@ MeshFormat::Status MeshFormatReader::setNodes( MEDCoupling::DataArrayDouble* coo nCoords[1] = y; nCoords[2] = z; std::copy(coordPointer, coordPointer+_dim, coordPrt); - MeshFormatElement e(MeshFormat::GmfVertices, i-1); + MeshFormatElement const e(MeshFormat::GmfVertices, i-1); _fams.insert(std::pair (ref, e), 1); coordPrt += _dim; } @@ -474,7 +482,7 @@ void MeshFormatReader::setEdges( MEDCoupling::MEDCouplingUMesh* dimMesh1, int nb int ref; // read extra vertices for quadratic edges std::vector quadNodesAtEdges( nbEdges + 1, -1 ); - if ( int nbQuadEdges = _reader.GmfStatKwd(_myCurrentFileId, MeshFormat::GmfExtraVerticesAtEdges)) + if ( int const nbQuadEdges = _reader.GmfStatKwd(_myCurrentFileId, MeshFormat::GmfExtraVerticesAtEdges)) { _reader.GmfGotoKwd(_myCurrentFileId, MeshFormat::GmfExtraVerticesAtEdges); for ( int i = 1; i <= nbQuadEdges; ++i ) @@ -496,7 +504,7 @@ void MeshFormatReader::setEdges( MEDCoupling::MEDCouplingUMesh* dimMesh1, int nb mcIdType nodalConnPerCell[3] = {iN[0], iN[1], midN}; backward_shift(nodalConnPerCell, 3); dimMesh1->insertNextCell(INTERP_KERNEL::NORM_SEG3, 3,nodalConnPerCell); - MeshFormatElement e(MeshFormat::GmfEdges, i-1); + MeshFormatElement const e(MeshFormat::GmfEdges, i-1); _fams.insert(std::pair (ref, e), 1 -_dim); } else @@ -505,7 +513,7 @@ void MeshFormatReader::setEdges( MEDCoupling::MEDCouplingUMesh* dimMesh1, int nb mcIdType nodalConnPerCell[2] = {iN[0], iN[1]}; backward_shift(nodalConnPerCell, 2); dimMesh1->insertNextCell(INTERP_KERNEL::NORM_SEG2, 2,nodalConnPerCell); - MeshFormatElement e(MeshFormat::GmfEdges, i-1); + MeshFormatElement const e(MeshFormat::GmfEdges, i-1); _fams.insert(std::pair (ref, e), 1 -_dim); } } @@ -521,7 +529,7 @@ void MeshFormatReader::setTriangles(MEDCoupling::MEDCouplingUMesh* dimMesh2, int int ref; // read extra vertices for quadratic triangles std::vector< std::vector > quadNodesAtTriangles( nbTria + 1 ); - if ( int nbQuadTria = _reader.GmfStatKwd(_myCurrentFileId, MeshFormat::GmfExtraVerticesAtTriangles )) + if ( int const nbQuadTria = _reader.GmfStatKwd(_myCurrentFileId, MeshFormat::GmfExtraVerticesAtTriangles )) { _reader.GmfGotoKwd( _myCurrentFileId, MeshFormat::GmfExtraVerticesAtTriangles ); for ( int i = 1; i <= nbQuadTria; ++i ) @@ -552,7 +560,7 @@ void MeshFormatReader::setTriangles(MEDCoupling::MEDCouplingUMesh* dimMesh2, int mcIdType nodalConnPerCell[6] = {iN[0], iN[1], iN[2], midN[0], midN[1], midN[2]}; backward_shift(nodalConnPerCell, 6); dimMesh2->insertNextCell(INTERP_KERNEL::NORM_TRI6, 6, nodalConnPerCell); - MeshFormatElement e(MeshFormat::GmfTriangles, i-1); + MeshFormatElement const e(MeshFormat::GmfTriangles, i-1); _fams.insert(std::pair (ref, e), 2 -_dim); } else @@ -560,7 +568,7 @@ void MeshFormatReader::setTriangles(MEDCoupling::MEDCouplingUMesh* dimMesh2, int mcIdType nodalConnPerCell[3] = {iN[0], iN[1], iN[2]}; backward_shift(nodalConnPerCell, 3); dimMesh2->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,nodalConnPerCell); - MeshFormatElement e(MeshFormat::GmfTriangles, i-1); + MeshFormatElement const e(MeshFormat::GmfTriangles, i-1); _fams.insert(std::pair (ref, e), 2 -_dim); } if ( !midN.empty() ) MeshFormat::FreeVector( midN ); @@ -575,7 +583,7 @@ void MeshFormatReader::setQuadrangles( MEDCoupling::MEDCouplingUMesh* dimMesh2, int ref; // read extra vertices for quadratic quadrangles std::vector< std::vector > quadNodesAtQuadrilaterals( nbQuad + 1 ); - if ( int nbQuadQuad = _reader.GmfStatKwd( _myCurrentFileId, MeshFormat::GmfExtraVerticesAtQuadrilaterals )) + if ( int const nbQuadQuad = _reader.GmfStatKwd( _myCurrentFileId, MeshFormat::GmfExtraVerticesAtQuadrilaterals )) { _reader.GmfGotoKwd(_myCurrentFileId, MeshFormat::GmfExtraVerticesAtQuadrilaterals); for ( int i = 1; i <= nbQuadQuad; ++i ) @@ -603,7 +611,7 @@ void MeshFormatReader::setQuadrangles( MEDCoupling::MEDCouplingUMesh* dimMesh2, }; backward_shift(nodalConnPerCell, 8); dimMesh2->insertNextCell(INTERP_KERNEL::NORM_QUAD8,8, nodalConnPerCell); - MeshFormatElement e(MeshFormat::GmfQuadrilaterals, i-1); + MeshFormatElement const e(MeshFormat::GmfQuadrilaterals, i-1); _fams.insert(std::pair (ref, e), 2 -_dim); } else if ( midN.size() > 8-4 ) // QUAD9 @@ -613,7 +621,7 @@ void MeshFormatReader::setQuadrangles( MEDCoupling::MEDCouplingUMesh* dimMesh2, }; backward_shift(nodalConnPerCell, 9); dimMesh2->insertNextCell(INTERP_KERNEL::NORM_QUAD9,9, nodalConnPerCell); - MeshFormatElement e(MeshFormat::GmfQuadrilaterals, i-1); + MeshFormatElement const e(MeshFormat::GmfQuadrilaterals, i-1); _fams.insert(std::pair (ref, e), 2 -_dim); } else // QUAD4 @@ -621,7 +629,7 @@ void MeshFormatReader::setQuadrangles( MEDCoupling::MEDCouplingUMesh* dimMesh2, mcIdType nodalConnPerCell[4] = {iN[0], iN[1], iN[2], iN[3]}; backward_shift(nodalConnPerCell, 4); dimMesh2->insertNextCell(INTERP_KERNEL::NORM_QUAD4, 4, nodalConnPerCell); - MeshFormatElement e(MeshFormat::GmfQuadrilaterals, i-1); + MeshFormatElement const e(MeshFormat::GmfQuadrilaterals, i-1); _fams.insert(std::pair (ref, e), 2 -_dim); } if ( !midN.empty() ) MeshFormat::FreeVector( midN ); @@ -635,7 +643,7 @@ void MeshFormatReader::setTetrahedras( MEDCoupling::MEDCouplingUMesh* dimMesh3, int ref; // read extra vertices for quadratic tetrahedra std::vector< std::vector > quadNodesAtTetrahedra( nbTet + 1 ); - if ( int nbQuadTetra = _reader.GmfStatKwd( _myCurrentFileId, MeshFormat::GmfExtraVerticesAtTetrahedra )) + if ( int const nbQuadTetra = _reader.GmfStatKwd( _myCurrentFileId, MeshFormat::GmfExtraVerticesAtTetrahedra )) { _reader.GmfGotoKwd(_myCurrentFileId, MeshFormat::GmfExtraVerticesAtTetrahedra); for ( int i = 1; i <= nbQuadTetra; ++i ) @@ -663,7 +671,7 @@ void MeshFormatReader::setTetrahedras( MEDCoupling::MEDCouplingUMesh* dimMesh3, }; backward_shift(nodalConnPerCell, 10); dimMesh3->insertNextCell(INTERP_KERNEL::NORM_TETRA10, 10,nodalConnPerCell); - MeshFormatElement e(MeshFormat::GmfTetrahedra, i-1); + MeshFormatElement const e(MeshFormat::GmfTetrahedra, i-1); _fams.insert(std::pair (ref, e), 3 -_dim); } else // TETRA4 @@ -671,7 +679,7 @@ void MeshFormatReader::setTetrahedras( MEDCoupling::MEDCouplingUMesh* dimMesh3, mcIdType nodalConnPerCell[4] = {iN[0], iN[2], iN[1], iN[3]}; backward_shift(nodalConnPerCell, 4); dimMesh3->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4, nodalConnPerCell); - MeshFormatElement e(MeshFormat::GmfTetrahedra, i-1); + MeshFormatElement const e(MeshFormat::GmfTetrahedra, i-1); _fams.insert(std::pair (ref, e), 3 -_dim); } if ( !midN.empty() ) MeshFormat::FreeVector( midN ); @@ -691,7 +699,7 @@ void MeshFormatReader::setPyramids( MEDCoupling::MEDCouplingUMesh* dimMesh3, int mcIdType nodalConnPerCell[5] = {iN[3], iN[2], iN[1], iN[0], iN[4]}; backward_shift(nodalConnPerCell, 5); dimMesh3->insertNextCell(INTERP_KERNEL::NORM_PYRA5, 5,nodalConnPerCell); - MeshFormatElement e(MeshFormat::GmfPyramids, i-1); + MeshFormatElement const e(MeshFormat::GmfPyramids, i-1); _fams.insert(std::pair (ref, e), 3 -_dim); } @@ -704,7 +712,7 @@ void MeshFormatReader::setHexahedras( MEDCoupling::MEDCouplingUMesh* dimMesh3, i int ref; // read extra vertices for quadratic hexahedra std::vector< std::vector > quadNodesAtHexahedra( nbHex + 1 ); - if ( int nbQuadHexa = _reader.GmfStatKwd( _myCurrentFileId, MeshFormat::GmfExtraVerticesAtHexahedra )) + if ( int const nbQuadHexa = _reader.GmfStatKwd( _myCurrentFileId, MeshFormat::GmfExtraVerticesAtHexahedra )) { _reader.GmfGotoKwd(_myCurrentFileId, MeshFormat::GmfExtraVerticesAtHexahedra); for ( int i = 1; i <= nbQuadHexa; ++i ) @@ -744,7 +752,7 @@ void MeshFormatReader::setHexahedras( MEDCoupling::MEDCouplingUMesh* dimMesh3, i }; backward_shift(nodalConnPerCell, 20); dimMesh3->insertNextCell(INTERP_KERNEL::NORM_HEXA20,20, nodalConnPerCell); - MeshFormatElement e(MeshFormat::GmfHexahedra, i-1); + MeshFormatElement const e(MeshFormat::GmfHexahedra, i-1); _fams.insert(std::pair (ref, e), 3 -_dim); @@ -763,7 +771,7 @@ void MeshFormatReader::setHexahedras( MEDCoupling::MEDCouplingUMesh* dimMesh3, i }; backward_shift(nodalConnPerCell, 27); dimMesh3->insertNextCell(INTERP_KERNEL::NORM_HEXA27,27, nodalConnPerCell); - MeshFormatElement e(MeshFormat::GmfHexahedra, i-1); + MeshFormatElement const e(MeshFormat::GmfHexahedra, i-1); _fams.insert(std::pair (ref, e), 3 -_dim); } @@ -774,7 +782,7 @@ void MeshFormatReader::setHexahedras( MEDCoupling::MEDCouplingUMesh* dimMesh3, i }; backward_shift(nodalConnPerCell, 8); dimMesh3->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8, nodalConnPerCell); - MeshFormatElement e(MeshFormat::GmfHexahedra, i-1); + MeshFormatElement const e(MeshFormat::GmfHexahedra, i-1); _fams.insert(std::pair (ref, e), 3 -_dim); } @@ -797,7 +805,7 @@ void MeshFormatReader::setPrisms(MEDCoupling::MEDCouplingUMesh* dimMesh3, int nb mcIdType nodalConnPerCell[8] = {iN[0], iN[2], iN[1], iN[3], iN[5], iN[4]}; backward_shift(nodalConnPerCell, 8); dimMesh3->insertNextCell(INTERP_KERNEL::NORM_PENTA6, 6,nodalConnPerCell); - MeshFormatElement e(MeshFormat::GmfPrisms, i-1); + MeshFormatElement const e(MeshFormat::GmfPrisms, i-1); _fams.insert(std::pair (ref, e), 3 -_dim); } @@ -877,7 +885,7 @@ void MeshFormatReader::setTypeOfFieldAndDimRel(MeshFormat::GmfKwdCod kwd, MEDCou } -INTERP_KERNEL::NormalizedCellType MeshFormatReader::toMedType(MeshFormat::GmfKwdCod kwd) +INTERP_KERNEL::NormalizedCellType MeshFormatReader::toMedType(MeshFormat::GmfKwdCod /*kwd*/) { INTERP_KERNEL::NormalizedCellType type; //~switch (kwd) @@ -919,13 +927,12 @@ void MeshFormatReader::buildFamilies() void MeshFormatReader::buildCellsFamilies() { - std::vector levs = _uMesh->getNonEmptyLevels(); - for (size_t iDim = 0; iDim const levs = _uMesh->getNonEmptyLevels(); + for (int const dimRelMax : levs) { - int dimRelMax = levs[iDim]; std::map * > famDim = _fams.getMapAtLevel(dimRelMax); std::map * >::const_iterator _meshFormatFamsIt = famDim.begin(); - std::vector< const MEDCoupling::DataArrayIdType* > fams; + std::vector< const MEDCoupling::DataArrayIdType* > const fams; MEDCoupling::DataArrayIdType* cellIds = MEDCoupling::DataArrayIdType::New(); cellIds->alloc(_uMesh->getSizeAtLevel(dimRelMax), 1); cellIds->fillWithZero(); @@ -933,10 +940,10 @@ void MeshFormatReader::buildCellsFamilies() for(; _meshFormatFamsIt!= famDim.end(); ++_meshFormatFamsIt) { const int famId = _meshFormatFamsIt->first; - std::string famName ="FromMeshGemsFormatAttributFamily_"+std::to_string(famId); + std::string const famName ="FromMeshGemsFormatAttributFamily_"+std::to_string(famId); std::vector * cellsInFam = _meshFormatFamsIt->second; if (!famId) continue; - std::vector ::iterator cellsInFamIt = cellsInFam->begin(); + auto cellsInFamIt = cellsInFam->begin(); _uMesh->addFamily(famName, famId); for ( ; cellsInFamIt !=cellsInFam->end(); ++cellsInFamIt) @@ -954,11 +961,11 @@ void MeshFormatReader::buildCellsFamilies() void MeshFormatReader::buildNodesFamilies() { - std::vector levs = _uMesh->getNonEmptyLevels(); - int dimRelMax = 1; + std::vector const levs = _uMesh->getNonEmptyLevels(); + int const dimRelMax = 1; std::map * > famDim = _fams.getMapAtLevel(dimRelMax); std::map * >::const_iterator _meshFormatFamsIt = famDim.begin(); - std::vector< const MEDCoupling::DataArrayIdType* > fams; + std::vector< const MEDCoupling::DataArrayIdType* > const fams; MEDCoupling::DataArrayIdType* cellIds = MEDCoupling::DataArrayIdType::New(); cellIds->alloc(_uMesh->getSizeAtLevel(dimRelMax), 1); cellIds->fillWithZero(); @@ -969,11 +976,10 @@ void MeshFormatReader::buildNodesFamilies() if (!famId) continue; bool thisIsACellFamily = false; - for (size_t iDim = 0; iDim* > famDimAtLevel = _fams.getMapAtLevel(dimMesh); - std::map * >::iterator famDimAtLevelId = famDimAtLevel.find(famId); + auto const famDimAtLevelId = famDimAtLevel.find(famId); if (famDimAtLevelId != famDimAtLevel.end()) { thisIsACellFamily = true; @@ -983,9 +989,9 @@ void MeshFormatReader::buildNodesFamilies() } if (thisIsACellFamily) continue; - std::string famName ="FromMeshGemsFormatAttributFamily_"+std::to_string(famId); + std::string const famName ="FromMeshGemsFormatAttributFamily_"+std::to_string(famId); std::vector * cellsInFam = _meshFormatFamsIt->second; - std::vector ::iterator cellsInFamIt = cellsInFam->begin(); + auto cellsInFamIt = cellsInFam->begin(); _uMesh->addFamily(famName, famId); for ( ; cellsInFamIt !=cellsInFam->end(); ++cellsInFamIt) diff --git a/src/MEDLoader/MeshFormatReader.hxx b/src/MEDLoader/MeshFormatReader.hxx index d87929d6b..7e6863987 100644 --- a/src/MEDLoader/MeshFormatReader.hxx +++ b/src/MEDLoader/MeshFormatReader.hxx @@ -25,18 +25,17 @@ #include #include #include -#include #include "MCAuto.hxx" #include "InterpKernelException.hxx" -#include "NormalizedUnstructuredMesh.hxx" +#include "MEDLoaderDefines.hxx" +#include "MEDCouplingRefCountObject.hxx" #include "MCType.hxx" #include "MEDMESHConverterUtilities.hxx" #include "libmesh5.hxx" +#include "NormalizedGeometricTypes" -#include #if !defined(WIN32) && !defined(__APPLE__) -#include #endif namespace MEDCoupling @@ -80,14 +79,14 @@ namespace MEDCoupling private: void insertPairInMap(std::map *> &aMap, std::pair addToFamily) { - std::map *>::iterator it = aMap.find(addToFamily.first); + auto const it = aMap.find(addToFamily.first); if (it != aMap.end()) { aMap[addToFamily.first]->push_back(addToFamily.second); } else { - std::vector *tmpVec = new std::vector; + auto *tmpVec = new std::vector; tmpVec->push_back(addToFamily.second); aMap.insert(std::pair *>(addToFamily.first, tmpVec)); } @@ -106,7 +105,7 @@ namespace MEDCoupling if (!aMap.size()) return; - std::map *>::iterator itTmp = aMap.find(removeFromFamily.first); + auto const itTmp = aMap.find(removeFromFamily.first); if (itTmp == aMap.end()) return; else @@ -161,7 +160,7 @@ namespace MEDCoupling private: void freeMap(std::map *> &aMap) { - std::map *>::iterator it = aMap.begin(); + auto it = aMap.begin(); for (; it != aMap.end(); ++it) delete it->second; } diff --git a/src/MEDLoader/MeshFormatWriter.cxx b/src/MEDLoader/MeshFormatWriter.cxx index d86046d4b..8cccf678b 100644 --- a/src/MEDLoader/MeshFormatWriter.cxx +++ b/src/MEDLoader/MeshFormatWriter.cxx @@ -18,29 +18,37 @@ // #include "MeshFormatWriter.hxx" +#include "MEDFileFieldMultiTS.hxx" +#include "MCAuto.hxx" +#include "MEDCouplingUMesh.hxx" +#include "MCType.hxx" +#include "MEDCouplingRefCountObject.hxx" #include "MEDFileMesh.hxx" #include "MEDFileField.hxx" #include "MEDFileData.hxx" #include "MEDCouplingFieldDouble.hxx" +#include "NormalizedGeometricTypes" #include "libmesh5.hxx" #include "MEDMESHConverterUtilities.hxx" #include #include -#include #include -#include +#include +#include +#include +#include namespace MEDCoupling { MeshFormatWriter::MeshFormatWriter() -{} += default; MeshFormatWriter::MeshFormatWriter(const std::string& meshFileName, const std::vector& fieldFileNames):_meshFileName(meshFileName), _fieldFileNames(fieldFileNames) {} MeshFormatWriter::~MeshFormatWriter() -{} += default; void MeshFormatWriter::setMeshFileName(const std::string& meshFileName) { _meshFileName = meshFileName; @@ -90,7 +98,7 @@ void MeshFormatWriter::setMEDFileDS(MEDCoupling::MEDFileData* mfd) void MeshFormatWriter::write() { - MeshFormat::Localizer loc; + MeshFormat::Localizer const loc; MEDCoupling::MCAuto mesh = _mesh->getMeshAtLevel( 1 ); MEDCoupling::MCAuto< MEDCoupling::MEDCouplingUMesh > umesh = mesh->buildUnstructured(); @@ -145,15 +153,15 @@ MeshFormat::Status MeshFormatWriter::perform() MEDCoupling::MCAuto< MEDCoupling::MEDCouplingUMesh > umesh3; std::vector dims = _mesh->getNonEmptyLevelsExt(); - int dim = _mesh->getMeshDimension(); + int const dim = _mesh->getMeshDimension(); bool threeDElements = false; bool twoDElements = false; bool OneDElements = false; if (dims.size() != 0) { - bool maxLevelDimElments = ( std::find(dims.begin(), dims.end(), 0) != dims.end() ); - bool nextToMaxLevelDimElments = ( std::find(dims.begin(), dims.end(), -1) != dims.end() ); - bool nextToNextToMaxLevelDimElments = (std::find(dims.begin(), dims.end(), -2) != dims.end() ); + bool const maxLevelDimElments = ( std::find(dims.begin(), dims.end(), 0) != dims.end() ); + bool const nextToMaxLevelDimElments = ( std::find(dims.begin(), dims.end(), -1) != dims.end() ); + bool const nextToNextToMaxLevelDimElments = (std::find(dims.begin(), dims.end(), -2) != dims.end() ); threeDElements = (dim == 3) ? maxLevelDimElments : false ; twoDElements = (dim == 3) ? nextToMaxLevelDimElments : maxLevelDimElments ; OneDElements = (dim == 3) ? nextToNextToMaxLevelDimElments : nextToMaxLevelDimElments; @@ -222,7 +230,7 @@ MeshFormat::Status MeshFormatWriter::perform() MEDCoupling::MCAuto< MEDCoupling::MEDCouplingMesh > mesh0 = _mesh->getMeshAtLevel(1); - MEDCoupling::MCAuto< MEDCoupling::MEDCouplingUMesh > umesh0 = mesh0->buildUnstructured(); + MEDCoupling::MCAuto< MEDCoupling::MEDCouplingUMesh > const umesh0 = mesh0->buildUnstructured(); // nodes getNodes(umesh0); @@ -330,10 +338,10 @@ MeshFormat::Status MeshFormatWriter::performFields() } - int dim = _mesh->getMeshDimension(); // dim mesh field lying to + int const dim = _mesh->getMeshDimension(); // dim mesh field lying to std::vector::const_iterator fieldFileIt = _fieldFileNames.begin(); int iField = 0; - std::vector levs {0} ; + std::vector const levs {0} ; for (; fieldFileIt !=_fieldFileNames.end(); ++fieldFileIt) { // Open files @@ -349,7 +357,7 @@ MeshFormat::Status MeshFormatWriter::performFields() std::vector< std::vector > fTypes = f->getTypesOfFieldAvailable(); std::vector< std::pair > iters = f->getIterations(); const std::vector& compInfo = f->getInfo(); - std::pair it = iters[0]; + std::pair const it = iters[0]; //~// Open File for writing _myCurrentFileId = _writer.GmfOpenMesh( fieldFileIt->c_str(), GmfWrite, _version, _dim ); @@ -388,7 +396,7 @@ MeshFormat::Status MeshFormatWriter::setFieldOnNodes(MEDCoupling::MEDFileFieldMu const MEDCoupling::DataArrayDouble* valsArray = f->getUndergroundDataArray(iteration, order); int typTab[] = { getGmfSolKwd((int)compSize, _dim) }; _writer.GmfSetKwd(_myCurrentFileId, MeshFormat::GmfSolAtVertices, (int)valsVec[0][0].second, 1, typTab); - double* valTab0 = new double[compSize]; + auto* valTab0 = new double[compSize]; double* valTab; for ( size_t i = valsVec[0][0].first; i < (std::size_t)valsVec[0][0].second; ++i ) { @@ -415,11 +423,11 @@ MeshFormat::Status MeshFormatWriter::setFieldOnNodes(MEDCoupling::MEDFileFieldMu MeshFormat::Status MeshFormatWriter::setFieldOnCells(MEDCoupling::MEDFileFieldMultiTS * f, int iteration, int order, std::vector levs ) { - int dim = _mesh->getMeshDimension(); // dim mesh field lying to - int absDim = f->getNonEmptyLevels(iteration, order, f->getMeshName(), levs); + int const dim = _mesh->getMeshDimension(); // dim mesh field lying to + int const absDim = f->getNonEmptyLevels(iteration, order, f->getMeshName(), levs); - MEDCoupling::MEDCouplingFieldDouble** cellToNodeFldb = new MEDCoupling::MEDCouplingFieldDouble* [(int)levs.size()] ; - MEDCoupling::MEDCouplingFieldDouble** fldb = new MEDCoupling::MEDCouplingFieldDouble* [(int)levs.size()] ; + auto** cellToNodeFldb = new MEDCoupling::MEDCouplingFieldDouble* [(int)levs.size()] ; + auto** fldb = new MEDCoupling::MEDCouplingFieldDouble* [(int)levs.size()] ; for (size_t k = 0; kfield( iteration, order,_mesh ); @@ -435,7 +443,7 @@ MeshFormat::Status MeshFormatWriter::setFieldOnCells(MEDCoupling::MEDFileFieldMu MEDCoupling::DataArrayDouble* timeStamp = cellToNodeFldb[j]->getArray(); double* values = timeStamp->getPointer(); - int typ = getGmfSolKwd((int)nbComp, _dim) ; + int const typ = getGmfSolKwd((int)nbComp, _dim) ; if(typ == -1) { addMessage( MeshFormat::Comment(" error with Number of Component ") << nbComp, /*fatal=*/true ); @@ -497,7 +505,7 @@ void MeshFormatWriter::extractSymetricTensor(double fullTensor[], double*& symTe for (int ii =0; ii<_dim; ii++) for (int jj =ii; jj<_dim; jj++) { - int kk = _dim*(_dim-1)/2- (_dim-ii)*(_dim-ii-1)/2+jj; + int const kk = _dim*(_dim-1)/2- (_dim-ii)*(_dim-ii-1)/2+jj; symTensor[kk] = fullTensor[ii+jj*_dim]; } } @@ -511,12 +519,12 @@ int MeshFormatWriter::getGmfSolKwd(const int nbComp, const int dim) } bool MeshFormatWriter::checkFileName() { - bool ret = true; + bool const ret = true; return ret; } bool MeshFormatWriter::checkFieldFileName() { - bool ret = true; + bool const ret = true; return ret; } @@ -550,7 +558,7 @@ MeshFormat::Status MeshFormatWriter::addMessage(const std::string& msg, void MeshFormatWriter::forward_shift(std::vector &conn) { - std::vector::iterator it = conn.begin(); + auto it = conn.begin(); for (; it != conn.end(); ++it) *it = *it+1; } @@ -575,7 +583,7 @@ void MeshFormatWriter::getNodes(MEDCoupling::MCAuto< MEDCoupling::MEDCouplingUMe std::copy(coordPrt, coordPrt+_dim, xyz); - MeshFormatNode e(xyz[0], xyz[1], xyz[2], idNode); + MeshFormatNode const e(xyz[0], xyz[1], xyz[2], idNode); _idNodeToNode.insert(std::pair (idNode, e)); coordPrt+= _dim; @@ -583,7 +591,7 @@ void MeshFormatWriter::getNodes(MEDCoupling::MCAuto< MEDCoupling::MEDCouplingUMe idNode++; } linkFamilyToNodes(); - std::map ::iterator itNode = _idNodeToNode.begin(); + auto itNode = _idNodeToNode.begin(); for (; itNode!= _idNodeToNode.end(); ++itNode) _dim == 3? _writer.GmfSetLin( _myCurrentFileId, MeshFormat::GmfVertices, itNode->second.xyz[0], itNode->second.xyz[1], itNode->second.xyz[2], std::abs(itNode->second._famId) ) : @@ -592,247 +600,247 @@ void MeshFormatWriter::getNodes(MEDCoupling::MCAuto< MEDCoupling::MEDCouplingUMe } -void MeshFormatWriter::getNSEG2(MEDCoupling::mcIdType nbEdgesNSEG2, MEDCoupling::MCAuto< MEDCoupling::MEDCouplingUMesh > umesh1) +void MeshFormatWriter::getNSEG2(MEDCoupling::mcIdType /*nbEdgesNSEG2*/, MEDCoupling::MCAuto< MEDCoupling::MEDCouplingUMesh > umesh1) { MEDCoupling::MCAuto elementId = umesh1->giveCellsWithType(INTERP_KERNEL::NORM_SEG2); std::map idCellToCell; - for ( const mcIdType *it=elementId->begin(); it!=elementId->end(); it++ ) + for (long const it : *elementId) { std::vector conn; - umesh1->getNodeIdsOfCell(*it, conn) ; + umesh1->getNodeIdsOfCell(it, conn) ; forward_shift(conn); - MeshFormatCell e(INTERP_KERNEL::NORM_SEG2, (int)*it); + MeshFormatCell e(INTERP_KERNEL::NORM_SEG2, (int)it); e.setConn(conn); - idCellToCell.insert(std::pair (*it, e)); + idCellToCell.insert(std::pair (it, e)); } _typeToIdCellToCell.insert(std::pair >(INTERP_KERNEL::NORM_SEG2, idCellToCell) ); } -void MeshFormatWriter::getNSEG3( MEDCoupling::mcIdType nbEdgesNSEG3, MEDCoupling::MCAuto< MEDCoupling::MEDCouplingUMesh > umesh1) +void MeshFormatWriter::getNSEG3( MEDCoupling::mcIdType /*nbEdgesNSEG3*/, MEDCoupling::MCAuto< MEDCoupling::MEDCouplingUMesh > umesh1) { MEDCoupling::MCAuto elementId = umesh1->giveCellsWithType(INTERP_KERNEL::NORM_SEG3); std::map idCellToCell; - for ( const mcIdType *it=elementId->begin(); it!=elementId->end(); it++ ) + for (long const it : *elementId) { std::vector conn; - umesh1->getNodeIdsOfCell(*it, conn) ; + umesh1->getNodeIdsOfCell(it, conn) ; forward_shift(conn); - MeshFormatCell e(INTERP_KERNEL::NORM_SEG3, (int)*it); + MeshFormatCell e(INTERP_KERNEL::NORM_SEG3, (int)it); e.setConn(conn); - idCellToCell.insert(std::pair (*it, e)); + idCellToCell.insert(std::pair (it, e)); } _typeToIdCellToCell.insert(std::pair >(INTERP_KERNEL::NORM_SEG3, idCellToCell) ); } -void MeshFormatWriter::getTRI3( MEDCoupling::mcIdType nbTRI3, MEDCoupling::MCAuto< MEDCoupling::MEDCouplingUMesh > umesh2) +void MeshFormatWriter::getTRI3( MEDCoupling::mcIdType /*nbTRI3*/, MEDCoupling::MCAuto< MEDCoupling::MEDCouplingUMesh > umesh2) { MEDCoupling::MCAuto elementId = umesh2->giveCellsWithType(INTERP_KERNEL::NORM_TRI3); std::map idCellToCell; - for ( const mcIdType *it=elementId->begin(); it!=elementId->end(); it++ ) + for (long const it : *elementId) { std::vector conn; - umesh2->getNodeIdsOfCell(*it, conn) ; + umesh2->getNodeIdsOfCell(it, conn) ; forward_shift(conn); - MeshFormatCell e(INTERP_KERNEL::NORM_TRI3, (int)*it); + MeshFormatCell e(INTERP_KERNEL::NORM_TRI3, (int)it); e.setConn(conn); - idCellToCell.insert(std::pair (*it, e)); + idCellToCell.insert(std::pair (it, e)); } _typeToIdCellToCell.insert(std::pair >(INTERP_KERNEL::NORM_TRI3, idCellToCell) ); } -void MeshFormatWriter::getTRI6( MEDCoupling::mcIdType nbTRI6, MEDCoupling::MCAuto< MEDCoupling::MEDCouplingUMesh > umesh2) +void MeshFormatWriter::getTRI6( MEDCoupling::mcIdType /*nbTRI6*/, MEDCoupling::MCAuto< MEDCoupling::MEDCouplingUMesh > umesh2) { MEDCoupling::MCAuto elementId = umesh2->giveCellsWithType(INTERP_KERNEL::NORM_TRI6); std::map idCellToCell; - for ( const mcIdType *it=elementId->begin(); it!=elementId->end(); it++ ) + for (long const it : *elementId) { std::vector conn; - umesh2->getNodeIdsOfCell(*it, conn) ; + umesh2->getNodeIdsOfCell(it, conn) ; forward_shift(conn); - MeshFormatCell e(INTERP_KERNEL::NORM_TRI6, (int)*it); + MeshFormatCell e(INTERP_KERNEL::NORM_TRI6, (int)it); e.setConn(conn); - idCellToCell.insert(std::pair (*it, e)); + idCellToCell.insert(std::pair (it, e)); } _typeToIdCellToCell.insert(std::pair >(INTERP_KERNEL::NORM_TRI6, idCellToCell) ); } -void MeshFormatWriter::getQUAD4( MEDCoupling::mcIdType nbQUAD4, MEDCoupling::MCAuto< MEDCoupling::MEDCouplingUMesh > umesh2) +void MeshFormatWriter::getQUAD4( MEDCoupling::mcIdType /*nbQUAD4*/, MEDCoupling::MCAuto< MEDCoupling::MEDCouplingUMesh > umesh2) { MEDCoupling::MCAuto elementId = umesh2->giveCellsWithType(INTERP_KERNEL::NORM_QUAD4); std::map idCellToCell; - for ( const mcIdType *it=elementId->begin(); it!=elementId->end(); it++ ) + for (long const it : *elementId) { std::vector conn; - umesh2->getNodeIdsOfCell(*it, conn) ; + umesh2->getNodeIdsOfCell(it, conn) ; forward_shift(conn); - MeshFormatCell e(INTERP_KERNEL::NORM_QUAD4, (int)*it); + MeshFormatCell e(INTERP_KERNEL::NORM_QUAD4, (int)it); e.setConn(conn); - idCellToCell.insert(std::pair (*it, e)); + idCellToCell.insert(std::pair (it, e)); } _typeToIdCellToCell.insert(std::pair >(INTERP_KERNEL::NORM_QUAD4, idCellToCell) ); } -void MeshFormatWriter::getQUAD8(MEDCoupling::mcIdType nbQUAD8, MEDCoupling::MCAuto< MEDCoupling::MEDCouplingUMesh > umesh2) +void MeshFormatWriter::getQUAD8(MEDCoupling::mcIdType /*nbQUAD8*/, MEDCoupling::MCAuto< MEDCoupling::MEDCouplingUMesh > umesh2) { MEDCoupling::MCAuto elementId = umesh2->giveCellsWithType(INTERP_KERNEL::NORM_QUAD8); std::map idCellToCell; - for ( const mcIdType *it=elementId->begin(); it!=elementId->end(); it++ ) + for (long const it : *elementId) { std::vector conn; - umesh2->getNodeIdsOfCell(*it, conn) ; + umesh2->getNodeIdsOfCell(it, conn) ; forward_shift(conn); - MeshFormatCell e(INTERP_KERNEL::NORM_QUAD8, (int)*it); + MeshFormatCell e(INTERP_KERNEL::NORM_QUAD8, (int)it); e.setConn(conn); - idCellToCell.insert(std::pair (*it, e)); + idCellToCell.insert(std::pair (it, e)); } _typeToIdCellToCell.insert(std::pair >(INTERP_KERNEL::NORM_QUAD8, idCellToCell) ); } -void MeshFormatWriter::getQUAD9(MEDCoupling::mcIdType nbQUAD9, MEDCoupling::MCAuto< MEDCoupling::MEDCouplingUMesh > umesh2) +void MeshFormatWriter::getQUAD9(MEDCoupling::mcIdType /*nbQUAD9*/, MEDCoupling::MCAuto< MEDCoupling::MEDCouplingUMesh > umesh2) { MEDCoupling::MCAuto elementId = umesh2->giveCellsWithType(INTERP_KERNEL::NORM_QUAD9); std::map idCellToCell; - for ( const mcIdType *it=elementId->begin(); it!=elementId->end(); it++ ) + for (long const it : *elementId) { std::vector conn; - umesh2->getNodeIdsOfCell(*it, conn) ; + umesh2->getNodeIdsOfCell(it, conn) ; forward_shift(conn); - MeshFormatCell e(INTERP_KERNEL::NORM_QUAD9, (int)*it); + MeshFormatCell e(INTERP_KERNEL::NORM_QUAD9, (int)it); e.setConn(conn); - idCellToCell.insert(std::pair (*it, e)); + idCellToCell.insert(std::pair (it, e)); } _typeToIdCellToCell.insert(std::pair >(INTERP_KERNEL::NORM_QUAD9, idCellToCell) ); } -void MeshFormatWriter::getTETRA4(MEDCoupling::mcIdType nbTETRA4, MEDCoupling::MCAuto< MEDCoupling::MEDCouplingUMesh > umesh3) +void MeshFormatWriter::getTETRA4(MEDCoupling::mcIdType /*nbTETRA4*/, MEDCoupling::MCAuto< MEDCoupling::MEDCouplingUMesh > umesh3) { MEDCoupling::MCAuto elementId = umesh3->giveCellsWithType(INTERP_KERNEL::NORM_TETRA4); std::map idCellToCell; - for ( const mcIdType *it=elementId->begin(); it!=elementId->end(); it++ ) + for (long const it : *elementId) { std::vector conn; - umesh3->getNodeIdsOfCell(*it, conn) ; + umesh3->getNodeIdsOfCell(it, conn) ; forward_shift(conn); - MeshFormatCell e(INTERP_KERNEL::NORM_TETRA4, (int)*it); + MeshFormatCell e(INTERP_KERNEL::NORM_TETRA4, (int)it); e.setConn(conn); - idCellToCell.insert(std::pair (*it, e)); + idCellToCell.insert(std::pair (it, e)); } _typeToIdCellToCell.insert(std::pair >(INTERP_KERNEL::NORM_TETRA4, idCellToCell) ); } -void MeshFormatWriter::getTETRA10(MEDCoupling::mcIdType nbTETRA10, MEDCoupling::MCAuto< MEDCoupling::MEDCouplingUMesh > umesh3) +void MeshFormatWriter::getTETRA10(MEDCoupling::mcIdType /*nbTETRA10*/, MEDCoupling::MCAuto< MEDCoupling::MEDCouplingUMesh > umesh3) { MEDCoupling::MCAuto elementId = umesh3->giveCellsWithType(INTERP_KERNEL::NORM_TETRA10); std::map idCellToCell; - for ( const mcIdType *it=elementId->begin(); it!=elementId->end(); it++ ) + for (long const it : *elementId) { std::vector conn; - umesh3->getNodeIdsOfCell(*it, conn) ; + umesh3->getNodeIdsOfCell(it, conn) ; forward_shift(conn); - MeshFormatCell e(INTERP_KERNEL::NORM_TETRA10, (int)*it); + MeshFormatCell e(INTERP_KERNEL::NORM_TETRA10, (int)it); e.setConn(conn); - idCellToCell.insert(std::pair (*it, e)); + idCellToCell.insert(std::pair (it, e)); } _typeToIdCellToCell.insert(std::pair >(INTERP_KERNEL::NORM_TETRA10, idCellToCell) ); } -void MeshFormatWriter::getPYRA5(MEDCoupling::mcIdType nbPYRA5, MEDCoupling::MCAuto< MEDCoupling::MEDCouplingUMesh > umesh3) +void MeshFormatWriter::getPYRA5(MEDCoupling::mcIdType /*nbPYRA5*/, MEDCoupling::MCAuto< MEDCoupling::MEDCouplingUMesh > umesh3) { MEDCoupling::MCAuto elementId = umesh3->giveCellsWithType(INTERP_KERNEL::NORM_PYRA5); std::map idCellToCell; - for ( const mcIdType *it=elementId->begin(); it!=elementId->end(); it++ ) + for (long const it : *elementId) { std::vector conn; - umesh3->getNodeIdsOfCell(*it, conn) ; + umesh3->getNodeIdsOfCell(it, conn) ; forward_shift(conn); - MeshFormatCell e(INTERP_KERNEL::NORM_PYRA5, (int)*it); + MeshFormatCell e(INTERP_KERNEL::NORM_PYRA5, (int)it); e.setConn(conn); - idCellToCell.insert(std::pair (*it, e)); + idCellToCell.insert(std::pair (it, e)); } _typeToIdCellToCell.insert(std::pair >(INTERP_KERNEL::NORM_PYRA5, idCellToCell) ); } -void MeshFormatWriter::getHEXA8(MEDCoupling::mcIdType nbHEXA8, MEDCoupling::MCAuto< MEDCoupling::MEDCouplingUMesh > umesh3) +void MeshFormatWriter::getHEXA8(MEDCoupling::mcIdType /*nbHEXA8*/, MEDCoupling::MCAuto< MEDCoupling::MEDCouplingUMesh > umesh3) { MEDCoupling::MCAuto elementId = umesh3->giveCellsWithType(INTERP_KERNEL::NORM_HEXA8); std::map idCellToCell; - for ( const mcIdType *it=elementId->begin(); it!=elementId->end(); it++ ) + for (long const it : *elementId) { std::vector conn; - umesh3->getNodeIdsOfCell(*it, conn) ; + umesh3->getNodeIdsOfCell(it, conn) ; forward_shift(conn); - MeshFormatCell e(INTERP_KERNEL::NORM_HEXA8, (int)*it); + MeshFormatCell e(INTERP_KERNEL::NORM_HEXA8, (int)it); e.setConn(conn); - idCellToCell.insert(std::pair (*it, e)); + idCellToCell.insert(std::pair (it, e)); } _typeToIdCellToCell.insert(std::pair >(INTERP_KERNEL::NORM_HEXA8, idCellToCell) ); } -void MeshFormatWriter::getHEXA20(MEDCoupling::mcIdType nbHEXA20, MEDCoupling::MCAuto< MEDCoupling::MEDCouplingUMesh > umesh3) +void MeshFormatWriter::getHEXA20(MEDCoupling::mcIdType /*nbHEXA20*/, MEDCoupling::MCAuto< MEDCoupling::MEDCouplingUMesh > umesh3) { MEDCoupling::MCAuto elementId = umesh3->giveCellsWithType(INTERP_KERNEL::NORM_HEXA20); std::map idCellToCell; - for ( const mcIdType *it=elementId->begin(); it!=elementId->end(); it++ ) + for (long const it : *elementId) { std::vector conn; - umesh3->getNodeIdsOfCell(*it, conn) ; + umesh3->getNodeIdsOfCell(it, conn) ; forward_shift(conn); - MeshFormatCell e(INTERP_KERNEL::NORM_HEXA20, (int)*it); + MeshFormatCell e(INTERP_KERNEL::NORM_HEXA20, (int)it); e.setConn(conn); - idCellToCell.insert(std::pair (*it, e)); + idCellToCell.insert(std::pair (it, e)); } _typeToIdCellToCell.insert(std::pair >(INTERP_KERNEL::NORM_HEXA20, idCellToCell) ); } -void MeshFormatWriter::getHEXA27(MEDCoupling::mcIdType nbHEXA27, MEDCoupling::MCAuto< MEDCoupling::MEDCouplingUMesh > umesh3) +void MeshFormatWriter::getHEXA27(MEDCoupling::mcIdType /*nbHEXA27*/, MEDCoupling::MCAuto< MEDCoupling::MEDCouplingUMesh > umesh3) { MEDCoupling::MCAuto elementId = umesh3->giveCellsWithType(INTERP_KERNEL::NORM_HEXA27); std::map idCellToCell; - for ( const mcIdType *it=elementId->begin(); it!=elementId->end(); it++ ) + for (long const it : *elementId) { std::vector conn; - umesh3->getNodeIdsOfCell(*it, conn) ; + umesh3->getNodeIdsOfCell(it, conn) ; forward_shift(conn); - MeshFormatCell e(INTERP_KERNEL::NORM_HEXA27, (int)*it); + MeshFormatCell e(INTERP_KERNEL::NORM_HEXA27, (int)it); e.setConn(conn); - idCellToCell.insert(std::pair (*it, e)); + idCellToCell.insert(std::pair (it, e)); } _typeToIdCellToCell.insert(std::pair >(INTERP_KERNEL::NORM_HEXA27, idCellToCell) ); } -void MeshFormatWriter::getPENTA6(MEDCoupling::mcIdType nbPENTA6, MEDCoupling::MCAuto< MEDCoupling::MEDCouplingUMesh > umesh3) +void MeshFormatWriter::getPENTA6(MEDCoupling::mcIdType /*nbPENTA6*/, MEDCoupling::MCAuto< MEDCoupling::MEDCouplingUMesh > umesh3) { MEDCoupling::MCAuto elementId = umesh3->giveCellsWithType(INTERP_KERNEL::NORM_PENTA6); std::map idCellToCell; - for ( const mcIdType *it=elementId->begin(); it!=elementId->end(); it++ ) + for (long const it : *elementId) { std::vector conn; - umesh3->getNodeIdsOfCell(*it, conn) ; + umesh3->getNodeIdsOfCell(it, conn) ; forward_shift(conn); - MeshFormatCell e(INTERP_KERNEL::NORM_PENTA6, (int)*it); + MeshFormatCell e(INTERP_KERNEL::NORM_PENTA6, (int)it); e.setConn(conn); - idCellToCell.insert(std::pair (*it, e)); + idCellToCell.insert(std::pair (it, e)); } _typeToIdCellToCell.insert(std::pair >(INTERP_KERNEL::NORM_PENTA6, idCellToCell) ); } @@ -850,7 +858,7 @@ void MeshFormatWriter::linkFamilyToNodes() const MEDCoupling::mcIdType * nodeIdsIt = nodeIds->begin(), * famIDEnd = nodeIds->end(); for(; nodeIdsIt< famIDEnd; ++nodeIdsIt) { - std::map ::iterator itNode = _idNodeToNode.find((int)*nodeIdsIt); + auto const itNode = _idNodeToNode.find((int)*nodeIdsIt); if (itNode == _idNodeToNode.end()) continue; else itNode->second._famId =(int) famIt->second; @@ -864,10 +872,9 @@ void MeshFormatWriter::linkFamilyToNodes() void MeshFormatWriter::linkFamilyToCells() { - std::vector levs = _mesh->getNonEmptyLevels(); - for (size_t iDim = 0; iDim < levs.size(); iDim++ ) + std::vector const levs = _mesh->getNonEmptyLevels(); + for (int const meshDimRelToMax : levs) { - int meshDimRelToMax = levs[iDim]; MEDCoupling::MCAuto< MEDCoupling::MEDCouplingMesh > mesh = _mesh->getMeshAtLevel( meshDimRelToMax); MEDCoupling::MCAuto< MEDCoupling::MEDCouplingUMesh > umesh0 = mesh->buildUnstructured(); const MEDCoupling::DataArrayIdType * famIdsField = _mesh->getFamilyFieldAtLevel(meshDimRelToMax); @@ -876,17 +883,17 @@ void MeshFormatWriter::linkFamilyToCells() for (; famID < famIDEnd; ++famID) { if (!(*famID)) continue; // "FAMILLE_ZERO" - std::string famName = _mesh->getFamilyNameGivenId(*famID); + std::string const famName = _mesh->getFamilyNameGivenId(*famID); MEDCoupling::MCAuto cellIds = _mesh->getFamilyArr( meshDimRelToMax, famName); const MEDCoupling::mcIdType * cellIdsIt = cellIds->begin(), *cellIDEnd = cellIds->end(); for(; cellIdsIt< cellIDEnd; ++cellIdsIt) { - INTERP_KERNEL::NormalizedCellType type = umesh0->getTypeOfCell(*cellIdsIt); //TODO - std::map >::iterator itCellMap = _typeToIdCellToCell.find(type); + INTERP_KERNEL::NormalizedCellType const type = umesh0->getTypeOfCell(*cellIdsIt); //TODO + auto const itCellMap = _typeToIdCellToCell.find(type); if (itCellMap == _typeToIdCellToCell.end()) continue; else { - std::map ::iterator itCell = itCellMap->second.find((int)*cellIdsIt); + auto const itCell = itCellMap->second.find((int)*cellIdsIt); if (itCell == itCellMap->second.end()) continue; else itCell->second._famId = (int)*famID; } @@ -901,10 +908,10 @@ void MeshFormatWriter::linkFamilyToCells() void MeshFormatWriter::writeCells() { - std::map < INTERP_KERNEL::NormalizedCellType, std::map >::iterator typeCellMapIt = _typeToIdCellToCell.begin(); + auto typeCellMapIt = _typeToIdCellToCell.begin(); for (; typeCellMapIt!= _typeToIdCellToCell.end(); ++typeCellMapIt) { - std::map::iterator cellMapIt = typeCellMapIt->second.begin(); + auto cellMapIt = typeCellMapIt->second.begin(); switch (typeCellMapIt->first) { case INTERP_KERNEL::NORM_SEG2 : diff --git a/src/MEDLoader/MeshFormatWriter.hxx b/src/MEDLoader/MeshFormatWriter.hxx index ceb05982f..04d3539e6 100644 --- a/src/MEDLoader/MeshFormatWriter.hxx +++ b/src/MEDLoader/MeshFormatWriter.hxx @@ -20,18 +20,22 @@ #ifndef MESHFORMATWRITER_HXX #define MESHFORMATWRITER_HXX -#include +#include +#include +#include +#include #include #include +#include #include "MCAuto.hxx" -#include "InterpKernelException.hxx" -#include "NormalizedUnstructuredMesh.hxx" +#include "NormalizedGeometricTypes" +#include "MEDLoaderDefines.hxx" +#include "MEDCouplingUMesh.hxx" #include "MCType.hxx" #include "MEDMESHConverterUtilities.hxx" #include "libmesh5.hxx" #include "MEDFileMesh.hxx" -#include namespace MEDCoupling { diff --git a/src/MEDLoader/SauvMedConvertor.cxx b/src/MEDLoader/SauvMedConvertor.cxx index f999f60d7..1af316a62 100644 --- a/src/MEDLoader/SauvMedConvertor.cxx +++ b/src/MEDLoader/SauvMedConvertor.cxx @@ -24,20 +24,36 @@ #include "SauvMedConvertor.hxx" #include "CellModel.hxx" +#include "InterpKernelException.hxx" +#include "MCIdType.hxx" +#include "MCAuto.hxx" +#include "MEDCouplingUMesh.hxx" +#include "MCType.hxx" +#include "MEDCouplingRefCountObject.hxx" #include "MEDFileMesh.hxx" #include "MEDFileField.hxx" #include "MEDFileData.hxx" #include "MEDCouplingFieldDouble.hxx" +#include "NormalizedGeometricTypes" +#include "SauvUtilities.hxx" +#include +#include #include #include #include +#include +#include #include #include #include #include #include +#include +#include +#include +#include #ifdef WIN32 #include @@ -46,7 +62,6 @@ #endif #ifdef HAS_XDR -#include #include #endif @@ -196,9 +211,9 @@ namespace inline void reverse(const Cell & aCell, const std::vector > & swapVec ) { Cell* ma = const_cast(&aCell); - for ( unsigned i = 0; i < swapVec.size(); ++i ) - std::swap( ma->_nodes[ swapVec[i].first ], - ma->_nodes[ swapVec[i].second ]); + for (const auto & i : swapVec) + std::swap( ma->_nodes[ i.first ], + ma->_nodes[ i.second ]); if ( swapVec.empty() ) ma->_reverse = true; else @@ -215,7 +230,7 @@ namespace return i1->_number < i2->_number; } }; - typedef std::map< const Cell*, unsigned, TCellByIDCompare > TCellToOrderMap; + using TCellToOrderMap = std::map; //================================================================================ /*! @@ -230,7 +245,7 @@ namespace // check if relocation table is necessary bool isRelocated = false; unsigned newOrder = 0; - TCellToOrderMap::iterator c2oIt = cell2order.begin(), c2oEnd = cell2order.end(); + auto c2oIt = cell2order.begin(), c2oEnd = cell2order.end(); for ( ; !isRelocated && c2oIt != c2oEnd; ++c2oIt, ++newOrder ) isRelocated = ( c2oIt->second != newOrder ); @@ -245,9 +260,9 @@ namespace namespace // define default GAUSS points { - typedef std::vector TDoubleVector; - typedef double* TCoordSlice; - typedef int TInt; + using TDoubleVector = std::vector; + using TCoordSlice = double *; + using TInt = int; //--------------------------------------------------------------- //! Shape function definitions //--------------------------------------------------------------- @@ -415,7 +430,7 @@ namespace // define default GAUSS points //--------------------------------------------------------------- TSeg2a::TSeg2a():TShapeFun(1,2) { - TInt aNbRef = GetNbRef(); + TInt const aNbRef = GetNbRef(); for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){ TCoordSlice aCoord = GetCoord(aRefId); switch(aRefId){ @@ -427,7 +442,7 @@ namespace // define default GAUSS points //--------------------------------------------------------------- TSeg3a::TSeg3a():TShapeFun(1,3) { - TInt aNbRef = GetNbRef(); + TInt const aNbRef = GetNbRef(); for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){ TCoordSlice aCoord = GetCoord(aRefId); switch(aRefId){ @@ -441,7 +456,7 @@ namespace // define default GAUSS points TTria3a::TTria3a(): TShapeFun(2,3) { - TInt aNbRef = GetNbRef(); + TInt const aNbRef = GetNbRef(); for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){ TCoordSlice aCoord = GetCoord(aRefId); switch(aRefId){ @@ -454,7 +469,7 @@ namespace // define default GAUSS points //--------------------------------------------------------------- TTria6a::TTria6a():TShapeFun(2,6) { - TInt aNbRef = GetNbRef(); + TInt const aNbRef = GetNbRef(); for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){ TCoordSlice aCoord = GetCoord(aRefId); switch(aRefId){ @@ -472,7 +487,7 @@ namespace // define default GAUSS points TTria3b::TTria3b(): TShapeFun(2,3) { - TInt aNbRef = GetNbRef(); + TInt const aNbRef = GetNbRef(); for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){ TCoordSlice aCoord = GetCoord(aRefId); switch(aRefId){ @@ -486,7 +501,7 @@ namespace // define default GAUSS points TTria6b::TTria6b(): TShapeFun(2,6) { - TInt aNbRef = GetNbRef(); + TInt const aNbRef = GetNbRef(); for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){ TCoordSlice aCoord = GetCoord(aRefId); switch(aRefId){ @@ -504,7 +519,7 @@ namespace // define default GAUSS points TQuad4a::TQuad4a(): TShapeFun(2,4) { - TInt aNbRef = GetNbRef(); + TInt const aNbRef = GetNbRef(); for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){ TCoordSlice aCoord = GetCoord(aRefId); switch(aRefId){ @@ -519,7 +534,7 @@ namespace // define default GAUSS points TQuad8a::TQuad8a(): TShapeFun(2,8) { - TInt aNbRef = GetNbRef(); + TInt const aNbRef = GetNbRef(); for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){ TCoordSlice aCoord = GetCoord(aRefId); switch(aRefId){ @@ -539,7 +554,7 @@ namespace // define default GAUSS points TQuad4b::TQuad4b(): TShapeFun(2,4) { - TInt aNbRef = GetNbRef(); + TInt const aNbRef = GetNbRef(); for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){ TCoordSlice aCoord = GetCoord(aRefId); switch(aRefId){ @@ -554,7 +569,7 @@ namespace // define default GAUSS points TQuad8b::TQuad8b(): TShapeFun(2,8) { - TInt aNbRef = GetNbRef(); + TInt const aNbRef = GetNbRef(); for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){ TCoordSlice aCoord = GetCoord(aRefId); switch(aRefId){ @@ -574,7 +589,7 @@ namespace // define default GAUSS points TTetra4a::TTetra4a(): TShapeFun(3,4) { - TInt aNbRef = GetNbRef(); + TInt const aNbRef = GetNbRef(); for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){ TCoordSlice aCoord = GetCoord(aRefId); switch(aRefId){ @@ -589,7 +604,7 @@ namespace // define default GAUSS points TTetra10a::TTetra10a(): TShapeFun(3,10) { - TInt aNbRef = GetNbRef(); + TInt const aNbRef = GetNbRef(); for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){ TCoordSlice aCoord = GetCoord(aRefId); switch(aRefId){ @@ -612,7 +627,7 @@ namespace // define default GAUSS points TTetra4b::TTetra4b(): TShapeFun(3,4) { - TInt aNbRef = GetNbRef(); + TInt const aNbRef = GetNbRef(); for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){ TCoordSlice aCoord = GetCoord(aRefId); switch(aRefId){ @@ -627,7 +642,7 @@ namespace // define default GAUSS points TTetra10b::TTetra10b(): TShapeFun(3,10) { - TInt aNbRef = GetNbRef(); + TInt const aNbRef = GetNbRef(); for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){ TCoordSlice aCoord = GetCoord(aRefId); switch(aRefId){ @@ -650,7 +665,7 @@ namespace // define default GAUSS points THexa8a::THexa8a(): TShapeFun(3,8) { - TInt aNbRef = GetNbRef(); + TInt const aNbRef = GetNbRef(); for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){ TCoordSlice aCoord = GetCoord(aRefId); switch(aRefId){ @@ -669,7 +684,7 @@ namespace // define default GAUSS points THexa20a::THexa20a(TInt theDim, TInt theNbRef): TShapeFun(theDim,theNbRef) { - std::size_t aNbRef = myRefCoord.size(); + std::size_t const aNbRef = myRefCoord.size(); for(std::size_t aRefId = 0; aRefId < aNbRef; aRefId++){ TCoordSlice aCoord = GetCoord(aRefId); switch(aRefId){ @@ -701,7 +716,7 @@ namespace // define default GAUSS points THexa27a::THexa27a(): THexa20a(3,27) { - std::size_t aNbRef = myRefCoord.size(); + std::size_t const aNbRef = myRefCoord.size(); for(std::size_t aRefId = 0; aRefId < aNbRef; aRefId++){ TCoordSlice aCoord = GetCoord(aRefId); switch(aRefId){ @@ -719,7 +734,7 @@ namespace // define default GAUSS points THexa8b::THexa8b(): TShapeFun(3,8) { - TInt aNbRef = GetNbRef(); + TInt const aNbRef = GetNbRef(); for(TInt aRefId = 0; aRefId < aNbRef; aRefId++){ TCoordSlice aCoord = GetCoord(aRefId); switch(aRefId){ @@ -738,7 +753,7 @@ namespace // define default GAUSS points THexa20b::THexa20b(TInt theDim, TInt theNbRef): TShapeFun(theDim,theNbRef) { - std::size_t aNbRef = myRefCoord.size(); + std::size_t const aNbRef = myRefCoord.size(); for(std::size_t aRefId = 0; aRefId < aNbRef; aRefId++){ TCoordSlice aCoord = GetCoord(aRefId); switch(aRefId){ @@ -770,7 +785,7 @@ namespace // define default GAUSS points TPenta6a::TPenta6a(): TShapeFun(3,6) { - std::size_t aNbRef = myRefCoord.size(); + std::size_t const aNbRef = myRefCoord.size(); for(std::size_t aRefId = 0; aRefId < aNbRef; aRefId++){ TCoordSlice aCoord = GetCoord(aRefId); switch(aRefId){ @@ -787,7 +802,7 @@ namespace // define default GAUSS points TPenta6b::TPenta6b(): TShapeFun(3,6) { - std::size_t aNbRef = myRefCoord.size(); + std::size_t const aNbRef = myRefCoord.size(); for(std::size_t aRefId = 0; aRefId < aNbRef; aRefId++){ TCoordSlice aCoord = GetCoord(aRefId); switch(aRefId){ @@ -804,7 +819,7 @@ namespace // define default GAUSS points TPenta15a::TPenta15a(): TShapeFun(3,15) { - std::size_t aNbRef = myRefCoord.size(); + std::size_t const aNbRef = myRefCoord.size(); for(std::size_t aRefId = 0; aRefId < aNbRef; aRefId++){ TCoordSlice aCoord = GetCoord(aRefId); switch(aRefId){ @@ -831,7 +846,7 @@ namespace // define default GAUSS points TPenta15b::TPenta15b(): TShapeFun(3,15) { - std::size_t aNbRef = myRefCoord.size(); + std::size_t const aNbRef = myRefCoord.size(); for(std::size_t aRefId = 0; aRefId < aNbRef; aRefId++){ TCoordSlice aCoord = GetCoord(aRefId); switch(aRefId){ @@ -858,7 +873,7 @@ namespace // define default GAUSS points TPyra5a::TPyra5a(): TShapeFun(3,5) { - std::size_t aNbRef = myRefCoord.size(); + std::size_t const aNbRef = myRefCoord.size(); for(std::size_t aRefId = 0; aRefId < aNbRef; aRefId++){ TCoordSlice aCoord = GetCoord(aRefId); switch(aRefId){ @@ -874,7 +889,7 @@ namespace // define default GAUSS points TPyra5b::TPyra5b(): TShapeFun(3,5) { - std::size_t aNbRef = myRefCoord.size(); + std::size_t const aNbRef = myRefCoord.size(); for(std::size_t aRefId = 0; aRefId < aNbRef; aRefId++){ TCoordSlice aCoord = GetCoord(aRefId); switch(aRefId){ @@ -890,7 +905,7 @@ namespace // define default GAUSS points TPyra13a::TPyra13a(): TShapeFun(3,13) { - std::size_t aNbRef = myRefCoord.size(); + std::size_t const aNbRef = myRefCoord.size(); for(std::size_t aRefId = 0; aRefId < aNbRef; aRefId++){ TCoordSlice aCoord = GetCoord(aRefId); switch(aRefId){ @@ -915,7 +930,7 @@ namespace // define default GAUSS points TPyra13b::TPyra13b(): TShapeFun(3,13) { - std::size_t aNbRef = myRefCoord.size(); + std::size_t const aNbRef = myRefCoord.size(); for(std::size_t aRefId = 0; aRefId < aNbRef; aRefId++){ TCoordSlice aCoord = GetCoord(aRefId); switch(aRefId){ @@ -1474,7 +1489,7 @@ const int * SauvUtilities::getGibi2MedQuadraticInterlace( INTERP_KERNEL::Normali static const int seg3 [] = {0,2,1}; if ( conn.empty() ) { - conn.resize( MaxMedCellType + 1, 0 ); + conn.resize( MaxMedCellType + 1, nullptr ); conn[ NORM_HEXA20 ] = hexa20; conn[ NORM_PENTA15] = penta15; conn[ NORM_PYRA13 ] = pyra13; @@ -1493,7 +1508,7 @@ const int * SauvUtilities::getGibi2MedQuadraticInterlace( INTERP_KERNEL::Normali //================================================================================ Cell::Cell(const Cell& ma) - : _nodes(ma._nodes), _reverse(ma._reverse), _sortedNodeIDs(0), _number(ma._number) + : _nodes(ma._nodes), _reverse(ma._reverse), _number(ma._number) { if ( ma._sortedNodeIDs ) { @@ -1510,7 +1525,7 @@ Cell::Cell(const Cell& ma) SauvUtilities::Link Cell::link(int i) const { - std::size_t i2 = ( i + 1 ) % _nodes.size(); + std::size_t const i2 = ( i + 1 ) % _nodes.size(); if ( _reverse ) return std::make_pair( _nodes[i2]->_number, _nodes[i]->_number ); else @@ -1527,7 +1542,7 @@ const TID* Cell::getSortedNodes() const { if ( !_sortedNodeIDs ) { - size_t l=_nodes.size(); + size_t const l=_nodes.size(); _sortedNodeIDs = new TID[ l ]; for (size_t i=0; i!=l; ++i) @@ -1598,8 +1613,8 @@ mcIdType Group::size() const else if ( !_cells.empty() ) sizze = _cells.size(); else - for ( size_t i = 0; i < _groups.size(); ++i ) - sizze += _groups[i]->size(); + for (auto _group : _groups) + sizze += _group->size(); return ToIdType( sizze ); } @@ -1704,11 +1719,11 @@ ASCIIReader::~ASCIIReader() if (_file >= 0) { ::close (_file); - if (_start != 0L) + if (_start != nullptr) { delete [] _start; //delete [] _tmpBuf; - _start = 0; + _start = nullptr; } _file = -1; } @@ -1817,7 +1832,7 @@ void ASCIIReader::init( int nbToRead, int nbPosInLine, int width, int shift /*= } else { - _curPos = 0; + _curPos = nullptr; } } @@ -1897,7 +1912,7 @@ void ASCIIReader::next() } else { - _curPos = 0; + _curPos = nullptr; } } @@ -1916,9 +1931,9 @@ int ASCIIReader::getInt() const // 53619906 | SCALAIRE // 53619907 | -63312600499 1 0 0 0 -2 0 2 // where -63312600499 is actually -633 and 12600499 - char hold=_curPos[_width]; + char const hold=_curPos[_width]; _curPos[_width] = '\0'; - int result = atoi( _curPos ); + int const result = atoi( _curPos ); _curPos[_width] = hold; return result; //return atoi(str()); @@ -1992,7 +2007,7 @@ std::string ASCIIReader::getName() const */ //================================================================================ -XDRReader::XDRReader(const char* fileName) :FileReader(fileName), _xdrs_file(NULL) +XDRReader::XDRReader(const char* fileName) :FileReader(fileName), _xdrs_file(nullptr) { } @@ -2010,7 +2025,7 @@ XDRReader::~XDRReader() xdr_destroy((XDR*)_xdrs); free((XDR*)_xdrs); ::fclose(_xdrs_file); - _xdrs_file = NULL; + _xdrs_file = nullptr; } #endif } @@ -2058,7 +2073,7 @@ bool XDRReader::open() xdr_destroy((XDR*)_xdrs); free((XDR*)_xdrs); fclose(_xdrs_file); - _xdrs_file = NULL; + _xdrs_file = nullptr; } } #endif @@ -2109,7 +2124,7 @@ void XDRReader::initNameReading(int nbValues, int width) _xdr_kind = _xdr_kind_char; if(nbValues*width) { - unsigned int nels = nbValues*width; + unsigned int const nels = nbValues*width; _xdr_cvals = (char*)malloc((nels+1)*sizeof(char)); #ifdef HAS_XDR xdr_string((XDR*)_xdrs, &_xdr_cvals, nels); @@ -2131,7 +2146,7 @@ void XDRReader::initIntReading(int nbValues) if(nbValues) { #ifdef HAS_XDR - unsigned int nels = nbValues; + unsigned int const nels = nbValues; unsigned int actual_nels; _xdr_ivals = (int*)malloc(nels*sizeof(int)); xdr_array((XDR*)_xdrs, (char **)&_xdr_ivals, &actual_nels, nels, sizeof(int), (xdrproc_t)xdr_int); @@ -2152,7 +2167,7 @@ void XDRReader::initDoubleReading(int nbValues) if(nbValues) { #ifdef HAS_XDR - unsigned int nels = nbValues; + unsigned int const nels = nbValues; unsigned int actual_nels; _xdr_dvals = (double*)malloc(nels*sizeof(double)); xdr_array((XDR*)_xdrs, (char **)&_xdr_dvals, &actual_nels, nels, sizeof(double), (xdrproc_t)xdr_double); @@ -2317,37 +2332,37 @@ Group* IntermediateMED::addNewGroup(std::vector* groupsTo // correct pointers to sub-groups for ( size_t j = 0; j < _groups[i]._groups.size(); ++j ) { - std::size_t iG = _groups[i]._groups[j] - &_groups[0]; + std::size_t const iG = _groups[i]._groups[j] - &_groups[0]; newGroups[i]._groups[j] = & newGroups[ iG ]; } } // fix given groups if ( groupsToFix ) - for ( size_t i = 0; i < groupsToFix->size(); ++i ) - if ( (*groupsToFix)[i] ) + for (auto & i : *groupsToFix) + if ( i ) { - std::size_t iG = (*groupsToFix)[i] - &_groups[0]; - (*groupsToFix)[i] = & newGroups[ iG ]; + std::size_t const iG = i - &_groups[0]; + i = & newGroups[ iG ]; } // fix field supports for ( int isNode = 0; isNode < 2; ++isNode ) { - std::vector& fields = isNode ? _nodeFields : _cellFields; - for ( size_t i = 0; i < fields.size(); ++i ) + std::vector const& fields = isNode ? _nodeFields : _cellFields; + for (auto & field : fields) { - if ( !fields[i] ) continue; - for ( size_t j = 0; j < fields[i]->_sub.size(); ++j ) - if ( fields[i]->_sub[j]._support ) + if ( !field ) continue; + for (auto & j : field->_sub) + if ( j._support ) { - std::size_t iG = fields[i]->_sub[j]._support - &_groups[0]; - fields[i]->_sub[j]._support = & newGroups[ iG ]; + std::size_t const iG = j._support - &_groups[0]; + j._support = & newGroups[ iG ]; } - if ( fields[i]->_group ) + if ( field->_group ) { - std::size_t iG = fields[i]->_group - &_groups[0]; - fields[i]->_group = & newGroups[ iG ]; + std::size_t const iG = field->_group - &_groups[0]; + field->_group = & newGroups[ iG ]; } } } @@ -2440,9 +2455,9 @@ void IntermediateMED::setGroupLongNames() // IMP 0023285: only keep the meshes named in the table MED_MAIL // clear all group names - for ( size_t i = 0; i < _groups.size(); ++i ) - if ( !_groups[i]._isProfile ) - _groups[i]._name.clear(); + for (auto & _group : _groups) + if ( !_group._isProfile ) + _group._name.clear(); // IMP 0020434: mapping GIBI names to MED names @@ -2450,7 +2465,7 @@ void IntermediateMED::setGroupLongNames() std::set treatedGroups; - std::list::iterator itGIBItoMED = _listGIBItoMED_mail.begin(); + auto itGIBItoMED = _listGIBItoMED_mail.begin(); for (; itGIBItoMED != _listGIBItoMED_mail.end(); itGIBItoMED++) { if ( (int)_groups.size() < itGIBItoMED->gibi_id ) continue; @@ -2466,9 +2481,9 @@ void IntermediateMED::setGroupLongNames() } else if ( !grp._refNames.empty() && grp._refNames.back().empty() ) { - for ( unsigned i = 0; i < grp._refNames.size(); ++i ) - if ( grp._refNames[i].empty() ) - grp._refNames[i] = _mapStrings[ (*itGIBItoMED).med_id ]; + for (auto & _refName : grp._refNames) + if ( _refName.empty() ) + _refName = _mapStrings[ (*itGIBItoMED).med_id ]; } else { @@ -2480,17 +2495,16 @@ void IntermediateMED::setGroupLongNames() // remove all cells belonging to non-named groups only // use Cell::_reverse to mark cells to keep - for ( size_t i = 0; i < _groups.size(); ++i ) + for (auto & grp : _groups) { - SauvUtilities::Group & grp = _groups[i]; if ( grp._isProfile || !grp._name.empty() ) { - for ( size_t iC = 0; iC < grp._cells.size(); ++iC ) - grp._cells[iC]->_reverse = true; + for (auto & _cell : grp._cells) + _cell->_reverse = true; - for (size_t j = 0; j < grp._groups.size(); ++j ) - for ( size_t iC = 0; iC < grp._groups[j]->_cells.size(); ++iC ) - grp._groups[j]->_cells[iC]->_reverse = true; + for (auto & _group : grp._groups) + for (auto & _cell : _group->_cells) + _cell->_reverse = true; } } // remove non-marked cells (with _reverse == false) @@ -2498,7 +2512,7 @@ void IntermediateMED::setGroupLongNames() while ( cellsIt.nextType() ) { std::set & cells = _cellsByType[ cellsIt.type() ]; - std::set::iterator cIt = cells.begin(); + auto cIt = cells.begin(); while ( cIt != cells.end() ) if ( cIt->_reverse ) { @@ -2520,7 +2534,7 @@ void IntermediateMED::setGroupLongNames() void IntermediateMED::setFieldLongNames(std::set< std::string >& usedNames) { - std::list::iterator itGIBItoMED = _listGIBItoMED_cham.begin(); + auto itGIBItoMED = _listGIBItoMED_cham.begin(); for (; itGIBItoMED != _listGIBItoMED_cham.end(); itGIBItoMED++) { if (itGIBItoMED->gibi_pile == PILE_FIELD) @@ -2535,10 +2549,10 @@ void IntermediateMED::setFieldLongNames(std::set< std::string >& usedNames) for (itGIBItoMED =_listGIBItoMED_comp.begin(); itGIBItoMED != _listGIBItoMED_comp.end(); itGIBItoMED++) { - std::string medName = _mapStrings[itGIBItoMED->med_id]; - std::string gibiName = _mapStrings[itGIBItoMED->gibi_id]; + std::string const medName = _mapStrings[itGIBItoMED->med_id]; + std::string const gibiName = _mapStrings[itGIBItoMED->gibi_id]; - bool name_found = false; + bool const name_found = false; for ( int isNodal = 0; isNodal < 2 && !name_found; ++isNodal ) { std::vector & fields = isNodal ? _nodeFields : _cellFields; @@ -2547,13 +2561,13 @@ void IntermediateMED::setFieldLongNames(std::set< std::string >& usedNames) if (medName.find( fields[ifi]->_name + "." ) == 0 ) { std::vector& aSubDs = fields[ifi]->_sub; - std::size_t nbSub = aSubDs.size(); + std::size_t const nbSub = aSubDs.size(); for (std::size_t isu = 0; isu < nbSub; isu++) for (int ico = 0; ico < aSubDs[isu].nbComponents(); ico++) { if (aSubDs[isu].compName(ico) == gibiName) { - std::string medNameCompo = medName.substr( fields[ifi]->_name.size() + 1 ); + std::string const medNameCompo = medName.substr( fields[ifi]->_name.size() + 1 ); fields[ifi]->_sub[isu].compName(ico) = medNameCompo; } } @@ -2562,10 +2576,10 @@ void IntermediateMED::setFieldLongNames(std::set< std::string >& usedNames) } } // iterate on _listGIBItoMED_comp - for ( size_t i = 0; i < _nodeFields.size() ; i++) - usedNames.insert( _nodeFields[i]->_name ); - for ( size_t i = 0; i < _cellFields.size() ; i++) - usedNames.insert( _cellFields[i]->_name ); + for (auto & _nodeField : _nodeFields) + usedNames.insert( _nodeField->_name ); + for (auto & _cellField : _cellFields) + usedNames.insert( _cellField->_name ); } //================================================================================ @@ -2576,9 +2590,8 @@ void IntermediateMED::setFieldLongNames(std::set< std::string >& usedNames) void IntermediateMED::decreaseHierarchicalDepthOfSubgroups() { - for (size_t i=0; i!=_groups.size(); ++i) + for (auto & grp : _groups) { - Group& grp = _groups[i]; for (size_t j = 0; j < grp._groups.size(); ++j ) { Group & sub_grp = *grp._groups[j]; @@ -2593,9 +2606,9 @@ void IntermediateMED::decreaseHierarchicalDepthOfSubgroups() // remove empty sub-_groups std::vector< Group* > newSubGroups; newSubGroups.reserve( grp._groups.size() ); - for (size_t j = 0; j < grp._groups.size(); ++j ) - if ( !grp._groups[j]->empty() ) - newSubGroups.push_back( grp._groups[j] ); + for (auto & _group : grp._groups) + if ( !_group->empty() ) + newSubGroups.push_back( _group ); if ( newSubGroups.size() < grp._groups.size() ) grp._groups.swap( newSubGroups ); } @@ -2619,17 +2632,15 @@ void IntermediateMED::eraseUselessGroups() // } std::set groups2convert; // keep not named sub-groups of field supports - for (size_t i=0; i!=_groups.size(); ++i) + for (auto & grp : _groups) { - Group& grp = _groups[i]; if ( grp._isProfile && !grp._groups.empty() ) groups2convert.insert( grp._groups.begin(), grp._groups.end() ); } // keep named groups and their subgroups - for (size_t i=0; i!=_groups.size(); ++i) + for (auto & grp : _groups) { - Group& grp = _groups[i]; if ( !grp._name.empty() && !grp.empty() ) { groups2convert.insert( &grp ); @@ -2637,9 +2648,9 @@ void IntermediateMED::eraseUselessGroups() } } // erase groups that are not in groups2convert and not _isProfile - for (size_t i=0; i!=_groups.size(); ++i) + for (auto & _group : _groups) { - Group* grp = &_groups[i]; + Group* grp = &_group; if ( !grp->_isProfile && !groups2convert.count( grp ) ) { grp->_cells.clear(); @@ -2657,17 +2668,16 @@ void IntermediateMED::eraseUselessGroups() void IntermediateMED::detectMixDimGroups() { //hasMixedCells = false; - for ( size_t i=0; i < _groups.size(); ++i ) + for (auto & grp : _groups) { - Group& grp = _groups[i]; if ( grp._groups.size() < 2 ) continue; // check if sub-groups have different dimension - unsigned dim1 = getDim( &grp ); + unsigned const dim1 = getDim( &grp ); for ( size_t j = 1; j < grp._groups.size(); ++j ) { - unsigned dim2 = getDim( grp._groups[j] ); + unsigned const dim2 = getDim( grp._groups[j] ); if ( dim1 != dim2 ) { grp._cells.clear(); @@ -2694,7 +2704,7 @@ void IntermediateMED::orientElements2D() // ------------------------------------ // fix connectivity of quadratic edges // ------------------------------------ - std::set& quadEdges = _cellsByType[ INTERP_KERNEL::NORM_SEG3 ]; + std::set const& quadEdges = _cellsByType[ INTERP_KERNEL::NORM_SEG3 ]; if ( !quadEdges.empty() ) { elemIt = quadEdges.begin(), elemEnd = quadEdges.end(); @@ -2820,9 +2830,8 @@ void IntermediateMED::orientFaces3D() std::map > linkFacesMap; std::map >::iterator lfIt, lfIt2; - for (size_t i=0; i!=_groups.size(); ++i) + for (auto & grp : _groups) { - Group& grp = _groups[i]; if ( !grp._cells.empty() && getDimension( grp._cellType ) == 2 ) for ( size_t j = 0; j < grp._cells.size(); ++j ) if ( faces.insert( grp._cells[j] ).second ) @@ -2861,7 +2870,7 @@ void IntermediateMED::orientFaces3D() // loop on links of for ( int i = 0; i < (int)face->_nodes.size(); ++i ) { - Link link = face->link( i ); + Link const link = face->link( i ); // find the neighbor faces lfIt = linkFacesMap.find( link ); int nbFaceByLink = 0; @@ -2869,7 +2878,7 @@ void IntermediateMED::orientFaces3D() if ( lfIt != linkFacesMap.end() ) { std::list & fList = lfIt->second; - std::list::iterator fIt = fList.begin(); + auto fIt = fList.begin(); assert( fIt != fList.end() ); for ( ; fIt != fList.end(); fIt++, nbFaceByLink++ ) { @@ -2880,13 +2889,13 @@ void IntermediateMED::orientFaces3D() // reverse and remove badFace from linkFacesMap for ( int j = 0; j < (int)badFace->_nodes.size(); ++j ) { - Link badlink = badFace->link( j ); + Link const badlink = badFace->link( j ); if ( badlink == link ) continue; lfIt2 = linkFacesMap.find( badlink ); if ( lfIt2 != linkFacesMap.end() ) { std::list & ff = lfIt2->second; - std::list::iterator lfIt3 = find( ff.begin(), ff.end(), badFace ); + auto const lfIt3 = find( ff.begin(), ff.end(), badFace ); // check if badFace has been found, // else we can't erase it // case of degenerated face in edge @@ -2906,12 +2915,12 @@ void IntermediateMED::orientFaces3D() linkFacesMap.erase( lfIt ); } // add good neighbors to the queue - Link revLink( link.second, link.first ); + Link const revLink( link.second, link.first ); lfIt = linkFacesMap.find( revLink ); if ( lfIt != linkFacesMap.end() ) { std::list & fList = lfIt->second; - std::list::iterator fIt = fList.begin(); + auto fIt = fList.begin(); for ( ; fIt != fList.end(); fIt++, nbFaceByLink++ ) { ml.push_back( *fIt ); @@ -2924,7 +2933,7 @@ void IntermediateMED::orientFaces3D() { if ( manifold ) { - std::list::iterator ii = ml.begin(); + auto ii = ml.begin(); std::cout << nbFaceByLink << " faces by 1 link:" << std::endl; for( ; ii!= ml.end(); ii++ ) std::cout << "in sub-mesh <" << fgm[ *ii ]->_name << "> " << **ii << std::endl; @@ -3013,7 +3022,7 @@ void IntermediateMED::orientVolumes() vec[0] = normal[1] * vec01[2] - normal[2] * vec01[1]; vec[1] = normal[2] * vec01[0] - normal[0] * vec01[2]; vec[2] = normal[0] * vec01[1] - normal[1] * vec01[0]; - double dot2 = vec[0]*vec03[0] + vec[1]*vec03[1] + vec[2]*vec03[2]; // vec*vec03 + double const dot2 = vec[0]*vec03[0] + vec[1]*vec03[1] + vec[2]*vec03[2]; // vec*vec03 if ( dot2 < 0 ) // concave -> reverse normal { normal[0] *= -1; @@ -3029,7 +3038,7 @@ void IntermediateMED::orientVolumes() tbDir[2] = n[0][2] - n[3][2]; // compare 2 directions: normal and top-bottom - double dot = normal[0]*tbDir[0] + normal[1]*tbDir[1] + normal[2]*tbDir[2]; + double const dot = normal[0]*tbDir[0] + normal[1]*tbDir[1] + normal[2]*tbDir[2]; if ( dot < 0. ) // need reverse reverse( *elemIt, swapVec ); @@ -3047,10 +3056,10 @@ void IntermediateMED::orientVolumes() int NodeContainer::numberNodes() { int id = 1; - for ( size_t i = 0; i < _nodes.size(); ++i ) - for ( size_t j = 0; j < _nodes[i].size(); ++j ) - if ( _nodes[i][j].isUsed() ) - _nodes[i][j]._number = id++; + for (auto & _node : _nodes) + for (auto & j : _node) + if ( j.isUsed() ) + j._number = id++; return id-1; } @@ -3088,7 +3097,7 @@ void IntermediateMED::numberElements() if ( elemIt->_number < minNumber ) minNumber = elemIt->_number; if ( elemIt->_number > maxNumber ) maxNumber = elemIt->_number; } - mcIdType typeSize = ToIdType( typeCells->size() ); + mcIdType const typeSize = ToIdType( typeCells->size() ); if ( typeSize != maxNumber - minNumber + 1 ) ok = false; if ( prevNbElems+1 != (int)minNumber ) @@ -3201,7 +3210,7 @@ void IntermediateMED::setConnectivity( MEDCoupling::MEDFileUMesh* mesh, prevNbCells += ToIdType( cells->size() ); // fill dimMesh - TCellType cellType = dimCells.type(); + TCellType const cellType = dimCells.type(); nodalConnOfCell = &connectivity[0]; for ( size_t i = 0; i < cells->size(); ++i, nodalConnOfCell += nbCellNodes ) dimMesh->insertNextCell( cellType, nbCellNodes, nodalConnOfCell ); @@ -3246,17 +3255,16 @@ void IntermediateMED::setGroups( MEDCoupling::MEDFileUMesh* mesh ) std::vector< Group* > groupVec; if ( grp._groups.empty() ) groupVec.push_back( & grp ); else groupVec = grp._groups; - for ( size_t iG = 0; iG < groupVec.size(); ++iG ) + for (auto aG : groupVec) { - Group* aG = groupVec[ iG ]; if ( (int)getDim( aG ) != dim ) continue; - for ( size_t iC = 0; iC < aG->_cells.size(); ++iC ) - cell2order.insert( cell2order.end(), std::make_pair( aG->_cells[iC], orderInGroup++ )); + for (auto & _cell : aG->_cells) + cell2order.insert( cell2order.end(), std::make_pair( _cell, orderInGroup++ )); } if ( cell2order.empty() ) continue; - bool isSelfIntersect = ( orderInGroup != cell2order.size() ); + bool const isSelfIntersect = ( orderInGroup != cell2order.size() ); if ( isSelfIntersect ) // self intersecting group { std::ostringstream msg; @@ -3324,7 +3332,7 @@ void IntermediateMED::setGroups( MEDCoupling::MEDFileUMesh* mesh ) bool IntermediateMED::isOnAll( const Group* grp, int & dimRel ) const { - int dim = getDim( grp ); + int const dim = getDim( grp ); mcIdType nbElems = 0; if ( dim == 0 ) @@ -3348,7 +3356,7 @@ bool IntermediateMED::isOnAll( const Group* grp, int & dimRel ) const dimRel = dim - meshDim; } - bool onAll = ( nbElems == grp->size() ); + bool const onAll = ( nbElems == grp->size() ); return onAll; } @@ -3360,7 +3368,7 @@ bool IntermediateMED::isOnAll( const Group* grp, int & dimRel ) const MEDCoupling::MEDFileFields * IntermediateMED::makeMEDFileFields(MEDCoupling::MEDFileUMesh* mesh) { - if ( _nodeFields.empty() && _cellFields.empty() ) return 0; + if ( _nodeFields.empty() && _cellFields.empty() ) return nullptr; // set long names std::set< std::string > usedFieldNames; @@ -3419,7 +3427,7 @@ void IntermediateMED::setFields( SauvUtilities::DoubleField* fld, double * valPtr = values->getPointer(); if ( uniteSubs ) { - mcIdType nbElems = fld->_group->size(); + mcIdType const nbElems = fld->_group->size(); for ( mcIdType elemShift = 0; elemShift < nbElems && iSub < fld->_sub.size(); ) elemShift += fld->setValues( valPtr, iSub++, elemShift ); setTS( fld, values, medFields, mesh ); @@ -3499,7 +3507,7 @@ void IntermediateMED::setTS( SauvUtilities::DoubleField* fld, // set gauss points if ( timeStamp->getTypeOfField() == MEDCoupling::ON_GAUSS_PT ) { - TGaussDef gaussDef( fld->_sub[iSub]._support->_cellType, + TGaussDef const gaussDef( fld->_sub[iSub]._support->_cellType, fld->_sub[iSub].nbGauss() ); timeStamp->setGaussLocalizationOnType( fld->_sub[iSub]._support->_cellType, gaussDef.myRefCoords, @@ -3549,7 +3557,7 @@ void IntermediateMED::makeFieldNewName(std::set< std::string >& usedNames, } else { - std::string::size_type pos = base.rfind('_'); + std::string::size_type const pos = base.rfind('_'); if ( pos != std::string::npos ) base = base.substr( 0, pos+1 ); else @@ -3673,7 +3681,7 @@ bool DoubleField::isMedCompatible(bool& sameNbGauss) const bool DoubleField::hasSameComponentsBySupport() const { - std::vector< _Sub_data >::const_iterator sub_data = _sub.begin(); + auto sub_data = _sub.begin(); const _Sub_data& first_sub_data = *sub_data; for ( ++sub_data ; sub_data != _sub.end(); ++sub_data ) { @@ -3776,7 +3784,7 @@ mcIdType DoubleField::setValues( double * valPtr, const int iSub, const mcIdType mcIdType valsShift = 0; for ( mcIdType iS = iSub-1, shift = elemShift; shift > 0; --iS) { - mcIdType nbE = _sub[iS]._support->size(); + mcIdType const nbE = _sub[iS]._support->size(); shift -= nbE; valsShift += nbE * _sub[iS].nbComponents() * _sub[iS].nbGauss(); } @@ -3784,14 +3792,14 @@ mcIdType DoubleField::setValues( double * valPtr, const int iSub, const mcIdType if ( isConstField ) for ( mcIdType iE = 0; iE < nbElems; ++iE ) { - mcIdType iMed = valsShift + nbValsByElem * ( relocTable.empty() ? iE : relocTable[iE+elemShift]-elemShift ); + mcIdType const iMed = valsShift + nbValsByElem * ( relocTable.empty() ? iE : relocTable[iE+elemShift]-elemShift ); for ( iComp = 0; iComp < nbComponents; ++iComp ) valPtr[ iMed + iComp ] = compValues[iComp][ 0 ]; } else for ( mcIdType iE = 0; iE < nbElems; ++iE ) { - mcIdType iMed = valsShift + nbValsByElem * ( relocTable.empty() ? iE : relocTable[iE+elemShift]-elemShift ); + mcIdType const iMed = valsShift + nbValsByElem * ( relocTable.empty() ? iE : relocTable[iE+elemShift]-elemShift ); for ( iComp = 0; iComp < nbComponents; ++iComp ) for ( int iG = 0; iG < nbGauss; ++iG ) valPtr[ iMed + iG * nbComponents + iComp ] = compValues[iComp][ iE * nbGauss + iG ]; @@ -3807,19 +3815,19 @@ mcIdType DoubleField::setValues( double * valPtr, const int iSub, const mcIdType IntermediateMED::~IntermediateMED() { - for ( size_t i = 0; i < _nodeFields.size(); ++i ) - if ( _nodeFields[i] ) - delete _nodeFields[i]; + for (auto & _nodeField : _nodeFields) + if ( _nodeField ) + delete _nodeField; _nodeFields.clear(); - for ( size_t i = 0; i < _cellFields.size(); ++i ) - if ( _cellFields[i] ) - delete _cellFields[i]; + for (auto & _cellField : _cellFields) + if ( _cellField ) + delete _cellField; _cellFields.clear(); - for ( size_t i = 0; i < _groups.size(); ++i ) - if ( _groups[i]._medGroup ) - _groups[i]._medGroup->decrRef(); + for (auto & _group : _groups) + if ( _group._medGroup ) + _group._medGroup->decrRef(); } //================================================================================ @@ -3848,7 +3856,7 @@ const std::set< Cell > * CellsByDimIterator::nextType() while ( ++myCurType < myTypeEnd ) if ( !myImed->_cellsByType[myCurType].empty() && ( myDim < 0 || dim(false) == myDim )) return & myImed->_cellsByType[myCurType]; - return 0; + return nullptr; } /*! * \brief return dimension of cells returned by the last or further next() diff --git a/src/MEDLoader/SauvMedConvertor.hxx b/src/MEDLoader/SauvMedConvertor.hxx index 580ef1187..73c8d3d3a 100644 --- a/src/MEDLoader/SauvMedConvertor.hxx +++ b/src/MEDLoader/SauvMedConvertor.hxx @@ -24,12 +24,17 @@ #ifndef __SauvMedConvertor_HXX__ #define __SauvMedConvertor_HXX__ -#include "InterpKernelException.hxx" -#include "NormalizedUnstructuredMesh.hxx" +#include "MCIdType.hxx" #include "MEDCouplingRefCountObject.hxx" #include "SauvUtilities.hxx" #include "MCType.hxx" +#include "NormalizedGeometricTypes" +#include +#include +#include +#include +#include #include #include #include @@ -51,18 +56,18 @@ namespace SauvUtilities struct IntermediateMED; // ============================================================================== - typedef mcIdType TID; // an ID countered from 1 - typedef std::pair Link; // a pair of node numbers + using TID = mcIdType; // an ID countered from 1 + using Link = std::pair; // a pair of node numbers typedef INTERP_KERNEL::NormalizedCellType TCellType; // ============================================================================== struct Node { - TID _number; + TID _number{0}; size_t _coordID; - Node():_number(0){} + Node()= default; bool isUsed() const { return _number != 0; } }; @@ -70,13 +75,13 @@ namespace SauvUtilities struct Cell { std::vector< Node* > _nodes; - mutable bool _reverse; // to reverse orientation of a face only - mutable TID* _sortedNodeIDs; // for comparison - mutable TID _number; + mutable bool _reverse{false}; // to reverse orientation of a face only + mutable TID* _sortedNodeIDs{nullptr}; // for comparison + mutable TID _number{0}; - Cell(size_t nnNodes=0) : _nodes(nnNodes),_reverse(false),_sortedNodeIDs(0),_number(0) {} + Cell(size_t nnNodes=0) : _nodes(nnNodes) {} Cell(const Cell& ma); - void init() const { if ( _sortedNodeIDs ) delete [] _sortedNodeIDs; _sortedNodeIDs = 0; } + void init() const { if ( _sortedNodeIDs ) delete [] _sortedNodeIDs; _sortedNodeIDs = nullptr; } ~Cell() { init(); } const TID* getSortedNodes() const; // creates if needed and return _sortedNodeIDs @@ -91,11 +96,11 @@ namespace SauvUtilities // ============================================================================== struct Group { - TCellType _cellType; + TCellType _cellType{INTERP_KERNEL::NORM_ERROR}; std::string _name; std::vector _cells; std::vector< Group* > _groups; // des sous-groupes composant le Group - bool _isProfile; // is a field support or not + bool _isProfile{false}; // is a field support or not std::vector _refNames; /* names of groups referring this one; _refNames is resized according to nb of references while reading a group (pile 1) and it is filled with @@ -103,12 +108,12 @@ namespace SauvUtilities reference is converted into a copy of the medGroup (issue 0021311) */ - MEDCoupling::DataArrayIdType* _medGroup; // result of conversion + MEDCoupling::DataArrayIdType* _medGroup{nullptr}; // result of conversion std::vector< mcIdType > _relocTable; // for _cells[i] gives its index in _medGroup bool empty() const { return _cells.empty() && _groups.empty(); } mcIdType size() const; - Group():_cellType(INTERP_KERNEL::NORM_ERROR), _isProfile(false), _medGroup(NULL) {} + Group() {} }; // ============================================================================== @@ -138,17 +143,17 @@ namespace SauvUtilities std::string _name; std::string _description; // field description std::vector< _Sub_data > _sub; - Group* _group; /* if _group == NULL then each subcomponent makes a + Group* _group{nullptr}; /* if _group == NULL then each subcomponent makes a separate med field, else all subcomponents are converted into timestamps of one med field. The latter is possible only if nb of components in all subs is the same and supports of subcomponents do not overlap */ std::vector< std::vector< double > > _comp_values; - MEDCoupling::MEDFileFieldMultiTS* _curMedField; + MEDCoupling::MEDFileFieldMultiTS* _curMedField{nullptr}; DoubleField( int nb_sub, int total_nb_comp ) - : _sub(nb_sub), _group(NULL), _curMedField(NULL) { _comp_values.reserve( total_nb_comp ); } + : _sub(nb_sub) { _comp_values.reserve( total_nb_comp ); } ~DoubleField(); std::vector< double >& addComponent( int nb_values ); // return a vector ready to fill in bool hasCommonSupport() const { return _group; } // true if there is one support for all subs @@ -235,8 +240,8 @@ namespace SauvUtilities */ struct IntermediateMED { - unsigned _spaceDim; - unsigned _nbNodes; + unsigned _spaceDim{0}; + unsigned _nbNodes{0}; NodeContainer _points; std::vector _coords; std::vector _groups; @@ -249,13 +254,13 @@ namespace SauvUtilities std::list _listGIBItoMED_comp; // to read from table "MED_COMP" of PILE_TABLES std::map _mapStrings; // to read from PILE_STRINGS - IntermediateMED(): _spaceDim(0), _nbNodes(0) {} + IntermediateMED() = default; ~IntermediateMED(); Node* getNode( TID nID ) { return _points.getNode( nID ); } mcIdType getNbCellsOfType( TCellType type ) const { return ToIdType(_cellsByType[type].size()); } const Cell* insert(TCellType type, const Cell& ma) { return &( *_cellsByType[type].insert( ma ).first ); } - Group* addNewGroup(std::vector* groupsToFix=0); + Group* addNewGroup(std::vector* groupsToFix=nullptr); MEDCoupling::MEDFileData* convertInMEDFileDS(); private: @@ -312,19 +317,19 @@ namespace SauvUtilities { public: ASCIIReader(const char* fileName); - virtual ~ASCIIReader(); - virtual bool isASCII() const; - virtual bool open(); - virtual bool getNextLine (char* & line, bool raiseOEF = true ); - virtual void initNameReading(int nbValues, int width = 8); - virtual void initIntReading(int nbValues); - virtual void initDoubleReading(int nbValues); - virtual bool more() const; - virtual void next(); - virtual int getInt() const; - virtual float getFloat() const; - virtual double getDouble() const; - virtual std::string getName() const; + ~ASCIIReader() override; + bool isASCII() const override; + bool open() override; + bool getNextLine (char* & line, bool raiseOEF = true ) override; + void initNameReading(int nbValues, int width = 8) override; + void initIntReading(int nbValues) override; + void initDoubleReading(int nbValues) override; + bool more() const override; + void next() override; + int getInt() const override; + float getFloat() const override; + double getDouble() const override; + std::string getName() const override; int lineNb() const { return _lineNb; } std::string getClassName() const override { return std::string("ASCIIReader"); } private: @@ -351,19 +356,19 @@ namespace SauvUtilities { public: XDRReader(const char* fileName); - virtual ~XDRReader(); - virtual bool isASCII() const; - virtual bool open(); - virtual bool getNextLine (char* & line, bool raiseOEF = true ); - virtual void initNameReading(int nbValues, int width = 8); - virtual void initIntReading(int nbValues); - virtual void initDoubleReading(int nbValues); - virtual bool more() const; - virtual void next(); - virtual int getInt() const; - virtual float getFloat() const; - virtual double getDouble() const; - virtual std::string getName() const; + ~XDRReader() override; + bool isASCII() const override; + bool open() override; + bool getNextLine (char* & line, bool raiseOEF = true ) override; + void initNameReading(int nbValues, int width = 8) override; + void initIntReading(int nbValues) override; + void initDoubleReading(int nbValues) override; + bool more() const override; + void next() override; + int getInt() const override; + float getFloat() const override; + double getDouble() const override; + std::string getName() const override; std::string getClassName() const override { return std::string("XDRReader"); } private: diff --git a/src/MEDLoader/SauvReader.cxx b/src/MEDLoader/SauvReader.cxx index f2a64ffff..e6ad167f9 100644 --- a/src/MEDLoader/SauvReader.cxx +++ b/src/MEDLoader/SauvReader.cxx @@ -23,14 +23,22 @@ #include "SauvReader.hxx" +#include "InterpKernelException.hxx" #include "SauvMedConvertor.hxx" #include "MCAuto.hxx" -#include "NormalizedUnstructuredMesh.hxx" #include "MEDCouplingRefCountObject.hxx" +#include "SauvUtilities.hxx" +#include "NormalizedGeometricTypes" +#include +#include #include -#include +#include +#include #include +#include +#include +#include using namespace MEDCoupling; using namespace SauvUtilities; @@ -46,7 +54,7 @@ namespace public: Localizer() { - _locale = setlocale(LC_NUMERIC, NULL); + _locale = setlocale(LC_NUMERIC, nullptr); setlocale(LC_NUMERIC, "C"); } ~Localizer() @@ -72,7 +80,7 @@ SauvReader* SauvReader::New(const std::string& fileName) parser = new XDRReader( fileName.c_str() ); if ( parser->open() ) { - SauvReader* reader = new SauvReader; + auto* reader = new SauvReader; reader->_fileReader = parser.retn(); return reader; } @@ -81,7 +89,7 @@ SauvReader* SauvReader::New(const std::string& fileName) parser = new ASCIIReader( fileName.c_str() ); if ( parser->open() ) { - SauvReader* reader = new SauvReader; + auto* reader = new SauvReader; reader->_fileReader = parser.retn(); return reader; } @@ -132,7 +140,7 @@ std::string SauvReader::lineNb() const MEDCoupling::MEDFileData * SauvReader::loadInMEDFileDS() { - Localizer loc; // localization, to read numbers in "C" locale + Localizer const loc; // localization, to read numbers in "C" locale SauvUtilities::IntermediateMED iMed; // intermadiate DS _iMed = &iMed; @@ -402,11 +410,11 @@ void SauvReader::read_PILE_SOUS_MAILLAGE(const int nbObjects, for (int object=0; object!=nbObjects; ++object) // loop on sub-groups { initIntReading( 5 ); - int castemCellType = getIntNext(); - int nbSubGroups = getIntNext(); - int nbReferences = getIntNext(); - int nbNodesPerElem = getIntNext(); - int nbElements = getIntNext(); + int const castemCellType = getIntNext(); + int const nbSubGroups = getIntNext(); + int const nbReferences = getIntNext(); + int const nbNodesPerElem = getIntNext(); + int const nbElements = getIntNext(); _iMed->_groups.push_back(Group()); SauvUtilities::Group & group = _iMed->_groups.back(); @@ -462,7 +470,7 @@ void SauvReader::read_PILE_SOUS_MAILLAGE(const int nbObjects, ma.init(); for ( int n = 0; n < nbNodesPerElem; ++n ) { - int nodeID = getIntNext(); + int const nodeID = getIntNext(); pNode = _iMed->getNode( nodeID ); ma._nodes[n] = pNode; _iMed->_nbNodes += ( !pNode->isUsed() ); @@ -478,7 +486,7 @@ void SauvReader::read_PILE_SOUS_MAILLAGE(const int nbObjects, // set group names for (i=0; i!=(int)objectNames.size(); ++i) { - int grpID = nameIndices[i]; + int const grpID = nameIndices[i]; SauvUtilities::Group & grp = _iMed->_groups[ grpID-1 ]; if ( !grp._name.empty() ) // a group has several names { // create a group with subgroup grp and named grp.name @@ -508,7 +516,7 @@ void SauvReader::read_PILE_LREEL (const int nbObjects, std::vector& for (int object=0; object!=nbObjects; ++object) // pour chaque Group { initIntReading(1); - int nb_vals = getIntNext(); + int const nb_vals = getIntNext(); initDoubleReading(nb_vals); for(int i=0; i&, std:: if ( isXRD() ) { initIntReading(1); - int nb_vals = getIntNext(); + int const nb_vals = getIntNext(); initIntReading(nb_vals); for(int i=0; i&, std::ve if ( isXRD() ) { initIntReading(1); - int nb_vals = getIntNext(); + int const nb_vals = getIntNext(); initDoubleReading(nb_vals); for(int i=0; i&, std:: if ( isXRD() ) { initIntReading(1); - int nb_vals = getIntNext(); + int const nb_vals = getIntNext(); initIntReading(nb_vals); for(int i=0; i& for (int object=0; object!=nbObjects; ++object) // pour chaque Group { initIntReading(2); - int len = getIntNext(); - int nb_vals = getIntNext(); - int nb_char = len*nb_vals; + int const len = getIntNext(); + int const nb_vals = getIntNext(); + int const nb_char = len*nb_vals; int nb_char_tmp = 0; - int fixed_length = 71; + int const fixed_length = 71; while (nb_char_tmp < nb_char) { - int remain_len = nb_char - nb_char_tmp; + int const remain_len = nb_char - nb_char_tmp; int width; if ( remain_len > fixed_length ) { @@ -618,18 +626,18 @@ void SauvReader::read_PILE_MODL (const int nbObjects, std::vector&, { // see wrmodl.eso initIntReading(10); - int n1 = getIntNext(); - int nm2 = getIntNext(); - int nm3 = getIntNext(); - int nm4 = getIntNext(); - int nm5 = getIntNext(); - int n45 = getIntNext(); + int const n1 = getIntNext(); + int const nm2 = getIntNext(); + int const nm3 = getIntNext(); + int const nm4 = getIntNext(); + int const nm5 = getIntNext(); + int const n45 = getIntNext(); /*int nm6 =*/ getIntNext(); /*int nm7 =*/ getIntNext(); next(); next(); - int nm1 = n1 * n45; - int nm9 = n1 * 16; + int const nm1 = n1 * n45; + int const nm9 = n1 * 16; for (initIntReading(nm1); more(); next()); for (initIntReading(nm9); more(); next()); for (initNameReading(nm5, 8); more(); next()); @@ -649,14 +657,14 @@ void SauvReader::read_PILE_MODL (const int nbObjects, std::vector&, void SauvReader::read_PILE_NOEUDS (const int nbObjects, std::vector&, std::vector&) { initIntReading(1); - int nb_indices = getIntNext(); + int const nb_indices = getIntNext(); if (nb_indices != nbObjects) THROW_IK_EXCEPTION("Error of reading PILE NUMERO " << PILE_NOEUDS << lineNb() ); for ( initIntReading( nbObjects ); more(); next() ) { - int coordID = getInt(); + int const coordID = getInt(); _iMed->getNode( index()+1 )->_coordID = coordID; } } @@ -667,10 +675,10 @@ void SauvReader::read_PILE_NOEUDS (const int nbObjects, std::vector */ //================================================================================ -void SauvReader::read_PILE_COORDONNEES (const int nbObjects, std::vector&, std::vector&) +void SauvReader::read_PILE_COORDONNEES (const int /*nbObjects*/, std::vector&, std::vector&) { initIntReading(1); - int nbReals = getIntNext(); + int const nbReals = getIntNext(); if ( nbReals < (int)(_iMed->_nbNodes*(_iMed->_spaceDim+1)) ) THROW_IK_EXCEPTION("Error of reading PILE NUMERO " << PILE_COORDONNEES << lineNb() ); @@ -699,8 +707,8 @@ void SauvReader::read_PILE_COORDONNEES (const int nbObjects, std::vector& supports, SauvUtilities::DoubleField* field) { - SauvUtilities::Group* group = NULL; - set sup_set( supports.begin(), supports.end() ); + SauvUtilities::Group* group = nullptr; + set const sup_set( supports.begin(), supports.end() ); if ( sup_set.size() == 1 ) // one or equal supports { group = supports[0]; @@ -711,13 +719,13 @@ void SauvReader::setFieldSupport(const vector& supports, map nbGaussByCellType; for ( size_t i = 0; i < supports.size(); ++i ) { - map::iterator ct2ng = nbGaussByCellType.find( supports[i]->_cellType ); + auto const ct2ng = nbGaussByCellType.find( supports[i]->_cellType ); if ( ct2ng == nbGaussByCellType.end() ) nbGaussByCellType[ supports[i]->_cellType ] = field->_sub[i].nbGauss(); else if ( ct2ng->second != field->_sub[i].nbGauss() ) return; } - bool isSameCellType = ( nbGaussByCellType.size() == 1 ); + bool const isSameCellType = ( nbGaussByCellType.size() == 1 ); // try to find an existing composite group with the same sub-groups if ( isSameCellType ) for ( size_t i = 0; i < _iMed->_groups.size() && !group; ++i ) @@ -757,8 +765,8 @@ void SauvReader::setFieldSupport(const vector& supports, isSwapped = false; for ( std::size_t i = 1; i < groups.size(); ++i ) { - std::size_t nbN1 = groups[i-1]->empty() ? 0 : groups[i-1]->_cells[0]->_nodes.size(); - std::size_t nbN2 = groups[i ]->empty() ? 0 : groups[i ]->_cells[0]->_nodes.size(); + std::size_t const nbN1 = groups[i-1]->empty() ? 0 : groups[i-1]->_cells[0]->_nodes.size(); + std::size_t const nbN2 = groups[i ]->empty() ? 0 : groups[i ]->_cells[0]->_nodes.size(); if ( nbN1 > nbN2 ) { isSwapped = isModified = true; @@ -774,12 +782,12 @@ void SauvReader::setFieldSupport(const vector& supports, size_t iFromSub = 0, iNewSub = 0, iNewComp = 0; for ( ; iFromSub < field->_sub.size(); iFromSub += groups.size() ) { - size_t iFromComp = iNewComp; - for ( size_t iG = 0; iG < groups.size(); ++iG ) + size_t const iFromComp = iNewComp; + for (auto & group : groups) { size_t iComp = iFromComp; for ( size_t iSub = iFromSub; iSub < field->_sub.size(); ++iSub ) - if ( field->_sub[ iSub ]._support == groups[ iG ] ) + if ( field->_sub[ iSub ]._support == group ) { newSub[ iNewSub++ ] = field->_sub[ iSub ]; int iC = 0, nbC = field->_sub[ iSub ].nbComponents(); @@ -817,7 +825,7 @@ void SauvReader::setFieldNames(const vector& field unsigned i; for ( i = 0; i < indices_objets_nommes.size(); ++i ) { - int fieldIndex = indices_objets_nommes[ i ]; + int const fieldIndex = indices_objets_nommes[ i ]; if ( fields[ fieldIndex - 1 ] ) fields[ fieldIndex - 1 ]->_name = objets_nommes[ i ]; } @@ -833,7 +841,7 @@ void SauvReader::read_PILE_NODES_FIELD (const int nbObjects, std::vector& objectNames, std::vector& nameIndices) { - _iMed->_nodeFields.resize( nbObjects, (SauvUtilities::DoubleField*) 0 ); + _iMed->_nodeFields.resize( nbObjects, (SauvUtilities::DoubleField*) nullptr ); for (int object=0; object!=nbObjects; ++object) // loop on fields { // EXAMPLE ( with no values ) @@ -867,7 +875,7 @@ void SauvReader::read_PILE_NODES_FIELD (const int nbObjects, initIntReading( nb_sub * 3 ); for ( i_sub = 0; i_sub < nb_sub; ++i_sub ) { - int supId = -getIntNext(); // (a) reference to support + int const supId = -getIntNext(); // (a) reference to support if ( supId < 1 || supId > (int)_iMed->_groups.size() ) THROW_IK_EXCEPTION("Wrong mesh reference: "<< supId << lineNb() ); supports[ i_sub ] = &_iMed->_groups[ supId-1 ]; // (a) reference to support @@ -880,7 +888,7 @@ void SauvReader::read_PILE_NODES_FIELD (const int nbObjects, } // create a field if there are values - SauvUtilities::DoubleField* fdouble = 0; + SauvUtilities::DoubleField* fdouble = nullptr; if ( total_nb_values > 0 ) fdouble = new DoubleField( nb_sub, total_nb_comp ); _iMed->_nodeFields[ object ] = fdouble; @@ -895,7 +903,7 @@ void SauvReader::read_PILE_NODES_FIELD (const int nbObjects, for ( i_comp = 0; i_comp < nb_comps[ i_sub ]; ++i_comp, next() ) { // store component name - string compName = getName(); + string const compName = getName(); if ( fdouble ) fdouble->_sub[ i_sub ].compName( i_comp ) = compName; } @@ -974,14 +982,14 @@ void SauvReader::read_PILE_FIELD (const int nbObjects, // (17) 1.00000000000000E+02 1.00000000000000E+02 1.00000000000000E+02 // (18) ... - _iMed->_cellFields.resize( nbObjects, (SauvUtilities::DoubleField*) 0 ); + _iMed->_cellFields.resize( nbObjects, (SauvUtilities::DoubleField*) nullptr ); for (int object=0; object!=nbObjects; ++object) // pour chaque field { initIntReading( 4 ); int i_sub, nb_sub = getIntNext(); // (1) 2 6 next(); // skip "2" next(); // skip "6" - int title_length = getIntNext(); // <title length> + int const title_length = getIntNext(); // <title length> if ( nb_sub < 1 ) THROW_IK_EXCEPTION("Error of field reading: wrong nb of subcomponents " << nb_sub << lineNb() ); @@ -1018,7 +1026,7 @@ void SauvReader::read_PILE_FIELD (const int nbObjects, vector<int> nb_comp( nb_sub ); for ( i_sub = 0; i_sub < nb_sub; ++i_sub ) { // (3) - int supportId = -getIntNext(); // <reference to support> + int const supportId = -getIntNext(); // <reference to support> next(); // ignore <address> nb_comp [ i_sub ] = getIntNext(); // <nb of components in the sub> for ( int i = 0; i < 6; ++i ) next(); // ignore 6 ints, in example "0 0 0 -2 0 3" @@ -1039,7 +1047,7 @@ void SauvReader::read_PILE_FIELD (const int nbObjects, // loop on subcomponents of a field, each of which refers to // a certain support and has its own number of components; // read component values - SauvUtilities::DoubleField* fdouble = 0; + SauvUtilities::DoubleField* fdouble = nullptr; for ( i_sub = 0; i_sub < nb_sub; ++ i_sub ) { vector<string> comp_names( nb_comp[ i_sub ]), comp_type( nb_comp[ i_sub ]); @@ -1059,7 +1067,7 @@ void SauvReader::read_PILE_FIELD (const int nbObjects, << ">" << lineNb() ); } // now type is known, create a field, one for all subs - bool isReal = (nb_comp[i_sub] > 0) ? (comp_type[0] == "REAL*8") : true; + bool const isReal = (nb_comp[i_sub] > 0) ? (comp_type[0] == "REAL*8") : true; if ( !fdouble && total_nb_comp ) { if ( !isReal ) @@ -1075,7 +1083,7 @@ void SauvReader::read_PILE_FIELD (const int nbObjects, { // (9) nb of values initIntReading( 4 ); - int nb_val_by_elem = getIntNext(); + int const nb_val_by_elem = getIntNext(); int nb_values = getIntNext(); next(); next(); @@ -1125,9 +1133,9 @@ void SauvReader::read_PILE_TABLES (const int nbObjects, { // IMP 0020434: mapping GIBI names to MED names - string table_med_mail = "MED_MAIL"; - string table_med_cham = "MED_CHAM"; - string table_med_comp = "MED_COMP"; + string const table_med_mail = "MED_MAIL"; + string const table_med_cham = "MED_CHAM"; + string const table_med_comp = "MED_COMP"; int table_med_mail_id = -1; int table_med_cham_id = -1; int table_med_comp_id = -1; @@ -1145,7 +1153,7 @@ void SauvReader::read_PILE_TABLES (const int nbObjects, // read tables "MED_MAIL", "MED_CHAM" and "MED_COMP", that keeps correspondence // between GIBI names (8 symbols if any) and MED names (possibly longer) initIntReading(1); - int nb_table_vals = getIntNext(); + int const nb_table_vals = getIntNext(); if (nb_table_vals < 0) THROW_IK_EXCEPTION("Error of reading PILE NUMERO 10" << lineNb() ); @@ -1208,13 +1216,13 @@ void SauvReader::read_PILE_TABLES (const int nbObjects, //================================================================================ void SauvReader::read_PILE_STRINGS (const int nbObjects, - std::vector<std::string>& objectNames, - std::vector<int>& nameIndices) + std::vector<std::string>& /*objectNames*/, + std::vector<int>& /*nameIndices*/) { // IMP 0020434: mapping GIBI names to MED names initIntReading(2); - int stringLen = getIntNext(); - int nbSubStrings = getIntNext(); + int const stringLen = getIntNext(); + int const nbSubStrings = getIntNext(); if (nbSubStrings != nbObjects) THROW_IK_EXCEPTION("Error of reading PILE NUMERO 27" << lineNb() ); @@ -1224,7 +1232,7 @@ void SauvReader::read_PILE_STRINGS (const int nbObjects, const int fixedLength = 71; while ((int)aWholeString.length() < stringLen) { - int remainLen = (int)(stringLen - aWholeString.length()); + int const remainLen = (int)(stringLen - aWholeString.length()); int len; if ( remainLen > fixedLength ) { @@ -1246,7 +1254,7 @@ void SauvReader::read_PILE_STRINGS (const int nbObjects, while ((int)aWholeString.length() < stringLen) { getNextLine( line ); - int remainLen = (int)(stringLen - aWholeString.length()); + int const remainLen = (int)(stringLen - aWholeString.length()); if ( remainLen > fixedLength ) { aWholeString += line + 1; diff --git a/src/MEDLoader/SauvReader.hxx b/src/MEDLoader/SauvReader.hxx index 789973176..d03bfab36 100644 --- a/src/MEDLoader/SauvReader.hxx +++ b/src/MEDLoader/SauvReader.hxx @@ -24,10 +24,10 @@ #define __SAUVREADER_HXX__ #include "MEDLoaderDefines.hxx" -#include "InterpKernelException.hxx" #include "SauvUtilities.hxx" #include "MEDCouplingRefCountObject.hxx" +#include <cstddef> #include <vector> #include <string> #include <set> @@ -48,12 +48,12 @@ class SauvReader : public MEDCoupling::RefCountObject public: MEDLOADER_EXPORT static SauvReader* New(const std::string& fileName); MEDLOADER_EXPORT MEDCoupling::MEDFileData * loadInMEDFileDS(); - MEDLOADER_EXPORT ~SauvReader(); + MEDLOADER_EXPORT ~SauvReader() override; MEDLOADER_EXPORT std::string getClassName() const override { return std::string("SauvReader"); } private: - std::size_t getHeapMemorySizeWithoutChildren() const; - std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const; + std::size_t getHeapMemorySizeWithoutChildren() const override; + std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const override; void readRecord2(); void readRecord4(); void readRecord7(); @@ -90,7 +90,7 @@ class SauvReader : public MEDCoupling::RefCountObject void next() { _fileReader->next(); } int index() const { return _fileReader->index(); } int getInt() const { return _fileReader->getInt(); } - int getIntNext() { int i = getInt(); next(); return i; } + int getIntNext() { int const i = getInt(); next(); return i; } float getFloat() const { return _fileReader->getFloat(); } double getDouble() const { return _fileReader->getDouble(); } std::string getName() const { return _fileReader->getName(); } diff --git a/src/MEDLoader/SauvUtilities.hxx b/src/MEDLoader/SauvUtilities.hxx index 9945aaf7d..c92e15c7a 100644 --- a/src/MEDLoader/SauvUtilities.hxx +++ b/src/MEDLoader/SauvUtilities.hxx @@ -25,10 +25,12 @@ #include "MEDLoaderDefines.hxx" #include "MEDCouplingRefCountObject.hxx" -#include "NormalizedUnstructuredMesh.hxx" +#include "NormalizedGeometricTypes" +#include <cstddef> #include <string> #include <sstream> +#include <vector> namespace SauvUtilities { @@ -88,7 +90,7 @@ namespace SauvUtilities { public: FileReader(const char* fileName); - virtual ~FileReader() {} + ~FileReader() override = default; virtual bool isASCII() const = 0; virtual bool open() = 0; @@ -104,8 +106,8 @@ namespace SauvUtilities virtual double getDouble() const = 0; virtual std::string getName() const = 0; protected: - std::size_t getHeapMemorySizeWithoutChildren() const { return 0; } - std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const { return std::vector<const BigMemoryObject *>(); } + std::size_t getHeapMemorySizeWithoutChildren() const override { return 0; } + std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const override { return std::vector<const BigMemoryObject *>(); } protected: std::string _fileName; int _iRead, _nbToRead; diff --git a/src/MEDLoader/SauvWriter.cxx b/src/MEDLoader/SauvWriter.cxx index 800cf9cff..77980d814 100644 --- a/src/MEDLoader/SauvWriter.cxx +++ b/src/MEDLoader/SauvWriter.cxx @@ -23,16 +23,30 @@ #include "SauvWriter.hxx" #include "InterpKernelException.hxx" +#include "MCIdType.hxx" +#include "MEDFileFieldMultiTS.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include "MCType.hxx" +#include "MEDCouplingUMesh.hxx" +#include "MCAuto.hxx" +#include "MEDCouplingMemArray.hxx" #include "MEDFileMesh.hxx" #include "MEDFileField.hxx" #include "MEDFileData.hxx" #include "CellModel.hxx" +#include "NormalizedGeometricTypes" +#include "SauvUtilities.hxx" +#include <cctype> #include <fstream> -#include <sstream> #include <iostream> #include <cstdlib> #include <iomanip> +#include <map> +#include <set> +#include <string> +#include <utility> +#include <vector> using namespace MEDCoupling; using namespace SauvUtilities; @@ -87,7 +101,7 @@ namespace if ( !name.empty() ) { // cut off leading white spaces - string::size_type firstChar = name.find_first_not_of(" \t"); + string::size_type const firstChar = name.find_first_not_of(" \t"); if (firstChar < name.length()) { name = name.substr(firstChar); @@ -97,7 +111,7 @@ namespace name = ""; // only whitespaces there - remove them } // cut off trailing white spaces - string::size_type lastChar = name.find_last_not_of(" \t"); + string::size_type const lastChar = name.find_last_not_of(" \t"); if (lastChar < name.length()) name = name.substr(0, lastChar + 1); } @@ -130,7 +144,7 @@ namespace if (!healedName.empty()) { string name = healedName; - std::size_t len = name.length(); + std::size_t const len = name.length(); for (std::size_t i = 0; i < len; ++i) name[i] = (char)toupper(name[i]); @@ -141,13 +155,13 @@ namespace { INFOS_MED("Save <" << theName << "> as <" << name << ">"); - map<string,int>::iterator it = nameMap.find(name); + auto const it = nameMap.find(name); if (it != nameMap.end()) { // There is already such name in the map. // a. Replace in the map the old pair by the current one - int old_ind = nameMap[name]; + int const old_ind = nameMap[name]; nameMap[name] = ind; // b. Rebuild the old pair (which was in the map, // it seems to be built automatically by step II) @@ -168,10 +182,10 @@ namespace if (new_loc_index > 0) { // prefix - string str = name.substr(0,5); + string const str = name.substr(0,5); if (namePrefixesMap.find(str) != namePrefixesMap.end()) { - int old_loc_index = namePrefixesMap[str]; + int const old_loc_index = namePrefixesMap[str]; if (new_loc_index < old_loc_index) new_loc_index = old_loc_index; } namePrefixesMap[str] = new_loc_index; @@ -187,7 +201,7 @@ namespace if (len > 5) name = name.substr(0,5); // numeric suffix - map<string,int>::iterator name2ind = namePrefixesMap.insert( make_pair( name, 0 )).first; + auto const name2ind = namePrefixesMap.insert( make_pair( name, 0 )).first; string numSuffix = SauvUtilities::toString( ++(name2ind->second) ); if ( numSuffix.size() + name.size() > 8 ) @@ -263,7 +277,7 @@ void SauvWriter::setMEDFileDS(const MEDFileData* medData, for ( int i = 0; i < fields->getNumberOfFields(); ++i ) { MEDFileAnyTypeFieldMultiTS * fB = fields->getFieldAtPos(i); - MEDFileFieldMultiTS * f = dynamic_cast<MEDFileFieldMultiTS *>(fB); + auto * f = dynamic_cast<MEDFileFieldMultiTS *>(fB); if(!f) continue;// fields on int32 not managed if ( f->getMeshName() == _fileMesh->getName() ) @@ -330,10 +344,8 @@ void SauvWriter::fillSubMeshes( int& nbSauvObjects, map<string,int>& nameNbMap ) // fill names of SubMesh'es and count nb of sauv sub-meshes they will be stored into nbSauvObjects = 0; map<string,int> namePrefixMap; - for ( size_t i = 0; i < _subs.size(); ++i ) + for (auto & sm : _subs) { - SubMesh& sm = _subs[i]; - sm._nbSauvObjects = 0; if ( sm._subs.empty() ) { @@ -369,11 +381,10 @@ void SauvWriter::fillSubMeshes( int& nbSauvObjects, map<string,int>& nameNbMap ) void SauvWriter::fillFamilySubMeshes() { - SubMesh* nilSm = (SubMesh*) 0; - std::vector<int> dims = _fileMesh->getNonEmptyLevelsExt(); - for ( size_t iDim = 0; iDim < dims.size(); ++iDim ) + auto* nilSm = (SubMesh*) nullptr; + std::vector<int> const dims = _fileMesh->getNonEmptyLevelsExt(); + for (int const dimRelExt : dims) { - int dimRelExt = dims[ iDim ]; MCAuto< MEDCouplingMesh > mesh = _fileMesh->getMeshAtLevel(dimRelExt); const DataArrayIdType * famIds = _fileMesh->getFamilyFieldAtLevel(dimRelExt); if ( !famIds ) continue; @@ -389,12 +400,12 @@ void SauvWriter::fillFamilySubMeshes() if ( *famID != curFamID ) { curFamID = *famID; - map< mcIdType, SubMesh* >::iterator f2s = _famIDs2Sub.insert( make_pair( curFamID, nilSm )).first; + auto const f2s = _famIDs2Sub.insert( make_pair( curFamID, nilSm )).first; if ( !f2s->second ) f2s->second = addSubMesh( "", dimRelExt ); // no names for families curSubMesh = f2s->second; } - INTERP_KERNEL::NormalizedCellType cellType = + INTERP_KERNEL::NormalizedCellType const cellType = dimRelExt == 1 ? INTERP_KERNEL::NORM_POINT1 : mesh->getTypeOfCell( cellID ); curSubMesh->_cellIDsByType[ cellType ].push_back( cellID ); } @@ -432,7 +443,7 @@ void SauvWriter::fillFamilySubMeshes() void SauvWriter::fillGroupSubMeshes() { const map<string, vector<string> >& grpFams = _fileMesh->getGroupInfo(); - map<string, vector<string> >::const_iterator g2ff = grpFams.begin(); + auto g2ff = grpFams.begin(); for ( ; g2ff != grpFams.end(); ++g2ff ) { const string& groupName = g2ff->first; @@ -440,10 +451,10 @@ void SauvWriter::fillGroupSubMeshes() if ( famNames.empty() ) continue; std::vector<SubMesh*> famSubMeshes( famNames.size() ); std::size_t k = 0; - for ( size_t i = 0; i < famNames.size(); ++i ) + for (const auto & famName : famNames) { - mcIdType famID = _fileMesh->getFamilyId( famNames[i].c_str() ); - map< mcIdType, SubMesh* >::iterator i2f = _famIDs2Sub.find( famID ); + mcIdType const famID = _fileMesh->getFamilyId( famName.c_str() ); + auto const i2f = _famIDs2Sub.find( famID ); if ( i2f != _famIDs2Sub.end() ) { famSubMeshes[ k ] = i2f->second; @@ -489,19 +500,19 @@ void SauvWriter::fillGroupSubMeshes() void SauvWriter::fillProfileSubMeshes() { _profile2Sub.clear(); - SubMesh* nilSm = (SubMesh*) 0; + auto* nilSm = (SubMesh*) nullptr; for ( int isOnNodes = 0; isOnNodes < 2; ++isOnNodes ) { vector< MCAuto< MEDFileFieldMultiTS > > fields = isOnNodes ? _nodeFields : _cellFields; - for ( size_t i = 0; i < fields.size(); ++i ) + for (auto & field : fields) { - vector< pair<int,int> > iters = fields[i]->getIterations(); + vector< pair<int,int> > iters = field->getIterations(); vector<INTERP_KERNEL::NormalizedCellType> types; vector< vector<TypeOfField> > typesF; vector< vector<string> > pfls, locs; - fields[i]->getFieldSplitedByType( iters[0].first, iters[0].second, + field->getFieldSplitedByType( iters[0].first, iters[0].second, _fileMesh->getName().c_str(), types, typesF, pfls, locs); int dimRelExt; for ( size_t iType = 0; iType < types.size(); ++iType ) @@ -512,14 +523,14 @@ void SauvWriter::fillProfileSubMeshes() dimRelExt = getDimension( types[iType] ) - _fileMesh->getMeshDimension(); for ( size_t iPfl = 0; iPfl < pfls[iType].size(); ++iPfl ) { - bool isOnAll = pfls[iType][iPfl].empty(); + bool const isOnAll = pfls[iType][iPfl].empty(); if ( isOnAll ) pfls[iType][iPfl] = noProfileName( types[iType] ); - map< string, SubMesh* >::iterator pfl2sm = + auto const pfl2sm = _profile2Sub.insert( make_pair( pfls[iType][iPfl], nilSm )).first; if ( !pfl2sm->second ) { SubMesh* sm = pfl2sm->second = addSubMesh( "", dimRelExt ); // no names for profiles - const DataArrayIdType * pfl = isOnAll ? 0 : fields[i]->getProfile( pfls[iType][iPfl].c_str() ); + const DataArrayIdType * pfl = isOnAll ? nullptr : field->getProfile( pfls[iType][iPfl].c_str() ); makeProfileIDs( sm, types[iType], pfl ); } } @@ -537,19 +548,19 @@ void SauvWriter::fillProfileSubMeshes() int SauvWriter::evaluateNbProfileSubMeshes() const { std::size_t nb = 0; - for ( std::size_t i = 0; i < _nodeFields.size(); ++i ) - nb += 1 + _nodeFields[i]->getPflsReallyUsed().size(); + for (const auto & _nodeField : _nodeFields) + nb += 1 + _nodeField->getPflsReallyUsed().size(); - for ( std::size_t i = 0; i < _cellFields.size(); ++i ) + for (const auto & _cellField : _cellFields) { - nb += _cellFields[i]->getPflsReallyUsed().size(); + nb += _cellField->getPflsReallyUsed().size(); - vector< pair<int,int> > iters = _cellFields[i]->getIterations(); + vector< pair<int,int> > iters = _cellField->getIterations(); vector<INTERP_KERNEL::NormalizedCellType> types; vector< vector<TypeOfField> > typesF; vector< vector<string> > pfls, locs; - _cellFields[i]->getFieldSplitedByType( iters[0].first, iters[0].second, + _cellField->getFieldSplitedByType( iters[0].first, iters[0].second, _fileMesh->getName().c_str(), types, typesF, pfls, locs); nb += 2 * types.size(); // x 2 - a type can be on nodes and on cells at the same time } @@ -569,7 +580,7 @@ void SauvWriter::makeProfileIDs( SubMesh* sm, { MCAuto< MEDCouplingMesh > mesh = _fileMesh->getMeshAtLevel(sm->_dimRelExt); - const MEDCouplingUMesh* uMesh = dynamic_cast< const MEDCouplingUMesh* > ((const MEDCouplingMesh*) mesh ); + const auto* uMesh = dynamic_cast< const MEDCouplingUMesh* > ((const MEDCouplingMesh*) mesh ); if ( sm->_dimRelExt == 1 ) type = INTERP_KERNEL::NORM_POINT1; vector< mcIdType >& ids = sm->_cellIDsByType[ type ]; @@ -603,7 +614,7 @@ void SauvWriter::makeProfileIDs( SubMesh* sm, code[1] = mesh->getNumberOfCellsWithType( type ); code[2] = -1; } - vector<const DataArrayIdType *> idsPerType( 1, profile ); + vector<const DataArrayIdType *> const idsPerType( 1, profile ); MCAuto<DataArrayIdType> resIDs = uMesh->checkTypeConsistencyAndContig( code, idsPerType ); if (( const DataArrayIdType *) resIDs ) @@ -691,7 +702,7 @@ void SauvWriter::writeNames( const map<string,int>& nameNbMap ) // * 8001 FORMAT(8(1X,A8)) TFieldCounter fcount( *_sauvFile, 8 ); *_sauvFile << left; - map<string,int>::const_iterator nameNbIt = nameNbMap.begin(); + auto nameNbIt = nameNbMap.begin(); for ( ; nameNbIt != nameNbMap.end(); nameNbIt++, fcount++ ) *_sauvFile << " " << setw(8) << nameNbIt->first; fcount.stop(); @@ -729,7 +740,7 @@ void SauvWriter::writeSubMeshes() for ( unsigned int iSub = 0; iSub < _subs.size(); ++iSub ) { - SubMesh& sm = _subs[iSub]; + SubMesh const& sm = _subs[iSub]; if ( sm._nbSauvObjects < 1 ) continue; // The first record of each sub-mesh writes @@ -756,13 +767,13 @@ void SauvWriter::writeSubMeshes() const vector<mcIdType>& cellIDs = sm._cellIDsByType[iType]; if ( cellIDs.empty() ) continue; - INTERP_KERNEL::NormalizedCellType + auto cellType = INTERP_KERNEL::NormalizedCellType( iType ); const INTERP_KERNEL::CellModel & cell = INTERP_KERNEL::CellModel::GetCellModel( cellType ); - int castemType = SauvUtilities::med2gibiGeom( cellType ); - unsigned nbElemNodes = cell.getNumberOfNodes(); - std::size_t nbElems = cellIDs.size(); + int const castemType = SauvUtilities::med2gibiGeom( cellType ); + unsigned const nbElemNodes = cell.getNumberOfNodes(); + std::size_t const nbElems = cellIDs.size(); *_sauvFile << setw(8) << castemType << zeroI8 @@ -818,13 +829,13 @@ void SauvWriter::writeSubMeshes() void SauvWriter::writeCompoundSubMesh(int iSub) { - SubMesh& sm = _subs[iSub]; + SubMesh const& sm = _subs[iSub]; if ( sm._nbSauvObjects < 1 || sm._subs.empty()) return; vector< int > subIDs; - for ( size_t i = 0; i < sm._subs.size(); ++i ) // loop on sub-meshes of families - for ( int j = 0; j < sm._subs[i]->_nbSauvObjects; ++j ) - subIDs.push_back( sm._subs[i]->_id + j ); + for (auto & _sub : sm._subs) // loop on sub-meshes of families + for ( int j = 0; j < _sub->_nbSauvObjects; ++j ) + subIDs.push_back( _sub->_id + j ); *_sauvFile << zeroI8 << setw(8) << subIDs.size() @@ -881,8 +892,8 @@ void SauvWriter::writeNodes() { for ( int j = 0; j < dim; ++j, fcount++ ) { - double coo = coordArray->getIJ( i, j ); - bool zero = ( -precision < coo && coo < precision ); + double const coo = coordArray->getIJ( i, j ); + bool const zero = ( -precision < coo && coo < precision ); *_sauvFile << setw(22) << ( zero ? 0.0 : coo ); } *_sauvFile << density; @@ -902,7 +913,7 @@ void SauvWriter::writeNodes() void SauvWriter::writeLongNames() { - int nbTables = + int const nbTables = 3 - _longNames[ LN_MAIL ].empty() - _longNames[ LN_CHAM ].empty() - _longNames[ LN_COMP ].empty(); if (nbTables == 0) return; @@ -938,7 +949,7 @@ void SauvWriter::writeLongNames() *_sauvFile << setw(8) << longNames.size()*4 << endl; // Nb of table values - vector<nameGIBItoMED>::iterator itGIBItoMED = longNames.begin(); + auto itGIBItoMED = longNames.begin(); for (; itGIBItoMED != longNames.end(); itGIBItoMED++, iStr++) { // PILE of i-th key (med name) @@ -1006,7 +1017,7 @@ void SauvWriter::writeFieldNames( const bool isNodal, for ( unsigned int iF = 0; iF < flds.size(); ++iF ) { - string name = addName( nameNbMap, fldNamePrefixMap, flds[iF]->getName(), iF+1 ); + string const name = addName( nameNbMap, fldNamePrefixMap, flds[iF]->getName(), iF+1 ); nameGIBItoMED aMEDName; aMEDName.gibi_pile = isNodal ? PILE_NODES_FIELD : PILE_FIELD; aMEDName.gibi_id = iF+1; @@ -1033,11 +1044,11 @@ void SauvWriter::makeCompNames(const string& fieldName, const vector<string>& compInfo, map<string, string>& mapMedToGibi) { - for ( size_t i = 0; i < compInfo.size(); ++i ) - mapMedToGibi[compInfo[i]] = cleanName( compInfo[i] ); + for (const auto & i : compInfo) + mapMedToGibi[i] = cleanName( i ); int compIndex = 1; - map<string, string>::iterator namesIt = mapMedToGibi.begin(); + auto namesIt = mapMedToGibi.begin(); for (; namesIt != mapMedToGibi.end(); namesIt++) { string & compGibiName = (*namesIt).second; @@ -1053,7 +1064,7 @@ void SauvWriter::makeCompNames(const string& fieldName, while (mapMedToGibi.count(compGibiName) > 0); // real component name could be CXXX } - string compMedName = fieldName + "." + namesIt->first; + string const compMedName = fieldName + "." + namesIt->first; nameGIBItoMED aMEDName; aMEDName.med_name = compMedName; aMEDName.gibi_pile = PILE_STRINGS; @@ -1084,11 +1095,11 @@ void SauvWriter::writeNodalFields(map<string,int>& fldNamePrefixMap) // (5) cree par muc pri // (6) // (7) 2 - for ( size_t iF = 0; iF < _nodeFields.size(); ++iF ) + for (auto & _nodeField : _nodeFields) { // (1) write nb subcomponents, nb components(total) - vector< pair<int,int> > iters = _nodeFields[iF]->getIterations(); - const vector<string>& compInfo = _nodeFields[iF]->getInfo(); + vector< pair<int,int> > const iters = _nodeField->getIterations(); + const vector<string>& compInfo = _nodeField->getInfo(); const std::size_t nbSub = iters.size(); const std::size_t nbComp = compInfo.size(); const std::size_t totalNbComp = nbSub * nbComp; @@ -1101,20 +1112,18 @@ void SauvWriter::writeNodalFields(map<string,int>& fldNamePrefixMap) // write support, number of values and number of components fcount.init(10); vector< mcIdType > vals(3); - for ( std::size_t iIt = 0; iIt < iters.size(); ++iIt ) + for (auto it : iters) { - pair<int,int> it = iters[iIt]; - vector<INTERP_KERNEL::NormalizedCellType> types; vector< vector<TypeOfField> > typesF; vector< vector<string> > pfls, locs; vector< vector< std::pair<mcIdType,mcIdType> > > valsVec; - valsVec=_nodeFields[iF]->getFieldSplitedByType( it.first, it.second, _fileMesh->getName().c_str(), + valsVec=_nodeField->getFieldSplitedByType( it.first, it.second, _fileMesh->getName().c_str(), types, typesF, pfls, locs); // believe that there can be only one type in a nodal field, // so do not use a loop on types if ( pfls[0][0].empty() ) pfls[0][0] = noProfileName( types[0] ); - map< string, SubMesh* >::iterator pfl2Sub = _profile2Sub.find( pfls[0][0] ); + auto const pfl2Sub = _profile2Sub.find( pfls[0][0] ); if ( pfl2Sub == _profile2Sub.end() ) THROW_IK_EXCEPTION( "SauvWriter::writeNodalFields(): no sub-mesh for profile |" << pfls[0][0] << "|"); @@ -1128,7 +1137,7 @@ void SauvWriter::writeNodalFields(map<string,int>& fldNamePrefixMap) // (3) Write names of components map<string, string> mapMedToGibi; - makeCompNames( _nodeFields[iF]->getName(), compInfo, mapMedToGibi ); + makeCompNames( _nodeField->getName(), compInfo, mapMedToGibi ); fcount.init(8); *_sauvFile << left; for ( std::size_t iIt = 0; iIt < iters.size(); ++iIt ) @@ -1143,26 +1152,24 @@ void SauvWriter::writeNodalFields(map<string,int>& fldNamePrefixMap) *_sauvFile << " " << setw(8) << 0; fcount.stop(); - string description = _nodeFields[iF]->getName(); + string const description = _nodeField->getName(); *_sauvFile << endl; // (5) TYPE *_sauvFile << setw(72) << description.substr(0,71) << endl; // (6) TITRE //*_sauvFile << endl; // (7) 0 attributes // write values of each component fcount.init( 3 ); // 3 values per a line - for ( std::size_t iIt = 0; iIt < iters.size(); ++iIt ) + for (auto it : iters) { - pair<int,int> it = iters[iIt]; - vector<INTERP_KERNEL::NormalizedCellType> types; vector< vector<TypeOfField> > typesF; vector< vector<string> > pfls, locs; vector< vector< std::pair<mcIdType,mcIdType> > > valsVec; - valsVec = _nodeFields[iF]->getFieldSplitedByType( it.first, it.second, _fileMesh->getName().c_str(), + valsVec = _nodeField->getFieldSplitedByType( it.first, it.second, _fileMesh->getName().c_str(), types, typesF, pfls, locs); // believe that there can be only one type in a nodal field, // so do not perform a loop on types - const DataArrayDouble* valsArray = _nodeFields[iF]->getUndergroundDataArray(it.first, it.second); + const DataArrayDouble* valsArray = _nodeField->getUndergroundDataArray(it.first, it.second); for ( size_t j = 0; j < compInfo.size(); ++j ) { for ( size_t i = valsVec[0][0].first; i < (std::size_t)valsVec[0][0].second; ++i, fcount++ ) @@ -1210,19 +1217,17 @@ void SauvWriter::writeElemFields(map<string,int>& fldNamePrefixMap) { // count nb of sub-components std::size_t iSub, nbSub = 0; - vector< pair<int,int> > iters = _cellFields[iF]->getIterations(); - for ( std::size_t iIt = 0; iIt < iters.size(); ++iIt ) + vector< pair<int,int> > const iters = _cellFields[iF]->getIterations(); + for (auto it : iters) { - pair<int,int> it = iters[iIt]; - vector<INTERP_KERNEL::NormalizedCellType> types; vector< vector<TypeOfField> > typesF; vector< vector<string> > pfls, locs; vector< vector< std::pair<mcIdType,mcIdType> > > valsVec; valsVec = _cellFields[iF]->getFieldSplitedByType( it.first, it.second, _fileMesh->getName().c_str(), types, typesF, pfls, locs); - for ( size_t i = 0; i < valsVec.size(); ++i ) - nbSub += valsVec[i].size(); + for (const auto & i : valsVec) + nbSub += i.size(); } // (1) write nb sub-components, title length *_sauvFile << setw(8) << nbSub @@ -1230,7 +1235,7 @@ void SauvWriter::writeElemFields(map<string,int>& fldNamePrefixMap) << setw(8) << 6 // whatever << setw(8) << 72 << endl; // title length // (2) title - string title = _cellFields[iF]->getName(); + string const title = _cellFields[iF]->getName(); *_sauvFile << setw(72) << title.substr(0,71) << endl; *_sauvFile << setw(72) << " " << endl; @@ -1239,10 +1244,8 @@ void SauvWriter::writeElemFields(map<string,int>& fldNamePrefixMap) const vector<string>& compInfo = _cellFields[iF]->getInfo(); vals[2] = ToIdType( compInfo.size() ); fcount.init(10); - for ( std::size_t iIt = 0; iIt < iters.size(); ++iIt ) + for (auto it : iters) { - pair<int,int> it = iters[iIt]; - vector<INTERP_KERNEL::NormalizedCellType> types; vector< vector<TypeOfField> > typesF; vector< vector<string> > pfls, locs; @@ -1252,7 +1255,7 @@ void SauvWriter::writeElemFields(map<string,int>& fldNamePrefixMap) for ( size_t iP = 0; iP < pfls[iType].size(); ++iP ) { if ( pfls[iType][iP].empty() ) pfls[iType][iP] = noProfileName( types[iType] ); - map< string, SubMesh* >::iterator pfl2Sub = _profile2Sub.find( pfls[iType][iP] ); + auto const pfl2Sub = _profile2Sub.find( pfls[iType][iP] ); if ( pfl2Sub == _profile2Sub.end() ) THROW_IK_EXCEPTION( "SauvWriter::writeElemFields(): no sub-mesh for profile |" << pfls[iType][iP] << "|"); @@ -1277,9 +1280,8 @@ void SauvWriter::writeElemFields(map<string,int>& fldNamePrefixMap) // loop on sub-components of a field, each of which refers to // a certain support and has its own number of components - for ( std::size_t iIt = 0; iIt < iters.size(); ++iIt ) + for (auto it : iters) { - pair<int,int> it = iters[iIt]; writeElemTimeStamp( iF, it.first, it.second ); } } // loop on cell fields @@ -1291,7 +1293,7 @@ void SauvWriter::writeElemFields(map<string,int>& fldNamePrefixMap) */ //================================================================================ -void SauvWriter::writeElemTimeStamp(int iF, int iter, int order) +void SauvWriter::writeElemTimeStamp(int iF, int iter, int order) { // (6) 317767 317761 317755 317815 // (7) YOUN NU H SIGY @@ -1343,7 +1345,7 @@ void SauvWriter::writeElemTimeStamp(int iF, int iter, int order) int nbPntPerCell = 1; if ( !locs[iType][iP].empty() ) { - int locID = _cellFields[iF]->getLocalizationId( locs[iType][iP].c_str() ); + int const locID = _cellFields[iF]->getLocalizationId( locs[iType][iP].c_str() ); nbPntPerCell = _cellFields[iF]->getNbOfGaussPtPerCell( locID ); } else if ( typesF[iType][iP] == ON_GAUSS_NE ) diff --git a/src/MEDLoader/SauvWriter.hxx b/src/MEDLoader/SauvWriter.hxx index 6b36b97f5..015722064 100644 --- a/src/MEDLoader/SauvWriter.hxx +++ b/src/MEDLoader/SauvWriter.hxx @@ -25,11 +25,13 @@ #include "MEDLoaderDefines.hxx" #include "MEDCouplingRefCountObject.hxx" -#include "NormalizedUnstructuredMesh.hxx" +#include "NormalizedGeometricTypes" #include "SauvUtilities.hxx" #include "MCAuto.hxx" #include "MCType.hxx" +#include <cstddef> +#include <fstream> #include <vector> #include <string> #include <map> @@ -55,8 +57,8 @@ namespace MEDCoupling MEDLOADER_EXPORT std::string getClassName() const override { return std::string("SauvWriter"); } private: SauvWriter(); - std::size_t getHeapMemorySizeWithoutChildren() const; - std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const; + std::size_t getHeapMemorySizeWithoutChildren() const override; + std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const override; /*! * \brief Class representing a GIBI sub-mesh (described in the pile 1 of the SAUVE file). * It stands for a named med sub-mesh (family, etc) and contains either cell IDs or other sub-meshes. diff --git a/src/MEDLoader/Test/MEDLoaderTest.cxx b/src/MEDLoader/Test/MEDLoaderTest.cxx index 5d1c77ddb..2c805e490 100644 --- a/src/MEDLoader/Test/MEDLoaderTest.cxx +++ b/src/MEDLoader/Test/MEDLoaderTest.cxx @@ -19,7 +19,12 @@ // Author : Anthony Geay (CEA/DEN) #include "MEDLoaderTest.hxx" -#include "MEDCouplingCMesh.hxx" +#include "InterpKernelException.hxx" +#include "MCIdType.hxx" +#include "MEDCouplingFieldInt.hxx" +#include "MCType.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include "MCAuto.hxx" #include "MEDLoader.hxx" #include "MEDLoaderBase.hxx" #include "MEDCouplingUMesh.hxx" @@ -27,11 +32,20 @@ #include "MEDCouplingFieldFloat.hxx" #include "MEDCouplingFieldInt64.hxx" #include "MEDCouplingMemArray.hxx" +#include "NormalizedGeometricTypes" #include "TestInterpKernelUtils.hxx" // getResourceFile() #include "MEDFileMesh.hxx" #include <algorithm> +#include <cmath> +#include <cppunit/TestAssert.h> +#include <functional> +#include <math.h> +#include <cstdint> #include <numeric> +#include <vector> +#include <utility> +#include <set> using namespace MEDCoupling; @@ -97,7 +111,7 @@ void MEDLoaderTest::testFieldRW1() { MEDCouplingFieldDouble *f1=buildVecFieldOnCells_1(); WriteField("file6.med",f1,true); - MEDCouplingFieldDouble *f2=dynamic_cast<MEDCouplingFieldDouble *>(ReadFieldCell("file6.med",f1->getMesh()->getName().c_str(),0,f1->getName().c_str(),0,1)); + auto *f2=dynamic_cast<MEDCouplingFieldDouble *>(ReadFieldCell("file6.med",f1->getMesh()->getName().c_str(),0,f1->getName().c_str(),0,1)); CPPUNIT_ASSERT(f1->isEqual(f2,1e-12,1e-12)); f1->decrRef(); f2->decrRef(); @@ -141,7 +155,7 @@ void MEDLoaderTest::testFieldRW2() WriteFieldUsingAlreadyWrittenMesh(fileName,f1_int64); WriteFieldUsingAlreadyWrittenMesh(fileName,f1_fl); //retrieving time steps... - MEDCouplingFieldDouble *f2=dynamic_cast<MEDCouplingFieldDouble *>(ReadFieldCell(fileName,f1->getMesh()->getName().c_str(),0,f1->getName().c_str(),8,9)); + auto *f2=dynamic_cast<MEDCouplingFieldDouble *>(ReadFieldCell(fileName,f1->getMesh()->getName().c_str(),0,f1->getName().c_str(),8,9)); f1->setTime(10.,8,9); tmp[0]=VAL1; CPPUNIT_ASSERT(f1->isEqual(f2,1e-12,1e-12)); @@ -164,11 +178,11 @@ void MEDLoaderTest::testFieldRW2() CPPUNIT_ASSERT(f1_int->isEqual(f2_int,1e-12,0)); // exact equality for int values f2_int->decrRef(); f1_int->decrRef(); - MEDCouplingFieldInt64 *f2_int64=dynamic_cast<MEDCouplingFieldInt64 *>(ReadFieldCell(fileName,f1_int64->getMesh()->getName().c_str(),0,f1_int64->getName().c_str(),8,9)); + auto *f2_int64=dynamic_cast<MEDCouplingFieldInt64 *>(ReadFieldCell(fileName,f1_int64->getMesh()->getName().c_str(),0,f1_int64->getName().c_str(),8,9)); CPPUNIT_ASSERT(f1_int64->isEqual(f2_int64,1e-12,0)); // exact equality for int values f2_int64->decrRef(); f1_int64->decrRef(); - MEDCouplingFieldFloat *f2_fl=dynamic_cast<MEDCouplingFieldFloat *>(ReadFieldCell(fileName,f1_fl->getMesh()->getName().c_str(),0,f1_fl->getName().c_str(),8,9)); + auto *f2_fl=dynamic_cast<MEDCouplingFieldFloat *>(ReadFieldCell(fileName,f1_fl->getMesh()->getName().c_str(),0,f1_fl->getName().c_str(),8,9)); CPPUNIT_ASSERT(f1_fl->isEqual(f2_fl,1e-12,1e-07f)); // float comparison f2_fl->decrRef(); f1_fl->decrRef(); @@ -292,10 +306,10 @@ void MEDLoaderTest::testMultiMeshRW1() const char fileName[]="file10.med"; MEDCouplingUMesh *mesh1=build3DMesh_1(); const mcIdType part1[5]={1,2,4,13,15}; - MEDCouplingUMesh *mesh2=(MEDCouplingUMesh *)mesh1->buildPartOfMySelf(part1,part1+5,true); + auto *mesh2=(MEDCouplingUMesh *)mesh1->buildPartOfMySelf(part1,part1+5,true); mesh2->setName("mesh2"); const mcIdType part2[4]={3,4,13,14}; - MEDCouplingUMesh *mesh3=(MEDCouplingUMesh *)mesh1->buildPartOfMySelf(part2,part2+4,true); + auto *mesh3=(MEDCouplingUMesh *)mesh1->buildPartOfMySelf(part2,part2+4,true); mesh3->setName("mesh3"); MEDCouplingUMesh *mesh4=MEDCouplingUMesh::New(); mesh4->setName("mesh4"); @@ -316,7 +330,7 @@ void MEDLoaderTest::testMultiMeshRW1() MEDCouplingUMesh *mesh5=ReadUMeshFromFile(fileName,mnane); mesh1->setName(mnane); const mcIdType part3[18]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17}; - MEDCouplingUMesh *mesh6=(MEDCouplingUMesh *)mesh5->buildPartOfMySelf(part3,part3+18,true); + auto *mesh6=(MEDCouplingUMesh *)mesh5->buildPartOfMySelf(part3,part3+18,true); mesh6->setName(mnane); mesh5->decrRef(); CPPUNIT_ASSERT(mesh6->isEqual(mesh1,1e-12)); @@ -354,7 +368,7 @@ void MEDLoaderTest::testMultiMeshRW1() mesh2_2->decrRef(); // std::vector<std::string> ret(GetMeshFamiliesNamesOnGroup(fileName,"3DToto","3DMesh_1")); - std::set<std::string> s(ret.begin(),ret.end()); + std::set<std::string> const s(ret.begin(),ret.end()); std::set<std::string> ref_s; ref_s.insert("Family_-2"); ref_s.insert("Family_-3"); @@ -384,10 +398,10 @@ void MEDLoaderTest::testFieldProfilRW1() da->decrRef(); WriteUMesh(fileName,mesh1,true); const mcIdType part1[5]={1,2,4,13,15}; - MEDCouplingUMesh *mesh2=(MEDCouplingUMesh *)mesh1->buildPartOfMySelf(part1,part1+5,true); + auto *mesh2=(MEDCouplingUMesh *)mesh1->buildPartOfMySelf(part1,part1+5,true); mesh2->setName(mesh1->getName().c_str());// <- important for the test // - mcIdType nbOfCells=mesh2->getNumberOfCells(); + mcIdType const nbOfCells=mesh2->getNumberOfCells(); CPPUNIT_ASSERT_EQUAL(ToIdType(5),nbOfCells); MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME); f1->setName("VectorFieldOnCells"); @@ -404,7 +418,7 @@ void MEDLoaderTest::testFieldProfilRW1() // WriteField(fileName,f1,false);// <- false important for the test // - MEDCouplingFieldDouble *f2=dynamic_cast<MEDCouplingFieldDouble *>(ReadFieldCell(fileName,f1->getMesh()->getName().c_str(),0,f1->getName().c_str(),2,7)); + auto *f2=dynamic_cast<MEDCouplingFieldDouble *>(ReadFieldCell(fileName,f1->getMesh()->getName().c_str(),0,f1->getName().c_str(),2,7)); std::vector<MEDCoupling::TypeOfField> types=GetTypesOfField(fileName,f1->getMesh()->getName().c_str(),f1->getName().c_str()); CPPUNIT_ASSERT_EQUAL(1,(int)types.size()); CPPUNIT_ASSERT(types[0]==ON_CELLS); @@ -425,7 +439,7 @@ void MEDLoaderTest::testFieldNodeProfilRW1() const char fileName[]="file19.med"; const char fileName2[]="file20.med"; MEDCouplingUMesh *m=build2DMesh_1(); - mcIdType nbOfNodes=m->getNumberOfNodes(); + mcIdType const nbOfNodes=m->getNumberOfNodes(); WriteUMesh(fileName,m,true); MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_NODES,ONE_TIME); f1->setName("VFieldOnNodes"); @@ -445,7 +459,7 @@ void MEDLoaderTest::testFieldNodeProfilRW1() (const_cast<MEDCouplingMesh *>(f2->getMesh()))->setName(f1->getMesh()->getName().c_str()); WriteField(fileName,f2,false);// <- false important for the test // - MEDCouplingFieldDouble *f3=dynamic_cast<MEDCouplingFieldDouble *>(ReadFieldNode(fileName,f2->getMesh()->getName().c_str(),0,f2->getName().c_str(),2,7)); + auto *f3=dynamic_cast<MEDCouplingFieldDouble *>(ReadFieldNode(fileName,f2->getMesh()->getName().c_str(),0,f2->getName().c_str(),2,7)); f3->checkConsistencyLight(); CPPUNIT_ASSERT(f3->isEqual(f2,1e-12,1e-12)); f3->decrRef(); @@ -491,7 +505,7 @@ void MEDLoaderTest::testFieldNodeProfilRW2() f1->renumberNodes(renumArr); f1->checkConsistencyLight(); WriteField(fileName,f1,false);// <- false important for the test - MEDCouplingFieldDouble *f2=dynamic_cast<MEDCouplingFieldDouble *>(ReadFieldNode(fileName,f1->getMesh()->getName().c_str(),0,f1->getName().c_str(),2,7)); + auto *f2=dynamic_cast<MEDCouplingFieldDouble *>(ReadFieldNode(fileName,f1->getMesh()->getName().c_str(),0,f1->getName().c_str(),2,7)); CPPUNIT_ASSERT(f2->isEqual(f1,1e-12,1e-12)); // f2->decrRef(); @@ -589,7 +603,7 @@ void MEDLoaderTest::testFieldShuffleRW1() const mcIdType renumber1[6]={2,1,5,0,3,4}; f1->renumberCells(renumber1,false); WriteField(fileName,f1,true); - MEDCouplingFieldDouble *f2=dynamic_cast<MEDCouplingFieldDouble *>((MEDCouplingField *)ReadFieldCell(fileName,mesh->getName().c_str(),0,f1->getName().c_str(),2,7)); + auto *f2=dynamic_cast<MEDCouplingFieldDouble *>((MEDCouplingField *)ReadFieldCell(fileName,mesh->getName().c_str(),0,f1->getName().c_str(),2,7)); CPPUNIT_ASSERT(f2->isEqual(f1,1e-12,1e-12)); f2->decrRef(); // @@ -642,8 +656,8 @@ void MEDLoaderTest::testMultiFieldShuffleRW1() CPPUNIT_ASSERT(fs[2]->isEqual(f_3,1e-12,1e-12)); CPPUNIT_ASSERT(mm==fs[1]->getMesh());// <- important for the test CPPUNIT_ASSERT(mm==fs[2]->getMesh());// <- important for the test - for(std::vector<MEDCouplingFieldDouble *>::iterator iter=fs.begin();iter!=fs.end();iter++) - (*iter)->decrRef(); + for(auto & f : fs) + f->decrRef(); // f_1->decrRef(); f_2->decrRef(); @@ -660,7 +674,7 @@ void MEDLoaderTest::testWriteUMeshesRW1() const double vec[3]={0.,0.,1.}; std::vector<mcIdType> nodes; m3d->findNodesOnPlane(pt,vec,1e-12,nodes); - MEDCouplingUMesh *m2d=(MEDCouplingUMesh *)m3d->buildFacePartOfMySelfNode(&nodes[0],&nodes[0]+nodes.size(),true); + auto *m2d=(MEDCouplingUMesh *)m3d->buildFacePartOfMySelfNode(&nodes[0],&nodes[0]+nodes.size(),true); const mcIdType renumber[5]={1,2,0,4,3}; m2d->renumberCells(renumber,false); m2d->setName("ExampleOfMultiDimW"); @@ -690,7 +704,7 @@ void MEDLoaderTest::testWriteUMeshesRW1() f1->setTime(3.14,2,7); f1->checkConsistencyLight(); WriteFieldUsingAlreadyWrittenMesh(fileName,f1); - MEDCouplingFieldDouble *f2=dynamic_cast<MEDCouplingFieldDouble *>((MEDCouplingField *)ReadFieldCell(fileName,f1->getMesh()->getName().c_str(),-1,f1->getName().c_str(),2,7)); + auto *f2=dynamic_cast<MEDCouplingFieldDouble *>((MEDCouplingField *)ReadFieldCell(fileName,f1->getMesh()->getName().c_str(),-1,f1->getName().c_str(),2,7)); CPPUNIT_ASSERT(f2->isEqual(f1,1e-12,1e-12)); f1->decrRef(); f2->decrRef(); @@ -755,7 +769,7 @@ void MEDLoaderTest::testMixCellAndNodesFieldRW1() CPPUNIT_ASSERT_EQUAL(ON_NODES,ts[0]); CPPUNIT_ASSERT_EQUAL(ON_CELLS,ts[1]); // - MEDCouplingFieldDouble *f3=dynamic_cast<MEDCouplingFieldDouble *>((MEDCouplingField *)ReadFieldNode(fileName,f1->getMesh()->getName().c_str(),0,f1->getName().c_str(),2,7)); + auto *f3=dynamic_cast<MEDCouplingFieldDouble *>((MEDCouplingField *)ReadFieldNode(fileName,f1->getMesh()->getName().c_str(),0,f1->getName().c_str(),2,7)); CPPUNIT_ASSERT(f3->isEqual(f2,1e-12,1e-12)); f3->decrRef(); f3=dynamic_cast<MEDCouplingFieldDouble *>((MEDCouplingField *)ReadFieldCell(fileName,f1->getMesh()->getName().c_str(),0,f1->getName().c_str(),2,7)); @@ -808,7 +822,7 @@ void MEDLoaderTest::testMEDLoaderRead1() using namespace std; using namespace INTERP_KERNEL; - string fileName= INTERP_TEST::getResourceFile("pointe.med", 3); + string const fileName= INTERP_TEST::getResourceFile("pointe.med", 3); vector<string> meshNames=GetMeshNames(fileName.c_str()); CPPUNIT_ASSERT_EQUAL(1,(int)meshNames.size()); MEDCouplingUMesh *mesh=ReadUMeshFromFile(fileName.c_str(),meshNames[0].c_str(),0); @@ -886,7 +900,7 @@ void MEDLoaderTest::testMEDLoaderRead1() CPPUNIT_ASSERT_EQUAL(-1,its1[0].first); CPPUNIT_ASSERT_EQUAL(-1,its1[0].second); // - MEDCouplingFieldDouble *field0=dynamic_cast<MEDCouplingFieldDouble *>((MEDCouplingField *)ReadFieldCell(fileName.c_str(),meshNames[0].c_str(),0,fieldsName[0].c_str(),its0[0].first,its0[0].second)); + auto *field0=dynamic_cast<MEDCouplingFieldDouble *>((MEDCouplingField *)ReadFieldCell(fileName.c_str(),meshNames[0].c_str(),0,fieldsName[0].c_str(),its0[0].first,its0[0].second)); field0->checkConsistencyLight(); CPPUNIT_ASSERT(field0->getName()==fieldsName[0]); CPPUNIT_ASSERT_EQUAL(1,(int)field0->getNumberOfComponents()); @@ -896,7 +910,7 @@ void MEDLoaderTest::testMEDLoaderRead1() std::transform(field0->getArray()->getPointer(),field0->getArray()->getPointer()+16,expectedValues,diffValue,std::minus<double>()); CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,*std::max_element(diffValue,diffValue+16),1e-12); CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,*std::min_element(diffValue,diffValue+16),1e-12); - const MEDCouplingUMesh *constMesh=dynamic_cast<const MEDCouplingUMesh *>(field0->getMesh()); + const auto *constMesh=dynamic_cast<const MEDCouplingUMesh *>(field0->getMesh()); CPPUNIT_ASSERT(constMesh); CPPUNIT_ASSERT_EQUAL(3,constMesh->getSpaceDimension()); CPPUNIT_ASSERT_EQUAL(3,constMesh->getMeshDimension()); @@ -915,7 +929,7 @@ void MEDLoaderTest::testMEDLoaderRead1() CPPUNIT_ASSERT_DOUBLES_EQUAL(46.,std::accumulate(constMesh->getCoords()->getConstPointer(),constMesh->getCoords()->getConstPointer()+57,0),1e-12); field0->decrRef(); // - MEDCouplingFieldDouble *field1=dynamic_cast<MEDCouplingFieldDouble *>((MEDCouplingField *)ReadFieldCell(fileName.c_str(),meshNames[0].c_str(),0,fieldsName[1].c_str(),its1[0].first,its1[0].second)); + auto *field1=dynamic_cast<MEDCouplingFieldDouble *>((MEDCouplingField *)ReadFieldCell(fileName.c_str(),meshNames[0].c_str(),0,fieldsName[1].c_str(),its1[0].first,its1[0].second)); field1->checkConsistencyLight(); CPPUNIT_ASSERT(field1->getName()==fieldsName[1]); CPPUNIT_ASSERT_EQUAL(3,(int)field1->getNumberOfComponents()); @@ -956,7 +970,7 @@ void MEDLoaderTest::testMEDLoaderRead1() CPPUNIT_ASSERT_EQUAL(-1,its0Node[1].second); CPPUNIT_ASSERT_EQUAL(2,its0Node[2].first); CPPUNIT_ASSERT_EQUAL(-1,its0Node[2].second); - MEDCouplingFieldDouble *field0Nodes=dynamic_cast<MEDCouplingFieldDouble *>((MEDCouplingField *)ReadFieldNode(fileName.c_str(),meshNames[0].c_str(),0,fieldsNameNode[0].c_str(),its0Node[0].first,its0Node[0].second)); + auto *field0Nodes=dynamic_cast<MEDCouplingFieldDouble *>((MEDCouplingField *)ReadFieldNode(fileName.c_str(),meshNames[0].c_str(),0,fieldsNameNode[0].c_str(),its0Node[0].first,its0Node[0].second)); field0Nodes->checkConsistencyLight(); CPPUNIT_ASSERT(field0Nodes->getName()==fieldsNameNode[0]); CPPUNIT_ASSERT_EQUAL(1,(int)field0Nodes->getNumberOfComponents()); @@ -1032,7 +1046,7 @@ void MEDLoaderTest::testMEDLoaderPolygonRead() using namespace std; using namespace INTERP_KERNEL; - string fileName=INTERP_TEST::getResourceFile("polygones.med", 3); + string const fileName=INTERP_TEST::getResourceFile("polygones.med", 3); vector<string> meshNames=GetMeshNames(fileName.c_str()); CPPUNIT_ASSERT_EQUAL(1,(int)meshNames.size()); CPPUNIT_ASSERT(meshNames[0]=="Bord"); @@ -1065,12 +1079,12 @@ void MEDLoaderTest::testMEDLoaderPolygonRead() CPPUNIT_ASSERT(fieldsName[2]=="bord_:_non-ortho"); std::vector<std::pair<int,int> > its0=GetCellFieldIterations(fileName.c_str(),meshNames[0].c_str(),fieldsName[0].c_str()); CPPUNIT_ASSERT_EQUAL(1,(int)its0.size()); - MEDCouplingFieldDouble *field=dynamic_cast<MEDCouplingFieldDouble *>((MEDCouplingField *)ReadFieldCell(fileName.c_str(),meshNames[0].c_str(),0,fieldsName[0].c_str(),its0[0].first,its0[0].second)); + auto *field=dynamic_cast<MEDCouplingFieldDouble *>((MEDCouplingField *)ReadFieldCell(fileName.c_str(),meshNames[0].c_str(),0,fieldsName[0].c_str(),its0[0].first,its0[0].second)); field->checkConsistencyLight(); CPPUNIT_ASSERT(field->getName()==fieldsName[0]); CPPUNIT_ASSERT_EQUAL(1,(int)field->getNumberOfComponents()); CPPUNIT_ASSERT_EQUAL(538,(int)field->getNumberOfTuples()); - const MEDCouplingUMesh *constMesh=dynamic_cast<const MEDCouplingUMesh *>(field->getMesh()); + const auto *constMesh=dynamic_cast<const MEDCouplingUMesh *>(field->getMesh()); CPPUNIT_ASSERT(constMesh); CPPUNIT_ASSERT_EQUAL(3,constMesh->getSpaceDimension()); CPPUNIT_ASSERT_EQUAL(2,constMesh->getMeshDimension()); @@ -1098,7 +1112,7 @@ void MEDLoaderTest::testMEDLoaderPolyhedronRead() using namespace std; using namespace INTERP_KERNEL; - string fileName=INTERP_TEST::getResourceFile("poly3D.med", 3); + string const fileName=INTERP_TEST::getResourceFile("poly3D.med", 3); vector<string> meshNames=GetMeshNames(fileName.c_str()); CPPUNIT_ASSERT_EQUAL(1,(int)meshNames.size()); CPPUNIT_ASSERT(meshNames[0]=="poly3D"); @@ -1373,11 +1387,11 @@ MEDCouplingUMesh *MEDLoaderTest::build3DMesh_2() { MEDCouplingUMesh *m3dsurfBase=build3DSurfMesh_1(); mcIdType numbers[5]={0,1,2,3,5}; - MEDCouplingUMesh *m3dsurf=(MEDCouplingUMesh *)m3dsurfBase->buildPartOfMySelf(numbers,numbers+5,false); + auto *m3dsurf=(MEDCouplingUMesh *)m3dsurfBase->buildPartOfMySelf(numbers,numbers+5,false); m3dsurfBase->decrRef(); MEDCouplingUMesh *m1dBase=build1DMesh_1(); mcIdType numbers2[4]={0,1,2,3}; - MEDCouplingUMesh *m1d=(MEDCouplingUMesh *)m1dBase->buildPartOfMySelf(numbers2,numbers2+4,false); + auto *m1d=(MEDCouplingUMesh *)m1dBase->buildPartOfMySelf(numbers2,numbers2+4,false); m1dBase->decrRef(); m1d->changeSpaceDimension(3); const double vec[3]={0.,1.,0.}; @@ -1392,7 +1406,7 @@ MEDCouplingUMesh *MEDLoaderTest::build3DMesh_2() MEDCouplingFieldDouble *MEDLoaderTest::buildVecFieldOnCells_1() { MEDCouplingUMesh *mesh=build3DSurfMesh_1(); - mcIdType nbOfCells=mesh->getNumberOfCells(); + mcIdType const nbOfCells=mesh->getNumberOfCells(); MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME); f1->setName("VectorFieldOnCells"); f1->setMesh(mesh); @@ -1415,7 +1429,7 @@ MEDCouplingFieldDouble *MEDLoaderTest::buildVecFieldOnCells_1() MEDCouplingFieldInt *MEDLoaderTest::buildIntVecFieldOnCells_1() { MEDCouplingUMesh *mesh=build3DSurfMesh_1(); - mcIdType nbOfCells=mesh->getNumberOfCells(); + mcIdType const nbOfCells=mesh->getNumberOfCells(); MEDCouplingFieldInt *f1=MEDCouplingFieldInt::New(ON_CELLS,ONE_TIME); f1->setName("IntVectorFieldOnCells"); f1->setMesh(mesh); @@ -1438,7 +1452,7 @@ MEDCouplingFieldInt *MEDLoaderTest::buildIntVecFieldOnCells_1() MEDCouplingFieldInt64 *MEDLoaderTest::buildInt64VecFieldOnCells_1() { MEDCouplingUMesh *mesh=build3DSurfMesh_1(); - mcIdType nbOfCells=mesh->getNumberOfCells(); + mcIdType const nbOfCells=mesh->getNumberOfCells(); MEDCouplingFieldInt64 *f1=MEDCouplingFieldInt64::New(ON_CELLS,ONE_TIME); f1->setName("Int64VectorFieldOnCells"); f1->setMesh(mesh); @@ -1461,7 +1475,7 @@ MEDCouplingFieldInt64 *MEDLoaderTest::buildInt64VecFieldOnCells_1() MEDCouplingFieldFloat *MEDLoaderTest::buildFloatVecFieldOnCells_1() { MEDCouplingUMesh *mesh=build3DSurfMesh_1(); - mcIdType nbOfCells=mesh->getNumberOfCells(); + mcIdType const nbOfCells=mesh->getNumberOfCells(); MEDCouplingFieldFloat *f1=MEDCouplingFieldFloat::New(ON_CELLS,ONE_TIME); f1->setName("FloatVectorFieldOnCells"); f1->setMesh(mesh); @@ -1485,7 +1499,7 @@ MEDCouplingFieldFloat *MEDLoaderTest::buildFloatVecFieldOnCells_1() MEDCouplingFieldDouble *MEDLoaderTest::buildVecFieldOnNodes_1() { MEDCouplingUMesh *mesh=build3DSurfMesh_1(); - mcIdType nbOfNodes=mesh->getNumberOfNodes(); + mcIdType const nbOfNodes=mesh->getNumberOfNodes(); MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_NODES,ONE_TIME); f1->setName("VectorFieldOnNodes"); f1->setMesh(mesh); @@ -1518,7 +1532,7 @@ MEDCouplingFieldDouble *MEDLoaderTest::buildVecFieldOnGauss_1() const double gsCoo1[12]={ 2*_b-1, 1-4*_b, 2*_b-1, 2.07*_b-1, 1-4*_b, 2*_b-1, 1-4*_a, 2*_a-1, 2*_a-1, 1-4*_a, 2*_a-1, 2*_a-1 }; const double wg1[6]={ 4*_p2, 4*_p2, 4*_p2, 4*_p1, 4*_p1, 4*_p1 }; - std::vector<double> _refCoo1(refCoo1,refCoo1+6); + std::vector<double> const _refCoo1(refCoo1,refCoo1+6); std::vector<double> _gsCoo1(gsCoo1,gsCoo1+12); std::vector<double> _wg1(wg1,wg1+6); MEDCouplingUMesh *m=build2DMesh_2(); @@ -1527,12 +1541,12 @@ MEDCouplingFieldDouble *MEDLoaderTest::buildVecFieldOnGauss_1() f->setMesh(m); f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_TRI3,_refCoo1,_gsCoo1,_wg1); const double refCoo2[12]={-1.0,1.0, -1.0,-1.0, 1.0,-1.0, -1.0,0.0, 0.0,-1.0, 0.0,0.0 }; - std::vector<double> _refCoo2(refCoo2,refCoo2+12); + std::vector<double> const _refCoo2(refCoo2,refCoo2+12); std::vector<double> _gsCoo2(_gsCoo1); std::vector<double> _wg2(_wg1); _gsCoo2.resize(6); _wg2.resize(3); const double refCoo3[8]={ 0.,0., 1.,0., 1.,1., 0.,1. }; - std::vector<double> _refCoo3(refCoo3,refCoo3+8); + std::vector<double> const _refCoo3(refCoo3,refCoo3+8); _gsCoo1.resize(4); _wg1.resize(2); f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_QUAD4,_refCoo3,_gsCoo1,_wg1); f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_TRI6,_refCoo2,_gsCoo2,_wg2); diff --git a/src/MEDLoader/Test/MEDLoaderTest.hxx b/src/MEDLoader/Test/MEDLoaderTest.hxx index dc3332af2..d059df3c5 100644 --- a/src/MEDLoader/Test/MEDLoaderTest.hxx +++ b/src/MEDLoader/Test/MEDLoaderTest.hxx @@ -22,6 +22,8 @@ #define __MEDLOADERTEST_HXX__ #include "MEDCouplingFieldInt.hxx" // this one can not use a class forward +#include <cppunit/TestFixture.h> +#include "MEDCouplingTraits.hxx" #include <cppunit/extensions/HelperMacros.h> namespace MEDCoupling diff --git a/src/MEDLoader/Test/SauvLoaderTest.cxx b/src/MEDLoader/Test/SauvLoaderTest.cxx index 408f26994..a79107242 100644 --- a/src/MEDLoader/Test/SauvLoaderTest.cxx +++ b/src/MEDLoader/Test/SauvLoaderTest.cxx @@ -19,12 +19,30 @@ #include "SauvLoaderTest.hxx" +#include "MCAuto.hxx" +#include "MCIdType.hxx" +#include "MCType.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include "MEDCouplingUMesh.hxx" +#include "NormalizedGeometricTypes" +#include "MEDFileMesh.hxx" +#include "MEDFileField.hxx" +#include "MEDFileFieldMultiTS.hxx" +#include "MEDCouplingMesh.hxx" #include "SauvReader.hxx" #include "SauvWriter.hxx" #include "MEDFileData.hxx" #include "MEDCouplingFieldDouble.hxx" #include "MEDCouplingMemArray.hxx" #include "TestInterpKernelUtils.hxx" // getResourceFile() +#include <algorithm> +#include <cppunit/TestAssert.h> +#include <iostream> +#include <cstddef> +#include <map> +#include <stdio.h> +#include <vector> +#include <utility> #ifdef WIN32 #include <windows.h> @@ -32,7 +50,6 @@ # include <unistd.h> #endif -#include <vector> #include <string> using namespace MEDCoupling; @@ -40,7 +57,7 @@ using namespace MEDCoupling; void SauvLoaderTest::testSauv2Med() { // read a file containing all types of readable piles - std::string file = INTERP_TEST::getResourceFile("allPillesTest.sauv", 3); + std::string const file = INTERP_TEST::getResourceFile("allPillesTest.sauv", 3); MCAuto<SauvReader> sr=SauvReader::New(file.c_str()); MCAuto<MEDFileData> d2=sr->loadInMEDFileDS(); // write MED @@ -113,7 +130,7 @@ void SauvLoaderTest::testMed2SauvOnAMeshWithVoidFamily() // read SAUV and check groups MCAuto<SauvReader> sr=SauvReader::New(sauvFile); MCAuto<MEDFileData> d2=sr->loadInMEDFileDS(); - MEDFileUMesh* m2 = static_cast<MEDFileUMesh*>( d2->getMeshes()->getMeshAtPos(0) ); + auto* m2 = static_cast<MEDFileUMesh*>( d2->getMeshes()->getMeshAtPos(0) ); MCAuto<MEDCouplingUMesh> group1 = m2->getGroup(0, "Group1"); CPPUNIT_ASSERT_EQUAL(1,(int)group1->getNumberOfCells()); MCAuto<MEDCouplingUMesh> group2 = m2->getGroup(0, "Group2"); @@ -125,13 +142,13 @@ void SauvLoaderTest::testMed2SauvOnAMeshWithVoidFamily() void SauvLoaderTest::testSauv2MedOnA3SubsField() { // read SAUV - std::string sauvFile = INTERP_TEST::getResourceFile("portico_3subs.sauv", 3); + std::string const sauvFile = INTERP_TEST::getResourceFile("portico_3subs.sauv", 3); MCAuto<SauvReader> sr=SauvReader::New(sauvFile.c_str()); MCAuto<MEDFileData> d2=sr->loadInMEDFileDS(); // check mesh - MEDFileUMesh* m2 = static_cast<MEDFileUMesh*>(d2->getMeshes()->getMeshAtPos(0)); + auto* m2 = static_cast<MEDFileUMesh*>(d2->getMeshes()->getMeshAtPos(0)); MCAuto<MEDCouplingUMesh> mesh1d = m2->getMeshAtLevel(0); - MCAuto<MEDCouplingFieldDouble> length1dField = mesh1d->getMeasureField(0); + MCAuto<MEDCouplingFieldDouble> length1dField = mesh1d->getMeasureField(false); std::cout << "Length of 1d elements: " << length1dField->accumulate(0) << std::endl; CPPUNIT_ASSERT_DOUBLES_EQUAL(3, length1dField->accumulate(0), 1e-12); // check field @@ -146,7 +163,7 @@ void SauvLoaderTest::testSauv2MedOnA3SubsField() // Check first component of the field // 2 gauss points per element => 12 values - double values[12] = { + double const values[12] = { -7.687500000000e-03, -7.687500000000e-03, -4.562500000000e-03, @@ -169,11 +186,11 @@ void SauvLoaderTest::testSauv2MedOnA3SubsField() void SauvLoaderTest::testMed2Sauv() { // read pointe.med - std::string file = INTERP_TEST::getResourceFile("pointe.med", 3); + std::string const file = INTERP_TEST::getResourceFile("pointe.med", 3); MCAuto<MEDFileData> pointeMed=MEDFileData::New(file.c_str()); // add 3 faces to pointeMed - MEDFileUMesh* pointeMedMesh = static_cast<MEDFileUMesh*>(pointeMed->getMeshes()->getMeshAtPos(0)); + auto* pointeMedMesh = static_cast<MEDFileUMesh*>(pointeMed->getMeshes()->getMeshAtPos(0)); MCAuto<MEDCouplingUMesh> pointeM1D = MEDCouplingUMesh::New(); DataArrayDouble *coords = pointeMedMesh->getCoords(); pointeM1D->setCoords( coords ); @@ -238,7 +255,7 @@ void SauvLoaderTest::testMed2Sauv() MCAuto<MEDFileData> d2=sr->loadInMEDFileDS(); CPPUNIT_ASSERT_EQUAL(1,d2->getNumberOfMeshes()); CPPUNIT_ASSERT_EQUAL(4,d2->getNumberOfFields()); - MEDFileUMesh * m = static_cast<MEDFileUMesh*>( d2->getMeshes()->getMeshAtPos(0) ); + auto * m = static_cast<MEDFileUMesh*>( d2->getMeshes()->getMeshAtPos(0) ); CPPUNIT_ASSERT_EQUAL(std::string("maa1"),std::string(m->getName() )); CPPUNIT_ASSERT_EQUAL(3,m->getMeshDimension()); std::vector<std::string > groups = m->getGroupsNames(); @@ -262,8 +279,8 @@ void SauvLoaderTest::testMed2Sauv() DataArrayDouble *coo = m->getCoords(); DataArrayDouble *pointeCoo = pointeMedMesh->getCoords(); CPPUNIT_ASSERT(coo->isEqualWithoutConsideringStr(*pointeCoo,1e-12)); - MCAuto<MEDCouplingFieldDouble> vol = um0->getMeasureField(0); - MCAuto<MEDCouplingFieldDouble> pointeVol = pointeUM0->getMeasureField(0); + MCAuto<MEDCouplingFieldDouble> vol = um0->getMeasureField(false); + MCAuto<MEDCouplingFieldDouble> pointeVol = pointeUM0->getMeasureField(false); CPPUNIT_ASSERT_DOUBLES_EQUAL( vol->accumulate(0), pointeVol->accumulate(0),1e-12); // check fields // fieldnodedouble @@ -318,7 +335,7 @@ void SauvLoaderTest::testMed2Sauv() void SauvLoaderTest::testCellsWithLingNames() { // test IMP 3285: [CEA 1778] SauvReader: only keep the meshes named in the table MED_MAIL - std::string file = INTERP_TEST::getResourceFile("test_MED_MAIL.sauv", 3); + std::string const file = INTERP_TEST::getResourceFile("test_MED_MAIL.sauv", 3); MCAuto<SauvReader> sr=SauvReader::New(file.c_str()); MCAuto<MEDFileData> d2=sr->loadInMEDFileDS(); // check that the mesh contains @@ -327,7 +344,7 @@ void SauvLoaderTest::testCellsWithLingNames() // - Nombre de mailles de type MED_QUAD4 : 43 // - Nombre de mailles de type MED_HEXA8 : 24 // - Nombre de mailles de type MED_PENTA6 : 3 - MEDFileUMesh* m = static_cast<MEDFileUMesh*>( d2->getMeshes()->getMeshAtPos(0)); + auto* m = static_cast<MEDFileUMesh*>( d2->getMeshes()->getMeshAtPos(0)); CPPUNIT_ASSERT_EQUAL(ToIdType(6), m->getNumberOfCellsWithType( INTERP_KERNEL::NORM_TRI3 )); CPPUNIT_ASSERT_EQUAL(ToIdType(43), m->getNumberOfCellsWithType( INTERP_KERNEL::NORM_QUAD4 )); CPPUNIT_ASSERT_EQUAL(ToIdType(24), m->getNumberOfCellsWithType( INTERP_KERNEL::NORM_HEXA8 )); @@ -342,17 +359,17 @@ void SauvLoaderTest::tearDown() #else const char* fileToRemove[nbFilesToRemove] = { "allPillesTest.med", "pointe.sauv", "mesh_with_void_family.sauv" }; #endif - for ( int i = 0; i < nbFilesToRemove; ++i ) + for (auto & i : fileToRemove) { #ifdef WIN32 if (GetFileAttributes(fileToRemove[i]) != INVALID_FILE_ATTRIBUTES) #else - if (access(fileToRemove[i], F_OK) == 0) + if (access(i, F_OK) == 0) #endif #if defined(WIN32) && defined(UNICODE) _wremove(fileToRemove[i]); #else - remove(fileToRemove[i]); + remove(i); #endif } } diff --git a/src/MEDLoader/Test/SauvLoaderTest.hxx b/src/MEDLoader/Test/SauvLoaderTest.hxx index 799445d57..27147aa92 100644 --- a/src/MEDLoader/Test/SauvLoaderTest.hxx +++ b/src/MEDLoader/Test/SauvLoaderTest.hxx @@ -20,9 +20,9 @@ #ifndef __SauvLoaderTest_HXX__ #define __SauvLoaderTest_HXX__ +#include <cppunit/TestFixture.h> #include <cppunit/extensions/HelperMacros.h> -#include "MEDLoaderTest.hxx" namespace MEDCoupling { @@ -43,7 +43,7 @@ namespace MEDCoupling void testCellsWithLingNames(); public: - void tearDown(); + void tearDown() override; }; } diff --git a/src/MEDLoader/Test/TestMEDLoader.cxx b/src/MEDLoader/Test/TestMEDLoader.cxx index 9e73982d1..73a391128 100644 --- a/src/MEDLoader/Test/TestMEDLoader.cxx +++ b/src/MEDLoader/Test/TestMEDLoader.cxx @@ -18,9 +18,9 @@ // // Author : Anthony Geay (CEA/DEN) -#include "CppUnitTest.hxx" #include "MEDLoaderTest.hxx" #include "CrackAlgoTest.hxx" +#include <cppunit/extensions/HelperMacros.h> CPPUNIT_TEST_SUITE_REGISTRATION( MEDCoupling::MEDLoaderTest ); CPPUNIT_TEST_SUITE_REGISTRATION( MEDCoupling::CrackAlgoTest ); diff --git a/src/MEDLoader/Test/TestSauvLoader.cxx b/src/MEDLoader/Test/TestSauvLoader.cxx index d2c8d4d68..6f6e7d1dd 100644 --- a/src/MEDLoader/Test/TestSauvLoader.cxx +++ b/src/MEDLoader/Test/TestSauvLoader.cxx @@ -17,9 +17,8 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -#include "CppUnitTest.hxx" #include "SauvLoaderTest.hxx" +#include <cppunit/extensions/HelperMacros.h> CPPUNIT_TEST_SUITE_REGISTRATION( MEDCoupling::SauvLoaderTest ); -#include "BasicMainTest.hxx" diff --git a/src/MEDLoader/libmesh5.hxx b/src/MEDLoader/libmesh5.hxx index f1d755390..f1e6da8b3 100644 --- a/src/MEDLoader/libmesh5.hxx +++ b/src/MEDLoader/libmesh5.hxx @@ -52,6 +52,7 @@ // see MeshGems/Docs/meshgems_formats_description.pdf extern const char* GmfKwdFmt[ GmfMaxKwd + 1 ][4]; // occ/24009 +#include <cstdio> #include "MEDLoaderDefines.hxx" /*----------------------------------------------------------*/ /* Structures */ diff --git a/src/MEDPartitioner/MEDPARTITIONER_ConnectZone.cxx b/src/MEDPartitioner/MEDPARTITIONER_ConnectZone.cxx index 9970753be..0bc2be98c 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_ConnectZone.cxx +++ b/src/MEDPartitioner/MEDPARTITIONER_ConnectZone.cxx @@ -19,9 +19,14 @@ #include "MEDPARTITIONER_ConnectZone.hxx" +#include "MCIdType.hxx" +#include "MCAuto.hxx" +#include "MCType.hxx" #include "MEDCouplingSkyLineArray.hxx" #include <map> +#include <utility> +#include <vector> using namespace MEDCoupling; @@ -30,18 +35,18 @@ MEDPARTITIONER::ConnectZone::ConnectZone(): ,_description("") ,_local_domain_number(0) ,_distant_domain_number(0) - ,_local_mesh(0) - ,_distant_mesh(0) - ,_node_corresp(0) - ,_face_corresp(0) + ,_local_mesh(nullptr) + ,_distant_mesh(nullptr) + ,_node_corresp(nullptr) + ,_face_corresp(nullptr) { } MEDPARTITIONER::ConnectZone::~ConnectZone() { - for(std::map < std::pair <mcIdType, mcIdType>,MEDCouplingSkyLineArray * >::iterator iter=_entity_corresp.begin(); iter!=_entity_corresp.end();iter++) + for(auto & iter : _entity_corresp) { - iter->second->decrRef(); + iter.second->decrRef(); } } @@ -50,8 +55,8 @@ MEDPARTITIONER::ConnectZone::ConnectZone(const ConnectZone & myConnectZone): ,_description(myConnectZone._description) ,_local_domain_number(myConnectZone._local_domain_number) ,_distant_domain_number(myConnectZone._distant_domain_number) - ,_local_mesh(0) - ,_distant_mesh(0) + ,_local_mesh(nullptr) + ,_distant_mesh(nullptr) ,_node_corresp(myConnectZone._node_corresp) ,_face_corresp(myConnectZone._face_corresp) ,_entity_corresp(myConnectZone._entity_corresp) @@ -91,9 +96,9 @@ MEDCouplingUMesh *MEDPARTITIONER::ConnectZone::getDistantMesh() const bool MEDPARTITIONER::ConnectZone::isEntityCorrespPresent(mcIdType localEntity, mcIdType distantEntity) const { typedef std::map<std::pair<mcIdType,mcIdType>, MEDCouplingSkyLineArray*>::const_iterator map_iter; - for(map_iter iter=_entity_corresp.begin(); iter != _entity_corresp.end(); iter++) + for(const auto & iter : _entity_corresp) { - if ((iter->first).first==localEntity && (iter->first).second==distantEntity) + if ((iter.first).first==localEntity && (iter.first).second==distantEntity) return true; } return false; @@ -144,12 +149,12 @@ const mcIdType *MEDPARTITIONER::ConnectZone::getEntityCorrespIndex(mcIdType loca { typedef std::map<std::pair<mcIdType,mcIdType>, MEDCouplingSkyLineArray*>::const_iterator map_iter; - for(map_iter iter=_entity_corresp.begin();iter!=_entity_corresp.end();iter++) + for(const auto & iter : _entity_corresp) { - if ((iter->first).first==localEntity && (iter->first).second==distantEntity) - return iter->second->getIndex(); + if ((iter.first).first==localEntity && (iter.first).second==distantEntity) + return iter.second->getIndex(); } - return 0; + return nullptr; } const mcIdType *MEDPARTITIONER::ConnectZone::getEntityCorrespValue(mcIdType localEntity, @@ -157,12 +162,12 @@ const mcIdType *MEDPARTITIONER::ConnectZone::getEntityCorrespValue(mcIdType loca { typedef std::map<std::pair<mcIdType,mcIdType>, MEDCouplingSkyLineArray*>::const_iterator map_iter; - for (map_iter iter=_entity_corresp.begin();iter!=_entity_corresp.end();iter++) + for (const auto & iter : _entity_corresp) { - if ((iter->first).first==localEntity && (iter->first).second==distantEntity) - return iter->second->getValues(); + if ((iter.first).first==localEntity && (iter.first).second==distantEntity) + return iter.second->getValues(); } - return 0; + return nullptr; } mcIdType MEDPARTITIONER::ConnectZone::getEntityCorrespNumber(mcIdType localEntity, @@ -170,10 +175,10 @@ mcIdType MEDPARTITIONER::ConnectZone::getEntityCorrespNumber(mcIdType localEntit { typedef std::map<std::pair<mcIdType,mcIdType>, MEDCouplingSkyLineArray*>::const_iterator map_iter; - for(map_iter iter=_entity_corresp.begin();iter!=_entity_corresp.end();iter++) + for(const auto & iter : _entity_corresp) { - if((iter->first).first==localEntity && (iter->first).second==distantEntity) - return iter->second->getNumberOf(); + if((iter.first).first==localEntity && (iter.first).second==distantEntity) + return iter.second->getNumberOf(); } return 0; } @@ -183,10 +188,10 @@ mcIdType MEDPARTITIONER::ConnectZone::getEntityCorrespLength(mcIdType localEntit { typedef std::map<std::pair<mcIdType,mcIdType>, MEDCouplingSkyLineArray*>::const_iterator map_iter; - for (map_iter iter=_entity_corresp.begin(); iter != _entity_corresp.end(); iter++) + for (const auto & iter : _entity_corresp) { - if ((iter->first).first==localEntity && (iter->first).second==distantEntity) - return iter->second->getLength(); + if ((iter.first).first==localEntity && (iter.first).second==distantEntity) + return iter.second->getLength(); } return 0; } @@ -196,19 +201,19 @@ MEDPARTITIONER::ConnectZone::getEntityCorresp(mcIdType localEntity, mcIdType dis { typedef std::map<std::pair<mcIdType,mcIdType>, MEDCouplingSkyLineArray*>::const_iterator map_iter; - for (map_iter iter=_entity_corresp.begin(); iter != _entity_corresp.end(); iter++) + for (const auto & iter : _entity_corresp) { - if ((iter->first).first==localEntity && (iter->first).second==distantEntity) - return iter->second; + if ((iter.first).first==localEntity && (iter.first).second==distantEntity) + return iter.second; } - return 0; + return nullptr; } std::vector< std::pair< mcIdType,mcIdType > > MEDPARTITIONER::ConnectZone::getEntities() const { std::vector< std::pair< mcIdType,mcIdType > > types; - std::map<std::pair<mcIdType,mcIdType>, MEDCouplingSkyLineArray*>::const_iterator + auto iter = _entity_corresp.begin(); for ( ; iter != _entity_corresp.end(); iter++) { @@ -272,7 +277,7 @@ void MEDPARTITIONER::ConnectZone::setNodeCorresp(const mcIdType * nodeCorresp, m void MEDPARTITIONER::ConnectZone::setNodeCorresp(MEDCouplingSkyLineArray* array) { - MCAuto<MEDCouplingSkyLineArray> arr(array); + MCAuto<MEDCouplingSkyLineArray> const arr(array); _node_corresp = arr; } @@ -300,7 +305,7 @@ void MEDPARTITIONER::ConnectZone::setFaceCorresp(const mcIdType * faceCorresp, m void MEDPARTITIONER::ConnectZone::setFaceCorresp(MEDCouplingSkyLineArray* array) { - MCAuto<MEDCouplingSkyLineArray> arr (array); + MCAuto<MEDCouplingSkyLineArray> const arr (array); _face_corresp = arr; } @@ -332,7 +337,7 @@ void MEDPARTITIONER::ConnectZone::setEntityCorresp(mcIdType localEntity, mcIdTyp void MEDPARTITIONER::ConnectZone::setEntityCorresp(mcIdType localEntity, mcIdType distantEntity, MEDCouplingSkyLineArray *array) { - MEDCouplingSkyLineArray * nullArray = 0; + MEDCouplingSkyLineArray * nullArray = nullptr; std::map < std::pair <mcIdType,mcIdType>, MEDCouplingSkyLineArray * >::iterator it; it = _entity_corresp.insert ( std::make_pair( std::make_pair(localEntity,distantEntity), nullArray )).first; diff --git a/src/MEDPartitioner/MEDPARTITIONER_ConnectZone.hxx b/src/MEDPartitioner/MEDPARTITIONER_ConnectZone.hxx index ef4eec328..9128c22ba 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_ConnectZone.hxx +++ b/src/MEDPartitioner/MEDPARTITIONER_ConnectZone.hxx @@ -20,9 +20,10 @@ #ifndef __MEDPARTITIONER_CONNECTZONE_HXX__ #define __MEDPARTITIONER_CONNECTZONE_HXX__ +#include "MCIdType.hxx" #include "MEDPARTITIONER.hxx" #include "MCAuto.hxx" -#include "MCType.hxx" +#include <utility> namespace MEDCoupling { diff --git a/src/MEDPartitioner/MEDPARTITIONER_Graph.cxx b/src/MEDPartitioner/MEDPARTITIONER_Graph.cxx index 652ba4f87..29ba8e788 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_Graph.cxx +++ b/src/MEDPartitioner/MEDPARTITIONER_Graph.cxx @@ -19,6 +19,8 @@ #include "MEDPARTITIONER_Graph.hxx" +#include "MCIdType.hxx" +#include "MCType.hxx" #include "MEDCouplingSkyLineArray.hxx" #include <set> @@ -26,20 +28,19 @@ namespace MEDPARTITIONER { Graph::Graph(): - _graph(0),_partition(0), - _edge_weight(0),_cell_weight(0) + _graph(nullptr),_partition(nullptr), + _edge_weight(nullptr),_cell_weight(nullptr) { } Graph::Graph(MEDCoupling::MEDCouplingSkyLineArray *array, int *edgeweight): - _graph(array),_partition(0), - _edge_weight(edgeweight),_cell_weight(0) + _graph(array),_partition(nullptr), + _edge_weight(edgeweight),_cell_weight(nullptr) { } Graph::~Graph() - { - } + = default; int Graph::nbDomains() const { @@ -47,8 +48,8 @@ namespace MEDPARTITIONER if ( _partition.isNotNull() ) if ( MEDCoupling::DataArrayIdType* array = _partition->getValuesArray() ) { - for ( const mcIdType * dom = array->begin(); dom != array->end(); ++dom ) - domains.insert( *dom ); + for (long const dom : *array) + domains.insert( dom ); } return (int)domains.size(); } diff --git a/src/MEDPartitioner/MEDPARTITIONER_Graph.hxx b/src/MEDPartitioner/MEDPARTITIONER_Graph.hxx index bd799a3b4..2beab244b 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_Graph.hxx +++ b/src/MEDPartitioner/MEDPARTITIONER_Graph.hxx @@ -20,9 +20,9 @@ #ifndef __MEDPARTITIONER_GRAPH_HXX__ #define __MEDPARTITIONER_GRAPH_HXX__ +#include "MCIdType.hxx" #include "MEDPARTITIONER.hxx" #include "MCAuto.hxx" -#include "MCType.hxx" #include <string> @@ -39,18 +39,18 @@ namespace MEDPARTITIONER class MEDPARTITIONER_EXPORT Graph { public: - typedef enum {METIS,SCOTCH,PTSCOTCH} splitter_type; + using splitter_type = enum {METIS,SCOTCH,PTSCOTCH}; Graph(); //creates a graph from a SKYLINEARRAY- WARNING!! Graph takes ownership of the array. - Graph(MEDCouplingSkyLineArray* graph, int* edgeweight=0); + Graph(MEDCouplingSkyLineArray* graph, int* edgeweight=nullptr); virtual ~Graph(); void setEdgesWeights(int *edgeweight) { _edge_weight=edgeweight; } void setVerticesWeights(int *cellweight) { _cell_weight=cellweight; } //computes partitioning of the graph - virtual void partGraph(int ndomain, const std::string& options_string="", ParaDomainSelector *sel=0) = 0; + virtual void partGraph(int ndomain, const std::string& options_string="", ParaDomainSelector *sel=nullptr) = 0; //returns the partitioning const mcIdType *getPart() const; diff --git a/src/MEDPartitioner/MEDPARTITIONER_JointFinder.cxx b/src/MEDPartitioner/MEDPARTITIONER_JointFinder.cxx index 229592f98..6e1861f9c 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_JointFinder.cxx +++ b/src/MEDPartitioner/MEDPARTITIONER_JointFinder.cxx @@ -18,13 +18,22 @@ // #include "MEDPARTITIONER_JointFinder.hxx" + +#include <algorithm> +#include <cstddef> +#include <iostream> +#include <utility> +#include <map> +#include <vector> + +#include "MCType.hxx" +#include "MCIdType.hxx" #include "MEDPARTITIONER_MeshCollection.hxx" #include "MEDPARTITIONER_Topology.hxx" #include "MEDPARTITIONER_ParaDomainSelector.hxx" #include "MEDPARTITIONER_Utils.hxx" #include "MEDCouplingUMesh.hxx" -#include "BBTree.txx" /*! * Method contributing to the distant cell graph @@ -34,12 +43,11 @@ MEDPARTITIONER::JointFinder::JointFinder(const MeshCollection& mc):_mesh_collect } MEDPARTITIONER::JointFinder::~JointFinder() -{ -} += default; void MEDPARTITIONER::JointFinder::findCommonDistantNodes() { - int nbdomain=_topology->nbDomain(); + int const nbdomain=_topology->nbDomain(); _distant_node_cell.resize(nbdomain); _node_node.resize(nbdomain); for (int i=0; i<nbdomain; i++) @@ -47,11 +55,11 @@ void MEDPARTITIONER::JointFinder::findCommonDistantNodes() _distant_node_cell[i].resize(nbdomain); _node_node[i].resize(nbdomain); } - int nbproc=_domain_selector->nbProcs(); - std::vector<BBTreeOfDim* > bbtree(nbdomain,(BBTreeOfDim*) 0); - std::vector<double* > bbxi(nbdomain,(double*) 0); - std::vector<MEDCoupling::DataArrayIdType*> rev(nbdomain,(MEDCoupling::DataArrayIdType*) 0); - std::vector<MEDCoupling::DataArrayIdType*> revIndx(nbdomain,(MEDCoupling::DataArrayIdType*) 0); + int const nbproc=_domain_selector->nbProcs(); + std::vector<BBTreeOfDim* > bbtree(nbdomain,(BBTreeOfDim*) nullptr); + std::vector<double* > bbxi(nbdomain,(double*) nullptr); + std::vector<MEDCoupling::DataArrayIdType*> rev(nbdomain,(MEDCoupling::DataArrayIdType*) nullptr); + std::vector<MEDCoupling::DataArrayIdType*> revIndx(nbdomain,(MEDCoupling::DataArrayIdType*) nullptr); //int meshDim=-1; int spaceDim=-1; @@ -66,14 +74,14 @@ void MEDPARTITIONER::JointFinder::findCommonDistantNodes() rev[mydomain] = MEDCoupling::DataArrayIdType::New(); revIndx[mydomain] = MEDCoupling::DataArrayIdType::New(); myMesh->getReverseNodalConnectivity(rev[mydomain],revIndx[mydomain]); - double* bbx=new double[2*spaceDim*myMesh->getNumberOfNodes()]; + auto* bbx=new double[2*spaceDim*myMesh->getNumberOfNodes()]; for (int i=0; i<myMesh->getNumberOfNodes()*spaceDim; i++) { const double* coords=myMesh->getCoords()->getConstPointer(); bbx[2*i]=(coords[i])-1e-12; bbx[2*i+1]=bbx[2*i]+2e-12; } - bbtree[mydomain]=new BBTreeOfDim( spaceDim, bbx,0,0,myMesh->getNumberOfNodes(),-1e-12); + bbtree[mydomain]=new BBTreeOfDim( spaceDim, bbx,nullptr,0,myMesh->getNumberOfNodes(),-1e-12); //keep bbx because need it in getIntersectingElems //no delete [] bbx yet bbxi[mydomain]=bbx; @@ -90,7 +98,7 @@ void MEDPARTITIONER::JointFinder::findCommonDistantNodes() if (_domain_selector->isMyDomain(isource)) { //preparing data for treatment on target proc - int targetProc = _domain_selector->getProcessorID(itarget); + int const targetProc = _domain_selector->getProcessorID(itarget); std::vector<double> vec(spaceDim*sourceMesh->getNumberOfNodes()); std::copy(sourceMesh->getCoords()->getConstPointer(),sourceMesh->getCoords()->getConstPointer()+sourceMesh->getNumberOfNodes()*spaceDim,&vec[0]); @@ -109,13 +117,13 @@ void MEDPARTITIONER::JointFinder::findCommonDistantNodes() if (_domain_selector->isMyDomain(itarget)) { //receiving data from source proc - int sourceProc = isource%nbproc; + int const sourceProc = isource%nbproc; std::vector<double> recvVec; RecvDoubleVec(recvVec,sourceProc); std::map<mcIdType,mcIdType> commonNodes; // (local nodes, distant nodes) list for (mcIdType inode=0; inode<ToIdType(recvVec.size()/spaceDim); inode++) { - double* bbox=new double[2*spaceDim]; + auto* bbox=new double[2*spaceDim]; for (int i=0; i<spaceDim; i++) { bbox[2*i]=recvVec[inode*spaceDim+i]-1e-12; @@ -132,15 +140,15 @@ void MEDPARTITIONER::JointFinder::findCommonDistantNodes() } std::vector<mcIdType> nodeCellCorrespondency; - for (std::map<mcIdType,mcIdType>::iterator iter=commonNodes.begin(); iter!=commonNodes.end(); iter++) + for (auto & commonNode : commonNodes) { - _node_node[itarget][isource].push_back(std::make_pair(iter->first, iter->second));//storing node pairs in a vector + _node_node[itarget][isource].push_back(std::make_pair(commonNode.first, commonNode.second));//storing node pairs in a vector const mcIdType* revIndxPtr=revIndx[itarget]->getConstPointer(); const mcIdType* revPtr=rev[itarget]->getConstPointer(); - for (mcIdType icell=revIndxPtr[iter->first]; icell<revIndxPtr[iter->first+1]; icell++) + for (mcIdType icell=revIndxPtr[commonNode.first]; icell<revIndxPtr[commonNode.first+1]; icell++) { - nodeCellCorrespondency.push_back(iter->second); // - mcIdType globalCell=_topology->convertCellToGlobal(itarget,revPtr[icell]); + nodeCellCorrespondency.push_back(commonNode.second); // + mcIdType const globalCell=_topology->convertCellToGlobal(itarget,revPtr[icell]); nodeCellCorrespondency.push_back(globalCell); } } @@ -152,13 +160,13 @@ void MEDPARTITIONER::JointFinder::findCommonDistantNodes() //free rev(nbdomain) revIndx(nbdomain) bbtree(nbdomain) bbxi(nbdomain) for (int i=0; i<nbdomain; i++) { - if (rev[i]!=0) + if (rev[i]!=nullptr) rev[i]->decrRef(); - if (revIndx[i]!=0) + if (revIndx[i]!=nullptr) revIndx[i]->decrRef(); - if (bbtree[i]!=0) + if (bbtree[i]!=nullptr) delete bbtree[i]; - if (bbxi[i]!=0) + if (bbxi[i]!=nullptr) delete [] bbxi[i]; } @@ -179,7 +187,7 @@ std::vector<std::vector<std::vector<std::pair<mcIdType,mcIdType> > > >& MEDPARTI void MEDPARTITIONER::JointFinder::print() //it is for debug on small arrays under mpi 2,3 cpus { - int nbdomain=_topology->nbDomain(); + int const nbdomain=_topology->nbDomain(); //MPI_Barrier(MPI_COMM_WORLD); if (MyGlobals::_Is0verbose>0) std::cout << "\nJointFinder print node-node (nn)iproc|itarget|isource|i|inodefirst-inodesecond\n\n" << diff --git a/src/MEDPartitioner/MEDPARTITIONER_JointFinder.hxx b/src/MEDPartitioner/MEDPARTITIONER_JointFinder.hxx index 79c0d2d0d..898813946 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_JointFinder.hxx +++ b/src/MEDPartitioner/MEDPARTITIONER_JointFinder.hxx @@ -20,10 +20,11 @@ #ifndef __MEDPARTITIONER_JOINTFINDER_HXX__ #define __MEDPARTITIONER_JOINTFINDER_HXX__ +#include "MCIdType.hxx" #include "MEDPARTITIONER.hxx" -#include "MCType.hxx" #include <map> +#include <utility> #include <vector> namespace MEDPARTITIONER diff --git a/src/MEDPartitioner/MEDPARTITIONER_MEDPartitioner.cxx b/src/MEDPartitioner/MEDPARTITIONER_MEDPartitioner.cxx index cf75ce812..829fffa00 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_MEDPartitioner.cxx +++ b/src/MEDPartitioner/MEDPARTITIONER_MEDPartitioner.cxx @@ -18,12 +18,15 @@ // #include "MEDPARTITIONER_MEDPartitioner.hxx" +#include "MCType.hxx" +#include "MCAuto.hxx" #include "MEDPARTITIONER_MeshCollection.hxx" #include "MEDPARTITIONER_Topology.hxx" #include "MEDPARTITIONER_ParaDomainSelector.hxx" #include "MEDPARTITIONER_ParallelTopology.hxx" #include "MEDPARTITIONER_Utils.hxx" #include "MEDPARTITIONER_Graph.hxx" +#include <string> #ifdef MED_ENABLE_METIS # include "MEDPARTITIONER_MetisGraph.hxx" #endif @@ -38,7 +41,6 @@ #include "MEDCouplingUMesh.hxx" #include "MEDCouplingSkyLineArray.hxx" -#include <iostream> #include <vector> const char MEDPARTITIONER::MEDPartitioner::METIS_PART_ALG[]="Metis"; @@ -46,7 +48,7 @@ const char MEDPARTITIONER::MEDPartitioner::SCOTCH_PART_ALG[]="Scotch"; const char MEDPARTITIONER::MEDPartitioner::PTSCOTCH_PART_ALG[]="PTScotch"; MEDPARTITIONER::MEDPartitioner::MEDPartitioner(const std::string& filename, int ndomains, const std::string& library,bool create_boundary_faces, bool create_joints, bool mesure_memory): - _input_collection( 0 ), _output_collection( 0 ), _new_topology( 0 ) + _input_collection( nullptr ), _output_collection( nullptr ), _new_topology( nullptr ) { MyGlobals::_World_Size = 1; MyGlobals::_Rank = 0; @@ -57,7 +59,7 @@ MEDPARTITIONER::MEDPartitioner::MEDPartitioner(const std::string& filename, int _input_collection=new MeshCollection(filename,parallelizer); _input_collection->setParaDomainSelector( ¶llelizer ); - MEDPARTITIONER::ParallelTopology* aPT = + auto* aPT = (MEDPARTITIONER::ParallelTopology*) _input_collection->getTopology(); aPT->setGlobalNumerotationDefault( _input_collection->getParaDomainSelector() ); _input_collection->prepareFieldDescriptions(); @@ -67,7 +69,7 @@ MEDPARTITIONER::MEDPartitioner::MEDPartitioner(const std::string& filename, int } MEDPARTITIONER::MEDPartitioner::MEDPartitioner(const MEDCoupling::MEDFileData* filedata, int ndomains, const std::string& library,bool create_boundary_faces, bool create_joints, bool mesure_memory): - _input_collection( 0 ), _output_collection( 0 ), _new_topology( 0 ) + _input_collection( nullptr ), _output_collection( nullptr ), _new_topology( nullptr ) { MyGlobals::_World_Size = 1; MyGlobals::_Rank = 0; @@ -79,7 +81,7 @@ MEDPARTITIONER::MEDPartitioner::MEDPartitioner(const MEDCoupling::MEDFileData* f _input_collection->setParaDomainSelector( ¶llelizer ); _input_collection->retrieveDriver()->readMEDFileData(filedata); - MEDPARTITIONER::ParallelTopology* aPT = + auto* aPT = (MEDPARTITIONER::ParallelTopology*) _input_collection->getTopology(); aPT->setGlobalNumerotationDefault( _input_collection->getParaDomainSelector() ); _input_collection->prepareFieldDescriptions(); @@ -89,7 +91,7 @@ MEDPARTITIONER::MEDPartitioner::MEDPartitioner(const MEDCoupling::MEDFileData* f } MEDPARTITIONER::MEDPartitioner::MEDPartitioner(const MEDCoupling::MEDFileData* filedata, MEDPARTITIONER ::Graph* graph, bool create_boundary_faces, bool create_joints, bool mesure_memory): - _input_collection( 0 ), _output_collection( 0 ), _new_topology( 0 ) + _input_collection( nullptr ), _output_collection( nullptr ), _new_topology( nullptr ) { MyGlobals::_World_Size = 1; MyGlobals::_Rank = 0; @@ -101,7 +103,7 @@ MEDPARTITIONER::MEDPartitioner::MEDPartitioner(const MEDCoupling::MEDFileData* f _input_collection->setParaDomainSelector( ¶llelizer ); _input_collection->retrieveDriver()->readMEDFileData(filedata); - MEDPARTITIONER::ParallelTopology* aPT = + auto* aPT = (MEDPARTITIONER::ParallelTopology*) _input_collection->getTopology(); aPT->setGlobalNumerotationDefault( _input_collection->getParaDomainSelector() ); _input_collection->prepareFieldDescriptions(); @@ -115,12 +117,12 @@ MEDPARTITIONER::MEDPartitioner::MEDPartitioner(const MEDCoupling::MEDFileData* f MEDPARTITIONER::MEDPartitioner::~MEDPartitioner() { - delete _input_collection; _input_collection = 0; - delete _output_collection; _output_collection = 0; - delete _new_topology; _new_topology = 0; + delete _input_collection; _input_collection = nullptr; + delete _output_collection; _output_collection = nullptr; + delete _new_topology; _new_topology = nullptr; } -void MEDPARTITIONER::MEDPartitioner::createPartitionCollection(int ndomains, const std::string& library,bool create_boundary_faces, bool create_joints, bool mesure_memory) +void MEDPARTITIONER::MEDPartitioner::createPartitionCollection(int ndomains, const std::string& library,bool /*create_boundary_faces*/, bool /*create_joints*/, bool /*mesure_memory*/) { //ParallelTopology* aPT = (ParallelTopology*) _input_collection->getTopology(); if (library == "metis") @@ -146,7 +148,7 @@ MEDCoupling::MEDFileData* MEDPARTITIONER::MEDPartitioner::getMEDFileData() MEDPARTITIONER::Graph* MEDPARTITIONER::MEDPartitioner::Graph(MEDCoupling::MEDCouplingSkyLineArray* graph, Graph::splitter_type split, int* edgeweight, DataArrayIdType *vlbloctab) { - MEDPARTITIONER::Graph* cellGraph=0; + MEDPARTITIONER::Graph* cellGraph=nullptr; // will be destroyed by XXXGraph class: MEDCoupling::MCAuto<MEDCoupling::MEDCouplingSkyLineArray> arr(MEDCoupling::MEDCouplingSkyLineArray::New(graph->getIndexArray(), graph->getValuesArray())); switch (split) diff --git a/src/MEDPartitioner/MEDPARTITIONER_MEDPartitioner.hxx b/src/MEDPartitioner/MEDPARTITIONER_MEDPartitioner.hxx index 8d8fc07a9..fa53166b5 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_MEDPartitioner.hxx +++ b/src/MEDPartitioner/MEDPARTITIONER_MEDPartitioner.hxx @@ -24,7 +24,7 @@ #include "MEDPARTITIONER_Graph.hxx" #include "MCType.hxx" -#include <map> +#include <string> #include <vector> namespace MEDCoupling @@ -44,7 +44,7 @@ namespace MEDPARTITIONER MEDPartitioner(const std::string& filename, int ndomains=1, const std::string& library="metis",bool create_boundary_faces=false, bool create_joints=false, bool mesure_memory=false); MEDPartitioner(const MEDCoupling::MEDFileData* fileData, int ndomains=1, const std::string& library="metis",bool create_boundary_faces=false, bool create_joints=false, bool mesure_memory=false); MEDPartitioner(const MEDCoupling::MEDFileData* fileData, Graph* graph, bool create_boundary_faces=false, bool create_joints=false, bool mesure_memory=false); - static MEDPARTITIONER::Graph* Graph(MEDCoupling::MEDCouplingSkyLineArray* graph, Graph::splitter_type split=Graph::METIS, int* edgeweight=0, DataArrayIdType* vlbloctab=0); + static MEDPARTITIONER::Graph* Graph(MEDCoupling::MEDCouplingSkyLineArray* graph, Graph::splitter_type split=Graph::METIS, int* edgeweight=nullptr, DataArrayIdType* vlbloctab=nullptr); static std::vector<std::string> AvailableAlgorithms(); static std::vector<std::string> AllAlgorithms(); static bool HasMetisAlg(); diff --git a/src/MEDPartitioner/MEDPARTITIONER_MeshCollection.cxx b/src/MEDPartitioner/MEDPARTITIONER_MeshCollection.cxx index f3677d4a9..54014d7ce 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_MeshCollection.cxx +++ b/src/MEDPartitioner/MEDPARTITIONER_MeshCollection.cxx @@ -19,6 +19,8 @@ #include "MEDPARTITIONER_MeshCollection.hxx" +#include "MCType.hxx" +#include "MCIdType.hxx" #include "MEDPARTITIONER_ConnectZone.hxx" #include "MEDPARTITIONER_Graph.hxx" #include "MEDPARTITIONER_MeshCollectionDriver.hxx" @@ -29,6 +31,9 @@ #include "MEDPARTITIONER_Topology.hxx" #include "MEDPARTITIONER_UserGraph.hxx" #include "MEDPARTITIONER_Utils.hxx" +#include <cstddef> +#include "NormalizedGeometricTypes" +#include <sstream> #ifdef HAVE_MPI #include "MEDPARTITIONER_JointFinder.hxx" @@ -37,7 +42,6 @@ #include "MCAuto.hxx" #include "MEDCouplingFieldDouble.hxx" #include "MEDCouplingMemArray.hxx" -#include "MEDCouplingNormalizedUnstructuredMesh.hxx" #include "MEDCouplingSkyLineArray.hxx" #include "MEDCouplingUMesh.hxx" #include "MEDLoader.hxx" @@ -57,24 +61,22 @@ #include "MEDPARTITIONER_ScotchGraph.hxx" #endif -#include <set> #include <vector> #include <string> -#include <limits> #include <iostream> #include <fstream> MEDPARTITIONER::MeshCollection::MeshCollection() - : _topology(0), + : _topology(nullptr), _owns_topology(false), - _driver(0), - _domain_selector( 0 ), + _driver(nullptr), + _domain_selector( nullptr ), _i_non_empty_mesh(-1), _driver_type(MEDPARTITIONER::MedXml), _subdomain_boundary_creates( MyGlobals::_Create_Boundary_Faces ), _family_splitting(false), _create_empty_groups(false), - _joint_finder(0) + _joint_finder(nullptr) { } @@ -95,7 +97,7 @@ MEDPARTITIONER::MeshCollection::MeshCollection(MeshCollection& initialCollection bool create_empty_groups) : _topology(topology), _owns_topology(false), - _driver(0), + _driver(nullptr), _domain_selector( initialCollection._domain_selector ), _i_non_empty_mesh(-1), _name(initialCollection._name), @@ -103,7 +105,7 @@ MEDPARTITIONER::MeshCollection::MeshCollection(MeshCollection& initialCollection _subdomain_boundary_creates(MyGlobals::_Create_Boundary_Faces), _family_splitting(family_splitting), _create_empty_groups(create_empty_groups), - _joint_finder(0) + _joint_finder(nullptr) { std::vector<std::vector<std::vector<mcIdType> > > new2oldIds(initialCollection.getTopology()->nbDomain()); std::vector<MEDCoupling::DataArrayIdType*> o2nRenumber; @@ -210,7 +212,7 @@ void MEDPARTITIONER::MeshCollection::castCellMeshes(MeshCollection& initialColle { if (MyGlobals::_Verbose>10) std::cout << "proc " << MyGlobals::_Rank << " : castCellMeshes" << std::endl; - if (_topology==0) + if (_topology==nullptr) throw INTERP_KERNEL::Exception("Topology has not been defined on call to castCellMeshes"); int nbNewDomain=_topology->nbDomain(); @@ -218,20 +220,20 @@ void MEDPARTITIONER::MeshCollection::castCellMeshes(MeshCollection& initialColle _mesh.resize(nbNewDomain); o2nRenumber.resize(nbNewDomain,0); - int rank=MyGlobals::_Rank; + int const rank=MyGlobals::_Rank; //splitting the initial domains into smaller bits std::vector<std::vector<MEDCoupling::MEDCouplingUMesh*> > splitMeshes; splitMeshes.resize(nbNewDomain); for (int inew=0; inew<nbNewDomain; inew++) { - splitMeshes[inew].resize(nbOldDomain, (MEDCoupling::MEDCouplingUMesh*)0); + splitMeshes[inew].resize(nbOldDomain, (MEDCoupling::MEDCouplingUMesh*)nullptr); } for (int iold=0; iold<nbOldDomain; iold++) { if (!isParallelMode() || initialCollection._domain_selector->isMyDomain(iold)) { - mcIdType size=(initialCollection._mesh)[iold]->getNumberOfCells(); + mcIdType const size=(initialCollection._mesh)[iold]->getNumberOfCells(); std::vector<mcIdType> globalids(size); initialCollection.getTopology()->getCellList(iold, &globalids[0]); std::vector<mcIdType> ilocalnew(size); //local @@ -329,7 +331,7 @@ void MEDPARTITIONER::MeshCollection::createNodeMapping( MeshCollection& initialC { double* bbox; - BBTreeOfDim* tree = 0; + BBTreeOfDim* tree = nullptr; int dim = 3; if (!isParallelMode() || (_domain_selector->isMyDomain(iold))) { @@ -337,7 +339,7 @@ void MEDPARTITIONER::MeshCollection::createNodeMapping( MeshCollection& initialC MEDCoupling::DataArrayDouble* coords = initialCollection.getMesh(iold)->getCoords(); double* coordsPtr=coords->getPointer(); dim = (int)coords->getNumberOfComponents(); - mcIdType nvertices=initialCollection.getMesh(iold)->getNumberOfNodes(); + mcIdType const nvertices=initialCollection.getMesh(iold)->getNumberOfNodes(); bbox=new double[nvertices*2*dim]; for (int i=0; i<nvertices*dim;i++) @@ -345,7 +347,7 @@ void MEDPARTITIONER::MeshCollection::createNodeMapping( MeshCollection& initialC bbox[i*2]=coordsPtr[i]-1e-8; bbox[i*2+1]=coordsPtr[i]+1e-8; } - tree=new BBTreeOfDim( dim, bbox,0,0,nvertices,1e-9); + tree=new BBTreeOfDim( dim, bbox,nullptr,0,nvertices,1e-9); } for (int inew=0; inew<_topology->nbDomain(); inew++) @@ -400,10 +402,10 @@ void getNodeIds(MEDCoupling::MEDCouplingUMesh& meshOne, MEDCoupling::MEDCoupling using MEDPARTITIONER::BBTreeOfDim; //if (!&meshOne || !&meshTwo) return; //empty or not existing double* bbox; - BBTreeOfDim* tree = 0; - mcIdType nv1=meshOne.getNumberOfNodes(); + BBTreeOfDim* tree = nullptr; + mcIdType const nv1=meshOne.getNumberOfNodes(); MEDCoupling::DataArrayDouble* coords=meshOne.getCoords(); - int dim = (int)coords->getNumberOfComponents(); + int const dim = (int)coords->getNumberOfComponents(); bbox=new double[nv1*2*dim]; double* coordsPtr=coords->getPointer(); @@ -412,7 +414,7 @@ void getNodeIds(MEDCoupling::MEDCouplingUMesh& meshOne, MEDCoupling::MEDCoupling bbox[i*2]=coordsPtr[i]-1e-8; bbox[i*2+1]=coordsPtr[i]+1e-8; } - tree=new BBTreeOfDim( dim, bbox,0,0,nv1,1e-9); + tree=new BBTreeOfDim( dim, bbox,nullptr,0,nv1,1e-9); mcIdType nv2=meshTwo.getNumberOfNodes(); nodeIds.resize(nv2,-1); @@ -450,7 +452,7 @@ void MEDPARTITIONER::MeshCollection::castFaceMeshes(MeshCollection& initialColle if (MyGlobals::_Verbose>10) std::cout << "proc " << MyGlobals::_Rank << " : castFaceMeshes" << std::endl; - if (_topology==0) + if (_topology==nullptr) throw INTERP_KERNEL::Exception("Topology has not been defined on call to castFaceMeshes"); int nbNewDomain=_topology->nbDomain(); @@ -464,7 +466,7 @@ void MEDPARTITIONER::MeshCollection::castFaceMeshes(MeshCollection& initialColle splitMeshes.resize(nbNewDomain); for (int inew=0; inew<nbNewDomain; inew++) { - splitMeshes[inew].resize(nbOldDomain, (MEDCoupling::MEDCouplingUMesh*)0); + splitMeshes[inew].resize(nbOldDomain, (MEDCoupling::MEDCouplingUMesh*)nullptr); } new2oldIds.resize(nbOldDomain); for (int iold=0; iold<nbOldDomain; iold++) new2oldIds[iold].resize(nbNewDomain); @@ -595,13 +597,13 @@ void MEDPARTITIONER::MeshCollection::castFaceMeshes(MeshCollection& initialColle for (int iold=0; iold<nbOldDomain; iold++) { MEDCoupling::MEDCouplingUMesh *umesh=splitMeshes[inew][iold]; - if (umesh!=0) + if (umesh!=nullptr) if (umesh->getNumberOfCells()>0) myMeshes.push_back(umesh); } - MEDCoupling::MEDCouplingUMesh *bndMesh = 0; + MEDCoupling::MEDCouplingUMesh *bndMesh = nullptr; if ( _subdomain_boundary_creates && _mesh[inew] && _mesh[inew]->getNumberOfCells()>0 ) @@ -747,7 +749,7 @@ void MEDPARTITIONER::MeshCollection::remapIntField(int inew, int iold, MEDCoupling::DataArrayDouble* targetCoords=targetMesh.computeCellCenterOfMass(); const double* tc=targetCoords->getConstPointer(); mcIdType targetSize=targetMesh.getNumberOfCells(); - mcIdType sourceSize=sourceMesh.getNumberOfCells(); + mcIdType const sourceSize=sourceMesh.getNumberOfCells(); if (MyGlobals::_Verbose>200) std::cout<<"remap vers target de taille "<<targetSize<<std::endl; std::vector<mcIdType> ccI; @@ -758,12 +760,12 @@ void MEDPARTITIONER::MeshCollection::remapIntField(int inew, int iold, const BBTreeOfDim* tree; bool cleantree=false; - MEDCoupling::DataArrayDouble* sourceBBox=0; - int dim = (int)targetCoords->getNumberOfComponents(); - if (myTree==0) + MEDCoupling::DataArrayDouble* sourceBBox=nullptr; + int const dim = (int)targetCoords->getNumberOfComponents(); + if (myTree==nullptr) { sourceBBox=sourceMesh.computeCellCenterOfMass()->computeBBoxPerTuple(1e-8); - tree=new BBTreeOfDim( dim, sourceBBox->getConstPointer(),0,0, sourceBBox->getNumberOfTuples(),1e-10); + tree=new BBTreeOfDim( dim, sourceBBox->getConstPointer(),nullptr,0, sourceBBox->getNumberOfTuples(),1e-10); cleantree=true; } else tree=myTree; @@ -817,7 +819,7 @@ void MEDPARTITIONER::MeshCollection::remapIntField(int inew, int iold, targetCoords->decrRef(); if (cleantree) delete tree; - if (sourceBBox !=0) sourceBBox->decrRef(); + if (sourceBBox !=nullptr) sourceBBox->decrRef(); } void MEDPARTITIONER::MeshCollection::castAllFields(MeshCollection& initialCollection, std::string nameArrayTo) @@ -825,17 +827,17 @@ void MEDPARTITIONER::MeshCollection::castAllFields(MeshCollection& initialCollec if (nameArrayTo!="cellFieldDouble") throw INTERP_KERNEL::Exception("Error castAllField only on cellFieldDouble"); - std::string nameTo="typeData=6"; //resume the type of field casted + std::string const nameTo="typeData=6"; //resume the type of field casted // send-recv operations - std::size_t ioldMax=initialCollection.getMesh().size(); - std::size_t inewMax=this->getMesh().size(); - std::size_t iFieldMax=initialCollection.getFieldDescriptions().size(); + std::size_t const ioldMax=initialCollection.getMesh().size(); + std::size_t const inewMax=this->getMesh().size(); + std::size_t const iFieldMax=initialCollection.getFieldDescriptions().size(); if (MyGlobals::_Verbose>10) std::cout << "castAllFields with:\n" << ReprVectorOfString(initialCollection.getFieldDescriptions()) << std::endl; //see collection.prepareFieldDescriptions() for (std::size_t ifield=0; ifield<iFieldMax; ifield++) { - std::string descriptionField=initialCollection.getFieldDescriptions()[ifield]; + std::string const descriptionField=initialCollection.getFieldDescriptions()[ifield]; if (descriptionField.find(nameTo)==std::string::npos) continue; //only nameTo accepted in Fields name description #ifdef HAVE_MPI @@ -846,7 +848,7 @@ void MEDPARTITIONER::MeshCollection::castAllFields(MeshCollection& initialCollec //sending arrays for distant domains if (isParallelMode() && _domain_selector->isMyDomain(iold) && !_domain_selector->isMyDomain(inew)) { - int target=_domain_selector->getProcessorID(inew); + int const target=_domain_selector->getProcessorID(inew); MEDCoupling::DataArrayDouble* field=initialCollection.getField(descriptionField,iold); if (MyGlobals::_Verbose>10) std::cout << "proc " << _domain_selector->rank() << " : castAllFields sendDouble" << std::endl; @@ -855,7 +857,7 @@ void MEDPARTITIONER::MeshCollection::castAllFields(MeshCollection& initialCollec //receiving arrays from distant domains if (isParallelMode() && !_domain_selector->isMyDomain(iold) && _domain_selector->isMyDomain(inew)) { - int source=_domain_selector->getProcessorID(iold); + int const source=_domain_selector->getProcessorID(iold); //receive vector if (MyGlobals::_Verbose>10) std::cout << "proc " << _domain_selector->rank() << " : castAllFields recvDouble" << std::endl; @@ -901,15 +903,15 @@ void MEDPARTITIONER::MeshCollection::remapDoubleField(int inew, int iold, if (MyGlobals::_Verbose>300) std::cout << "proc " << MyGlobals::_Rank << " : remapDoubleField " << key << " size " << ccI->getNbOfElems() << std::endl; - mcIdType nbcell=this->getMesh()[inew]->getNumberOfCells(); - std::size_t nbcomp=fromArray->getNumberOfComponents(); - int nbPtGauss=StrToInt(ExtractFromDescription(descriptionField, "nbPtGauss=")); + mcIdType const nbcell=this->getMesh()[inew]->getNumberOfCells(); + std::size_t const nbcomp=fromArray->getNumberOfComponents(); + int const nbPtGauss=StrToInt(ExtractFromDescription(descriptionField, "nbPtGauss=")); std::string tag="inewFieldDouble="+IntToStr(inew); key=descriptionField+SerializeFromString(tag); - mcIdType fromArrayNbOfElem=fromArray->getNbOfElems(); + mcIdType const fromArrayNbOfElem=fromArray->getNbOfElems(); mcIdType fromArrayNbOfComp=ToIdType(fromArray->getNumberOfComponents()); - mcIdType fromArrayNbOfCell=fromArrayNbOfElem/fromArrayNbOfComp/nbPtGauss; + mcIdType const fromArrayNbOfCell=fromArrayNbOfElem/fromArrayNbOfComp/nbPtGauss; if (MyGlobals::_Verbose>1000) { @@ -920,7 +922,7 @@ void MEDPARTITIONER::MeshCollection::remapDoubleField(int inew, int iold, " nbComponents " << fromArray->getNumberOfComponents() << std::endl; } - MEDCoupling::DataArrayDouble* field=0; + MEDCoupling::DataArrayDouble* field=nullptr; std::map<std::string,MEDCoupling::DataArrayDouble*>::iterator it2; it2=_map_dataarray_double.find(key); if (it2==_map_dataarray_double.end()) @@ -950,7 +952,7 @@ void MEDPARTITIONER::MeshCollection::remapDoubleField(int inew, int iold, else { //replaced by setPartOfValuesAdv if nbPtGauss==1 - mcIdType iMax=ccI->getNbOfElems(); + mcIdType const iMax=ccI->getNbOfElems(); mcIdType* pccI=ccI->getPointer(); double* pField=field->getPointer(); double* pFrom=fromArray->getPointer(); @@ -961,8 +963,8 @@ void MEDPARTITIONER::MeshCollection::remapDoubleField(int inew, int iold, isource=pccI[i+1]; if ((itarget<0) || (itarget>=nbcell) || (isource<0) || (isource>=fromArrayNbOfCell)) throw INTERP_KERNEL::Exception("Error field override"); - mcIdType ita=itarget*delta; - mcIdType iso=isource*delta; + mcIdType const ita=itarget*delta; + mcIdType const iso=isource*delta; for (mcIdType k=0; k<delta; k++) pField[ita+k]=pFrom[iso+k]; //components and gausspoints } } @@ -1122,7 +1124,7 @@ void MEDPARTITIONER::MeshCollection::buildConnectZones( const NodeMapping& nodeM if ( corresp.empty() ) continue; - MEDPARTITIONER::ConnectZone* cz = 0; + MEDPARTITIONER::ConnectZone* cz = nullptr; for ( size_t i = 0; i < czVec.size() && !cz; ++i ) if ( czVec[i] && czVec[i]->getLocalDomainNumber () == idomain && @@ -1175,7 +1177,7 @@ void MEDPARTITIONER::MeshCollection::buildConnectZones( const NodeMapping& nodeM if ( types1.size() < 1 || types2.size() < 1 ) continue; // parallel mode? - MEDPARTITIONER::ConnectZone* cz21 = 0; // zone 2 -> 1 + MEDPARTITIONER::ConnectZone* cz21 = nullptr; // zone 2 -> 1 for ( size_t j = 0; j < czVec.size() && !cz21; ++j ) if ( czVec[j] && czVec[j]->getLocalDomainNumber () == cz->getDistantDomainNumber() && @@ -1239,9 +1241,9 @@ void MEDPARTITIONER::MeshCollection::buildConnectZones( const NodeMapping& nodeM } }// split and sort - cz->setEntityCorresp( 0, 0, 0, 0 ); // erase ids computed by _topology + cz->setEntityCorresp( 0, 0, nullptr, 0 ); // erase ids computed by _topology if ( cz21 ) - cz21->setEntityCorresp( 0, 0, 0, 0 ); + cz21->setEntityCorresp( 0, 0, nullptr, 0 ); } // loop on czVec @@ -1260,7 +1262,7 @@ void MEDPARTITIONER::MeshCollection::buildConnectZones( const NodeMapping& nodeM if ( cz->getDistantDomainNumber() < cz->getLocalDomainNumber() ) continue; // treat a pair of domains once - MEDPARTITIONER::ConnectZone* cz21 = 0; // zone 2 -> 1 + MEDPARTITIONER::ConnectZone* cz21 = nullptr; // zone 2 -> 1 for ( size_t j = 0; j < czVec.size() && !cz21; ++j ) if ( czVec[j] && czVec[j]->getLocalDomainNumber () == cz->getDistantDomainNumber() && @@ -1326,8 +1328,8 @@ void MEDPARTITIONER::MeshCollection::buildBoundaryFaces() { for (unsigned int inew2 = inew1+1; inew2 < nbMeshes; inew2++ ) { - MEDCouplingUMesh* mesh1 = 0; - MEDCouplingUMesh* mesh2 = 0; + MEDCouplingUMesh* mesh1 = nullptr; + MEDCouplingUMesh* mesh2 = nullptr; //MEDCouplingUMesh* recvMesh = 0; bool mesh1Here = true, mesh2Here = true; if (isParallelMode()) @@ -1454,10 +1456,10 @@ void MEDPARTITIONER::MeshCollection::createJointGroup( const std::vector< mcIdTy _group_info.erase( groupName ); // get family IDs array - mcIdType* famIDs = 0; - int inew = (is2nd ? inew2 : inew1 ); + mcIdType* famIDs = nullptr; + int const inew = (is2nd ? inew2 : inew1 ); mcIdType totalNbFaces = _face_mesh[ inew ] ? _face_mesh[ inew ]->getNumberOfCells() : 0; - std::string cle = Cle1ToStr( "faceFamily_toArray", inew ); + std::string const cle = Cle1ToStr( "faceFamily_toArray", inew ); if ( !_map_dataarray_int.count(cle) ) { if ( totalNbFaces > 0 ) @@ -1519,16 +1521,16 @@ void MEDPARTITIONER::MeshCollection::createJointGroup( const std::vector< mcIdTy * \param filename name of the master file containing the list of all the MED files */ MEDPARTITIONER::MeshCollection::MeshCollection(const std::string& filename) - : _topology(0), + : _topology(nullptr), _owns_topology(true), - _driver(0), - _domain_selector( 0 ), + _driver(nullptr), + _domain_selector( nullptr ), _i_non_empty_mesh(-1), _driver_type(MEDPARTITIONER::Undefined), _subdomain_boundary_creates(MyGlobals::_Create_Boundary_Faces), _family_splitting(false), _create_empty_groups(false), - _joint_finder(0) + _joint_finder(nullptr) { try { @@ -1538,7 +1540,7 @@ MEDPARTITIONER::MeshCollection::MeshCollection(const std::string& filename) } catch(...) { // Handle all exceptions - if ( _driver ) delete _driver; _driver=0; + if ( _driver ) delete _driver; _driver=nullptr; try { _driver=new MeshCollectionMedAsciiDriver(this); @@ -1548,7 +1550,7 @@ MEDPARTITIONER::MeshCollection::MeshCollection(const std::string& filename) catch(...) { delete _driver; - _driver=0; + _driver=nullptr; throw INTERP_KERNEL::Exception("file does not comply with any recognized format"); } } @@ -1563,18 +1565,18 @@ MEDPARTITIONER::MeshCollection::MeshCollection(const std::string& filename) * \param domainSelector - selector of domains to load */ MEDPARTITIONER::MeshCollection::MeshCollection(const std::string& filename, ParaDomainSelector& domainSelector) - : _topology(0), + : _topology(nullptr), _owns_topology(true), - _driver(0), + _driver(nullptr), _domain_selector( &domainSelector ), _i_non_empty_mesh(-1), _driver_type(MEDPARTITIONER::Undefined), _subdomain_boundary_creates(MyGlobals::_Create_Boundary_Faces), _family_splitting(false), _create_empty_groups(false), - _joint_finder(0) + _joint_finder(nullptr) { - std::string myfile=filename; + std::string const myfile=filename; std::size_t found=myfile.find(".xml"); if (found!=std::string::npos) //file .xml { @@ -1650,7 +1652,7 @@ MEDPARTITIONER::MeshCollection::MeshCollection(const std::string& filename, Para } catch(...) { // Handle all exceptions - delete _driver; _driver=0; + delete _driver; _driver=nullptr; throw INTERP_KERNEL::Exception("file medpartitioner_xxx.xml does not comply with any recognized format"); } } @@ -1665,7 +1667,7 @@ MEDPARTITIONER::MeshCollection::MeshCollection(const std::string& filename, Para catch(...) { delete _driver; - _driver=0; + _driver=nullptr; throw INTERP_KERNEL::Exception("file name with no extension does not comply with any recognized format"); } } @@ -1722,17 +1724,17 @@ MEDPARTITIONER::MeshCollection::MeshCollection(const std::string& filename, Para * \param meshname name of the mesh that is to be read */ MEDPARTITIONER::MeshCollection::MeshCollection(const std::string& filename, const std::string& meshname) - : _topology(0), + : _topology(nullptr), _owns_topology(true), - _driver(0), - _domain_selector( 0 ), + _driver(nullptr), + _domain_selector( nullptr ), _i_non_empty_mesh(-1), _name(meshname), _driver_type(MEDPARTITIONER::MedXml), _subdomain_boundary_creates(MyGlobals::_Create_Boundary_Faces), _family_splitting(false), _create_empty_groups(false), - _joint_finder(0) + _joint_finder(nullptr) { try // avoid memory leak in case of inexistent filename { @@ -1741,7 +1743,7 @@ MEDPARTITIONER::MeshCollection::MeshCollection(const std::string& filename, cons catch (...) { delete _driver; - _driver=0; + _driver=nullptr; throw INTERP_KERNEL::Exception("problem reading .med files"); } if ( _mesh[0] && _mesh[0]->getNumberOfNodes() > 0 ) @@ -1750,20 +1752,20 @@ MEDPARTITIONER::MeshCollection::MeshCollection(const std::string& filename, cons MEDPARTITIONER::MeshCollection::~MeshCollection() { - for (std::size_t i=0; i<_mesh.size();i++) - if (_mesh[i]!=0) _mesh[i]->decrRef(); + for (auto & i : _mesh) + if (i!=nullptr) i->decrRef(); - for (std::size_t i=0; i<_cell_family_ids.size();i++) - if (_cell_family_ids[i]!=0) - _cell_family_ids[i]->decrRef(); + for (auto & _cell_family_id : _cell_family_ids) + if (_cell_family_id!=nullptr) + _cell_family_id->decrRef(); - for (std::size_t i=0; i<_face_mesh.size();i++) - if (_face_mesh[i]!=0) - _face_mesh[i]->decrRef(); + for (auto & i : _face_mesh) + if (i!=nullptr) + i->decrRef(); - for (std::size_t i=0; i<_face_family_ids.size();i++) - if (_face_family_ids[i]!=0) - _face_family_ids[i]->decrRef(); + for (auto & _face_family_id : _face_family_ids) + if (_face_family_id!=nullptr) + _face_family_id->decrRef(); for (std::map<std::string, MEDCoupling::DataArrayIdType*>::iterator it=_map_dataarray_int.begin() ; it!=_map_dataarray_int.end(); it++ ) if ((*it).second!=0) @@ -1774,7 +1776,7 @@ MEDPARTITIONER::MeshCollection::~MeshCollection() (*it).second->decrRef(); delete _driver; - if (_topology!=0 && _owns_topology) + if (_topology!=nullptr && _owns_topology) delete _topology; #ifdef HAVE_MPI delete _joint_finder; @@ -1795,7 +1797,7 @@ void MEDPARTITIONER::MeshCollection::write(const std::string& filename) { //suppresses link with driver so that it can be changed for writing delete _driver; - _driver=0; + _driver=nullptr; retrieveDriver()->write (filename.c_str(), _domain_selector); } @@ -1803,7 +1805,7 @@ void MEDPARTITIONER::MeshCollection::write(const std::string& filename) */ MEDPARTITIONER::MeshCollectionDriver* MEDPARTITIONER::MeshCollection::retrieveDriver() { - if (_driver==0) + if (_driver==nullptr) { switch(_driver_type) { @@ -1840,9 +1842,9 @@ int MEDPARTITIONER::MeshCollection::getMeshDimension() const int MEDPARTITIONER::MeshCollection::getNbOfLocalMeshes() const { int nb=0; - for (size_t i=0; i<_mesh.size(); i++) + for (auto i : _mesh) { - if (_mesh[i]) nb++; + if (i) nb++; } return nb; } @@ -1850,9 +1852,9 @@ int MEDPARTITIONER::MeshCollection::getNbOfLocalMeshes() const mcIdType MEDPARTITIONER::MeshCollection::getNbOfLocalCells() const { mcIdType nb=0; - for (size_t i=0; i<_mesh.size(); i++) + for (auto i : _mesh) { - if (_mesh[i]) nb=nb+_mesh[i]->getNumberOfCells(); + if (i) nb=nb+i->getNumberOfCells(); } return nb; } @@ -1860,9 +1862,9 @@ mcIdType MEDPARTITIONER::MeshCollection::getNbOfLocalCells() const mcIdType MEDPARTITIONER::MeshCollection::getNbOfLocalFaces() const { mcIdType nb=0; - for (size_t i=0; i<_face_mesh.size(); i++) + for (auto i : _face_mesh) { - if (_face_mesh[i]) nb=nb+_face_mesh[i]->getNumberOfCells(); + if (i) nb=nb+i->getNumberOfCells(); } return nb; } @@ -1903,7 +1905,7 @@ MEDPARTITIONER::Topology* MEDPARTITIONER::MeshCollection::getTopology() const void MEDPARTITIONER::MeshCollection::setTopology(Topology* topo, bool takeOwneship) { - if (_topology!=0) + if (_topology!=nullptr) { throw INTERP_KERNEL::Exception("topology is already set"); } @@ -1920,7 +1922,7 @@ void MEDPARTITIONER::MeshCollection::setTopology(Topology* topo, bool takeOwnesh * \param edgeweight returns the pointer to the table that contains the edgeweights * (only used if indivisible regions are required) */ -void MEDPARTITIONER::MeshCollection::buildCellGraph(MEDCoupling::MEDCouplingSkyLineArray* & array, int *& edgeweights ) +void MEDPARTITIONER::MeshCollection::buildCellGraph(MEDCoupling::MEDCouplingSkyLineArray* & array, int *& /*edgeweights*/ ) { using std::map; @@ -1950,7 +1952,7 @@ void MEDPARTITIONER::MeshCollection::buildCellGraph(MEDCoupling::MEDCouplingSkyL * \param edgeweight returns the pointer to the table that contains the edgeweights * (only used if indivisible regions are required) */ -void MEDPARTITIONER::MeshCollection::buildParallelCellGraph(MEDCoupling::MEDCouplingSkyLineArray* & array, int *& edgeweights ) +void MEDPARTITIONER::MeshCollection::buildParallelCellGraph(MEDCoupling::MEDCouplingSkyLineArray* & array, int *& /*edgeweights*/ ) { using std::multimap; using std::vector; @@ -1962,7 +1964,7 @@ void MEDPARTITIONER::MeshCollection::buildParallelCellGraph(MEDCoupling::MEDCoup std::multimap<mcIdType,mcIdType> cell2cell; std::vector<std::vector<std::multimap<mcIdType,mcIdType> > > commonDistantNodes; - int nbdomain=_topology->nbDomain(); + int const nbdomain=_topology->nbDomain(); #ifdef HAVE_MPI if (isParallelMode()) { @@ -1987,7 +1989,7 @@ void MEDPARTITIONER::MeshCollection::buildParallelCellGraph(MEDCoupling::MEDCoup MEDCoupling::DataArrayIdType* index=MEDCoupling::DataArrayIdType::New(); MEDCoupling::DataArrayIdType* revConn=MEDCoupling::DataArrayIdType::New(); - mcIdType nbNodes=_mesh[idomain]->getNumberOfNodes(); + mcIdType const nbNodes=_mesh[idomain]->getNumberOfNodes(); _mesh[idomain]->getReverseNodalConnectivity(revConn,index); //problem saturation over 1 000 000 nodes for 1 proc if (MyGlobals::_Verbose>100) @@ -1998,8 +2000,8 @@ void MEDPARTITIONER::MeshCollection::buildParallelCellGraph(MEDCoupling::MEDCoup { for (mcIdType icell=index_ptr[i]; icell<index_ptr[i+1]; icell++) { - mcIdType globalNode=_topology->convertNodeToGlobal(idomain,i); - mcIdType globalCell=_topology->convertCellToGlobal(idomain,revConnPtr[icell]); + mcIdType const globalNode=_topology->convertNodeToGlobal(idomain,i); + mcIdType const globalCell=_topology->convertCellToGlobal(idomain,revConnPtr[icell]); node2cell.insert(make_pair(globalNode, globalCell)); } } @@ -2009,8 +2011,8 @@ void MEDPARTITIONER::MeshCollection::buildParallelCellGraph(MEDCoupling::MEDCoup for (int iother=0; iother<nbdomain; iother++) { std::multimap<mcIdType,mcIdType>::iterator it; - int isource=idomain; - int itarget=iother; + int const isource=idomain; + int const itarget=iother; for (it=_joint_finder->getDistantNodeCell()[isource][itarget].begin(); it!=_joint_finder->getDistantNodeCell()[isource][itarget].end(); it++) { @@ -2089,11 +2091,11 @@ void MEDPARTITIONER::MeshCollection::buildParallelCellGraph(MEDCoupling::MEDCoup for (int idomain=0; idomain<nbdomain; idomain++) { if (isParallelMode() && !_domain_selector->isMyDomain(idomain)) continue; - mcIdType nbCells=_mesh[idomain]->getNumberOfCells(); + mcIdType const nbCells=_mesh[idomain]->getNumberOfCells(); for (mcIdType icell=0; icell<nbCells; icell++) { mcIdType size=0; - mcIdType globalCell=_topology->convertCellToGlobal(idomain,icell); + mcIdType const globalCell=_topology->convertCellToGlobal(idomain,icell); multimap<mcIdType,mcIdType>::iterator it; pair<multimap<mcIdType,mcIdType>::iterator,multimap<mcIdType,mcIdType>::iterator> ret; ret=cell2cell.equal_range(globalCell); @@ -2157,15 +2159,15 @@ MEDPARTITIONER::Topology* MEDPARTITIONER::MeshCollection::createPartition(int nb if (nbdomain <1) throw INTERP_KERNEL::Exception("Number of subdomains must be > 0"); - MEDCoupling::MEDCouplingSkyLineArray* array=0; - int* edgeweights=0; + MEDCoupling::MEDCouplingSkyLineArray* array=nullptr; + int* edgeweights=nullptr; if (_topology->nbDomain()>1 || isParallelMode()) buildParallelCellGraph(array,edgeweights); else buildCellGraph(array,edgeweights); - Graph* cellGraph = 0; + Graph* cellGraph = nullptr; switch (split) { case Graph::METIS: @@ -2201,9 +2203,9 @@ MEDPARTITIONER::Topology* MEDPARTITIONER::MeshCollection::createPartition(int nb } //!user-defined weights - if (user_edge_weights!=0) + if (user_edge_weights!=nullptr) cellGraph->setEdgesWeights(user_edge_weights); - if (user_vertices_weights!=0) + if (user_vertices_weights!=nullptr) cellGraph->setVerticesWeights(user_vertices_weights); if (MyGlobals::_Is0verbose>10) @@ -2213,7 +2215,7 @@ MEDPARTITIONER::Topology* MEDPARTITIONER::MeshCollection::createPartition(int nb if (MyGlobals::_Is0verbose>10) std::cout << "building new topology" << std::endl; //cellGraph is a shared pointer - Topology *topology=0; + Topology *topology=nullptr; topology=new ParallelTopology (cellGraph, getTopology(), nbdomain, getMeshDimension()); //cleaning delete [] edgeweights; @@ -2231,8 +2233,8 @@ MEDPARTITIONER::Topology* MEDPARTITIONER::MeshCollection::createPartition(int nb */ MEDPARTITIONER::Topology* MEDPARTITIONER::MeshCollection::createPartition(const int* partition) { - MEDCoupling::MEDCouplingSkyLineArray* array=0; - int* edgeweights=0; + MEDCoupling::MEDCouplingSkyLineArray* array=nullptr; + int* edgeweights=nullptr; if ( _topology->nbDomain()>1) buildParallelCellGraph(array,edgeweights); @@ -2248,7 +2250,7 @@ MEDPARTITIONER::Topology* MEDPARTITIONER::MeshCollection::createPartition(const cellGraph=new UserGraph(array, partition, _topology->nbCells()); //cellGraph is a shared pointer - Topology *topology=0; + Topology *topology=nullptr; int nbdomain=(int)domains.size(); topology=new ParallelTopology (cellGraph, getTopology(), nbdomain, getMeshDimension()); // if (array!=0) delete array; @@ -2271,7 +2273,7 @@ MEDCoupling::DataArrayDouble *MEDPARTITIONER::MeshCollection::getField(std::stri //getField look for and read it if not done, and assume decrRef() in ~MeshCollection; //something like MCAuto<MEDCouplingFieldDouble> f2=ReadFieldCell(name,f1->getMesh()->getName(),0,f1->getName(),0,1); { - int rank=MyGlobals::_Rank; + int const rank=MyGlobals::_Rank; std::string tag="ioldFieldDouble="+IntToStr(iold); std::string descriptionIold=descriptionField+SerializeFromString(tag); if (_map_dataarray_double.find(descriptionIold)!=_map_dataarray_double.end()) @@ -2325,7 +2327,7 @@ void MEDPARTITIONER::MeshCollection::prepareFieldDescriptions() } //here vector(procs*fields) of serialised vector(description) data _field_descriptions=r2; - std::size_t nbfields=_field_descriptions.size(); //on all domains + std::size_t const nbfields=_field_descriptions.size(); //on all domains if ((nbfields%nbfiles)!=0) { if (MyGlobals::_Rank==0) @@ -2339,12 +2341,12 @@ void MEDPARTITIONER::MeshCollection::prepareFieldDescriptions() throw INTERP_KERNEL::Exception("incoherent number of fields references in all files .med\n"); } _field_descriptions.resize(nbfields/nbfiles); - for (std::size_t i=0; i<_field_descriptions.size(); i++) + for (auto & _field_description : _field_descriptions) { - std::string str=_field_descriptions[i]; + std::string str=_field_description; str=EraseTagSerialized(str,"idomain="); str=EraseTagSerialized(str,"fileName="); - _field_descriptions[i]=str; + _field_description=str; } } @@ -2397,7 +2399,7 @@ void MEDPARTITIONER::MeshCollection::filterFaceOnCell() std::vector< mcIdType > faceOnCell; std::vector< mcIdType > faceNotOnCell; - mcIdType nbface=mfac->getNumberOfCells(); + mcIdType const nbface=mfac->getNumberOfCells(); for (mcIdType iface=0; iface<nbface; iface++) { bool ok; @@ -2418,10 +2420,10 @@ void MEDPARTITIONER::MeshCollection::filterFaceOnCell() std::cout << "filterFaceOnCell problem 1" << std::endl; continue; } - mcIdType nbcell=revIndxC[inod+1]-revIndxC[inod]; + mcIdType const nbcell=revIndxC[inod+1]-revIndxC[inod]; for (mcIdType j=0; j<nbcell; j++) //look for each cell with inod { - mcIdType icel=revC[revIndxC[inod]+j]; + mcIdType const icel=revC[revIndxC[inod]+j]; std::vector< mcIdType > inodesCell; mcel->getNodeIdsOfCell(icel, inodesCell); ok=isFaceOncell(inodesFace, inodesCell); @@ -2457,7 +2459,7 @@ void MEDPARTITIONER::MeshCollection::filterFaceOnCell() mfac->decrRef(); // filter the face families - std::string key = Cle1ToStr("faceFamily_toArray",inew); + std::string const key = Cle1ToStr("faceFamily_toArray",inew); if ( getMapDataArrayInt().count( key )) { MEDCoupling::DataArrayIdType * & fam = getMapDataArrayInt()[ key ]; diff --git a/src/MEDPartitioner/MEDPARTITIONER_MeshCollection.hxx b/src/MEDPartitioner/MEDPARTITIONER_MeshCollection.hxx index 4816631bb..43e71f0f7 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_MeshCollection.hxx +++ b/src/MEDPartitioner/MEDPARTITIONER_MeshCollection.hxx @@ -20,16 +20,19 @@ #ifndef __MEDPARTITIONER_MESHCOLLECTION_HXX__ #define __MEDPARTITIONER_MESHCOLLECTION_HXX__ +#include "MCType.hxx" +#include "MCIdType.hxx" +#include "MEDCouplingMemArray.hxx" #include "MEDPARTITIONER.hxx" #include "MEDPARTITIONER_Graph.hxx" #include "MEDPARTITIONER_Utils.hxx" #include "MEDCouplingSkyLineArray.hxx" #include <map> +#include <utility> #include <vector> #include <string> -#include "BBTree.txx" namespace MEDCoupling { @@ -80,7 +83,7 @@ namespace MEDPARTITIONER //creation and partition of the associated graph Topology* createPartition(int nbdomain, Graph::splitter_type type = Graph::METIS, - const std::string& ="", int* edgeweights=0, int* verticesweights=0); + const std::string& ="", int* edgeweights=nullptr, int* verticesweights=nullptr); //creation of a user specified partition Topology* createPartition(const int* partition); diff --git a/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionDriver.cxx b/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionDriver.cxx index 7bb159719..83a647c0b 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionDriver.cxx +++ b/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionDriver.cxx @@ -19,6 +19,11 @@ #include "MEDPARTITIONER_MeshCollectionDriver.hxx" +#include "MCType.hxx" +#include "MCIdType.hxx" +#include "MCAuto.hxx" +#include "MEDFileFieldMultiTS.hxx" +#include "MEDFileField1TS.hxx" #include "MEDPARTITIONER_ConnectZone.hxx" #include "MEDPARTITIONER_MeshCollection.hxx" #include "MEDPARTITIONER_ParaDomainSelector.hxx" @@ -35,19 +40,16 @@ #include "MEDFileMesh.hxx" #include "MEDLoader.hxx" +#include <cstddef> #include <map> -#include <set> +#include <sstream> +#include <utility> #include <vector> #include <string> -#include <fstream> #include <iostream> -#include <libxml/tree.h> -#include <libxml/parser.h> -#include <libxml/xpath.h> -#include <libxml/xpathInternals.h> -#include "med.h" +#include "NormalizedGeometricTypes" using namespace MEDPARTITIONER; @@ -83,7 +85,7 @@ int MeshCollectionDriver::readSeq(const char* filename, const char* meshname) (_collection->getCZ()).clear(); - ParallelTopology* aPT = new ParallelTopology((_collection->getMesh())); + auto* aPT = new ParallelTopology((_collection->getMesh())); _collection->setTopology(aPT, true); _collection->setName(meshname); _collection->setDomainNames(meshname); @@ -94,20 +96,20 @@ int MeshCollectionDriver::readSeq(const char* filename, const char* meshname) void MeshCollectionDriver::readMEDFileData(const MEDCoupling::MEDFileData* filedata) { const int nbDomains = filedata->getMeshes()->getNumberOfMeshes(); - _collection->getMesh() .resize( nbDomains, 0 ); - _collection->getFaceMesh() .resize( nbDomains, 0 ); - _collection->getCellFamilyIds().resize( nbDomains, 0 ); - _collection->getFaceFamilyIds().resize( nbDomains, 0 ); + _collection->getMesh() .resize( nbDomains, nullptr ); + _collection->getFaceMesh() .resize( nbDomains, nullptr ); + _collection->getCellFamilyIds().resize( nbDomains, nullptr ); + _collection->getFaceFamilyIds().resize( nbDomains, nullptr ); for (int i=0; i<nbDomains; i++) { - MEDCoupling::MEDFileUMesh *mfm = dynamic_cast<MEDCoupling::MEDFileUMesh *>(filedata->getMeshes()->getMeshAtPos(i)); + auto *mfm = dynamic_cast<MEDCoupling::MEDFileUMesh *>(filedata->getMeshes()->getMeshAtPos(i)); readData(mfm,i); if ( mfm && mfm->getMeshDimension() > 0 ) _collection->setNonEmptyMesh( i ); } - ParallelTopology* aPT = new ParallelTopology(_collection->getMesh()); + auto* aPT = new ParallelTopology(_collection->getMesh()); _collection->setTopology(aPT, true); if ( nbDomains > 0 ) { @@ -178,16 +180,16 @@ void MeshCollectionDriver::readData(MEDCoupling::MEDFileUMesh* mfm, int idomain) void MeshCollectionDriver::readSubdomain(int idomain) { - std::string meshname=MyGlobals::_Mesh_Names[idomain]; - std::string file=MyGlobals::_File_Names[idomain]; + std::string const meshname=MyGlobals::_Mesh_Names[idomain]; + std::string const file=MyGlobals::_File_Names[idomain]; readFileData(file,meshname,idomain); std::vector<std::string> localInformation; - std::string str; + std::string const str; localInformation.push_back(str+"ioldDomain="+IntToStr(idomain)); localInformation.push_back(str+"meshName="+meshname); MyGlobals::_General_Informations.push_back(SerializeFromVectorOfString(localInformation)); - std::vector<std::string> localFields=BrowseAllFieldsOnMesh(file, meshname, idomain); + std::vector<std::string> const localFields=BrowseAllFieldsOnMesh(file, meshname, idomain); if (localFields.size()>0) MyGlobals::_Field_Descriptions.push_back(SerializeFromVectorOfString(localFields)); } @@ -212,7 +214,7 @@ MEDCoupling::MEDFileMesh* MeshCollectionDriver::getMesh(int idomain) const std::string finalMeshName=""; if (MyGlobals::_General_Informations.size()!=0) { - std::size_t found=MyGlobals::_General_Informations[0].find("finalMeshName="); + std::size_t const found=MyGlobals::_General_Informations[0].find("finalMeshName="); if ((found!=std::string::npos) && (found>0)) { finalMeshName=ExtractFromDescription(MyGlobals::_General_Informations[0], "finalMeshName="); @@ -304,16 +306,16 @@ MEDCoupling::MEDFileMesh* MeshCollectionDriver::getMesh(int idomain) const j1st->pushCorrespondence( corr ); } - std::vector< std::pair< mcIdType,mcIdType > > types = cz->getEntities(); + std::vector< std::pair< mcIdType,mcIdType > > const types = cz->getEntities(); INTERP_KERNEL::NormalizedCellType t1, t2; - for ( size_t it = 0; it < types.size(); ++it ) + for (auto & type : types) { const MEDCouplingSkyLineArray * cellCorr = - cz->getEntityCorresp( types[it].first, types[it].second ); + cz->getEntityCorresp( type.first, type.second ); if ( cellCorr && cellCorr->getNumberOf() > 0 ) { - t1 = INTERP_KERNEL::NormalizedCellType( types[it].first ); - t2 = INTERP_KERNEL::NormalizedCellType( types[it].second ); + t1 = INTERP_KERNEL::NormalizedCellType( type.first ); + t2 = INTERP_KERNEL::NormalizedCellType( type.second ); MCAuto< MEDFileJointCorrespondence> corr = MEDFileJointCorrespondence::New( cellCorr->getValuesArray(), t1, t2 ); j1st->pushCorrespondence( corr ); @@ -326,18 +328,18 @@ MEDCoupling::MEDFileMesh* MeshCollectionDriver::getMesh(int idomain) const return mfm; } -MEDCoupling::MEDCouplingFieldDouble* MeshCollectionDriver::getField(std::string key, std::string description, MEDCoupling::DataArrayDouble* data, MEDCoupling::MEDFileMesh* mfm, int idomain) const +MEDCoupling::MEDCouplingFieldDouble* MeshCollectionDriver::getField(std::string /*key*/, std::string description, MEDCoupling::DataArrayDouble* data, MEDCoupling::MEDFileMesh* mfm, int /*idomain*/) const { - std::string desc=description; + std::string const desc=description; if (MyGlobals::_Verbose>20) std::cout << "proc " << MyGlobals::_Rank << " : write field " << desc << std::endl; std::string meshName, fieldName; int typeField, DT, IT, entity; FieldShortDescriptionToData(desc, fieldName, typeField, entity, DT, IT); - double time=StrToDouble(ExtractFromDescription(desc, "time=")); - int typeData=StrToInt(ExtractFromDescription(desc, "typeData=")); - std::string entityName=ExtractFromDescription(desc, "entityName="); - MEDCoupling::MEDCouplingFieldDouble* field=0; + double const time=StrToDouble(ExtractFromDescription(desc, "time=")); + int const typeData=StrToInt(ExtractFromDescription(desc, "typeData=")); + std::string const entityName=ExtractFromDescription(desc, "entityName="); + MEDCoupling::MEDCouplingFieldDouble* field=nullptr; if (typeData!=6) { std::cout << "WARNING : writeMedFile : typeData " << typeData << " not implemented for fields\n"; @@ -368,7 +370,7 @@ MEDCoupling::MEDCouplingFieldDouble* MeshCollectionDriver::getField(std::string r1=SelectTagsInVectorOfString(r1,"DT="+IntToStr(DT)); r1=SelectTagsInVectorOfString(r1,"IT="+IntToStr(IT)); //not saved in file? field->setDescription(ExtractFromDescription(r1[0], "fieldDescription=")); - std::size_t nbc=StrToInt(ExtractFromDescription(r1[0], "nbComponents=")); + std::size_t const nbc=StrToInt(ExtractFromDescription(r1[0], "nbComponents=")); if (nbc==da->getNumberOfComponents()) { for (unsigned int i=0; i<nbc; i++) @@ -390,15 +392,15 @@ void MeshCollectionDriver::writeMedFile(int idomain, const std::string& distfile MEDCoupling::MEDFileMesh* mfm = getMesh( idomain ); mfm->write(distfilename,2); - std::string key="/inewFieldDouble="+IntToStr(idomain)+"/"; + std::string const key="/inewFieldDouble="+IntToStr(idomain)+"/"; std::map<std::string,MEDCoupling::DataArrayDouble*>::iterator it; int nbfFieldFound=0; for (it=_collection->getMapDataArrayDouble().begin() ; it!=_collection->getMapDataArrayDouble().end(); it++) { - size_t found=(*it).first.find(key); + size_t const found=(*it).first.find(key); if (found==std::string::npos) continue; - MEDCoupling::MEDCouplingFieldDouble* field=0; + MEDCoupling::MEDCouplingFieldDouble* field=nullptr; field = getField(key, (*it).first, (*it).second, mfm, idomain); nbfFieldFound++; try @@ -434,15 +436,15 @@ MEDCoupling::MEDFileData* MeshCollectionDriver::getMEDFileData() MEDCoupling::MEDFileMesh* mfm = getMesh( i ); meshes->pushMesh(mfm); - std::string key="/inewFieldDouble="+IntToStr(i)+"/"; + std::string const key="/inewFieldDouble="+IntToStr(i)+"/"; std::map<std::string,MEDCoupling::DataArrayDouble*>::iterator it; MEDCoupling::MEDFileFieldMultiTS* fieldsMTS = MEDCoupling::MEDFileFieldMultiTS::New(); for (it=_collection->getMapDataArrayDouble().begin() ; it!=_collection->getMapDataArrayDouble().end(); it++) { - size_t found=(*it).first.find(key); + size_t const found=(*it).first.find(key); if (found==std::string::npos) continue; - MEDCoupling::MEDCouplingFieldDouble* field=0; + MEDCoupling::MEDCouplingFieldDouble* field=nullptr; field=getField(key, (*it).first, (*it).second, mfm, i); MEDCoupling::MEDFileField1TS* f1ts = MEDCoupling::MEDFileField1TS::New(); f1ts->setFieldNoProfileSBT(field); diff --git a/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionDriver.hxx b/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionDriver.hxx index ac0c699e4..f042c70bd 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionDriver.hxx +++ b/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionDriver.hxx @@ -22,7 +22,6 @@ #include "MEDPARTITIONER.hxx" -#include <vector> #include <string> namespace MEDCoupling @@ -43,11 +42,11 @@ namespace MEDPARTITIONER { public: MeshCollectionDriver(MeshCollection*); - virtual ~MeshCollectionDriver() { } - virtual int read(const char*, ParaDomainSelector* sel=0) = 0; + virtual ~MeshCollectionDriver() = default; + virtual int read(const char*, ParaDomainSelector* sel=nullptr) = 0; int readSeq(const char*,const char*); MEDCoupling::MEDFileData *getMEDFileData(); - virtual void write(const char*, ParaDomainSelector* sel=0) const = 0; + virtual void write(const char*, ParaDomainSelector* sel=nullptr) const = 0; void readMEDFileData(const MEDCoupling::MEDFileData* filedata); protected: void readSubdomain(int idomain); diff --git a/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionMedAsciiDriver.cxx b/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionMedAsciiDriver.cxx index d200a1121..72c828241 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionMedAsciiDriver.cxx +++ b/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionMedAsciiDriver.cxx @@ -17,6 +17,7 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +#include "MCIdType.hxx" #include "MEDPARTITIONER_ParallelTopology.hxx" #include "MEDPARTITIONER_MeshCollectionDriver.hxx" #include "MEDPARTITIONER_MeshCollection.hxx" @@ -27,18 +28,14 @@ #include "MEDCouplingUMesh.hxx" #include "MEDLoader.hxx" -#include <map> -#include <set> +#include <cstddef> +#include <cstdlib> #include <vector> #include <string> #include <fstream> #include <iostream> #include <sstream> -#include <libxml/tree.h> -#include <libxml/parser.h> -#include <libxml/xpath.h> -#include <libxml/xpathInternals.h> using namespace MEDPARTITIONER; @@ -57,24 +54,24 @@ int MeshCollectionMedAsciiDriver::read(MEDCoupling::MEDFileData* filedata) { readMEDFileData(filedata); - std::vector<MEDPARTITIONER::ConnectZone*> cz; // to fill from filedata + std::vector<MEDPARTITIONER::ConnectZone*> const cz; // to fill from filedata std::vector<mcIdType*> cellglobal; std::vector<mcIdType*> nodeglobal; std::vector<mcIdType*> faceglobal; - std::size_t size = _collection->getMesh().size(); + std::size_t const size = _collection->getMesh().size(); cellglobal.resize(size); nodeglobal.resize(size); faceglobal.resize(size); for ( unsigned int idomain = 0; idomain < size; ++idomain ) { - cellglobal[idomain]=0; - faceglobal[idomain]=0; - nodeglobal[idomain]=0; + cellglobal[idomain]=nullptr; + faceglobal[idomain]=nullptr; + nodeglobal[idomain]=nullptr; if ( (_collection->getMesh())[idomain] && (_collection->getMesh())[idomain]->getNumberOfNodes() > 0 ) _collection->setNonEmptyMesh(idomain); } //creation of topology from mesh and connect zones - ParallelTopology* aPT = new ParallelTopology((_collection->getMesh()), cz, cellglobal, nodeglobal, faceglobal); + auto* aPT = new ParallelTopology((_collection->getMesh()), cz, cellglobal, nodeglobal, faceglobal); _collection->setTopology(aPT,true); return 0; @@ -125,9 +122,9 @@ int MeshCollectionMedAsciiDriver::read(const char* filename, ParaDomainSelector* //reading information about the domain std::string mesh,host; int idomain; - cellglobal[i]=0; - faceglobal[i]=0; - nodeglobal[i]=0; + cellglobal[i]=nullptr; + faceglobal[i]=nullptr; + nodeglobal[i]=nullptr; asciiinput >> mesh >> idomain >> MyGlobals::_Mesh_Names[i] >> host >> MyGlobals::_File_Names[i]; @@ -150,7 +147,7 @@ int MeshCollectionMedAsciiDriver::read(const char* filename, ParaDomainSelector* } //creation of topology from mesh and connect zones - ParallelTopology* aPT = new ParallelTopology((_collection->getMesh()), (_collection->getCZ()), cellglobal, nodeglobal, faceglobal); + auto* aPT = new ParallelTopology((_collection->getMesh()), (_collection->getCZ()), cellglobal, nodeglobal, faceglobal); _collection->setTopology(aPT, true); for (int i=0; i<nbdomain; i++) @@ -168,7 +165,7 @@ int MeshCollectionMedAsciiDriver::read(const char* filename, ParaDomainSelector* */ void MeshCollectionMedAsciiDriver::write(const char* filename, ParaDomainSelector* domainSelector) const { - std::size_t nbdomains=_collection->getMesh().size(); + std::size_t const nbdomains=_collection->getMesh().size(); std::vector<std::string> filenames; filenames.resize(nbdomains); diff --git a/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionMedAsciiDriver.hxx b/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionMedAsciiDriver.hxx index 1da628556..8315ebbe2 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionMedAsciiDriver.hxx +++ b/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionMedAsciiDriver.hxx @@ -22,6 +22,7 @@ #include "MEDPARTITIONER.hxx" #include "MEDPARTITIONER_MeshCollectionDriver.hxx" +#include <string> namespace MEDPARTITIONER { @@ -30,10 +31,10 @@ namespace MEDPARTITIONER { public: MeshCollectionMedAsciiDriver(MeshCollection*); - virtual ~MeshCollectionMedAsciiDriver() { } - int read(const char*, ParaDomainSelector* sel=0); + ~MeshCollectionMedAsciiDriver() override = default; + int read(const char*, ParaDomainSelector* sel=nullptr) override; int read(MEDCoupling::MEDFileData*); - void write(const char*, ParaDomainSelector* sel=0) const; + void write(const char*, ParaDomainSelector* sel=nullptr) const override; private: std::string _master_filename; }; diff --git a/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionMedXmlDriver.cxx b/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionMedXmlDriver.cxx index e8af4feff..f1dee14fd 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionMedXmlDriver.cxx +++ b/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionMedXmlDriver.cxx @@ -26,14 +26,13 @@ #include "MEDCouplingUMesh.hxx" #include "MEDLoader.hxx" -#include "MEDFileMesh.hxx" +#include "libxml/xmlstring.h" -#include <map> -#include <set> +#include <cstdio> +#include <ctime> #include <vector> #include <string> #include <cstring> -#include <fstream> #include <sstream> #include <iostream> #ifdef WIN32 @@ -45,7 +44,6 @@ #include <libxml/tree.h> #include <libxml/parser.h> #include <libxml/xpath.h> -#include <libxml/xpathInternals.h> using namespace MEDPARTITIONER; @@ -92,7 +90,7 @@ int MeshCollectionMedXmlDriver::read(const char* filename, ParaDomainSelector* d //number of domains xmlXPathContextPtr xpathCtx = xmlXPathNewContext(master_doc); xmlXPathObjectPtr xpathObj = xmlXPathEvalExpression(BAD_CAST "//splitting/subdomain", xpathCtx); - if (xpathObj==0 || xpathObj->nodesetval->nodeNr ==0) + if (xpathObj==nullptr || xpathObj->nodesetval->nodeNr ==0) throw INTERP_KERNEL::Exception("Xml Master File does not contain /MED/splitting/subdomain node"); //as subdomain has only one property which is "number" @@ -103,7 +101,7 @@ int MeshCollectionMedXmlDriver::read(const char* filename, ParaDomainSelector* d //mesh name xmlXPathFreeObject(xpathObj); xpathObj = xmlXPathEvalExpression(BAD_CAST "//content/mesh", xpathCtx); - if (xpathObj==0 || xpathObj->nodesetval->nodeNr ==0) + if (xpathObj==nullptr || xpathObj->nodesetval->nodeNr ==0) throw INTERP_KERNEL::Exception("Xml Master File does not contain /MED/content/mesh node"); _collection->setName( (const char*)xpathObj->nodesetval->nodeTab[0]->properties->children->content); @@ -119,20 +117,20 @@ int MeshCollectionMedXmlDriver::read(const char* filename, ParaDomainSelector* d const char filechar[]="//files/subfile"; xmlXPathFreeObject(xpathObj); xpathObj = xmlXPathEvalExpression(BAD_CAST filechar, xpathCtx); - if (xpathObj==0 || xpathObj->nodesetval->nodeNr ==0) + if (xpathObj==nullptr || xpathObj->nodesetval->nodeNr ==0) throw INTERP_KERNEL::Exception("Xml Master File does not contain /MED/files/subfile nodes"); - int nbfiles = xpathObj->nodesetval ->nodeNr; + int const nbfiles = xpathObj->nodesetval ->nodeNr; for (int i=0; i<nbfiles;i++) { //reading information about the domain - std::string host; + std::string const host; //reading file names std::ostringstream name_search_string; name_search_string<<"//files/subfile[@id=\""<<i+1<<"\"]/name"; xmlXPathObjectPtr xpathObjfilename = xmlXPathEvalExpression(BAD_CAST name_search_string.str().c_str(),xpathCtx); - if (xpathObjfilename->nodesetval ==0) + if (xpathObjfilename->nodesetval ==nullptr) throw INTERP_KERNEL::Exception("Error retrieving a file name from subfile of Xml Master File"); MyGlobals::_File_Names[i]=(const char*)xpathObjfilename->nodesetval->nodeTab[0]->children->content; @@ -141,7 +139,7 @@ int MeshCollectionMedXmlDriver::read(const char* filename, ParaDomainSelector* d mesh_search_string<<"//mapping/mesh/chunk[@subdomain=\""<<i+1<<"\"]/name"; xmlXPathObjectPtr xpathMeshObj = xmlXPathEvalExpression(BAD_CAST mesh_search_string.str().c_str(),xpathCtx); - if (xpathMeshObj->nodesetval ==0) + if (xpathMeshObj->nodesetval ==nullptr) throw INTERP_KERNEL::Exception("Error retrieving mesh name from chunk of Xml Master File"); MyGlobals::_Mesh_Names[i]=(const char*)xpathMeshObj->nodesetval->nodeTab[0]->children->content; @@ -162,7 +160,7 @@ int MeshCollectionMedXmlDriver::read(const char* filename, ParaDomainSelector* d throw INTERP_KERNEL::Exception("I/O error reading parallel MED file"); } - ParallelTopology* aPT = new ParallelTopology(_collection->getMesh()); + auto* aPT = new ParallelTopology(_collection->getMesh()); //creation of topology from mesh and connect zones if ( _collection->isParallelMode() ) { @@ -182,18 +180,18 @@ int MeshCollectionMedXmlDriver::read(const char* filename, ParaDomainSelector* d */ void MeshCollectionMedXmlDriver::write(const char* filename, ParaDomainSelector* domainSelector) const { - xmlDocPtr master_doc = 0; - xmlNodePtr root_node = 0, node, node2; + xmlDocPtr master_doc = nullptr; + xmlNodePtr root_node = nullptr, node, node2; char buff[256]; //Creating the Xml document master_doc = xmlNewDoc(BAD_CAST "1.0"); - root_node = xmlNewNode(0, BAD_CAST "root"); + root_node = xmlNewNode(nullptr, BAD_CAST "root"); xmlDocSetRootElement(master_doc,root_node); //Creating child nodes // Version tag - node = xmlNewChild(root_node, 0, BAD_CAST "version",0); + node = xmlNewChild(root_node, nullptr, BAD_CAST "version",nullptr); xmlNewProp(node, BAD_CAST "maj", BAD_CAST "2"); xmlNewProp(node, BAD_CAST "min", BAD_CAST "3"); xmlNewProp(node, BAD_CAST "ver", BAD_CAST "1"); @@ -216,39 +214,39 @@ void MeshCollectionMedXmlDriver::write(const char* filename, ParaDomainSelector* ,st.wDay); #endif - node = xmlNewChild(root_node,0, BAD_CAST "description",0); + node = xmlNewChild(root_node,nullptr, BAD_CAST "description",nullptr); xmlNewProp(node, BAD_CAST "what", BAD_CAST _collection->getDescription().c_str()); xmlNewProp(node, BAD_CAST "when", BAD_CAST date); //Content tag - node =xmlNewChild(root_node,0, BAD_CAST "content",0); - node2 = xmlNewChild(node, 0, BAD_CAST "mesh",0); + node =xmlNewChild(root_node,nullptr, BAD_CAST "content",nullptr); + node2 = xmlNewChild(node, nullptr, BAD_CAST "mesh",nullptr); xmlNewProp(node2, BAD_CAST "name", BAD_CAST _collection->getName().c_str()); //Splitting tag - node=xmlNewChild(root_node,0,BAD_CAST "splitting",0); - node2=xmlNewChild(node,0,BAD_CAST "subdomain",0); + node=xmlNewChild(root_node,nullptr,BAD_CAST "splitting",nullptr); + node2=xmlNewChild(node,nullptr,BAD_CAST "subdomain",nullptr); sprintf(buff, "%d", (int)_collection->getMesh().size()); xmlNewProp(node2, BAD_CAST "number", BAD_CAST buff); - node2=xmlNewChild(node,0,BAD_CAST "global_numbering",0); + node2=xmlNewChild(node,nullptr,BAD_CAST "global_numbering",nullptr); xmlNewProp(node2, BAD_CAST "present", BAD_CAST "yes"); //Files tag - xmlNodePtr file_node=xmlNewChild(root_node,0,BAD_CAST "files",0); + xmlNodePtr file_node=xmlNewChild(root_node,nullptr,BAD_CAST "files",nullptr); //Mapping tag - node = xmlNewChild(root_node,0,BAD_CAST "mapping",0); - xmlNodePtr mesh_node = xmlNewChild(node, 0, BAD_CAST "mesh",0); + node = xmlNewChild(root_node,nullptr,BAD_CAST "mapping",nullptr); + xmlNodePtr mesh_node = xmlNewChild(node, nullptr, BAD_CAST "mesh",nullptr); xmlNewProp(mesh_node, BAD_CAST "name", BAD_CAST _collection->getName().c_str()); - int nbdomains= _collection->getNbOfGlobalMeshes(); + int const nbdomains= _collection->getNbOfGlobalMeshes(); //loop on the domains std::string finalMeshName=""; if (MyGlobals::_General_Informations.size()!=0) { - std::size_t found=MyGlobals::_General_Informations[0].find("finalMeshName="); + std::size_t const found=MyGlobals::_General_Informations[0].find("finalMeshName="); if ((found!=std::string::npos) && (found>0)) { finalMeshName=ExtractFromDescription(MyGlobals::_General_Informations[0], "finalMeshName="); @@ -280,15 +278,15 @@ void MeshCollectionMedXmlDriver::write(const char* filename, ParaDomainSelector* if (domainSelector->rank()==0) { //updating the ascii description file - node = xmlNewChild(file_node, 0, BAD_CAST "subfile",0); + node = xmlNewChild(file_node, nullptr, BAD_CAST "subfile",nullptr); sprintf (buff,"%d",idomain+1); xmlNewProp(node, BAD_CAST "id", BAD_CAST buff); - xmlNewChild(node,0,BAD_CAST "name",BAD_CAST distfilename.c_str()); - xmlNewChild(node,0,BAD_CAST "machine",BAD_CAST "localhost"); + xmlNewChild(node,nullptr,BAD_CAST "name",BAD_CAST distfilename.c_str()); + xmlNewChild(node,nullptr,BAD_CAST "machine",BAD_CAST "localhost"); - node = xmlNewChild(mesh_node,0, BAD_CAST "chunk",0); + node = xmlNewChild(mesh_node,nullptr, BAD_CAST "chunk",nullptr); xmlNewProp(node, BAD_CAST "subdomain", BAD_CAST buff); - xmlNewChild(node,0,BAD_CAST "name", BAD_CAST finalMeshName.c_str()); + xmlNewChild(node,nullptr,BAD_CAST "name", BAD_CAST finalMeshName.c_str()); //xmlNewChild(node,0,BAD_CAST "name", BAD_CAST ((_collection->getMesh())[idomain]->getName()).c_str()); } } diff --git a/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionMedXmlDriver.hxx b/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionMedXmlDriver.hxx index 5b6ca6022..adcc4cc6a 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionMedXmlDriver.hxx +++ b/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionMedXmlDriver.hxx @@ -22,6 +22,7 @@ #include "MEDPARTITIONER.hxx" #include "MEDPARTITIONER_MeshCollectionDriver.hxx" +#include <string> namespace MEDPARTITIONER { @@ -30,9 +31,9 @@ namespace MEDPARTITIONER { public: MeshCollectionMedXmlDriver(MeshCollection*); - virtual ~MeshCollectionMedXmlDriver() { } - int read(const char*, ParaDomainSelector* sel=0); - void write(const char*, ParaDomainSelector* sel=0) const; + ~MeshCollectionMedXmlDriver() override = default; + int read(const char*, ParaDomainSelector* sel=nullptr) override; + void write(const char*, ParaDomainSelector* sel=nullptr) const override; private : std::string _master_filename; }; diff --git a/src/MEDPartitioner/MEDPARTITIONER_MetisGraph.cxx b/src/MEDPartitioner/MEDPARTITIONER_MetisGraph.cxx index e9a339acb..a8901a970 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_MetisGraph.cxx +++ b/src/MEDPartitioner/MEDPARTITIONER_MetisGraph.cxx @@ -18,13 +18,15 @@ // #include "MEDPARTITIONER_MetisGraph.hxx" +#include "MCIdType.hxx" #include "MEDPARTITIONER_ParaDomainSelector.hxx" #include "MEDPARTITIONER_Utils.hxx" #include "MEDCouplingSkyLineArray.hxx" -#include "InterpKernelException.hxx" #include <iostream> +#include <string> +#include <vector> extern "C" { @@ -43,12 +45,11 @@ METISGraph::METISGraph(MEDCoupling::MEDCouplingSkyLineArray* graph, int* edgewei } METISGraph::~METISGraph() -{ -} += default; void METISGraph::partGraph(int ndomain, const std::string& options_string, - ParaDomainSelector *parallelizer) + ParaDomainSelector * /*parallelizer*/) { using std::vector; if (MyGlobals::_Verbose>10) @@ -69,7 +70,7 @@ void METISGraph::partGraph(int ndomain, //constraints int * vwgt=_cell_weight; int * adjwgt=_edge_weight; - int wgtflag=(_edge_weight!=0)?1:0+(_cell_weight!=0)?2:0; + int wgtflag=(_edge_weight!=nullptr)?1:0+(_cell_weight!=nullptr)?2:0; //base 0 or 1 int base=0; //ndomain diff --git a/src/MEDPartitioner/MEDPARTITIONER_MetisGraph.hxx b/src/MEDPartitioner/MEDPARTITIONER_MetisGraph.hxx index 79ed24cd2..fb8ab7339 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_MetisGraph.hxx +++ b/src/MEDPartitioner/MEDPARTITIONER_MetisGraph.hxx @@ -31,9 +31,9 @@ namespace MEDPARTITIONER { public: METISGraph(); - METISGraph(MEDCoupling::MEDCouplingSkyLineArray*, int *edgeweight=0); - virtual ~METISGraph(); - void partGraph(int ndomain, const std::string& options_string="", ParaDomainSelector *sel=0); + METISGraph(MEDCoupling::MEDCouplingSkyLineArray*, int *edgeweight=nullptr); + ~METISGraph() override; + void partGraph(int ndomain, const std::string& options_string="", ParaDomainSelector *sel=nullptr) override; }; } diff --git a/src/MEDPartitioner/MEDPARTITIONER_PTScotchGraph.cxx b/src/MEDPartitioner/MEDPARTITIONER_PTScotchGraph.cxx index b97847c84..1c737c3c7 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_PTScotchGraph.cxx +++ b/src/MEDPartitioner/MEDPARTITIONER_PTScotchGraph.cxx @@ -18,15 +18,18 @@ // #include "MEDPARTITIONER_PTScotchGraph.hxx" +#include "MEDPARTITIONER_Graph.hxx" #include "MEDPARTITIONER_Utils.hxx" +#include "MCIdType.hxx" #include "MEDCouplingSkyLineArray.hxx" #include "MEDCouplingMemArray.hxx" #include "MCType.hxx" +#include "scotch.h" #include <cstdio> -#include <memory> #include <mpi.h> +#include <string> #ifdef MED_ENABLE_PTSCOTCH extern "C" @@ -44,10 +47,9 @@ PTSCOTCHGraph::PTSCOTCHGraph(MEDCoupling::MEDCouplingSkyLineArray *graph, int *e } PTSCOTCHGraph::~PTSCOTCHGraph() -{ -} += default; -void PTSCOTCHGraph::partGraph(int ndomain, const std::string& options_string, ParaDomainSelector* sel) +void PTSCOTCHGraph::partGraph(int ndomain, const std::string& options_string, ParaDomainSelector* /*sel*/) { if (MyGlobals::_Verbose>10) std::cout << "proc " << MyGlobals::_Rank << " : PTSCOTCHGraph::partGraph" << std::endl; @@ -55,10 +57,10 @@ void PTSCOTCHGraph::partGraph(int ndomain, const std::string& options_string, Pa //number of graph vertices int n = FromIdType<int>(_graph->getNumberOf()); //graph - mcIdType * xadj=const_cast<mcIdType*>(_graph->getIndex()); - mcIdType * adjncy=const_cast<mcIdType*>(_graph->getValues()); + auto * xadj=const_cast<mcIdType*>(_graph->getIndex()); + auto * adjncy=const_cast<mcIdType*>(_graph->getValues()); //ndomain - int nparts=ndomain; + int const nparts=ndomain; #if !defined(MED_ENABLE_PTSCOTCH) throw INTERP_KERNEL::Exception("PTSCOTCHGraph::partGraph : PTSCOTCH is not available. Check your products, please."); @@ -95,13 +97,13 @@ void PTSCOTCHGraph::partGraph(int ndomain, const std::string& options_string, Pa n, // vertlocnbr , nb of local graph nodes n, // vertlocmax , should be set to vertlocnbr for graphs without holes xadj, // vertloctab[vertnbr+1] , index vertex table - 0, // vendloctab , index end vertex table if disjoint, set to zero + nullptr, // vendloctab , index end vertex table if disjoint, set to zero cellWeightPtr, // veloloctab , graph vertices loads, set to zero vlbloctab, // vlblocltab , vertex label array : global vertex index xadj[n], // edgelocnbr , number of edges xadj[n], // edgelocsiz , same as edgelocnbr if edgeloctab is compact adjncy, // edgeloctab[edgelocnbr], global indexes of edges - 0, // edgegsttab , optional, should be computed internally, set to zero + nullptr, // edgegsttab , optional, should be computed internally, set to zero edgeWeightPtr); // edloloctab , graph edges loads, set to zero SCOTCH_Strat scotch_strategy; diff --git a/src/MEDPartitioner/MEDPARTITIONER_PTScotchGraph.hxx b/src/MEDPartitioner/MEDPARTITIONER_PTScotchGraph.hxx index b7aea8507..53c4420ed 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_PTScotchGraph.hxx +++ b/src/MEDPartitioner/MEDPARTITIONER_PTScotchGraph.hxx @@ -35,10 +35,10 @@ namespace MEDPARTITIONER class MEDPARTITIONER_EXPORT PTSCOTCHGraph : public Graph { public: - PTSCOTCHGraph() { } - PTSCOTCHGraph(MEDCoupling::MEDCouplingSkyLineArray* , int *edgeweight=0, DataArrayIdType *vlbloctab=0); - virtual ~PTSCOTCHGraph(); - void partGraph(int ndomain, const std::string& options_string="", ParaDomainSelector* sel=0); + PTSCOTCHGraph() = default; + PTSCOTCHGraph(MEDCoupling::MEDCouplingSkyLineArray* , int *edgeweight=nullptr, DataArrayIdType *vlbloctab=nullptr); + ~PTSCOTCHGraph() override; + void partGraph(int ndomain, const std::string& options_string="", ParaDomainSelector* sel=nullptr) override; protected: MEDCoupling::DataArrayIdType *_vlbloctab; }; diff --git a/src/MEDPartitioner/MEDPARTITIONER_ParMetisGraph.cxx b/src/MEDPartitioner/MEDPARTITIONER_ParMetisGraph.cxx index 3c0378d6e..a679f47b8 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_ParMetisGraph.cxx +++ b/src/MEDPartitioner/MEDPARTITIONER_ParMetisGraph.cxx @@ -18,6 +18,7 @@ // #include "MEDPARTITIONER_ParMetisGraph.hxx" +#include "MCIdType.hxx" #include "MEDPARTITIONER_ParaDomainSelector.hxx" #include "MEDPARTITIONER_Utils.hxx" @@ -25,6 +26,8 @@ #include "InterpKernelException.hxx" #include <iostream> +#include <string> +#include <vector> #ifdef MED_ENABLE_PARMETIS #include <parmetis.h> @@ -45,12 +48,11 @@ ParMETISGraph::ParMETISGraph(MEDCoupling::MEDCouplingSkyLineArray* graph, int* e } ParMETISGraph::~ParMETISGraph() -{ -} += default; void ParMETISGraph::partGraph(int ndomain, - const std::string& options_string, - ParaDomainSelector *parallelizer) + const std::string& /*options_string*/, + ParaDomainSelector * /*parallelizer*/) { using std::vector; vector<int> ran,vx,va; //for randomize @@ -59,7 +61,7 @@ void ParMETISGraph::partGraph(int ndomain, std::cout << "proc " << MyGlobals::_Rank << " : ParMETISGraph::partGraph" << std::endl; // number of graph vertices - int n=FromIdType<int>(_graph->getNumberOf()); + int const n=FromIdType<int>(_graph->getNumberOf()); //graph #ifdef MEDCOUPLING_USE_64BIT_IDS std::vector<int> indexVec( _graph->getIndex(), _graph->getIndexArray()->end() ); @@ -73,11 +75,11 @@ void ParMETISGraph::partGraph(int ndomain, //constraints int * vwgt=_cell_weight; int * adjwgt=_edge_weight; - int wgtflag=(_edge_weight!=0)?1:0+(_cell_weight!=0)?2:0; + int const wgtflag=(_edge_weight!=nullptr)?1:0+(_cell_weight!=nullptr)?2:0; //base 0 or 1 - int base=0; + int const base=0; //ndomain - int nparts=ndomain; + int const nparts=ndomain; //options /* (0=default_option,option,random_seed) see defs.h @@ -87,7 +89,7 @@ void ParMETISGraph::partGraph(int ndomain, #define PMV3_OPTION_PSR 3 seems no changes int options[4]={1,0,33,0}; //test for a random seed of 33 */ - int options[4]={0,0,0,0}; + int const options[4]={0,0,0,0}; // output parameters int edgecut; #if !defined(MED_ENABLE_PARMETIS) diff --git a/src/MEDPartitioner/MEDPARTITIONER_ParMetisGraph.hxx b/src/MEDPartitioner/MEDPARTITIONER_ParMetisGraph.hxx index 1e9d97479..8143e3067 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_ParMetisGraph.hxx +++ b/src/MEDPartitioner/MEDPARTITIONER_ParMetisGraph.hxx @@ -31,9 +31,9 @@ namespace MEDPARTITIONER { public: ParMETISGraph(); - ParMETISGraph(MEDCoupling::MEDCouplingSkyLineArray*, int *edgeweight=0); - virtual ~ParMETISGraph(); - void partGraph(int ndomain, const std::string& options_string="", ParaDomainSelector *sel=0); + ParMETISGraph(MEDCoupling::MEDCouplingSkyLineArray*, int *edgeweight=nullptr); + ~ParMETISGraph() override; + void partGraph(int ndomain, const std::string& options_string="", ParaDomainSelector *sel=nullptr) override; }; } diff --git a/src/MEDPartitioner/MEDPARTITIONER_ParaDomainSelector.cxx b/src/MEDPartitioner/MEDPARTITIONER_ParaDomainSelector.cxx index 1f6b821a8..b1cd85bd4 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_ParaDomainSelector.cxx +++ b/src/MEDPartitioner/MEDPARTITIONER_ParaDomainSelector.cxx @@ -18,7 +18,11 @@ // #include "MEDPARTITIONER_ParaDomainSelector.hxx" -#include "MEDPARTITIONER_UserGraph.hxx" +#include "MEDPARTITIONER_Graph.hxx" +#include "MCType.hxx" +#include "MEDCouplingMemArray.hxx" +#include "MEDCouplingPointSet.hxx" +#include "MEDCouplingMesh.hxx" #include "MEDPARTITIONER_Utils.hxx" #include "MEDPARTITIONER_Utils.hxx" @@ -26,8 +30,9 @@ #include "MEDCouplingSkyLineArray.hxx" #include "MCIdType.hxx" +#include <cstddef> #include <iostream> -#include <numeric> +#include <linux/sysinfo.h> #ifdef HAVE_MPI @@ -76,8 +81,7 @@ MEDPARTITIONER::ParaDomainSelector::ParaDomainSelector(bool mesure_memory) } MEDPARTITIONER::ParaDomainSelector::~ParaDomainSelector() -{ -} += default; /*! * \brief Return true if is running on different hosts @@ -92,9 +96,9 @@ bool MEDPARTITIONER::ParaDomainSelector::isOnDifferentHosts() const int size; MPI_Get_processor_name( name_here, &size); - int next_proc = (rank() + 1) % nbProcs(); - int prev_proc = (rank() - 1 + nbProcs()) % nbProcs(); - int tag = 1111111; + int const next_proc = (rank() + 1) % nbProcs(); + int const prev_proc = (rank() - 1 + nbProcs()) % nbProcs(); + int const tag = 1111111; MPI_Status status; MPI_Sendrecv((void*)&name_here[0], MPI_MAX_PROCESSOR_NAME, MPI_CHAR, next_proc, tag, @@ -222,7 +226,7 @@ void MEDPARTITIONER::ParaDomainSelector::gatherNbOf(const std::vector<MEDCouplin _nb_vert_of_procs[0] = 0; // base = 0 for (int i=0; i<nb_domains; ++i) { - int rankk = getProcessorID(i); + int const rankk = getProcessorID(i); _nb_vert_of_procs[rankk+1] += all_nb_elems[i*2]; } for (std::size_t i=1; i<_nb_vert_of_procs.size(); ++i) @@ -297,7 +301,7 @@ mcIdType MEDPARTITIONER::ParaDomainSelector::getProcNodeShift() const */ std::unique_ptr<MEDPARTITIONER::Graph> MEDPARTITIONER::ParaDomainSelector::gatherGraph(const Graph* graph) const { - Graph* glob_graph = 0; + Graph* glob_graph = nullptr; evaluateMemory(); #ifdef HAVE_MPI @@ -310,8 +314,8 @@ std::unique_ptr<MEDPARTITIONER::Graph> MEDPARTITIONER::ParaDomainSelector::gathe for ( std::size_t i = 1; i < _nb_vert_of_procs.size(); ++i ) index_size_of_proc[i-1] = FromIdType<int>(_nb_vert_of_procs[ i ] - _nb_vert_of_procs[ i-1 ]); - mcIdType index_size = 1 + _cell_shift_by_domain.back(); - mcIdType *graph_index = new mcIdType[ index_size ]; + mcIdType const index_size = 1 + _cell_shift_by_domain.back(); + auto *graph_index = new mcIdType[ index_size ]; const mcIdType *index = graph->getGraph()->getIndex(); MCAuto< DataArrayInt > nb_vert_of_procs = FromIdTypeVec( _nb_vert_of_procs ); int *proc_index_displacement = nb_vert_of_procs->getPointer(); @@ -340,7 +344,7 @@ std::unique_ptr<MEDPARTITIONER::Graph> MEDPARTITIONER::ParaDomainSelector::gathe // update graph_index for ( int i = 1; i < nbProcs(); ++i ) { - mcIdType shift = graph_index[ proc_index_displacement[i]-1 ]-graph_index[0]; + mcIdType const shift = graph_index[ proc_index_displacement[i]-1 ]-graph_index[0]; for ( int j = proc_index_displacement[i]; j < proc_index_displacement[i+1]; ++j ) graph_index[ j ] += shift; } @@ -349,8 +353,8 @@ std::unique_ptr<MEDPARTITIONER::Graph> MEDPARTITIONER::ParaDomainSelector::gathe // Gather values // -------------- - mcIdType value_size = graph_index[ index_size-1 ] - graph_index[ 0 ]; - mcIdType *graph_value = new mcIdType[ value_size ]; + mcIdType const value_size = graph_index[ index_size-1 ] - graph_index[ 0 ]; + auto *graph_value = new mcIdType[ value_size ]; const mcIdType *value = graph->getGraph()->getValues(); MPI_Allgatherv((void*) value, // send local value @@ -366,7 +370,7 @@ std::unique_ptr<MEDPARTITIONER::Graph> MEDPARTITIONER::ParaDomainSelector::gathe // Gather partition // ----------------- - mcIdType * partition = new mcIdType[ _cell_shift_by_domain.back() ]; + auto * partition = new mcIdType[ _cell_shift_by_domain.back() ]; const mcIdType* part = graph->getPart(); MPI_Allgatherv((void*) part, // send local partition @@ -409,7 +413,7 @@ void MEDPARTITIONER::ParaDomainSelector::setNbCellPairs( mcIdType nb_cell_pairs, if ( _nb_cell_pairs_by_joint.empty() ) _nb_cell_pairs_by_joint.resize( _nb_result_domains*(_nb_result_domains+1), 0); - int joint_id = jointId( loc_domain, dist_domain ); + int const joint_id = jointId( loc_domain, dist_domain ); _nb_cell_pairs_by_joint[ joint_id ] = nb_cell_pairs; } evaluateMemory(); @@ -425,7 +429,7 @@ mcIdType MEDPARTITIONER::ParaDomainSelector::getNbCellPairs( int dist_domain, in { evaluateMemory(); - int joint_id = jointId( loc_domain, dist_domain ); + int const joint_id = jointId( loc_domain, dist_domain ); return _nb_cell_pairs_by_joint[ joint_id ]; } @@ -467,12 +471,12 @@ mcIdType MEDPARTITIONER::ParaDomainSelector::getFisrtGlobalIdOfSubentity( int lo // (got in gatherNbOf( MED_FACE )). evaluateMemory(); - mcIdType total_nb_faces = _face_shift_by_domain.empty() ? 0 : _face_shift_by_domain.back(); + mcIdType const total_nb_faces = _face_shift_by_domain.empty() ? 0 : _face_shift_by_domain.back(); mcIdType id = total_nb_faces + 1; if ( _nb_cell_pairs_by_joint.empty() ) throw INTERP_KERNEL::Exception("gatherNbCellPairs() must be called before"); - int joint_id = jointId( loc_domain, dist_domain ); + int const joint_id = jointId( loc_domain, dist_domain ); for ( int j = 0; j < joint_id; ++j ) id += _nb_cell_pairs_by_joint[ j ]; @@ -490,8 +494,8 @@ int *MEDPARTITIONER::ParaDomainSelector::exchangeSubentityIds( int loc_domain, i { int* loc_ids_dist = new int[ loc_ids_here.size()]; #ifdef HAVE_MPI - int dest = getProcessorID( dist_domain ); - int tag = 2002 + jointId( loc_domain, dist_domain ); + int const dest = getProcessorID( dist_domain ); + int const tag = 2002 + jointId( loc_domain, dist_domain ); MPI_Status status; MPI_Sendrecv((void*)&loc_ids_here[0], (int)loc_ids_here.size(), MPI_INT, dest, tag, (void*) loc_ids_dist, (int)loc_ids_here.size(), MPI_INT, dest, tag, @@ -563,12 +567,12 @@ void MEDPARTITIONER::ParaDomainSelector::sendMesh(const MEDCoupling::MEDCoupling if (mesh.getNumberOfCells()>0) //no sends if empty { - MEDCoupling::DataArrayIdType *v1Local=0; - MEDCoupling::DataArrayDouble *v2Local=0; + MEDCoupling::DataArrayIdType *v1Local=nullptr; + MEDCoupling::DataArrayDouble *v2Local=nullptr; //serialization of local mesh to send data to distant proc. mesh.serialize(v1Local,v2Local); int nbLocalElems=0; - mcIdType* ptLocal=0; + mcIdType* ptLocal=nullptr; if(v1Local) //if empty getNbOfElems() is 1! { nbLocalElems=FromIdType<int>(v1Local->getNbOfElems()); // if empty be 1! @@ -576,7 +580,7 @@ void MEDPARTITIONER::ParaDomainSelector::sendMesh(const MEDCoupling::MEDCoupling } MPI_Send(ptLocal, nbLocalElems, MPI_ID_TYPE, target, 1111, MPI_COMM_WORLD); int nbLocalElems2=0; - double *ptLocal2=0; + double *ptLocal2=nullptr; if(v2Local) //if empty be 0! { nbLocalElems2=FromIdType<int>(v2Local->getNbOfElems()); @@ -628,14 +632,14 @@ void MEDPARTITIONER::ParaDomainSelector::recvMesh(MEDCoupling::MEDCouplingUMesh* mesh->resizeForUnserialization(tinyInfoDistant,v1Distant,v2Distant,unusedTinyDistantSts); int nbDistElem=0; - mcIdType *ptDist=0; + mcIdType *ptDist=nullptr; if(v1Distant) { nbDistElem=FromIdType<int>(v1Distant->getNbOfElems()); ptDist=v1Distant->getPointer(); } MPI_Recv(ptDist, nbDistElem, MPI_ID_TYPE, source,1111, MPI_COMM_WORLD, &status); - double *ptDist2=0; + double *ptDist2=nullptr; nbDistElem=0; if(v2Distant) { @@ -671,7 +675,7 @@ int MEDPARTITIONER::ParaDomainSelector::evaluateMemory() const int used_memory = 0; #if !defined WIN32 && !defined __APPLE__ struct sysinfo si; - int err = sysinfo( &si ); + int const err = sysinfo( &si ); if ( !err ) used_memory = (int)(( si.totalram - si.freeram + si.totalswap - si.freeswap ) * si.mem_unit ) / 1024; #endif diff --git a/src/MEDPartitioner/MEDPARTITIONER_ParaDomainSelector.hxx b/src/MEDPartitioner/MEDPARTITIONER_ParaDomainSelector.hxx index 8502c693d..232f63085 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_ParaDomainSelector.hxx +++ b/src/MEDPartitioner/MEDPARTITIONER_ParaDomainSelector.hxx @@ -20,8 +20,8 @@ #ifndef __MEDPARTITIONER_PARADOMAINSELECTOR_HXX__ #define __MEDPARTITIONER_PARADOMAINSELECTOR_HXX__ +#include "MCIdType.hxx" #include "MEDPARTITIONER.hxx" -#include "MCType.hxx" #include <memory> #include <vector> diff --git a/src/MEDPartitioner/MEDPARTITIONER_ParallelTopology.cxx b/src/MEDPartitioner/MEDPARTITIONER_ParallelTopology.cxx index cf607dfc6..2a81568ff 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_ParallelTopology.cxx +++ b/src/MEDPartitioner/MEDPARTITIONER_ParallelTopology.cxx @@ -30,8 +30,8 @@ #include "InterpKernelHashMap.hxx" #include "MCIdType.hxx" -#include <set> -#include <map> +#include <cstddef> +#include <utility> #include <vector> #include <iostream> @@ -99,7 +99,7 @@ void ParallelTopology::setGlobalNumerotationDefault(ParaDomainSelector* domainSe for (int idomain=0; idomain<_nb_domain; idomain++) { _loc_to_glob[idomain].resize(_nb_cells[idomain]); - mcIdType domainCellShift=domainSelector->getDomainCellShift(idomain); + mcIdType const domainCellShift=domainSelector->getDomainCellShift(idomain); for (mcIdType i=0; i<_nb_cells[idomain]; i++) { mcIdType global=domainCellShift+i ; @@ -118,7 +118,7 @@ void ParallelTopology::setGlobalNumerotationDefault(ParaDomainSelector* domainSe for (int idomain=0; idomain<_nb_domain; idomain++) { _node_loc_to_glob[idomain].resize(_nb_nodes[idomain]); - mcIdType domainNodeShift=domainSelector->getDomainNodeShift(idomain); + mcIdType const domainNodeShift=domainSelector->getDomainNodeShift(idomain); for (mcIdType i=0; i<_nb_nodes[idomain]; i++) { mcIdType global=domainNodeShift+i ; @@ -150,7 +150,7 @@ ParallelTopology::ParallelTopology(const std::vector<MEDCoupling::MEDCouplingUMe _nb_domain=(int)meshes.size(); mcIdType index_global=0; mcIdType index_node_global=0; - mcIdType index_face_global=0; + mcIdType const index_face_global=0; _nb_cells.resize(_nb_domain); _nb_nodes.resize(_nb_domain); @@ -230,7 +230,7 @@ ParallelTopology::ParallelTopology(const std::vector<MEDCoupling::MEDCouplingUMe for (mcIdType i=0; i< nb_node; i++) { mcIdType local= node_corresp[i*2]; - mcIdType distant = node_corresp[i*2+1]; + mcIdType const distant = node_corresp[i*2+1]; local2distant.insert(std::make_pair(local, std::make_pair(distant_ip,distant))); } } @@ -301,7 +301,7 @@ ParallelTopology::ParallelTopology(Graph* graph, Topology* oldTopology, int nb_d int icellProc=0; //all cells of my domains are concatenated in part for (int iold=0; iold<oldTopology->nbDomain(); iold++) { - mcIdType ioldNbCell=oldTopology->getCellNumber(iold); + mcIdType const ioldNbCell=oldTopology->getCellNumber(iold); //std::cout<<"proc "<<MyGlobals::_Rank<<" : cell number old domain "<<iold<<" : "<<ioldNbCell<<std::endl; //if not my old domains getCellNumber is 0 std::vector<mcIdType> globalids(ioldNbCell); @@ -340,7 +340,7 @@ ParallelTopology::ParallelTopology(Graph* graph, Topology* oldTopology, int nb_d int iGlobDom = FromIdType<int>(part[ iGlob ]); for ( mcIdType i = index[ iGlob ]; i < index[ iGlob+1 ]; i++ ) { - mcIdType iGlobNear = value[ i ]; + mcIdType const iGlobNear = value[ i ]; if ( iGlob > iGlobNear ) continue; // treat ( iGlob, iGlobNear ) pair once int iGlobNearDom = FromIdType<int>(part[ iGlobNear ]); @@ -362,7 +362,7 @@ ParallelTopology::ParallelTopology(Graph* graph, Topology* oldTopology, int nb_d std::vector< mcIdType > & corresp = cellCorresp[ idomain ][ idomainNear ]; if ( corresp.empty() ) continue; - MEDPARTITIONER::ConnectZone* cz = new MEDPARTITIONER::ConnectZone(); + auto* cz = new MEDPARTITIONER::ConnectZone(); cz->setName( "Connect Zone defined by MEDPARTITIONER" ); cz->setDistantDomainNumber( idomainNear ); cz->setLocalDomainNumber ( idomain ); @@ -375,10 +375,10 @@ ParallelTopology::ParallelTopology(Graph* graph, Topology* oldTopology, int nb_d ParallelTopology::~ParallelTopology() { - for ( size_t i = 0; i < _connect_zones.size(); ++i ) + for (auto & _connect_zone : _connect_zones) { - delete _connect_zones[i]; - _connect_zones[i] = 0; + delete _connect_zone; + _connect_zone = nullptr; } _connect_zones.clear(); } @@ -564,7 +564,7 @@ void ParallelTopology::convertToLocal2ndVersion(mcIdType* nodes, mcIdType nbnode for (mcIdType inode=0; inode<nbnodes; inode++) { // cout <<" inode :"<<inode<< " global = "<<type_connectivity[type][inode]; - mcIdType global = nodes[inode]; + mcIdType const global = nodes[inode]; typedef INTERP_KERNEL::HashMultiMap<mcIdType,std::pair<int,mcIdType> >::iterator mmiter; std::pair<mmiter,mmiter> range=_node_glob_to_loc.equal_range(global); for (mmiter it=range.first; it !=range.second; it++) diff --git a/src/MEDPartitioner/MEDPARTITIONER_ParallelTopology.hxx b/src/MEDPartitioner/MEDPARTITIONER_ParallelTopology.hxx index 13f9b3ee0..45700c46c 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_ParallelTopology.hxx +++ b/src/MEDPartitioner/MEDPARTITIONER_ParallelTopology.hxx @@ -20,12 +20,14 @@ #ifndef __MEDPARTITIONER_PARALLELTOPOLOGY_HXX__ #define __MEDPARTITIONER_PARALLELTOPOLOGY_HXX__ +#include "MCIdType.hxx" #include "MEDPARTITIONER.hxx" #include "MEDPARTITIONER_Topology.hxx" #include "InterpKernelHashMap.hxx" #include <set> +#include <utility> #include <vector> namespace MEDPARTITIONER @@ -47,118 +49,118 @@ namespace MEDPARTITIONER std::vector<mcIdType*>&, std::vector<mcIdType*>&); ParallelTopology(Graph* graph, Topology* oldTopology, int nbdomain, int mesh_dimension); - ~ParallelTopology(); + ~ParallelTopology() override; void setGlobalNumerotationDefault(ParaDomainSelector* domainSelector); /*! converts a list of global cell numbers * to a distributed array with local cell numbers */ - void convertGlobalNodeList(const mcIdType*, mcIdType,mcIdType*,int*); - void convertGlobalNodeList(const mcIdType*, mcIdType,mcIdType*,int); - void convertGlobalNodeListWithTwins(const mcIdType* face_list, mcIdType nbnode, mcIdType*& local, int*& ip, mcIdType*& full_array, mcIdType& size); + void convertGlobalNodeList(const mcIdType*, mcIdType,mcIdType*,int*) override; + void convertGlobalNodeList(const mcIdType*, mcIdType,mcIdType*,int) override; + void convertGlobalNodeListWithTwins(const mcIdType* face_list, mcIdType nbnode, mcIdType*& local, int*& ip, mcIdType*& full_array, mcIdType& size) override; /*! converts a list of global node numbers * to a distributed array with local cell numbers */ - void convertGlobalCellList(const mcIdType*, mcIdType , mcIdType*, int *); + void convertGlobalCellList(const mcIdType*, mcIdType , mcIdType*, int *) override; /*! converts a list of global face numbers * to a distributed array with local face numbers */ - void convertGlobalFaceList(const mcIdType*, mcIdType , mcIdType*, int *); - void convertGlobalFaceList(const mcIdType*, mcIdType , mcIdType*, int); - void convertGlobalFaceListWithTwins(const mcIdType* face_list, mcIdType nbface, mcIdType*& local, int*& ip, mcIdType*& full_array,mcIdType& size); + void convertGlobalFaceList(const mcIdType*, mcIdType , mcIdType*, int *) override; + void convertGlobalFaceList(const mcIdType*, mcIdType , mcIdType*, int) override; + void convertGlobalFaceListWithTwins(const mcIdType* face_list, mcIdType nbface, mcIdType*& local, int*& ip, mcIdType*& full_array,mcIdType& size) override; /*! converting node global numberings to local numberings */ - void convertToLocal2ndVersion(mcIdType* nodes, mcIdType nbnodes, int idomain); + void convertToLocal2ndVersion(mcIdType* nodes, mcIdType nbnodes, int idomain) override; /*! converting node local numbering to global */ - mcIdType convertNodeToGlobal(int ip, mcIdType icell) const { return _node_loc_to_glob[ip][icell]; } + mcIdType convertNodeToGlobal(int ip, mcIdType icell) const override { return _node_loc_to_glob[ip][icell]; } /*! converting face local numbering to global */ - mcIdType convertFaceToGlobal(int ip, mcIdType iface) const { return _face_loc_to_glob[ip][iface]; } + mcIdType convertFaceToGlobal(int ip, mcIdType iface) const override { return _face_loc_to_glob[ip][iface]; } /*! converting cell global numbering to local */ - mcIdType convertCellToGlobal(int ip, mcIdType icell) const { return _loc_to_glob[ip][icell]; } + mcIdType convertCellToGlobal(int ip, mcIdType icell) const override { return _loc_to_glob[ip][icell]; } - void convertNodeToGlobal(int ip, const mcIdType* local, mcIdType n, mcIdType *global) const + void convertNodeToGlobal(int ip, const mcIdType* local, mcIdType n, mcIdType *global) const override { for (mcIdType i=0; i<n; i++) global[i]=_node_loc_to_glob[ip][local[i]]; } - void convertCellToGlobal(int ip, const mcIdType* local, mcIdType n, mcIdType *global) const + void convertCellToGlobal(int ip, const mcIdType* local, mcIdType n, mcIdType *global) const override { for (mcIdType i=0; i<n; i++) global[i]=_loc_to_glob[ip][local[i]]; } - void convertFaceToGlobal(int ip, const mcIdType* local, mcIdType n, mcIdType *global) const + void convertFaceToGlobal(int ip, const mcIdType* local, mcIdType n, mcIdType *global) const override { for (mcIdType i=0; i<n; i++) global[i]=_face_loc_to_glob[ip][local[i]]; } - int nbDomain() const { return _nb_domain; } + int nbDomain() const override { return _nb_domain; } - mcIdType nbCells() const { return _nb_total_cells; } + mcIdType nbCells() const override { return _nb_total_cells; } - mcIdType nbNodes() const { return _nb_total_nodes; } + mcIdType nbNodes() const override { return _nb_total_nodes; } - mcIdType nbCells( int idomain) const { return _nb_cells[idomain]; } + mcIdType nbCells( int idomain) const override { return _nb_cells[idomain]; } /*! retrieving number of nodes */ - mcIdType getNodeNumber(int idomain) const { return _nb_nodes[idomain]; } + mcIdType getNodeNumber(int idomain) const override { return _nb_nodes[idomain]; } - mcIdType getNodeNumber() const; + mcIdType getNodeNumber() const override; - void getNodeList(int idomain, mcIdType* list) const; + void getNodeList(int idomain, mcIdType* list) const override; /*! retrieving cell numbers after merging in parallel mode */ - std::vector<mcIdType> & getFusedCellNumbers(int idomain) { return _cell_loc_to_glob_fuse[idomain]; } + std::vector<mcIdType> & getFusedCellNumbers(int idomain) override { return _cell_loc_to_glob_fuse[idomain]; } - const std::vector<mcIdType>& getFusedCellNumbers(int idomain) const { return _cell_loc_to_glob_fuse[idomain]; } + const std::vector<mcIdType>& getFusedCellNumbers(int idomain) const override { return _cell_loc_to_glob_fuse[idomain]; } /*! retrieving face numbers after merging in parallel mode */ - std::vector<mcIdType> & getFusedFaceNumbers(int idomain) { return _face_loc_to_glob_fuse[idomain]; } + std::vector<mcIdType> & getFusedFaceNumbers(int idomain) override { return _face_loc_to_glob_fuse[idomain]; } - const std::vector<mcIdType>& getFusedFaceNumbers(int idomain) const { return _face_loc_to_glob_fuse[idomain]; } + const std::vector<mcIdType>& getFusedFaceNumbers(int idomain) const override { return _face_loc_to_glob_fuse[idomain]; } /*! retrieving number of nodes */ - mcIdType getCellNumber(int idomain) const { return _nb_cells[idomain]; } + mcIdType getCellNumber(int idomain) const override { return _nb_cells[idomain]; } mcIdType getCellDomainNumber(int global) const { return (_glob_to_loc.find(global)->second).first; } - void getCellList(int idomain, mcIdType* list) const; + void getCellList(int idomain, mcIdType* list) const override; - mcIdType getFaceNumber(int idomain) const { return _nb_faces[idomain]; } + mcIdType getFaceNumber(int idomain) const override { return _nb_faces[idomain]; } - mcIdType getFaceNumber() const; + mcIdType getFaceNumber() const override; - void getFaceList(int idomain, mcIdType* list) const; + void getFaceList(int idomain, mcIdType* list) const override; /*! converting a global cell number to a local representation (domain + local number) */ - std::pair<int,mcIdType> convertGlobalCell(mcIdType iglobal) const { return _glob_to_loc.find(iglobal)->second; } + std::pair<int,mcIdType> convertGlobalCell(mcIdType iglobal) const override { return _glob_to_loc.find(iglobal)->second; } - mcIdType convertGlobalFace(mcIdType iglobal, int idomain); + mcIdType convertGlobalFace(mcIdType iglobal, int idomain) override; - mcIdType convertGlobalNode(mcIdType iglobal, int idomain); + mcIdType convertGlobalNode(mcIdType iglobal, int idomain) override; - std::vector<MEDPARTITIONER::ConnectZone*>& getCZ(); + std::vector<MEDPARTITIONER::ConnectZone*>& getCZ() override; //adding a face to the topology - void appendFace(int idomain, mcIdType ilocal, mcIdType iglobal); + void appendFace(int idomain, mcIdType ilocal, mcIdType iglobal) override; //return max global face number - mcIdType getMaxGlobalFace() const; + mcIdType getMaxGlobalFace() const override; private: bool hasCellWithNodes( const MeshCollection&, int dom, const std::set<mcIdType>& nodes ); private: //mapping global -> local - typedef INTERP_KERNEL::HashMultiMap<mcIdType,std::pair<int,mcIdType> > TGlob2DomainLoc; + using TGlob2DomainLoc = INTERP_KERNEL::HashMultiMap<mcIdType, std::pair<int, mcIdType>>; TGlob2DomainLoc _glob_to_loc; TGlob2DomainLoc _node_glob_to_loc; @@ -172,7 +174,7 @@ namespace MEDPARTITIONER std::vector<std::vector <mcIdType> > _face_loc_to_glob_fuse; // glob nums after merging //mapping global -> local - typedef INTERP_KERNEL::HashMultiMap<mcIdType,std::pair<int,mcIdType> > TGlob2LocsMap; + using TGlob2LocsMap = INTERP_KERNEL::HashMultiMap<mcIdType, std::pair<int, mcIdType>>; TGlob2LocsMap _face_glob_to_loc; //mapping local -> global diff --git a/src/MEDPartitioner/MEDPARTITIONER_ScotchGraph.cxx b/src/MEDPartitioner/MEDPARTITIONER_ScotchGraph.cxx index cbb451e2a..97b2c6739 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_ScotchGraph.cxx +++ b/src/MEDPartitioner/MEDPARTITIONER_ScotchGraph.cxx @@ -17,13 +17,17 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +#include "MCIdType.hxx" #include "MEDPARTITIONER_Graph.hxx" #include "MEDPARTITIONER_ScotchGraph.hxx" #include "MEDPARTITIONER_Utils.hxx" #include "MEDCouplingSkyLineArray.hxx" +#include <iostream> #include <cstdio> +#include <string> +#include <vector> #ifdef MED_ENABLE_SCOTCH extern "C" @@ -44,16 +48,15 @@ SCOTCHGraph::SCOTCHGraph(MEDCoupling::MEDCouplingSkyLineArray* graph, int* edgew } SCOTCHGraph::~SCOTCHGraph() -{ -} += default; -void SCOTCHGraph::partGraph(int ndomain, const std::string& options_string, ParaDomainSelector* sel) +void SCOTCHGraph::partGraph(int ndomain, const std::string& options_string, ParaDomainSelector* /*sel*/) { if (MyGlobals::_Verbose>10) std::cout << "proc " << MyGlobals::_Rank << " : SCOTCHGraph::partGraph" << std::endl; //number of graph vertices - int n = FromIdType<int>(_graph->getNumberOf()); + int const n = FromIdType<int>(_graph->getNumberOf()); //graph #ifdef MEDCOUPLING_USE_64BIT_IDS std::vector<int> indexVec( _graph->getIndex(), _graph->getIndexArray()->end() ); @@ -65,7 +68,7 @@ void SCOTCHGraph::partGraph(int ndomain, const std::string& options_string, Para int * adjncy=const_cast<int*>(_graph->getValues()); #endif //ndomain - int nparts=ndomain; + int const nparts=ndomain; #if !defined(MED_ENABLE_SCOTCH) throw INTERP_KERNEL::Exception("SCOTCHGraph::partGraph : SCOTCH is not available. Check your products, please."); diff --git a/src/MEDPartitioner/MEDPARTITIONER_ScotchGraph.hxx b/src/MEDPartitioner/MEDPARTITIONER_ScotchGraph.hxx index 2db7ded55..de6015735 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_ScotchGraph.hxx +++ b/src/MEDPartitioner/MEDPARTITIONER_ScotchGraph.hxx @@ -31,9 +31,9 @@ namespace MEDPARTITIONER { public: SCOTCHGraph(); - SCOTCHGraph(MEDCoupling::MEDCouplingSkyLineArray*, int* edgeweight=0); - virtual ~SCOTCHGraph(); - void partGraph(int ndomain, const std::string& options_string="", ParaDomainSelector* sel=0); + SCOTCHGraph(MEDCoupling::MEDCouplingSkyLineArray*, int* edgeweight=nullptr); + ~SCOTCHGraph() override; + void partGraph(int ndomain, const std::string& options_string="", ParaDomainSelector* sel=nullptr) override; }; } diff --git a/src/MEDPartitioner/MEDPARTITIONER_Topology.hxx b/src/MEDPartitioner/MEDPARTITIONER_Topology.hxx index f7672817f..e61fa9d83 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_Topology.hxx +++ b/src/MEDPartitioner/MEDPARTITIONER_Topology.hxx @@ -20,10 +20,10 @@ #ifndef __MEDPARTITIONER_TOPOLOGY_HXX__ #define __MEDPARTITIONER_TOPOLOGY_HXX__ +#include "MCIdType.hxx" #include "MEDPARTITIONER.hxx" -#include "MCType.hxx" -#include <map> +#include <utility> #include <vector> namespace MEDCoupling @@ -41,9 +41,9 @@ namespace MEDPARTITIONER class MEDPARTITIONER_EXPORT Topology { public: - Topology() { } + Topology() = default; Topology(std::vector<MEDCoupling::MEDCouplingUMesh*>, std::vector<MEDPARTITIONER::ConnectZone*>) { } - virtual ~Topology() { } + virtual ~Topology() = default; /*! converts a list of global cell numbers * to a distributed array with local cell numbers diff --git a/src/MEDPartitioner/MEDPARTITIONER_UserGraph.cxx b/src/MEDPartitioner/MEDPARTITIONER_UserGraph.cxx index 35136b2ef..88a9862cd 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_UserGraph.cxx +++ b/src/MEDPartitioner/MEDPARTITIONER_UserGraph.cxx @@ -17,12 +17,14 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +#include "MCIdType.hxx" #include "MEDPARTITIONER_Graph.hxx" #include "MEDPARTITIONER_UserGraph.hxx" #include "MEDCouplingSkyLineArray.hxx" #include <iostream> +#include <string> #include <vector> using namespace MEDPARTITIONER; @@ -32,7 +34,7 @@ using namespace MEDPARTITIONER; * (domain numbers range from 0 to ndomain-1 * \param n number of cells in the mesh */ -UserGraph::UserGraph(MEDCoupling::MEDCouplingSkyLineArray *array, const int *partition, mcIdType n):Graph(array,0) +UserGraph::UserGraph(MEDCoupling::MEDCouplingSkyLineArray *array, const int *partition, mcIdType n):Graph(array,nullptr) { std::vector<mcIdType> index(n+1),value(n); @@ -49,10 +51,9 @@ UserGraph::UserGraph(MEDCoupling::MEDCouplingSkyLineArray *array, const int *par } UserGraph::~UserGraph() -{ -} += default; -void UserGraph::partGraph(int ndomain, const std::string& options, ParaDomainSelector* sel) +void UserGraph::partGraph(int /*ndomain*/, const std::string& /*options*/, ParaDomainSelector* /*sel*/) { std::cerr << "MEDPARTITIONER::UserGraph::partGraph() should not have to be used" << std::endl; } diff --git a/src/MEDPartitioner/MEDPARTITIONER_UserGraph.hxx b/src/MEDPartitioner/MEDPARTITIONER_UserGraph.hxx index ff93ed32d..2450f52df 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_UserGraph.hxx +++ b/src/MEDPartitioner/MEDPARTITIONER_UserGraph.hxx @@ -20,6 +20,7 @@ #ifndef __MEDPARTITIONER_USERGRAPH_HXX__ #define __MEDPARTITIONER_USERGRAPH_HXX__ +#include "MCIdType.hxx" #include "MEDPARTITIONER.hxx" #include "MEDPARTITIONER_Graph.hxx" @@ -31,8 +32,8 @@ namespace MEDPARTITIONER { public: UserGraph(MEDCoupling::MEDCouplingSkyLineArray*, const int*, mcIdType); - virtual ~UserGraph(); - void partGraph(int, const std::string& options=std::string(""), ParaDomainSelector *sel=0); + ~UserGraph() override; + void partGraph(int, const std::string& options=std::string(""), ParaDomainSelector *sel=nullptr) override; }; } #endif diff --git a/src/MEDPartitioner/MEDPARTITIONER_Utils.cxx b/src/MEDPartitioner/MEDPARTITIONER_Utils.cxx index 1b85e136e..cbdb56c6b 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_Utils.cxx +++ b/src/MEDPartitioner/MEDPARTITIONER_Utils.cxx @@ -19,22 +19,32 @@ #include "MEDPARTITIONER_Utils.hxx" +#include "MCIdType.hxx" +#include "MCType.hxx" +#include "MEDCouplingMemArray.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include "BBTree.txx" #include "MEDLoader.hxx" #include "MEDLoaderBase.hxx" -#include "MEDFileUtilities.hxx" -#include "CellModel.hxx" #include "MEDCouplingUMesh.hxx" #include "MEDCouplingFieldDouble.hxx" #include "InterpKernelException.hxx" #include "MCAuto.hxx" #include "InterpKernelAutoPtr.hxx" +#include "med.h" +#include "medfile.h" +#include "medfield.h" -#include <fstream> +#include <cstdlib> +#include <algorithm> #include <iostream> #include <iomanip> +#include <map> #include <sstream> #include <string> #include <cstring> +#include <vector> +#include <utility> using namespace MEDPARTITIONER; @@ -113,8 +123,8 @@ std::vector<int> MEDPARTITIONER::CreateRandomSize(const int size) srand( MyGlobals::_Randomize ); for (int i=0; i<size; i++) { - int ii=rand()%size; - int tmp=res[ii]; + int const ii=rand()%size; + int const tmp=res[ii]; res[ii]=res[i]; res[i]=tmp; } @@ -131,20 +141,20 @@ void MEDPARTITIONER::RandomizeAdj(int* xadj, int* adjncy, std::vector<int>& ran, std::cerr << "MEDPARTITIONER::RandomizeAdj only works on one proc!" << std::endl; return; } - std::size_t size=ran.size(); + std::size_t const size=ran.size(); std::vector<int> invran(size); for (unsigned int i=0; i<size; i++) invran[ran[i]]=i; vx.resize(size+1); - int lga=xadj[size]; + int const lga=xadj[size]; va.resize(lga); int jj=0; vx[0]=0; for (std::size_t i=0; i<size; i++) { - int ir=ran[i]; + int const ir=ran[i]; int ii=xadj[ir]; - int lgj=xadj[ir+1]-ii; + int const lgj=xadj[ir+1]-ii; for (int j=0; j<lgj; j++) { va[jj]=invran[adjncy[ii]]; @@ -161,7 +171,7 @@ void MEDPARTITIONER::TestRandomize() //int adjncy[13]={1,4,0,2,4,1,3,4,2,4,4,3,4}; int xadj[6]={0,2,5,9,12,13}; int adjncy[13]={0,0,1,1,1,2,2,2,2,3,3,3,4}; - int size=5; + int const size=5; std::vector<int> r=CreateRandomSize(size); std::vector<int> vx,va; RandomizeAdj(&xadj[0],&adjncy[0],r,vx,va); @@ -172,8 +182,8 @@ std::string MEDPARTITIONER::ReprVectorOfString(const std::vector<std::string>& v if (vec.size()==0) return std::string(" NONE\n"); std::ostringstream oss; - for (std::vector<std::string>::const_iterator i=vec.begin(); i!=vec.end(); ++i) - oss << " -> '" << *i << "'" << std::endl; + for (const auto & i : vec) + oss << " -> '" << i << "'" << std::endl; return oss.str(); } @@ -182,8 +192,8 @@ std::string MEDPARTITIONER::ReprVectorOfString(const std::vector<std::string>& v if (vec.size()==0) return std::string(" NONE\n"); std::ostringstream oss; - for (std::vector<std::string>::const_iterator i=vec.begin(); i!=vec.end(); ++i) - oss << separator << *i; + for (const auto & i : vec) + oss << separator << i; return oss.str(); } @@ -192,8 +202,8 @@ std::string MEDPARTITIONER::ReprMapOfStringInt(const std::map<std::string,mcIdTy if (mymap.size()==0) return std::string(" NONE\n"); std::ostringstream oss; - for (std::map<std::string,mcIdType>::const_iterator i=mymap.begin(); i!=mymap.end(); ++i) - oss << " -> [" << (*i).first << "]=" << (*i).second << std::endl; + for (const auto & i : mymap) + oss << " -> [" << i.first << "]=" << i.second << std::endl; return oss.str(); } @@ -202,8 +212,8 @@ std::string MEDPARTITIONER::ReprMapOfStringVectorOfString(const std::map< std::s if (mymap.size()==0) return std::string(" NONE\n"); std::ostringstream oss; - for (std::map< std::string,std::vector<std::string> >::const_iterator i=mymap.begin(); i!=mymap.end(); ++i) - oss << " -> [" << (*i).first << "]=" << std::endl << ReprVectorOfString((*i).second) << std::endl; + for (const auto & i : mymap) + oss << " -> [" << i.first << "]=" << std::endl << ReprVectorOfString(i.second) << std::endl; return oss.str(); } @@ -212,10 +222,10 @@ std::string MEDPARTITIONER::ReprFieldDescriptions(const std::vector<std::string> if (vec.size()==0) return std::string(" NONE\n"); std::ostringstream oss; - for (std::vector<std::string>::const_iterator i=vec.begin(); i!=vec.end(); ++i) + for (const auto & i : vec) { oss << " ->"; - oss << ReprVectorOfString(DeserializeToVectorOfString(*i), separator) << std::endl; + oss << ReprVectorOfString(DeserializeToVectorOfString(i), separator) << std::endl; } return oss.str(); } @@ -238,8 +248,8 @@ std::string MEDPARTITIONER::SerializeFromString(const std::string& s) std::string MEDPARTITIONER::SerializeFromVectorOfString(const std::vector<std::string>& vec) { std::ostringstream oss; - for (std::vector<std::string>::const_iterator i=vec.begin(); i!=vec.end(); ++i) - oss<< std::setw(5) << (*i).size() << "/" << *i << "/"; + for (const auto & i : vec) + oss<< std::setw(5) << i.size() << "/" << i << "/"; return oss.str(); } @@ -250,7 +260,7 @@ std::vector<std::string> MEDPARTITIONER::DeserializeToVectorOfString(const std:: { std::vector<std::string> res; std::size_t pos=0; - std::size_t posmax=str.size(); + std::size_t const posmax=str.size(); if (posmax==0) return res; //empty vector std::size_t length; @@ -271,12 +281,12 @@ std::vector<std::string> MEDPARTITIONER::DeserializeToVectorOfString(const std:: std::string MEDPARTITIONER::EraseTagSerialized(const std::string& fromStr, const std::string& tag) { - std::vector<std::string> vec=DeserializeToVectorOfString(fromStr); + std::vector<std::string> const vec=DeserializeToVectorOfString(fromStr); std::vector<std::string> res; - for (std::size_t i=0; i<vec.size(); i++) + for (const auto & i : vec) { - if (vec[i].find(tag)==std::string::npos) - res.push_back(vec[i]); + if (i.find(tag)==std::string::npos) + res.push_back(i); } return MEDPARTITIONER::SerializeFromVectorOfString(res); } @@ -288,10 +298,10 @@ std::string MEDPARTITIONER::EraseTagSerialized(const std::string& fromStr, const std::vector<std::string> MEDPARTITIONER::VectorizeFromMapOfStringInt(const std::map<std::string,mcIdType>& mymap) { std::vector<std::string> res; - for (std::map<std::string,mcIdType>::const_iterator i=mymap.begin(); i!=mymap.end(); ++i) + for (const auto & i : mymap) { std::ostringstream oss; - oss << (*i).second << "/" << (*i).first; + oss << i.second << "/" << i.first; res.push_back(oss.str()); } return res; @@ -303,18 +313,18 @@ std::vector<std::string> MEDPARTITIONER::VectorizeFromMapOfStringInt(const std:: std::map<std::string,mcIdType> MEDPARTITIONER::DevectorizeToMapOfStringInt(const std::vector<std::string>& vec) { std::map<std::string,mcIdType> res; - for (std::vector<std::string>::const_iterator i=vec.begin(); i!=vec.end(); ++i) + for (const auto & i : vec) { - std::size_t pos=0; - std::size_t posmax=(*i).size(); - std::size_t found=(*i).find('/'); //first slash + std::size_t const pos=0; + std::size_t const posmax=i.size(); + std::size_t const found=i.find('/'); //first slash if ((found==std::string::npos) || (found<1)) throw INTERP_KERNEL::Exception("Error aIntNumber/anyString is expected"); mcIdType second; - std::istringstream iss((*i).substr(pos,found)); + std::istringstream iss(i.substr(pos,found)); iss >> second; - std::string first=(*i).substr(pos+found+1,posmax-found); - std::map<std::string,mcIdType>::iterator it=res.find(first); + std::string const first=i.substr(pos+found+1,posmax-found); + auto const it=res.find(first); if (it!=res.end()) if ((*it).second!=second) throw INTERP_KERNEL::Exception("Error not the same map value"); @@ -331,11 +341,11 @@ std::map<std::string,mcIdType> MEDPARTITIONER::DevectorizeToMapOfStringInt(const std::vector<std::string> MEDPARTITIONER::VectorizeFromMapOfStringVectorOfString(const std::map< std::string,std::vector<std::string> >& mymap) { std::vector<std::string> res; - for (std::map< std::string,std::vector<std::string> >::const_iterator i=mymap.begin(); i!=mymap.end(); ++i) + for (const auto & i : mymap) { - std::vector<std::string> vs=(*i).second; //a vector of string; + std::vector<std::string> vs=i.second; //a vector of string; std::ostringstream oss; - oss << "Keymap/" << (*i).first << "/" << (*i).second.size(); + oss << "Keymap/" << i.first << "/" << i.second.size(); vs.insert(vs.begin(), oss.str()); res.push_back(SerializeFromVectorOfString(vs)); } @@ -349,20 +359,20 @@ std::vector<std::string> MEDPARTITIONER::VectorizeFromMapOfStringVectorOfString( std::map< std::string,std::vector<std::string> > MEDPARTITIONER::DevectorizeToMapOfStringVectorOfString(const std::vector<std::string>& vec) { std::map< std::string,std::vector<std::string> > res; - for (std::vector<std::string>::const_iterator i=vec.begin(); i!=vec.end(); ++i) + for (const auto & i : vec) { - std::vector<std::string> vs=DeserializeToVectorOfString(*i); + std::vector<std::string> vs=DeserializeToVectorOfString(i); - std::string enTete=vs[0]; - std::size_t posmax=enTete.size(); - std::size_t foundKey=enTete.find("Keymap/"); - std::size_t foundSizeVector=enTete.find_last_of('/'); + std::string const enTete=vs[0]; + std::size_t const posmax=enTete.size(); + std::size_t const foundKey=enTete.find("Keymap/"); + std::size_t const foundSizeVector=enTete.find_last_of('/'); if ((foundKey==std::string::npos) || (foundKey!=0) || ((foundKey+7)>=foundSizeVector)) throw INTERP_KERNEL::Exception("Error Keymap/anyString/aIntNumber is expected"); int sizeVector; std::istringstream iss(enTete.substr(foundSizeVector+1,posmax-foundSizeVector)); iss >> sizeVector; - std::string keymap=enTete.substr(foundKey+7,foundSizeVector-foundKey-7); + std::string const keymap=enTete.substr(foundKey+7,foundSizeVector-foundKey-7); for (int ii=1; ii<=sizeVector; ii++) res[keymap].push_back(vs[ii]); //add unconditionally,so merge duplicates in second vector } @@ -378,9 +388,9 @@ std::vector<std::string> MEDPARTITIONER::SelectTagsInVectorOfString(const std::v std::vector<std::string> res; if (vec.size()==0) return res; - for (std::vector<std::string>::const_iterator i=vec.begin(); i!=vec.end(); ++i) + for (const auto & i : vec) { - if ((*i).find(tag)!=std::string::npos) res.push_back(*i); + if (i.find(tag)!=std::string::npos) res.push_back(i); } return res; } @@ -394,18 +404,18 @@ std::vector<std::string> MEDPARTITIONER::DeleteDuplicatesInVectorOfString(const if (vec.size()==0) return res; //shit for unique and unique_copy for the duplicate CONSECUTIVE elements //I do not want to sort - for (std::vector<std::string>::const_iterator i=vec.begin(); i!=vec.end(); ++i) + for (const auto & i : vec) { bool found=false; - for (std::vector<std::string>::const_iterator j=res.begin(); j!=res.end(); ++j) + for (const auto & re : res) { - if ((*i).compare(*j)==0) + if (i.compare(re)==0) { found=true; break; } } - if (!found) res.push_back(*i); + if (!found) res.push_back(i); } return res; } @@ -413,8 +423,8 @@ std::vector<std::string> MEDPARTITIONER::DeleteDuplicatesInVectorOfString(const std::map< std::string,std::vector<std::string> > MEDPARTITIONER::DeleteDuplicatesInMapOfStringVectorOfString(const std::map< std::string,std::vector<std::string> >& mymap) { std::map< std::string,std::vector<std::string> > res; - for (std::map< std::string,std::vector<std::string> >::const_iterator i=mymap.begin(); i!=mymap.end(); ++i) - res[(*i).first]=DeleteDuplicatesInVectorOfString((*i).second); + for (const auto & i : mymap) + res[i.first]=DeleteDuplicatesInVectorOfString(i.second); return res; } @@ -429,8 +439,8 @@ std::string MEDPARTITIONER::Cle1ToStr(const std::string& s, const int inew) void MEDPARTITIONER::Cle1ToData(const std::string& key, std::string& s, int& inew) { - std::size_t posmax=key.size(); - std::size_t found=key.find(' '); + std::size_t const posmax=key.size(); + std::size_t const found=key.find(' '); if ((found==std::string::npos) || (found<1)) throw INTERP_KERNEL::Exception("Error 'aStringWithoutWhitespace aInt' is expected"); s=key.substr(0,found); @@ -447,8 +457,8 @@ std::string MEDPARTITIONER::Cle2ToStr(const std::string& s, const int inew, cons void MEDPARTITIONER::Cle2ToData(const std::string& key, std::string& s, int& inew, int& iold) { - std::size_t posmax=key.size(); - std::size_t found=key.find(' '); + std::size_t const posmax=key.size(); + std::size_t const found=key.find(' '); if ((found==std::string::npos) || (found<1)) throw INTERP_KERNEL::Exception("Error 'aStringWithoutWhitespace aInt aInt' is expected"); s=key.substr(0,found); @@ -479,7 +489,7 @@ std::string MEDPARTITIONER::ExtractFromDescription(const std::string& descriptio res=res.substr(0,found); return res; } - std::size_t lg=StrToInt(description.substr(found-6,found)); + std::size_t const lg=StrToInt(description.substr(found-6,found)); beg+=tag.length(); return description.substr(beg,lg-tag.length()); } @@ -539,7 +549,7 @@ std::vector<std::string> MEDPARTITIONER::BrowseFieldDouble(const MEDCoupling::ME std::vector<std::string> res; if (fd->getArray()) { - std::size_t nb=fd->getArray()->getNumberOfComponents(); + std::size_t const nb=fd->getArray()->getNumberOfComponents(); res.push_back("nbComponents="); res.back()+=IntToStr((int)nb); for (unsigned int i=0; i<nb; i++) { @@ -560,31 +570,31 @@ std::vector<std::string> MEDPARTITIONER::BrowseFieldDouble(const MEDCoupling::ME std::vector<std::string> MEDPARTITIONER::BrowseAllFields(const std::string& myfile) { std::vector<std::string> res; - std::vector<std::string> meshNames=MEDCoupling::GetMeshNames(myfile); + std::vector<std::string> const meshNames=MEDCoupling::GetMeshNames(myfile); - for (std::size_t i=0; i<meshNames.size(); i++) + for (const auto & meshName : meshNames) { - std::vector<std::string> fieldNames= - MEDCoupling::GetAllFieldNamesOnMesh(myfile,meshNames[i]); - for (std::size_t j = 0; j < fieldNames.size(); j++) + std::vector<std::string> const fieldNames= + MEDCoupling::GetAllFieldNamesOnMesh(myfile,meshName); + for (const auto & fieldName : fieldNames) { - std::vector< MEDCoupling::TypeOfField > typeFields= - MEDCoupling::GetTypesOfField(myfile, meshNames[i], fieldNames[j]); - for (std::size_t k = 0; k < typeFields.size(); k++) + std::vector< MEDCoupling::TypeOfField > const typeFields= + MEDCoupling::GetTypesOfField(myfile, meshName, fieldName); + for (auto & typeField : typeFields) { - std::vector< std::pair< int, int > > its= - GetFieldIterations(typeFields[k], myfile, meshNames[i], fieldNames[j]); + std::vector< std::pair< int, int > > const its= + GetFieldIterations(typeField, myfile, meshName, fieldName); if (MyGlobals::_Is0verbose>100) - std::cout<< "fieldName " << fieldNames[j] << " typeField " << typeFields[k] << " its.size() " << its.size() << std::endl; - for (std::size_t m = 0; m < its.size(); m++) + std::cout<< "fieldName " << fieldName << " typeField " << typeField << " its.size() " << its.size() << std::endl; + for (auto & it : its) { std::vector<std::string> resi; resi.push_back("fileName="); resi.back()+=myfile; - resi.push_back("meshName="); resi.back()+=meshNames[i]; - resi.push_back("fieldName="); resi.back()+=fieldNames[j]; - resi.push_back("typeField="); resi.back()+=IntToStr((int)typeFields[k]); - resi.push_back("DT="); resi.back()+=IntToStr((int)its[m].first); - resi.push_back("IT="); resi.back()+=IntToStr((int)its[m].second); + resi.push_back("meshName="); resi.back()+=meshName; + resi.push_back("fieldName="); resi.back()+=fieldName; + resi.push_back("typeField="); resi.back()+=IntToStr((int)typeField); + resi.push_back("DT="); resi.back()+=IntToStr((int)it.first); + resi.push_back("IT="); resi.back()+=IntToStr((int)it.second); res.push_back(SerializeFromVectorOfString(resi)); } } @@ -593,7 +603,7 @@ std::vector<std::string> MEDPARTITIONER::BrowseAllFields(const std::string& myfi return res; } -std::vector<std::string> MEDPARTITIONER::GetInfosOfField(const char *fileName, const char *meshName, const int idomain) +std::vector<std::string> MEDPARTITIONER::GetInfosOfField(const char *fileName, const char * /*meshName*/, const int idomain) { const int lggeom=10; const med_geometry_type GEOMTYPE[lggeom]={ //MED_N_CELL_FIXED_GEO] = { @@ -671,8 +681,8 @@ std::vector<std::string> MEDPARTITIONER::GetInfosOfField(const char *fileName, c }; std::vector<std::string> res; - med_idt fid=MEDfileOpen(fileName,MED_ACC_RDONLY); - med_int nbFields=MEDnField(fid); + med_idt const fid=MEDfileOpen(fileName,MED_ACC_RDONLY); + med_int const nbFields=MEDnField(fid); if (MyGlobals::_Verbose>20) std::cout << "on filename " << fileName << " nbOfField " << nbFields << std::endl; // @@ -685,14 +695,14 @@ std::vector<std::string> MEDPARTITIONER::GetInfosOfField(const char *fileName, c // for(int i=1; i<=nbFields; i++) { - med_int ncomp=MEDfieldnComponent(fid,i); + med_int const ncomp=MEDfieldnComponent(fid,i); INTERP_KERNEL::AutoPtr<char> comp=new char[ncomp*MED_SNAME_SIZE+1]; INTERP_KERNEL::AutoPtr<char> unit=new char[ncomp*MED_SNAME_SIZE+1]; INTERP_KERNEL::AutoPtr<char> dt_unit=new char[MED_LNAME_SIZE+1]; med_int nbPdt; MEDfieldInfo(fid,i,nomcha,maa_ass,&localmesh,&typcha,comp,unit,dt_unit,&nbPdt); - std::string curFieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE+1); - std::string curMeshName=MEDLoaderBase::buildStringFromFortran(maa_ass,MED_NAME_SIZE+1); + std::string const curFieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE+1); + std::string const curMeshName=MEDLoaderBase::buildStringFromFortran(maa_ass,MED_NAME_SIZE+1); for (int k=1; k<=nbPdt; k++) { MEDfieldComputingStepInfo(fid,nomcha,k,&numdt,&numo,&dt); @@ -705,16 +715,16 @@ std::vector<std::string> MEDPARTITIONER::GetInfosOfField(const char *fileName, c for (int j=0; j<lggeom; j++) { med_int profilesize=0,nbi=0; - med_entity_type enttype=ENTITYTYPE[ie]; + med_entity_type const enttype=ENTITYTYPE[ie]; //enttype=MED_NODE;enttype=MED_CELL;enttype=MED_NODE_ELEMENT; char pflname[MED_NAME_SIZE+1]=""; char locname[MED_NAME_SIZE+1]=""; - med_int nbofprofile=MEDfieldnProfile(fid,nomcha,numdt,numo,enttype,GEOMTYPE[j],pflname,locname); - int profileit=1; + med_int const nbofprofile=MEDfieldnProfile(fid,nomcha,numdt,numo,enttype,GEOMTYPE[j],pflname,locname); + int const profileit=1; if (enttype==MED_NODE) { - med_geometry_type mygeomtype=MED_UNDEF_ENTITY_TYPE; - med_int nbOfVal=MEDfieldnValueWithProfile(fid,nomcha,numdt,numo,enttype,mygeomtype,profileit, + med_geometry_type const mygeomtype=MED_UNDEF_ENTITY_TYPE; + med_int const nbOfVal=MEDfieldnValueWithProfile(fid,nomcha,numdt,numo,enttype,mygeomtype,profileit, MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi); if (nbOfVal>0) { @@ -745,8 +755,8 @@ std::vector<std::string> MEDPARTITIONER::GetInfosOfField(const char *fileName, c } else { - med_geometry_type mygeomtype=GEOMTYPE[j]; - med_int nbOfVal=MEDfieldnValueWithProfile(fid,nomcha,numdt,numo,enttype,mygeomtype,profileit, + med_geometry_type const mygeomtype=GEOMTYPE[j]; + med_int const nbOfVal=MEDfieldnValueWithProfile(fid,nomcha,numdt,numo,enttype,mygeomtype,profileit, MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi); if (nbOfVal>0) { @@ -864,7 +874,7 @@ namespace MEDPARTITIONER _PgetIntersectingElems = & BBTreeOfDim::_getIntersectingElems< 1 >; break; default: - _tree=0; + _tree=nullptr; throw INTERP_KERNEL::Exception("BBTreeOfDim(): wrong space dimension"); } } @@ -877,13 +887,13 @@ namespace MEDPARTITIONER void BBTreeOfDim::getElementsAroundPoint( const double* coordsPtr, std::vector<mcIdType>& elems ) const { - BBTreeOfDim* me = (BBTreeOfDim*) this; + auto* me = (BBTreeOfDim*) this; (me->*_PgetElementsAroundPoint) ( coordsPtr, elems ); } void BBTreeOfDim::getIntersectingElems(const double* bb, std::vector<mcIdType>& elems) const { - BBTreeOfDim* me = (BBTreeOfDim*) this; + auto* me = (BBTreeOfDim*) this; (me->*_PgetIntersectingElems) ( bb, elems ); } } diff --git a/src/MEDPartitioner/MEDPARTITIONER_Utils.hxx b/src/MEDPartitioner/MEDPARTITIONER_Utils.hxx index 5fa75974e..e2b069333 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_Utils.hxx +++ b/src/MEDPartitioner/MEDPARTITIONER_Utils.hxx @@ -20,11 +20,17 @@ #ifndef __MEDPARTITIONER_UTILS_HXX__ #define __MEDPARTITIONER_UTILS_HXX__ +#include "MCIdType.hxx" +#include "MCType.hxx" +#include "MEDCouplingMemArray.hxx" +#include "MEDCouplingMesh.hxx" +#include "MCAuto.hxx" #include "MEDPARTITIONER.hxx" #include "MEDCouplingUMesh.hxx" #include "BBTree.txx" +#include <cstddef> #include <string> #include <vector> #include <map> diff --git a/src/MEDPartitioner/MEDPARTITIONER_UtilsPara.cxx b/src/MEDPartitioner/MEDPARTITIONER_UtilsPara.cxx index 3fcc686e5..1fc7c1825 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_UtilsPara.cxx +++ b/src/MEDPartitioner/MEDPARTITIONER_UtilsPara.cxx @@ -17,24 +17,19 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +#include "MCType.hxx" +#include "MEDCouplingMemArray.hxx" #include "MEDPARTITIONER_Utils.hxx" #include "MEDLoader.hxx" -#include "MEDLoaderBase.hxx" -#include "MEDFileUtilities.hxx" -#include "CellModel.hxx" -#include "MEDCouplingUMesh.hxx" -#include "MEDCouplingFieldDouble.hxx" #include "InterpKernelException.hxx" -#include "MCAuto.hxx" -#include "MEDCouplingMemArray.txx" -#include "InterpKernelAutoPtr.hxx" -#include <fstream> +#include <cstddef> #include <iostream> #include <iomanip> #include <sstream> #include <string> +#include <vector> #ifdef HAVE_MPI @@ -56,14 +51,14 @@ using namespace MEDPARTITIONER; */ std::vector<std::string> MEDPARTITIONER::SendAndReceiveVectorOfString(const std::vector<std::string>& vec, const int source, const int target) { - int rank=MyGlobals::_Rank; + int const rank=MyGlobals::_Rank; MPI_Status status; - int tag = 111001; + int const tag = 111001; if (rank == source) { - std::string str=SerializeFromVectorOfString(vec); - int size=(int)str.length(); + std::string const str=SerializeFromVectorOfString(vec); + int const size=(int)str.length(); MPI_Send( &size, 1, MPI_INT, target, tag, MPI_COMM_WORLD ); MPI_Send( (void*)str.data(), (int)str.length(), MPI_CHAR, target, tag+100, MPI_COMM_WORLD ); } @@ -72,7 +67,7 @@ std::vector<std::string> MEDPARTITIONER::SendAndReceiveVectorOfString(const std: if (rank == target) { MPI_Recv(&recSize, 1, MPI_INT, source, tag, MPI_COMM_WORLD, &status); - std::string recData(recSize,'x'); + std::string const recData(recSize,'x'); MPI_Recv((void*)recData.data(), recSize, MPI_CHAR, source, tag+100, MPI_COMM_WORLD, &status); return DeserializeToVectorOfString(recData); //not empty one for target proc } @@ -88,11 +83,11 @@ std::vector<std::string> MEDPARTITIONER::AllgathervVectorOfString(const std::vec if (MyGlobals::_World_Size==1) //nothing to do return vec; - int world_size=MyGlobals::_World_Size; + int const world_size=MyGlobals::_World_Size; std::string str=SerializeFromVectorOfString(vec); std::vector<int> indexes(world_size); - int size=(int)str.length(); + int const size=(int)str.length(); MPI_Allgather(&size, 1, MPI_INT, &indexes[0], 1, MPI_INT, MPI_COMM_WORLD); @@ -123,7 +118,7 @@ std::vector<std::string> MEDPARTITIONER::AllgathervVectorOfString(const std::vec */ void MEDPARTITIONER::SendDoubleVec(const std::vector<double>& vec, const int target) { - int tag = 111002; + int const tag = 111002; int size=(int)vec.size(); if (MyGlobals::_Verbose>1000) std::cout << "proc " << MyGlobals::_Rank << " : --> SendDoubleVec " << size << std::endl; @@ -141,7 +136,7 @@ void MEDPARTITIONER::SendDoubleVec(const std::vector<double>& vec, const int tar */ std::vector<double>* MEDPARTITIONER::RecvDoubleVec(const int source) { - int tag = 111002; + int const tag = 111002; int size; #ifdef HAVE_MPI MPI_Status status; @@ -157,7 +152,7 @@ std::vector<double>* MEDPARTITIONER::RecvDoubleVec(const int source) void MEDPARTITIONER::RecvDoubleVec(std::vector<double>& vec, const int source) { - int tag = 111002; + int const tag = 111002; int size; #ifdef HAVE_MPI MPI_Status status; @@ -175,7 +170,7 @@ void MEDPARTITIONER::RecvDoubleVec(std::vector<double>& vec, const int source) */ void MEDPARTITIONER::SendIntVec(const std::vector<mcIdType>& vec, const int target) { - int tag = 111003; + int const tag = 111003; int size=(int)vec.size(); if (MyGlobals::_Verbose>1000) std::cout << "proc " << MyGlobals::_Rank << " : --> SendIntVec " << size << std::endl; @@ -192,7 +187,7 @@ void MEDPARTITIONER::SendIntVec(const std::vector<mcIdType>& vec, const int targ */ std::vector<int> *MEDPARTITIONER::RecvIntVec(const int source) { - int tag = 111003; + int const tag = 111003; int size; #ifdef HAVE_MPI MPI_Status status; @@ -208,7 +203,7 @@ std::vector<int> *MEDPARTITIONER::RecvIntVec(const int source) void MEDPARTITIONER::RecvIntVec(std::vector<mcIdType>& vec, const int source) { - int tag = 111003; + int const tag = 111003; int size; #ifdef HAVE_MPI MPI_Status status; @@ -228,9 +223,9 @@ void MEDPARTITIONER::RecvIntVec(std::vector<mcIdType>& vec, const int source) */ void MEDPARTITIONER::SendDataArrayInt(const MEDCoupling::DataArrayInt *da, const int target) { - if (da==0) + if (da==nullptr) throw INTERP_KERNEL::Exception("Problem send DataArrayInt* NULL"); - int tag = 111004; + int const tag = 111004; int size[3]; size[0]=(int)da->getNbOfElems(); size[1]=(int)da->getNumberOfTuples(); @@ -251,7 +246,7 @@ void MEDPARTITIONER::SendDataArrayInt(const MEDCoupling::DataArrayInt *da, const */ MEDCoupling::DataArrayInt *MEDPARTITIONER::RecvDataArrayInt(const int source) { - int tag = 111004; + int const tag = 111004; int size[3]; #ifdef HAVE_MPI MPI_Status status; @@ -276,9 +271,9 @@ MEDCoupling::DataArrayInt *MEDPARTITIONER::RecvDataArrayInt(const int source) */ void MEDPARTITIONER::SendDataArrayDouble(const MEDCoupling::DataArrayDouble *da, const int target) { - if (da==0) + if (da==nullptr) throw INTERP_KERNEL::Exception("Problem send DataArrayDouble* NULL"); - int tag = 111005; + int const tag = 111005; int size[3]; size[0]=(int)da->getNbOfElems(); size[1]=(int)da->getNumberOfTuples(); @@ -299,7 +294,7 @@ void MEDPARTITIONER::SendDataArrayDouble(const MEDCoupling::DataArrayDouble *da, */ MEDCoupling::DataArrayDouble* MEDPARTITIONER::RecvDataArrayDouble(const int source) { - int tag = 111005; + int const tag = 111005; int size[3]; #ifdef HAVE_MPI MPI_Status status; @@ -388,7 +383,7 @@ void MEDPARTITIONER::TestVectorOfStringMpi() void MEDPARTITIONER::TestMapOfStringIntMpi() { - int rank=MyGlobals::_Rank; + int const rank=MyGlobals::_Rank; std::map<std::string,mcIdType> myMap; myMap["one"]=1; myMap["two"]=22; //a bug @@ -418,7 +413,7 @@ void MEDPARTITIONER::TestMapOfStringIntMpi() void MEDPARTITIONER::TestMapOfStringVectorOfStringMpi() { - int rank=MyGlobals::_Rank; + int const rank=MyGlobals::_Rank; std::vector<std::string> myVector; std::ostringstream oss; oss << "hello from " << std::setw(5) << MyGlobals::_Rank << " " << std::string(rank+1,'n') << " next is an empty one"; @@ -464,13 +459,13 @@ void MEDPARTITIONER::TestMapOfStringVectorOfStringMpi() void MEDPARTITIONER::TestDataArrayMpi() { - int rank=MyGlobals::_Rank; + int const rank=MyGlobals::_Rank; //int { MEDCoupling::DataArrayInt* send=MEDCoupling::DataArrayInt::New(); - MEDCoupling::DataArrayInt* recv=0; - int nbOfTuples=5; - int numberOfComponents=3; + MEDCoupling::DataArrayInt* recv=nullptr; + int const nbOfTuples=5; + int const numberOfComponents=3; send->alloc(nbOfTuples,numberOfComponents); std::vector<int> vals; for (int j=0; j<nbOfTuples; j++) @@ -497,9 +492,9 @@ void MEDPARTITIONER::TestDataArrayMpi() //double { MEDCoupling::DataArrayDouble* send=MEDCoupling::DataArrayDouble::New(); - MEDCoupling::DataArrayDouble* recv=0; - int nbOfTuples=5; - int numberOfComponents=3; + MEDCoupling::DataArrayDouble* recv=nullptr; + int const nbOfTuples=5; + int const numberOfComponents=3; send->alloc(nbOfTuples,numberOfComponents); std::vector<double> vals; for (int j=0; j<nbOfTuples; j++) @@ -528,9 +523,9 @@ void MEDPARTITIONER::TestDataArrayMpi() void MEDPARTITIONER::TestPersistantMpi0To1(int taille, int nb) { double temps_debut=MPI_Wtime(); - int rank=MyGlobals::_Rank; + int const rank=MyGlobals::_Rank; std::vector<int> x, y; - int tag=111111; + int const tag=111111; MPI_Request requete0, requete1; MPI_Status statut; int ok=0; @@ -658,10 +653,10 @@ void MEDPARTITIONER::TestPersistantMpiRing(int taille, int nb) void MEDPARTITIONER::TestPersistantMpiRingOnCommSplit(int size, int nb) { double temps_debut=MPI_Wtime(); - int rank=MyGlobals::_Rank; + int const rank=MyGlobals::_Rank; MPI_Comm newcomm; int color=1; - int rankMax=4; + int const rankMax=4; if (rank>=rankMax) color=MPI_UNDEFINED; //MPI_Comm_dup (MPI_COMM_WORLD, &newcomm) ; diff --git a/src/MEDPartitioner/Test/MEDPARTITIONERTest.cxx b/src/MEDPartitioner/Test/MEDPARTITIONERTest.cxx index f9816ce69..be29070d2 100644 --- a/src/MEDPartitioner/Test/MEDPARTITIONERTest.cxx +++ b/src/MEDPartitioner/Test/MEDPARTITIONERTest.cxx @@ -19,6 +19,10 @@ #include "MEDPARTITIONERTest.hxx" +#include "MCIdType.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include "MCType.hxx" +#include "MCAuto.hxx" #include "MEDPARTITIONER_MeshCollection.hxx" #include "MEDPARTITIONER_ParallelTopology.hxx" #include "MEDPARTITIONER_ParaDomainSelector.hxx" @@ -27,21 +31,21 @@ #include "CellModel.hxx" #include "MEDFileMesh.hxx" #include "MEDLoader.hxx" -#include "MEDLoaderBase.hxx" #include "MEDCouplingUMesh.hxx" #include "MEDCouplingMappedExtrudedMesh.hxx" #include "MEDCouplingFieldDouble.hxx" -#include "MEDCouplingMemArray.hxx" +#include "MEDCouplingMemArray.txx" #include "MEDCouplingMultiFields.hxx" +#include "NormalizedGeometricTypes" #include <cppunit/TestAssert.h> -#include <sstream> +#include <iostream> +#include <memory> #include <fstream> #include <cmath> -#include <list> -#include <stdexcept> #include <cstdlib> +#include <string> #include <vector> #ifdef WIN32 #include<direct.h> @@ -102,7 +106,7 @@ std::string MEDPARTITIONERTest::getPartitionerExe() const if (my_file.good()) return execName; } - execName = getcwd(NULL, 0); + execName = getcwd(nullptr, 0); #ifndef WIN32 execName += "/../../MEDPartitioner/medpartitioner"; #else @@ -231,7 +235,7 @@ MEDCoupling::MEDCouplingUMesh * MEDPARTITIONERTest::buildCUBE3DMesh() std::copy(conn.begin()+i*8,conn.begin()+(i+1)*8,onehexa); if (false) //(_verbose) { - for (int j=0; j<8; j++) cout<<onehexa[j]<<" "; + for (long const j : onehexa) cout<<j<<" "; cout<<endl; } mesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,onehexa); @@ -255,13 +259,13 @@ MEDCoupling::MEDCouplingUMesh * MEDPARTITIONERTest::buildCARRE3DMesh() for (int j=0; j<=_nj; j++) for (int i=0; i<=_ni; i++) { - int k=j; + int const k=j; coor.push_back(i+.1); coor.push_back(j+.2); coor.push_back(k+.3); } int ii; - int k=0; + int const k=0; for (int j=0; j<_nj; j++) for (int i=0; i<_ni; i++) { @@ -299,7 +303,7 @@ MEDCoupling::MEDCouplingUMesh * MEDPARTITIONERTest::buildCARRE3DMesh() std::copy(conn.begin()+i*4,conn.begin()+(i+1)*4,onequa); if (false) //(_verbose) { - for (int j=0; j<4; j++) cout<<onequa[j]<<" "; + for (long const j : onequa) cout<<j<<" "; cout<<endl; } mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,onequa); @@ -323,13 +327,13 @@ MEDCoupling::MEDCouplingUMesh * MEDPARTITIONERTest::buildFACE3DMesh() for (int j=0; j<=_nj; j++) for (int i=0; i<=_ni; i++) { - int k=0; + int const k=0; coor.push_back(i+.1); coor.push_back(j+.2); coor.push_back(k+.3); } int ii; - int k=0; + int const k=0; for (int j=0; j<_nj; j++) for (int i=0; i<_ni; i++) { @@ -368,7 +372,7 @@ MEDCoupling::MEDCouplingUMesh * MEDPARTITIONERTest::buildFACE3DMesh() std::copy(conn.begin()+i*4,conn.begin()+(i+1)*4,onequa); if (false) //(_verbose) { - for (int j=0; j<4; j++) cout<<onequa[j]<<" "; + for (long const j : onequa) cout<<j<<" "; cout<<endl; } mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,onequa); @@ -398,7 +402,7 @@ MEDCouplingFieldDouble * MEDPARTITIONERTest::buildVecFieldOnCells(string myfileN } MEDCouplingUMesh *mesh=ReadUMeshFromFile(myfileName.c_str(),_mesh_name.c_str(),0); - mcIdType nbOfCells=mesh->getNumberOfCells(); + mcIdType const nbOfCells=mesh->getNumberOfCells(); MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME); f1->setName("VectorFieldOnCells"); f1->setDescription("DescriptionOfFieldOnCells"); //not saved in file? @@ -431,7 +435,7 @@ MEDCouplingFieldDouble * MEDPARTITIONERTest::buildVecFieldOnNodes() } MEDCouplingUMesh *mesh=ReadUMeshFromFile(_file_name.c_str(),_mesh_name.c_str(),0); - mcIdType nbOfNodes=mesh->getNumberOfNodes(); + mcIdType const nbOfNodes=mesh->getNumberOfNodes(); MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_NODES,ONE_TIME); f1->setName("VectorFieldOnNodes"); f1->setDescription("DescriptionOfFieldOnNodes"); //not saved in file? @@ -603,7 +607,7 @@ void MEDPARTITIONERTest::createHugeTestMesh(int ni, int nj, int nk, int nbx, int DataArrayDouble* coords=mesh->getCoords(); //int nbOfComp=coords->getNumberOfComponents(); //be 3D - mcIdType nbOfTuple=coords->getNumberOfTuples(); + mcIdType const nbOfTuple=coords->getNumberOfTuples(); double* ptr=coords->getPointer(); double* ptrini=ptrInit; for (mcIdType i=0; i<nbOfTuple; i++) @@ -690,10 +694,10 @@ void MEDPARTITIONERTest::createTestMeshWithVecFieldOnCells() //more nbptgauss=8 by default needs set MEDCouplingFieldDiscretizationPerCell //theory: (may be) http://www.code-aster.org/V2/doc/v9/fr/man_r/r3/r3.06.03.pdf - int nbptgauss=8; //nb pt de gauss by cell - mcIdType nbcell=f3->getMesh()->getNumberOfCells(); - mcIdType nb=nbcell*nbptgauss; - int nbcomp=2; + int const nbptgauss=8; //nb pt de gauss by cell + mcIdType const nbcell=f3->getMesh()->getNumberOfCells(); + mcIdType const nb=nbcell*nbptgauss; + int const nbcomp=2; array->alloc(nb,nbcomp); double *ptr=array->getPointer(); int ii=0; @@ -806,9 +810,9 @@ void MEDPARTITIONERTest::testMeshCollectionSingle() createTestMeshes(); MyGlobals::_World_Size=1; MyGlobals::_Rank=0; - string fileName=_file_name_with_faces; + string const fileName=_file_name_with_faces; MEDPARTITIONER::ParaDomainSelector parallelizer(false); - MEDPARTITIONER::MeshCollection collection(fileName,parallelizer); + MEDPARTITIONER::MeshCollection const collection(fileName,parallelizer); CPPUNIT_ASSERT(collection.isParallelMode()); CPPUNIT_ASSERT_EQUAL(3, collection.getMeshDimension()); CPPUNIT_ASSERT(collection.getName()=="testMesh"); @@ -822,9 +826,9 @@ void MEDPARTITIONERTest::testMeshCollectionXml() { setSmallSize(); createHugeTestMesh(_ni, _nj, _nk, 2, 2, 2, 32); //xml but not so huge - string fileName=_file_name_huge_xml; + string const fileName=_file_name_huge_xml; MEDPARTITIONER::ParaDomainSelector parallelizer(false); - MEDPARTITIONER::MeshCollection collection(fileName,parallelizer); + MEDPARTITIONER::MeshCollection const collection(fileName,parallelizer); CPPUNIT_ASSERT(collection.isParallelMode()); CPPUNIT_ASSERT_EQUAL(3, collection.getMeshDimension()); CPPUNIT_ASSERT(collection.getName()=="testMesh"); @@ -845,14 +849,14 @@ void MEDPARTITIONERTest::testMeshCollectionSinglePartitionMetis() setSmallSize(); createTestMeshes(); //MyGlobals::_Verbose=500; - string fileName=_file_name_with_faces; - int ndomains=2; + string const fileName=_file_name_with_faces; + int const ndomains=2; bool split_family=false; bool empty_groups=false; MEDPARTITIONER::ParaDomainSelector parallelizer(false); MEDPARTITIONER::MeshCollection collection(fileName,parallelizer); - MEDPARTITIONER::ParallelTopology* aPT = (MEDPARTITIONER::ParallelTopology*) collection.getTopology(); + auto* aPT = (MEDPARTITIONER::ParallelTopology*) collection.getTopology(); aPT->setGlobalNumerotationDefault(collection.getParaDomainSelector()); //Creating the graph and partitioning it auto_ptr< MEDPARTITIONER::Topology > new_topo; @@ -879,13 +883,13 @@ void MEDPARTITIONERTest::testMeshCollectionComplexPartitionMetis() { setSmallSize(); createHugeTestMesh(_ni, _nj, _nk, 2, 2, 2, 32); //xml on 2*2*2 meshes but not so huge - string fileName=_file_name_huge_xml; + string const fileName=_file_name_huge_xml; bool split_family=false; bool empty_groups=false; MEDPARTITIONER::ParaDomainSelector parallelizer(false); MEDPARTITIONER::MeshCollection collection(fileName,parallelizer); - MEDPARTITIONER::ParallelTopology* aPT = (MEDPARTITIONER::ParallelTopology*) collection.getTopology(); + auto* aPT = (MEDPARTITIONER::ParallelTopology*) collection.getTopology(); aPT->setGlobalNumerotationDefault(collection.getParaDomainSelector()); for (int ndomains=2 ; ndomains<=16 ; ndomains++) @@ -908,7 +912,7 @@ void MEDPARTITIONERTest::testMetisSmallSize() //#if !defined(HAVE_MPI) setSmallSize(); createTestMeshes(); - std::string MetisOrScotch("metis"); + std::string const MetisOrScotch("metis"); launchMetisOrScotchMedpartitionerOnTestMeshes(MetisOrScotch); verifyMetisOrScotchMedpartitionerOnSmallSizeForMesh(MetisOrScotch); verifyMetisOrScotchMedpartitionerOnSmallSizeForFieldOnCells(MetisOrScotch); @@ -1077,15 +1081,15 @@ void MEDPARTITIONERTest::verifyMetisOrScotchMedpartitionerOnSmallSizeForMesh(std std::vector<MEDCoupling::MEDCouplingUMesh*>cellMeshes=collection.getMesh(); CPPUNIT_ASSERT_EQUAL(5, (int) cellMeshes.size()); mcIdType nbcells=0; - for (std::size_t i = 0; i < cellMeshes.size(); i++) - nbcells+=cellMeshes[i]->getNumberOfCells(); + for (auto & cellMeshe : cellMeshes) + nbcells+=cellMeshe->getNumberOfCells(); CPPUNIT_ASSERT_EQUAL(cellMesh->getNumberOfCells(), nbcells); std::vector<MEDCoupling::MEDCouplingUMesh*>faceMeshes=collection.getFaceMesh(); CPPUNIT_ASSERT_EQUAL(5, (int) faceMeshes.size()); mcIdType nbfaces=0; - for (std::size_t i=0; i < faceMeshes.size(); i++) - nbfaces+=faceMeshes[i]->getNumberOfCells(); + for (auto & faceMeshe : faceMeshes) + nbfaces+=faceMeshe->getNumberOfCells(); CPPUNIT_ASSERT_EQUAL(faceMesh->getNumberOfCells(), nbfaces); //merge split meshes and test equality @@ -1218,8 +1222,8 @@ void MEDPARTITIONERTest::verifyMetisOrScotchMedpartitionerOnSmallSizeForFieldOnC mcIdType* pc=corr[1]->getPointer(); for (int i = 0; i < nbcells; i++) { - std::size_t i1=pc[i]*nbcomp; - std::size_t i2=i*nbcomp; + std::size_t const i1=pc[i]*nbcomp; + std::size_t const i2=i*nbcomp; for (std::size_t j = 0; j < nbcomp; j++) { if (p1[i1+j]==p2[i2+j]) nbequal++; @@ -1300,15 +1304,15 @@ void MEDPARTITIONERTest::verifyMetisOrScotchMedpartitionerOnSmallSizeForFieldOnG } int nbequal=0; - int nbptgauss=8; + int const nbptgauss=8; std::size_t nbcomp=field1->getNumberOfComponents(); double* p1=f1->getPointer(); double* p2=f2->getPointer(); mcIdType* pc=corr[1]->getPointer(); for (int i = 0; i < nbcells; i++) { - std::size_t i1=pc[i]*nbcomp*nbptgauss; - std::size_t i2=i*nbcomp*nbptgauss; + std::size_t const i1=pc[i]*nbcomp*nbptgauss; + std::size_t const i2=i*nbcomp*nbptgauss; for (std::size_t j = 0; j < nbcomp*nbptgauss; j++) { if (p1[i1+j]==p2[i2+j]) nbequal++; @@ -1420,7 +1424,7 @@ void MEDPARTITIONERTest::testCreateBoundaryFaces2D() const int ndomains = 4; ParaDomainSelector parallelizer(false); MeshCollection collection(fileName,parallelizer); - ParallelTopology* aPT = (ParallelTopology*) collection.getTopology(); + auto* aPT = (ParallelTopology*) collection.getTopology(); aPT->setGlobalNumerotationDefault(collection.getParaDomainSelector()); std::unique_ptr< Topology > new_topo; diff --git a/src/MEDPartitioner/Test/MEDPARTITIONERTest.hxx b/src/MEDPartitioner/Test/MEDPARTITIONERTest.hxx index dbec8117f..922a3f86f 100644 --- a/src/MEDPartitioner/Test/MEDPARTITIONERTest.hxx +++ b/src/MEDPartitioner/Test/MEDPARTITIONERTest.hxx @@ -20,6 +20,7 @@ #ifndef __MEDPARTITIONERTEST_HXX__ #define __MEDPARTITIONERTEST_HXX__ +#include <cppunit/TestFixture.h> #ifdef WIN32 # if defined MEDPARTITIONERTEST_EXPORTS || defined MEDPARTITIONERTest_EXPORTS # define MEDPARTITIONERTEST_EXPORT __declspec( dllexport ) @@ -33,9 +34,7 @@ #include <cppunit/extensions/HelperMacros.h> -#include <set> #include <string> -#include <iostream> #include "MEDCouplingUMesh.hxx" #include "MEDCouplingMappedExtrudedMesh.hxx" @@ -118,8 +117,8 @@ public: void deleteTestMeshes(); //for CPPUNIT_TEST - void setUp(); - void tearDown(); + void setUp() override; + void tearDown() override; void testMeshCollectionSingle(); void testMeshCollectionXml(); #if defined(MED_ENABLE_METIS) diff --git a/src/MEDPartitioner/Test/MEDPARTITIONERTestPara.cxx b/src/MEDPartitioner/Test/MEDPARTITIONERTestPara.cxx index 5649aa477..890ddc3bf 100644 --- a/src/MEDPartitioner/Test/MEDPARTITIONERTestPara.cxx +++ b/src/MEDPartitioner/Test/MEDPARTITIONERTestPara.cxx @@ -17,6 +17,9 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +#include "MCType.hxx" +#include "MCAuto.hxx" +#include "MEDCouplingRefCountObject.hxx" #include "MEDPARTITIONERTest.hxx" #include "MEDPARTITIONER_MeshCollection.hxx" @@ -24,10 +27,8 @@ #include "MEDPARTITIONER_ParaDomainSelector.hxx" #include "MEDPARTITIONER_Utils.hxx" -#include "CellModel.hxx" #include "MEDFileMesh.hxx" #include "MEDLoader.hxx" -#include "MEDLoaderBase.hxx" #include "MEDCouplingUMesh.hxx" #include "MEDCouplingMappedExtrudedMesh.hxx" #include "MEDCouplingFieldDouble.hxx" @@ -36,12 +37,11 @@ #include <cppunit/TestAssert.h> -#include <sstream> +#include <fstream> +#include <iostream> #include <cmath> -#include <list> -#include <stdexcept> #include <cstdlib> -#include <vector> +#include <string> #include <unistd.h> // get_current_dir_name() @@ -59,7 +59,7 @@ std::string MEDPARTITIONERTest::getPartitionerParaExe() const { execName=getenv("MEDCOUPLING_ROOT_DIR"); execName+="/bin/medpartitioner_para"; - std::ifstream my_file(execName.c_str()); + std::ifstream const my_file(execName.c_str()); if (my_file.good()) return execName; } @@ -92,7 +92,7 @@ void MEDPARTITIONERTest::verifyMedpartitionerOnSmallSizeForMesh() input=targetName+".xml"; MEDPARTITIONER::ParaDomainSelector parallelizer(false); - MEDPARTITIONER::MeshCollection collection(input,parallelizer); + MEDPARTITIONER::MeshCollection const collection(input,parallelizer); CPPUNIT_ASSERT_EQUAL(3, collection.getMeshDimension()); std::vector<MEDCoupling::MEDCouplingUMesh*>cellMeshes=collection.getMesh(); CPPUNIT_ASSERT_EQUAL(5, (int) cellMeshes.size()); @@ -235,8 +235,8 @@ void MEDPARTITIONERTest::verifyMedpartitionerOnSmallSizeForFieldOnCells() int* pc=corr[1]->getPointer(); for (int i = 0; i < nbcells; i++) { - int i1=pc[i]*nbcomp; - int i2=i*nbcomp; + int const i1=pc[i]*nbcomp; + int const i2=i*nbcomp; for (int j = 0; j < nbcomp; j++) { if (p1[i1+j]==p2[i2+j]) nbequal++; @@ -316,15 +316,15 @@ void MEDPARTITIONERTest::verifyMedpartitionerOnSmallSizeForFieldOnGaussNe() } int nbequal=0; - int nbptgauss=8; + int const nbptgauss=8; int nbcomp=field1->getNumberOfComponents(); double* p1=f1->getPointer(); double* p2=f2->getPointer(); int* pc=corr[1]->getPointer(); for (int i = 0; i < nbcells; i++) { - int i1=pc[i]*nbcomp*nbptgauss; - int i2=i*nbcomp*nbptgauss; + int const i1=pc[i]*nbcomp*nbptgauss; + int const i2=i*nbcomp*nbptgauss; for (int j = 0; j < nbcomp*nbptgauss; j++) { if (p1[i1+j]==p2[i2+j]) nbequal++; diff --git a/src/MEDPartitioner/Test/TestMEDPARTITIONER.cxx b/src/MEDPartitioner/Test/TestMEDPARTITIONER.cxx index ef9d8f10a..a95650853 100644 --- a/src/MEDPartitioner/Test/TestMEDPARTITIONER.cxx +++ b/src/MEDPartitioner/Test/TestMEDPARTITIONER.cxx @@ -19,6 +19,7 @@ //include all MEDPARTITIONER Test #include "MEDPARTITIONERTest.hxx" +#include <cppunit/extensions/HelperMacros.h> //Registers the fixture into the 'registry' CPPUNIT_TEST_SUITE_REGISTRATION( MEDPARTITIONERTest ); diff --git a/src/MEDPartitioner/medpartitioner.cxx b/src/MEDPartitioner/medpartitioner.cxx index 59198ebe9..36f2fbe10 100644 --- a/src/MEDPartitioner/medpartitioner.cxx +++ b/src/MEDPartitioner/medpartitioner.cxx @@ -33,16 +33,22 @@ #include "MEDPARTITIONER_Utils.hxx" */ +#include "InterpKernelException.hxx" #include "MEDPARTITIONER_MeshCollection.hxx" #include "MEDPARTITIONER_ParallelTopology.hxx" #include "MEDPARTITIONER_ParaDomainSelector.hxx" #include "MEDPARTITIONER_Utils.hxx" +#include <stdio.h> +#include <memory> +#include <cstdio> +#include <exception> #include <string> #include <fstream> #include <cstring> #include <cstdlib> #include <iostream> +#include <vector> using namespace std; using namespace MEDPARTITIONER; @@ -57,14 +63,14 @@ int main(int argc, char** argv) // Defining options // by parsing the command line - bool split_family=false; - bool empty_groups=false; + bool const split_family=false; + bool const empty_groups=false; bool mesure_memory=false; - bool filter_face=true; + bool const filter_face=true; string input; string output; - string meshname; + string const meshname; string library="metis"; //default int ndomains; int help=0; @@ -76,7 +82,7 @@ int main(int argc, char** argv) MyGlobals::_Create_Joints=0; // Primitive parsing of command-line options - string desc ("Available options of medpartitioner V1.0:\n" + string const desc ("Available options of medpartitioner V1.0:\n" "\t--help : produces this help message\n" "\t--verbose : echoes arguments\n" "\t--input-file=<string> : name of the input .med file or .xml master file\n" @@ -161,8 +167,8 @@ int main(int argc, char** argv) //testing whether it is possible to write a file at the specified location if (MyGlobals::_Rank==0) { - string outputtest = output + ".testioms."; - ofstream testfile (outputtest.c_str()); + string const outputtest = output + ".testioms."; + ofstream const testfile (outputtest.c_str()); if (testfile.fail()) { cerr << "output-file directory does not exist or is in read-only access" << endl; @@ -202,7 +208,7 @@ int main(int argc, char** argv) }*/ MEDPARTITIONER::ParaDomainSelector parallelizer(mesure_memory); MEDPARTITIONER::MeshCollection collection(input,parallelizer); - MEDPARTITIONER::ParallelTopology* aPT = (MEDPARTITIONER::ParallelTopology*) collection.getTopology(); + auto* aPT = (MEDPARTITIONER::ParallelTopology*) collection.getTopology(); aPT->setGlobalNumerotationDefault(collection.getParaDomainSelector()); //to have unique valid fields names/pointers/descriptions for partitionning collection.prepareFieldDescriptions(); @@ -237,12 +243,12 @@ int main(int argc, char** argv) r2=SelectTagsInVectorOfString(r2,"meshName="); if (r2.size()==(collection.getMesh()).size()) { - for (std::size_t i=0; i<r2.size(); i++) - r2[i]=EraseTagSerialized(r2[i],"ioldDomain="); + for (auto & i : r2) + i=EraseTagSerialized(i,"ioldDomain="); r2=DeleteDuplicatesInVectorOfString(r2); if (r2.size()==1) { - string finalMesh="finalMeshName="+ExtractFromDescription(r2[0], "meshName="); + string const finalMesh="finalMeshName="+ExtractFromDescription(r2[0], "meshName="); finalInformations.push_back(SerializeFromString(finalMesh)); } } @@ -257,11 +263,11 @@ int main(int argc, char** argv) r2=SelectTagsInVectorOfString(r1,"fieldName="); r2=SelectTagsInVectorOfString(r2,"nbComponents="); //may be yes? or not? - for (std::size_t i=0; i<r2.size(); i++) - r2[i]=EraseTagSerialized(r2[i],"ioldFieldDouble="); + for (auto & i : r2) + i=EraseTagSerialized(i,"ioldFieldDouble="); r2=DeleteDuplicatesInVectorOfString(r2); - for (std::size_t i=0; i<r2.size(); i++) - finalInformations.push_back(r2[i]); + for (const auto & i : r2) + finalInformations.push_back(i); MyGlobals::_General_Informations=finalInformations; if (MyGlobals::_Is0verbose) diff --git a/src/MEDPartitioner/medpartitioner_para.cxx b/src/MEDPartitioner/medpartitioner_para.cxx index 9874f7717..33af294b4 100644 --- a/src/MEDPartitioner/medpartitioner_para.cxx +++ b/src/MEDPartitioner/medpartitioner_para.cxx @@ -39,18 +39,10 @@ */ -#include "MEDPARTITIONER_MeshCollection.hxx" -#include "MEDPARTITIONER_ParallelTopology.hxx" -#include "MEDPARTITIONER_ParaDomainSelector.hxx" #include "MEDPARTITIONER_Utils.hxx" -#include "MEDLoader.hxx" -#include <fstream> #include <iostream> -#include <iomanip> -#include <sstream> -#include <string> #include <cstring> #ifdef HAVE_MPI @@ -60,7 +52,7 @@ using namespace std; using namespace MEDPARTITIONER; -int main(int argc, char** argv) +int main(int /*argc*/, char** /*argv*/) { #if !defined(MED_ENABLE_PARMETIS) cout << "Sorry, no one split method is available. Please, compile with ParMETIS."<<endl; diff --git a/src/ParaMEDLoader/ParaMEDFileMesh.cxx b/src/ParaMEDLoader/ParaMEDFileMesh.cxx index 67d2c8829..6e6e8e6bc 100644 --- a/src/ParaMEDLoader/ParaMEDFileMesh.cxx +++ b/src/ParaMEDLoader/ParaMEDFileMesh.cxx @@ -19,15 +19,22 @@ // Author : Anthony Geay (EDF R&D) #include "ParaMEDFileMesh.hxx" +#include "InterpKernelAutoPtr.hxx" #include "MCAuto.hxx" +#include "MCIdType.hxx" +#include "MEDCouplingMesh.hxx" +#include "MEDCouplingMemArray.hxx" +#include "MCType.hxx" +#include "MEDCouplingRefCountObject.hxx" #include "MEDFileMesh.hxx" #include "MEDFileMeshLL.hxx" -#include "MEDLoader.hxx" #include "MEDFileField1TS.hxx" #include "MEDFileUtilities.hxx" #include "MEDFileEntities.hxx" -#include <iostream> -#include <fstream> +#include "med.h" +#include "NormalizedGeometricTypes" +#include "MEDLoader.hxx" +#include <string> // From MEDLOader.cxx TU @@ -167,7 +174,7 @@ MEDFileUMesh *ParaMEDFileUMesh::ParaNew(int iPart, int nbOfParts, const MPI_Comm * Loads mesh \a mName in parallel using a custom partition of the mesh cells among the processes. * See ParaMEDFileUMesh::ParaNew for detailed description. */ -MEDFileUMesh *ParaMEDFileUMesh::NewPrivate(med_idt fid, const MPI_Comm& com, const std::map<INTERP_KERNEL::NormalizedCellType,std::vector<mcIdType>>& distrib, const std::string& fileName, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs) +MEDFileUMesh *ParaMEDFileUMesh::NewPrivate(med_idt fid, const MPI_Comm& com, const std::map<INTERP_KERNEL::NormalizedCellType,std::vector<mcIdType>>& distrib, const std::string& /*fileName*/, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs) { MCAuto<MEDFileUMesh> ret; for(std::map<INTERP_KERNEL::NormalizedCellType,std::vector<mcIdType>>::const_iterator iter=distrib.begin(); iter!= distrib.end(); iter++) diff --git a/src/ParaMEDLoader/ParaMEDFileMesh.hxx b/src/ParaMEDLoader/ParaMEDFileMesh.hxx index b65763183..10582e78a 100644 --- a/src/ParaMEDLoader/ParaMEDFileMesh.hxx +++ b/src/ParaMEDLoader/ParaMEDFileMesh.hxx @@ -26,11 +26,9 @@ #include "mpi.h" #include <string> -#include <vector> -#include <map> -#include "MCIdType.hxx" #include "MEDCouplingRefCountObject.hxx" #include "NormalizedGeometricTypes" +#include "MCIdType.hxx" namespace MEDCoupling { @@ -43,16 +41,16 @@ namespace MEDCoupling class ParaMEDFileMesh { public: - static MEDFileMesh *New(int iPart, int nbOfParts, const std::string& fileName, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0); - static MEDFileMesh *ParaNew(int iPart, int nbOfParts, const MPI_Comm& com, const MPI_Info& nfo, const std::string& fileName, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0); + static MEDFileMesh *New(int iPart, int nbOfParts, const std::string& fileName, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=nullptr); + static MEDFileMesh *ParaNew(int iPart, int nbOfParts, const MPI_Comm& com, const MPI_Info& nfo, const std::string& fileName, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=nullptr); }; class ParaMEDFileUMesh { public: - static MEDFileUMesh *New(int iPart, int nbOfParts, const std::string& fileName, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0); - static MEDFileUMesh *ParaNew(int iPart, int nbOfParts, const MPI_Comm& com, const MPI_Info& nfo, const std::string& fileName, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0); - static MEDFileUMesh *ParaNew(const std::map<INTERP_KERNEL::NormalizedCellType,std::vector<mcIdType>>&, const MPI_Comm& com, const MPI_Info& nfo, const std::string& fileName, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0); + static MEDFileUMesh *New(int iPart, int nbOfParts, const std::string& fileName, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=nullptr); + static MEDFileUMesh *ParaNew(int iPart, int nbOfParts, const MPI_Comm& com, const MPI_Info& nfo, const std::string& fileName, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=nullptr); + static MEDFileUMesh *ParaNew(const std::map<INTERP_KERNEL::NormalizedCellType,std::vector<mcIdType>>&, const MPI_Comm& com, const MPI_Info& nfo, const std::string& fileName, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=nullptr); private: static MEDFileUMesh *NewPrivate(med_idt fid, int iPart, int nbOfParts, const std::string& fileName, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs); diff --git a/src/ParaMEDLoader/ParaMEDLoader.cxx b/src/ParaMEDLoader/ParaMEDLoader.cxx index 233461126..9155b069b 100644 --- a/src/ParaMEDLoader/ParaMEDLoader.cxx +++ b/src/ParaMEDLoader/ParaMEDLoader.cxx @@ -24,21 +24,21 @@ #include "BlockTopology.hxx" #include "MEDCouplingUMesh.hxx" +#include <cstddef> #include <fstream> #include <sstream> using namespace MEDCoupling; ParaMEDLoader::ParaMEDLoader() -{ -} += default; void ParaMEDLoader::WriteParaMesh(const char *fileName, MEDCoupling::ParaMESH *mesh) { if(!mesh->getBlockTopology()->getProcGroup()->containsMyRank()) return ; - int myRank=mesh->getBlockTopology()->getProcGroup()->myRank(); - int nbDomains=mesh->getBlockTopology()->getProcGroup()->size(); + int const myRank=mesh->getBlockTopology()->getProcGroup()->myRank(); + int const nbDomains=mesh->getBlockTopology()->getProcGroup()->size(); std::vector<std::string> fileNames(nbDomains); for(int i=0;i<nbDomains;i++) { diff --git a/src/ParaMEDMEM/BlockTopology.cxx b/src/ParaMEDMEM/BlockTopology.cxx index 34051ef1e..77cd48008 100644 --- a/src/ParaMEDMEM/BlockTopology.cxx +++ b/src/ParaMEDMEM/BlockTopology.cxx @@ -18,18 +18,21 @@ // #include "BlockTopology.hxx" +#include "MCType.hxx" #include "MEDCouplingMemArray.hxx" #include "MEDCouplingCMesh.hxx" #include "CommInterface.hxx" +#include "ParaIdType.hxx" #include "ProcessorGroup.hxx" #include "MPIProcessorGroup.hxx" #include "ComponentTopology.hxx" #include "InterpKernelUtilities.hxx" -#include <vector> +#include <cstddef> #include <algorithm> #include <utility> #include <iostream> +#include <vector> using namespace std; @@ -139,8 +142,8 @@ namespace MEDCoupling */ BlockTopology::BlockTopology(const ProcessorGroup& group, mcIdType nb_elem):_dimension(1),_proc_group(&group),_owns_processor_group(false) { - mcIdType* nbelems_per_proc = new mcIdType[group.size()]; - const MPIProcessorGroup* mpi_group=dynamic_cast<const MPIProcessorGroup*>(_proc_group); + auto* nbelems_per_proc = new mcIdType[group.size()]; + const auto* mpi_group=dynamic_cast<const MPIProcessorGroup*>(_proc_group); const MPI_Comm* comm=mpi_group->getComm(); mcIdType nbtemp=nb_elem; mpi_group->getCommInterface().allGather(&nbtemp, 1, MPI_ID_TYPE, @@ -187,8 +190,8 @@ namespace MEDCoupling { int subdomain_id=0; mcIdType position=global; - mcIdType size=_nb_elems; - std::size_t size_procs=_proc_group->size(); + mcIdType const size=_nb_elems; + std::size_t const size_procs=_proc_group->size(); mcIdType increment=size; vector<mcIdType>axis_position(_dimension); vector<mcIdType>axis_offset(_dimension); @@ -197,8 +200,8 @@ namespace MEDCoupling std::size_t axis_size=_local_array_indices[idim].size()-1; mcIdType axis_nb_elem=_local_array_indices[idim][axis_size]; increment=increment/axis_nb_elem; - int proc_increment = (int)(size_procs/axis_size); - mcIdType axis_pos=position/increment; + int const proc_increment = (int)(size_procs/axis_size); + mcIdType const axis_pos=position/increment; position=position%increment; int iaxis=1; while (_local_array_indices[idim][iaxis]<=axis_pos) @@ -235,7 +238,7 @@ namespace MEDCoupling mcIdType axis_nb_elem=_local_array_indices[idim][axis_size]; increment=axis_nb_elem==0?0:increment/axis_nb_elem; proc_increment = proc_increment/axis_size; - std::size_t proc_axis=subdomain_id/proc_increment; + std::size_t const proc_axis=subdomain_id/proc_increment; subdomain_id=subdomain_id%proc_increment; mcIdType local_axis_nb_elem=_local_array_indices[idim][proc_axis+1]-_local_array_indices[idim][proc_axis]; local_increment = (local_axis_nb_elem==0)?0:(local_increment/local_axis_nb_elem); @@ -255,7 +258,7 @@ namespace MEDCoupling for (int i=_dimension-1; i>=0; i--) { increment *=_nb_procs_per_dim[i]; - int idim=position%increment; + int const idim=position%increment; position=position/increment; mcIdType imin=_local_array_indices[i][idim]; mcIdType imax=_local_array_indices[i][idim+1]; @@ -272,12 +275,12 @@ namespace MEDCoupling std::vector<std::pair<int,mcIdType> > BlockTopology::getLocalArrayMinMax() const { vector<pair<int,mcIdType> > local_indices (_dimension); - int myrank=_proc_group->myRank(); + int const myrank=_proc_group->myRank(); int increment=1; for (int i=_dimension-1; i>=0; i--) { increment *=_nb_procs_per_dim[i]; - int idim=myrank%increment; + int const idim=myrank%increment; local_indices[i].first=(int)_local_array_indices[i][idim]; local_indices[i].second=_local_array_indices[i][idim+1]; cout << local_indices[i].first << " "<< local_indices[i].second<<endl; @@ -305,7 +308,7 @@ namespace MEDCoupling //serializing the comm group mcIdType size_comm=_proc_group->size(); buffer.push_back(size_comm); - MPIProcessorGroup world_group(_proc_group->getCommInterface()); + MPIProcessorGroup const world_group(_proc_group->getCommInterface()); for (int i=0; i<size_comm;i++) { int world_rank=world_group.translateRank(_proc_group, i); @@ -340,7 +343,7 @@ namespace MEDCoupling _local_array_indices[i][j]=*(ptr_serializer++); } set<int> procs; - mcIdType size_comm=*(ptr_serializer++); + mcIdType const size_comm=*(ptr_serializer++); for (int i=0; i<size_comm; i++) procs.insert((int)*(ptr_serializer++)); diff --git a/src/ParaMEDMEM/BlockTopology.hxx b/src/ParaMEDMEM/BlockTopology.hxx index c88a1261a..7412ce3ed 100644 --- a/src/ParaMEDMEM/BlockTopology.hxx +++ b/src/ParaMEDMEM/BlockTopology.hxx @@ -20,9 +20,12 @@ #ifndef __BLOCKTOPOLOGY_HXX__ #define __BLOCKTOPOLOGY_HXX__ +#include "MCType.hxx" +#include "CommInterface.hxx" #include "Topology.hxx" #include "ProcessorGroup.hxx" +#include <utility> #include <vector> namespace MEDCoupling @@ -49,13 +52,13 @@ namespace MEDCoupling BlockTopology(const ProcessorGroup& group, MEDCouplingCMesh *grid); BlockTopology(const BlockTopology& geom_topo, const ComponentTopology& comp_topo); BlockTopology(const ProcessorGroup& group, mcIdType nb_elem); - virtual ~BlockTopology(); + ~BlockTopology() override; void release(); //!Retrieves the number of elements for a given topology - mcIdType getNbElements()const { return _nb_elems; } - mcIdType getNbLocalElements() const; - const ProcessorGroup* getProcGroup()const { return _proc_group; } + mcIdType getNbElements()const override { return _nb_elems; } + mcIdType getNbLocalElements() const override; + const ProcessorGroup* getProcGroup()const override { return _proc_group; } std::pair<int,mcIdType> globalToLocal (const mcIdType) const ; mcIdType localToGlobal (const std::pair<int,mcIdType>) const; std::vector<std::pair<int,mcIdType> > getLocalArrayMinMax() const ; diff --git a/src/ParaMEDMEM/ByStringMPIProcessorGroup.cxx b/src/ParaMEDMEM/ByStringMPIProcessorGroup.cxx index 49f39e8a0..fffb5e134 100644 --- a/src/ParaMEDMEM/ByStringMPIProcessorGroup.cxx +++ b/src/ParaMEDMEM/ByStringMPIProcessorGroup.cxx @@ -19,9 +19,9 @@ #include "ByStringMPIProcessorGroup.hxx" -#include <iostream> -#include <set> -#include <algorithm> +#include <cstddef> +#include <string> +#include "MPIProcessorGroup.hxx" #include "mpi.h" using namespace std; @@ -106,8 +106,7 @@ namespace MEDCoupling } ByStringMPIProcessorGroup::~ByStringMPIProcessorGroup() - { - } + = default; ByStringMPIProcessorGroup *ByStringMPIProcessorGroup::deepCopy() const { diff --git a/src/ParaMEDMEM/ByStringMPIProcessorGroup.hxx b/src/ParaMEDMEM/ByStringMPIProcessorGroup.hxx index 21bf13fdb..5e90bbd38 100644 --- a/src/ParaMEDMEM/ByStringMPIProcessorGroup.hxx +++ b/src/ParaMEDMEM/ByStringMPIProcessorGroup.hxx @@ -21,6 +21,7 @@ #define __BYSTRINGMPIPROCESSORGROUP_HXX__ #include "MPIProcessorGroup.hxx" +#include <string> namespace MEDCoupling { @@ -32,8 +33,8 @@ namespace MEDCoupling ByStringMPIProcessorGroup(const CommInterface& interface); ByStringMPIProcessorGroup(const CommInterface& interface, const std::string& simCodeTag, const MPI_Comm& world_comm=MPI_COMM_WORLD); ByStringMPIProcessorGroup(const ByStringMPIProcessorGroup& other); - virtual ~ByStringMPIProcessorGroup(); - virtual ByStringMPIProcessorGroup *deepCopy() const; + ~ByStringMPIProcessorGroup() override; + ByStringMPIProcessorGroup *deepCopy() const override; }; } diff --git a/src/ParaMEDMEM/CommInterface.cxx b/src/ParaMEDMEM/CommInterface.cxx index 04e3e8d42..caadf1b00 100644 --- a/src/ParaMEDMEM/CommInterface.cxx +++ b/src/ParaMEDMEM/CommInterface.cxx @@ -18,6 +18,9 @@ // #include "CommInterface.hxx" +#include "MCType.hxx" +#include "MCAuto.hxx" +#include "MEDCouplingMemArray.hxx" namespace MEDCoupling { diff --git a/src/ParaMEDMEM/CommInterface.hxx b/src/ParaMEDMEM/CommInterface.hxx index 3d52fe9a5..2c34eaf41 100644 --- a/src/ParaMEDMEM/CommInterface.hxx +++ b/src/ParaMEDMEM/CommInterface.hxx @@ -19,13 +19,18 @@ #pragma once +#include "MCType.hxx" +#include "MCAuto.hxx" +#include "MEDCouplingTraits.hxx" #include "ParaIdType.hxx" #include "MEDCouplingMemArray.hxx" +#include <limits> +#include <cstddef> #include <mpi.h> -#include <memory> #include <numeric> +#include <memory> namespace MEDCoupling { @@ -90,8 +95,8 @@ namespace MEDCoupling class CommInterface { public: - CommInterface() { } - virtual ~CommInterface() { } + CommInterface() = default; + virtual ~CommInterface() = default; int worldSize() const { int size; MPI_Comm_size(MPI_COMM_WORLD, &size); diff --git a/src/ParaMEDMEM/ComponentTopology.cxx b/src/ParaMEDMEM/ComponentTopology.cxx index b6895f7bb..53c55410f 100644 --- a/src/ParaMEDMEM/ComponentTopology.cxx +++ b/src/ParaMEDMEM/ComponentTopology.cxx @@ -19,7 +19,6 @@ #include "ComponentTopology.hxx" #include "ProcessorGroup.hxx" -#include "InterpolationUtils.hxx" namespace MEDCoupling { @@ -28,7 +27,7 @@ namespace MEDCoupling */ ComponentTopology::ComponentTopology(int nb_comp, ProcessorGroup* group):_proc_group(group) { - int nb_blocks=group->size(); + int const nb_blocks=group->size(); if (nb_blocks>nb_comp) throw INTERP_KERNEL::Exception("ComponentTopology Number of components must be larger than number of blocks"); @@ -46,7 +45,7 @@ namespace MEDCoupling /* Generic constructor for \a nb_comp components equally parted * in \a nb_blocks blocks */ - ComponentTopology::ComponentTopology(int nb_comp, int nb_blocks):_proc_group(0) + ComponentTopology::ComponentTopology(int nb_comp, int nb_blocks):_proc_group(nullptr) { if (nb_blocks>nb_comp) throw INTERP_KERNEL::Exception("ComponentTopology Number of components must be larger than number of blocks"); @@ -63,7 +62,7 @@ namespace MEDCoupling } //!Constructor for one block of \a nb_comp components - ComponentTopology::ComponentTopology(int nb_comp):_proc_group(0) + ComponentTopology::ComponentTopology(int nb_comp):_proc_group(nullptr) { _component_array.resize(2); @@ -73,7 +72,7 @@ namespace MEDCoupling } //! Constructor for one component - ComponentTopology::ComponentTopology():_proc_group(0) + ComponentTopology::ComponentTopology():_proc_group(nullptr) { _component_array.resize(2); _component_array[0]=0; @@ -82,16 +81,15 @@ namespace MEDCoupling } ComponentTopology::~ComponentTopology() - { - } + = default; int ComponentTopology::nbLocalComponents() const { - if (_proc_group==0) + if (_proc_group==nullptr) return nbComponents(); int nbcomp; - int myrank = _proc_group->myRank(); + int const myrank = _proc_group->myRank(); if (myrank!=-1) nbcomp = _component_array[myrank+1]-_component_array[myrank]; else @@ -101,11 +99,11 @@ namespace MEDCoupling int ComponentTopology::firstLocalComponent() const { - if (_proc_group==0) + if (_proc_group==nullptr) return 0; int icomp; - int myrank = _proc_group->myRank(); + int const myrank = _proc_group->myRank(); if (myrank!=-1) icomp = _component_array[myrank]; else diff --git a/src/ParaMEDMEM/DEC.cxx b/src/ParaMEDMEM/DEC.cxx index 1a6a4d615..caf3b916b 100644 --- a/src/ParaMEDMEM/DEC.cxx +++ b/src/ParaMEDMEM/DEC.cxx @@ -17,21 +17,13 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -#include "CommInterface.hxx" -#include "Topology.hxx" -#include "BlockTopology.hxx" -#include "ComponentTopology.hxx" -#include "ParaFIELD.hxx" -#include "ParaMESH.hxx" #include "DEC.hxx" -#include "ICoCoMEDDoubleField.hxx" -#include "MPIProcessorGroup.hxx" #include <cmath> namespace MEDCoupling { - DEC::DEC():_comm_interface(0) + DEC::DEC():_comm_interface(nullptr) { } @@ -41,6 +33,5 @@ namespace MEDCoupling } DEC::~DEC() - { - } + = default; } diff --git a/src/ParaMEDMEM/DEC.hxx b/src/ParaMEDMEM/DEC.hxx index 672223bc0..2a00bb7f5 100644 --- a/src/ParaMEDMEM/DEC.hxx +++ b/src/ParaMEDMEM/DEC.hxx @@ -20,8 +20,6 @@ #ifndef __DEC_HXX__ #define __DEC_HXX__ -#include "MEDCouplingFieldDouble.hxx" -#include "NormalizedUnstructuredMesh.hxx" #include "DECOptions.hxx" namespace MEDCoupling diff --git a/src/ParaMEDMEM/DECOptions.hxx b/src/ParaMEDMEM/DECOptions.hxx index e83afd8be..7c2ff78d4 100644 --- a/src/ParaMEDMEM/DECOptions.hxx +++ b/src/ParaMEDMEM/DECOptions.hxx @@ -51,16 +51,13 @@ namespace MEDCoupling { protected: std::string _method; - bool _asynchronous; - TimeInterpolationMethod _timeInterpolationMethod; - AllToAllMethod _allToAllMethod; - bool _forcedRenormalization; + bool _asynchronous{false}; + TimeInterpolationMethod _timeInterpolationMethod{WithoutTimeInterp}; + AllToAllMethod _allToAllMethod{Native}; + bool _forcedRenormalization{false}; public: - DECOptions():_method("P0"), - _asynchronous(false), - _timeInterpolationMethod(WithoutTimeInterp), - _allToAllMethod(Native), - _forcedRenormalization(false) + DECOptions():_method("P0") + { } diff --git a/src/ParaMEDMEM/DisjointDEC.cxx b/src/ParaMEDMEM/DisjointDEC.cxx index b213300bb..1fab3ca21 100644 --- a/src/ParaMEDMEM/DisjointDEC.cxx +++ b/src/ParaMEDMEM/DisjointDEC.cxx @@ -19,26 +19,28 @@ #include "DisjointDEC.hxx" #include "CommInterface.hxx" +#include "DEC.hxx" +#include "MEDCouplingNatureOfFieldEnum" +#include "MEDCouplingPointSet.hxx" +#include "MEDCouplingMesh.hxx" +#include "MEDCouplingRefCountObject.hxx" #include "Topology.hxx" -#include "BlockTopology.hxx" #include "ComponentTopology.hxx" #include "ParaFIELD.hxx" #include "ParaMESH.hxx" -#include "ICoCoField.hxx" #include "ICoCoMEDDoubleField.hxx" #include "MPIProcessorGroup.hxx" #include <cmath> -#include <iostream> namespace MEDCoupling { DisjointDEC::DisjointDEC(ProcessorGroup& source_group, ProcessorGroup& target_group): - _local_field(0), + _local_field(nullptr), _source_group(&source_group), _target_group(&target_group), - _comm_interface(0), + _comm_interface(nullptr), _owns_field(false), _owns_groups(false), _union_comm(MPI_COMM_NULL) @@ -49,11 +51,11 @@ namespace MEDCoupling DisjointDEC::DisjointDEC(const DisjointDEC& s): DEC(s), - _local_field(0), - _union_group(0), - _source_group(0), - _target_group(0), - _comm_interface(0), + _local_field(nullptr), + _union_group(nullptr), + _source_group(nullptr), + _target_group(nullptr), + _comm_interface(nullptr), _owns_field(false), _owns_groups(false), _union_comm(MPI_COMM_NULL) @@ -102,13 +104,13 @@ namespace MEDCoupling DisjointDEC::DisjointDEC(const std::set<int>& source_ids, const std::set<int>& target_ids, const MPI_Comm& world_comm): - _local_field(0), - _comm_interface(0), + _local_field(nullptr), + _comm_interface(nullptr), _owns_field(false), _owns_groups(true), _union_comm(MPI_COMM_NULL) { - MEDCoupling::CommInterface comm; + MEDCoupling::CommInterface const comm; // Create the list of procs including source and target std::set<int> union_ids; // source and target ids in world_comm union_ids.insert(source_ids.begin(),source_ids.end()); @@ -126,9 +128,9 @@ namespace MEDCoupling delete[] union_ranks_world; if (_union_comm==MPI_COMM_NULL) { // This process is not in union - _source_group=0; - _target_group=0; - _union_group=0; + _source_group=nullptr; + _target_group=nullptr; + _union_group=nullptr; comm.groupFree(&union_group); comm.groupFree(&world_group); return; @@ -197,8 +199,8 @@ namespace MEDCoupling void DisjointDEC::checkPartitionGroup() const { int size = -1; - MPIProcessorGroup * tgt = static_cast<MPIProcessorGroup *>(_target_group); - MPIProcessorGroup * src = static_cast<MPIProcessorGroup *>(_source_group); + auto * tgt = static_cast<MPIProcessorGroup *>(_target_group); + auto * src = static_cast<MPIProcessorGroup *>(_source_group); MPI_Comm comm_t = tgt->getWorldComm(); MPI_Comm comm_s = src->getWorldComm(); if (comm_t != comm_s) @@ -256,8 +258,8 @@ namespace MEDCoupling local_group=_target_group; else throw INTERP_KERNEL::Exception("Invalid procgroup for field attachment to DEC"); - ParaMESH *paramesh=new ParaMESH(static_cast<MEDCouplingPointSet *>(const_cast<MEDCouplingMesh *>(field->getMesh())),*local_group,field->getMesh()->getName()); - ParaFIELD *tmp=new ParaFIELD(field, paramesh, *local_group); + auto *paramesh=new ParaMESH(static_cast<MEDCouplingPointSet *>(const_cast<MEDCouplingMesh *>(field->getMesh())),*local_group,field->getMesh()->getName()); + auto *tmp=new ParaFIELD(field, paramesh, *local_group); tmp->setOwnSupport(true); attachLocalField(tmp,true); //_comm_interface=&(local_group->getCommInterface()); @@ -304,7 +306,7 @@ namespace MEDCoupling if (_source_group->containsMyRank()) for (int icomp=0; icomp<(int)_local_field->getField()->getArray()->getNumberOfComponents(); icomp++) { - double total_norm = _local_field->getVolumeIntegral(icomp+1,isWAbs); + double const total_norm = _local_field->getVolumeIntegral(icomp+1,isWAbs); double source_norm = total_norm; _comm_interface->broadcast(&source_norm, 1, MPI_DOUBLE, 0,* dynamic_cast<MPIProcessorGroup*>(_union_group)->getComm()); @@ -313,7 +315,7 @@ namespace MEDCoupling { for (int icomp=0; icomp<(int)_local_field->getField()->getArray()->getNumberOfComponents(); icomp++) { - double total_norm = _local_field->getVolumeIntegral(icomp+1,isWAbs); + double const total_norm = _local_field->getVolumeIntegral(icomp+1,isWAbs); double source_norm=total_norm; _comm_interface->broadcast(&source_norm, 1, MPI_DOUBLE, 0,* dynamic_cast<MPIProcessorGroup*>(_union_group)->getComm()); @@ -348,7 +350,7 @@ namespace MEDCoupling { if (_local_field) { - TypeOfField entity = _local_field->getField()->getTypeOfField(); + TypeOfField const entity = _local_field->getField()->getTypeOfField(); if ( getMethod() == "P0" ) { if ( entity != ON_CELLS ) diff --git a/src/ParaMEDMEM/DisjointDEC.hxx b/src/ParaMEDMEM/DisjointDEC.hxx index dc53b31b5..c44dd2868 100644 --- a/src/ParaMEDMEM/DisjointDEC.hxx +++ b/src/ParaMEDMEM/DisjointDEC.hxx @@ -21,7 +21,7 @@ #define __DISJOINTDEC_HXX__ #include "MEDCouplingFieldDouble.hxx" -#include "NormalizedUnstructuredMesh.hxx" +#include "MEDCouplingNatureOfFieldEnum" #include "DEC.hxx" #include <mpi.h> @@ -69,8 +69,8 @@ namespace MEDCoupling class DisjointDEC : public DEC { public: - DisjointDEC():_local_field(0),_union_group(0),_source_group(0),_target_group(0), - _comm_interface(0), + DisjointDEC():_local_field(nullptr),_union_group(nullptr),_source_group(nullptr),_target_group(nullptr), + _comm_interface(nullptr), _owns_field(false),_owns_groups(false), _union_comm(MPI_COMM_NULL) { } @@ -79,7 +79,7 @@ namespace MEDCoupling DisjointDEC &operator=(const DisjointDEC& s); DisjointDEC(const std::set<int>& src_ids, const std::set<int>& trg_ids, const MPI_Comm& world_comm=MPI_COMM_WORLD); - virtual ~DisjointDEC(); + ~DisjointDEC() override; void setNature(NatureOfField nature); void attachLocalField( MEDCouplingFieldDouble *field); @@ -90,8 +90,8 @@ namespace MEDCoupling virtual void prepareTargetDE() = 0; virtual void recvData() = 0; virtual void sendData() = 0; - void sendRecvData(bool way=true); - virtual void synchronize() = 0; + void sendRecvData(bool way=true) override; + void synchronize() override = 0; virtual void computeProcGroup() { } void renormalizeTargetField(bool isWAbs); diff --git a/src/ParaMEDMEM/ElementLocator.cxx b/src/ParaMEDMEM/ElementLocator.cxx index cc2a90cd6..408e2d5a7 100644 --- a/src/ParaMEDMEM/ElementLocator.cxx +++ b/src/ParaMEDMEM/ElementLocator.cxx @@ -17,22 +17,27 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +#include <cstddef> #include <mpi.h> #include "CommInterface.hxx" #include "ElementLocator.hxx" +#include "MEDCouplingFieldDouble.hxx" +#include "MEDCouplingNatureOfFieldEnum" +#include "MCType.hxx" +#include "ParaIdType.hxx" +#include "MEDCouplingMemArray.hxx" #include "Topology.hxx" -#include "BlockTopology.hxx" #include "ParaFIELD.hxx" #include "ParaMESH.hxx" #include "ProcessorGroup.hxx" #include "MPIProcessorGroup.hxx" -#include "MEDCouplingFieldDouble.hxx" #include "MCAuto.hxx" -#include "DirectedBoundingBox.hxx" -#include <map> -#include <set> #include <limits> +#include <string> +#include <vector> +#include <set> +#include <map> using namespace std; @@ -62,7 +67,7 @@ namespace MEDCoupling const MPI_Comm *ElementLocator::getCommunicator() const { - MPIProcessorGroup* group=static_cast<MPIProcessorGroup*> (_union_group); + auto* group=static_cast<MPIProcessorGroup*> (_union_group); return group->getComm(); } @@ -83,7 +88,7 @@ namespace MEDCoupling MEDCouplingPointSet*& distant_mesh, mcIdType*& distant_ids) { - int rank = _union_group->translateRank(&_distant_group,idistantrank); + int const rank = _union_group->translateRank(&_distant_group,idistantrank); if (find(_distant_proc_ids.begin(), _distant_proc_ids.end(),rank)==_distant_proc_ids.end()) return; @@ -100,7 +105,7 @@ namespace MEDCoupling #endif DataArrayIdType *distant_ids_send; - MEDCouplingPointSet *send_mesh = (MEDCouplingPointSet *)_local_para_field.getField()->buildSubMeshData(elems->begin(),elems->end(),distant_ids_send); + auto *send_mesh = (MEDCouplingPointSet *)_local_para_field.getField()->buildSubMeshData(elems->begin(),elems->end(),distant_ids_send); _exchangeMesh(send_mesh, distant_mesh, idistantrank, distant_ids_send, distant_ids); distant_ids_send->decrRef(); @@ -111,11 +116,11 @@ namespace MEDCoupling void ElementLocator::exchangeMethod(const std::string& sourceMeth, int idistantrank, std::string& targetMeth) { CommInterface comm_interface=_union_group->getCommInterface(); - MPIProcessorGroup* group=static_cast<MPIProcessorGroup*> (_union_group); + auto* group=static_cast<MPIProcessorGroup*> (_union_group); const MPI_Comm* comm=(group->getComm()); MPI_Status status; // it must be converted to union numbering before communication - int idistRankInUnion = group->translateRank(&_distant_group,idistantrank); + int const idistRankInUnion = group->translateRank(&_distant_group,idistantrank); char *recv_buffer=new char[4]; std::vector<char> send_buffer(4); std::copy(sourceMeth.begin(),sourceMeth.end(),send_buffer.begin()); @@ -133,8 +138,8 @@ namespace MEDCoupling */ void ElementLocator::_computeBoundingBoxes() { - CommInterface comm_interface =_union_group->getCommInterface(); - MPIProcessorGroup* group=static_cast<MPIProcessorGroup*> (_union_group); + CommInterface const comm_interface =_union_group->getCommInterface(); + auto* group=static_cast<MPIProcessorGroup*> (_union_group); const MPI_Comm* comm = group->getComm(); _local_cell_mesh_space_dim = -1; if(_local_cell_mesh->getMeshDimension() != -1) @@ -161,9 +166,9 @@ namespace MEDCoupling if ( dbbData.size() < bbSize ) dbbData.resize(bbSize,0); double * minmax= &dbbData[0]; #else - int bbSize = 2*_local_cell_mesh_space_dim; + int const bbSize = 2*_local_cell_mesh_space_dim; _domain_bounding_boxes = new double[bbSize*_union_group->size()]; - double * minmax=new double [bbSize]; + auto * minmax=new double [bbSize]; if(_local_cell_mesh->getMeshDimension() != -1) _local_cell_mesh->getBoundingBox(minmax); else @@ -180,7 +185,7 @@ namespace MEDCoupling for (int i=0; i< _distant_group.size(); i++) { - int rank=_union_group->translateRank(&_distant_group,i); + int const rank=_union_group->translateRank(&_distant_group,i); if (_intersectsBoundingBox(rank)) { @@ -212,7 +217,7 @@ namespace MEDCoupling const double eps = 1e-12; for (int idim=0; idim < _local_cell_mesh_space_dim; idim++) { - bool intersects = (distant_bb[idim*2]<local_bb[idim*2+1]+eps) + bool const intersects = (distant_bb[idim*2]<local_bb[idim*2+1]+eps) && (local_bb[idim*2]<distant_bb[idim*2+1]+eps); if (!intersects) return false; } @@ -243,20 +248,20 @@ namespace MEDCoupling tinyInfoLocal.push_back(distant_ids_send->getNumberOfTuples()); tinyInfoDistant.resize(tinyInfoLocal.size()); std::fill(tinyInfoDistant.begin(),tinyInfoDistant.end(),0); - MPIProcessorGroup* group=static_cast<MPIProcessorGroup*> (_union_group); + auto* group=static_cast<MPIProcessorGroup*> (_union_group); const MPI_Comm* comm=group->getComm(); MPI_Status status; // iproc_distant is the number of proc in distant group // it must be converted to union numbering before communication - int iprocdistant_in_union = group->translateRank(&_distant_group, + int const iprocdistant_in_union = group->translateRank(&_distant_group, iproc_distant); comm_interface.sendRecv(&tinyInfoLocal[0], (int)tinyInfoLocal.size(), MPI_ID_TYPE, iprocdistant_in_union, 1112, &tinyInfoDistant[0], (int)tinyInfoDistant.size(), MPI_ID_TYPE,iprocdistant_in_union,1112, *comm, &status); - DataArrayIdType *v1Local=0; - DataArrayDouble *v2Local=0; + DataArrayIdType *v1Local=nullptr; + DataArrayDouble *v2Local=nullptr; DataArrayIdType *v1Distant=DataArrayIdType::New(); DataArrayDouble *v2Distant=DataArrayDouble::New(); //serialization of local mesh to send data to distant proc. @@ -331,7 +336,7 @@ namespace MEDCoupling { policy.resize(_distant_proc_ids.size()); int procId=0; - CommInterface comm; + CommInterface const comm; MPI_Status status; for(vector<int>::const_iterator iter=_distant_proc_ids.begin();iter!=_distant_proc_ids.end();iter++,procId++) { @@ -347,7 +352,7 @@ namespace MEDCoupling void ElementLocator::sendSumToLazySideW(const std::vector< std::vector<mcIdType> >& distantLocEltIds, const std::vector< std::vector<double> >& partialSumRelToDistantIds) { int procId=0; - CommInterface comm; + CommInterface const comm; for(vector<int>::const_iterator iter=_distant_proc_ids.begin();iter!=_distant_proc_ids.end();iter++,procId++) { const vector<mcIdType>& eltIds=distantLocEltIds[procId]; @@ -365,7 +370,7 @@ namespace MEDCoupling void ElementLocator::recvSumFromLazySideW(std::vector< std::vector<double> >& globalSumRelToDistantIds) { int procId=0; - CommInterface comm; + CommInterface const comm; MPI_Status status; for(vector<int>::const_iterator iter=_distant_proc_ids.begin();iter!=_distant_proc_ids.end();iter++,procId++) { @@ -380,7 +385,7 @@ namespace MEDCoupling void ElementLocator::sendLocalIdsToLazyProcsW(const std::vector< std::vector<mcIdType> >& distantLocEltIds) { int procId=0; - CommInterface comm; + CommInterface const comm; for(vector<int>::const_iterator iter=_distant_proc_ids.begin();iter!=_distant_proc_ids.end();iter++,procId++) { const vector<mcIdType>& eltIds=distantLocEltIds[procId]; @@ -396,7 +401,7 @@ namespace MEDCoupling void ElementLocator::recvGlobalIdsFromLazyProcsW(const std::vector< std::vector<mcIdType> >& distantLocEltIds, std::vector< std::vector<mcIdType> >& globalIds) { int procId=0; - CommInterface comm; + CommInterface const comm; MPI_Status status; globalIds.resize(_distant_proc_ids.size()); for(vector<int>::const_iterator iter=_distant_proc_ids.begin();iter!=_distant_proc_ids.end();iter++,procId++) @@ -414,7 +419,7 @@ namespace MEDCoupling void ElementLocator::recvCandidatesGlobalIdsFromLazyProcsW(std::vector< std::vector<mcIdType> >& globalIds) { int procId=0; - CommInterface comm; + CommInterface const comm; MPI_Status status; globalIds.resize(_distant_proc_ids.size()); for(vector<int>::const_iterator iter=_distant_proc_ids.begin();iter!=_distant_proc_ids.end();iter++,procId++) @@ -433,7 +438,7 @@ namespace MEDCoupling void ElementLocator::sendPartialSumToLazyProcsW(const std::vector<mcIdType>& distantGlobIds, const std::vector<double>& sum) { int procId=0; - CommInterface comm; + CommInterface const comm; int lgth=(int)distantGlobIds.size(); for(vector<int>::const_iterator iter=_distant_proc_ids.begin();iter!=_distant_proc_ids.end();iter++,procId++) { @@ -449,7 +454,7 @@ namespace MEDCoupling void ElementLocator::sendCandidatesForAddElementsW(const std::vector<mcIdType>& distantGlobIds) { int procId=0; - CommInterface comm; + CommInterface const comm; int lgth=(int)distantGlobIds.size(); for(vector<int>::const_iterator iter=_distant_proc_ids.begin();iter!=_distant_proc_ids.end();iter++,procId++) { @@ -464,7 +469,7 @@ namespace MEDCoupling void ElementLocator::recvAddElementsFromLazyProcsW(std::vector<std::vector<mcIdType> >& elementsToAdd) { int procId=0; - CommInterface comm; + CommInterface const comm; MPI_Status status; int lgth=(int)_distant_proc_ids.size(); elementsToAdd.resize(lgth); @@ -483,7 +488,7 @@ namespace MEDCoupling */ int ElementLocator::sendPolicyToWorkingSideL() { - CommInterface comm; + CommInterface const comm; int toSend; DataArrayIdType *isCumulative=_local_para_field.returnCumulativeGlobalNumbering(); if(isCumulative) @@ -505,7 +510,7 @@ namespace MEDCoupling { _values_added.resize(_local_para_field.getField()->getNumberOfTuples()); int procId=0; - CommInterface comm; + CommInterface const comm; _ids_per_working_proc.resize(_distant_proc_ids.size()); MPI_Status status; for(vector<int>::const_iterator iter=_distant_proc_ids.begin();iter!=_distant_proc_ids.end();iter++,procId++) @@ -528,7 +533,7 @@ namespace MEDCoupling void ElementLocator::sendToWorkingSideL() { int procId=0; - CommInterface comm; + CommInterface const comm; for(vector<int>::const_iterator iter=_distant_proc_ids.begin();iter!=_distant_proc_ids.end();iter++,procId++) { vector<mcIdType>& ids=_ids_per_working_proc[procId]; @@ -548,7 +553,7 @@ namespace MEDCoupling void ElementLocator::recvLocalIdsFromWorkingSideL() { int procId=0; - CommInterface comm; + CommInterface const comm; _ids_per_working_proc.resize(_distant_proc_ids.size()); MPI_Status status; for(vector<int>::const_iterator iter=_distant_proc_ids.begin();iter!=_distant_proc_ids.end();iter++,procId++) @@ -567,7 +572,7 @@ namespace MEDCoupling void ElementLocator::sendGlobalIdsToWorkingSideL() { int procId=0; - CommInterface comm; + CommInterface const comm; DataArrayIdType *globalIds=_local_para_field.returnGlobalNumbering(); const mcIdType *globalIdsC=globalIds->getConstPointer(); for(vector<int>::const_iterator iter=_distant_proc_ids.begin();iter!=_distant_proc_ids.end();iter++,procId++) @@ -590,7 +595,7 @@ namespace MEDCoupling { std::size_t procId=0; std::size_t wProcSize=_distant_proc_ids.size(); - CommInterface comm; + CommInterface const comm; _ids_per_working_proc.resize(wProcSize); _values_per_working_proc.resize(wProcSize); MPI_Status status; @@ -635,7 +640,7 @@ namespace MEDCoupling { std::size_t procId=0; std::size_t wProcSize=_distant_proc_ids.size(); - CommInterface comm; + CommInterface const comm; _ids_per_working_proc3.resize(wProcSize); MPI_Status status; std::map<int,double> sums; @@ -676,7 +681,7 @@ namespace MEDCoupling void ElementLocator::sendAddElementsToWorkingSideL() { int procId=0; - CommInterface comm; + CommInterface const comm; for(vector<int>::const_iterator iter=_distant_proc_ids.begin();iter!=_distant_proc_ids.end();iter++,procId++) { const std::vector<mcIdType>& vals=_ids_per_working_proc3[procId]; @@ -693,7 +698,7 @@ namespace MEDCoupling void ElementLocator::sendCandidatesGlobalIdsToWorkingSideL() { int procId=0; - CommInterface comm; + CommInterface const comm; DataArrayIdType *globalIds=_local_para_field.returnGlobalNumbering(); const mcIdType *globalIdsC=globalIds->getConstPointer(); MCAuto<DataArrayIdType> candidates=_local_para_field.getSupport()->getCellMesh()->findBoundaryNodes(); diff --git a/src/ParaMEDMEM/ElementLocator.hxx b/src/ParaMEDMEM/ElementLocator.hxx index 7d7c69820..0ef39fc62 100644 --- a/src/ParaMEDMEM/ElementLocator.hxx +++ b/src/ParaMEDMEM/ElementLocator.hxx @@ -20,13 +20,14 @@ #ifndef __ELEMENTLOCATOR_HXX__ #define __ELEMENTLOCATOR_HXX__ -#include "InterpolationOptions.hxx" -#include "MEDCouplingNatureOfField.hxx" -#include "MCType.hxx" - #include <mpi.h> + +#include <string> #include <vector> -#include <set> + +#include "InterpolationOptions.hxx" +#include "MCType.hxx" +#include "MEDCouplingNatureOfFieldEnum" namespace MEDCoupling { @@ -49,7 +50,10 @@ namespace MEDCoupling MEDCouplingPointSet*& target_mesh, mcIdType*& distant_ids); void exchangeMethod(const std::string& sourceMeth, int idistantrank, std::string& targetMeth); - const std::vector<int>& getDistantProcIds() const { return _distant_proc_ids; } + const std::vector<int> &getDistantProcIds() const + { + return _distant_proc_ids; + } const MPI_Comm *getCommunicator() const; NatureOfField getLocalNature() const; //! This method is used to informed if there is -1D mesh on distant_group side or on local_group side. @@ -89,8 +93,8 @@ namespace MEDCoupling int _local_cell_mesh_space_dim; bool _is_m1d_corr; MEDCouplingPointSet* _local_face_mesh; - std::vector<MEDCouplingPointSet*> _distant_cell_meshes; - std::vector<MEDCouplingPointSet*> _distant_face_meshes; + std::vector<MEDCouplingPointSet *> _distant_cell_meshes; + std::vector<MEDCouplingPointSet *> _distant_face_meshes; double* _domain_bounding_boxes; const ProcessorGroup& _distant_group; const ProcessorGroup& _local_group; @@ -99,10 +103,11 @@ namespace MEDCoupling const MPI_Comm *_comm; //Attributes only used by lazy side std::vector<double> _values_added; - std::vector< std::vector<mcIdType> > _ids_per_working_proc; - std::vector< std::vector<mcIdType> > _ids_per_working_proc3; - std::vector< std::vector<double> > _values_per_working_proc; - public: + std::vector<std::vector<mcIdType> > _ids_per_working_proc; + std::vector<std::vector<mcIdType> > _ids_per_working_proc3; + std::vector<std::vector<double> > _values_per_working_proc; + + public: static const int CUMULATIVE_POLICY=3; static const int NO_POST_TREATMENT_POLICY=7; }; diff --git a/src/ParaMEDMEM/ExplicitCoincidentDEC.cxx b/src/ParaMEDMEM/ExplicitCoincidentDEC.cxx index 6dbed42cb..841c76119 100644 --- a/src/ParaMEDMEM/ExplicitCoincidentDEC.cxx +++ b/src/ParaMEDMEM/ExplicitCoincidentDEC.cxx @@ -17,15 +17,20 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +#include <cstddef> +#include <iostream> #include <mpi.h> +#include <utility> #include "CommInterface.hxx" +#include "ExplicitTopology.hxx" +#include "MCType.hxx" +#include "ParaIdType.hxx" +#include "MEDCouplingRefCountObject.hxx" #include "Topology.hxx" -#include "BlockTopology.hxx" #include "ComponentTopology.hxx" #include "ParaFIELD.hxx" #include "MPIProcessorGroup.hxx" #include "ExplicitCoincidentDEC.hxx" -#include "ExplicitMapping.hxx" #include "InterpKernelUtilities.hxx" using namespace std; @@ -89,18 +94,17 @@ namespace MEDCoupling /*! Constructor */ ExplicitCoincidentDEC::ExplicitCoincidentDEC(): - _toposource(0),_topotarget(0), - _targetgroup(0), _sourcegroup(0), - _sendcounts(0), _recvcounts(0), - _senddispls(0), _recvdispls(0), - _recvbuffer(0), _sendbuffer(0), + _toposource(nullptr),_topotarget(nullptr), + _targetgroup(nullptr), _sourcegroup(nullptr), + _sendcounts(nullptr), _recvcounts(nullptr), + _senddispls(nullptr), _recvdispls(nullptr), + _recvbuffer(nullptr), _sendbuffer(nullptr), _distant_elems(), _explicit_mapping() { } ExplicitCoincidentDEC::~ExplicitCoincidentDEC() - { - } + = default; /*! Synchronization process for exchanging topologies */ @@ -137,15 +141,15 @@ namespace MEDCoupling if (!_toposource->getProcGroup()->containsMyRank()) return; - MPIProcessorGroup* group=new MPIProcessorGroup(_sourcegroup->getCommInterface()); + auto* group=new MPIProcessorGroup(_sourcegroup->getCommInterface()); // Warning : the size of the target side is implicitly deduced //from the size of MPI_COMM_WORLD - int target_size = _toposource->getProcGroup()->getCommInterface().worldSize()- _toposource->getProcGroup()->size() ; + int const target_size = _toposource->getProcGroup()->getCommInterface().worldSize()- _toposource->getProcGroup()->size() ; vector<int>* target_arrays=new vector<int>[target_size]; - mcIdType nb_local = _toposource-> getNbLocalElements(); + mcIdType const nb_local = _toposource-> getNbLocalElements(); std::size_t union_size=group->size(); @@ -186,7 +190,7 @@ namespace MEDCoupling for (int ielem=0; ielem<nb_local; ielem++) { - int ncomp = _toposource->getNbComponents(); + int const ncomp = _toposource->getNbComponents(); for (int icomp=0; icomp<ncomp; icomp++) { _sendbuffer[ielem*ncomp+icomp]=value[bufferindex[ielem]*ncomp+icomp]; @@ -203,10 +207,10 @@ namespace MEDCoupling { if (!_topotarget->getProcGroup()->containsMyRank()) return; - MPIProcessorGroup* group=new MPIProcessorGroup(_topotarget->getProcGroup()->getCommInterface()); + auto* group=new MPIProcessorGroup(_topotarget->getProcGroup()->getCommInterface()); vector < vector <mcIdType> > source_arrays(_sourcegroup->size()); - mcIdType nb_local = _topotarget-> getNbLocalElements(); + mcIdType const nb_local = _topotarget-> getNbLocalElements(); for (mcIdType ielem=0; ielem< nb_local ; ielem++) { //pair<int,mcIdType> source_local =_distant_elems[ielem]; @@ -228,7 +232,7 @@ namespace MEDCoupling for (int iproc=0; iproc < _sourcegroup->size(); iproc++) { //converts the rank in target to the rank in union communicator - int unionrank=group->translateRank(_sourcegroup,iproc); + int const unionrank=group->translateRank(_sourcegroup,iproc); _recvcounts[unionrank]=(int)(source_arrays[iproc].size()*_topotarget->getNbComponents()); } for (std::size_t i=1; i<union_size; i++) @@ -249,19 +253,19 @@ namespace MEDCoupling { MPI_Status status; - mcIdType* serializer=0; + mcIdType* serializer=nullptr; mcIdType size; - MPIProcessorGroup* group=new MPIProcessorGroup(*_comm_interface); + auto* group=new MPIProcessorGroup(*_comm_interface); // The send processors serialize the send topology // and send the buffers to the recv procs - if (toposend !=0 && toposend->getProcGroup()->containsMyRank()) + if (toposend !=nullptr && toposend->getProcGroup()->containsMyRank()) { toposend->serialize(serializer, size); for (int iproc=0; iproc< group->size(); iproc++) { - int itarget=iproc; + int const itarget=iproc; if (!toposend->getProcGroup()->contains(itarget)) { _comm_interface->send(&size,1,MPI_ID_TYPE, itarget,tag+itarget,*(group->getComm())); @@ -272,25 +276,25 @@ namespace MEDCoupling else { vector <int> size2(group->size()); - int myworldrank=group->myRank(); + int const myworldrank=group->myRank(); for (int iproc=0; iproc<group->size();iproc++) { - int isource = iproc; + int const isource = iproc; if (!toporecv->getProcGroup()->contains(isource)) { mcIdType nbelem; _comm_interface->recv(&nbelem, 1, MPI_ID_TYPE, isource, tag+myworldrank, *(group->getComm()), &status); - mcIdType* buffer = new mcIdType[nbelem]; + auto* buffer = new mcIdType[nbelem]; _comm_interface->recv(buffer, (int)nbelem, MPI_ID_TYPE, isource,tag+myworldrank, *(group->getComm()), &status); - ExplicitTopology* topotemp=new ExplicitTopology(); + auto* topotemp=new ExplicitTopology(); topotemp->unserialize(buffer, *_comm_interface); delete[] buffer; for (mcIdType ielem=0; ielem<toporecv->getNbLocalElements(); ielem++) { - mcIdType global = toporecv->localToGlobal(ielem); - mcIdType sendlocal=topotemp->globalToLocal(global); + mcIdType const global = toporecv->localToGlobal(ielem); + mcIdType const sendlocal=topotemp->globalToLocal(global); if (sendlocal!=-1) { size2[iproc]++; @@ -307,13 +311,13 @@ namespace MEDCoupling void ExplicitCoincidentDEC::transferMappingToSource() { - MPIProcessorGroup* group=new MPIProcessorGroup(*_comm_interface); + auto* group=new MPIProcessorGroup(*_comm_interface); // sending source->target mapping which is stored by target //in _distant_elems from target to source - if (_topotarget!=0 && _topotarget->getProcGroup()->containsMyRank()) + if (_topotarget!=nullptr && _topotarget->getProcGroup()->containsMyRank()) { - int world_size = _topotarget->getProcGroup()->getCommInterface().worldSize() ; + int const world_size = _topotarget->getProcGroup()->getCommInterface().worldSize() ; int* nb_transfer_union=new int[world_size]; int* dummy_recv=new int[world_size]; for (int i=0; i<world_size; i++) @@ -341,7 +345,7 @@ namespace MEDCoupling } int* recvcounts=new int[world_size]; int* recvdispls=new int[world_size]; - int *dummyrecv=0; + int *dummyrecv=nullptr; for (int i=0; i <world_size; i++) { recvcounts[i]=0; @@ -353,7 +357,7 @@ namespace MEDCoupling //receiving in the source subdomains the mapping sent by targets else { - int world_size = _toposource->getProcGroup()->getCommInterface().worldSize() ; + int const world_size = _toposource->getProcGroup()->getCommInterface().worldSize() ; int* nb_transfer_union=new int[world_size]; int* dummy_send=new int[world_size]; for (int i=0; i<world_size; i++) @@ -363,11 +367,11 @@ namespace MEDCoupling int total_size=0; for (int i=0; i< world_size; i++) total_size+=nb_transfer_union[i]; - int nbtarget = _targetgroup->size(); + int const nbtarget = _targetgroup->size(); int* targetranks = new int[ nbtarget]; for (int i=0; i<nbtarget; i++) targetranks[i]=group->translateRank(_targetgroup,i); - mcIdType* mappingbuffer= new mcIdType [total_size*2]; + auto* mappingbuffer= new mcIdType [total_size*2]; int* sendcounts= new int [world_size]; int* senddispls = new int [world_size]; int* recvcounts=new int[world_size]; @@ -381,7 +385,7 @@ namespace MEDCoupling recvdispls[i]=recvdispls[i-1]+recvcounts[i-1]; } - int *dummysend=0; + int *dummysend=nullptr; for (int i=0; i <world_size; i++) { sendcounts[i]=0; @@ -403,14 +407,14 @@ namespace MEDCoupling _recvbuffer, _recvcounts, _recvdispls, MPI_DOUBLE,MPI_COMM_WORLD); cout<<"end AllToAll"<<endl; mcIdType nb_local = _topotarget->getNbLocalElements(); - double* value=new double[nb_local*_topotarget->getNbComponents()]; + auto* value=new double[nb_local*_topotarget->getNbComponents()]; vector<int> counters(_sourcegroup->size()); counters[0]=0; for (int i=0; i<_sourcegroup->size()-1; i++) { - MPIProcessorGroup* group=new MPIProcessorGroup(*_comm_interface); - int worldrank=group->translateRank(_sourcegroup,i); + auto* group=new MPIProcessorGroup(*_comm_interface); + int const worldrank=group->translateRank(_sourcegroup,i); counters[i+1]=counters[i]+_recvcounts[worldrank]; } diff --git a/src/ParaMEDMEM/ExplicitCoincidentDEC.hxx b/src/ParaMEDMEM/ExplicitCoincidentDEC.hxx index d0cea410a..6b0ee6443 100644 --- a/src/ParaMEDMEM/ExplicitCoincidentDEC.hxx +++ b/src/ParaMEDMEM/ExplicitCoincidentDEC.hxx @@ -24,7 +24,6 @@ #include "ExplicitMapping.hxx" #include "ExplicitTopology.hxx" -#include <map> namespace MEDCoupling { @@ -34,15 +33,15 @@ namespace MEDCoupling { public: ExplicitCoincidentDEC(); - virtual ~ExplicitCoincidentDEC(); - void synchronize(); + ~ExplicitCoincidentDEC() override; + void synchronize() override; void broadcastTopology(BlockTopology*&, int tag); void broadcastTopology(const ExplicitTopology* toposend, ExplicitTopology* toporecv, int tag); void transferMappingToSource(); - void prepareSourceDE(); - void prepareTargetDE(); - void recvData(); - void sendData(); + void prepareSourceDE() override; + void prepareTargetDE() override; + void recvData() override; + void sendData() override; private: ExplicitTopology* _toposource; ExplicitTopology* _topotarget; diff --git a/src/ParaMEDMEM/ExplicitMapping.cxx b/src/ParaMEDMEM/ExplicitMapping.cxx index a6cdfa569..ad14323ff 100644 --- a/src/ParaMEDMEM/ExplicitMapping.cxx +++ b/src/ParaMEDMEM/ExplicitMapping.cxx @@ -18,21 +18,25 @@ // #include "ExplicitMapping.hxx" +#include <utility> +#include "MCIdType.hxx" +#include <vector> +#include <map> namespace MEDCoupling { ExplicitMapping::ExplicitMapping(): _mapping(), _distant_domains(), - _numbers(0), _domains(0), _comm_buffer(0), - _buffer_index(0), _send_counts(0) + _numbers(nullptr), _domains(nullptr), _comm_buffer(nullptr), + _buffer_index(nullptr), _send_counts(nullptr) { } ExplicitMapping::~ExplicitMapping() { - if (_domains!=0) delete[] _domains; - if (_numbers!=0) delete[] _numbers; - if (_comm_buffer!=0) delete[] _comm_buffer; + if (_domains!=nullptr) delete[] _domains; + if (_numbers!=nullptr) delete[] _numbers; + if (_comm_buffer!=nullptr) delete[] _comm_buffer; } void ExplicitMapping::pushBackElem(std::pair<int,mcIdType> idistant) @@ -49,10 +53,8 @@ namespace MEDCoupling { if (_distant_domains.empty()) { - for (std::vector <std::pair<int,mcIdType> >::const_iterator iter= _mapping.begin(); - iter!=_mapping.end(); - iter++) - _distant_domains.insert(iter->first); + for (const auto & iter : _mapping) + _distant_domains.insert(iter.first); } return (int)_distant_domains.size(); } @@ -64,7 +66,7 @@ namespace MEDCoupling int ExplicitMapping::getDistantDomain(int i) { - if (_domains==0) + if (_domains==nullptr) computeNumbers(); return _domains[i]; @@ -72,7 +74,7 @@ namespace MEDCoupling int ExplicitMapping::getNbDistantElems(int i) { - if (_numbers==0) + if (_numbers==nullptr) computeNumbers(); return _numbers[i]; } @@ -85,12 +87,12 @@ namespace MEDCoupling for (int i=1; i<(int)_distant_domains.size();i++) offsets[i]=offsets[i-1]+_numbers[i-1]; - for (int i=0; i<(int)_mapping.size(); i++) + for (auto & i : _mapping) { - mcIdType offset= offsets[_mapping[i].first]; + mcIdType const offset= offsets[i.first]; _comm_buffer[offset*2]=idproc; - _comm_buffer[offset*2+1]=_mapping[i].second; - offsets[_mapping[i].first]++; + _comm_buffer[offset*2+1]=i.second; + offsets[i.first]++; } return _comm_buffer; } @@ -133,16 +135,16 @@ namespace MEDCoupling void ExplicitMapping::computeNumbers() { std::map <int,int> counts; - if (_numbers==0) + if (_numbers==nullptr) { _numbers=new int[nbDistantDomains()]; _domains=new int[nbDistantDomains()]; - for (int i=0; i<(int)_mapping.size(); i++) + for (auto & i : _mapping) { - if ( counts.find(_mapping[i].first) == counts.end()) - counts.insert(std::make_pair(_mapping[i].first,1)); + if ( counts.find(i.first) == counts.end()) + counts.insert(std::make_pair(i.first,1)); else - (counts[_mapping[i].first])++; + (counts[i.first])++; } int counter=0; for (std::map<int,int>::const_iterator iter=counts.begin(); diff --git a/src/ParaMEDMEM/ExplicitMapping.hxx b/src/ParaMEDMEM/ExplicitMapping.hxx index 340cdb73c..dd2f757c2 100644 --- a/src/ParaMEDMEM/ExplicitMapping.hxx +++ b/src/ParaMEDMEM/ExplicitMapping.hxx @@ -22,8 +22,8 @@ #include "MCIdType.hxx" +#include <utility> #include <vector> -#include <map> #include <set> namespace MEDCoupling diff --git a/src/ParaMEDMEM/ExplicitTopology.cxx b/src/ParaMEDMEM/ExplicitTopology.cxx index 5aecc1520..434ba0288 100644 --- a/src/ParaMEDMEM/ExplicitTopology.cxx +++ b/src/ParaMEDMEM/ExplicitTopology.cxx @@ -18,15 +18,13 @@ // #include "CommInterface.hxx" -#include "ProcessorGroup.hxx" +#include "MCType.hxx" #include "MPIProcessorGroup.hxx" #include "ParaMESH.hxx" -#include "Topology.hxx" #include "ExplicitTopology.hxx" #include "BlockTopology.hxx" -#include "ComponentTopology.hxx" -#include <vector> +#include <iostream> #include <algorithm> using namespace std; @@ -34,8 +32,8 @@ namespace MEDCoupling { ExplicitTopology::ExplicitTopology(): - _proc_group(NULL), _nb_elems(0), _nb_components(0), - _loc2glob(NULL), _glob2loc() + _proc_group(nullptr), _nb_elems(0), _nb_components(0), + _loc2glob(nullptr), _glob2loc() {} ExplicitTopology::ExplicitTopology(const ParaMESH& paramesh ): @@ -69,7 +67,7 @@ ExplicitTopology::ExplicitTopology(const ExplicitTopology& topo, int nb_componen ExplicitTopology::~ExplicitTopology() { - if (_loc2glob != 0) delete[] _loc2glob; + if (_loc2glob != nullptr) delete[] _loc2glob; } @@ -94,7 +92,7 @@ void ExplicitTopology::serialize(mcIdType* & serializer, mcIdType& size) const * after communication. Uses the same structure as the one used for serialize() * * */ -void ExplicitTopology::unserialize(const mcIdType* serializer,const CommInterface& comm_interface) +void ExplicitTopology::unserialize(const mcIdType* serializer,const CommInterface& /*comm_interface*/) { const mcIdType* ptr_serializer=serializer; cout << "unserialize..."<<endl; diff --git a/src/ParaMEDMEM/ExplicitTopology.hxx b/src/ParaMEDMEM/ExplicitTopology.hxx index 32401a5ee..419fea84b 100644 --- a/src/ParaMEDMEM/ExplicitTopology.hxx +++ b/src/ParaMEDMEM/ExplicitTopology.hxx @@ -20,17 +20,17 @@ #ifndef __EXPLICITTOPOLOGY_HXX__ #define __EXPLICITTOPOLOGY_HXX__ +#include "MCType.hxx" +#include "CommInterface.hxx" #include "ProcessorGroup.hxx" #include "InterpKernelHashMap.hxx" +#include "Topology.hxx" -#include <vector> #include <utility> -#include <iostream> namespace MEDCoupling { class ParaMESH; - class Topology; class ComponentTopology; /*! diff --git a/src/ParaMEDMEM/InterpKernelDEC.cxx b/src/ParaMEDMEM/InterpKernelDEC.cxx index f4494f489..5c925f032 100644 --- a/src/ParaMEDMEM/InterpKernelDEC.cxx +++ b/src/ParaMEDMEM/InterpKernelDEC.cxx @@ -17,15 +17,17 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +#include <cstddef> #include <mpi.h> -#include "CommInterface.hxx" +#include <string> +#include <utility> +#include "DisjointDEC.hxx" +#include "MCType.hxx" +#include "MCAuto.hxx" +#include "InterpKernelException.hxx" #include "Topology.hxx" -#include "BlockTopology.hxx" #include "ComponentTopology.hxx" #include "ParaFIELD.hxx" -#include "MPIProcessorGroup.hxx" -#include "ParaMESH.hxx" -#include "DEC.hxx" #include "InterpolationMatrix.hxx" #include "InterpKernelDEC.hxx" #include "ElementLocator.hxx" @@ -34,7 +36,7 @@ namespace MEDCoupling { InterpKernelDEC::InterpKernelDEC(): DisjointDEC(), - _interpolation_matrix(0) + _interpolation_matrix(nullptr) { } @@ -51,7 +53,7 @@ namespace MEDCoupling */ InterpKernelDEC::InterpKernelDEC(ProcessorGroup& source_group, ProcessorGroup& target_group): DisjointDEC(source_group, target_group), - _interpolation_matrix(0) + _interpolation_matrix(nullptr) { } @@ -65,7 +67,7 @@ namespace MEDCoupling InterpKernelDEC::InterpKernelDEC(const std::set<int>& src_ids, const std::set<int>& trg_ids, const MPI_Comm& world_comm): DisjointDEC(src_ids,trg_ids,world_comm), - _interpolation_matrix(0) + _interpolation_matrix(nullptr) { } @@ -76,7 +78,7 @@ namespace MEDCoupling */ InterpKernelDEC::InterpKernelDEC(ProcessorGroup& generic_group, const std::string& source_group, const std::string& target_group): DisjointDEC(generic_group.getProcIDsByName(source_group),generic_group.getProcIDsByName(target_group)), - _interpolation_matrix(0) + _interpolation_matrix(nullptr) { } @@ -147,27 +149,27 @@ namespace MEDCoupling ElementLocator locator(*_local_field, *_target_group, *_source_group); //transferring option from InterpKernelDEC to ElementLocator locator.copyOptions(*this); - MEDCouplingPointSet* distant_mesh=0; - mcIdType* distant_ids=0; + MEDCouplingPointSet* distant_mesh=nullptr; + mcIdType* distant_ids=nullptr; std::string distantMeth; for (int i=0; i<_target_group->size(); i++) { // int idistant_proc = (i+_source_group->myRank())%_target_group->size(); - int idistant_proc=i; + int const idistant_proc=i; //gathers pieces of the target meshes that can intersect the local mesh locator.exchangeMesh(idistant_proc,distant_mesh,distant_ids); - if (distant_mesh !=0) + if (distant_mesh !=nullptr) { locator.exchangeMethod(_method,idistant_proc,distantMeth); //adds the contribution of the distant mesh on the local one - int idistant_proc_in_union=_union_group->translateRank(_target_group,idistant_proc); + int const idistant_proc_in_union=_union_group->translateRank(_target_group,idistant_proc); //std::cout <<"add contribution from proc "<<idistant_proc_in_union<<" to proc "<<_union_group->myRank()<<std::endl; _interpolation_matrix->addContribution(*distant_mesh,idistant_proc_in_union,distant_ids,_method,distantMeth); distant_mesh->decrRef(); delete [] distant_ids; - distant_mesh=0; - distant_ids=0; + distant_mesh=nullptr; + distant_ids=nullptr; } } _interpolation_matrix->finishContributionW(locator); @@ -178,23 +180,23 @@ namespace MEDCoupling ElementLocator locator(*_local_field, *_source_group, *_target_group); //transferring option from InterpKernelDEC to ElementLocator locator.copyOptions(*this); - MEDCouplingPointSet* distant_mesh=0; - mcIdType* distant_ids=0; + MEDCouplingPointSet* distant_mesh=nullptr; + mcIdType* distant_ids=nullptr; for (int i=0; i<_source_group->size(); i++) { // int idistant_proc = (i+_target_group->myRank())%_source_group->size(); - int idistant_proc=i; + int const idistant_proc=i; //gathers pieces of the target meshes that can intersect the local mesh locator.exchangeMesh(idistant_proc,distant_mesh,distant_ids); //std::cout << " Data sent from "<<_union_group->myRank()<<" to source proc "<< idistant_proc<<std::endl; - if (distant_mesh!=0) + if (distant_mesh!=nullptr) { std::string distantMeth; locator.exchangeMethod(_method,idistant_proc,distantMeth); distant_mesh->decrRef(); delete [] distant_ids; - distant_mesh=0; - distant_ids=0; + distant_mesh=nullptr; + distant_ids=nullptr; } } _interpolation_matrix->finishContributionL(locator); diff --git a/src/ParaMEDMEM/InterpKernelDEC.hxx b/src/ParaMEDMEM/InterpKernelDEC.hxx index 3a8803a22..824307fbb 100644 --- a/src/ParaMEDMEM/InterpKernelDEC.hxx +++ b/src/ParaMEDMEM/InterpKernelDEC.hxx @@ -21,8 +21,11 @@ #define __INTERPKERNELDEC_HXX__ #include "DisjointDEC.hxx" +#include "MCAuto.hxx" +#include "MCType.hxx" #include "MxN_Mapping.hxx" #include "InterpolationOptions.hxx" +#include <string> namespace MEDCoupling { @@ -133,18 +136,18 @@ namespace MEDCoupling InterpKernelDEC(const std::set<int>& src_ids, const std::set<int>& trg_ids, const MPI_Comm& world_comm=MPI_COMM_WORLD); InterpKernelDEC(ProcessorGroup& generic_group, const std::string& source_group, const std::string& target_group); InterpKernelDEC(ProcessorGroup& generic_group, const std::string& interaction_group); - virtual ~InterpKernelDEC(); + ~InterpKernelDEC() override; void release(); - void synchronize(); + void synchronize() override; void synchronizeWithDefaultValue(double val); MCAuto<DataArrayIdType> retrieveNonFetchedIds() const; - void recvData(); + void recvData() override; void recvData(double time); - void sendData(); + void sendData() override; void sendData(double time , double deltatime); - void prepareSourceDE() { } - void prepareTargetDE() { } + void prepareSourceDE() override { } + void prepareTargetDE() override { } private: MCAuto<DataArrayIdType> retrieveNonFetchedIdsSource() const; MCAuto<DataArrayIdType> retrieveNonFetchedIdsTarget() const; diff --git a/src/ParaMEDMEM/InterpolationMatrix.cxx b/src/ParaMEDMEM/InterpolationMatrix.cxx index b8271a945..2fbffef53 100644 --- a/src/ParaMEDMEM/InterpolationMatrix.cxx +++ b/src/ParaMEDMEM/InterpolationMatrix.cxx @@ -17,27 +17,37 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +#include "DECOptions.hxx" +#include "MCType.hxx" +#include "MEDCouplingNormalizedUnstructuredMesh.txx" +#include "Interpolation2D.hxx" +#include "Interpolation3D.hxx" +#include "Interpolation2D3D.hxx" +#include "Interpolation2D1D.hxx" +#include "Interpolation1D.hxx" +#include "MEDCouplingNatureOfFieldEnum" +#include "MCAuto.hxx" +#include "InterpKernelException.hxx" #include "ParaMESH.hxx" #include "ParaFIELD.hxx" #include "ProcessorGroup.hxx" #include "MxN_Mapping.hxx" #include "InterpolationMatrix.hxx" -#include "TranslationRotationMatrix.hxx" -#include "Interpolation.hxx" -#include "Interpolation1D.txx" #include "Interpolation2DCurve.hxx" -#include "Interpolation2D.txx" #include "Interpolation3DSurf.hxx" #include "Interpolation3D.txx" #include "Interpolation2D3D.txx" #include "Interpolation2D1D.txx" #include "MEDCouplingUMesh.hxx" -#include "MEDCouplingNormalizedUnstructuredMesh.txx" #include "InterpolationOptions.hxx" -#include "NormalizedUnstructuredMesh.hxx" #include "ElementLocator.hxx" #include <algorithm> +#include <string> +#include <cstddef> +#include <utility> +#include <sstream> +#include <limits> using namespace std; @@ -67,15 +77,14 @@ namespace MEDCoupling _source_group(source_group), _target_group(target_group) { - mcIdType nbelems = source_field->getField()->getNumberOfTuples(); + mcIdType const nbelems = source_field->getField()->getNumberOfTuples(); _row_offsets.resize(nbelems+1); _coeffs.resize(nbelems); _target_volume.resize(nbelems); } InterpolationMatrix::~InterpolationMatrix() - { - } + = default; /*! @@ -104,8 +113,8 @@ namespace MEDCoupling //creating the interpolator structure vector<map<mcIdType,double> > surfaces; //computation of the intersection volumes between source and target elements - MEDCouplingUMesh *distant_supportC=dynamic_cast<MEDCouplingUMesh *>(&distant_support); - MEDCouplingUMesh *source_supportC=dynamic_cast<MEDCouplingUMesh *>(_source_support); + auto *distant_supportC=dynamic_cast<MEDCouplingUMesh *>(&distant_support); + auto *source_supportC=dynamic_cast<MEDCouplingUMesh *>(_source_support); if ( distant_support.getMeshDimension() == -1 ) { if(source_supportC->getMeshDimension()==2 && source_supportC->getSpaceDimension()==2) @@ -248,9 +257,9 @@ namespace MEDCoupling { throw INTERP_KERNEL::Exception("no interpolator exists for these mesh and space dimensions "); } - bool needTargetSurf=isSurfaceComputationNeeded(targetMeth); + bool const needTargetSurf=isSurfaceComputationNeeded(targetMeth); - MEDCouplingFieldDouble *target_triangle_surf=0; + MEDCouplingFieldDouble *target_triangle_surf=nullptr; if(needTargetSurf) target_triangle_surf = distant_support.getMeasureField(getMeasureAbsStatus()); fillDSFromVM(iproc_distant,distant_elems,surfaces,target_triangle_surf); @@ -345,7 +354,7 @@ namespace MEDCoupling void InterpolationMatrix::finishContributionW(ElementLocator& elementLocator) { - NatureOfField nature=elementLocator.getLocalNature(); + NatureOfField const nature=elementLocator.getLocalNature(); switch(nature) { case IntensiveMaximum: @@ -378,7 +387,7 @@ namespace MEDCoupling void InterpolationMatrix::finishContributionL(ElementLocator& elementLocator) { - NatureOfField nature=elementLocator.getLocalNature(); + NatureOfField const nature=elementLocator.getLocalNature(); switch(nature) { case IntensiveMaximum: @@ -418,7 +427,7 @@ namespace MEDCoupling void InterpolationMatrix::computeConservVolDenoL(ElementLocator& elementLocator) { - int pol1=elementLocator.sendPolicyToWorkingSideL(); + int const pol1=elementLocator.sendPolicyToWorkingSideL(); if(pol1==ElementLocator::NO_POST_TREATMENT_POLICY) { elementLocator.recvFromWorkingSideL(); @@ -442,7 +451,7 @@ namespace MEDCoupling throw INTERP_KERNEL::Exception("Not managed policy detected on lazy side : not implemented !"); } - void InterpolationMatrix::computeIntegralDenoW(ElementLocator& elementLocator) + void InterpolationMatrix::computeIntegralDenoW(ElementLocator& /*elementLocator*/) { MEDCouplingFieldDouble *source_triangle_surf = _source_support->getMeasureField(getMeasureAbsStatus()); _deno_multiply.resize(_coeffs.size()); @@ -457,7 +466,7 @@ namespace MEDCoupling _deno_reverse_multiply=_target_volume; } - void InterpolationMatrix::computeRevIntegralDenoW(ElementLocator& elementLocator) + void InterpolationMatrix::computeRevIntegralDenoW(ElementLocator& /*elementLocator*/) { _deno_multiply=_target_volume; MEDCouplingFieldDouble *source_triangle_surf = _source_support->getMeasureField(getMeasureAbsStatus()); @@ -841,7 +850,7 @@ namespace MEDCoupling */ void InterpolationMatrix::prepare() { - mcIdType nbelems = _source_field->getField()->getNumberOfTuples(); + mcIdType const nbelems = _source_field->getField()->getNumberOfTuples(); for (mcIdType ielem=0; ielem < nbelems; ielem++) { _row_offsets[ielem+1]+=_row_offsets[ielem]; diff --git a/src/ParaMEDMEM/InterpolationMatrix.hxx b/src/ParaMEDMEM/InterpolationMatrix.hxx index 4d966ee53..b42493d14 100644 --- a/src/ParaMEDMEM/InterpolationMatrix.hxx +++ b/src/ParaMEDMEM/InterpolationMatrix.hxx @@ -20,10 +20,18 @@ #ifndef __INTERPOLATIONMATRIX_HXX__ #define __INTERPOLATIONMATRIX_HXX__ +#include "MCType.hxx" +#include "MCAuto.hxx" +#include "MEDCouplingFieldDouble.hxx" +#include "MEDCouplingPointSet.hxx" #include "MPIAccessDEC.hxx" #include "MxN_Mapping.hxx" #include "InterpolationOptions.hxx" #include "DECOptions.hxx" +#include "ParaFIELD.hxx" +#include <string> +#include <vector> +#include <utility> namespace MEDCoupling { diff --git a/src/ParaMEDMEM/LinearTimeInterpolator.cxx b/src/ParaMEDMEM/LinearTimeInterpolator.cxx index 7c897f142..8c23e2a0e 100644 --- a/src/ParaMEDMEM/LinearTimeInterpolator.cxx +++ b/src/ParaMEDMEM/LinearTimeInterpolator.cxx @@ -18,6 +18,7 @@ // #include "LinearTimeInterpolator.hxx" +#include "TimeInterpolator.hxx" using namespace std; @@ -31,11 +32,10 @@ namespace MEDCoupling } LinearTimeInterpolator::~LinearTimeInterpolator() - { - } + = default; void LinearTimeInterpolator::doInterp( double time0, double time1, double time, - int recvcount , int nbuff0, int nbuff1, + int recvcount , int /*nbuff0*/, int /*nbuff1*/, int **recvbuff0, int **recvbuff1, int *result ) { for(int i = 0 ; i < recvcount ; i++ ) @@ -43,7 +43,7 @@ namespace MEDCoupling } void LinearTimeInterpolator::doInterp( double time0, double time1, double time, - int recvcount , int nbuff0, int nbuff1, + int recvcount , int /*nbuff0*/, int /*nbuff1*/, double **recvbuff0, double **recvbuff1, double *result ) { diff --git a/src/ParaMEDMEM/LinearTimeInterpolator.hxx b/src/ParaMEDMEM/LinearTimeInterpolator.hxx index eac403f93..91378419d 100644 --- a/src/ParaMEDMEM/LinearTimeInterpolator.hxx +++ b/src/ParaMEDMEM/LinearTimeInterpolator.hxx @@ -22,8 +22,6 @@ #include "TimeInterpolator.hxx" -#include <map> -#include <iostream> namespace MEDCoupling { @@ -39,13 +37,13 @@ namespace MEDCoupling public: LinearTimeInterpolator( double InterpPrecision=0, int nStepBefore=1, int nStepAfter=1 ) ; - virtual ~LinearTimeInterpolator(); + ~LinearTimeInterpolator() override; void doInterp( double time0, double time1, double time, int recvcount, int nbuff0, int nbuff1, - int **recvbuff0, int **recvbuff1, int *result ); + int **recvbuff0, int **recvbuff1, int *result ) override; void doInterp( double time0, double time1, double time, int recvcount, int nbuff0, int nbuff1, - double **recvbuff0, double **recvbuff1, double *result ); + double **recvbuff0, double **recvbuff1, double *result ) override; }; } diff --git a/src/ParaMEDMEM/MPIAccess/MPIAccess.cxx b/src/ParaMEDMEM/MPIAccess/MPIAccess.cxx index 549cd0cbf..f65270b87 100644 --- a/src/ParaMEDMEM/MPIAccess/MPIAccess.cxx +++ b/src/ParaMEDMEM/MPIAccess/MPIAccess.cxx @@ -19,9 +19,12 @@ #include "MPIAccess/MPIAccess.hxx" -#include "InterpolationUtils.hxx" +#include "MPIProcessorGroup.hxx" +#include <cstddef> +#include <cstdlib> #include <iostream> +#include <limits> using namespace std; @@ -195,7 +198,7 @@ namespace MEDCoupling int MPIAccess::newRequest( MPI_Datatype datatype, int tag , int destsourcerank , bool fromsourcerank , bool asynchronous ) { - RequestStruct *mpiaccessstruct = new RequestStruct; + auto *mpiaccessstruct = new RequestStruct; mpiaccessstruct->MPITag = tag ; mpiaccessstruct->MPIDatatype = datatype ; mpiaccessstruct->MPITarget = destsourcerank ; @@ -297,7 +300,7 @@ namespace MEDCoupling // Returns in ArrayOfSendRequests with the dimension "size" all the // SendRequestIds - int MPIAccess::sendRequestIds(int size, int *ArrayOfSendRequests) + int MPIAccess::sendRequestIds(int /*size*/, int *ArrayOfSendRequests) { int destrank ; int i = 0 ; @@ -322,7 +325,7 @@ namespace MEDCoupling // Returns in ArrayOfRecvRequests with the dimension "size" all the // RecvRequestIds - int MPIAccess::recvRequestIds(int size, int *ArrayOfRecvRequests) + int MPIAccess::recvRequestIds(int /*size*/, int *ArrayOfRecvRequests) { int sourcerank ; int i = 0 ; @@ -375,7 +378,7 @@ namespace MEDCoupling int MPItag = newSendTag( datatype, target , aMethodIdent , false , RequestId ) ; if ( aMethodIdent == _message_time ) { - TimeMessage *aTimeMsg = (TimeMessage *) buffer ; + auto *aTimeMsg = (TimeMessage *) buffer ; aTimeMsg->tag = MPItag ; } deleteRequest( RequestId ) ; @@ -397,7 +400,7 @@ namespace MEDCoupling { int sts = MPI_SUCCESS ; RequestId = -1 ; - if ( OutCount != NULL ) + if ( OutCount != nullptr ) *OutCount = -1 ; if ( count ) { @@ -414,7 +417,7 @@ namespace MEDCoupling setMPICompleted( RequestId , true ) ; deleteStatus( RequestId ) ; } - if ( OutCount != NULL ) + if ( OutCount != nullptr ) *OutCount = outcount ; if ( _trace ) cout << "MPIAccess::Recv" << _my_rank << " RecvRequestId " @@ -437,7 +440,7 @@ namespace MEDCoupling int MPItag = newSendTag( datatype, target , aMethodIdent , true , RequestId ) ; if ( aMethodIdent == _message_time ) { - TimeMessage *aTimeMsg = (TimeMessage *) buffer ; + auto *aTimeMsg = (TimeMessage *) buffer ; aTimeMsg->tag = MPItag ; } MPI_Request *aSendRequest = MPIRequest( RequestId ) ; @@ -515,7 +518,7 @@ namespace MEDCoupling << RecvRequestId << " outcount " << outcount << endl ; } } - if ( OutCount != NULL ) + if ( OutCount != nullptr ) { *OutCount = outcount ; if ( _trace ) @@ -688,7 +691,7 @@ namespace MEDCoupling return status ; } - int MPIAccess::waitAny(int count, int *array_of_RequestIds, int &RequestId) + int MPIAccess::waitAny(int /*count*/, int * /*array_of_RequestIds*/, int &RequestId) { int status = MPI_ERR_OTHER ; RequestId = -1 ; @@ -696,7 +699,7 @@ namespace MEDCoupling return status ; } - int MPIAccess::testAny(int count, int *array_of_RequestIds, int &RequestId, int &flag) + int MPIAccess::testAny(int /*count*/, int * /*array_of_RequestIds*/, int &RequestId, int &flag) { int status = MPI_ERR_OTHER ; RequestId = -1 ; @@ -759,16 +762,16 @@ namespace MEDCoupling return retstatus ; } - int MPIAccess::waitSome(int count, int *array_of_RequestIds, int outcount, - int *outarray_of_RequestIds) + int MPIAccess::waitSome(int /*count*/, int * /*array_of_RequestIds*/, int /*outcount*/, + int * /*outarray_of_RequestIds*/) { int status = MPI_ERR_OTHER ; cout << "MPIAccess::WaitSome not yet implemented" << endl ; return status ; } - int MPIAccess::testSome(int count, int *array_of_RequestIds, int outcounts, - int *outarray_of_RequestIds) + int MPIAccess::testSome(int /*count*/, int * /*array_of_RequestIds*/, int /*outcounts*/, + int * /*outarray_of_RequestIds*/) { int status = MPI_ERR_OTHER ; cout << "MPIAccess::TestSome not yet implemented" << endl ; diff --git a/src/ParaMEDMEM/MPIAccess/MPIAccess.hxx b/src/ParaMEDMEM/MPIAccess/MPIAccess.hxx index f8cdc4c5b..7c355fffb 100644 --- a/src/ParaMEDMEM/MPIAccess/MPIAccess.hxx +++ b/src/ParaMEDMEM/MPIAccess/MPIAccess.hxx @@ -21,13 +21,13 @@ #define __MPIACCESS_HXX__ #include "CommInterface.hxx" -#include "ProcessorGroup.hxx" #include "MPIProcessorGroup.hxx" -#include <map> +#include <cstddef> +#include <iostream> #include <list> #include <vector> -#include <iostream> +#include <map> namespace MEDCoupling { @@ -83,13 +83,13 @@ namespace MEDCoupling int ISend(void* buffer, int count, MPI_Datatype datatype, int target, int &RequestId) ; int recv(void* buffer, int count, MPI_Datatype datatype, int source, - int &RequestId, int *OutCount=NULL) ; + int &RequestId, int *OutCount=nullptr) ; int IRecv(void* buffer, int count, MPI_Datatype datatype, int source, int &RequestId) ; int sendRecv(void* sendbuf, int sendcount, MPI_Datatype sendtype, int dest, int &SendRequestId, void* recvbuf, int recvcount, MPI_Datatype recvtype, int source, - int &RecvRequestId, int *OutCount=NULL) ; + int &RecvRequestId, int *OutCount=nullptr) ; int ISendRecv(void* sendbuf, int sendcount, MPI_Datatype sendtype, int dest, int &SendRequestId, void* recvbuf, int recvcount, MPI_Datatype recvtype, int source, int &RecvRequestId) ; @@ -397,7 +397,7 @@ namespace MEDCoupling struct RequestStruct *aRequestStruct = _map_of_request_struct[ RequestId ]; if ( aRequestStruct ) return aRequestStruct->MPIStatus; - return NULL ; + return nullptr ; } // Set the MPICompleted field of the structure Request corresponding to RequestId diff --git a/src/ParaMEDMEM/MPIAccess/MPIAccessDEC.cxx b/src/ParaMEDMEM/MPIAccess/MPIAccessDEC.cxx index c13cbc8d1..55f04c602 100644 --- a/src/ParaMEDMEM/MPIAccess/MPIAccessDEC.cxx +++ b/src/ParaMEDMEM/MPIAccess/MPIAccessDEC.cxx @@ -18,8 +18,14 @@ // #include "MPIAccess/MPIAccessDEC.hxx" +#include "ProcessorGroup.hxx" +#include "MPIProcessorGroup.hxx" +#include "MPIAccess.hxx" +#include "DECOptions.hxx" +#include "LinearTimeInterpolator.hxx" #include <cstring> +#include <iostream> using namespace std; @@ -47,7 +53,7 @@ namespace MEDCoupling { procs.insert(i) ; } - MPIProcessorGroup *mpilg = static_cast<MPIProcessorGroup *>(const_cast<ProcessorGroup *>(&source_group)); + auto *mpilg = static_cast<MPIProcessorGroup *>(const_cast<ProcessorGroup *>(&source_group)); _MPI_union_group = new MEDCoupling::MPIProcessorGroup( union_group->getCommInterface(),procs,mpilg->getWorldComm()); delete union_group ; _my_rank = _MPI_union_group->myRank() ; @@ -69,7 +75,7 @@ namespace MEDCoupling _data_messages_type->resize( _group_size ) ; _data_messages = new vector< vector< void * > > ; _data_messages->resize( _group_size ) ; - _time_interpolator = NULL ; + _time_interpolator = nullptr ; _map_of_send_buffers = new map< int , SendBuffStruct * > ; } @@ -104,7 +110,7 @@ namespace MEDCoupling switch ( aTimeInterp ) { case WithoutTimeInterp : - _time_interpolator = NULL ; + _time_interpolator = nullptr ; _n_step_before = 0 ; _n_step_after = 0 ; break ; @@ -347,7 +353,7 @@ namespace MEDCoupling checkSent() ; //DoSend + DoRecv : SendRecv - SendBuffStruct * aSendDataStruct = NULL ; + SendBuffStruct * aSendDataStruct = nullptr ; if ( _asynchronous && sendbuf ) { aSendDataStruct = new SendBuffStruct ; @@ -409,7 +415,7 @@ namespace MEDCoupling } //DoSend + DoRecv : SendRecv - SendBuffStruct * aSendDataStruct = NULL ; + SendBuffStruct * aSendDataStruct = nullptr ; if ( _asynchronous && sendbuf ) { aSendDataStruct = new SendBuffStruct ; @@ -518,7 +524,7 @@ namespace MEDCoupling int SendTimeRequestId ; int SendDataRequestId ; - if ( _time_interpolator == NULL ) + if ( _time_interpolator == nullptr ) { return MPI_ERR_OTHER ; } @@ -530,11 +536,11 @@ namespace MEDCoupling } //DoSend : Time + SendBuff - SendBuffStruct * aSendTimeStruct = NULL ; - SendBuffStruct * aSendDataStruct = NULL ; + SendBuffStruct * aSendTimeStruct = nullptr ; + SendBuffStruct * aSendDataStruct = nullptr ; if ( sendbuf && sendcount ) { - TimeMessage * aSendTimeMessage = new TimeMessage ; + auto * aSendTimeMessage = new TimeMessage ; if ( _asynchronous ) { aSendTimeStruct = new SendBuffStruct ; @@ -637,7 +643,7 @@ namespace MEDCoupling int SendTimeRequestId ; int SendDataRequestId ; - if ( _time_interpolator == NULL ) + if ( _time_interpolator == nullptr ) { return MPI_ERR_OTHER ; } @@ -665,11 +671,11 @@ namespace MEDCoupling + And if we are in synchronous mode we delete the SendMessages. */ //DoSend : Time + SendBuff - SendBuffStruct * aSendTimeStruct = NULL ; - SendBuffStruct * aSendDataStruct = NULL ; + SendBuffStruct * aSendTimeStruct = nullptr ; + SendBuffStruct * aSendDataStruct = nullptr ; if ( sendbuf ) { - TimeMessage * aSendTimeMessage = new TimeMessage ; + auto * aSendTimeMessage = new TimeMessage ; if ( _asynchronous ) { aSendTimeStruct = new SendBuffStruct ; @@ -909,10 +915,10 @@ namespace MEDCoupling { int sts = MPI_SUCCESS ; int flag = WithWait ; - int size = _MPI_access->sendRequestIdsSize() ; + int const size = _MPI_access->sendRequestIdsSize() ; int * ArrayOfSendRequests = new int[ size ] ; - int nSendRequest = _MPI_access->sendRequestIds( size , ArrayOfSendRequests ) ; - bool SendTrace = false ; + int const nSendRequest = _MPI_access->sendRequestIds( size , ArrayOfSendRequests ) ; + bool const SendTrace = false ; int i ; for ( i = 0 ; i < nSendRequest ; i++ ) { diff --git a/src/ParaMEDMEM/MPIAccess/MPIAccessDEC.hxx b/src/ParaMEDMEM/MPIAccess/MPIAccessDEC.hxx index 8f724a057..63dcb706b 100644 --- a/src/ParaMEDMEM/MPIAccess/MPIAccessDEC.hxx +++ b/src/ParaMEDMEM/MPIAccess/MPIAccessDEC.hxx @@ -20,12 +20,14 @@ #ifndef __MPIACCESSDEC_HXX__ #define __MPIACCESSDEC_HXX__ -#include "DEC.hxx" -#include "LinearTimeInterpolator.hxx" +#include "DECOptions.hxx" -#include <map> +#include <cstdlib> #include <iostream> #include "MPIAccess.hxx" +#include "ProcessorGroup.hxx" +#include "MPIProcessorGroup.hxx" +#include "TimeInterpolator.hxx" namespace MEDCoupling { diff --git a/src/ParaMEDMEM/MPIProcessorGroup.cxx b/src/ParaMEDMEM/MPIProcessorGroup.cxx index 1e40fd65d..42b169ac0 100644 --- a/src/ParaMEDMEM/MPIProcessorGroup.cxx +++ b/src/ParaMEDMEM/MPIProcessorGroup.cxx @@ -20,11 +20,10 @@ #include "ProcessorGroup.hxx" #include "MPIProcessorGroup.hxx" #include "CommInterface.hxx" -#include "InterpolationUtils.hxx" +#include <cstdlib> #include <iostream> -#include <set> -#include <algorithm> +#include <string> #include "mpi.h" using namespace std; @@ -165,7 +164,7 @@ namespace MEDCoupling _comm_interface.groupFree(&group_world); throw INTERP_KERNEL::Exception("invalid argument in MPIProcessorGroup constructor (comm,pfirst,plast)"); } - int nprocs=pend-pstart+1; + int const nprocs=pend-pstart+1; int* ranks=new int[nprocs]; for (int i=pstart; i<=pend;i++) { @@ -222,7 +221,7 @@ namespace MEDCoupling */ int MPIProcessorGroup::translateRank(const ProcessorGroup* group, int rank) const { - const MPIProcessorGroup* targetgroup=dynamic_cast<const MPIProcessorGroup*>(group); + const auto* targetgroup=dynamic_cast<const MPIProcessorGroup*>(group); int local_rank; MPI_Group_translate_ranks(targetgroup->_group, 1, &rank, _group, &local_rank); return local_rank; @@ -235,7 +234,7 @@ namespace MEDCoupling ProcessorGroup* MPIProcessorGroup::createComplementProcGroup() const { set <int> procs; - int world_size=_comm_interface.worldSize(); + int const world_size=_comm_interface.worldSize(); for (int i=0; i<world_size; i++) procs.insert(i); for (set<int>::const_iterator iter=_proc_ids.begin(); iter!= _proc_ids.end(); iter++) diff --git a/src/ParaMEDMEM/MPIProcessorGroup.hxx b/src/ParaMEDMEM/MPIProcessorGroup.hxx index 1dd035995..007c7281f 100644 --- a/src/ParaMEDMEM/MPIProcessorGroup.hxx +++ b/src/ParaMEDMEM/MPIProcessorGroup.hxx @@ -22,8 +22,8 @@ #include "ProcessorGroup.hxx" -#include <set> #include <mpi.h> +#include <string> namespace MEDCoupling { @@ -38,18 +38,18 @@ namespace MEDCoupling MPIProcessorGroup (const ProcessorGroup& proc_group, std::set<int> proc_ids); MPIProcessorGroup(const CommInterface& interface,int pstart, int pend, const MPI_Comm& world_comm=MPI_COMM_WORLD); MPIProcessorGroup(const MPIProcessorGroup& other); - virtual ~MPIProcessorGroup(); + ~MPIProcessorGroup() override; void release(); - virtual MPIProcessorGroup *deepCopy() const; - virtual ProcessorGroup* fuse (const ProcessorGroup&) const; - void intersect (ProcessorGroup&) { } - int myRank() const; - bool containsMyRank() const { int rank; MPI_Group_rank(_group, &rank); return (rank!=MPI_UNDEFINED); } - int translateRank(const ProcessorGroup* group, int rank) const; + MPIProcessorGroup *deepCopy() const override; + ProcessorGroup* fuse (const ProcessorGroup&) const override; + void intersect (ProcessorGroup&) override { } + int myRank() const override; + bool containsMyRank() const override { int rank; MPI_Group_rank(_group, &rank); return (rank!=MPI_UNDEFINED); } + int translateRank(const ProcessorGroup* group, int rank) const override; const MPI_Comm* getComm() const { return &_comm; } - ProcessorGroup* createComplementProcGroup() const; - ProcessorGroup* createProcGroup() const; + ProcessorGroup* createComplementProcGroup() const override; + ProcessorGroup* createProcGroup() const override; MPI_Comm getWorldComm() { return _world_comm; } private: void updateMPISpecificAttributes(); diff --git a/src/ParaMEDMEM/MxN_Mapping.cxx b/src/ParaMEDMEM/MxN_Mapping.cxx index f076bbb65..76b807d2d 100644 --- a/src/ParaMEDMEM/MxN_Mapping.cxx +++ b/src/ParaMEDMEM/MxN_Mapping.cxx @@ -18,9 +18,17 @@ // #include "CommInterface.hxx" +#include "DECOptions.hxx" +#include "MCType.hxx" +#include "ParaIdType.hxx" +#include "MCAuto.hxx" +#include "MEDCouplingFieldDouble.hxx" +#include "MEDCouplingMemArray.hxx" #include "ProcessorGroup.hxx" #include "MPIProcessorGroup.hxx" #include "MPIAccessDEC.hxx" +#include <cstddef> +#include <ostream> #include "MxN_Mapping.hxx" using namespace std; @@ -67,7 +75,7 @@ namespace MEDCoupling void MxN_Mapping::prepareSendRecv() { - CommInterface comm_interface=_union_group->getCommInterface(); + CommInterface const comm_interface=_union_group->getCommInterface(); // sending count pattern int* nbsend=new int[_union_group->size()]; int* nbrecv=new int[_union_group->size()]; @@ -76,7 +84,7 @@ namespace MEDCoupling nbsend[i]=_send_proc_offsets[i+1]-_send_proc_offsets[i]; } - MPIProcessorGroup* group = static_cast<MPIProcessorGroup*>(_union_group); + auto* group = static_cast<MPIProcessorGroup*>(_union_group); const MPI_Comm* comm=group->getComm(); comm_interface.allToAll(nbsend, 1, MPI_INT, nbrecv, 1, MPI_INT, @@ -93,8 +101,8 @@ namespace MEDCoupling delete[] nbrecv; _recv_ids.resize(_recv_proc_offsets[_union_group->size()]); - mcIdType* isendbuf=0; - mcIdType* irecvbuf=0; + mcIdType* isendbuf=nullptr; + mcIdType* irecvbuf=nullptr; if (_sending_ids.size()>0) isendbuf = new mcIdType[_sending_ids.size()]; if (_recv_ids.size()>0) @@ -160,12 +168,12 @@ namespace MEDCoupling */ void MxN_Mapping::sendRecv(double* sendfield, MEDCouplingFieldDouble& field) const { - CommInterface comm_interface=_union_group->getCommInterface(); - const MPIProcessorGroup* group = static_cast<const MPIProcessorGroup*>(_union_group); + CommInterface const comm_interface=_union_group->getCommInterface(); + const auto* group = static_cast<const MPIProcessorGroup*>(_union_group); int nbcomp=(int)field.getArray()->getNumberOfComponents(); - double* sendbuf=0; - double* recvbuf=0; + double* sendbuf=nullptr; + double* recvbuf=nullptr; if (_sending_ids.size() >0) sendbuf = new double[_sending_ids.size()*nbcomp]; if (_recv_ids.size()>0) @@ -223,9 +231,9 @@ namespace MEDCoupling recvptr++; } } - if (sendbuf!=0 && getAllToAllMethod()== Native) + if (sendbuf!=nullptr && getAllToAllMethod()== Native) delete[] sendbuf; - if (recvbuf !=0) + if (recvbuf !=nullptr) delete[] recvbuf; delete[] sendcounts; delete[] recvcounts; @@ -243,12 +251,12 @@ namespace MEDCoupling */ void MxN_Mapping::reverseSendRecv(double* recvfield, MEDCouplingFieldDouble& field) const { - CommInterface comm_interface=_union_group->getCommInterface(); - const MPIProcessorGroup* group = static_cast<const MPIProcessorGroup*>(_union_group); + CommInterface const comm_interface=_union_group->getCommInterface(); + const auto* group = static_cast<const MPIProcessorGroup*>(_union_group); int nbcomp=(int)field.getArray()->getNumberOfComponents(); - double* sendbuf=0; - double* recvbuf=0; + double* sendbuf=nullptr; + double* recvbuf=nullptr; if (_recv_ids.size() >0) sendbuf = new double[_recv_ids.size()*nbcomp]; if (_sending_ids.size()>0) @@ -303,9 +311,9 @@ namespace MEDCoupling recvptr++; } } - if (sendbuf!=0 && getAllToAllMethod() == Native) + if (sendbuf!=nullptr && getAllToAllMethod() == Native) delete[] sendbuf; - if (recvbuf!=0) + if (recvbuf!=nullptr) delete[] recvbuf; delete[] sendcounts; delete[] recvcounts; diff --git a/src/ParaMEDMEM/MxN_Mapping.hxx b/src/ParaMEDMEM/MxN_Mapping.hxx index 9f488c24a..1f12d0c22 100644 --- a/src/ParaMEDMEM/MxN_Mapping.hxx +++ b/src/ParaMEDMEM/MxN_Mapping.hxx @@ -20,11 +20,13 @@ #ifndef __MXN_MAPPING_HXX__ #define __MXN_MAPPING_HXX__ +#include "MCType.hxx" +#include "MCAuto.hxx" #include "MEDCouplingFieldDouble.hxx" #include "MPIAccessDEC.hxx" #include "DECOptions.hxx" -#include <vector> +#include <ostream> namespace MEDCoupling { diff --git a/src/ParaMEDMEM/NonCoincidentDEC.cxx b/src/ParaMEDMEM/NonCoincidentDEC.cxx index 70df1fb64..d74986974 100644 --- a/src/ParaMEDMEM/NonCoincidentDEC.cxx +++ b/src/ParaMEDMEM/NonCoincidentDEC.cxx @@ -17,13 +17,12 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +#include <cstddef> #include <mpi.h> -#include "CommInterface.hxx" +#include <string> #include "Topology.hxx" -#include "BlockTopology.hxx" #include "ComponentTopology.hxx" #include "ParaFIELD.hxx" -#include "MPIProcessorGroup.hxx" #include "DEC.hxx" #include "NonCoincidentDEC.hxx" @@ -242,8 +241,7 @@ namespace MEDCoupling } NonCoincidentDEC::NonCoincidentDEC() - { - } + = default; /*! Constructor of a non coincident \ref para-dec "DEC" with * a source group on which lies a field lying on a mesh and a @@ -259,8 +257,7 @@ namespace MEDCoupling {} NonCoincidentDEC::~NonCoincidentDEC() - { - } + = default; /*! Synchronization process. Calling this method * synchronizes the topologies so that the target side @@ -347,7 +344,7 @@ namespace MEDCoupling { int nbelems = _local_field->getField()->getSupport()->getMesh()->getNumberOfElements(MED_EN::MED_CELL, MED_EN::MED_ALL_ELEMENTS); int nbcomp = _local_field->getField()->getNumberOfComponents(); - double* values = new double [nbelems*nbcomp]; + auto* values = new double [nbelems*nbcomp]; fvm_locator_exchange_point_var(_locator, 0, values, @@ -370,7 +367,7 @@ namespace MEDCoupling { const double* values=_local_field->getField()->getValue(); int nbcomp = _local_field->getField()->getNumberOfComponents(); - double* distant_values = new double [_nb_distant_points*nbcomp]; + auto* distant_values = new double [_nb_distant_points*nbcomp]; //cheap interpolation : the value of the cell is transferred to the point for (int i=0; i<_nb_distant_points; i++) diff --git a/src/ParaMEDMEM/NonCoincidentDEC.hxx b/src/ParaMEDMEM/NonCoincidentDEC.hxx index 160ac6c75..95ba91ebf 100644 --- a/src/ParaMEDMEM/NonCoincidentDEC.hxx +++ b/src/ParaMEDMEM/NonCoincidentDEC.hxx @@ -21,6 +21,7 @@ #define __NONCOINCIDENTDEC_HXX__ #include "DEC.hxx" +#include "ProcessorGroup.hxx" struct _fvm_locator_t; @@ -34,9 +35,9 @@ namespace MEDCoupling NonCoincidentDEC(); NonCoincidentDEC(ProcessorGroup& , ProcessorGroup&); - virtual ~NonCoincidentDEC(); + ~NonCoincidentDEC() override; - void synchronize(); + void synchronize() override; void recvData(); diff --git a/src/ParaMEDMEM/OverlapDEC.cxx b/src/ParaMEDMEM/OverlapDEC.cxx index 2bb5cc152..feb10d340 100644 --- a/src/ParaMEDMEM/OverlapDEC.cxx +++ b/src/ParaMEDMEM/OverlapDEC.cxx @@ -20,24 +20,28 @@ #include "OverlapDEC.hxx" #include "CommInterface.hxx" +#include "MCType.hxx" +#include "MEDCouplingMesh.hxx" #include "ParaMESH.hxx" #include "ParaFIELD.hxx" #include "MPIProcessorGroup.hxx" #include "OverlapElementLocator.hxx" #include "OverlapInterpolationMatrix.hxx" #include "ICoCoMEDDoubleField.hxx" +#include <string> +#include <ostream> namespace MEDCoupling { OverlapDEC::OverlapDEC(const std::set<int>& procIds, const MPI_Comm& world_comm): _load_balancing_algo(1), - _own_group(true),_interpolation_matrix(0), _locator(0), + _own_group(true),_interpolation_matrix(nullptr), _locator(nullptr), _default_field_value(0.0), - _source_field(0),_own_source_field(false), - _target_field(0),_own_target_field(false), + _source_field(nullptr),_own_source_field(false), + _target_field(nullptr),_own_target_field(false), _comm(MPI_COMM_NULL) { - MEDCoupling::CommInterface comm; + MEDCoupling::CommInterface const comm; int *ranks_world=new int[procIds.size()]; // ranks of sources and targets in world_comm std::copy(procIds.begin(),procIds.end(),ranks_world); MPI_Group group,world_group; @@ -49,7 +53,7 @@ namespace MEDCoupling comm.groupFree(&world_group); if(_comm==MPI_COMM_NULL) { - _group=0; + _group=nullptr; return ; } std::set<int> idsUnion; @@ -89,7 +93,7 @@ namespace MEDCoupling _locator = nullptr; if (_comm != MPI_COMM_NULL) { - MEDCoupling::CommInterface comm; + MEDCoupling::CommInterface const comm; comm.commFree(&_comm); } _comm = MPI_COMM_NULL; @@ -131,8 +135,8 @@ namespace MEDCoupling _locator->copyOptions(*this); _locator->exchangeMeshes(*_interpolation_matrix); std::vector< std::pair<int,int> > jobs=_locator->getToDoList(); - std::string srcMeth=_locator->getSourceMethod(); - std::string trgMeth=_locator->getTargetMethod(); + std::string const srcMeth=_locator->getSourceMethod(); + std::string const trgMeth=_locator->getTargetMethod(); for(std::vector< std::pair<int,int> >::const_iterator it=jobs.begin();it!=jobs.end();it++) { const MEDCouplingPointSet *src=_locator->getSourceMesh((*it).first); @@ -170,9 +174,9 @@ namespace MEDCoupling if(!isInGroup()) return ; - ParaMESH *paramesh = new ParaMESH(static_cast<MEDCouplingPointSet *>(const_cast<MEDCouplingMesh *>(field->getMesh())), + auto *paramesh = new ParaMESH(static_cast<MEDCouplingPointSet *>(const_cast<MEDCouplingMesh *>(field->getMesh())), *_group,field->getMesh()->getName()); - ParaFIELD *tmpField=new ParaFIELD(field, paramesh, *_group); + auto *tmpField=new ParaFIELD(field, paramesh, *_group); tmpField->setOwnSupport(true); attachSourceLocalField(tmpField,true); } @@ -182,9 +186,9 @@ namespace MEDCoupling if(!isInGroup()) return ; - ParaMESH *paramesh = new ParaMESH(static_cast<MEDCouplingPointSet *>(const_cast<MEDCouplingMesh *>(field->getMesh())), + auto *paramesh = new ParaMESH(static_cast<MEDCouplingPointSet *>(const_cast<MEDCouplingMesh *>(field->getMesh())), *_group,field->getMesh()->getName()); - ParaFIELD *tmpField=new ParaFIELD(field, paramesh, *_group); + auto *tmpField=new ParaFIELD(field, paramesh, *_group); tmpField->setOwnSupport(true); attachTargetLocalField(tmpField,true); } diff --git a/src/ParaMEDMEM/OverlapDEC.hxx b/src/ParaMEDMEM/OverlapDEC.hxx index 923e5e119..c31619034 100644 --- a/src/ParaMEDMEM/OverlapDEC.hxx +++ b/src/ParaMEDMEM/OverlapDEC.hxx @@ -23,9 +23,10 @@ #include "DEC.hxx" #include "InterpolationOptions.hxx" +#include "MEDCouplingFieldDouble.hxx" #include <mpi.h> -#include <string> +#include <ostream> namespace ICoCo { class MEDDoubleField; @@ -237,13 +238,13 @@ namespace MEDCoupling { public: OverlapDEC(const std::set<int>& procIds,const MPI_Comm& world_comm=MPI_COMM_WORLD); - virtual ~OverlapDEC(); + ~OverlapDEC() override; void release(); - void sendRecvData(bool way=true); + void sendRecvData(bool way=true) override; void sendData(); void recvData(); - void synchronize(); + void synchronize() override; void attachSourceLocalField(ParaFIELD *field, bool ownPt=false); void attachTargetLocalField(ParaFIELD *field, bool ownPt=false); void attachSourceLocalField(MEDCouplingFieldDouble *field); diff --git a/src/ParaMEDMEM/OverlapElementLocator.cxx b/src/ParaMEDMEM/OverlapElementLocator.cxx index 4d85fddd2..f0ef74434 100644 --- a/src/ParaMEDMEM/OverlapElementLocator.cxx +++ b/src/ParaMEDMEM/OverlapElementLocator.cxx @@ -21,19 +21,22 @@ #include "OverlapElementLocator.hxx" #include "CommInterface.hxx" +#include "MCType.hxx" +#include "ParaIdType.hxx" +#include "MEDCouplingMesh.hxx" #include "Topology.hxx" -#include "BlockTopology.hxx" #include "ParaFIELD.hxx" #include "ParaMESH.hxx" #include "ProcessorGroup.hxx" #include "MPIProcessorGroup.hxx" #include "OverlapInterpolationMatrix.hxx" -#include "MEDCouplingFieldDouble.hxx" #include "MEDCouplingFieldDiscretization.hxx" -#include "DirectedBoundingBox.hxx" +#include "MEDCouplingFieldDouble.hxx" #include "InterpKernelAutoPtr.hxx" #include <limits> +#include <ostream> +#include <string> using namespace std; @@ -45,9 +48,9 @@ namespace MEDCoupling const ProcessorGroup& group, double epsAbs, int workSharingAlgo) : _local_source_field(sourceField), _local_target_field(targetField), - _local_source_mesh(0), - _local_target_mesh(0), - _domain_bounding_boxes(0), + _local_source_mesh(nullptr), + _local_target_mesh(nullptr), + _domain_bounding_boxes(nullptr), _epsAbs(epsAbs), _group(group) { @@ -80,14 +83,14 @@ namespace MEDCoupling const MPI_Comm *OverlapElementLocator::getCommunicator() const { - const MPIProcessorGroup* group=static_cast<const MPIProcessorGroup*>(&_group); + const auto* group=static_cast<const MPIProcessorGroup*>(&_group); return group->getComm(); } void OverlapElementLocator::computeBoundingBoxesAndInteractionList() { - CommInterface comm_interface=_group.getCommInterface(); - const MPIProcessorGroup* group=static_cast<const MPIProcessorGroup*> (&_group); + CommInterface const comm_interface=_group.getCommInterface(); + const auto* group=static_cast<const MPIProcessorGroup*> (&_group); _local_space_dim=0; if(_local_source_mesh) _local_space_dim=_local_source_mesh->getSpaceDimension(); @@ -95,7 +98,7 @@ namespace MEDCoupling _local_space_dim=_local_target_mesh->getSpaceDimension(); // const MPI_Comm* comm = group->getComm(); - int bbSize=2*2*_local_space_dim;//2 (for source/target) 2 (min/max) + int const bbSize=2*2*_local_space_dim;//2 (for source/target) 2 (min/max) _domain_bounding_boxes=new double[bbSize*_group.size()]; INTERP_KERNEL::AutoPtr<double> minmax=new double[bbSize]; //Format minmax : Xmin_src,Xmax_src,Ymin_src,Ymax_src,Zmin_src,Zmax_src,Xmin_trg,Xmax_trg,Ymin_trg,Ymax_trg,Zmin_trg,Zmax_trg @@ -151,7 +154,7 @@ namespace MEDCoupling //If _group.myRank()==myPair.first, current proc should fetch target mesh of myPair.second (if different from _group.myRank()). //If _group.myRank()==myPair.second, current proc should fetch source mesh of myPair.second. - int myProcId=_group.myRank(); + int const myProcId=_group.myRank(); _to_do_list=_all_todo_lists[myProcId]; #ifdef DEC_DEBUG @@ -293,7 +296,7 @@ namespace MEDCoupling // // Final formatting - extract remaining keys in each map: // - int myProcId = _group.myRank(); + int const myProcId = _group.myRank(); _all_todo_lists.resize(grp_size); procID = 0; for(const auto& itVector: full_set) @@ -326,7 +329,7 @@ namespace MEDCoupling { // Feeding now '_procs_to_send*'. A same id can appears twice. The second parameter in pair means what // to send true=source, false=target - int myProcId=_group.myRank(); + int const myProcId=_group.myRank(); _procs_to_send_mesh.clear(); _procs_to_send_field.clear(); for(int i=0;i<_group.size();i++) @@ -362,7 +365,7 @@ namespace MEDCoupling */ void OverlapElementLocator::exchangeMeshes(OverlapInterpolationMatrix& matrix) { - int myProcId=_group.myRank(); + int const myProcId=_group.myRank(); //starting to receive every procs whose id is lower than myProcId. std::vector<Proc_SrcOrTgt> firstRcv, secondRcv; for (const ProcCouple& pc: _to_do_list) @@ -407,7 +410,7 @@ namespace MEDCoupling const MEDCouplingPointSet *OverlapElementLocator::getSourceMesh(int procId) const { - int myProcId=_group.myRank(); + int const myProcId=_group.myRank(); if(myProcId==procId) return _local_source_mesh; Proc_SrcOrTgt p(procId,true); @@ -417,9 +420,9 @@ namespace MEDCoupling const DataArrayIdType *OverlapElementLocator::getSourceIds(int procId) const { - int myProcId=_group.myRank(); + int const myProcId=_group.myRank(); if(myProcId==procId) - return 0; + return nullptr; Proc_SrcOrTgt p(procId,true); std::map<Proc_SrcOrTgt, AutoDAInt >::const_iterator it=_remote_elems.find(p); return (*it).second; @@ -427,7 +430,7 @@ namespace MEDCoupling const MEDCouplingPointSet *OverlapElementLocator::getTargetMesh(int procId) const { - int myProcId=_group.myRank(); + int const myProcId=_group.myRank(); if(myProcId==procId) return _local_target_mesh; Proc_SrcOrTgt p(procId,false); @@ -437,9 +440,9 @@ namespace MEDCoupling const DataArrayIdType *OverlapElementLocator::getTargetIds(int procId) const { - int myProcId=_group.myRank(); + int const myProcId=_group.myRank(); if(myProcId==procId) - return 0; + return nullptr; Proc_SrcOrTgt p(procId,false); std::map<Proc_SrcOrTgt, AutoDAInt >::const_iterator it=_remote_elems.find(p); return (*it).second; @@ -458,7 +461,7 @@ namespace MEDCoupling for (int idim=0; idim < _local_space_dim; idim++) { - bool intersects = (target_bb[idim*2]<source_bb[idim*2+1]+_epsAbs) + bool const intersects = (target_bb[idim*2]<source_bb[idim*2+1]+_epsAbs) && (source_bb[idim*2]<target_bb[idim*2+1]+_epsAbs); if (!intersects) return false; @@ -483,9 +486,9 @@ namespace MEDCoupling #endif //int myProcId=_group.myRank(); - const double *distant_bb=0; - MEDCouplingPointSet *local_mesh=0; - const ParaFIELD *field=0; + const double *distant_bb=nullptr; + MEDCouplingPointSet *local_mesh=nullptr; + const ParaFIELD *field=nullptr; if(sourceOrTarget)//source for local mesh but target for distant mesh { distant_bb=_domain_bounding_boxes+procId*2*2*_local_space_dim+2*_local_space_dim; @@ -500,7 +503,7 @@ namespace MEDCoupling } AutoDAInt elems=local_mesh->getCellsInBoundingBox(distant_bb,getBoundingBoxAdjustment()); DataArrayIdType *old2new_map; - MEDCouplingPointSet *send_mesh=static_cast<MEDCouplingPointSet *>(field->getField()->buildSubMeshData(elems->begin(),elems->end(),old2new_map)); + auto *send_mesh=static_cast<MEDCouplingPointSet *>(field->getField()->buildSubMeshData(elems->begin(),elems->end(),old2new_map)); if(sourceOrTarget) matrix.keepTracksOfSourceIds(procId,old2new_map); else @@ -523,8 +526,8 @@ namespace MEDCoupling scout << "(" << rank << ") RCV part of " << st << " FROM: " << procId; std::cout << scout.str() << "\n"; #endif - DataArrayIdType *old2new_map=0; - MEDCouplingPointSet *m=0; + DataArrayIdType *old2new_map=nullptr; + MEDCouplingPointSet *m=nullptr; receiveMesh(procId,m,old2new_map); Proc_SrcOrTgt p(procId,sourceOrTarget); _remote_meshes[p]=m; @@ -533,7 +536,7 @@ namespace MEDCoupling void OverlapElementLocator::sendMesh(int procId, const MEDCouplingPointSet *mesh, const DataArrayIdType *idsToSend) const { - CommInterface comInterface=_group.getCommInterface(); + CommInterface const comInterface=_group.getCommInterface(); // First stage : exchanging sizes vector<double> tinyInfoLocalD;//tinyInfoLocalD not used for the moment @@ -548,8 +551,8 @@ namespace MEDCoupling comInterface.send(&lgth,2,MPI_ID_TYPE,procId,START_TAG_MESH_XCH,*_comm); comInterface.send(&tinyInfoLocal[0],(int)tinyInfoLocal.size(),MPI_ID_TYPE,procId,START_TAG_MESH_XCH+1,*comm); // - DataArrayIdType *v1Local=0; - DataArrayDouble *v2Local=0; + DataArrayIdType *v1Local=nullptr; + DataArrayDouble *v2Local=nullptr; mesh->serialize(v1Local,v2Local); comInterface.send(v1Local->getPointer(),(int)v1Local->getNbOfElems(),MPI_ID_TYPE,procId,START_TAG_MESH_XCH+2,*comm); comInterface.send(v2Local->getPointer(),(int)v2Local->getNbOfElems(),MPI_DOUBLE,procId,START_TAG_MESH_XCH+3,*comm); @@ -565,7 +568,7 @@ namespace MEDCoupling mcIdType lgth[2]; MPI_Status status; const MPI_Comm *comm=getCommunicator(); - CommInterface comInterface=_group.getCommInterface(); + CommInterface const comInterface=_group.getCommInterface(); comInterface.recv(lgth,2,MPI_ID_TYPE,procId,START_TAG_MESH_XCH,*_comm,&status); std::vector<mcIdType> tinyInfoDistant(lgth[0]); ids=DataArrayIdType::New(); diff --git a/src/ParaMEDMEM/OverlapElementLocator.hxx b/src/ParaMEDMEM/OverlapElementLocator.hxx index 5d44c2ff9..c10c7909f 100644 --- a/src/ParaMEDMEM/OverlapElementLocator.hxx +++ b/src/ParaMEDMEM/OverlapElementLocator.hxx @@ -22,15 +22,14 @@ #define __OVERLAPELEMENTLOCATOR_HXX__ #include "InterpolationOptions.hxx" -#include "MEDCouplingNatureOfField.hxx" +#include "MCType.hxx" #include "MEDCouplingPointSet.hxx" -#include "MEDCouplingMemArray.hxx" #include "MCAuto.hxx" #include <mpi.h> -#include <vector> -#include <map> -#include <set> +#include <utility> +#include <string> +#include <ostream> //#define DEC_DEBUG @@ -40,7 +39,7 @@ namespace MEDCoupling class ProcessorGroup; class OverlapInterpolationMatrix; - typedef std::pair<int,int> ProcCouple; // a couple of proc IDs, typically used to define a exchange betw 2 procs + using ProcCouple = std::pair<int, int>; // a couple of proc IDs, typically used to define a exchange betw 2 procs class OverlapElementLocator : public INTERP_KERNEL::InterpolationOptions { @@ -71,9 +70,9 @@ namespace MEDCoupling void sendMesh(int procId, const MEDCouplingPointSet *mesh, const DataArrayIdType *idsToSend) const; void receiveMesh(int procId, MEDCouplingPointSet* &mesh, DataArrayIdType *&ids) const; private: - typedef MCAuto< MEDCouplingPointSet > AutoMCPointSet; - typedef MCAuto< DataArrayIdType > AutoDAInt; - typedef std::pair<int,bool> Proc_SrcOrTgt; ///< a key indicating a proc ID and whether the data is for source mesh/field or target mesh/field + using AutoMCPointSet = MCAuto<MEDCouplingPointSet>; + using AutoDAInt = MCAuto<DataArrayInt64>; + using Proc_SrcOrTgt = std::pair<int, bool>; ///< a key indicating a proc ID and whether the data is for source mesh/field or target mesh/field static const int START_TAG_MESH_XCH; diff --git a/src/ParaMEDMEM/OverlapInterpolationMatrix.cxx b/src/ParaMEDMEM/OverlapInterpolationMatrix.cxx index 00b64df0c..21bc60160 100644 --- a/src/ParaMEDMEM/OverlapInterpolationMatrix.cxx +++ b/src/ParaMEDMEM/OverlapInterpolationMatrix.cxx @@ -19,27 +19,30 @@ // Author : Anthony Geay (CEA/DEN) #include "OverlapInterpolationMatrix.hxx" +#include "DECOptions.hxx" +#include "OverlapElementLocator.hxx" +#include "MCType.hxx" +#include "MEDCouplingNormalizedUnstructuredMesh.txx" +#include "Interpolation2D.hxx" +#include "Interpolation3D.hxx" +#include "Interpolation2D3D.hxx" +#include "Interpolation2D1D.hxx" +#include "Interpolation1D.hxx" +#include "MEDCouplingNatureOfFieldEnum" #include "ParaMESH.hxx" #include "ParaFIELD.hxx" #include "ProcessorGroup.hxx" -#include "TranslationRotationMatrix.hxx" -#include "Interpolation.hxx" -#include "Interpolation1D.txx" #include "Interpolation2DCurve.hxx" -#include "Interpolation2D.txx" #include "Interpolation3DSurf.hxx" #include "Interpolation3D.txx" #include "Interpolation2D3D.txx" #include "Interpolation2D1D.txx" #include "MEDCouplingUMesh.hxx" -#include "MEDCouplingFieldDouble.hxx" -#include "MEDCouplingNormalizedUnstructuredMesh.txx" #include "InterpolationOptions.hxx" -#include "NormalizedUnstructuredMesh.hxx" #include "ElementLocator.hxx" -#include "InterpKernelAutoPtr.hxx" +#include "MEDCouplingFieldDouble.hxx" -#include <algorithm> +#include <string> using namespace std; @@ -72,8 +75,7 @@ namespace MEDCoupling } OverlapInterpolationMatrix::~OverlapInterpolationMatrix() - { - } + = default; // TODO? Merge with MEDCouplingRemapper::prepareInterpKernelOnlyUU() ? /**! @@ -93,8 +95,8 @@ namespace MEDCoupling vector<SparseDoubleVec > sparse_matrix_part; mcIdType colSize=0; //computation of the intersection volumes between source and target elements - const MEDCouplingUMesh *trgC=dynamic_cast<const MEDCouplingUMesh *>(trg); - const MEDCouplingUMesh *srcC=dynamic_cast<const MEDCouplingUMesh *>(src); + const auto *trgC=dynamic_cast<const MEDCouplingUMesh *>(trg); + const auto *srcC=dynamic_cast<const MEDCouplingUMesh *>(src); if ( src->getMeshDimension() == -1 ) { if(trgC->getMeshDimension()==2 && trgC->getSpaceDimension()==2) diff --git a/src/ParaMEDMEM/OverlapInterpolationMatrix.hxx b/src/ParaMEDMEM/OverlapInterpolationMatrix.hxx index 690e1120d..db8f1f28b 100644 --- a/src/ParaMEDMEM/OverlapInterpolationMatrix.hxx +++ b/src/ParaMEDMEM/OverlapInterpolationMatrix.hxx @@ -21,10 +21,12 @@ #ifndef __OVERLAPINTERPOLATIONMATRIX_HXX__ #define __OVERLAPINTERPOLATIONMATRIX_HXX__ -#include "MPIAccessDEC.hxx" +#include "MCType.hxx" +#include "OverlapElementLocator.hxx" #include "OverlapMapping.hxx" #include "InterpolationOptions.hxx" #include "DECOptions.hxx" +#include <string> namespace MEDCoupling { diff --git a/src/ParaMEDMEM/OverlapMapping.cxx b/src/ParaMEDMEM/OverlapMapping.cxx index 051ad3043..4b512d063 100644 --- a/src/ParaMEDMEM/OverlapMapping.cxx +++ b/src/ParaMEDMEM/OverlapMapping.cxx @@ -19,14 +19,19 @@ // Author : Anthony Geay (CEA/DEN) #include "OverlapMapping.hxx" +#include "MCType.hxx" +#include "MEDCouplingMemArray.hxx" +#include "MCIdType.hxx" #include "MPIProcessorGroup.hxx" #include "MEDCouplingFieldDouble.hxx" #include "MCAuto.hxx" #include "InterpKernelAutoPtr.hxx" +#include "OverlapElementLocator.hxx" +#include "ParaIdType.hxx" -#include <numeric> +#include <cstddef> #include <algorithm> using namespace MEDCoupling; @@ -64,7 +69,7 @@ void OverlapMapping::keepTracksOfTargetIds(int procId, DataArrayIdType *ids) * * One of the 2 is necessarily null (the two can be null together) */ -void OverlapMapping::addContributionST(const std::vector< SparseDoubleVec >& matrixST, const DataArrayIdType *srcIds, int srcProcId, const DataArrayIdType *trgIds, int trgProcId) +void OverlapMapping::addContributionST(const std::vector< SparseDoubleVec >& matrixST, const DataArrayIdType *srcIds, int srcProcId, const DataArrayIdType * /*trgIds*/, int trgProcId) { _matrixes_st.push_back(matrixST); _source_proc_id_st.push_back(srcProcId); @@ -97,15 +102,15 @@ void OverlapMapping::prepare(const std::vector< int >& procsToSendField, mcIdTyp printMatrixesST(); #endif - CommInterface commInterface=_group.getCommInterface(); - const MPIProcessorGroup *group=static_cast<const MPIProcessorGroup*>(&_group); + CommInterface const commInterface=_group.getCommInterface(); + const auto *group=static_cast<const MPIProcessorGroup*>(&_group); const MPI_Comm *comm=group->getComm(); std::size_t grpSize=_group.size(); INTERP_KERNEL::AutoPtr<mcIdType> nbsend=new mcIdType[grpSize]; INTERP_KERNEL::AutoPtr<int> nbsend2=new int[grpSize]; INTERP_KERNEL::AutoPtr<int> nbsend3=new int[grpSize]; std::fill<mcIdType *>(nbsend,nbsend+grpSize,0); - int myProcId=_group.myRank(); + int const myProcId=_group.myRank(); for(std::size_t i=0;i<_matrixes_st.size();i++) if(_source_proc_id_st[i]==myProcId) nbsend[_target_proc_id_st[i]]=(int)_matrixes_st[i].size(); @@ -116,7 +121,7 @@ void OverlapMapping::prepare(const std::vector< int >& procsToSendField, mcIdTyp INTERP_KERNEL::AutoPtr<int> nbrecv1=new int[grpSize]; INTERP_KERNEL::AutoPtr<int> nbrecv2=new int[grpSize]; // - mcIdType *tmp=0; + mcIdType *tmp=nullptr; serializeMatrixStep0ST(nbrecv, tmp,nbsend2,nbsend3, nbrecv1,nbrecv2); @@ -129,7 +134,7 @@ void OverlapMapping::prepare(const std::vector< int >& procsToSendField, mcIdTyp std::fill<int *>(nbsend2,nbsend2+grpSize,0); INTERP_KERNEL::AutoPtr<int> nbrecv3=new int[grpSize]; INTERP_KERNEL::AutoPtr<int> nbrecv4=new int[grpSize]; - double *tmp2=0; + double *tmp2=nullptr; mcIdType lgthOfArr=serializeMatrixStep1ST(nbrecv,bigArrRecv,nbrecv1,nbrecv2, tmp,tmp2, nbsend2,nbsend3,nbrecv3,nbrecv4); @@ -240,7 +245,7 @@ void OverlapMapping::computeDenoRevIntegral(const DataArrayDouble & targetAreas) */ void OverlapMapping::computeDenoConservativeVolumic(mcIdType nbOfTuplesTrg) { - int myProcId=_group.myRank(); + int const myProcId=_group.myRank(); // _the_deno_st.clear(); std::size_t sz1=_the_matrix_st.size(); @@ -305,10 +310,10 @@ void OverlapMapping::computeDenoConservativeVolumic(mcIdType nbOfTuplesTrg) void OverlapMapping::serializeMatrixStep0ST(const mcIdType *nbOfElemsSrc, mcIdType *&bigArr, int *count, int *offsets, int *countForRecv, int *offsetsForRecv) const { - std::size_t grpSize=_group.size(); + std::size_t const grpSize=_group.size(); std::fill<int *>(count,count+grpSize,0); std::size_t szz=0; - int myProcId=_group.myRank(); + int const myProcId=_group.myRank(); for(std::size_t i=0;i<_matrixes_st.size();i++) { if(_source_proc_id_st[i]==myProcId && _matrixes_st[i].size())// && _target_proc_id_st[i]!=myProcId @@ -350,12 +355,12 @@ void OverlapMapping::serializeMatrixStep0ST(const mcIdType *nbOfElemsSrc, mcIdTy * This method performs step#1 and step#2/3. It returns the size of expected array to get allToAllV. * It is where the locally computed matrices are serialized to be sent to adequate final proc. */ -mcIdType OverlapMapping::serializeMatrixStep1ST(const mcIdType *nbOfElemsSrc, const mcIdType *recvStep0, const int *countStep0, const int *offsStep0, +mcIdType OverlapMapping::serializeMatrixStep1ST(const mcIdType *nbOfElemsSrc, const mcIdType *recvStep0, const int * /*countStep0*/, const int *offsStep0, mcIdType *&bigArrI, double *&bigArrD, int *count, int *offsets, int *countForRecv, int *offsForRecv) const { - std::size_t grpSize=_group.size(); - int myProcId=_group.myRank(); + std::size_t const grpSize=_group.size(); + int const myProcId=_group.myRank(); offsForRecv[0]=0; mcIdType szz=0; for(std::size_t i=0;i<grpSize;i++) @@ -418,15 +423,15 @@ mcIdType OverlapMapping::serializeMatrixStep1ST(const mcIdType *nbOfElemsSrc, co * - The second is the pseudo id of source proc (correspondence with true id is in attribute _the_matrix_st_source_proc_id and _the_matrix_st_source_ids) * - the third is the srcId in the pseudo source proc */ -void OverlapMapping::unserializationST(mcIdType nbOfTrgElems, +void OverlapMapping::unserializationST(mcIdType /*nbOfTrgElems*/, const mcIdType *nbOfElemsSrcPerProc,//first all2all - const mcIdType *bigArrRecv, const int *bigArrRecvCounts, const int *bigArrRecvOffs,//2nd all2all - const mcIdType *bigArrRecv2, const double *bigArrDRecv2, const int *bigArrRecv2Count, const int *bigArrRecv2Offs)//3rd and 4th all2alls + const mcIdType *bigArrRecv, const int * /*bigArrRecvCounts*/, const int *bigArrRecvOffs,//2nd all2all + const mcIdType *bigArrRecv2, const double *bigArrDRecv2, const int * /*bigArrRecv2Count*/, const int *bigArrRecv2Offs)//3rd and 4th all2alls { _the_matrix_st.clear(); _the_matrix_st_source_proc_id.clear(); // - std::size_t grpSize=_group.size(); + std::size_t const grpSize=_group.size(); for(unsigned int i=0;i<grpSize;i++) if(nbOfElemsSrcPerProc[i]!=0) _the_matrix_st_source_proc_id.push_back(i); @@ -440,8 +445,8 @@ void OverlapMapping::unserializationST(mcIdType nbOfTrgElems, _the_matrix_st[j].resize(nbOfElemsSrcPerProc[i]); for(mcIdType k=0;k<nbOfElemsSrcPerProc[i];k++) { - mcIdType offs=bigArrRecv[bigArrRecvOffs[i]+k]; - mcIdType lgthOfMap=bigArrRecv[bigArrRecvOffs[i]+k+1]-offs; + mcIdType const offs=bigArrRecv[bigArrRecvOffs[i]+k]; + mcIdType const lgthOfMap=bigArrRecv[bigArrRecvOffs[i]+k+1]-offs; for(mcIdType l=0;l<lgthOfMap;l++) _the_matrix_st[j][k][bigArrRecv2[bigArrRecv2Offs[i]+offs+l]]=bigArrDRecv2[bigArrRecv2Offs[i]+offs+l]; } @@ -457,7 +462,7 @@ void OverlapMapping::unserializationST(mcIdType nbOfTrgElems, */ void OverlapMapping::finishToFillFinalMatrixST() { - int myProcId=_group.myRank(); + int const myProcId=_group.myRank(); std::size_t sz=_matrixes_st.size(); int nbOfEntryToAdd=0; for(std::size_t i=0;i<sz;i++) @@ -466,7 +471,7 @@ void OverlapMapping::finishToFillFinalMatrixST() if(nbOfEntryToAdd==0) return ; std::size_t oldNbOfEntry=_the_matrix_st.size(); - std::size_t newNbOfEntry=oldNbOfEntry+nbOfEntryToAdd; + std::size_t const newNbOfEntry=oldNbOfEntry+nbOfEntryToAdd; _the_matrix_st.resize(newNbOfEntry); std::size_t j=oldNbOfEntry; for(std::size_t i=0;i<sz;i++) @@ -489,11 +494,11 @@ void OverlapMapping::multiply(const MEDCouplingFieldDouble *fieldInput, MEDCoupl using namespace std; std::size_t nbOfCompo=fieldInput->getNumberOfComponents();//to improve same number of components to test - CommInterface commInterface=_group.getCommInterface(); - const MPIProcessorGroup *group=static_cast<const MPIProcessorGroup*>(&_group); + CommInterface const commInterface=_group.getCommInterface(); + const auto *group=static_cast<const MPIProcessorGroup*>(&_group); const MPI_Comm *comm=group->getComm(); int grpSize=_group.size(); - int myProcID=_group.myRank(); + int const myProcID=_group.myRank(); // INTERP_KERNEL::AutoPtr<int> nbsend=new int[grpSize]; INTERP_KERNEL::AutoPtr<int> nbsend2=new int[grpSize]; @@ -619,7 +624,7 @@ void OverlapMapping::multiply(const MEDCouplingFieldDouble *fieldInput, MEDCoupl INTERP_KERNEL::AutoPtr<double> tmp=new double[nbOfCompo]; // By default field value set to default value - so mark which cells are hit - mcIdType ntup = fieldOutput->getNumberOfTuples(); + mcIdType const ntup = fieldOutput->getNumberOfTuples(); INTERP_KERNEL::AutoPtr<bool> hit_cells = new bool[ntup]; std::fill((bool *)hit_cells, (bool *)hit_cells+ntup, false); @@ -778,8 +783,8 @@ void OverlapMapping::fillSourceIdsZipReceivedForMultiply() /* When it is called, only the bits received from other processors (i.e. the remotely executed jobs) are in the big matrix _the_matrix_st. */ - CommInterface commInterface=_group.getCommInterface(); - int myProcId=_group.myRank(); + CommInterface const commInterface=_group.getCommInterface(); + int const myProcId=_group.myRank(); std::size_t nbOfMatrixRecveived=_the_matrix_st_source_proc_id.size(); for(std::size_t i=0;i<nbOfMatrixRecveived;i++) { diff --git a/src/ParaMEDMEM/OverlapMapping.hxx b/src/ParaMEDMEM/OverlapMapping.hxx index b3b0e6d97..688408320 100644 --- a/src/ParaMEDMEM/OverlapMapping.hxx +++ b/src/ParaMEDMEM/OverlapMapping.hxx @@ -21,11 +21,13 @@ #ifndef __OVERLAPMAPPING_HXX__ #define __OVERLAPMAPPING_HXX__ -#include "MCAuto.hxx" +#include "MCType.hxx" +#include "MEDCouplingMemArray.hxx" #include "OverlapElementLocator.hxx" #include <vector> #include <map> + //#define DEC_DEBUG namespace MEDCoupling diff --git a/src/ParaMEDMEM/ParaDataArray.cxx b/src/ParaMEDMEM/ParaDataArray.cxx index 54b82215f..7bd2249c0 100644 --- a/src/ParaMEDMEM/ParaDataArray.cxx +++ b/src/ParaMEDMEM/ParaDataArray.cxx @@ -19,6 +19,8 @@ // Author : Anthony Geay (EDF R&D) #include "ParaDataArray.txx" +#include "MCType.hxx" +#include "MEDCouplingMemArray.hxx" using namespace MEDCoupling; diff --git a/src/ParaMEDMEM/ParaDataArray.hxx b/src/ParaMEDMEM/ParaDataArray.hxx index ac8516443..107612848 100644 --- a/src/ParaMEDMEM/ParaDataArray.hxx +++ b/src/ParaMEDMEM/ParaDataArray.hxx @@ -20,7 +20,14 @@ #pragma once +#include "MCAuto.hxx" +#include "MCType.hxx" #include "MEDCouplingMemArray.hxx" +#include "MEDCouplingRefCountObject.hxx" +#include "MEDCouplingTraits.hxx" +#include <cstddef> +#include <vector> +#include <string> namespace MEDCoupling { diff --git a/src/ParaMEDMEM/ParaDataArray.txx b/src/ParaMEDMEM/ParaDataArray.txx index d8cdbfc0c..232c7c8ac 100644 --- a/src/ParaMEDMEM/ParaDataArray.txx +++ b/src/ParaMEDMEM/ParaDataArray.txx @@ -20,11 +20,17 @@ #pragma once +#include "MEDCouplingTraits.hxx" +#include "MCType.hxx" +#include "MEDCouplingMemArray.txx" +#include "MCAuto.hxx" #include "ParaDataArray.hxx" #include "CommInterface.hxx" -#include "MEDCouplingMemArray.txx" +#include <cstddef> +#include <limits> #include <sstream> +#include <string> namespace MEDCoupling { diff --git a/src/ParaMEDMEM/ParaFIELD.cxx b/src/ParaMEDMEM/ParaFIELD.cxx index f90fe3444..c4b396180 100644 --- a/src/ParaMEDMEM/ParaFIELD.cxx +++ b/src/ParaMEDMEM/ParaFIELD.cxx @@ -17,6 +17,10 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +#include "MEDCouplingRefCountObject.hxx" +#include "MEDCouplingMemArray.hxx" +#include "DisjointDEC.hxx" +#include "MCType.hxx" #include "Topology.hxx" #include "BlockTopology.hxx" #include "ComponentTopology.hxx" @@ -28,9 +32,7 @@ #include "ParaFIELD.hxx" #include "ParaMESH.hxx" #include "InterpKernelUtilities.hxx" -#include "InterpolationMatrix.hxx" -#include <numeric> namespace MEDCoupling { @@ -68,13 +70,13 @@ namespace MEDCoupling */ ParaFIELD::ParaFIELD(TypeOfField type, TypeOfTimeDiscretization td, ParaMESH* para_support, const ComponentTopology& component_topology) - :_field(0), - _component_topology(component_topology),_topology(0),_own_support(false), + :_field(nullptr), + _component_topology(component_topology),_topology(nullptr),_own_support(false), _support(para_support) { if (para_support->isStructured() || (para_support->getTopology()->getProcGroup()->size()==1 && component_topology.nbBlocks()!=1)) { - const BlockTopology* source_topo = dynamic_cast<const BlockTopology*>(para_support->getTopology()); + const auto* source_topo = dynamic_cast<const BlockTopology*>(para_support->getTopology()); _topology=new BlockTopology(*source_topo,component_topology); } else @@ -83,12 +85,12 @@ namespace MEDCoupling throw INTERP_KERNEL::Exception(LOCALIZED("ParaFIELD constructor : Unstructured Support not taken into account with component topology yet")); else { - const BlockTopology* source_topo=dynamic_cast<const BlockTopology*> (para_support->getTopology()); - int nb_local_comp=component_topology.nbLocalComponents(); + const auto* source_topo=dynamic_cast<const BlockTopology*> (para_support->getTopology()); + int const nb_local_comp=component_topology.nbLocalComponents(); _topology=new BlockTopology(*source_topo,nb_local_comp); } } - int nb_components = component_topology.nbLocalComponents(); + int const nb_components = component_topology.nbLocalComponents(); if (nb_components!=0) { _field=MEDCouplingFieldDouble::New(type,td); @@ -110,14 +112,14 @@ namespace MEDCoupling This constructor supposes that support underlying \a subdomain_field has no ParaMESH attached and it therefore recreates one. It therefore takes ownership over _support. The component topology associated with the field is a basic one (all components on the same processor). */ - ParaFIELD::ParaFIELD(MEDCouplingFieldDouble* subdomain_field, ParaMESH *sup, const ProcessorGroup& proc_group): + ParaFIELD::ParaFIELD(MEDCouplingFieldDouble* subdomain_field, ParaMESH *sup, const ProcessorGroup& /*proc_group*/): _field(subdomain_field), - _component_topology(ComponentTopology((int)_field->getNumberOfComponents())),_topology(0),_own_support(false), + _component_topology(ComponentTopology((int)_field->getNumberOfComponents())),_topology(nullptr),_own_support(false), _support(sup) { if(_field) _field->incrRef(); - const BlockTopology* source_topo=dynamic_cast<const BlockTopology*> (_support->getTopology()); + const auto* source_topo=dynamic_cast<const BlockTopology*> (_support->getTopology()); _topology=new BlockTopology(*source_topo,_component_topology.nbLocalComponents()); } @@ -146,10 +148,10 @@ namespace MEDCoupling _topology = nullptr; } - void ParaFIELD::synchronizeTarget(ParaFIELD* source_field) + void ParaFIELD::synchronizeTarget(ParaFIELD* /*source_field*/) { DisjointDEC* data_channel; - if (dynamic_cast<BlockTopology*>(_topology)!=0) + if (dynamic_cast<BlockTopology*>(_topology)!=nullptr) { data_channel=new StructuredCoincidentDEC; } @@ -165,10 +167,10 @@ namespace MEDCoupling delete data_channel; } - void ParaFIELD::synchronizeSource(ParaFIELD* target_field) + void ParaFIELD::synchronizeSource(ParaFIELD* /*target_field*/) { DisjointDEC* data_channel; - if (dynamic_cast<BlockTopology*>(_topology)!=0) + if (dynamic_cast<BlockTopology*>(_topology)!=nullptr) { data_channel=new StructuredCoincidentDEC; } @@ -193,24 +195,24 @@ namespace MEDCoupling DataArrayIdType* ParaFIELD::returnCumulativeGlobalNumbering() const { if(!_field) - return 0; - TypeOfField type=_field->getTypeOfField(); + return nullptr; + TypeOfField const type=_field->getTypeOfField(); switch(type) { case ON_CELLS: - return 0; + return nullptr; case ON_NODES: return _support->getGlobalNumberingNodeDA(); default: - return 0; + return nullptr; } } DataArrayIdType* ParaFIELD::returnGlobalNumbering() const { if(!_field) - return 0; - TypeOfField type=_field->getTypeOfField(); + return nullptr; + TypeOfField const type=_field->getTypeOfField(); switch(type) { case ON_CELLS: @@ -218,7 +220,7 @@ namespace MEDCoupling case ON_NODES: return _support->getGlobalNumberingNodeDA(); default: - return 0; + return nullptr; } } @@ -232,7 +234,7 @@ namespace MEDCoupling over the all domain. */ double ParaFIELD::getVolumeIntegral(int icomp, bool isWAbs) const { - CommInterface comm_interface = _topology->getProcGroup()->getCommInterface(); + CommInterface const comm_interface = _topology->getProcGroup()->getCommInterface(); double integral=_field->integral(icomp,isWAbs); double total=0.; const MPI_Comm* comm = (dynamic_cast<const MPIProcessorGroup*>(_topology->getProcGroup()))->getComm(); diff --git a/src/ParaMEDMEM/ParaGRID.cxx b/src/ParaMEDMEM/ParaGRID.cxx index 7ea1d0385..d1b5a7c86 100644 --- a/src/ParaMEDMEM/ParaGRID.cxx +++ b/src/ParaMEDMEM/ParaGRID.cxx @@ -20,11 +20,9 @@ #include "ParaGRID.hxx" #include "Topology.hxx" #include "BlockTopology.hxx" -#include "MEDCouplingMemArray.hxx" #include "MEDCouplingCMesh.hxx" #include "InterpKernelUtilities.hxx" -#include <iostream> using namespace std; @@ -35,13 +33,13 @@ namespace MEDCoupling _global_axis() { _block_topology = dynamic_cast<BlockTopology*>(topology); - if(_block_topology==0) + if(_block_topology==nullptr) throw INTERP_KERNEL::Exception(LOCALIZED("ParaGRID::ParaGRID topology must be block topology")); if (!_block_topology->getProcGroup()->containsMyRank()) return; - int dimension=_block_topology->getDimension() ; + int const dimension=_block_topology->getDimension() ; if (dimension != global_grid->getSpaceDimension()) throw INTERP_KERNEL::Exception(LOCALIZED("ParaGrid::ParaGrid incompatible topology")); _grid=global_grid; diff --git a/src/ParaMEDMEM/ParaGRID.hxx b/src/ParaMEDMEM/ParaGRID.hxx index 3bc60afda..372a51446 100644 --- a/src/ParaMEDMEM/ParaGRID.hxx +++ b/src/ParaMEDMEM/ParaGRID.hxx @@ -20,7 +20,6 @@ #ifndef __PARAGRID_HXX__ #define __PARAGRID_HXX__ -#include "InterpolationUtils.hxx" #include <vector> diff --git a/src/ParaMEDMEM/ParaMESH.cxx b/src/ParaMEDMEM/ParaMESH.cxx index 92965d4c2..f89e3f705 100644 --- a/src/ParaMEDMEM/ParaMESH.cxx +++ b/src/ParaMEDMEM/ParaMESH.cxx @@ -19,14 +19,13 @@ // #include "ParaMESH.hxx" +#include "MEDCouplingPointSet.hxx" +#include "MCType.hxx" #include "ProcessorGroup.hxx" -#include "MPIProcessorGroup.hxx" #include "Topology.hxx" #include "BlockTopology.hxx" -#include "MEDCouplingMemArray.hxx" -#include <fstream> -#include <vector> +#include <string> //inclusion for the namespaces using namespace std; @@ -47,14 +46,14 @@ namespace MEDCoupling _cell_global.takeRef(CorrespElt_local2global); } - ParaMESH::ParaMESH( MEDCouplingPointSet *mesh, const ProcessorGroup& proc_group, const std::string& name): + ParaMESH::ParaMESH( MEDCouplingPointSet *mesh, const ProcessorGroup& proc_group, const std::string& /*name*/): _my_domain_id(proc_group.myRank()), _block_topology(new BlockTopology(proc_group, mesh->getNumberOfCells())) { _cell_mesh.takeRef(mesh); - mcIdType nb_elem=mesh->getNumberOfCells(); + mcIdType const nb_elem=mesh->getNumberOfCells(); _explicit_topology=new BlockTopology(proc_group,nb_elem); - mcIdType nbOfCells=mesh->getNumberOfCells(); + mcIdType const nbOfCells=mesh->getNumberOfCells(); _cell_global = DataArrayIdType::New(); _cell_global->alloc(nbOfCells,1); mcIdType *cellglobal=_cell_global->getPointer(); diff --git a/src/ParaMEDMEM/ParaMESH.hxx b/src/ParaMEDMEM/ParaMESH.hxx index ab9cb5f3b..2c5b99560 100644 --- a/src/ParaMEDMEM/ParaMESH.hxx +++ b/src/ParaMEDMEM/ParaMESH.hxx @@ -19,12 +19,12 @@ #pragma once +#include "MCType.hxx" +#include "MCAuto.hxx" #include "MEDCouplingPointSet.hxx" #include "ProcessorGroup.hxx" -#include "MEDCouplingMemArray.hxx" #include <string> -#include <vector> namespace MEDCoupling { diff --git a/src/ParaMEDMEM/ParaSkyLineArray.cxx b/src/ParaMEDMEM/ParaSkyLineArray.cxx index d8d6da424..93da4bd78 100644 --- a/src/ParaMEDMEM/ParaSkyLineArray.cxx +++ b/src/ParaMEDMEM/ParaSkyLineArray.cxx @@ -20,20 +20,17 @@ // Author : Anthony Geay (EDF R&D) #include "ParaSkyLineArray.hxx" -#include "ProcessorGroup.hxx" +#include "MEDCouplingSkyLineArray.hxx" +#include "MCType.hxx" +#include "MCAuto.hxx" #include "MPIProcessorGroup.hxx" -#include "Topology.hxx" -#include "BlockTopology.hxx" #include "CommInterface.hxx" #include "MEDCouplingMemArray.hxx" #include "mpi.h" -#include <fstream> +#include <cstddef> #include <sstream> -#include <numeric> -#include <memory> -#include <vector> using namespace MEDCoupling; @@ -78,7 +75,7 @@ std::vector<const BigMemoryObject *> ParaSkyLineArray::getDirectChildrenWithNull MCAuto<ParaSkyLineArray> ParaSkyLineArray::equiRedistribute(mcIdType nbOfEntities) const { MPI_Comm comm(MPI_COMM_WORLD); - CommInterface ci; + CommInterface const ci; int size; ci.commSize(comm,&size); std::vector< MCAuto<MEDCouplingSkyLineArray> > skToBeSent(size); diff --git a/src/ParaMEDMEM/ParaSkyLineArray.hxx b/src/ParaMEDMEM/ParaSkyLineArray.hxx index 0f6abf7bf..7c08e5a50 100644 --- a/src/ParaMEDMEM/ParaSkyLineArray.hxx +++ b/src/ParaMEDMEM/ParaSkyLineArray.hxx @@ -20,10 +20,12 @@ #pragma once +#include "MEDCouplingRefCountObject.hxx" +#include "MCAuto.hxx" +#include "MCType.hxx" #include "MEDCouplingSkyLineArray.hxx" -#include "ProcessorGroup.hxx" -#include "MEDCouplingMemArray.hxx" +#include <cstddef> #include <string> #include <vector> @@ -41,7 +43,7 @@ namespace MEDCoupling MCAuto<ParaSkyLineArray> equiRedistribute(mcIdType nbOfEntities) const; MEDCouplingSkyLineArray *getSkyLineArray() const; DataArrayIdType *getGlobalIdsArray() const; - virtual ~ParaSkyLineArray() { } + ~ParaSkyLineArray() override = default; private: ParaSkyLineArray(MEDCouplingSkyLineArray *ska, DataArrayIdType *globalIds); protected: diff --git a/src/ParaMEDMEM/ParaUMesh.cxx b/src/ParaMEDMEM/ParaUMesh.cxx index b2502f9f3..bfb7d5acc 100644 --- a/src/ParaMEDMEM/ParaUMesh.cxx +++ b/src/ParaMEDMEM/ParaUMesh.cxx @@ -20,20 +20,19 @@ // Author : Anthony Geay (EDF R&D) #include "ParaUMesh.hxx" -#include "ProcessorGroup.hxx" +#include "MEDCouplingUMesh.hxx" +#include "MCAuto.hxx" +#include "MCType.hxx" +#include "ParaIdType.hxx" +#include "MEDCouplingRefCountObject.hxx" #include "MPIProcessorGroup.hxx" -#include "Topology.hxx" -#include "BlockTopology.hxx" #include "CommInterface.hxx" -#include "MEDCouplingMemArray.hxx" +#include "MEDCouplingMemArray.txx" #include "mpi.h" -#include <fstream> -#include <sstream> +#include <cstddef> #include <numeric> -#include <memory> -#include <vector> using namespace MEDCoupling; @@ -82,7 +81,7 @@ MCAuto<DataArrayIdType> ParaUMesh::getCellIdsLyingOnNodes(const DataArrayIdType MCAuto<DataArrayIdType> ParaUMesh::getCellIdsLyingOnNodesTrue(const DataArrayIdType *globalNodeIds) const { MPI_Comm comm(MPI_COMM_WORLD); - CommInterface ci; + CommInterface const ci; int size; ci.commSize(comm,&size); std::unique_ptr<mcIdType[]> nbOfElems(new mcIdType[size]),nbOfElems2(new mcIdType[size]),nbOfElems3(new mcIdType[size]); @@ -90,7 +89,7 @@ MCAuto<DataArrayIdType> ParaUMesh::getCellIdsLyingOnNodesTrue(const DataArrayIdT ci.allGather(&nbOfNodeIdsLoc,1,MPI_ID_TYPE,nbOfElems.get(),1,MPI_ID_TYPE,comm); std::vector< MCAuto<DataArrayIdType> > tabs(size); //store for each proc the local nodeids intercepted by current proc - int nbOfCollectiveCalls = 1;// this parameter controls the memory peak + int const nbOfCollectiveCalls = 1;// this parameter controls the memory peak // loop to avoid to all procs to have all the nodes per proc for(int subDiv = 0 ; subDiv < nbOfCollectiveCalls ; ++subDiv) { @@ -121,7 +120,7 @@ MCAuto<DataArrayIdType> ParaUMesh::getCellIdsLyingOnNodesTrue(const DataArrayIdT { MCAuto<DataArrayIdType> localNodeIds(tabs[curRk]); localNodeIds->sort(); - MCAuto<DataArrayIdType> localNodeIdsUnique(localNodeIds->buildUnique()); + MCAuto<DataArrayIdType> const localNodeIdsUnique(localNodeIds->buildUnique()); MCAuto<DataArrayIdType> localCellCaptured(_mesh->getCellIdsLyingOnNodes(localNodeIdsUnique->begin(),localNodeIdsUnique->end(),true)); MCAuto<DataArrayIdType> localCellCapturedGlob(_cell_global->selectByTupleIdSafe(localCellCaptured->begin(),localCellCaptured->end())); tabs[curRk] = localCellCapturedGlob; @@ -151,14 +150,14 @@ MCAuto<DataArrayIdType> ParaUMesh::getCellIdsLyingOnNodesTrue(const DataArrayIdT MCAuto<DataArrayIdType> ParaUMesh::getCellIdsLyingOnNodesFalse(const DataArrayIdType *globalNodeIds) const { MPI_Comm comm(MPI_COMM_WORLD); - CommInterface ci; + CommInterface const ci; int size; ci.commSize(comm,&size); std::unique_ptr<mcIdType[]> nbOfElems(new mcIdType[size]),nbOfElems2(new mcIdType[size]),nbOfElems3(new mcIdType[size]); mcIdType nbOfNodeIdsLoc(globalNodeIds->getNumberOfTuples()); ci.allGather(&nbOfNodeIdsLoc,1,MPI_ID_TYPE,nbOfElems.get(),1,MPI_ID_TYPE,comm); // loop to avoid to all procs to have all the nodes per proc - int nbOfCollectiveCalls = 1;// this parameter controls the memory peak + int const nbOfCollectiveCalls = 1;// this parameter controls the memory peak std::vector< MCAuto<DataArrayIdType> > tabs(size); for(int subDiv = 0 ; subDiv < nbOfCollectiveCalls ; ++subDiv) { @@ -177,7 +176,7 @@ MCAuto<DataArrayIdType> ParaUMesh::getCellIdsLyingOnNodesFalse(const DataArrayId globalNodeIdsOfCurProc->useArray(allGlobalNodeIds.get()+offset,false,DeallocType::CPP_DEALLOC,nbOfElemsSp[curRk],1); offset += nbOfElemsSp[curRk]; MCAuto<DataArrayIdType> globalNodeIdsCaptured(_node_global->buildIntersection(globalNodeIdsOfCurProc)); - MCAuto<DataArrayIdType> localNodeIdsToLocate(_node_global->findIdForEach(globalNodeIdsCaptured->begin(),globalNodeIdsCaptured->end())); + MCAuto<DataArrayIdType> const localNodeIdsToLocate(_node_global->findIdForEach(globalNodeIdsCaptured->begin(),globalNodeIdsCaptured->end())); MCAuto<DataArrayIdType> localCellCaptured(_mesh->getCellIdsLyingOnNodes(localNodeIdsToLocate->begin(),localNodeIdsToLocate->end(),false)); MCAuto<DataArrayIdType> localCellCapturedGlob(_cell_global->selectByTupleIdSafe(localCellCaptured->begin(),localCellCaptured->end())); if(tabs[curRk].isNull()) @@ -233,7 +232,7 @@ DataArrayDouble *ParaUMesh::redistributeNodeField(const DataArrayIdType *globalC ParaUMesh *ParaUMesh::redistributeCells(const DataArrayIdType *globalCellIds) const { MPI_Comm comm(MPI_COMM_WORLD); - CommInterface ci; + CommInterface const ci; std::unique_ptr<mcIdType[]> allGlobalCellIds,allGlobalCellIdsIndex; int size(ci.allGatherArrays(comm,globalCellIds,allGlobalCellIds,allGlobalCellIdsIndex)); // Prepare ParaUMesh parts to be sent : compute for each proc the contribution of current rank. @@ -246,11 +245,11 @@ ParaUMesh *ParaUMesh::redistributeCells(const DataArrayIdType *globalCellIds) co globalCellIdsOfCurProc->useArray(allGlobalCellIds.get()+offset,false,DeallocType::CPP_DEALLOC,allGlobalCellIdsIndex[curRk+1]-offset,1); // the key call is here : compute for rank curRk the cells to be sent MCAuto<DataArrayIdType> globalCellIdsCaptured(_cell_global->buildIntersection(globalCellIdsOfCurProc));// OK for the global cellIds - MCAuto<DataArrayIdType> localCellIdsCaptured(_cell_global->findIdForEach(globalCellIdsCaptured->begin(),globalCellIdsCaptured->end())); + MCAuto<DataArrayIdType> const localCellIdsCaptured(_cell_global->findIdForEach(globalCellIdsCaptured->begin(),globalCellIdsCaptured->end())); MCAuto<MEDCouplingUMesh> meshPart(_mesh->buildPartOfMySelf(localCellIdsCaptured->begin(),localCellIdsCaptured->end(),true)); MCAuto<DataArrayIdType> o2n(meshPart->zipCoordsTraducer());// OK for the mesh MCAuto<DataArrayIdType> n2o(o2n->invertArrayO2N2N2O(meshPart->getNumberOfNodes())); - MCAuto<DataArrayIdType> globalNodeIdsPart(_node_global->selectByTupleIdSafe(n2o->begin(),n2o->end())); // OK for the global nodeIds + MCAuto<DataArrayIdType> const globalNodeIdsPart(_node_global->selectByTupleIdSafe(n2o->begin(),n2o->end())); // OK for the global nodeIds meshPartsToBeSent[curRk] = meshPart; globalCellIdsToBeSent[curRk] = globalCellIdsCaptured; globalNodeIdsToBeSent[curRk] = globalNodeIdsPart; @@ -284,7 +283,7 @@ ParaUMesh *ParaUMesh::redistributeCells(const DataArrayIdType *globalCellIds) co MCAuto<DataArrayIdType> aggregatedNodeIdsSorted(aggregatedNodeIds->copySorted()); MCAuto<DataArrayIdType> nodeIdsIntoAggregatedIds(DataArrayIdType::FindPermutationFromFirstToSecondDuplicate(aggregatedNodeIdsSorted,aggregatedNodeIds)); MCAuto<DataArrayIdType> idxOfSameNodeIds(aggregatedNodeIdsSorted->indexOfSameConsecutiveValueGroups()); - MCAuto<DataArrayIdType> n2o_nodes(nodeIdsIntoAggregatedIds->selectByTupleIdSafe(idxOfSameNodeIds->begin(),idxOfSameNodeIds->end()-1));//new == new ordering so that global node ids are sorted . old == coarse ordering implied by the aggregation + MCAuto<DataArrayIdType> const n2o_nodes(nodeIdsIntoAggregatedIds->selectByTupleIdSafe(idxOfSameNodeIds->begin(),idxOfSameNodeIds->end()-1));//new == new ordering so that global node ids are sorted . old == coarse ordering implied by the aggregation MCAuto<DataArrayIdType> finalGlobalNodeIds(aggregatedNodeIdsSorted->selectByTupleIdSafe(idxOfSameNodeIds->begin(),idxOfSameNodeIds->end()-1)); MCAuto<DataArrayDouble> finalCoords(coords->selectByTupleIdSafe(n2o_nodes->begin(),n2o_nodes->end())); finalCoords->copyStringInfoFrom(*_mesh->getCoords()); diff --git a/src/ParaMEDMEM/ParaUMesh.hxx b/src/ParaMEDMEM/ParaUMesh.hxx index 9e6d83e50..b915b3e08 100644 --- a/src/ParaMEDMEM/ParaUMesh.hxx +++ b/src/ParaMEDMEM/ParaUMesh.hxx @@ -20,12 +20,16 @@ #pragma once +#include "MEDCouplingRefCountObject.hxx" +#include "MCAuto.hxx" +#include "MEDCouplingTraits.hxx" +#include "CommInterface.hxx" +#include "MCType.hxx" #include "MEDCouplingUMesh.hxx" -#include "ProcessorGroup.hxx" #include "MEDCouplingMemArray.hxx" +#include <cstddef> #include <string> -#include <vector> namespace MEDCoupling { @@ -48,7 +52,7 @@ namespace MEDCoupling DataArrayIdType *getGlobalCellIds() { return _cell_global; } DataArrayIdType *getGlobalNodeIds() { return _node_global; } protected: - virtual ~ParaUMesh() { } + ~ParaUMesh() override = default; ParaUMesh(MEDCouplingUMesh *mesh, DataArrayIdType *globalCellIds, DataArrayIdType *globalNodeIds); std::string getClassName() const override { return "ParaUMesh"; } std::size_t getHeapMemorySizeWithoutChildren() const override; @@ -65,7 +69,7 @@ namespace MEDCoupling { using DataArrayT = typename Traits<T>::ArrayType; MPI_Comm comm(MPI_COMM_WORLD); - CommInterface ci; + CommInterface const ci; if( _cell_global->getNumberOfTuples() != fieldValueToRed->getNumberOfTuples() ) throw INTERP_KERNEL::Exception("PAraUMesh::redistributeCellFieldT : invalid input length of array !"); std::unique_ptr<mcIdType[]> allGlobalCellIds,allGlobalCellIdsIndex; @@ -106,7 +110,7 @@ namespace MEDCoupling { using DataArrayT = typename Traits<T>::ArrayType; MPI_Comm comm(MPI_COMM_WORLD); - CommInterface ci; + CommInterface const ci; if( _node_global->getNumberOfTuples() != fieldValueToRed->getNumberOfTuples() ) throw INTERP_KERNEL::Exception("PAraUMesh::redistributeNodeFieldT : invalid input length of array !"); std::unique_ptr<mcIdType[]> allGlobalCellIds,allGlobalCellIdsIndex; @@ -121,7 +125,7 @@ namespace MEDCoupling globalCellIdsOfCurProc->useArray(allGlobalCellIds.get()+offset,false,DeallocType::CPP_DEALLOC,allGlobalCellIdsIndex[curRk+1]-offset,1); // the key call is here : compute for rank curRk the cells to be sent MCAuto<DataArrayIdType> globalCellIdsCaptured(_cell_global->buildIntersection(globalCellIdsOfCurProc));// OK for the global cellIds - MCAuto<DataArrayIdType> localCellIdsCaptured(_cell_global->findIdForEach(globalCellIdsCaptured->begin(),globalCellIdsCaptured->end())); + MCAuto<DataArrayIdType> const localCellIdsCaptured(_cell_global->findIdForEach(globalCellIdsCaptured->begin(),globalCellIdsCaptured->end())); MCAuto<MEDCouplingUMesh> meshPart(_mesh->buildPartOfMySelf(localCellIdsCaptured->begin(),localCellIdsCaptured->end(),true)); MCAuto<DataArrayIdType> o2n(meshPart->zipCoordsTraducer());// OK for the mesh MCAuto<DataArrayIdType> n2o(o2n->invertArrayO2N2N2O(meshPart->getNumberOfNodes())); diff --git a/src/ParaMEDMEM/ProcessorGroup.cxx b/src/ParaMEDMEM/ProcessorGroup.cxx index a1834d14f..26406189b 100644 --- a/src/ParaMEDMEM/ProcessorGroup.cxx +++ b/src/ParaMEDMEM/ProcessorGroup.cxx @@ -18,7 +18,7 @@ // #include "ProcessorGroup.hxx" -#include "InterpolationUtils.hxx" +#include "CommInterface.hxx" namespace MEDCoupling { diff --git a/src/ParaMEDMEM/ProcessorGroup.hxx b/src/ParaMEDMEM/ProcessorGroup.hxx index 7e5e71048..63320b389 100644 --- a/src/ParaMEDMEM/ProcessorGroup.hxx +++ b/src/ParaMEDMEM/ProcessorGroup.hxx @@ -22,7 +22,7 @@ #include "CommInterface.hxx" -#include <set> +#include <string> namespace MEDCoupling { @@ -45,7 +45,7 @@ namespace MEDCoupling ProcessorGroup (const CommInterface& interface, int start, int end); ProcessorGroup(const CommInterface& interface,std::map<std::string,std::set<int>> proc_ids_by_name,const std::string& simCodeTag): _comm_interface(interface),_proc_ids_by_name(proc_ids_by_name),_proc_ids(proc_ids_by_name.at(simCodeTag)) { } - virtual ~ProcessorGroup() { } + virtual ~ProcessorGroup() = default; virtual ProcessorGroup *deepCopy() const = 0; virtual ProcessorGroup* fuse (const ProcessorGroup&) const = 0; virtual void intersect (ProcessorGroup&) = 0; diff --git a/src/ParaMEDMEM/StructuredCoincidentDEC.cxx b/src/ParaMEDMEM/StructuredCoincidentDEC.cxx index 89c0ce4c3..05f5273c2 100644 --- a/src/ParaMEDMEM/StructuredCoincidentDEC.cxx +++ b/src/ParaMEDMEM/StructuredCoincidentDEC.cxx @@ -17,8 +17,11 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +#include <cstddef> #include <mpi.h> -#include "CommInterface.hxx" +#include "DisjointDEC.hxx" +#include "MCType.hxx" +#include "ParaIdType.hxx" #include "Topology.hxx" #include "BlockTopology.hxx" #include "ComponentTopology.hxx" @@ -28,6 +31,7 @@ #include "InterpKernelUtilities.hxx" #include <iostream> +#include <utility> using namespace std; @@ -122,15 +126,15 @@ namespace MEDCoupling if (!_topo_source->getProcGroup()->containsMyRank()) return; - MPIProcessorGroup* group=new MPIProcessorGroup(_topo_source->getProcGroup()->getCommInterface()); + auto* group=new MPIProcessorGroup(_topo_source->getProcGroup()->getCommInterface()); - int myranksource = _topo_source->getProcGroup()->myRank(); + int const myranksource = _topo_source->getProcGroup()->myRank(); vector <mcIdType>* target_arrays=new vector<mcIdType>[_topo_target->getProcGroup()->size()]; //cout<<" topotarget size"<< _topo_target->getProcGroup()->size()<<endl; - mcIdType nb_local = _topo_source-> getNbLocalElements(); + mcIdType const nb_local = _topo_source-> getNbLocalElements(); for (mcIdType ielem=0; ielem< nb_local ; ielem++) { // cout <<"source local :"<<myranksource<<","<<ielem<<endl; @@ -159,7 +163,7 @@ namespace MEDCoupling for (int iproc=0; iproc < _topo_target->getProcGroup()->size(); iproc++) { //converts the rank in target to the rank in union communicator - int unionrank=group->translateRank(_topo_target->getProcGroup(),iproc); + int const unionrank=group->translateRank(_topo_target->getProcGroup(),iproc); _send_counts[unionrank]=(int)target_arrays[iproc].size(); } @@ -200,12 +204,12 @@ namespace MEDCoupling { if (!_topo_target->getProcGroup()->containsMyRank()) return; - MPIProcessorGroup* group=new MPIProcessorGroup(_topo_source->getProcGroup()->getCommInterface()); + auto* group=new MPIProcessorGroup(_topo_source->getProcGroup()->getCommInterface()); - int myranktarget = _topo_target->getProcGroup()->myRank(); + int const myranktarget = _topo_target->getProcGroup()->myRank(); vector < vector <mcIdType> > source_arrays(_topo_source->getProcGroup()->size()); - mcIdType nb_local = _topo_target-> getNbLocalElements(); + mcIdType const nb_local = _topo_target-> getNbLocalElements(); for (mcIdType ielem=0; ielem< nb_local ; ielem++) { // cout <<"TS target local :"<<myranktarget<<","<<ielem<<endl; @@ -230,7 +234,7 @@ namespace MEDCoupling for (int iproc=0; iproc < _topo_source->getProcGroup()->size(); iproc++) { //converts the rank in target to the rank in union communicator - int unionrank=group->translateRank(_topo_source->getProcGroup(),iproc); + int const unionrank=group->translateRank(_topo_source->getProcGroup(),iproc); _recv_counts[unionrank]=(int)source_arrays[iproc].size(); } for (std::size_t i=1; i<union_size; i++) @@ -252,15 +256,15 @@ namespace MEDCoupling { MPI_Status status; - mcIdType* serializer=0; + mcIdType* serializer=nullptr; mcIdType size; - MPIProcessorGroup* group=new MPIProcessorGroup(*_comm_interface); + auto* group=new MPIProcessorGroup(*_comm_interface); // The master proc creates a send buffer containing a serialized topology int rank_master; - if (topo!=0 && topo->getProcGroup()->myRank()==0) + if (topo!=nullptr && topo->getProcGroup()->myRank()==0) { MESSAGE ("Master rank"); topo->serialize(serializer, size); @@ -282,23 +286,23 @@ namespace MEDCoupling // The topology is broadcasted to all processors in the group _comm_interface->broadcast(&size, 1,MPI_ID_TYPE,rank_master,*(group->getComm())); - mcIdType* buffer=new mcIdType[size]; - if (topo!=0 && topo->getProcGroup()->myRank()==0) + auto* buffer=new mcIdType[size]; + if (topo!=nullptr && topo->getProcGroup()->myRank()==0) copy(serializer, serializer+size, buffer); _comm_interface->broadcast(buffer,(int)size,MPI_ID_TYPE,rank_master,*(group->getComm())); // Processors which did not possess the source topology unserialize it - BlockTopology* topotemp=new BlockTopology(); + auto* topotemp=new BlockTopology(); topotemp->unserialize(buffer, *_comm_interface); - if (topo==0) + if (topo==nullptr) topo=topotemp; else delete topotemp; // Memory cleaning delete[] buffer; - if (serializer!=0) + if (serializer!=nullptr) delete[] serializer; MESSAGE (" rank "<<group->myRank()<< " unserialize is over"); delete group; @@ -324,17 +328,17 @@ namespace MEDCoupling _recv_buffer, _recv_counts, _recv_displs, MPI_DOUBLE,comm); cout<<"end AllToAll"<<endl; - mcIdType nb_local = _topo_target->getNbLocalElements(); + mcIdType const nb_local = _topo_target->getNbLocalElements(); //double* value=new double[nb_local]; - double* value=const_cast<double*>(_local_field->getField()->getArray()->getPointer()); + auto* value=const_cast<double*>(_local_field->getField()->getArray()->getPointer()); - int myranktarget=_topo_target->getProcGroup()->myRank(); + int const myranktarget=_topo_target->getProcGroup()->myRank(); vector<int> counters(_topo_source->getProcGroup()->size()); counters[0]=0; for (int i=0; i<_topo_source->getProcGroup()->size()-1; i++) { - MPIProcessorGroup* group=new MPIProcessorGroup(*_comm_interface); - int worldrank=group->translateRank(_topo_source->getProcGroup(),i); + auto* group=new MPIProcessorGroup(*_comm_interface); + int const worldrank=group->translateRank(_topo_source->getProcGroup(),i); counters[i+1]=counters[i]+_recv_counts[worldrank]; delete group; } diff --git a/src/ParaMEDMEM/StructuredCoincidentDEC.hxx b/src/ParaMEDMEM/StructuredCoincidentDEC.hxx index 7c821c4e0..1db7f9b06 100644 --- a/src/ParaMEDMEM/StructuredCoincidentDEC.hxx +++ b/src/ParaMEDMEM/StructuredCoincidentDEC.hxx @@ -86,14 +86,14 @@ namespace MEDCoupling public: StructuredCoincidentDEC(); StructuredCoincidentDEC( ProcessorGroup& source, ProcessorGroup& target); - virtual ~StructuredCoincidentDEC(); + ~StructuredCoincidentDEC() override; void release(); - void synchronize(); - void recvData(); - void sendData(); - void prepareSourceDE(); - void prepareTargetDE(); + void synchronize() override; + void recvData() override; + void sendData() override; + void prepareSourceDE() override; + void prepareTargetDE() override; private : void synchronizeTopology(); diff --git a/src/ParaMEDMEM/TimeInterpolator.cxx b/src/ParaMEDMEM/TimeInterpolator.cxx index 2a94cdd79..8e8af1635 100644 --- a/src/ParaMEDMEM/TimeInterpolator.cxx +++ b/src/ParaMEDMEM/TimeInterpolator.cxx @@ -29,6 +29,5 @@ namespace MEDCoupling } TimeInterpolator::~TimeInterpolator() - { - } + = default; } diff --git a/src/ParaMEDMEM/TimeInterpolator.hxx b/src/ParaMEDMEM/TimeInterpolator.hxx index 8673d1cf1..258f45230 100644 --- a/src/ParaMEDMEM/TimeInterpolator.hxx +++ b/src/ParaMEDMEM/TimeInterpolator.hxx @@ -20,10 +20,7 @@ #ifndef __TIMEINTERPOLATOR_HXX__ #define __TIMEINTERPOLATOR_HXX__ -#include "ProcessorGroup.hxx" -#include <map> -#include <iostream> namespace MEDCoupling { diff --git a/src/RENUMBER/RENUMBER_BOOSTRenumbering.cxx b/src/RENUMBER/RENUMBER_BOOSTRenumbering.cxx index 423591332..079da0bc1 100644 --- a/src/RENUMBER/RENUMBER_BOOSTRenumbering.cxx +++ b/src/RENUMBER/RENUMBER_BOOSTRenumbering.cxx @@ -19,14 +19,17 @@ #include "RENUMBER_BOOSTRenumbering.hxx" +#include "MCIdType.hxx" +#include "MCType.hxx" #include "MEDCouplingMemArray.hxx" #include "MCAuto.hxx" -#include <boost/config.hpp> #include <boost/graph/adjacency_list.hpp> #include <boost/graph/cuthill_mckee_ordering.hpp> +#include <boost/graph/graph_selectors.hpp> +#include <boost/graph/detail/adjacency_list.hpp> #include <boost/graph/properties.hpp> -#include <boost/graph/bandwidth.hpp> +#include <boost/pending/property.hpp> void BOOSTRenumbering::renumber(const mcIdType *graph, const mcIdType *index_graph, mcIdType nbCell, MEDCoupling::DataArrayIdType *&iperm, MEDCoupling::DataArrayIdType *&perm) { @@ -42,7 +45,7 @@ void BOOSTRenumbering::renumber(const mcIdType *graph, const mcIdType *index_gra for (mcIdType j=index_graph[i];j<index_graph[i+1];++j) add_edge(i,graph[j],G); boost::property_map<Graph, boost::vertex_index_t>::type - index_map = boost::get(boost::vertex_index, G); + const index_map = boost::get(boost::vertex_index, G); boost::cuthill_mckee_ordering(G, out0->getPointer(), boost::get(boost::vertex_color, G), boost::make_degree_map(G)); mcIdType *out0Ptr(out0->getPointer()),*out1Ptr(out1->getPointer()); diff --git a/src/RENUMBER/RENUMBER_BOOSTRenumbering.hxx b/src/RENUMBER/RENUMBER_BOOSTRenumbering.hxx index 648420742..74f785dbd 100644 --- a/src/RENUMBER/RENUMBER_BOOSTRenumbering.hxx +++ b/src/RENUMBER/RENUMBER_BOOSTRenumbering.hxx @@ -20,13 +20,15 @@ #ifndef __BOOSTRENUMBERING_HXX__ #define __BOOSTRENUMBERING_HXX__ +#include "MCIdType.hxx" +#include "MCType.hxx" #include "RENUMBERDefines.hxx" #include "RENUMBER_Renumbering.hxx" class RENUMBER_EXPORT BOOSTRenumbering:public Renumbering { public: - void renumber(const mcIdType *graph, const mcIdType *index_graph, mcIdType nbCell, MEDCoupling::DataArrayIdType *&iperm, MEDCoupling::DataArrayIdType *&perm); + void renumber(const mcIdType *graph, const mcIdType *index_graph, mcIdType nbCell, MEDCoupling::DataArrayIdType *&iperm, MEDCoupling::DataArrayIdType *&perm) override; }; #endif /*BOOSTRENUMBERING_HXX_*/ diff --git a/src/RENUMBER/RENUMBER_METISRenumbering.cxx b/src/RENUMBER/RENUMBER_METISRenumbering.cxx index b4d626815..0e90cba77 100644 --- a/src/RENUMBER/RENUMBER_METISRenumbering.cxx +++ b/src/RENUMBER/RENUMBER_METISRenumbering.cxx @@ -17,6 +17,10 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +#include "MCIdType.hxx" +#include "MCType.hxx" +#include <vector> +#include <algorithm> #ifdef MED_ENABLE_PARMETIS // include parmetis.h even if it is not needed here // to avoid inclusion of c++ definitions within extern "C" @@ -57,7 +61,7 @@ void METISRenumbering::renumber(const mcIdType *graph, const mcIdType *index_gra std::vector<idx_t> indexVec( index_graph, index_graph + indexSize ); std::vector<idx_t> graphVec( graph, graph + graphSize ); std::vector<idx_t> out0Vec( nbCell ), out1Vec( nbCell ); - idx_t nb = static_cast<idx_t>( nbCell ); + auto nb = static_cast<idx_t>( nbCell ); METIS_NodeND(&nb,indexVec.data(),graphVec.data(),&num_flag,&options,out0Vec.data(),out1Vec.data()); std::copy( out0Vec.begin(),out0Vec.end(),out0->getPointer() ); std::copy( out1Vec.begin(),out1Vec.end(),out1->getPointer() ); diff --git a/src/RENUMBER/RENUMBER_METISRenumbering.hxx b/src/RENUMBER/RENUMBER_METISRenumbering.hxx index 8d0ad6d4f..b61c42a96 100644 --- a/src/RENUMBER/RENUMBER_METISRenumbering.hxx +++ b/src/RENUMBER/RENUMBER_METISRenumbering.hxx @@ -20,13 +20,15 @@ #ifndef __METISRENUMBERING_HXX__ #define __METISRENUMBERING_HXX__ +#include "MCIdType.hxx" +#include "MCType.hxx" #include "RENUMBERDefines.hxx" #include "RENUMBER_Renumbering.hxx" class RENUMBER_EXPORT METISRenumbering:public Renumbering { public: - virtual void renumber(const mcIdType *graph, const mcIdType *index_graph, mcIdType nb_cell, MEDCoupling::DataArrayIdType *&iperm, MEDCoupling::DataArrayIdType *&perm); + void renumber(const mcIdType *graph, const mcIdType *index_graph, mcIdType nb_cell, MEDCoupling::DataArrayIdType *&iperm, MEDCoupling::DataArrayIdType *&perm) override; }; #endif /*METISRENUMBERING_HXX_*/ diff --git a/src/RENUMBER/RENUMBER_Renumbering.hxx b/src/RENUMBER/RENUMBER_Renumbering.hxx index 7742218a6..d6ebbd61a 100644 --- a/src/RENUMBER/RENUMBER_Renumbering.hxx +++ b/src/RENUMBER/RENUMBER_Renumbering.hxx @@ -20,10 +20,10 @@ #ifndef RENUMBERING_HXX_ #define RENUMBERING_HXX_ +#include "MCIdType.hxx" #include "RENUMBERDefines.hxx" #include "MCType.hxx" -#include <vector> namespace MEDCoupling { @@ -34,7 +34,7 @@ class RENUMBER_EXPORT Renumbering { public: virtual void renumber(const mcIdType *graph, const mcIdType *index_graph, mcIdType nbCell, MEDCoupling::DataArrayIdType *&iperm, MEDCoupling::DataArrayIdType *&perm) = 0; - virtual ~Renumbering() { } + virtual ~Renumbering() = default; }; #endif /*RENUMBERING_HXX_*/ diff --git a/src/RENUMBER/RenumberingFactory.cxx b/src/RENUMBER/RenumberingFactory.cxx index e53c634a8..6ad2eea46 100644 --- a/src/RENUMBER/RenumberingFactory.cxx +++ b/src/RENUMBER/RenumberingFactory.cxx @@ -19,6 +19,9 @@ #include "RenumberingFactory.hxx" #include "RENUMBER_Renumbering.hxx" +#include <string> +#include <cctype> +#include <vector> #ifdef MED_ENABLE_METIS #include "RENUMBER_METISRenumbering.hxx" #endif @@ -54,7 +57,7 @@ namespace MED_RENUMBER else { std::cerr << "The method has to be METIS or BOOST" << std::endl; - return 0; + return nullptr; } #endif #ifndef ENABLE_BOOST diff --git a/src/RENUMBER/RenumberingFactory.hxx b/src/RENUMBER/RenumberingFactory.hxx index 540a14e78..b1f5b9e4d 100644 --- a/src/RENUMBER/RenumberingFactory.hxx +++ b/src/RENUMBER/RenumberingFactory.hxx @@ -24,6 +24,7 @@ #include "RENUMBER_Renumbering.hxx" #include <string> +#include <vector> namespace MED_RENUMBER { diff --git a/src/RENUMBER/renumbering.cxx b/src/RENUMBER/renumbering.cxx index a417f7cc1..ac312d4a1 100644 --- a/src/RENUMBER/renumbering.cxx +++ b/src/RENUMBER/renumbering.cxx @@ -17,18 +17,25 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +#include "MCAuto.hxx" +#include "MCType.hxx" +#include "MCIdType.hxx" +#include "MEDCouplingMemArray.hxx" #include "MEDFileData.hxx" +#include "MEDFileFieldMultiTS.hxx" +#include "MEDFileField1TS.hxx" #include "MEDFileMesh.hxx" #include "MEDFileField.hxx" #include "MEDCouplingUMesh.hxx" +#include "RENUMBER_Renumbering.hxx" #include "RenumberingFactory.hxx" +#include <sstream> #include <time.h> #include <string> #include <cstdlib> -#include <fstream> #include <iostream> using namespace std; @@ -45,10 +52,10 @@ int main(int argc, char** argv) << " filename_in meshname method[BOOST/METIS] filename_out" << endl << endl; return -1; } - string filename_in = argv[1]; - string meshname = argv[2]; - string type_renum = argv[3]; - string filename_out = argv[4]; + string const filename_in = argv[1]; + string const meshname = argv[2]; + string const type_renum = argv[3]; + string const filename_out = argv[4]; if(type_renum!="METIS" && type_renum!="BOOST") { @@ -59,7 +66,7 @@ int main(int argc, char** argv) cout << "Reading : " << flush; MCAuto<MEDFileData> fd(MEDFileData::New(filename_in)); MEDFileMesh *m=fd->getMeshes()->getMeshWithName(meshname); - MEDFileUMesh *mc=dynamic_cast<MEDFileUMesh *>(m); + auto *mc=dynamic_cast<MEDFileUMesh *>(m); if(!mc) { std::ostringstream oss; oss << "In file \"" << filename_in << "\" the mesh name \"" << meshname<< "\" exists but is not unstructured !"; @@ -71,18 +78,18 @@ int main(int argc, char** argv) MCAuto<MEDCouplingUMesh> workMesh=mc->getMeshAtLevel(0); //std::vector<mcIdType> code=workMesh->getDistributionOfTypes(); cout << "Building the graph : " << flush; - DataArrayIdType *neighb=0,*neighbI=0; + DataArrayIdType *neighb=nullptr,*neighbI=nullptr; workMesh->computeNeighborsOfCells(neighb,neighbI); MCAuto<DataArrayIdType> neighbSafe(neighb),neighbISafe(neighbI),ipermSafe,permSafe; const mcIdType *graph=neighbSafe->begin(); const mcIdType *graph_index=neighbISafe->begin(); // Compute permutation iperm->new2old perm->old2new - DataArrayIdType *iperm(0),*perm(0); + DataArrayIdType *iperm(nullptr),*perm(nullptr); Renumbering *renumb=RenumberingFactory(type_renum); renumb->renumber(graph,graph_index,workMesh->getNumberOfCells(),iperm,perm); ipermSafe=iperm; permSafe=perm; delete renumb; - ipermSafe=0;//erase new2old, we are using only old 2 new + ipermSafe=nullptr;//erase new2old, we are using only old 2 new t_compute_graph=(double)clock(); cout << " : " << (t_compute_graph-t_read_st)/(double) CLOCKS_PER_SEC << "s" << endl; cout.flush(); @@ -106,13 +113,13 @@ int main(int argc, char** argv) { for(int i=0;i<fs->getNumberOfFields();i++) { - MEDFileFieldMultiTS *fmts=dynamic_cast<MEDFileFieldMultiTS *>(fs->getFieldAtPos(i)); + auto *fmts=dynamic_cast<MEDFileFieldMultiTS *>(fs->getFieldAtPos(i)); if(!fmts) continue; if(fmts->getMeshName()==meshname) { for(int j=0;j<fmts->getNumberOfTS();j++) { - MEDFileField1TS *f1ts=dynamic_cast<MEDFileField1TS*>(fmts->getTimeStepAtPos(j)); + auto *f1ts=dynamic_cast<MEDFileField1TS*>(fmts->getTimeStepAtPos(j)); if(!f1ts) continue; DataArrayDouble *arr=f1ts->getUndergroundDataArray(); arr->renumberInPlace(perm->begin());