From: ageay Date: Tue, 14 Jun 2011 15:27:52 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: V5_1_6rc1~15 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=064b76ec1b672e9ca9ff3f0fa1bd1260ffc4b9f4;p=tools%2Fmedcoupling.git *** empty log message *** --- diff --git a/src/INTERP_KERNEL/BBTree.txx b/src/INTERP_KERNEL/BBTree.txx index b24255fd7..f77c34904 100644 --- a/src/INTERP_KERNEL/BBTree.txx +++ b/src/INTERP_KERNEL/BBTree.txx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __BBTREE_TXX__ #define __BBTREE_TXX__ diff --git a/src/INTERP_KERNEL/Bases/INTERPKERNELBASESDefines.hxx b/src/INTERP_KERNEL/Bases/INTERPKERNELBASESDefines.hxx index 68977cc3a..63558a927 100644 --- a/src/INTERP_KERNEL/Bases/INTERPKERNELBASESDefines.hxx +++ b/src/INTERP_KERNEL/Bases/INTERPKERNELBASESDefines.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __INTERPKERNELBASESDEFINES_HXX__ diff --git a/src/INTERP_KERNEL/Bases/InterpKernelAutoPtr.hxx b/src/INTERP_KERNEL/Bases/InterpKernelAutoPtr.hxx new file mode 100644 index 000000000..59198946b --- /dev/null +++ b/src/INTERP_KERNEL/Bases/InterpKernelAutoPtr.hxx @@ -0,0 +1,45 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef __INTERPKERNELAUTOPTR_HXX__ +#define __INTERPKERNELAUTOPTR_HXX__ + +namespace INTERP_KERNEL +{ + template + class AutoPtr + { + public: + AutoPtr(T *ptr=0):_ptr(ptr) { } + ~AutoPtr() { destroyPtr(); } + AutoPtr &operator=(T *ptr) { destroyPtr(); _ptr=ptr; return *this; } + T *operator->() { return _ptr ; } + const T *operator->() const { return _ptr; } + T& operator*() { return *_ptr; } + const T& operator*() const { return *_ptr; } + operator T *() { return _ptr; } + operator const T *() const { return _ptr; } + private: + void destroyPtr() { delete [] _ptr; } + private: + T *_ptr; + }; +} + +#endif diff --git a/src/INTERP_KERNEL/Bases/InterpKernelException.cxx b/src/INTERP_KERNEL/Bases/InterpKernelException.cxx index e73efc12f..00c8d2f26 100644 --- a/src/INTERP_KERNEL/Bases/InterpKernelException.cxx +++ b/src/INTERP_KERNEL/Bases/InterpKernelException.cxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "InterpKernelException.hxx" diff --git a/src/INTERP_KERNEL/Bases/InterpKernelException.hxx b/src/INTERP_KERNEL/Bases/InterpKernelException.hxx index 187dcdeda..59b925068 100644 --- a/src/INTERP_KERNEL/Bases/InterpKernelException.hxx +++ b/src/INTERP_KERNEL/Bases/InterpKernelException.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __INTERPKERNELEXCEPTION_HXX__ @@ -27,7 +27,7 @@ namespace INTERP_KERNEL { - class INTERPKERNELBASES_EXPORT Exception : std::exception + class INTERPKERNELBASES_EXPORT Exception : public std::exception { public: Exception(const char *what); diff --git a/src/INTERP_KERNEL/Bases/InterpKernelHashMap.hxx b/src/INTERP_KERNEL/Bases/InterpKernelHashMap.hxx index b4cc8cfbe..e4fc93c81 100644 --- a/src/INTERP_KERNEL/Bases/InterpKernelHashMap.hxx +++ b/src/INTERP_KERNEL/Bases/InterpKernelHashMap.hxx @@ -194,7 +194,7 @@ namespace INTERP_KERNEL class _HashFn = hash<_Key>, class _EqualKey = std::equal_to<_Key>, class _Alloc = std::allocator<_Tp> > - class hash_multimap + class HashMultiMap { private: typedef hashtable, _Key, _HashFn, @@ -227,32 +227,32 @@ namespace INTERP_KERNEL allocator_type get_allocator() const { return _M_ht.get_allocator(); } - hash_multimap() : _M_ht(100, hasher(), key_equal(), allocator_type()) { } + HashMultiMap() : _M_ht(100, hasher(), key_equal(), allocator_type()) { } - explicit hash_multimap(size_type __n) : _M_ht(__n, hasher(), key_equal(), allocator_type()) {} + explicit HashMultiMap(size_type __n) : _M_ht(__n, hasher(), key_equal(), allocator_type()) {} - hash_multimap(size_type __n, const hasher& __hf) : _M_ht(__n, __hf, key_equal(), allocator_type()) {} + HashMultiMap(size_type __n, const hasher& __hf) : _M_ht(__n, __hf, key_equal(), allocator_type()) {} - hash_multimap(size_type __n, const hasher& __hf, const key_equal& __eql, - const allocator_type& __a = allocator_type()) : _M_ht(__n, __hf, __eql, __a) {} + HashMultiMap(size_type __n, const hasher& __hf, const key_equal& __eql, + const allocator_type& __a = allocator_type()) : _M_ht(__n, __hf, __eql, __a) {} template - hash_multimap(_InputIterator __f, _InputIterator __l) : _M_ht(100, hasher(), key_equal(), allocator_type()) + HashMultiMap(_InputIterator __f, _InputIterator __l) : _M_ht(100, hasher(), key_equal(), allocator_type()) { _M_ht.insert_equal(__f, __l); } template - hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n) : _M_ht(__n, hasher(), key_equal(), allocator_type()) + HashMultiMap(_InputIterator __f, _InputIterator __l, size_type __n) : _M_ht(__n, hasher(), key_equal(), allocator_type()) { _M_ht.insert_equal(__f, __l); } template - hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n, const hasher& __hf) + HashMultiMap(_InputIterator __f, _InputIterator __l, size_type __n, const hasher& __hf) : _M_ht(__n, __hf, key_equal(), allocator_type()) { _M_ht.insert_equal(__f, __l); } template - hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n, - const hasher& __hf, const key_equal& __eql, - const allocator_type& __a = allocator_type()) + HashMultiMap(_InputIterator __f, _InputIterator __l, size_type __n, + const hasher& __hf, const key_equal& __eql, + const allocator_type& __a = allocator_type()) : _M_ht(__n, __hf, __eql, __a) { _M_ht.insert_equal(__f, __l); } @@ -262,11 +262,11 @@ namespace INTERP_KERNEL bool empty() const { return _M_ht.empty(); } - void swap(hash_multimap& __hs) { _M_ht.swap(__hs._M_ht); } + void swap(HashMultiMap& __hs) { _M_ht.swap(__hs._M_ht); } template - friend bool operator==(const hash_multimap<_K1, _T1, _HF, _EqK, _Al>&, - const hash_multimap<_K1, _T1, _HF, _EqK, _Al>&); + friend bool operator==(const HashMultiMap<_K1, _T1, _HF, _EqK, _Al>&, + const HashMultiMap<_K1, _T1, _HF, _EqK, _Al>&); iterator begin() { return _M_ht.begin(); } @@ -311,18 +311,18 @@ namespace INTERP_KERNEL }; template - inline bool operator==(const hash_multimap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm1, - const hash_multimap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm2) + inline bool operator==(const HashMultiMap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm1, + const HashMultiMap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm2) { return __hm1._M_ht == __hm2._M_ht; } template - inline bool operator!=(const hash_multimap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm1, - const hash_multimap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm2) + inline bool operator!=(const HashMultiMap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm1, + const HashMultiMap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm2) { return !(__hm1 == __hm2); } template - inline void swap(hash_multimap<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm1, - hash_multimap<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm2) + inline void swap(HashMultiMap<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm1, + HashMultiMap<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm2) { __hm1.swap(__hm2); } } @@ -330,7 +330,7 @@ namespace INTERP_KERNEL namespace std { // Specialization of insert_iterator so that it will work for HashMap - // and hash_multimap. + // and HashMultiMap. template class insert_iterator > @@ -365,11 +365,11 @@ namespace std }; template - class insert_iterator > + class insert_iterator > { protected: - typedef INTERP_KERNEL::hash_multimap<_Key, _Tp, _HashFn, _EqKey, _Alloc> + typedef INTERP_KERNEL::HashMultiMap<_Key, _Tp, _HashFn, _EqKey, _Alloc> _Container; _Container* container; typename _Container::iterator iter; diff --git a/src/INTERP_KERNEL/Bases/InterpKernelStlExt.hxx b/src/INTERP_KERNEL/Bases/InterpKernelStlExt.hxx index 36b40df94..fb047120c 100644 --- a/src/INTERP_KERNEL/Bases/InterpKernelStlExt.hxx +++ b/src/INTERP_KERNEL/Bases/InterpKernelStlExt.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __INTERPKERNELSTLEXT_HXX__ diff --git a/src/INTERP_KERNEL/Bases/Makefile.am b/src/INTERP_KERNEL/Bases/Makefile.am index fc89569bc..1c2071f5d 100755 --- a/src/INTERP_KERNEL/Bases/Makefile.am +++ b/src/INTERP_KERNEL/Bases/Makefile.am @@ -1,20 +1,20 @@ -# Copyright (C) 2007-2010 CEA/DEN, EDF R&D +# Copyright (C) 2007-2011 CEA/DEN, EDF R&D # -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. # -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. # -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # # File : Makefile.am @@ -32,7 +32,8 @@ NormalizedUnstructuredMesh.hxx \ InterpKernelStlExt.hxx \ InterpKernelHashMap.hxx \ InterpKernelHashTable.hxx \ -InterpKernelHashFun.hxx +InterpKernelHashFun.hxx \ +InterpKernelAutoPtr.hxx # Libraries targets diff --git a/src/INTERP_KERNEL/Bases/NormalizedUnstructuredMesh.hxx b/src/INTERP_KERNEL/Bases/NormalizedUnstructuredMesh.hxx index 5d2350cae..5f11ae19c 100644 --- a/src/INTERP_KERNEL/Bases/NormalizedUnstructuredMesh.hxx +++ b/src/INTERP_KERNEL/Bases/NormalizedUnstructuredMesh.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __NORMALIZEDUNSTRUCTUREDMESH_HXX__ @@ -31,7 +31,7 @@ namespace INTERP_KERNEL typedef enum { - NORM_POINT0 = 0, + NORM_POINT1 = 0, NORM_SEG2 = 1, NORM_SEG3 = 2, NORM_TRI3 = 3, @@ -45,6 +45,7 @@ namespace INTERP_KERNEL NORM_PENTA6 = 16, NORM_HEXA8 = 18, NORM_TETRA10 = 20, + NORM_HEXGP12 = 22, NORM_PYRA13 = 23, NORM_PENTA15 = 25, NORM_HEXA20 = 30, diff --git a/src/INTERP_KERNEL/BoundingBox.cxx b/src/INTERP_KERNEL/BoundingBox.cxx index 4179448b4..a194d7067 100644 --- a/src/INTERP_KERNEL/BoundingBox.cxx +++ b/src/INTERP_KERNEL/BoundingBox.cxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "BoundingBox.hxx" diff --git a/src/INTERP_KERNEL/BoundingBox.hxx b/src/INTERP_KERNEL/BoundingBox.hxx index d95cfd818..4ff2c3343 100644 --- a/src/INTERP_KERNEL/BoundingBox.hxx +++ b/src/INTERP_KERNEL/BoundingBox.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __BOUNDINGBOX_HXX__ diff --git a/src/INTERP_KERNEL/CellModel.cxx b/src/INTERP_KERNEL/CellModel.cxx index 88bc7a820..050fe25bc 100644 --- a/src/INTERP_KERNEL/CellModel.cxx +++ b/src/INTERP_KERNEL/CellModel.cxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "CellModel.hxx" @@ -27,11 +27,11 @@ namespace INTERP_KERNEL { - const char *CellModel::CELL_TYPES_REPR[]={"NORM_POINT0", "NORM_SEG2", "NORM_SEG3", "NORM_TRI3", "NORM_QUAD4",// 0->4 + const char *CellModel::CELL_TYPES_REPR[]={"NORM_POINT1", "NORM_SEG2", "NORM_SEG3", "NORM_TRI3", "NORM_QUAD4",// 0->4 "NORM_POLYGON", "NORM_TRI6", "" , "NORM_QUAD8", "",//5->9 "", "", "", "", "NORM_TETRA4",//10->14 "NORM_PYRA5", "NORM_PENTA6", "", "NORM_HEXA8", "",//15->19 - "NORM_TETRA10", "", "", "NORM_PYRA13", "",//20->24 + "NORM_TETRA10", "", "NORM_HEXGP12", "NORM_PYRA13", "",//20->24 "NORM_PENTA15", "", "", "", "",//25->29 "NORM_HEXA20", "NORM_POLYHED", "", "", "",//30->34 "", "", "", "", "",//35->39 @@ -39,7 +39,7 @@ namespace INTERP_KERNEL std::map CellModel::_map_of_unique_instance; - const CellModel& CellModel::getCellModel(NormalizedCellType type) + const CellModel& CellModel::GetCellModel(NormalizedCellType type) { if(_map_of_unique_instance.empty()) buildUniqueInstance(); @@ -64,7 +64,7 @@ namespace INTERP_KERNEL { if(_type==type) return true; - const CellModel& other=getCellModel(type); + const CellModel& other=GetCellModel(type); if(_dim!=other.getDimension()) return false; bool b1=isQuadratic(); @@ -78,7 +78,7 @@ namespace INTERP_KERNEL void CellModel::buildUniqueInstance() { - _map_of_unique_instance.insert(std::make_pair(NORM_POINT0,CellModel(NORM_POINT0))); + _map_of_unique_instance.insert(std::make_pair(NORM_POINT1,CellModel(NORM_POINT1))); _map_of_unique_instance.insert(std::make_pair(NORM_SEG2,CellModel(NORM_SEG2))); _map_of_unique_instance.insert(std::make_pair(NORM_SEG3,CellModel(NORM_SEG3))); _map_of_unique_instance.insert(std::make_pair(NORM_TRI3,CellModel(NORM_TRI3))); @@ -90,6 +90,7 @@ namespace INTERP_KERNEL _map_of_unique_instance.insert(std::make_pair(NORM_PYRA5,CellModel(NORM_PYRA5))); _map_of_unique_instance.insert(std::make_pair(NORM_PENTA6,CellModel(NORM_PENTA6))); _map_of_unique_instance.insert(std::make_pair(NORM_TETRA10,CellModel(NORM_TETRA10))); + _map_of_unique_instance.insert(std::make_pair(NORM_HEXGP12,CellModel(NORM_HEXGP12))); _map_of_unique_instance.insert(std::make_pair(NORM_PYRA13,CellModel(NORM_PYRA13))); _map_of_unique_instance.insert(std::make_pair(NORM_PENTA15,CellModel(NORM_PENTA15))); _map_of_unique_instance.insert(std::make_pair(NORM_HEXA20,CellModel(NORM_HEXA20))); @@ -106,24 +107,24 @@ namespace INTERP_KERNEL _quadratic_type=NORM_ERROR; switch(type) { - case NORM_POINT0: + case NORM_POINT1: { - _nb_of_pts=0; _nb_of_sons=0; _dim=0; _extruded_type=NORM_SEG2; + _nb_of_pts=1; _nb_of_sons=0; _dim=0; _extruded_type=NORM_SEG2; _is_simplex=true; } break; case NORM_SEG2: { - _nb_of_pts=2; _nb_of_sons=0; _dim=1; _extruded_type=NORM_QUAD4; _quadratic_type=NORM_SEG3; + _nb_of_pts=2; _nb_of_sons=0; _dim=1; _extruded_type=NORM_QUAD4; _quadratic_type=NORM_SEG3; _is_simplex=true; } break; case NORM_SEG3: { - _nb_of_pts=3; _nb_of_sons=0; _dim=1; _extruded_type=NORM_QUAD8; _linear_type=NORM_SEG2; + _nb_of_pts=3; _nb_of_sons=0; _dim=1; _extruded_type=NORM_QUAD8; _linear_type=NORM_SEG2; _is_simplex=false; } break; case NORM_TETRA4: { - _nb_of_pts=4; _nb_of_sons=4; _dim=3; _quadratic_type=NORM_TETRA10; + _nb_of_pts=4; _nb_of_sons=4; _dim=3; _quadratic_type=NORM_TETRA10; _is_simplex=true; _sons_type[0]=NORM_TRI3; _sons_type[1]=NORM_TRI3; _sons_type[2]=NORM_TRI3; _sons_type[3]=NORM_TRI3; _sons_con[0][0]=0; _sons_con[0][1]=1; _sons_con[0][2]=2; _nb_of_sons_con[0]=3; _sons_con[1][0]=0; _sons_con[1][1]=3; _sons_con[1][2]=1; _nb_of_sons_con[1]=3; @@ -133,7 +134,7 @@ namespace INTERP_KERNEL break; case NORM_HEXA8: { - _nb_of_pts=8; _nb_of_sons=6; _dim=3; _quadratic_type=NORM_HEXA20; + _nb_of_pts=8; _nb_of_sons=6; _dim=3; _quadratic_type=NORM_HEXA20; _is_simplex=false; _sons_type[0]=NORM_QUAD4; _sons_type[1]=NORM_QUAD4; _sons_type[2]=NORM_QUAD4; _sons_type[3]=NORM_QUAD4; _sons_type[4]=NORM_QUAD4; _sons_type[5]=NORM_QUAD4; _sons_con[0][0]=0; _sons_con[0][1]=1; _sons_con[0][2]=2; _sons_con[0][3]=3; _nb_of_sons_con[0]=4; _sons_con[1][0]=4; _sons_con[1][1]=7; _sons_con[1][2]=6; _sons_con[1][3]=5; _nb_of_sons_con[1]=4; @@ -145,7 +146,7 @@ namespace INTERP_KERNEL break; case NORM_QUAD4: { - _nb_of_pts=4; _nb_of_sons=4; _dim=2; _quadratic_type=NORM_QUAD8; + _nb_of_pts=4; _nb_of_sons=4; _dim=2; _quadratic_type=NORM_QUAD8; _is_simplex=false; _sons_type[0]=NORM_SEG2; _sons_type[1]=NORM_SEG2; _sons_type[2]=NORM_SEG2; _sons_type[3]=NORM_SEG2; _sons_con[0][0]=0; _sons_con[0][1]=1; _nb_of_sons_con[0]=2; _sons_con[1][0]=1; _sons_con[1][1]=2; _nb_of_sons_con[1]=2; @@ -155,7 +156,7 @@ namespace INTERP_KERNEL break; case NORM_TRI3: { - _nb_of_pts=3; _nb_of_sons=3; _dim=2; _quadratic_type=NORM_TRI6; + _nb_of_pts=3; _nb_of_sons=3; _dim=2; _quadratic_type=NORM_TRI6; _is_simplex=true; _sons_type[0]=NORM_SEG2; _sons_type[1]=NORM_SEG2; _sons_type[2]=NORM_SEG2; _sons_con[0][0]=0; _sons_con[0][1]=1; _nb_of_sons_con[0]=2; _sons_con[1][0]=1; _sons_con[1][1]=2; _nb_of_sons_con[1]=2; @@ -164,7 +165,7 @@ namespace INTERP_KERNEL break; case NORM_TRI6: { - _nb_of_pts=6; _nb_of_sons=3; _dim=2; _linear_type=NORM_TRI3; + _nb_of_pts=6; _nb_of_sons=3; _dim=2; _linear_type=NORM_TRI3; _is_simplex=false; _sons_type[0]=NORM_SEG3; _sons_type[1]=NORM_SEG3; _sons_type[2]=NORM_SEG3; _sons_con[0][0]=0; _sons_con[0][1]=1; _sons_con[0][2]=3; _nb_of_sons_con[0]=3; _sons_con[1][0]=1; _sons_con[1][1]=2; _sons_con[1][2]=4; _nb_of_sons_con[1]=3; @@ -173,7 +174,7 @@ namespace INTERP_KERNEL break; case NORM_QUAD8: { - _nb_of_pts=8; _nb_of_sons=4; _dim=2; _linear_type=NORM_QUAD4; + _nb_of_pts=8; _nb_of_sons=4; _dim=2; _linear_type=NORM_QUAD4; _is_simplex=false; _sons_type[0]=NORM_SEG3; _sons_type[1]=NORM_SEG3; _sons_type[2]=NORM_SEG3; _sons_type[3]=NORM_SEG3; _sons_con[0][0]=0; _sons_con[0][1]=1; _sons_con[0][2]=4; _nb_of_sons_con[0]=3; _sons_con[1][0]=1; _sons_con[1][1]=2; _sons_con[1][2]=5; _nb_of_sons_con[1]=3; @@ -183,7 +184,7 @@ namespace INTERP_KERNEL break; case NORM_PYRA5: { - _nb_of_pts=5; _nb_of_sons=5; _dim=3; _quadratic_type=NORM_PYRA13; + _nb_of_pts=5; _nb_of_sons=5; _dim=3; _quadratic_type=NORM_PYRA13; _is_simplex=false; _sons_type[0]=NORM_QUAD4; _sons_type[1]=NORM_TRI3; _sons_type[2]=NORM_TRI3; _sons_type[3]=NORM_TRI3; _sons_type[4]=NORM_TRI3; _sons_con[0][0]=0; _sons_con[0][1]=1; _sons_con[0][2]=2; _sons_con[0][3]=3; _nb_of_sons_con[0]=4; _sons_con[1][0]=0; _sons_con[1][1]=4; _sons_con[1][2]=1; _nb_of_sons_con[1]=3; @@ -194,7 +195,7 @@ namespace INTERP_KERNEL break; case NORM_PENTA6: { - _nb_of_pts=6; _nb_of_sons=5; _dim=3; _quadratic_type=NORM_PENTA15; + _nb_of_pts=6; _nb_of_sons=5; _dim=3; _quadratic_type=NORM_PENTA15; _is_simplex=false; _sons_type[0]=NORM_TRI3; _sons_type[1]=NORM_TRI3; _sons_type[2]=NORM_QUAD4; _sons_type[3]=NORM_QUAD4; _sons_type[4]=NORM_QUAD4; _sons_con[0][0]=0; _sons_con[0][1]=1; _sons_con[0][2]=2; _nb_of_sons_con[0]=3; _sons_con[1][0]=3; _sons_con[1][1]=5; _sons_con[1][2]=4; _nb_of_sons_con[1]=3; @@ -205,7 +206,7 @@ namespace INTERP_KERNEL break; case NORM_TETRA10: { - _nb_of_pts=10; _nb_of_sons=4; _dim=3; _linear_type=NORM_TETRA4; + _nb_of_pts=10; _nb_of_sons=4; _dim=3; _linear_type=NORM_TETRA4; _is_simplex=false; _sons_type[0]=NORM_TRI6; _sons_type[1]=NORM_TRI6; _sons_type[2]=NORM_TRI6; _sons_type[3]=NORM_TRI6; _sons_con[0][0]=0; _sons_con[0][1]=1; _sons_con[0][2]=2; _sons_con[0][3]=4; _sons_con[0][4]=5; _sons_con[0][5]=6; _nb_of_sons_con[0]=6; _sons_con[1][0]=0; _sons_con[1][1]=3; _sons_con[1][2]=1; _sons_con[1][3]=7; _sons_con[1][4]=8; _sons_con[1][5]=4; _nb_of_sons_con[1]=6; @@ -213,9 +214,24 @@ namespace INTERP_KERNEL _sons_con[3][0]=2; _sons_con[3][1]=3; _sons_con[3][2]=0; _sons_con[3][3]=9; _sons_con[3][4]=7; _sons_con[3][5]=6; _nb_of_sons_con[3]=6; _quadratic=true; } break; + case NORM_HEXGP12: + { + _nb_of_pts=12; _nb_of_sons=8; _dim=3; _is_simplex=false; + _sons_type[0]=NORM_POLYGON; _sons_type[1]=NORM_POLYGON; _sons_type[2]=NORM_QUAD4; _sons_type[3]=NORM_QUAD4; _sons_type[4]=NORM_QUAD4; _sons_type[5]=NORM_QUAD4; + _sons_type[6]=NORM_QUAD4; _sons_type[7]=NORM_QUAD4; + _sons_con[0][0]=0; _sons_con[0][1]=1; _sons_con[0][2]=2; _sons_con[0][3]=3; _sons_con[0][4]=4; _sons_con[0][5]=5; _nb_of_sons_con[0]=6; + _sons_con[1][0]=6; _sons_con[1][1]=11; _sons_con[1][2]=10; _sons_con[1][3]=9; _sons_con[1][4]=8; _sons_con[1][5]=7; _nb_of_sons_con[1]=6; + _sons_con[2][0]=0; _sons_con[2][1]=6; _sons_con[2][2]=7; _sons_con[2][3]=1; _nb_of_sons_con[2]=4; + _sons_con[3][0]=1; _sons_con[3][1]=7; _sons_con[3][2]=8; _sons_con[3][3]=2; _nb_of_sons_con[3]=4; + _sons_con[4][0]=2; _sons_con[4][1]=8; _sons_con[4][2]=9; _sons_con[4][3]=3; _nb_of_sons_con[4]=4; + _sons_con[5][0]=3; _sons_con[5][1]=9; _sons_con[5][2]=10; _sons_con[5][3]=4; _nb_of_sons_con[5]=4; + _sons_con[6][0]=4; _sons_con[6][1]=10; _sons_con[6][2]=11; _sons_con[6][3]=5; _nb_of_sons_con[6]=4; + _sons_con[7][0]=5; _sons_con[7][1]=11; _sons_con[7][2]=6; _sons_con[7][3]=0; _nb_of_sons_con[7]=4; + } + break; case NORM_PYRA13: { - _nb_of_pts=13; _nb_of_sons=5; _dim=3; _linear_type=NORM_PYRA5; + _nb_of_pts=13; _nb_of_sons=5; _dim=3; _linear_type=NORM_PYRA5; _is_simplex=false; _sons_type[0]=NORM_QUAD8; _sons_type[1]=NORM_TRI6; _sons_type[2]=NORM_TRI6; _sons_type[3]=NORM_TRI6; _sons_type[4]=NORM_TRI6; _sons_con[0][0]=0; _sons_con[0][1]=1; _sons_con[0][2]=2; _sons_con[0][3]=3; _sons_con[0][4]=5; _sons_con[0][5]=6; _sons_con[0][6]=7; _sons_con[0][7]=8; _nb_of_sons_con[0]=8; _sons_con[1][0]=0; _sons_con[1][1]=4; _sons_con[1][2]=1; _sons_con[1][3]=9; _sons_con[1][4]=10; _sons_con[1][5]=5; _nb_of_sons_con[1]=6; @@ -226,7 +242,7 @@ namespace INTERP_KERNEL break; case NORM_PENTA15: { - _nb_of_pts=15; _nb_of_sons=5; _dim=3; _linear_type=NORM_PENTA6; + _nb_of_pts=15; _nb_of_sons=5; _dim=3; _linear_type=NORM_PENTA6; _is_simplex=false; _sons_type[0]=NORM_TRI6; _sons_type[1]=NORM_TRI6; _sons_type[2]=NORM_QUAD8; _sons_type[3]=NORM_QUAD8; _sons_type[4]=NORM_QUAD8; _sons_con[0][0]=0; _sons_con[0][1]=1; _sons_con[0][2]=2; _sons_con[0][3]=6; _sons_con[0][4]=7; _sons_con[0][5]=8; _nb_of_sons_con[0]=6; _sons_con[1][0]=3; _sons_con[1][1]=5; _sons_con[1][2]=4; _sons_con[1][3]=11; _sons_con[1][4]=10; _sons_con[1][5]=9; _nb_of_sons_con[1]=6; @@ -237,7 +253,7 @@ namespace INTERP_KERNEL break; case NORM_HEXA20: { - _nb_of_pts=20; _nb_of_sons=6; _dim=3; _linear_type=NORM_HEXA8; + _nb_of_pts=20; _nb_of_sons=6; _dim=3; _linear_type=NORM_HEXA8; _is_simplex=false; _sons_type[0]=NORM_QUAD8; _sons_type[1]=NORM_QUAD8; _sons_type[2]=NORM_QUAD8; _sons_type[3]=NORM_QUAD8; _sons_type[4]=NORM_QUAD8; _sons_type[5]=NORM_QUAD8; _sons_con[0][0]=0; _sons_con[0][1]=1; _sons_con[0][2]=2; _sons_con[0][3]=3; _sons_con[0][4]=8; _sons_con[0][5]=9; _sons_con[0][6]=10; _sons_con[0][7]=11; _nb_of_sons_con[0]=8; _sons_con[1][0]=4; _sons_con[1][1]=7; _sons_con[1][2]=6; _sons_con[1][3]=5; _sons_con[1][4]=15; _sons_con[1][5]=14; _sons_con[1][6]=13; _sons_con[1][7]=12; _nb_of_sons_con[1]=8; @@ -249,12 +265,12 @@ namespace INTERP_KERNEL break; case NORM_POLYGON: { - _nb_of_pts=0; _nb_of_sons=0; _dim=2; _dyn=true; _extruded_type=NORM_POLYHED; + _nb_of_pts=0; _nb_of_sons=0; _dim=2; _dyn=true; _extruded_type=NORM_POLYHED; _is_simplex=false; } break; case NORM_POLYHED: { - _nb_of_pts=0; _nb_of_sons=0; _dim=3; _dyn=true; + _nb_of_pts=0; _nb_of_sons=0; _dim=3; _dyn=true; _is_simplex=false; } break; case NORM_ERROR: diff --git a/src/INTERP_KERNEL/CellModel.hxx b/src/INTERP_KERNEL/CellModel.hxx index 23b735512..44055ba6a 100644 --- a/src/INTERP_KERNEL/CellModel.hxx +++ b/src/INTERP_KERNEL/CellModel.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __CELLMODEL_INTERP_KERNEL_HXX__ @@ -34,18 +34,19 @@ namespace INTERP_KERNEL class CellModel { public: - static const unsigned MAX_NB_OF_SONS=6; + static const unsigned MAX_NB_OF_SONS=8; static const unsigned MAX_NB_OF_NODES_PER_ELEM=30; private: CellModel(NormalizedCellType type); static void buildUniqueInstance(); public: - INTERPKERNEL_EXPORT static const CellModel& getCellModel(NormalizedCellType type); + INTERPKERNEL_EXPORT static const CellModel& GetCellModel(NormalizedCellType type); INTERPKERNEL_EXPORT const char *getRepr() const; INTERPKERNEL_EXPORT bool isDynamic() const { return _dyn; } INTERPKERNEL_EXPORT bool isQuadratic() const { return _quadratic; } INTERPKERNEL_EXPORT unsigned getDimension() const { return _dim; } INTERPKERNEL_EXPORT bool isCompatibleWith(NormalizedCellType type) const; + INTERPKERNEL_EXPORT bool isSimplex() const { return _is_simplex; } //! sonId is in C format. INTERPKERNEL_EXPORT const unsigned *getNodesConstituentTheSon(unsigned sonId) const { return _sons_con[sonId]; } INTERPKERNEL_EXPORT unsigned getNumberOfNodes() const { return _nb_of_pts; } @@ -63,6 +64,7 @@ namespace INTERP_KERNEL private: bool _dyn; bool _quadratic; + bool _is_simplex; unsigned _dim; unsigned _nb_of_pts; unsigned _nb_of_sons; diff --git a/src/INTERP_KERNEL/ConvexIntersector.hxx b/src/INTERP_KERNEL/ConvexIntersector.hxx index 6657205ce..90fc4d434 100644 --- a/src/INTERP_KERNEL/ConvexIntersector.hxx +++ b/src/INTERP_KERNEL/ConvexIntersector.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __CONVEXINTERSECTOR_HXX__ diff --git a/src/INTERP_KERNEL/ConvexIntersector.txx b/src/INTERP_KERNEL/ConvexIntersector.txx index 45f6f4403..3c1cccb5f 100644 --- a/src/INTERP_KERNEL/ConvexIntersector.txx +++ b/src/INTERP_KERNEL/ConvexIntersector.txx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __CONVEXINTERSECTOR_TXX__ #define __CONVEXINTERSECTOR_TXX__ diff --git a/src/INTERP_KERNEL/CurveIntersector.hxx b/src/INTERP_KERNEL/CurveIntersector.hxx index 8e1f3929c..3264f9d11 100644 --- a/src/INTERP_KERNEL/CurveIntersector.hxx +++ b/src/INTERP_KERNEL/CurveIntersector.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __CURVEINTERSECTOR_HXX__ diff --git a/src/INTERP_KERNEL/CurveIntersector.txx b/src/INTERP_KERNEL/CurveIntersector.txx index 7fb2be48f..d0fb5f4e3 100644 --- a/src/INTERP_KERNEL/CurveIntersector.txx +++ b/src/INTERP_KERNEL/CurveIntersector.txx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __CURVEINTERSECTOR_TXX__ #define __CURVEINTERSECTOR_TXX__ diff --git a/src/INTERP_KERNEL/CurveIntersectorP0P0.hxx b/src/INTERP_KERNEL/CurveIntersectorP0P0.hxx index 3ce6f6ff5..23cdb9f3b 100644 --- a/src/INTERP_KERNEL/CurveIntersectorP0P0.hxx +++ b/src/INTERP_KERNEL/CurveIntersectorP0P0.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __CURVEINTERSECTORP0P0_HXX__ diff --git a/src/INTERP_KERNEL/CurveIntersectorP0P0.txx b/src/INTERP_KERNEL/CurveIntersectorP0P0.txx index a72c1ecca..2a823880e 100644 --- a/src/INTERP_KERNEL/CurveIntersectorP0P0.txx +++ b/src/INTERP_KERNEL/CurveIntersectorP0P0.txx @@ -1,20 +1,21 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// See http://www.salome-platform.org/ or email :webmaster.salome@opencascade.com #ifndef __CURVEINTERSECTORP0P0_TXX__ #define __CURVEINTERSECTORP0P0_TXX__ diff --git a/src/INTERP_KERNEL/CurveIntersectorP0P1.hxx b/src/INTERP_KERNEL/CurveIntersectorP0P1.hxx index 7d4b0cd0b..de14457a8 100644 --- a/src/INTERP_KERNEL/CurveIntersectorP0P1.hxx +++ b/src/INTERP_KERNEL/CurveIntersectorP0P1.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __CURVEINTERSECTORP0P1_HXX__ diff --git a/src/INTERP_KERNEL/CurveIntersectorP0P1.txx b/src/INTERP_KERNEL/CurveIntersectorP0P1.txx index 1947a9f5b..d6bed1d79 100644 --- a/src/INTERP_KERNEL/CurveIntersectorP0P1.txx +++ b/src/INTERP_KERNEL/CurveIntersectorP0P1.txx @@ -1,20 +1,21 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// See http://www.salome-platform.org/ or email :webmaster.salome@opencascade.com #ifndef __CurveIntersectorP0P1_TXX__ #define __CurveIntersectorP0P1_TXX__ diff --git a/src/INTERP_KERNEL/CurveIntersectorP1P0.hxx b/src/INTERP_KERNEL/CurveIntersectorP1P0.hxx index 914c28429..4fd5a9285 100644 --- a/src/INTERP_KERNEL/CurveIntersectorP1P0.hxx +++ b/src/INTERP_KERNEL/CurveIntersectorP1P0.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __CURVEINTERSECTORP1P0_HXX__ diff --git a/src/INTERP_KERNEL/CurveIntersectorP1P0.txx b/src/INTERP_KERNEL/CurveIntersectorP1P0.txx index f4e136dd3..b3f39e21b 100644 --- a/src/INTERP_KERNEL/CurveIntersectorP1P0.txx +++ b/src/INTERP_KERNEL/CurveIntersectorP1P0.txx @@ -1,20 +1,21 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// See http://www.salome-platform.org/ or email :webmaster.salome@opencascade.com #ifndef __CurveIntersectorP1P0_TXX__ #define __CurveIntersectorP1P0_TXX__ diff --git a/src/INTERP_KERNEL/CurveIntersectorP1P1.hxx b/src/INTERP_KERNEL/CurveIntersectorP1P1.hxx index 1df986724..41025289e 100644 --- a/src/INTERP_KERNEL/CurveIntersectorP1P1.hxx +++ b/src/INTERP_KERNEL/CurveIntersectorP1P1.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __CURVEINTERSECTORP1P1_HXX__ diff --git a/src/INTERP_KERNEL/CurveIntersectorP1P1.txx b/src/INTERP_KERNEL/CurveIntersectorP1P1.txx index 7be7429bb..d03a707c1 100644 --- a/src/INTERP_KERNEL/CurveIntersectorP1P1.txx +++ b/src/INTERP_KERNEL/CurveIntersectorP1P1.txx @@ -1,20 +1,21 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// See http://www.salome-platform.org/ or email :webmaster.salome@opencascade.com #ifndef __CurveIntersectorP1P1_TXX__ #define __CurveIntersectorP1P1_TXX__ diff --git a/src/INTERP_KERNEL/DirectedBoundingBox.cxx b/src/INTERP_KERNEL/DirectedBoundingBox.cxx index b59f78db6..5a1c4e148 100644 --- a/src/INTERP_KERNEL/DirectedBoundingBox.cxx +++ b/src/INTERP_KERNEL/DirectedBoundingBox.cxx @@ -1,20 +1,20 @@ -// Copyright (C) 2009-2010 OPEN CASCADE +// Copyright (C) 2009-2011 OPEN CASCADE // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // File : DirectedBoundingBox.cxx // Created : Mon Apr 12 14:41:22 2010 diff --git a/src/INTERP_KERNEL/DirectedBoundingBox.hxx b/src/INTERP_KERNEL/DirectedBoundingBox.hxx index 344f65909..d03d5aadf 100644 --- a/src/INTERP_KERNEL/DirectedBoundingBox.hxx +++ b/src/INTERP_KERNEL/DirectedBoundingBox.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2009-2010 OPEN CASCADE +// Copyright (C) 2009-2011 OPEN CASCADE // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __DIRECTEDBOUNDINGBOX_HXX__ diff --git a/src/INTERP_KERNEL/ExprEval/INTERPKERNELEXPREVALDefines.hxx b/src/INTERP_KERNEL/ExprEval/INTERPKERNELEXPREVALDefines.hxx index 8dbfa17f8..93c77b244 100644 --- a/src/INTERP_KERNEL/ExprEval/INTERPKERNELEXPREVALDefines.hxx +++ b/src/INTERP_KERNEL/ExprEval/INTERPKERNELEXPREVALDefines.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __INTERPKERNELEXPREVALDEFINES_HXX__ diff --git a/src/INTERP_KERNEL/ExprEval/InterpKernelAsmX86.cxx b/src/INTERP_KERNEL/ExprEval/InterpKernelAsmX86.cxx index ee7116fd2..cafd86973 100644 --- a/src/INTERP_KERNEL/ExprEval/InterpKernelAsmX86.cxx +++ b/src/INTERP_KERNEL/ExprEval/InterpKernelAsmX86.cxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "InterpKernelAsmX86.hxx" @@ -23,6 +23,14 @@ #include #include +#ifdef _POSIX_MAPPED_FILES +#include +#else +#ifdef WNT +#include +#endif +#endif + const char *INTERP_KERNEL::AsmX86::OPS[NB_OF_OPS]={"mov","push","pop","fld","faddp","fsubp","fmulp","fdivp","fcos","fsin","fabs","fchs","fsqrt","sub","add","ret","leave","movsd","fst"}; std::vector INTERP_KERNEL::AsmX86::convertIntoMachineLangage(const std::vector& asmb) const throw(INTERP_KERNEL::Exception) @@ -33,11 +41,20 @@ std::vector INTERP_KERNEL::AsmX86::convertIntoMachineLangage(const std::ve return ret; } -char *INTERP_KERNEL::AsmX86::convertMachineLangageInBasic(const std::vector& ml, int& lgth) const +char *INTERP_KERNEL::AsmX86::copyToExecMemZone(const std::vector& ml, unsigned& offset) const { - lgth=ml.size(); - char *ret=new char[lgth]; - std::copy(ml.begin(),ml.end(),ret); + char *ret=0; + int lgth=ml.size(); +#ifdef _POSIX_MAPPED_FILES + ret=(char *)mmap(0,lgth,PROT_EXEC | PROT_WRITE,MAP_ANONYMOUS | MAP_PRIVATE,-1,0); +#else +#ifdef WNT + HANDLE h=CreateFileMapping(INVALID_HANDLE_VALUE,NULL,PAGE_EXECUTE_READWRITE,0,lgth,NULL); + ret=(char *)MapViewOfFile(h,FILE_MAP_EXECUTE | FILE_MAP_READ | FILE_MAP_WRITE,0,0,lgth); +#endif +#endif + if(ret) + std::copy(ml.begin(),ml.end(),ret); return ret; } @@ -132,14 +149,14 @@ void INTERP_KERNEL::AsmX86::convertOneInstructionInML(const std::string& inst, s void INTERP_KERNEL::AsmX86::convertMov(const std::string& inst, std::vector& ml) throw(INTERP_KERNEL::Exception) { const char ASM1[]="ebp,esp"; - const char ML1[2]={0x89,0xe5}; + const unsigned char ML1[2]={0x89,0xe5}; if(inst==ASM1) { ml.insert(ml.end(),ML1,ML1+sizeof(ML1)); return ; } const char ASM2[]="rbp,rsp"; - const char ML2[3]={0x48,0x89,0xe5}; + const unsigned char ML2[3]={0x48,0x89,0xe5}; if(inst==ASM2) { ml.insert(ml.end(),ML2,ML2+sizeof(ML2)); @@ -169,7 +186,7 @@ void INTERP_KERNEL::AsmX86::convertMovToEsp(const std::string& inst1, const std: throw INTERP_KERNEL::Exception("not recognized convertMovToEsp exp !"); std::string inst1bis=inst1.substr(1,inst1.length()-2); const char ASM1[]="esp"; - const char ML1[3]={0xc7,0x04,0x24}; + const unsigned char ML1[3]={0xc7,0x04,0x24}; if(inst1bis==ASM1) {//mov dword [esp],0x3ff3c0ca ml.insert(ml.end(),ML1,ML1+sizeof(ML1)); @@ -180,7 +197,7 @@ void INTERP_KERNEL::AsmX86::convertMovToEsp(const std::string& inst1, const std: { if(inst1bis[3]=='+') {//mov dword [esp+4],0x3ff3c0ca - const char ML2[3]={0xc7,0x44,0x24}; + const unsigned char ML2[3]={0xc7,0x44,0x24}; ml.insert(ml.end(),ML2,ML2+sizeof(ML2)); std::string::size_type pos=inst1bis.find_first_of(']'); std::string inst1_1=inst1bis.substr(4,pos-4-1); @@ -192,7 +209,7 @@ void INTERP_KERNEL::AsmX86::convertMovToEsp(const std::string& inst1, const std: throw INTERP_KERNEL::Exception("Not recognized exp : mov [esp@..],..."); } const char ASM3[]="rsp"; - const char ML3[3]={0xc7,0x04,0x24}; + const unsigned char ML3[3]={0xc7,0x04,0x24}; if(inst1bis==ASM3) {//mov dword [rsp],0x3ff3c0ca ml.insert(ml.end(),ML3,ML3+sizeof(ML3)); @@ -203,7 +220,7 @@ void INTERP_KERNEL::AsmX86::convertMovToEsp(const std::string& inst1, const std: { if(inst1bis[3]=='+') {//mov dword [rsp+4],0x3ff3c0ca - const char ML2[3]={0xc7,0x44,0x24}; + const unsigned char ML2[3]={0xc7,0x44,0x24}; ml.insert(ml.end(),ML2,ML2+sizeof(ML2)); std::string::size_type pos=inst1bis.find_first_of(']'); std::string inst1_1=inst1bis.substr(4,pos-4-1); @@ -222,21 +239,21 @@ void INTERP_KERNEL::AsmX86::convertPush(const std::string& inst, std::vector& ml) throw(INTERP_KERNEL::Exception) { - const char ML1[2]={0xde,0xc1}; + 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) throw(INTERP_KERNEL::Exception) { - const char ML1[2]={0xde,0xe9}; + 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) throw(INTERP_KERNEL::Exception) { - const char ML1[2]={0xde,0xc9}; + 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) throw(INTERP_KERNEL::Exception) { - const char ML1[2]={0xde,0xf9}; + 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) throw(INTERP_KERNEL::Exception) { - const char ML[2]={0xd9,0xff}; + 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) throw(INTERP_KERNEL::Exception) { - const char ML[2]={0xd9,0xfe}; + 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) throw(INTERP_KERNEL::Exception) { - const char ML[2]={0xd9,0xe1}; + 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) throw(INTERP_KERNEL::Exception) { - const char ML[2]={0xd9,0xe0}; + 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) throw(INTERP_KERNEL::Exception) { - const char ML[2]={0xd9,0xfa}; + const unsigned char ML[2]={0xd9,0xfa}; ml.insert(ml.end(),ML,ML+sizeof(ML)); } @@ -375,7 +392,7 @@ void INTERP_KERNEL::AsmX86::convertSub(const std::string& inst, std::vector& ml) throw(INTERP_KERNEL::Exception) { - const char ML[1]={0xc3}; + 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) throw(INTERP_KERNEL::Exception) { - const char ML[1]={0xc9}; + const unsigned char ML[1]={0xc9}; ml.insert(ml.end(),ML,ML+sizeof(ML)); } void INTERP_KERNEL::AsmX86::convertMovsd(const std::string& inst, std::vector& ml) throw(INTERP_KERNEL::Exception) { const char ASM1[]="[rsp],xmm0"; - const char ML1[5]={0xf2,0x0f,0x11,0x04,0x24}; + const unsigned char ML1[5]={0xf2,0x0f,0x11,0x04,0x24}; if(inst==ASM1) { ml.insert(ml.end(),ML1,ML1+sizeof(ML1)); return ; } const char ASM2[]="xmm0,[rsp]"; - const char ML2[5]={0xf2,0x0f,0x10,0x04,0x24}; + const unsigned char ML2[5]={0xf2,0x0f,0x10,0x04,0x24}; if(inst==ASM2) { ml.insert(ml.end(),ML2,ML2+sizeof(ML2)); @@ -444,7 +461,7 @@ void INTERP_KERNEL::AsmX86::convertMovsd(const std::string& inst, std::vector& ml) throw(INTERP_KERNEL::Exception) { const char ASM1[]="qword [rsp]"; - const char ML1[3]={0xdd,0x14,0x24}; + const unsigned char ML1[3]={0xdd,0x14,0x24}; if(inst==ASM1) { ml.insert(ml.end(),ML1,ML1+sizeof(ML1)); diff --git a/src/INTERP_KERNEL/ExprEval/InterpKernelAsmX86.hxx b/src/INTERP_KERNEL/ExprEval/InterpKernelAsmX86.hxx index 11b8733e5..01d141402 100644 --- a/src/INTERP_KERNEL/ExprEval/InterpKernelAsmX86.hxx +++ b/src/INTERP_KERNEL/ExprEval/InterpKernelAsmX86.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __INTERPKERNELASMX86_HXX__ @@ -32,7 +32,7 @@ namespace INTERP_KERNEL { public: std::vector convertIntoMachineLangage(const std::vector& asmb) const throw(INTERP_KERNEL::Exception); - char *convertMachineLangageInBasic(const std::vector& ml, int& lgth) const; + char *copyToExecMemZone(const std::vector& ml, unsigned& offset) const; private: void convertOneInstructionInML(const std::string& inst, std::vector& ml) const throw(INTERP_KERNEL::Exception); private: diff --git a/src/INTERP_KERNEL/ExprEval/InterpKernelExprParser.cxx b/src/INTERP_KERNEL/ExprEval/InterpKernelExprParser.cxx index 585fac2f8..ff6edfb21 100644 --- a/src/INTERP_KERNEL/ExprEval/InterpKernelExprParser.cxx +++ b/src/INTERP_KERNEL/ExprEval/InterpKernelExprParser.cxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "InterpKernelExprParser.hxx" @@ -23,19 +23,12 @@ #include #include +#include #include #include #include #include -#ifdef _POSIX_MAPPED_FILES -#include -#else -#ifdef WNT -#include -#endif -#endif - using namespace INTERP_KERNEL; const char LeafExprVar::END_OF_RECOGNIZED_VAR[]="Vec"; @@ -81,6 +74,15 @@ void LeafExprVal::fillValue(Value *val) const throw(INTERP_KERNEL::Exception) val->setDouble(_value); } +void LeafExprVal::replaceValues(const std::vector& valuesInExpr) throw(INTERP_KERNEL::Exception) +{ + int pos=(int)_value; + int lgth=valuesInExpr.size(); + if(pos>=lgth || pos<0) + throw INTERP_KERNEL::Exception("LeafExprVal::replaceValues : Big Problem detected ! Send expression to Salome support with expression !"); + _value=valuesInExpr[pos]; +} + LeafExprVar::LeafExprVar(const std::string& var):_fast_pos(-1),_var_name(var) { } @@ -126,18 +128,27 @@ bool LeafExprVar::isRecognizedKeyVar(const std::string& var, int& pos) return true; } +/*! + * Nothing to do it is not a bug. + */ +void LeafExprVar::replaceValues(const std::vector& valuesInExpr) throw(INTERP_KERNEL::Exception) +{ +} + LeafExprVar::~LeafExprVar() { } ExprParser::ExprParser(const char *expr, ExprParser *father):_father(father),_is_parsed(false),_leaf(0),_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) { _expr=buildStringFromFortran(expr,lgth); + _expr=deleteWhiteSpaces(_expr); } ExprParser::~ExprParser() @@ -146,19 +157,22 @@ ExprParser::~ExprParser() releaseFunctions(); } -std::size_t ExprParser::findCorrespondingOpenBracket(const std::string& expr, std::size_t posOfCloseBracket) +std::size_t ExprParser::FindCorrespondingOpenBracket(const std::string& expr, std::size_t posOfCloseBracket) { int level=0; - for(std::size_t iter=posOfCloseBracket-1;iter>=0;iter--) - if(expr[iter]==')') - level++; - else if(expr[iter]=='(') - { - if(level==0) - return iter; - else - level--; - } + for(std::size_t iter=0;iter valuesInExpr; + fillValuesInExpr(valuesInExpr); checkBracketsParity(); if(!simplify()) parseDeeper(); + replaceValues(valuesInExpr); + _expr=tmp; } _is_parsing_ok=true; } @@ -384,12 +403,12 @@ void ExprParser::parseUnaryFunc() throw(INTERP_KERNEL::Exception) 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 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,5); - std::size_t pos3=funcName.find_first_not_of("+-*/^",0,5); + std::size_t pos2=funcName.find_first_of("+-*/^><",0,7); + std::size_t 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); @@ -409,7 +428,7 @@ void ExprParser::parseUnaryFunc() throw(INTERP_KERNEL::Exception) std::size_t pos6=0; for(int i=0;i",0,9); if(pos2!=std::string::npos) return false; delete _leaf; @@ -444,6 +463,66 @@ bool ExprParser::tryToInterpALeaf() throw(INTERP_KERNEL::Exception) return true; } +void ExprParser::parseForCmp() throw(INTERP_KERNEL::Exception) +{ + std::string::const_iterator iter; + int curLevel=0; + std::string curPart; + bool isParsingSucceed=false; + for(iter=_expr.begin();iter!=_expr.end();iter++) + { + switch(*iter) + { + case '>': + case '<': + { + isParsingSucceed=true; + if(!curPart.empty()) + { + _sub_expr.push_back(ExprParser(curPart.c_str(),this)); + curPart.clear(); + _func_btw_sub_expr.push_back(FunctionsFactory::buildBinaryFuncFromString(*iter)); + } + else + { + 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()); + LocateError(errMsg,tmp,0); + throw INTERP_KERNEL::Exception(errMsg.str().c_str()); + } + break; + } + case '(': + curLevel++; + curPart+=*iter; + break; + case ')': + curLevel--; + curPart+=*iter; + break; + default: + curPart+=*iter; + } + } + if(isParsingSucceed) + { + if(!curPart.empty()) + { + _sub_expr.push_back(ExprParser(curPart.c_str(),this)); + _is_parsing_ok=true; + } + else + { + std::ostringstream errMsg; + char MSGTYP4[]="Error following expression finished by > / < without right part."; + errMsg << EXPR_PARSE_ERR_MSG << MSGTYP4 << _expr; + throw INTERP_KERNEL::Exception(errMsg.str().c_str()); + } + } +} + void ExprParser::parseForAddMin() throw(INTERP_KERNEL::Exception) { std::string::const_iterator iter; @@ -535,7 +614,7 @@ void ExprParser::parseForMulDiv() throw(INTERP_KERNEL::Exception) char MSGTYP1[]="Error non unary function for '"; errMsg << EXPR_PARSE_ERR_MSG << MSGTYP1 << *iter << "'"; std::string tmp=_expr.substr(iter-_expr.begin()); - locateError(errMsg,tmp,0); + LocateError(errMsg,tmp,0); throw INTERP_KERNEL::Exception(errMsg.str().c_str()); } } @@ -596,7 +675,7 @@ void ExprParser::parseForPow() throw(INTERP_KERNEL::Exception) char MSGTYP1[]="Error non unary function for '"; errMsg << EXPR_PARSE_ERR_MSG << MSGTYP1 << *iter << "'"; std::string tmp=_expr.substr(iter-_expr.begin()); - locateError(errMsg,tmp,0);curPart+=*iter; + LocateError(errMsg,tmp,0);curPart+=*iter; throw INTERP_KERNEL::Exception(errMsg.str().c_str()); } break; @@ -648,12 +727,16 @@ bool ExprParser::simplify() throw(INTERP_KERNEL::Exception) parseUnaryFunc(); if(!_is_parsing_ok) { - parseForAddMin(); + parseForCmp(); if(!_is_parsing_ok) { - parseForMulDiv(); + parseForAddMin(); if(!_is_parsing_ok) - parseForPow(); + { + parseForMulDiv(); + if(!_is_parsing_ok) + parseForPow(); + } } } if(!_is_parsing_ok) @@ -661,7 +744,7 @@ bool ExprParser::simplify() throw(INTERP_KERNEL::Exception) std::ostringstream errMsg; char MSGTYP3[]="Error in interpreting : "; errMsg << EXPR_PARSE_ERR_MSG << MSGTYP3 << _expr; - locateError(errMsg,_expr,0); + LocateError(errMsg,_expr,0); throw INTERP_KERNEL::Exception(errMsg.str().c_str()); } return false; @@ -682,7 +765,7 @@ void ExprParser::checkBracketsParity() const throw(INTERP_KERNEL::Exception) std::ostringstream errMsg; char MSGTYP1[]="Error in brackets : closing brackets ')' before openning '('"; errMsg << EXPR_PARSE_ERR_MSG << MSGTYP1; - locateError(errMsg,_expr,iter-_expr.begin()); + LocateError(errMsg,_expr,iter-_expr.begin()); throw INTERP_KERNEL::Exception(errMsg.str().c_str()); } curLevel--; @@ -697,7 +780,139 @@ void ExprParser::checkBracketsParity() const throw(INTERP_KERNEL::Exception) } } -void ExprParser::locateError(std::ostream& stringToDisp, const std::string& srcOfErr, int posOfErr) +/*! + * This method substitutes part in [bg,end) in expr by the content of (str(id)) and returns the double value representation in expr[bg,end). + * If double representation is invalid an exception is thrown. + * This method returns a delta that is the delta to operate to pos in expr after substitution. + */ +double ExprParser::ReplaceAndTraduce(std::string& expr, int id, std::size_t bg, std::size_t end, int& delta) throw(INTERP_KERNEL::Exception) +{ + static const char MSG[]="Interal 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); + stream.str(tmp); + double ret=std::numeric_limits::max(); + stream >> ret; + if(stream.fail()) + throw INTERP_KERNEL::Exception(MSG); + if(!stream.eof()) + throw INTERP_KERNEL::Exception(MSG); + oss << id; + std::string tmp2(oss.str()); + std::size_t l1=tmp.length(); + delta=(int)tmp2.length()-(int)l1; + expr.replace(bg,l1,tmp2); + return ret; +} + +/*! + * This method makes the assumption that _expr has no white space. + * This method scans _expr finding in greedy mode the following pattern : + * {0..9}+{.}?{0..9}*{{eE}{-}?{0..9}+}? + */ +void ExprParser::fillValuesInExpr(std::vector& valuesInExpr) throw(INTERP_KERNEL::Exception) +{ + const char FIGURES[]="0123456789"; + const std::string other("+-*^/(<>,"); + std::size_t 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); + if(pos2>0) + {//treat case of "x*log10(x)" -> "10" should NOT be intercepted by this + if(other.find_first_of(_expr[pos2-1])==std::string::npos) + { + pos=_expr.find_first_not_of(FIGURES,pos2,10); + id--; + continue; + } + if(_expr[pos2-1]==')') + { + pos=_expr.find_first_not_of(FIGURES,pos2,10); + std::ostringstream oss; oss << "Problem on parsing : Number \"" << _expr.substr(pos2,pos!=std::string::npos?pos2-pos:std::string::npos); + oss << "\" is right after close parenthesis... ')'"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + } + if(pos2==std::string::npos) + break; + std::size_t pos3=_expr.find_first_not_of(FIGURES,pos2,10); + if(pos3==std::string::npos) + {//"x+1223442320" + valuesInExpr.push_back(ReplaceAndTraduce(_expr,id,pos2,std::string::npos,delta)); + break; + } + if(_expr[pos3]=='.') + pos3++; + if(pos3=lgth) + {//"x+1223334.223e+" or "1223334.223E-" + 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); + 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) << "\""; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + //OK, normal case + valuesInExpr.push_back(ReplaceAndTraduce(_expr,id,pos2,pos5,delta)); + pos=pos5+delta; + continue; + } + else//"x+1223334.223e" + { + std::ostringstream oss; oss << "Invalid expr : float number at the end of expr is invalid lacking number after exponential ! " << _expr.substr(pos2); + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + } + } + } + else + {//"x+1223334." + valuesInExpr.push_back(ReplaceAndTraduce(_expr,id,pos2,std::string::npos,delta)); + break; + } + } +} + +void ExprParser::replaceValues(const std::vector& valuesInExpr) throw(INTERP_KERNEL::Exception) +{ + if(_leaf) + _leaf->replaceValues(valuesInExpr); + else + { + for(std::list::iterator iter=_sub_expr.begin();iter!=_sub_expr.end();iter++) + (*iter).replaceValues(valuesInExpr); + } +} + +void ExprParser::LocateError(std::ostream& stringToDisp, const std::string& srcOfErr, int posOfErr) { stringToDisp << "Position is " << posOfErr << " of string : \"" << srcOfErr << "\"" << std::endl; } @@ -719,21 +934,8 @@ char *ExprParser::compileX86() const for(std::vector::const_iterator iter=output.begin();iter!=output.end();iter++) std::cout << std::hex << (int)((unsigned char)(*iter)) << " "; std::cout << std::endl; - int lgth; - char *lm=asmb.convertMachineLangageInBasic(output,lgth); - char *ret=0; -#ifdef _POSIX_MAPPED_FILES - ret=(char *)mmap(0,lgth,PROT_EXEC | PROT_WRITE,MAP_ANONYMOUS | MAP_PRIVATE,-1,0); -#else -#ifdef WNT - HANDLE h=CreateFileMapping(INVALID_HANDLE_VALUE,NULL,PAGE_EXECUTE_READWRITE,0,lgth,NULL); - ret=(char *)MapViewOfFile(h,FILE_MAP_EXECUTE | FILE_MAP_READ | FILE_MAP_WRITE,0,0,lgth); -#endif -#endif - if(ret) - std::copy(lm,lm+lgth,ret); - delete [] lm; - return ret; + unsigned offset; + return asmb.copyToExecMemZone(output,offset); } char *ExprParser::compileX86_64() const @@ -757,21 +959,8 @@ char *ExprParser::compileX86_64() const for(std::vector::const_iterator iter=output.begin();iter!=output.end();iter++) std::cout << std::hex << (int)((unsigned char)(*iter)) << " "; std::cout << std::endl; - int lgth; - char *lm=asmb.convertMachineLangageInBasic(output,lgth); - char *ret=0; -#ifdef _POSIX_MAPPED_FILES - ret=(char *)mmap(0,lgth,PROT_EXEC | PROT_WRITE,MAP_ANONYMOUS | MAP_PRIVATE,-1,0); -#else -#ifdef WNT - HANDLE h=CreateFileMapping(INVALID_HANDLE_VALUE,NULL,PAGE_EXECUTE_READWRITE,0,lgth,NULL); - ret=(char *)MapViewOfFile(h,FILE_MAP_EXECUTE | FILE_MAP_READ | FILE_MAP_WRITE,0,0,lgth); -#endif -#endif - if(ret) - std::copy(lm,lm+lgth,ret); - delete [] lm; - return ret; + unsigned offset; + return asmb.copyToExecMemZone(output,offset); } void ExprParser::compileX86LowLev(std::vector& ass) const @@ -782,9 +971,9 @@ void ExprParser::compileX86LowLev(std::vector& ass) const { for(std::list::const_iterator iter=_sub_expr.begin();iter!=_sub_expr.end();iter++) (*iter).compileX86LowLev(ass); - for(std::list::const_iterator iter2=_func_btw_sub_expr.begin();iter2!=_func_btw_sub_expr.end();iter2++) - (*iter2)->operateX86(ass); } + for(std::list::const_iterator iter2=_func_btw_sub_expr.begin();iter2!=_func_btw_sub_expr.end();iter2++) + (*iter2)->operateX86(ass); } void ExprParser::compileX86_64LowLev(std::vector& ass) const @@ -795,9 +984,9 @@ void ExprParser::compileX86_64LowLev(std::vector& ass) const { for(std::list::const_iterator iter=_sub_expr.begin();iter!=_sub_expr.end();iter++) (*iter).compileX86_64LowLev(ass); - for(std::list::const_iterator iter2=_func_btw_sub_expr.begin();iter2!=_func_btw_sub_expr.end();iter2++) - (*iter2)->operateX86(ass); } + for(std::list::const_iterator iter2=_func_btw_sub_expr.begin();iter2!=_func_btw_sub_expr.end();iter2++) + (*iter2)->operateX86(ass); } void LeafExprVal::compileX86(std::vector& ass) const diff --git a/src/INTERP_KERNEL/ExprEval/InterpKernelExprParser.hxx b/src/INTERP_KERNEL/ExprEval/InterpKernelExprParser.hxx index 7ff8babb5..eef4f640d 100644 --- a/src/INTERP_KERNEL/ExprEval/InterpKernelExprParser.hxx +++ b/src/INTERP_KERNEL/ExprEval/InterpKernelExprParser.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __INTERPKERNELEXPRPARSER_HXX__ @@ -41,6 +41,7 @@ namespace INTERP_KERNEL virtual void fillValue(Value *val) const throw(INTERP_KERNEL::Exception) = 0; virtual void compileX86(std::vector& ass) const = 0; virtual void compileX86_64(std::vector& ass) const = 0; + virtual void replaceValues(const std::vector& valuesInExpr) throw(INTERP_KERNEL::Exception) = 0; static LeafExpr *buildInstanceFrom(const std::string& expr) throw(INTERP_KERNEL::Exception); }; @@ -52,6 +53,7 @@ namespace INTERP_KERNEL void compileX86(std::vector& ass) const; void compileX86_64(std::vector& ass) const; void fillValue(Value *val) const throw(INTERP_KERNEL::Exception); + void replaceValues(const std::vector& valuesInExpr) throw(INTERP_KERNEL::Exception); private: double _value; }; @@ -67,6 +69,7 @@ namespace INTERP_KERNEL std::string getVar() const { return _var_name; } void prepareExprEvaluation(const std::vector& vars) const throw(INTERP_KERNEL::Exception); void prepareExprEvaluationVec() const throw(INTERP_KERNEL::Exception); + void replaceValues(const std::vector& valuesInExpr) throw(INTERP_KERNEL::Exception); static bool isRecognizedKeyVar(const std::string& var, int& pos); public: static const char END_OF_RECOGNIZED_VAR[]; @@ -105,6 +108,7 @@ namespace INTERP_KERNEL void prepareExprEvaluationVecLowLev() const throw(INTERP_KERNEL::Exception); bool tryToInterpALeaf() throw(INTERP_KERNEL::Exception); void parseUnaryFunc() throw(INTERP_KERNEL::Exception); + void parseForCmp() throw(INTERP_KERNEL::Exception); void parseForAddMin() throw(INTERP_KERNEL::Exception); void parseForMulDiv() throw(INTERP_KERNEL::Exception); void parseForPow() throw(INTERP_KERNEL::Exception); @@ -112,8 +116,11 @@ namespace INTERP_KERNEL bool simplify() throw(INTERP_KERNEL::Exception); void releaseFunctions(); void checkBracketsParity() const throw(INTERP_KERNEL::Exception); - static std::size_t findCorrespondingOpenBracket(const std::string& expr, std::size_t posOfCloseBracket); - static void locateError(std::ostream& stringToDisp, const std::string& srcOfErr, int posOfErr); + void fillValuesInExpr(std::vector& valuesInExpr) throw(INTERP_KERNEL::Exception); + void replaceValues(const std::vector& valuesInExpr) throw(INTERP_KERNEL::Exception); + static double ReplaceAndTraduce(std::string& expr, int id, std::size_t bg, std::size_t end, int& delta) throw(INTERP_KERNEL::Exception); + static std::size_t FindCorrespondingOpenBracket(const std::string& expr, std::size_t posOfCloseBracket); + static void LocateError(std::ostream& stringToDisp, const std::string& srcOfErr, int posOfErr); private: ExprParser *_father; bool _is_parsed; diff --git a/src/INTERP_KERNEL/ExprEval/InterpKernelFunction.cxx b/src/INTERP_KERNEL/ExprEval/InterpKernelFunction.cxx index dd16329f6..c307a4460 100644 --- a/src/INTERP_KERNEL/ExprEval/InterpKernelFunction.cxx +++ b/src/INTERP_KERNEL/ExprEval/InterpKernelFunction.cxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "InterpKernelFunction.hxx" @@ -54,10 +54,20 @@ const char ExpFunction::REPR[]="exp"; const char LnFunction::REPR[]="ln"; +const char LogFunction::REPR[]="log"; + +const char Log10Function::REPR[]="log10"; + const char MaxFunction::REPR[]="max"; const char MinFunction::REPR[]="min"; +const char GreaterThanFunction::REPR[]=">"; + +const char LowerThanFunction::REPR[]="<"; + +const char IfFunction::REPR[]="if"; + Function *FunctionsFactory::buildFuncFromString(const char *type, int nbOfParams) throw(INTERP_KERNEL::Exception) { switch(nbOfParams) @@ -66,6 +76,8 @@ Function *FunctionsFactory::buildFuncFromString(const char *type, int nbOfParams return buildUnaryFuncFromString(type); case 2: return buildBinaryFuncFromString(type); + case 3: + return buildTernaryFuncFromString(type); default: throw INTERP_KERNEL::Exception("Invalid number of params detected : limited to 2 !"); } @@ -94,6 +106,10 @@ Function *FunctionsFactory::buildUnaryFuncFromString(const char *type) throw(INT return new ExpFunction; if(tmp==LnFunction::REPR) return new LnFunction; + if(tmp==LogFunction::REPR) + return new LogFunction; + if(tmp==Log10Function::REPR) + return new Log10Function; // std::string msg("Invalid unary function detected : \""); msg+=type; msg+="\""; @@ -117,11 +133,25 @@ Function *FunctionsFactory::buildBinaryFuncFromString(const char *type) throw(IN return new MaxFunction; if(tmp==MinFunction::REPR) return new MinFunction; + if(tmp==GreaterThanFunction::REPR) + return new GreaterThanFunction; + if(tmp==LowerThanFunction::REPR) + return new LowerThanFunction; std::string msg("Invalid binary function detected : \""); msg+=type; msg+="\""; throw INTERP_KERNEL::Exception(msg.c_str()); } +Function *FunctionsFactory::buildTernaryFuncFromString(const char *type) throw(INTERP_KERNEL::Exception) +{ + std::string tmp(type); + if(tmp==IfFunction::REPR) + return new IfFunction(); + std::string msg("Invalid ternary function detected : \""); + msg+=type; msg+="\""; + throw INTERP_KERNEL::Exception(msg.c_str()); +} + Function *FunctionsFactory::buildBinaryFuncFromString(char type) throw(INTERP_KERNEL::Exception) { char tmp[2]; tmp[0]=type; tmp[1]='\0'; @@ -377,6 +407,56 @@ bool LnFunction::isACall() const return true; } +LogFunction::~LogFunction() +{ +} + +void LogFunction::operate(std::vector& stack) const throw(INTERP_KERNEL::Exception) +{ + Value *val=stack.back(); + val->ln(); +} + +void LogFunction::operateX86(std::vector& asmb) const throw(INTERP_KERNEL::Exception) +{ + throw INTERP_KERNEL::Exception("Assembly for log Not implemented yet !"); +} + +const char *LogFunction::getRepr() const +{ + return REPR; +} + +bool LogFunction::isACall() const +{ + return true; +} + +Log10Function::~Log10Function() +{ +} + +void Log10Function::operate(std::vector& stack) const throw(INTERP_KERNEL::Exception) +{ + Value *val=stack.back(); + val->log10(); +} + +void Log10Function::operateX86(std::vector& asmb) const throw(INTERP_KERNEL::Exception) +{ + throw INTERP_KERNEL::Exception("Assembly for log Not implemented yet !"); +} + +const char *Log10Function::getRepr() const +{ + return REPR; +} + +bool Log10Function::isACall() const +{ + return true; +} + int BinaryFunction::getNbInputParams() const { return 2; @@ -649,3 +729,130 @@ bool MinFunction::isACall() const { return false; } + +GreaterThanFunction::~GreaterThanFunction() +{ +} + +void GreaterThanFunction::operate(std::vector& stack) const throw(INTERP_KERNEL::Exception) +{ + Value *val1=stack.back(); + stack.pop_back(); + Value *& val2=stack.back(); + Value *val3; + try + { + val3=val1->greaterThan(val2); + } + catch(INTERP_KERNEL::Exception& e) + { + delete val1; + throw e; + } + delete val1; + delete val2; + val2=val3; +} + +void GreaterThanFunction::operateX86(std::vector& asmb) const throw(INTERP_KERNEL::Exception) +{ + throw INTERP_KERNEL::Exception("Assembly Not implemented yet !"); +} + +const char *GreaterThanFunction::getRepr() const +{ + return REPR; +} + +bool GreaterThanFunction::isACall() const +{ + return false; +} + +LowerThanFunction::~LowerThanFunction() +{ +} + +void LowerThanFunction::operate(std::vector& stack) const throw(INTERP_KERNEL::Exception) +{ + Value *val1=stack.back(); + stack.pop_back(); + Value *& val2=stack.back(); + Value *val3; + try + { + val3=val1->lowerThan(val2); + } + catch(INTERP_KERNEL::Exception& e) + { + delete val1; + throw e; + } + delete val1; + delete val2; + val2=val3; +} + +void LowerThanFunction::operateX86(std::vector& asmb) const throw(INTERP_KERNEL::Exception) +{ + throw INTERP_KERNEL::Exception("Assembly Not implemented yet !"); +} + +const char *LowerThanFunction::getRepr() const +{ + return REPR; +} + +bool LowerThanFunction::isACall() const +{ + return false; +} + +int TernaryFunction::getNbInputParams() const +{ + return 3; +} + +IfFunction::~IfFunction() +{ +} + +void IfFunction::operate(std::vector& stack) const throw(INTERP_KERNEL::Exception) +{ + Value *val1=stack.back(); + stack.pop_back(); + Value *val2=stack.back(); + stack.pop_back(); + Value *&val3=stack.back(); + Value *val4; + try + { + val4=val1->ifFunc(val2,val3); + } + catch(INTERP_KERNEL::Exception& e) + { + delete val1; + delete val2; + throw e; + } + delete val1; + delete val2; + delete val3; + val3=val4; +} + +void IfFunction::operateX86(std::vector& asmb) const throw(INTERP_KERNEL::Exception) +{ + throw INTERP_KERNEL::Exception("Assembly Not implemented yet !"); +} + +const char *IfFunction::getRepr() const +{ + return REPR; +} + +bool IfFunction::isACall() const +{ + return false; +} + diff --git a/src/INTERP_KERNEL/ExprEval/InterpKernelFunction.hxx b/src/INTERP_KERNEL/ExprEval/InterpKernelFunction.hxx index 160e15ba9..1283a4c8c 100644 --- a/src/INTERP_KERNEL/ExprEval/InterpKernelFunction.hxx +++ b/src/INTERP_KERNEL/ExprEval/InterpKernelFunction.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __INTERPKERNELFUNCTION_HXX__ @@ -38,6 +38,7 @@ namespace INTERP_KERNEL //static Function *buildUnaryFuncFromString(char type) throw(INTERP_KERNEL::Exception); static Function *buildBinaryFuncFromString(const char *type) throw(INTERP_KERNEL::Exception); static Function *buildBinaryFuncFromString(char type) throw(INTERP_KERNEL::Exception); + static Function *buildTernaryFuncFromString(const char *type) throw(INTERP_KERNEL::Exception); }; class INTERPKERNELEXPREVAL_EXPORT Function @@ -177,6 +178,30 @@ namespace INTERP_KERNEL static const char REPR[]; }; + class INTERPKERNELEXPREVAL_EXPORT LogFunction : public UnaryFunction + { + public: + ~LogFunction(); + void operate(std::vector& stack) const throw(INTERP_KERNEL::Exception); + void operateX86(std::vector& asmb) const throw(INTERP_KERNEL::Exception); + const char *getRepr() const; + bool isACall() const; + public: + static const char REPR[]; + }; + + class INTERPKERNELEXPREVAL_EXPORT Log10Function : public UnaryFunction + { + public: + ~Log10Function(); + void operate(std::vector& stack) const throw(INTERP_KERNEL::Exception); + void operateX86(std::vector& asmb) const throw(INTERP_KERNEL::Exception); + const char *getRepr() const; + bool isACall() const; + public: + static const char REPR[]; + }; + class INTERPKERNELEXPREVAL_EXPORT BinaryFunction : public Function { public: @@ -266,6 +291,48 @@ namespace INTERP_KERNEL public: static const char REPR[]; }; + + class INTERPKERNELEXPREVAL_EXPORT GreaterThanFunction : public BinaryFunction + { + public: + ~GreaterThanFunction(); + void operate(std::vector& stack) const throw(INTERP_KERNEL::Exception); + void operateX86(std::vector& asmb) const throw(INTERP_KERNEL::Exception); + const char *getRepr() const; + bool isACall() const; + public: + static const char REPR[]; + }; + + class INTERPKERNELEXPREVAL_EXPORT LowerThanFunction : public BinaryFunction + { + public: + ~LowerThanFunction(); + void operate(std::vector& stack) const throw(INTERP_KERNEL::Exception); + void operateX86(std::vector& asmb) const throw(INTERP_KERNEL::Exception); + const char *getRepr() const; + bool isACall() const; + public: + static const char REPR[]; + }; + + class INTERPKERNELEXPREVAL_EXPORT TernaryFunction : public Function + { + public: + int getNbInputParams() const; + }; + + class INTERPKERNELEXPREVAL_EXPORT IfFunction : public TernaryFunction + { + public: + ~IfFunction(); + void operate(std::vector& stack) const throw(INTERP_KERNEL::Exception); + void operateX86(std::vector& asmb) const throw(INTERP_KERNEL::Exception); + const char *getRepr() const; + bool isACall() const; + public: + static const char REPR[]; + }; } #endif diff --git a/src/INTERP_KERNEL/ExprEval/InterpKernelUnit.cxx b/src/INTERP_KERNEL/ExprEval/InterpKernelUnit.cxx index 6eacf7221..3ff74c745 100644 --- a/src/INTERP_KERNEL/ExprEval/InterpKernelUnit.cxx +++ b/src/INTERP_KERNEL/ExprEval/InterpKernelUnit.cxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "InterpKernelUnit.hxx" diff --git a/src/INTERP_KERNEL/ExprEval/InterpKernelUnit.hxx b/src/INTERP_KERNEL/ExprEval/InterpKernelUnit.hxx index 1c5b50ee8..ce090dcb6 100644 --- a/src/INTERP_KERNEL/ExprEval/InterpKernelUnit.hxx +++ b/src/INTERP_KERNEL/ExprEval/InterpKernelUnit.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __INTERPKERNELUNIT_HXX__ diff --git a/src/INTERP_KERNEL/ExprEval/InterpKernelValue.cxx b/src/INTERP_KERNEL/ExprEval/InterpKernelValue.cxx index 5e3bcfe19..33561be76 100644 --- a/src/INTERP_KERNEL/ExprEval/InterpKernelValue.cxx +++ b/src/INTERP_KERNEL/ExprEval/InterpKernelValue.cxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "InterpKernelValue.hxx" @@ -90,11 +90,16 @@ void ValueDouble::exp() throw(INTERP_KERNEL::Exception) _data=std::exp(_data); } -void ValueDouble:: ln() throw(INTERP_KERNEL::Exception) +void ValueDouble::ln() throw(INTERP_KERNEL::Exception) { _data=std::log(_data); } +void ValueDouble::log10() throw(INTERP_KERNEL::Exception) +{ + _data=std::log10(_data); +} + Value *ValueDouble::plus(const Value *other) const throw(INTERP_KERNEL::Exception) { const ValueDouble *valC=checkSameType(other); @@ -137,6 +142,29 @@ Value *ValueDouble::min(const Value *other) const throw(INTERP_KERNEL::Exception return new ValueDouble(std::min(_data,valC->_data)); } +Value *ValueDouble::greaterThan(const Value *other) const throw(INTERP_KERNEL::Exception) +{ + const ValueDouble *valC=checkSameType(other); + return new ValueDouble(_data>valC->_data?std::numeric_limits::max():-std::numeric_limits::max()); +} + +Value *ValueDouble::lowerThan(const Value *other) const throw(INTERP_KERNEL::Exception) +{ + const ValueDouble *valC=checkSameType(other); + return new ValueDouble(_data_data?std::numeric_limits::max():-std::numeric_limits::max()); +} + +Value *ValueDouble::ifFunc(const Value *the, const Value *els) const throw(INTERP_KERNEL::Exception) +{ + const ValueDouble *theC=checkSameType(the); + const ValueDouble *elsC=checkSameType(els); + if(_data==std::numeric_limits::max()) + return new ValueDouble(theC->_data); + if(_data==-std::numeric_limits::max()) + return new ValueDouble(elsC->_data); + throw INTERP_KERNEL::Exception("ValueDouble::ifFunc : The fist element of ternary function if is not a binary op !"); +} + const ValueDouble *ValueDouble::checkSameType(const Value *val) throw(INTERP_KERNEL::Exception) { const ValueDouble *valC=dynamic_cast(val); @@ -215,6 +243,11 @@ void ValueUnit::ln() throw(INTERP_KERNEL::Exception) unsupportedOp(LnFunction::REPR); } +void ValueUnit::log10() throw(INTERP_KERNEL::Exception) +{ + unsupportedOp(Log10Function::REPR); +} + Value *ValueUnit::plus(const Value *other) const throw(INTERP_KERNEL::Exception) { unsupportedOp(PlusFunction::REPR); @@ -227,6 +260,24 @@ Value *ValueUnit::minus(const Value *other) const throw(INTERP_KERNEL::Exception return 0; } +Value *ValueUnit::greaterThan(const Value *other) const throw(INTERP_KERNEL::Exception) +{ + unsupportedOp(GreaterThanFunction::REPR); + return 0; +} + +Value *ValueUnit::lowerThan(const Value *other) const throw(INTERP_KERNEL::Exception) +{ + unsupportedOp(LowerThanFunction::REPR); + return 0; +} + +Value *ValueUnit::ifFunc(const Value *the, const Value *els) const throw(INTERP_KERNEL::Exception) +{ + unsupportedOp(IfFunction::REPR); + return 0; +} + Value *ValueUnit::mult(const Value *other) const throw(INTERP_KERNEL::Exception) { const ValueUnit *valC=checkSameType(other); @@ -357,10 +408,18 @@ void ValueDoubleExpr::ln() throw(INTERP_KERNEL::Exception) { double *it=std::find_if(_dest_data,_dest_data+_sz_dest_data,std::bind2nd(std::less_equal(),0.)); if(it!=_dest_data+_sz_dest_data) - throw INTERP_KERNEL::Exception("Trying to apply sqrt on < 0. value !"); + throw INTERP_KERNEL::Exception("Trying to apply neperian/natural log on <= 0. value !"); std::transform(_dest_data,_dest_data+_sz_dest_data,_dest_data,std::ptr_fun(std::log)); } +void ValueDoubleExpr::log10() throw(INTERP_KERNEL::Exception) +{ + double *it=std::find_if(_dest_data,_dest_data+_sz_dest_data,std::bind2nd(std::less_equal(),0.)); + if(it!=_dest_data+_sz_dest_data) + throw INTERP_KERNEL::Exception("Trying to apply log10 on <= 0. value !"); + std::transform(_dest_data,_dest_data+_sz_dest_data,_dest_data,std::ptr_fun(std::log10)); +} + Value *ValueDoubleExpr::plus(const Value *other) const throw(INTERP_KERNEL::Exception) { const ValueDoubleExpr *otherC=static_cast(other); @@ -423,3 +482,57 @@ Value *ValueDoubleExpr::min(const Value *other) const throw(INTERP_KERNEL::Excep std::transform(_dest_data,_dest_data+_sz_dest_data,otherC->getData(),ret->getData(),std::ptr_fun(std::min)); return ret; } + +Value *ValueDoubleExpr::greaterThan(const Value *other) const throw(INTERP_KERNEL::Exception) +{ + const ValueDoubleExpr *otherC=static_cast(other); + ValueDoubleExpr *ret=new ValueDoubleExpr(_sz_dest_data,_src_data); + for(int i=0;i<_sz_dest_data;i++) + if(_dest_data[i]<=otherC->getData()[i]) + { + std::fill(ret->getData(),ret->getData()+_sz_dest_data,-std::numeric_limits::max()); + return ret; + } + std::fill(ret->getData(),ret->getData()+_sz_dest_data,std::numeric_limits::max()); + return ret; +} + +Value *ValueDoubleExpr::lowerThan(const Value *other) const throw(INTERP_KERNEL::Exception) +{ + const ValueDoubleExpr *otherC=static_cast(other); + ValueDoubleExpr *ret=new ValueDoubleExpr(_sz_dest_data,_src_data); + for(int i=0;i<_sz_dest_data;i++) + if(_dest_data[i]>=otherC->getData()[i]) + { + std::fill(ret->getData(),ret->getData()+_sz_dest_data,-std::numeric_limits::max()); + return ret; + } + std::fill(ret->getData(),ret->getData()+_sz_dest_data,std::numeric_limits::max()); + return ret; +} + +Value *ValueDoubleExpr::ifFunc(const Value *the, const Value *els) const throw(INTERP_KERNEL::Exception) +{ + const ValueDoubleExpr *theC=static_cast(the); + const ValueDoubleExpr *elsC=static_cast(els); + ValueDoubleExpr *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++) + { + okmax=_dest_data[i]==std::numeric_limits::max(); + okmin=_dest_data[i]==-std::numeric_limits::max(); + } + if(okmax || okmin) + { + if(okmax) + std::copy(theC->getData(),theC->getData()+_sz_dest_data,ret->getData()); + else + std::copy(elsC->getData(),elsC->getData()+_sz_dest_data,ret->getData()); + return ret; + } + else + { + throw INTERP_KERNEL::Exception("ValueDoubleExpr::ifFunc : first parameter of ternary func is NOT a consequence of a boolean op !"); + } +} diff --git a/src/INTERP_KERNEL/ExprEval/InterpKernelValue.hxx b/src/INTERP_KERNEL/ExprEval/InterpKernelValue.hxx index 95ac2e66b..401a9cfe8 100644 --- a/src/INTERP_KERNEL/ExprEval/InterpKernelValue.hxx +++ b/src/INTERP_KERNEL/ExprEval/InterpKernelValue.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __INTERPKERNELVALUE_HXX__ @@ -43,6 +43,7 @@ namespace INTERP_KERNEL virtual void abs() throw(INTERP_KERNEL::Exception) = 0; virtual void exp() throw(INTERP_KERNEL::Exception) = 0; virtual void ln() throw(INTERP_KERNEL::Exception) = 0; + virtual void log10() throw(INTERP_KERNEL::Exception) = 0; //binary virtual Value *plus(const Value *other) const throw(INTERP_KERNEL::Exception) = 0; virtual Value *minus(const Value *other) const throw(INTERP_KERNEL::Exception) = 0; @@ -51,6 +52,10 @@ namespace INTERP_KERNEL virtual Value *pow(const Value *other) const throw(INTERP_KERNEL::Exception) = 0; virtual Value *max(const Value *other) const throw(INTERP_KERNEL::Exception) = 0; virtual Value *min(const Value *other) const throw(INTERP_KERNEL::Exception) = 0; + virtual Value *greaterThan(const Value *other) const throw(INTERP_KERNEL::Exception) = 0; + virtual Value *lowerThan(const Value *other) const throw(INTERP_KERNEL::Exception) = 0; + //ternary + virtual Value *ifFunc(const Value *the, const Value *els) const throw(INTERP_KERNEL::Exception) = 0; }; class INTERPKERNELEXPREVAL_EXPORT ValueDouble : public Value @@ -71,6 +76,7 @@ namespace INTERP_KERNEL void abs() throw(INTERP_KERNEL::Exception); void exp() throw(INTERP_KERNEL::Exception); void ln() throw(INTERP_KERNEL::Exception); + void log10() throw(INTERP_KERNEL::Exception); // Value *plus(const Value *other) const throw(INTERP_KERNEL::Exception); Value *minus(const Value *other) const throw(INTERP_KERNEL::Exception); @@ -79,6 +85,10 @@ namespace INTERP_KERNEL Value *pow(const Value *other) const throw(INTERP_KERNEL::Exception); Value *max(const Value *other) const throw(INTERP_KERNEL::Exception); Value *min(const Value *other) const throw(INTERP_KERNEL::Exception); + Value *greaterThan(const Value *other) const throw(INTERP_KERNEL::Exception); + Value *lowerThan(const Value *other) const throw(INTERP_KERNEL::Exception); + // + Value *ifFunc(const Value *the, const Value *els) const throw(INTERP_KERNEL::Exception); private: ValueDouble(double val); static const ValueDouble *checkSameType(const Value *val) throw(INTERP_KERNEL::Exception); @@ -104,6 +114,7 @@ namespace INTERP_KERNEL void abs() throw(INTERP_KERNEL::Exception); void exp() throw(INTERP_KERNEL::Exception); void ln() throw(INTERP_KERNEL::Exception); + void log10() throw(INTERP_KERNEL::Exception); // Value *plus(const Value *other) const throw(INTERP_KERNEL::Exception); Value *minus(const Value *other) const throw(INTERP_KERNEL::Exception); @@ -112,6 +123,10 @@ namespace INTERP_KERNEL Value *pow(const Value *other) const throw(INTERP_KERNEL::Exception); Value *max(const Value *other) const throw(INTERP_KERNEL::Exception); Value *min(const Value *other) const throw(INTERP_KERNEL::Exception); + Value *greaterThan(const Value *other) const throw(INTERP_KERNEL::Exception); + Value *lowerThan(const Value *other) const throw(INTERP_KERNEL::Exception); + // + Value *ifFunc(const Value *the, const Value *els) const throw(INTERP_KERNEL::Exception); private: ValueUnit(const DecompositionInUnitBase& unit); static void unsupportedOp(const char *type) throw(INTERP_KERNEL::Exception); @@ -139,6 +154,7 @@ namespace INTERP_KERNEL void abs() throw(INTERP_KERNEL::Exception); void exp() throw(INTERP_KERNEL::Exception); void ln() throw(INTERP_KERNEL::Exception); + void log10() throw(INTERP_KERNEL::Exception); // Value *plus(const Value *other) const throw(INTERP_KERNEL::Exception); Value *minus(const Value *other) const throw(INTERP_KERNEL::Exception); @@ -147,6 +163,10 @@ namespace INTERP_KERNEL Value *pow(const Value *other) const throw(INTERP_KERNEL::Exception); Value *max(const Value *other) const throw(INTERP_KERNEL::Exception); Value *min(const Value *other) const throw(INTERP_KERNEL::Exception); + Value *greaterThan(const Value *other) const throw(INTERP_KERNEL::Exception); + Value *lowerThan(const Value *other) const throw(INTERP_KERNEL::Exception); + // + Value *ifFunc(const Value *the, const Value *els) const throw(INTERP_KERNEL::Exception); private: int _sz_dest_data; double *_dest_data; diff --git a/src/INTERP_KERNEL/ExprEval/Makefile.am b/src/INTERP_KERNEL/ExprEval/Makefile.am index 28f5e9124..f03209061 100644 --- a/src/INTERP_KERNEL/ExprEval/Makefile.am +++ b/src/INTERP_KERNEL/ExprEval/Makefile.am @@ -1,20 +1,20 @@ -# Copyright (C) 2007-2010 CEA/DEN, EDF R&D +# Copyright (C) 2007-2011 CEA/DEN, EDF R&D # -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. # -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. # -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # # File : Makefile.am diff --git a/src/INTERP_KERNEL/GaussPoints/InterpKernelGaussCoords.cxx b/src/INTERP_KERNEL/GaussPoints/InterpKernelGaussCoords.cxx new file mode 100644 index 000000000..519977f8a --- /dev/null +++ b/src/INTERP_KERNEL/GaussPoints/InterpKernelGaussCoords.cxx @@ -0,0 +1,2130 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +//Local includes +#include "InterpKernelGaussCoords.hxx" +#include "CellModel.hxx" + +//STL includes +#include +#include +#include + +using namespace INTERP_KERNEL; + +//Define common part of the code in the MACRO +//--------------------------------------------------------------- +#define LOCAL_COORD_MACRO_BEGIN \ + _my_local_reference_coord.resize( _my_local_ref_dim*_my_local_nb_ref ); \ + for( int refId = 0; refId < _my_local_nb_ref; refId++ ) \ + { \ + double* coords = &_my_local_reference_coord[ refId*_my_local_ref_dim ]; \ + switch(refId) \ + { + +//--------------------------------------------------------------- +#define LOCAL_COORD_MACRO_END \ + } \ +} + +//--------------------------------------------------------------- +#define SHAPE_FUN_MACRO_BEGIN \ + for( int gaussId = 0 ; gaussId < _my_nb_gauss ; gaussId++ ) \ + { \ + double* funValue = &_my_function_value[ gaussId * _my_nb_ref ]; \ + const double* gc = &_my_gauss_coord[ gaussId * getGaussCoordDim() ]; + +//--------------------------------------------------------------- +#define SHAPE_FUN_MACRO_END \ + } + +#define CHECK_MACRO \ + if( ! aSatify ) \ + { \ + std::ostringstream stream; \ + stream << "Error in the gauss localization for the cell with type "; \ + stream << cellModel.getRepr(); \ + stream << " !!!"; \ + throw INTERP_KERNEL::Exception(stream.str().c_str()); \ + } + + +//--------------------------------------------------------------- +static bool IsEqual(double theLeft, double theRight) +{ + static double EPS = 1.0E-3; + if(fabs(theLeft) + fabs(theRight) > EPS) + return fabs(theLeft-theRight)/(fabs(theLeft)+fabs(theRight)) < EPS; + return true; +} + + +//////////////////////////////////////////////////////////////////////////////////////////////// +// GAUSS INFO CLASS // +//////////////////////////////////////////////////////////////////////////////////////////////// + +/*! + * Constructor of the GaussInfo + */ +GaussInfo::GaussInfo( NormalizedCellType theGeometry, + const DataVector& theGaussCoord, + int theNbGauss, + const DataVector& theReferenceCoord, + int theNbRef ) : + _my_geometry(theGeometry), + _my_nb_gauss(theNbGauss), + _my_gauss_coord(theGaussCoord), + _my_nb_ref(theNbRef), + _my_reference_coord(theReferenceCoord) +{ + + //Allocate shape function values + _my_function_value.resize( _my_nb_gauss * _my_nb_ref ); +} + +/*! + * Destructor + */ +GaussInfo::~GaussInfo() +{ +} + +/*! + * Return dimension of the gauss coordinates + */ +int GaussInfo::getGaussCoordDim() const +{ + if( _my_nb_gauss ) + { + return _my_gauss_coord.size()/_my_nb_gauss; + } + else + { + return 0; + } +} + +/*! + * Return dimension of the reference coordinates + */ +int GaussInfo::getReferenceCoordDim() const +{ + if( _my_nb_ref ) + { + return _my_reference_coord.size()/_my_nb_ref; + } + else + { + return 0; + } +} + +/*! + * Return type of the cell. + */ +NormalizedCellType GaussInfo::getCellType() const +{ + return _my_geometry; +} + +/*! + * Return Nb of the gauss points. + */ +int GaussInfo::getNbGauss() const +{ + return _my_nb_gauss; +} + +/*! + * Return Nb of the reference coordinates. + */ +int GaussInfo::getNbRef() const +{ + return _my_nb_ref; +} + +/*! + * Check coordinates + */ +bool GaussInfo::isSatisfy() +{ + + bool anIsSatisfy = ((_my_local_nb_ref == _my_nb_ref) && (_my_local_ref_dim == getReferenceCoordDim())); + //Check coordinates + if(anIsSatisfy) + { + for( int refId = 0; refId < _my_local_nb_ref; refId++ ) + { + double* refCoord = &_my_reference_coord[ refId*_my_local_ref_dim ]; + double* localRefCoord = &_my_local_reference_coord[ refId*_my_local_ref_dim ]; + bool anIsEqual = false; + for( int dimId = 0; dimId < _my_local_ref_dim; dimId++ ) + { + anIsEqual = IsEqual( localRefCoord[dimId], refCoord[dimId]); + if(!anIsEqual ) + { + return false; + } + } + } + } + return anIsSatisfy; +} + +/*! + * Initialize the internal vectors + */ +void GaussInfo::initLocalInfo() throw (INTERP_KERNEL::Exception) +{ + bool aSatify = false; + const CellModel& cellModel=CellModel::GetCellModel(_my_geometry); + switch( _my_geometry ) + { + case NORM_SEG2: + _my_local_ref_dim = 1; + _my_local_nb_ref = 2; + seg2Init(); + aSatify = isSatisfy(); + CHECK_MACRO; + break; + + case NORM_SEG3: + _my_local_ref_dim = 1; + _my_local_nb_ref = 3; + seg3Init(); + aSatify = isSatisfy(); + CHECK_MACRO; + break; + + case NORM_TRI3: + _my_local_ref_dim = 2; + _my_local_nb_ref = 3; + tria3aInit(); + aSatify = isSatisfy(); + + if(!aSatify) + { + tria3bInit(); + aSatify = isSatisfy(); + CHECK_MACRO; + } + break; + + case NORM_TRI6: + _my_local_ref_dim = 2; + _my_local_nb_ref = 6; + tria6aInit(); + aSatify = isSatisfy(); + if(!aSatify) + { + tria6bInit(); + aSatify = isSatisfy(); + CHECK_MACRO; + } + break; + + case NORM_QUAD4: + _my_local_ref_dim = 2; + _my_local_nb_ref = 4; + quad4aInit(); + aSatify = isSatisfy(); + + if(!aSatify) + { + quad4bInit(); + aSatify = isSatisfy(); + CHECK_MACRO; + } + break; + + case NORM_QUAD8: + _my_local_ref_dim = 2; + _my_local_nb_ref = 8; + quad8aInit(); + aSatify = isSatisfy(); + + if(!aSatify) + { + quad8bInit(); + aSatify = isSatisfy(); + CHECK_MACRO; + } + break; + + case NORM_TETRA4: + _my_local_ref_dim = 3; + _my_local_nb_ref = 4; + tetra4aInit(); + aSatify = isSatisfy(); + + if(!aSatify) + { + tetra4bInit(); + aSatify = isSatisfy(); + CHECK_MACRO; + } + break; + + case NORM_TETRA10: + _my_local_ref_dim = 3; + _my_local_nb_ref = 10; + tetra10aInit(); + aSatify = isSatisfy(); + + if(!aSatify) + { + tetra10bInit(); + aSatify = isSatisfy(); + CHECK_MACRO; + } + break; + + case NORM_PYRA5: + _my_local_ref_dim = 3; + _my_local_nb_ref = 5; + pyra5aInit(); + aSatify = isSatisfy(); + + if(!aSatify) + { + pyra5bInit(); + aSatify = isSatisfy(); + CHECK_MACRO; + } + break; + + case NORM_PYRA13: + _my_local_ref_dim = 3; + _my_local_nb_ref = 13; + pyra13aInit(); + aSatify = isSatisfy(); + + if(!aSatify) + { + pyra13bInit(); + aSatify = isSatisfy(); + CHECK_MACRO; + } + break; + + case NORM_PENTA6: + _my_local_ref_dim = 3; + _my_local_nb_ref = 6; + penta6aInit(); + aSatify = isSatisfy(); + + if(!aSatify) + { + penta6bInit(); + aSatify = isSatisfy(); + CHECK_MACRO; + } + break; + + case NORM_PENTA15: + _my_local_ref_dim = 3; + _my_local_nb_ref = 15; + penta15aInit(); + aSatify = isSatisfy(); + + if(!aSatify) + { + penta15bInit(); + aSatify = isSatisfy(); + CHECK_MACRO; + } + break; + + case NORM_HEXA8: + _my_local_ref_dim = 3; + _my_local_nb_ref = 8; + hexa8aInit(); + aSatify = isSatisfy(); + + if(!aSatify) + { + hexa8aInit(); + aSatify = isSatisfy(); + CHECK_MACRO; + } + break; + + case NORM_HEXA20: + _my_local_ref_dim = 3; + _my_local_nb_ref = 20; + hexa20aInit(); + aSatify = isSatisfy(); + + if(!aSatify) + { + hexa20aInit(); + aSatify = isSatisfy(); + CHECK_MACRO; + } + break; + + default: + throw INTERP_KERNEL::Exception("Not manged cell type !"); + break; + } +} + +/** + * Return shape function value by node id + */ +const double* GaussInfo::getFunctionValues( const int theGaussId ) const +{ + return &_my_function_value[ _my_nb_ref*theGaussId ]; +} + +/*! + * Init Segment 2 Reference coordinates ans Shape function. + */ +void GaussInfo::seg2Init() +{ + LOCAL_COORD_MACRO_BEGIN; + case 0: + coords[0] = -1.0; + break; + case 1: + coords[0] = 1.0; + break; + LOCAL_COORD_MACRO_END; + + SHAPE_FUN_MACRO_BEGIN; + funValue[0] = 0.5*(1.0 - gc[0]); + funValue[1] = 0.5*(1.0 + gc[0]); + SHAPE_FUN_MACRO_END; +} + +/*! + * Init Segment 3 Reference coordinates ans Shape function. + */ +void GaussInfo::seg3Init() +{ + LOCAL_COORD_MACRO_BEGIN; + case 0: + coords[0] = -1.0; + break; + case 1: + coords[0] = 1.0; + break; + case 2: + coords[0] = 0.0; + break; + LOCAL_COORD_MACRO_END; + + SHAPE_FUN_MACRO_BEGIN; + funValue[0] = 0.5*(1.0 - gc[0])*gc[0]; + funValue[1] = 0.5*(1.0 + gc[0])*gc[0]; + funValue[2] = (1.0 + gc[0])*(1.0 - gc[0]); + SHAPE_FUN_MACRO_END; +} + +/*! + * Init Triangle Reference coordinates ans Shape function. + * Case A. + */ +void GaussInfo::tria3aInit() +{ + LOCAL_COORD_MACRO_BEGIN; + case 0: + coords[0] = -1.0; + coords[1] = 1.0; + break; + case 1: + coords[0] = -1.0; + coords[1] = -1.0; + break; + case 2: + coords[0] = 1.0; + coords[1] = -1.0; + break; + LOCAL_COORD_MACRO_END; + + SHAPE_FUN_MACRO_BEGIN; + funValue[0] = 0.5*(1.0 + gc[1]); + funValue[1] = -0.5*(gc[0] + gc[1]); + funValue[2] = 0.5*(1.0 + gc[0]); + SHAPE_FUN_MACRO_END; +} + +/*! + * Init Triangle Reference coordinates ans Shape function. + * Case B. + */ +void GaussInfo::tria3bInit() +{ + LOCAL_COORD_MACRO_BEGIN; + case 0: + coords[0] = 0.0; + coords[1] = 0.0; + break; + case 1: + coords[0] = 1.0; + coords[1] = 0.0; + break; + case 2: + coords[0] = 0.0; + coords[1] = 1.0; + break; + LOCAL_COORD_MACRO_END; + + SHAPE_FUN_MACRO_BEGIN; + funValue[0] = 1.0 - gc[0] - gc[1]; + funValue[1] = gc[0]; + funValue[2] = gc[1]; + SHAPE_FUN_MACRO_END; +} + +/*! + * Init Quadratic Triangle Reference coordinates ans Shape function. + * Case A. + */ +void GaussInfo::tria6aInit() +{ + LOCAL_COORD_MACRO_BEGIN; + case 0: + coords[0] = -1.0; + coords[1] = 1.0; + break; + case 1: + coords[0] = -1.0; + coords[1] = -1.0; + break; + case 2: + coords[0] = 1.0; + coords[1] = -1.0; + break; + case 3: + coords[0] = -1.0; + coords[1] = 1.0; + break; + case 4: + coords[0] = 0.0; + coords[1] = -1.0; + break; + case 5: + coords[0] = 0.0; + coords[1] = 0.0; + break; + LOCAL_COORD_MACRO_END; + + SHAPE_FUN_MACRO_BEGIN; + funValue[0] = 0.5*(1.0 + gc[1])*gc[1]; + funValue[1] = 0.5*(gc[0] + gc[1])*(gc[0] + gc[1] + 1); + funValue[2] = 0.5*(1.0 + gc[0])*gc[0]; + funValue[3] = -1.0*(1.0 + gc[1])*(gc[0] + gc[1]); + funValue[4] = -1.0*(1.0 + gc[0])*(gc[0] + gc[1]); + funValue[5] = (1.0 + gc[1])*(1.0 + gc[1]); + SHAPE_FUN_MACRO_END; +} + +/*! + * Init Quadratic Triangle Reference coordinates ans Shape function. + * Case B. + */ +void GaussInfo::tria6bInit() +{ + LOCAL_COORD_MACRO_BEGIN; + case 0: + coords[0] = 0.0; + coords[1] = 0.0; + break; + + case 1: + coords[0] = 1.0; + coords[1] = 0.0; + break; + + case 2: + coords[0] = 0.0; + coords[1] = 1.0; + break; + + case 3: + coords[0] = 0.5; + coords[1] = 0.0; + break; + + case 4: + coords[0] = 0.5; + coords[1] = 0.5; + break; + + case 5: + coords[0] = 0.0; + coords[1] = 0.5; + break; + + LOCAL_COORD_MACRO_END; + + SHAPE_FUN_MACRO_BEGIN; + funValue[0] = (1.0 - gc[0] - gc[1])*(1.0 - 2.0*gc[0] - 2.0*gc[1]); + funValue[1] = gc[0]*(2.0*gc[0] - 1.0); + funValue[2] = gc[1]*(2.0*gc[1] - 1.0); + funValue[3] = 4.0*gc[0]*(1.0 - gc[0] - gc[1]); + funValue[4] = 4.0*gc[0]*gc[1]; + funValue[5] = 4.0*gc[1]*(1.0 - gc[0] - gc[1]); + SHAPE_FUN_MACRO_END; +} + +/*! + * Init Quadrangle Reference coordinates ans Shape function. + * Case A. + */ +void GaussInfo::quad4aInit() +{ + LOCAL_COORD_MACRO_BEGIN; + case 0: + coords[0] = -1.0; + coords[1] = 1.0; + break; + case 1: + coords[0] = -1.0; + coords[1] = -1.0; + break; + case 2: + coords[0] = 1.0; + coords[1] = -1.0; + break; + case 3: + coords[0] = 1.0; + coords[1] = 1.0; + break; + + LOCAL_COORD_MACRO_END; + + SHAPE_FUN_MACRO_BEGIN; + funValue[0] = 0.25*(1.0 + gc[1])*(1.0 - gc[0]); + funValue[1] = 0.25*(1.0 - gc[1])*(1.0 - gc[0]); + funValue[2] = 0.25*(1.0 - gc[1])*(1.0 + gc[0]); + funValue[3] = 0.25*(1.0 + gc[0])*(1.0 + gc[1]); + SHAPE_FUN_MACRO_END; +} + +/*! + * Init Quadrangle Reference coordinates ans Shape function. + * Case B. + */ +void GaussInfo::quad4bInit() +{ + LOCAL_COORD_MACRO_BEGIN; + case 0: + coords[0] = -1.0; + coords[1] = -1.0; + break; + case 1: + coords[0] = 1.0; + coords[1] = -1.0; + break; + case 2: + coords[0] = 1.0; + coords[1] = 1.0; + break; + case 3: + coords[0] = -1.0; + coords[1] = 1.0; + break; + + LOCAL_COORD_MACRO_END; + + SHAPE_FUN_MACRO_BEGIN; + funValue[0] = 0.25*(1.0 - gc[0])*(1.0 - gc[1]); + funValue[1] = 0.25*(1.0 + gc[0])*(1.0 - gc[1]); + funValue[2] = 0.25*(1.0 + gc[0])*(1.0 + gc[1]); + funValue[3] = 0.25*(1.0 - gc[0])*(1.0 + gc[1]); + SHAPE_FUN_MACRO_END; +} + + +/*! + * Init Quadratic Quadrangle Reference coordinates ans Shape function. + * Case A. + */ +void GaussInfo::quad8aInit() +{ + LOCAL_COORD_MACRO_BEGIN; + case 0: + coords[0] = -1.0; + coords[1] = 1.0; + break; + case 1: + coords[0] = -1.0; + coords[1] = -1.0; + break; + case 2: + coords[0] = 1.0; + coords[1] = -1.0; + break; + case 3: + coords[0] = 1.0; + coords[1] = 1.0; + break; + case 4: + coords[0] = -1.0; + coords[1] = 0.0; + break; + case 5: + coords[0] = 0.0; + coords[1] = -1.0; + break; + case 6: + coords[0] = 1.0; + coords[1] = 0.0; + break; + case 7: + coords[0] = 0.0; + coords[1] = 1.0; + break; + LOCAL_COORD_MACRO_END; + + SHAPE_FUN_MACRO_BEGIN; + funValue[0] = 0.25*(1.0 + gc[1])*(1.0 - gc[0])*(gc[1] - gc[0] - 1.0); + funValue[1] = 0.25*(1.0 - gc[1])*(1.0 - gc[0])*(-gc[1] - gc[0] - 1.0); + funValue[2] = 0.25*(1.0 - gc[1])*(1.0 + gc[0])*(-gc[1] + gc[0] - 1.0); + funValue[3] = 0.25*(1.0 + gc[1])*(1.0 + gc[0])*(gc[1] + gc[0] - 1.0); + funValue[4] = 0.5*(1.0 - gc[0])*(1.0 - gc[1])*(1.0 + gc[1]); + funValue[5] = 0.5*(1.0 - gc[1])*(1.0 - gc[0])*(1.0 + gc[0]); + funValue[6] = 0.5*(1.0 + gc[0])*(1.0 - gc[1])*(1.0 + gc[1]); + funValue[7] = 0.5*(1.0 + gc[1])*(1.0 - gc[0])*(1.0 + gc[0]); + SHAPE_FUN_MACRO_END; +} + +/*! + * Init Quadratic Quadrangle Reference coordinates ans Shape function. + * Case B. + */ +void GaussInfo::quad8bInit() +{ + LOCAL_COORD_MACRO_BEGIN; + case 0: + coords[0] = -1.0; + coords[1] = -1.0; + break; + case 1: + coords[0] = 1.0; + coords[1] = -1.0; + break; + case 2: + coords[0] = 1.0; + coords[1] = 1.0; + break; + case 3: + coords[0] = -1.0; + coords[1] = 1.0; + break; + case 4: + coords[0] = 0.0; + coords[1] = -1.0; + break; + case 5: + coords[0] = 1.0; + coords[1] = 0.0; + break; + case 6: + coords[0] = 0.0; + coords[1] = 1.0; + break; + case 7: + coords[0] = -1.0; + coords[1] = 0.0; + break; + LOCAL_COORD_MACRO_END; + + SHAPE_FUN_MACRO_BEGIN; + funValue[0] = 0.25*(1.0 - gc[0])*(1.0 - gc[1])*(-1.0 - gc[0] - gc[1]); + funValue[1] = 0.25*(1.0 + gc[0])*(1.0 - gc[1])*(-1.0 + gc[0] - gc[1]); + funValue[2] = 0.25*(1.0 + gc[0])*(1.0 + gc[1])*(-1.0 + gc[0] + gc[1]); + funValue[3] = 0.25*(1.0 - gc[0])*(1.0 + gc[1])*(-1.0 - gc[0] + gc[1]); + funValue[4] = 0.5*(1.0 - gc[0]*gc[0])*(1.0 - gc[1]); + funValue[5] = 0.5*(1.0 - gc[1]*gc[1])*(1.0 + gc[0]); + funValue[6] = 0.5*(1.0 - gc[0]*gc[0])*(1.0 + gc[1]); + funValue[7] = 0.5*(1.0 - gc[1]*gc[1])*(1.0 - gc[0]); + SHAPE_FUN_MACRO_END; +} + +/*! + * Init Tetrahedron Reference coordinates ans Shape function. + * Case A. + */ +void GaussInfo::tetra4aInit() +{ + LOCAL_COORD_MACRO_BEGIN; + case 0: + coords[0] = 0.0; + coords[1] = 1.0; + coords[2] = 0.0; + break; + case 1: + coords[0] = 0.0; + coords[1] = 0.0; + coords[2] = 1.0; + break; + case 2: + coords[0] = 0.0; + coords[1] = 0.0; + coords[2] = 0.0; + break; + case 3: + coords[0] = 1.0; + coords[1] = 0.0; + coords[2] = 0.0; + break; + LOCAL_COORD_MACRO_END; + + SHAPE_FUN_MACRO_BEGIN; + funValue[0] = gc[1]; + funValue[1] = gc[2]; + funValue[2] = 1.0 - gc[0] - gc[1] - gc[2]; + funValue[3] = gc[0]; + SHAPE_FUN_MACRO_END; +} + +/*! + * Init Tetrahedron Reference coordinates ans Shape function. + * Case B. + */ +void GaussInfo::tetra4bInit() +{ + LOCAL_COORD_MACRO_BEGIN; + case 0: + coords[0] = 0.0; + coords[1] = 1.0; + coords[2] = 0.0; + break; + case 2: + coords[0] = 0.0; + coords[1] = 0.0; + coords[2] = 1.0; + break; + case 1: + coords[0] = 0.0; + coords[1] = 0.0; + coords[2] = 0.0; + break; + case 3: + coords[0] = 1.0; + coords[1] = 0.0; + coords[2] = 0.0; + break; + LOCAL_COORD_MACRO_END; + + SHAPE_FUN_MACRO_BEGIN; + funValue[0] = gc[1]; + funValue[2] = gc[2]; + funValue[1] = 1.0 - gc[0] - gc[1] - gc[2]; + funValue[3] = gc[0]; + SHAPE_FUN_MACRO_END; + +} + +/*! + * Init Quadratic Tetrahedron Reference coordinates ans Shape function. + * Case A. + */ +void GaussInfo::tetra10aInit() +{ + LOCAL_COORD_MACRO_BEGIN; + case 0: + coords[0] = 0.0; + coords[1] = 1.0; + coords[2] = 0.0; + break; + case 1: + coords[0] = 0.0; + coords[1] = 0.0; + coords[2] = 1.0; + break; + case 2: + coords[0] = 0.0; + coords[1] = 0.0; + coords[2] = 0.0; + break; + case 3: + coords[0] = 1.0; + coords[1] = 0.0; + coords[2] = 0.0; + break; + case 4: + coords[0] = 0.0; + coords[1] = 0.5; + coords[2] = 0.5; + break; + case 5: + coords[0] = 0.0; + coords[1] = 0.0; + coords[2] = 0.5; + break; + case 6: + coords[0] = 0.0; + coords[1] = 0.5; + coords[2] = 0.0; + break; + case 7: + coords[0] = 0.5; + coords[1] = 0.5; + coords[2] = 0.0; + break; + case 8: + coords[0] = 0.5; + coords[1] = 0.0; + coords[2] = 0.5; + break; + case 9: + coords[0] = 0.5; + coords[1] = 0.0; + coords[2] = 0.0; + break; + LOCAL_COORD_MACRO_END; + + SHAPE_FUN_MACRO_BEGIN; + funValue[0] = gc[1]*(2.0*gc[1] - 1.0); + funValue[1] = gc[2]*(2.0*gc[2] - 1.0); + funValue[2] = (1.0 - gc[0] - gc[1] - gc[2])*(1.0 - 2.0*gc[0] - 2.0*gc[1] - 2.0*gc[2]); + funValue[3] = gc[0]*(2.0*gc[0] - 1.0); + funValue[4] = 4.0*gc[1]*gc[2]; + funValue[5] = 4.0*gc[2]*(1.0 - gc[0] - gc[1] - gc[2]); + funValue[6] = 4.0*gc[1]*(1.0 - gc[0] - gc[1] - gc[2]); + funValue[7] = 4.0*gc[0]*gc[1]; + funValue[8] = 4.0*gc[0]*gc[2]; + funValue[9] = 4.0*gc[0]*(1.0 - gc[0] - gc[1] - gc[2]); + SHAPE_FUN_MACRO_END; +} + +/*! + * Init Quadratic Tetrahedron Reference coordinates ans Shape function. + * Case B. + */ +void GaussInfo::tetra10bInit() +{ + LOCAL_COORD_MACRO_BEGIN; + case 0: + coords[0] = 0.0; + coords[1] = 1.0; + coords[2] = 0.0; + break; + case 2: + coords[0] = 0.0; + coords[1] = 0.0; + coords[2] = 1.0; + break; + case 1: + coords[0] = 0.0; + coords[1] = 0.0; + coords[2] = 0.0; + break; + case 3: + coords[0] = 1.0; + coords[1] = 0.0; + coords[2] = 0.0; + break; + case 6: + coords[0] = 0.0; + coords[1] = 0.5; + coords[2] = 0.5; + break; + case 5: + coords[0] = 0.0; + coords[1] = 0.0; + coords[2] = 0.5; + break; + case 4: + coords[0] = 0.0; + coords[1] = 0.5; + coords[2] = 0.0; + break; + case 7: + coords[0] = 0.5; + coords[1] = 0.5; + coords[2] = 0.0; + break; + case 9: + coords[0] = 0.5; + coords[1] = 0.0; + coords[2] = 0.5; + break; + case 8: + coords[0] = 0.5; + coords[1] = 0.0; + coords[2] = 0.0; + break; + LOCAL_COORD_MACRO_END; + + SHAPE_FUN_MACRO_BEGIN; + funValue[0] = gc[1]*(2.0*gc[1] - 1.0); + funValue[2] = gc[2]*(2.0*gc[2] - 1.0); + funValue[1] = (1.0 - gc[0] - gc[1] - gc[2])*(1.0 - 2.0*gc[0] - 2.0*gc[1] - 2.0*gc[2]); + funValue[3] = gc[0]*(2.0*gc[0] - 1.0); + funValue[6] = 4.0*gc[1]*gc[2]; + funValue[5] = 4.0*gc[2]*(1.0 - gc[0] - gc[1] - gc[2]); + funValue[4] = 4.0*gc[1]*(1.0 - gc[0] - gc[1] - gc[2]); + funValue[7] = 4.0*gc[0]*gc[1]; + funValue[9] = 4.0*gc[0]*gc[2]; + funValue[8] = 4.0*gc[0]*(1.0 - gc[0] - gc[1] - gc[2]); + SHAPE_FUN_MACRO_END; +} + +/*! + * Init Pyramid Reference coordinates ans Shape function. + * Case A. + */ +void GaussInfo::pyra5aInit() +{ + LOCAL_COORD_MACRO_BEGIN; + case 0: + coords[0] = 1.0; + coords[1] = 0.0; + coords[2] = 0.0; + break; + case 1: + coords[0] = 0.0; + coords[1] = 1.0; + coords[2] = 0.0; + break; + case 2: + coords[0] = -1.0; + coords[1] = 0.0; + coords[2] = 0.0; + break; + case 3: + coords[0] = 0.0; + coords[1] = -1.0; + coords[2] = 0.0; + break; + case 4: + coords[0] = 0.0; + coords[1] = 0.0; + coords[2] = 1.0; + break; + LOCAL_COORD_MACRO_END; + + SHAPE_FUN_MACRO_BEGIN; + funValue[0] = 0.25*(-gc[0] + gc[1] - 1.0)*(-gc[0] - gc[1] - 1.0)*(1.0 - gc[2]); + funValue[1] = 0.25*(-gc[0] - gc[1] - 1.0)*(+gc[0] - gc[1] - 1.0)*(1.0 - gc[2]); + funValue[2] = 0.25*(+gc[0] + gc[1] - 1.0)*(+gc[0] - gc[1] - 1.0)*(1.0 - gc[2]); + funValue[3] = 0.25*(+gc[0] + gc[1] - 1.0)*(-gc[0] + gc[1] - 1.0)*(1.0 - gc[2]); + funValue[4] = gc[2]; + SHAPE_FUN_MACRO_END; +} +/*! + * Init Pyramid Reference coordinates ans Shape function. + * Case B. + */ +void GaussInfo::pyra5bInit() +{ + LOCAL_COORD_MACRO_BEGIN; + case 0: + coords[0] = 1.0; + coords[1] = 0.0; + coords[2] = 0.0; + break; + case 3: + coords[0] = 0.0; + coords[1] = 1.0; + coords[2] = 0.0; + break; + case 2: + coords[0] = -1.0; + coords[1] = 0.0; + coords[2] = 0.0; + break; + case 1: + coords[0] = 0.0; + coords[1] = -1.0; + coords[2] = 0.0; + break; + case 4: + coords[0] = 0.0; + coords[1] = 0.0; + coords[2] = 1.0; + break; + LOCAL_COORD_MACRO_END; + + SHAPE_FUN_MACRO_BEGIN; + funValue[0] = 0.25*(-gc[0] + gc[1] - 1.0)*(-gc[0] - gc[1] - 1.0)*(1.0 - gc[2]); + funValue[3] = 0.25*(-gc[0] - gc[1] - 1.0)*(+gc[0] - gc[1] - 1.0)*(1.0 - gc[2]); + funValue[2] = 0.25*(+gc[0] + gc[1] - 1.0)*(+gc[0] - gc[1] - 1.0)*(1.0 - gc[2]); + funValue[1] = 0.25*(+gc[0] + gc[1] - 1.0)*(-gc[0] + gc[1] - 1.0)*(1.0 - gc[2]); + funValue[4] = gc[2]; + SHAPE_FUN_MACRO_END; +} + +/*! + * Init Quadratic Pyramid Reference coordinates ans Shape function. + * Case A. + */ +void GaussInfo::pyra13aInit() +{ + LOCAL_COORD_MACRO_BEGIN; + case 0: + coords[0] = 1.0; + coords[1] = 0.0; + coords[2] = 0.0; + break; + case 1: + coords[0] = 0.0; + coords[1] = 1.0; + coords[2] = 0.0; + break; + case 2: + coords[0] = -1.0; + coords[1] = 0.0; + coords[2] = 0.0; + break; + case 3: + coords[0] = 0.0; + coords[1] = -1.0; + coords[2] = 0.0; + break; + case 4: + coords[0] = 0.0; + coords[1] = 0.0; + coords[2] = 1.0; + break; + + case 5: + coords[0] = 0.5; + coords[1] = 0.5; + coords[2] = 0.0; + break; + case 6: + coords[0] = -0.5; + coords[1] = 0.5; + coords[2] = 0.0; + break; + case 7: + coords[0] = -0.5; + coords[1] = -0.5; + coords[2] = 0.0; + break; + case 8: + coords[0] = 0.5; + coords[1] = -0.5; + coords[2] = 0.0; + break; + case 9: + coords[0] = 0.5; + coords[1] = 0.0; + coords[2] = 0.5; + break; + case 10: + coords[0] = 0.0; + coords[1] = 0.5; + coords[2] = 0.5; + break; + case 11: + coords[0] = -0.5; + coords[1] = 0.0; + coords[2] = 0.5; + break; + case 12: + coords[0] = 0.0; + coords[1] = -0.5; + coords[2] = 0.5; + break; + LOCAL_COORD_MACRO_END; + + SHAPE_FUN_MACRO_BEGIN; + funValue[0] = 0.5*(-gc[0] + gc[1] + gc[2] - 1.0)*(-gc[0] - gc[1] + gc[2] - 1.0)* + (gc[0] - 0.5)/(1.0 - gc[2]); + funValue[1] = 0.5*(-gc[0] - gc[1] + gc[2] - 1.0)*(+gc[0] - gc[1] + gc[2] - 1.0)* + (gc[1] - 0.5)/(1.0 - gc[2]); + funValue[2] = 0.5*(+gc[0] - gc[1] + gc[2] - 1.0)*(+gc[0] + gc[1] + gc[2] - 1.0)* + (-gc[0] - 0.5)/(1.0 - gc[2]); + funValue[3] = 0.5*(+gc[0] + gc[1] + gc[2] - 1.0)*(-gc[0] + gc[1] + gc[2] - 1.0)* + (-gc[1] - 0.5)/(1.0 - gc[2]); + + funValue[4] = 2.0*gc[2]*(gc[2] - 0.5); + + funValue[5] = 0.5*(-gc[0] + gc[1] + gc[2] - 1.0)*(-gc[0] - gc[1] + gc[2] - 1.0)* + (gc[0] - gc[1] + gc[2] - 1.0)/(1.0 - gc[2]); + funValue[6] = 0.5*(-gc[0] - gc[1] + gc[2] - 1.0)*(gc[0] - gc[1] + gc[2] - 1.0)* + (gc[0] + gc[1] + gc[2] - 1.0)/(1.0 - gc[2]); + funValue[7] = 0.5*(gc[0] - gc[1] + gc[2] - 1.0)*(gc[0] + gc[1] + gc[2] - 1.0)* + (-gc[0] + gc[1] + gc[2] - 1.0)/(1.0 - gc[2]); + funValue[8] = 0.5*(gc[0] + gc[1] + gc[2] - 1.0)*(-gc[0] + gc[1] + gc[2] - 1.0)* + (-gc[0] - gc[1] + gc[2] - 1.0)/(1.0 - gc[2]); + + funValue[9] = 0.5*gc[2]*(-gc[0] + gc[1] + gc[2] - 1.0)*(-gc[0] - gc[1] + gc[2] - 1.0)/ + (1.0 - gc[2]); + funValue[10] = 0.5*gc[2]*(-gc[0] - gc[1] + gc[2] - 1.0)*(gc[0] - gc[1] + gc[2] - 1.0)/ + (1.0 - gc[2]); + funValue[11] = 0.5*gc[2]*(gc[0] - gc[1] + gc[2] - 1.0)*(gc[0] + gc[1] + gc[2] - 1.0)/ + (1.0 - gc[2]); + funValue[12] = 0.5*gc[2]*(gc[0] + gc[1] + gc[2] - 1.0)*(-gc[0] + gc[1] + gc[2] - 1.0)/ + (1.0 - gc[2]); + SHAPE_FUN_MACRO_END; +} + +/*! + * Init Quadratic Pyramid Reference coordinates ans Shape function. + * Case B. + */ +void GaussInfo::pyra13bInit() +{ + LOCAL_COORD_MACRO_BEGIN; + case 0: + coords[0] = 1.0; + coords[1] = 0.0; + coords[2] = 0.0; + break; + case 3: + coords[0] = 0.0; + coords[1] = 1.0; + coords[2] = 0.0; + break; + case 2: + coords[0] = -1.0; + coords[1] = 0.0; + coords[2] = 0.0; + break; + case 1: + coords[0] = 0.0; + coords[1] = -1.0; + coords[2] = 0.0; + break; + case 4: + coords[0] = 0.0; + coords[1] = 0.0; + coords[2] = 1.0; + break; + case 8: + coords[0] = 0.5; + coords[1] = 0.5; + coords[2] = 0.0; + break; + case 7: + coords[0] = -0.5; + coords[1] = 0.5; + coords[2] = 0.0; + break; + case 6: + coords[0] = -0.5; + coords[1] = -0.5; + coords[2] = 0.0; + break; + case 5: + coords[0] = 0.5; + coords[1] = -0.5; + coords[2] = 0.0; + break; + case 9: + coords[0] = 0.5; + coords[1] = 0.0; + coords[2] = 0.5; + break; + case 12: + coords[0] = 0.0; + coords[1] = 0.5; + coords[2] = 0.5; + break; + case 11: + coords[0] = -0.5; + coords[1] = 0.0; + coords[2] = 0.5; + break; + case 10: + coords[0] = 0.0; + coords[1] = -0.5; + coords[2] = 0.5; + break; + LOCAL_COORD_MACRO_END; + + SHAPE_FUN_MACRO_BEGIN; + funValue[0] = 0.5*(-gc[0] + gc[1] + gc[2] - 1.0)*(-gc[0] - gc[1] + gc[2] - 1.0)* + (gc[0] - 0.5)/(1.0 - gc[2]); + funValue[3] = 0.5*(-gc[0] - gc[1] + gc[2] - 1.0)*(+gc[0] - gc[1] + gc[2] - 1.0)* + (gc[1] - 0.5)/(1.0 - gc[2]); + funValue[2] = 0.5*(+gc[0] - gc[1] + gc[2] - 1.0)*(+gc[0] + gc[1] + gc[2] - 1.0)* + (-gc[0] - 0.5)/(1.0 - gc[2]); + funValue[1] = 0.5*(+gc[0] + gc[1] + gc[2] - 1.0)*(-gc[0] + gc[1] + gc[2] - 1.0)* + (-gc[1] - 0.5)/(1.0 - gc[2]); + + funValue[4] = 2.0*gc[2]*(gc[2] - 0.5); + + funValue[8] = 0.5*(-gc[0] + gc[1] + gc[2] - 1.0)*(-gc[0] - gc[1] + gc[2] - 1.0)* + (gc[0] - gc[1] + gc[2] - 1.0)/(1.0 - gc[2]); + funValue[7] = 0.5*(-gc[0] - gc[1] + gc[2] - 1.0)*(gc[0] - gc[1] + gc[2] - 1.0)* + (gc[0] + gc[1] + gc[2] - 1.0)/(1.0 - gc[2]); + funValue[6] = 0.5*(gc[0] - gc[1] + gc[2] - 1.0)*(gc[0] + gc[1] + gc[2] - 1.0)* + (-gc[0] + gc[1] + gc[2] - 1.0)/(1.0 - gc[2]); + funValue[5] = 0.5*(gc[0] + gc[1] + gc[2] - 1.0)*(-gc[0] + gc[1] + gc[2] - 1.0)* + (-gc[0] - gc[1] + gc[2] - 1.0)/(1.0 - gc[2]); + + funValue[9] = 0.5*gc[2]*(-gc[0] + gc[1] + gc[2] - 1.0)*(-gc[0] - gc[1] + gc[2] - 1.0)/ + (1.0 - gc[2]); + funValue[12] = 0.5*gc[2]*(-gc[0] - gc[1] + gc[2] - 1.0)*(gc[0] - gc[1] + gc[2] - 1.0)/ + (1.0 - gc[2]); + funValue[11] = 0.5*gc[2]*(gc[0] - gc[1] + gc[2] - 1.0)*(gc[0] + gc[1] + gc[2] - 1.0)/ + (1.0 - gc[2]); + funValue[10] = 0.5*gc[2]*(gc[0] + gc[1] + gc[2] - 1.0)*(-gc[0] + gc[1] + gc[2] - 1.0)/ + (1.0 - gc[2]); + SHAPE_FUN_MACRO_END; +} + + +/*! + * Init Pentahedron Reference coordinates and Shape function. + * Case A. + */ +void GaussInfo::penta6aInit() +{ + LOCAL_COORD_MACRO_BEGIN; + case 0: + coords[0] = -1.0; + coords[1] = 1.0; + coords[2] = 0.0; + break; + case 1: + coords[0] = -1.0; + coords[1] = -0.0; + coords[2] = 1.0; + break; + case 2: + coords[0] = -1.0; + coords[1] = 0.0; + coords[2] = 0.0; + break; + case 3: + coords[0] = 1.0; + coords[1] = 1.0; + coords[2] = 0.0; + break; + case 4: + coords[0] = 1.0; + coords[1] = 0.0; + coords[2] = 1.0; + break; + case 5: + coords[0] = 1.0; + coords[1] = 0.0; + coords[2] = 0.0; + break; + LOCAL_COORD_MACRO_END; + + SHAPE_FUN_MACRO_BEGIN; + funValue[0] = 0.5*gc[1]*(1.0 - gc[0]); + funValue[1] = 0.5*gc[2]*(1.0 - gc[0]); + funValue[2] = 0.5*(1.0 - gc[1] - gc[2])*(1.0 - gc[0]); + + funValue[3] = 0.5*gc[1]*(gc[0] + 1.0); + funValue[4] = 0.5*gc[2]*(gc[0] + 1.0); + funValue[5] = 0.5*(1.0 - gc[1] - gc[2])*(1.0 + gc[0]); + SHAPE_FUN_MACRO_END; +} + +/*! + * Init Pentahedron Reference coordinates and Shape function. + * Case B. + */ +void GaussInfo::penta6bInit() +{ + LOCAL_COORD_MACRO_BEGIN; + case 0: + coords[0] = -1.0; + coords[1] = 1.0; + coords[2] = 0.0; + break; + case 2: + coords[0] = -1.0; + coords[1] = -0.0; + coords[2] = 1.0; + break; + case 1: + coords[0] = -1.0; + coords[1] = 0.0; + coords[2] = 0.0; + break; + case 3: + coords[0] = 1.0; + coords[1] = 1.0; + coords[2] = 0.0; + break; + case 5: + coords[0] = 1.0; + coords[1] = 0.0; + coords[2] = 1.0; + break; + case 4: + coords[0] = 1.0; + coords[1] = 0.0; + coords[2] = 0.0; + break; + LOCAL_COORD_MACRO_END; + + SHAPE_FUN_MACRO_BEGIN; + funValue[0] = 0.5*gc[1]*(1.0 - gc[0]); + funValue[2] = 0.5*gc[2]*(1.0 - gc[0]); + funValue[1] = 0.5*(1.0 - gc[1] - gc[2])*(1.0 - gc[0]); + funValue[3] = 0.5*gc[1]*(gc[0] + 1.0); + funValue[5] = 0.5*gc[2]*(gc[0] + 1.0); + funValue[4] = 0.5*(1.0 - gc[1] - gc[2])*(1.0 + gc[0]); + SHAPE_FUN_MACRO_END; +} +/*! + * Init Pentahedron Reference coordinates and Shape function. + * Case A. + */ +void GaussInfo::penta15aInit() +{ + LOCAL_COORD_MACRO_BEGIN; + case 0: + coords[0] = -1.0; + coords[1] = 1.0; + coords[2] = 0.0; + break; + case 1: + coords[0] = -1.0; + coords[1] = -0.0; + coords[2] = 1.0; + break; + case 2: + coords[0] = -1.0; + coords[1] = 0.0; + coords[2] = 0.0; + break; + case 3: + coords[0] = 1.0; + coords[1] = 1.0; + coords[2] = 0.0; + break; + case 4: + coords[0] = 1.0; + coords[1] = 0.0; + coords[2] = 1.0; + break; + case 5: + coords[0] = 1.0; + coords[1] = 0.0; + coords[2] = 0.0; + break; + + case 6: + coords[0] = -1.0; + coords[1] = 0.5; + coords[2] = 0.5; + break; + case 7: + coords[0] = -1.0; + coords[1] = 0.0; + coords[2] = 0.5; + break; + case 8: + coords[0] = -1.0; + coords[1] = 0.5; + coords[2] = 0.0; + break; + case 9: + coords[0] = 0.0; + coords[1] = 1.0; + coords[2] = 0.0; + break; + case 10: + coords[0] = 0.0; + coords[1] = 0.0; + coords[2] = 1.0; + break; + case 11: + coords[0] = 0.0; + coords[1] = 0.0; + coords[2] = 0.0; + break; + case 12: + coords[0] = 1.0; + coords[1] = 0.5; + coords[2] = 0.5; + break; + case 13: + coords[0] = 1.0; + coords[1] = 0.0; + coords[2] = 0.5; + break; + case 14: + coords[0] = 1.0; + coords[1] = 0.5; + coords[2] = 0.0; + break; + LOCAL_COORD_MACRO_END; + + SHAPE_FUN_MACRO_BEGIN; + funValue[0] = 0.5*gc[1]*(1.0 - gc[0])*(2.0*gc[1] - 2.0 - gc[0]); + funValue[1] = 0.5*gc[2]*(1.0 - gc[0])*(2.0*gc[2] - 2.0 - gc[0]); + funValue[2] = 0.5*(gc[0] - 1.0)*(1.0 - gc[1] - gc[2])*(gc[0] + 2.0*gc[1] + 2.0*gc[2]); + + funValue[3] = 0.5*gc[1]*(1.0 + gc[0])*(2.0*gc[1] - 2.0 + gc[0]); + funValue[4] = 0.5*gc[2]*(1.0 + gc[0])*(2.0*gc[2] - 2.0 + gc[0]); + funValue[5] = 0.5*(-gc[0] - 1.0)*(1.0 - gc[1] - gc[2])*(-gc[0] + 2.0*gc[1] + 2.0*gc[2]); + + funValue[6] = 2.0*gc[1]*gc[2]*(1.0 - gc[0]); + funValue[7] = 2.0*gc[2]*(1.0 - gc[1] - gc[2])*(1.0 - gc[0]); + funValue[8] = 2.0*gc[1]*(1.0 - gc[1] - gc[2])*(1.0 - gc[0]); + + funValue[9] = gc[1]*(1.0 - gc[0]*gc[0]); + funValue[10] = gc[2]*(1.0 - gc[0]*gc[0]); + funValue[11] = (1.0 - gc[1] - gc[2])*(1.0 - gc[0]*gc[0]); + + funValue[12] = 2.0*gc[1]*gc[2]*(1.0 + gc[0]); + funValue[13] = 2.0*gc[2]*(1.0 - gc[1] - gc[2])*(1.0 + gc[0]); + funValue[14] = 2.0*gc[1]*(1.0 - gc[1] - gc[2])*(1.0 + gc[0]); + SHAPE_FUN_MACRO_END; +} + +/*! + * Init Qaudratic Pentahedron Reference coordinates and Shape function. + * Case B. + */ +void GaussInfo::penta15bInit() +{ + LOCAL_COORD_MACRO_BEGIN; + case 0: + coords[0] = -1.0; + coords[1] = 1.0; + coords[2] = 0.0; + break; + case 2: + coords[0] = -1.0; + coords[1] = -0.0; + coords[2] = 1.0; + break; + case 1: + coords[0] = -1.0; + coords[1] = 0.0; + coords[2] = 0.0; + break; + case 3: + coords[0] = 1.0; + coords[1] = 1.0; + coords[2] = 0.0; + break; + case 5: + coords[0] = 1.0; + coords[1] = 0.0; + coords[2] = 1.0; + break; + case 4: + coords[0] = 1.0; + coords[1] = 0.0; + coords[2] = 0.0; + break; + + case 8: + coords[0] = -1.0; + coords[1] = 0.5; + coords[2] = 0.5; + break; + case 7: + coords[0] = -1.0; + coords[1] = 0.0; + coords[2] = 0.5; + break; + case 6: + coords[0] = -1.0; + coords[1] = 0.5; + coords[2] = 0.0; + break; + case 12: + coords[0] = 0.0; + coords[1] = 1.0; + coords[2] = 0.0; + break; + case 14: + coords[0] = 0.0; + coords[1] = 0.0; + coords[2] = 1.0; + break; + case 13: + coords[0] = 0.0; + coords[1] = 0.0; + coords[2] = 0.0; + break; + case 11: + coords[0] = 1.0; + coords[1] = 0.5; + coords[2] = 0.5; + break; + case 10: + coords[0] = 1.0; + coords[1] = 0.0; + coords[2] = 0.5; + break; + case 9: + coords[0] = 1.0; + coords[1] = 0.5; + coords[2] = 0.0; + break; + LOCAL_COORD_MACRO_END; + + SHAPE_FUN_MACRO_BEGIN; + funValue[0] = 0.5*gc[1]*(1.0 - gc[0])*(2.0*gc[1] - 2.0 - gc[0]); + funValue[2] = 0.5*gc[2]*(1.0 - gc[0])*(2.0*gc[2] - 2.0 - gc[0]); + funValue[1] = 0.5*(gc[0] - 1.0)*(1.0 - gc[1] - gc[2])*(gc[0] + 2.0*gc[1] + 2.0*gc[2]); + + funValue[3] = 0.5*gc[1]*(1.0 + gc[0])*(2.0*gc[1] - 2.0 + gc[0]); + funValue[5] = 0.5*gc[2]*(1.0 + gc[0])*(2.0*gc[2] - 2.0 + gc[0]); + funValue[4] = 0.5*(-gc[0] - 1.0)*(1.0 - gc[1] - gc[2])*(-gc[0] + 2.0*gc[1] + 2.0*gc[2]); + + funValue[8] = 2.0*gc[1]*gc[2]*(1.0 - gc[0]); + funValue[7] = 2.0*gc[2]*(1.0 - gc[1] - gc[2])*(1.0 - gc[0]); + funValue[6] = 2.0*gc[1]*(1.0 - gc[1] - gc[2])*(1.0 - gc[0]); + + funValue[12] = gc[1]*(1.0 - gc[0]*gc[0]); + funValue[14] = gc[2]*(1.0 - gc[0]*gc[0]); + funValue[13] = (1.0 - gc[1] - gc[2])*(1.0 - gc[0]*gc[0]); + + funValue[11] = 2.0*gc[1]*gc[2]*(1.0 + gc[0]); + funValue[10] = 2.0*gc[2]*(1.0 - gc[1] - gc[2])*(1.0 + gc[0]); + funValue[9] = 2.0*gc[1]*(1.0 - gc[1] - gc[2])*(1.0 + gc[0]); + SHAPE_FUN_MACRO_END; +} + +/*! + * Init Hehahedron Reference coordinates and Shape function. + * Case A. + */ +void GaussInfo::hexa8aInit() +{ + LOCAL_COORD_MACRO_BEGIN; + case 0: + coords[0] = -1.0; + coords[1] = -1.0; + coords[2] = -1.0; + break; + case 1: + coords[0] = 1.0; + coords[1] = -1.0; + coords[2] = -1.0; + break; + case 2: + coords[0] = 1.0; + coords[1] = 1.0; + coords[2] = -1.0; + break; + case 3: + coords[0] = -1.0; + coords[1] = 1.0; + coords[2] = -1.0; + break; + case 4: + coords[0] = -1.0; + coords[1] = -1.0; + coords[2] = 1.0; + break; + case 5: + coords[0] = 1.0; + coords[1] = -1.0; + coords[2] = 1.0; + break; + case 6: + coords[0] = 1.0; + coords[1] = 1.0; + coords[2] = 1.0; + break; + case 7: + coords[0] = -1.0; + coords[1] = 1.0; + coords[2] = 1.0; + break; + LOCAL_COORD_MACRO_END; + + SHAPE_FUN_MACRO_BEGIN; + funValue[0] = 0.125*(1.0 - gc[0])*(1.0 - gc[1])*(1.0 - gc[2]); + funValue[1] = 0.125*(1.0 + gc[0])*(1.0 - gc[1])*(1.0 - gc[2]); + funValue[2] = 0.125*(1.0 + gc[0])*(1.0 + gc[1])*(1.0 - gc[2]); + funValue[3] = 0.125*(1.0 - gc[0])*(1.0 + gc[1])*(1.0 - gc[2]); + + funValue[4] = 0.125*(1.0 - gc[0])*(1.0 - gc[1])*(1.0 + gc[2]); + funValue[5] = 0.125*(1.0 + gc[0])*(1.0 - gc[1])*(1.0 + gc[2]); + funValue[6] = 0.125*(1.0 + gc[0])*(1.0 + gc[1])*(1.0 + gc[2]); + funValue[7] = 0.125*(1.0 - gc[0])*(1.0 + gc[1])*(1.0 + gc[2]); + SHAPE_FUN_MACRO_END; +} + +/*! + * Init Hehahedron Reference coordinates and Shape function. + * Case B. + */ +void GaussInfo::hexa8bInit() +{ + LOCAL_COORD_MACRO_BEGIN; + case 0: + coords[0] = -1.0; + coords[1] = -1.0; + coords[2] = -1.0; + break; + case 3: + coords[0] = 1.0; + coords[1] = -1.0; + coords[2] = -1.0; + break; + case 2: + coords[0] = 1.0; + coords[1] = 1.0; + coords[2] = -1.0; + break; + case 1: + coords[0] = -1.0; + coords[1] = 1.0; + coords[2] = -1.0; + break; + case 4: + coords[0] = -1.0; + coords[1] = -1.0; + coords[2] = 1.0; + break; + case 7: + coords[0] = 1.0; + coords[1] = -1.0; + coords[2] = 1.0; + break; + case 6: + coords[0] = 1.0; + coords[1] = 1.0; + coords[2] = 1.0; + break; + case 5: + coords[0] = -1.0; + coords[1] = 1.0; + coords[2] = 1.0; + break; + LOCAL_COORD_MACRO_END; + + SHAPE_FUN_MACRO_BEGIN; + funValue[0] = 0.125*(1.0 - gc[0])*(1.0 - gc[1])*(1.0 - gc[2]); + funValue[3] = 0.125*(1.0 + gc[0])*(1.0 - gc[1])*(1.0 - gc[2]); + funValue[2] = 0.125*(1.0 + gc[0])*(1.0 + gc[1])*(1.0 - gc[2]); + funValue[1] = 0.125*(1.0 - gc[0])*(1.0 + gc[1])*(1.0 - gc[2]); + + funValue[4] = 0.125*(1.0 - gc[0])*(1.0 - gc[1])*(1.0 + gc[2]); + funValue[7] = 0.125*(1.0 + gc[0])*(1.0 - gc[1])*(1.0 + gc[2]); + funValue[6] = 0.125*(1.0 + gc[0])*(1.0 + gc[1])*(1.0 + gc[2]); + funValue[5] = 0.125*(1.0 - gc[0])*(1.0 + gc[1])*(1.0 + gc[2]); + SHAPE_FUN_MACRO_END; +} + +/*! + * Init Qaudratic Hehahedron Reference coordinates and Shape function. + * Case A. + */ +void GaussInfo::hexa20aInit() +{ + LOCAL_COORD_MACRO_BEGIN; + case 0: + coords[0] = -1.0; + coords[1] = -1.0; + coords[2] = -1.0; + break; + case 1: + coords[0] = 1.0; + coords[1] = -1.0; + coords[2] = -1.0; + break; + case 2: + coords[0] = 1.0; + coords[1] = 1.0; + coords[2] = -1.0; + break; + case 3: + coords[0] = -1.0; + coords[1] = 1.0; + coords[2] = -1.0; + break; + case 4: + coords[0] = -1.0; + coords[1] = -1.0; + coords[2] = 1.0; + break; + case 5: + coords[0] = 1.0; + coords[1] = -1.0; + coords[2] = 1.0; + break; + case 6: + coords[0] = 1.0; + coords[1] = 1.0; + coords[2] = 1.0; + break; + case 7: + coords[0] = -1.0; + coords[1] = 1.0; + coords[2] = 1.0; + break; + + case 8: + coords[0] = 0.0; + coords[1] = -1.0; + coords[2] = -1.0; + break; + case 9: + coords[0] = 1.0; + coords[1] = 0.0; + coords[2] = -1.0; + break; + case 10: + coords[0] = 0.0; + coords[1] = 1.0; + coords[2] = -1.0; + break; + case 11: + coords[0] = -1.0; + coords[1] = 0.0; + coords[2] = -1.0; + break; + case 12: + coords[0] = -1.0; + coords[1] = -1.0; + coords[2] = 0.0; + break; + case 13: + coords[0] = 1.0; + coords[1] = -1.0; + coords[2] = 0.0; + break; + case 14: + coords[0] = 1.0; + coords[1] = 1.0; + coords[2] = 0.0; + break; + case 15: + coords[0] = -1.0; + coords[1] = 1.0; + coords[2] = 0.0; + break; + case 16: + coords[0] = 0.0; + coords[1] = -1.0; + coords[2] = 1.0; + break; + case 17: + coords[0] = 1.0; + coords[1] = 0.0; + coords[2] = 1.0; + break; + case 18: + coords[0] = 0.0; + coords[1] = 1.0; + coords[2] = 1.0; + break; + case 19: + coords[0] = -1.0; + coords[1] = 0.0; + coords[2] = 1.0; + break; + LOCAL_COORD_MACRO_END; + + SHAPE_FUN_MACRO_BEGIN; + funValue[0] = 0.125*(1.0 - gc[0])*(1.0 - gc[1])*(1.0 - gc[2])* + (-2.0 - gc[0] - gc[1] - gc[2]); + funValue[1] = 0.125*(1.0 + gc[0])*(1.0 - gc[1])*(1.0 - gc[2])* + (-2.0 + gc[0] - gc[1] - gc[2]); + funValue[2] = 0.125*(1.0 + gc[0])*(1.0 + gc[1])*(1.0 - gc[2])* + (-2.0 + gc[0] + gc[1] - gc[2]); + funValue[3] = 0.125*(1.0 - gc[0])*(1.0 + gc[1])*(1.0 - gc[2])* + (-2.0 - gc[0] + gc[1] - gc[2]); + funValue[4] = 0.125*(1.0 - gc[0])*(1.0 - gc[1])*(1.0 + gc[2])* + (-2.0 - gc[0] - gc[1] + gc[2]); + funValue[5] = 0.125*(1.0 + gc[0])*(1.0 - gc[1])*(1.0 + gc[2])* + (-2.0 + gc[0] - gc[1] + gc[2]); + funValue[6] = 0.125*(1.0 + gc[0])*(1.0 + gc[1])*(1.0 + gc[2])* + (-2.0 + gc[0] + gc[1] + gc[2]); + funValue[7] = 0.125*(1.0 - gc[0])*(1.0 + gc[1])*(1.0 + gc[2])* + (-2.0 - gc[0] + gc[1] + gc[2]); + + funValue[8] = 0.25*(1.0 - gc[0]*gc[0])*(1.0 - gc[1])*(1.0 - gc[2]); + funValue[9] = 0.25*(1.0 - gc[1]*gc[1])*(1.0 + gc[0])*(1.0 - gc[2]); + funValue[10] = 0.25*(1.0 - gc[0]*gc[0])*(1.0 + gc[1])*(1.0 - gc[2]); + funValue[11] = 0.25*(1.0 - gc[1]*gc[1])*(1.0 - gc[0])*(1.0 - gc[2]); + funValue[12] = 0.25*(1.0 - gc[2]*gc[2])*(1.0 - gc[0])*(1.0 - gc[1]); + funValue[13] = 0.25*(1.0 - gc[2]*gc[2])*(1.0 + gc[0])*(1.0 - gc[1]); + funValue[14] = 0.25*(1.0 - gc[2]*gc[2])*(1.0 + gc[0])*(1.0 + gc[1]); + funValue[15] = 0.25*(1.0 - gc[2]*gc[2])*(1.0 - gc[0])*(1.0 + gc[1]); + funValue[16] = 0.25*(1.0 - gc[0]*gc[0])*(1.0 - gc[1])*(1.0 + gc[2]); + funValue[17] = 0.25*(1.0 - gc[1]*gc[1])*(1.0 + gc[0])*(1.0 + gc[2]); + funValue[18] = 0.25*(1.0 - gc[0]*gc[0])*(1.0 + gc[1])*(1.0 + gc[2]); + funValue[19] = 0.25*(1.0 - gc[1]*gc[1])*(1.0 - gc[0])*(1.0 + gc[2]); + SHAPE_FUN_MACRO_END; +} + +/*! + * Init Qaudratic Hehahedron Reference coordinates and Shape function. + * Case B. + */ +void GaussInfo::hexa20bInit() +{ + LOCAL_COORD_MACRO_BEGIN; + case 0: + coords[0] = -1.0; + coords[1] = -1.0; + coords[2] = -1.0; + break; + case 3: + coords[0] = 1.0; + coords[1] = -1.0; + coords[2] = -1.0; + break; + case 2: + coords[0] = 1.0; + coords[1] = 1.0; + coords[2] = -1.0; + break; + case 1: + coords[0] = -1.0; + coords[1] = 1.0; + coords[2] = -1.0; + break; + case 4: + coords[0] = -1.0; + coords[1] = -1.0; + coords[2] = 1.0; + break; + case 7: + coords[0] = 1.0; + coords[1] = -1.0; + coords[2] = 1.0; + break; + case 6: + coords[0] = 1.0; + coords[1] = 1.0; + coords[2] = 1.0; + break; + case 5: + coords[0] = -1.0; + coords[1] = 1.0; + coords[2] = 1.0; + break; + + case 11: + coords[0] = 0.0; + coords[1] = -1.0; + coords[2] = -1.0; + break; + case 10: + coords[0] = 1.0; + coords[1] = 0.0; + coords[2] = -1.0; + break; + case 9: + coords[0] = 0.0; + coords[1] = 1.0; + coords[2] = -1.0; + break; + case 8: + coords[0] = -1.0; + coords[1] = 0.0; + coords[2] = -1.0; + break; + case 16: + coords[0] = -1.0; + coords[1] = -1.0; + coords[2] = 0.0; + break; + case 19: + coords[0] = 1.0; + coords[1] = -1.0; + coords[2] = 0.0; + break; + case 18: + coords[0] = 1.0; + coords[1] = 1.0; + coords[2] = 0.0; + break; + case 17: + coords[0] = -1.0; + coords[1] = 1.0; + coords[2] = 0.0; + break; + case 15: + coords[0] = 0.0; + coords[1] = -1.0; + coords[2] = 1.0; + break; + case 14: + coords[0] = 1.0; + coords[1] = 0.0; + coords[2] = 1.0; + break; + case 13: + coords[0] = 0.0; + coords[1] = 1.0; + coords[2] = 1.0; + break; + case 12: + coords[0] = -1.0; + coords[1] = 0.0; + coords[2] = 1.0; + break; + LOCAL_COORD_MACRO_END; + + SHAPE_FUN_MACRO_BEGIN; + + funValue[0] = 0.125*(1.0 - gc[0])*(1.0 - gc[1])*(1.0 - gc[2])* + (-2.0 - gc[0] - gc[1] - gc[2]); + funValue[3] = 0.125*(1.0 + gc[0])*(1.0 - gc[1])*(1.0 - gc[2])* + (-2.0 + gc[0] - gc[1] - gc[2]); + funValue[2] = 0.125*(1.0 + gc[0])*(1.0 + gc[1])*(1.0 - gc[2])* + (-2.0 + gc[0] + gc[1] - gc[2]); + funValue[1] = 0.125*(1.0 - gc[0])*(1.0 + gc[1])*(1.0 - gc[2])* + (-2.0 - gc[0] + gc[1] - gc[2]); + funValue[4] = 0.125*(1.0 - gc[0])*(1.0 - gc[1])*(1.0 + gc[2])* + (-2.0 - gc[0] - gc[1] + gc[2]); + funValue[7] = 0.125*(1.0 + gc[0])*(1.0 - gc[1])*(1.0 + gc[2])* + (-2.0 + gc[0] - gc[1] + gc[2]); + funValue[6] = 0.125*(1.0 + gc[0])*(1.0 + gc[1])*(1.0 + gc[2])* + (-2.0 + gc[0] + gc[1] + gc[2]); + funValue[5] = 0.125*(1.0 - gc[0])*(1.0 + gc[1])*(1.0 + gc[2])* + (-2.0 - gc[0] + gc[1] + gc[2]); + + funValue[11] = 0.25*(1.0 - gc[0]*gc[0])*(1.0 - gc[1])*(1.0 - gc[2]); + funValue[10] = 0.25*(1.0 - gc[1]*gc[1])*(1.0 + gc[0])*(1.0 - gc[2]); + funValue[9] = 0.25*(1.0 - gc[0]*gc[0])*(1.0 + gc[1])*(1.0 - gc[2]); + funValue[8] = 0.25*(1.0 - gc[1]*gc[1])*(1.0 - gc[0])*(1.0 - gc[2]); + funValue[16] = 0.25*(1.0 - gc[2]*gc[2])*(1.0 - gc[0])*(1.0 - gc[1]); + funValue[19] = 0.25*(1.0 - gc[2]*gc[2])*(1.0 + gc[0])*(1.0 - gc[1]); + funValue[18] = 0.25*(1.0 - gc[2]*gc[2])*(1.0 + gc[0])*(1.0 + gc[1]); + funValue[17] = 0.25*(1.0 - gc[2]*gc[2])*(1.0 - gc[0])*(1.0 + gc[1]); + funValue[15] = 0.25*(1.0 - gc[0]*gc[0])*(1.0 - gc[1])*(1.0 + gc[2]); + funValue[14] = 0.25*(1.0 - gc[1]*gc[1])*(1.0 + gc[0])*(1.0 + gc[2]); + funValue[13] = 0.25*(1.0 - gc[0]*gc[0])*(1.0 + gc[1])*(1.0 + gc[2]); + funValue[12] = 0.25*(1.0 - gc[1]*gc[1])*(1.0 - gc[0])*(1.0 + gc[2]); + SHAPE_FUN_MACRO_END; +} + + + +//////////////////////////////////////////////////////////////////////////////////////////////// +// GAUSS COORD CLASS // +//////////////////////////////////////////////////////////////////////////////////////////////// +/*! + * Constructor + */ +GaussCoords::GaussCoords() +{ +} + +/*! + * Destructor + */ +GaussCoords::~GaussCoords() +{ + GaussInfoVector::iterator it = _my_gauss_info.begin(); + for( ; it != _my_gauss_info.end(); it++ ) + { + if((*it) != NULL) + delete (*it); + } +} + +/*! + * Add Gauss localization info + */ +void GaussCoords::addGaussInfo( NormalizedCellType theGeometry, + int coordDim, + const double* theGaussCoord, + int theNbGauss, + const double* theReferenceCoord, + int theNbRef) throw (INTERP_KERNEL::Exception) +{ + GaussInfoVector::iterator it = _my_gauss_info.begin(); + for( ; it != _my_gauss_info.end(); it++ ) + { + if( (*it)->getCellType() == theGeometry ) + { + break; + } + } + + DataVector aGaussCoord; + for(int i = 0 ; i < theNbGauss*coordDim; i++ ) + aGaussCoord.push_back(theGaussCoord[i]); + + DataVector aReferenceCoord; + for(int i = 0 ; i < theNbRef*coordDim; i++ ) + aReferenceCoord.push_back(theReferenceCoord[i]); + + + GaussInfo* info = new GaussInfo( theGeometry, aGaussCoord, theNbGauss, aReferenceCoord, theNbRef); + info->initLocalInfo(); + + //If info with cell type doesn't exist add it + if( it == _my_gauss_info.end() ) + { + _my_gauss_info.push_back(info); + + // If information exists, update it + } + else + { + int index = std::distance(_my_gauss_info.begin(),it); + delete (*it); + _my_gauss_info[index] = info; + } +} + + +/*! + * Calculate gauss points coordinates + */ +double* GaussCoords::calculateCoords( NormalizedCellType theGeometry, + const double *theNodeCoords, + const int theSpaceDim, + const int *theIndex) throw (INTERP_KERNEL::Exception) +{ + const GaussInfo *info = getInfoGivenCellType(theGeometry); + int nbCoords = theSpaceDim * info->getNbGauss(); + double *aCoords = new double[nbCoords]; + calculateCoordsAlg(info,theNodeCoords,theSpaceDim,theIndex,aCoords); + return aCoords; +} + + +void GaussCoords::calculateCoords( NormalizedCellType theGeometry, const double *theNodeCoords, const int theSpaceDim, const int *theIndex, double *result) throw(INTERP_KERNEL::Exception) +{ + const GaussInfo *info = getInfoGivenCellType(theGeometry); + calculateCoordsAlg(info,theNodeCoords,theSpaceDim,theIndex,result); +} + +void GaussCoords::calculateCoordsAlg(const GaussInfo *info, const double* theNodeCoords, const int theSpaceDim, const int *theIndex, double *result) +{ + int aConn = info->getNbRef(); + + int nbCoords = theSpaceDim * info->getNbGauss(); + std::fill(result,result+nbCoords,0.); + + for( int gaussId = 0; gaussId < info->getNbGauss(); gaussId++ ) + { + double *coord=result+gaussId*theSpaceDim; + const double *function=info->getFunctionValues(gaussId); + for ( int connId = 0; connId < aConn ; connId++ ) + { + const double* nodeCoord = theNodeCoords + (theIndex[connId]*theSpaceDim); + for( int dimId = 0; dimId < theSpaceDim; dimId++ ) + coord[dimId] += nodeCoord[dimId]*function[connId]; + } + } +} + +const GaussInfo *GaussCoords::getInfoGivenCellType(NormalizedCellType cellType) +{ + GaussInfoVector::const_iterator it = _my_gauss_info.begin(); + //Try to find gauss localization info + for( ; it != _my_gauss_info.end() ; it++ ) + if( (*it)->getCellType()==cellType) + return (*it); + throw INTERP_KERNEL::Exception("Can't find gauss localization information !"); +} diff --git a/src/INTERP_KERNEL/GaussPoints/InterpKernelGaussCoords.hxx b/src/INTERP_KERNEL/GaussPoints/InterpKernelGaussCoords.hxx new file mode 100644 index 000000000..04821f0e1 --- /dev/null +++ b/src/INTERP_KERNEL/GaussPoints/InterpKernelGaussCoords.hxx @@ -0,0 +1,159 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef __INTERPKERNELGAUSS_HXX__ +#define __INTERPKERNELGAUSS_HXX__ + +#include "NormalizedUnstructuredMesh.hxx" +#include "InterpKernelException.hxx" + +#include + +namespace INTERP_KERNEL +{ + typedef std::vector DataVector; + typedef std::vector IndexVector; + + //Class to store Gauss Points information + class GaussInfo + { + public: + GaussInfo( NormalizedCellType theGeometry, + const DataVector& theGaussCoord, + int theNbGauss, + const DataVector& theReferenceCoord, + int theNbRef + ); + ~GaussInfo(); + + NormalizedCellType getCellType() const; + + int getGaussCoordDim() const; + int getReferenceCoordDim() const; + + int getNbGauss() const; + int getNbRef() const; + + const double* getFunctionValues( const int theGaussId ) const; + + void initLocalInfo() throw (INTERP_KERNEL::Exception); + + protected: + + bool isSatisfy(); + + //1D + void seg2Init(); + void seg3Init(); + + //2D + void tria3aInit(); + void tria3bInit(); + void tria6aInit(); + void tria6bInit(); + + void quad4aInit(); + void quad4bInit(); + void quad8aInit(); + void quad8bInit(); + + //3D + void tetra4aInit(); + void tetra4bInit(); + void tetra10aInit(); + void tetra10bInit(); + + void pyra5aInit(); + void pyra5bInit(); + void pyra13aInit(); + void pyra13bInit(); + + void penta6aInit(); + void penta6bInit(); + void penta15aInit(); + void penta15bInit(); + + void hexa8aInit(); + void hexa8bInit(); + void hexa20aInit(); + void hexa20bInit(); + + + private: + //INFORMATION from MEDMEM + NormalizedCellType _my_geometry; //Cell type + + int _my_nb_gauss; //Nb of the gauss points for element + DataVector _my_gauss_coord; //Gauss coordinates + + int _my_nb_ref; //Nb of the nodes for element: + //NORM_SEG2 - 2 + //NORM_SEG3 - 3 + //NORM_TRI3 - 3 + //............. + + DataVector _my_reference_coord; //Reference coordinates + + //LOCAL INFORMATION + DataVector _my_local_reference_coord; //Vector to store reference coordinates + int _my_local_ref_dim; //Dimension of the local reference coordinates: + // (x) - 1D case + // (x, y) - 2D case + // (x, y, z) - 3D case + int _my_local_nb_ref; //Nb of the local reference coordinates + + DataVector _my_function_value; //Shape Function values + }; + + + //Class for calculation of the coordinates of the gauss points + class GaussCoords + { + public: + + GaussCoords(); + ~GaussCoords(); + + void addGaussInfo( NormalizedCellType theGeometry, + int coordDim, + const double* theGaussCoord, + int theNbGauss, + const double* theReferenceCoord, + int theNbRef) throw (INTERP_KERNEL::Exception); + + double* calculateCoords( NormalizedCellType theGeometry, + const double* theNodeCoords, + const int theSpaceDim, + const int* theIndex) throw(INTERP_KERNEL::Exception); + + void calculateCoords( NormalizedCellType theGeometry, + const double* theNodeCoords, + const int theSpaceDim, + const int* theIndex, + double *result) throw(INTERP_KERNEL::Exception); + private: + const GaussInfo *getInfoGivenCellType(NormalizedCellType cellType); + void calculateCoordsAlg(const GaussInfo *info, const double* theNodeCoords, const int theSpaceDim, const int *theIndex, + double *result); + private: + typedef std::vector GaussInfoVector; + GaussInfoVector _my_gauss_info; + }; +} +#endif //INTERPKERNELGAUSS diff --git a/src/INTERP_KERNEL/GaussPoints/Makefile.am b/src/INTERP_KERNEL/GaussPoints/Makefile.am new file mode 100644 index 000000000..01d4a1454 --- /dev/null +++ b/src/INTERP_KERNEL/GaussPoints/Makefile.am @@ -0,0 +1,37 @@ +# Copyright (C) 2007-2011 CEA/DEN, EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +# File : Makefile.am +# Author : Vincent BERGEAUD (CEA/DEN/DANS/DM2S/SFME/LGLS) +# Module : MED +# +include $(top_srcdir)/adm_local/unix/make_common_starter.am + +noinst_LTLIBRARIES = libinterpkernelgauss.la + +salomeinclude_HEADERS = \ +InterpKernelGaussCoords.hxx + +# Libraries targets +dist_libinterpkernelgauss_la_SOURCES = \ +InterpKernelGaussCoords.cxx + +libinterpkernelgauss_la_CPPFLAGS=-I$(srcdir)/../Bases -I$(srcdir)/.. + +AM_CPPFLAGS += $(libinterpkernelgauss_la_CPPFLAGS) \ No newline at end of file diff --git a/src/INTERP_KERNEL/GenMathFormulae.hxx b/src/INTERP_KERNEL/GenMathFormulae.hxx index 42ce4f43f..99504bd7e 100644 --- a/src/INTERP_KERNEL/GenMathFormulae.hxx +++ b/src/INTERP_KERNEL/GenMathFormulae.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __GENMATHFORMULAE_HXX__ diff --git a/src/INTERP_KERNEL/Geometric2D/INTERPKERNELGEOMETRIC2DDefines.hxx b/src/INTERP_KERNEL/Geometric2D/INTERPKERNELGEOMETRIC2DDefines.hxx index 2909cb9d8..b5fa63065 100644 --- a/src/INTERP_KERNEL/Geometric2D/INTERPKERNELGEOMETRIC2DDefines.hxx +++ b/src/INTERP_KERNEL/Geometric2D/INTERPKERNELGEOMETRIC2DDefines.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __INTERPKERNELGEOMETRIC2DDEFINES_HXX__ diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DAbstractEdge.cxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DAbstractEdge.cxx index c92bf3014..790eafcfe 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DAbstractEdge.cxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DAbstractEdge.cxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "InterpKernelGeo2DAbstractEdge.hxx" diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DAbstractEdge.hxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DAbstractEdge.hxx index 34f0518b9..dadaeac41 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DAbstractEdge.hxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DAbstractEdge.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __INTERPKERNELGEO2DABSTRACTEDGE_HXX__ diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DBounds.cxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DBounds.cxx index 7b0187162..fbe4a0468 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DBounds.cxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DBounds.cxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "InterpKernelGeo2DBounds.hxx" diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DBounds.hxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DBounds.hxx index 4df244ba9..9f7afddc9 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DBounds.hxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DBounds.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __INTERPKERNELGEO2DBOUNDS_HXX__ diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.cxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.cxx index 6e13f3055..07b6d5ca3 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.cxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.cxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "InterpKernelGeo2DComposedEdge.hxx" diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.hxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.hxx index 772585e84..5e4299c0a 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.hxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __INTERPKERNELGEO2DCOMPOSEDNODE_HXX__ diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.cxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.cxx index 16c5fdd93..e75778c09 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.cxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.cxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "InterpKernelGeo2DEdge.hxx" @@ -607,7 +607,7 @@ void Edge::interpolate1DLin(const std::vector& distrib1, const std::vect MergePoints commonNode; for(int i=0;i::const_iterator iter=find_if(distrib2.begin()+1,distrib2.end(),bind2nd(std::greater_equal(),distrib1[i])); + std::vector::const_iterator iter=find_if(distrib2.begin()+1,distrib2.end(),bind2nd(std::greater_equal(),distrib1[i])); if(iter!=distrib2.end()) { for(int j=(iter-1)-distrib2.begin();j nodes(nbNodes); for(int i=0;i nodes(nbOfPoints); for(int i=0;i::_coordsT+OTT::coo2C(startOfCellNodeConn[i])*SPACEDIM); - if(CellModel::getCellModel(type).isQuadratic()) + if(CellModel::GetCellModel(type).isQuadratic()) return QuadraticPolygon::buildLinearPolygon(nodes); else return QuadraticPolygon::buildArcCirclePolygon(nodes); diff --git a/src/INTERP_KERNEL/INTERPKERNELDefines.hxx b/src/INTERP_KERNEL/INTERPKERNELDefines.hxx index 825b15783..7a18f8516 100644 --- a/src/INTERP_KERNEL/INTERPKERNELDefines.hxx +++ b/src/INTERP_KERNEL/INTERPKERNELDefines.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __INTERPKERNELDEFINES_HXX__ diff --git a/src/INTERP_KERNEL/IntegralUniformIntersector.hxx b/src/INTERP_KERNEL/IntegralUniformIntersector.hxx index e7fe7e9f2..41c53a87d 100644 --- a/src/INTERP_KERNEL/IntegralUniformIntersector.hxx +++ b/src/INTERP_KERNEL/IntegralUniformIntersector.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __INTEGRALUNIFORMINTERSECTOR_HXX__ diff --git a/src/INTERP_KERNEL/IntegralUniformIntersector.txx b/src/INTERP_KERNEL/IntegralUniformIntersector.txx index 334d9e0b0..1bc36d840 100644 --- a/src/INTERP_KERNEL/IntegralUniformIntersector.txx +++ b/src/INTERP_KERNEL/IntegralUniformIntersector.txx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __INTEGRALUNIFORMINTERSECTOR_TXX__ #define __INTEGRALUNIFORMINTERSECTOR_TXX__ diff --git a/src/INTERP_KERNEL/InterpKernelCellSimplify.cxx b/src/INTERP_KERNEL/InterpKernelCellSimplify.cxx new file mode 100644 index 000000000..5ebce3c4c --- /dev/null +++ b/src/INTERP_KERNEL/InterpKernelCellSimplify.cxx @@ -0,0 +1,495 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "InterpKernelCellSimplify.hxx" +#include "CellModel.hxx" + +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace INTERP_KERNEL; + +/*! + * This method takes as input a cell with type 'type' and whose connectivity is defined by (conn,lgth) + * It retrieves the same cell with a potentially different type (in return) whose connectivity is defined by (retConn,retLgth) + * \b WARNING for optimization reason the arrays 'retConn' and 'conn' can overlapped ! + */ +INTERP_KERNEL::NormalizedCellType CellSimplify::simplifyDegeneratedCell(INTERP_KERNEL::NormalizedCellType type, const int *conn, int lgth, + int *retConn, int& retLgth) throw(INTERP_KERNEL::Exception) +{ + const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(type); + std::set c(conn,conn+lgth); + c.erase(-1); + bool isObviousNonDegeneratedCell=((int)c.size()==lgth); + if(cm.isQuadratic() || isObviousNonDegeneratedCell) + {//quadratic do nothing for the moment. + retLgth=lgth; + int *tmp=new int[lgth];//no direct std::copy ! overlapping of conn and retConn ! + std::copy(conn,conn+lgth,tmp); + std::copy(tmp,tmp+lgth,retConn); + delete [] tmp; + return type; + } + if(cm.getDimension()==2) + { + int *tmp=new int[lgth]; + tmp[0]=conn[0]; + int newPos=1; + for(int i=1;i faces; + for(unsigned j=0;j nodes(conn,conn+lgth); + nodes.erase(-1); + int nbOfNodes=nodes.size(); + int magicNumber=100*nbOfNodes+nbOfFaces; + switch(magicNumber) + { + case 806: + return tryToUnPolyHex8(conn,nbOfFaces,lgth,retConn,retLgth); + case 1208: + return tryToUnPolyHexp12(conn,nbOfFaces,lgth,retConn,retLgth); + case 605: + return tryToUnPolyPenta6(conn,nbOfFaces,lgth,retConn,retLgth); + case 505: + return tryToUnPolyPyra5(conn,nbOfFaces,lgth,retConn,retLgth); + case 404: + return tryToUnPolyTetra4(conn,nbOfFaces,lgth,retConn,retLgth); + default: + retLgth=lgth; + std::copy(conn,conn+lgth,retConn); + return INTERP_KERNEL::NORM_POLYHED; + } +} + +bool CellSimplify::orientOppositeFace(const int *baseFace, int *retConn, const int *sideFace, int lgthBaseFace) +{ + std::vector tmp2; + std::set bases(baseFace,baseFace+lgthBaseFace); + std::set 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; + std::vector< std::pair > baseEdges(lgthBaseFace); + std::vector< std::pair > oppEdges(lgthBaseFace); + std::vector< std::pair > sideEdges(4); + for(int i=0;i(baseFace[i],baseFace[(i+1)%lgthBaseFace]); + oppEdges[i]=std::pair(retConn[i],retConn[(i+1)%lgthBaseFace]); + } + 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_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); + sideEdges[i]=r; + } + //end reverse sideFace + std::set< std::pair > baseEdgesS(baseEdges.begin(),baseEdges.end()); + std::set< std::pair > 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()) + return false; + } + if(tmp.size()!=1) + return false; + bool found=false; + std::pair pInOpp; + for(int i=0;i<4 && !found;i++) + {//finding the pair(edge) in sideFace that do not include any node of tmp[0] edge + found=(tmp[0].first!=sideEdges[i].first && tmp[0].first!=sideEdges[i].second && + tmp[0].second!=sideEdges[i].first && tmp[0].second!=sideEdges[i].second); + if(found) + {//found ! reverse it + pInOpp.first=sideEdges[i].second; + pInOpp.second=sideEdges[i].first; + } + } + if(!found) + return false; + int pos=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); + if(it==oppEdges.end())//the opposite edge of side face is not found opposite face ... maybe problem of orientation of polyhedron + return false; + int pos2=std::distance(oppEdges.begin(),it); + int offset=pos-pos2; + if(offset<0) + offset+=lgthBaseFace; + //this is the end copy the result + int *tmp3=new int[lgthBaseFace]; + for(int i=0;i(),(int)INTERP_KERNEL::NORM_QUAD4))==conn+lgth+nbOfFaces) + {//6 faces are QUAD4. + int oppositeFace=-1; + std::set 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_intersection(conn1.begin(),conn1.end(),conn2.begin(),conn2.end(),std::back_insert_iterator< std::vector >(tmp)); + if(tmp.empty()) + oppositeFace=i; + } + if(oppositeFace>=1) + {//oppositeFace of face#0 found. + int tmp2[4]; + if(tryToArrangeOppositeFace(conn,lgth,4,conn,conn+5*oppositeFace,6,tmp2)) + { + std::copy(conn,conn+4,retConn); + std::copy(tmp2,tmp2+4,retConn+4); + retLgth=8; + return INTERP_KERNEL::NORM_HEXA8; + } + } + } + retLgth=lgth; + std::copy(conn,conn+lgth,retConn); + return INTERP_KERNEL::NORM_POLYHED; +} + +INTERP_KERNEL::NormalizedCellType CellSimplify::tryToUnPolyHexp12(const int *conn, int nbOfFaces, int lgth, int *retConn, int& retLgth) +{ + int nbOfHexagon=std::count(conn+lgth,conn+lgth+nbOfFaces,(int)INTERP_KERNEL::NORM_POLYGON); + int nbOfQuad=std::count(conn+lgth,conn+lgth+nbOfFaces,(int)INTERP_KERNEL::NORM_QUAD4); + if(nbOfQuad==6 && nbOfHexagon==2) + { + const int *hexag0=std::find(conn+lgth,conn+lgth+nbOfFaces,(int)INTERP_KERNEL::NORM_POLYGON); + int hexg0Id=std::distance(conn+lgth,hexag0); + const int *hexag1=std::find(hexag0+1,conn+lgth+nbOfFaces,(int)INTERP_KERNEL::NORM_POLYGON); + int hexg1Id=std::distance(conn+lgth,hexag1); + const int *connHexag0=conn+5*hexg0Id; + int lgthH0=std::distance(connHexag0,std::find(connHexag0,conn+lgth,-1)); + if(lgthH0==6) + { + const int *connHexag1=conn+5*hexg0Id+7+(hexg1Id-hexg0Id-1)*5; + int 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_intersection(conn1.begin(),conn1.end(),conn2.begin(),conn2.end(),std::back_insert_iterator< std::vector >(tmp)); + if(tmp.empty()) + { + int tmp2[6]; + if(tryToArrangeOppositeFace(conn,lgth,6,connHexag0,connHexag1,8,tmp2)) + { + std::copy(connHexag0,connHexag0+6,retConn); + std::copy(tmp2,tmp2+6,retConn+6); + retLgth=12; + return INTERP_KERNEL::NORM_HEXGP12; + } + } + } + } + } + retLgth=lgth; + std::copy(conn,conn+lgth,retConn); + return INTERP_KERNEL::NORM_POLYHED; +} + +/*! + * Cell with 'conn' connectivity has been detected as a good candidate. Full check of this. If yes NORM_PENTA6 is returned. + * If fails a POLYHED is returned. + */ +INTERP_KERNEL::NormalizedCellType CellSimplify::tryToUnPolyPenta6(const int *conn, int nbOfFaces, int lgth, int *retConn, int& retLgth) +{ + int nbOfTriFace=std::count(conn+lgth,conn+lgth+nbOfFaces,(int)INTERP_KERNEL::NORM_TRI3); + int nbOfQuadFace=std::count(conn+lgth,conn+lgth+nbOfFaces,(int)INTERP_KERNEL::NORM_QUAD4); + if(nbOfTriFace==2 && nbOfQuadFace==3) + { + int tri3_0=std::distance(conn+lgth,std::find(conn+lgth,conn+lgth+nbOfFaces,(int)INTERP_KERNEL::NORM_TRI3)); + int tri3_1=std::distance(conn+lgth,std::find(conn+lgth+tri3_0+1,conn+lgth+nbOfFaces,(int)INTERP_KERNEL::NORM_TRI3)); + const int *tri_0=0,*tri_1=0; + const int *w=conn; + for(int i=0;i<5;i++) + { + if(i==tri3_0) + tri_0=w; + if(i==tri3_1) + tri_1=w; + w=std::find(w,conn+lgth,-1); + w++; + } + std::vector tmp; + std::set conn1(tri_0,tri_0+3); + std::set 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()) + { + int tmp2[3]; + if(tryToArrangeOppositeFace(conn,lgth,3,tri_0,tri_1,5,tmp2)) + { + std::copy(conn,conn+4,retConn); + std::copy(tmp2,tmp2+3,retConn+3); + retLgth=6; + return INTERP_KERNEL::NORM_PENTA6; + } + } + } + retLgth=lgth; + std::copy(conn,conn+lgth,retConn); + return INTERP_KERNEL::NORM_POLYHED; +} + +/*! + * Cell with 'conn' connectivity has been detected as a good candidate. Full check of this. If yes NORM_PYRA5 is returned. + * If fails a POLYHED is returned. + */ +INTERP_KERNEL::NormalizedCellType CellSimplify::tryToUnPolyPyra5(const int *conn, int nbOfFaces, int lgth, int *retConn, int& retLgth) +{ + int nbOfTriFace=std::count(conn+lgth,conn+lgth+nbOfFaces,(int)INTERP_KERNEL::NORM_TRI3); + int nbOfQuadFace=std::count(conn+lgth,conn+lgth+nbOfFaces,(int)INTERP_KERNEL::NORM_QUAD4); + if(nbOfTriFace==4 && nbOfQuadFace==1) + { + int quad4_pos=std::distance(conn+lgth,std::find(conn+lgth,conn+lgth+nbOfFaces,(int)INTERP_KERNEL::NORM_QUAD4)); + const int *quad4=0; + const int *w=conn; + for(int i=0;i<5 && quad4==0;i++) + { + if(i==quad4_pos) + quad4=w; + w=std::find(w,conn+lgth,-1); + w++; + } + std::set quad4S(quad4,quad4+4); + w=conn; + bool ok=true; + int point=-1; + for(int i=0;i<5 && ok;i++) + { + if(i!=quad4_pos) + { + std::vector tmp; + std::set 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(); + std::set_difference(conn2.begin(),conn2.end(),quad4S.begin(),quad4S.end(),std::back_insert_iterator< std::vector >(tmp)); + ok=ok && tmp.size()==1; + if(ok) + { + if(point>=0) + ok=point==tmp[0]; + else + point=tmp[0]; + } + } + w=std::find(w,conn+lgth,-1); + w++; + } + if(ok && point>=0) + { + std::copy(quad4,quad4+4,retConn); + retConn[4]=point; + retLgth=5; + return INTERP_KERNEL::NORM_PYRA5; + } + } + retLgth=lgth; + std::copy(conn,conn+lgth,retConn); + return INTERP_KERNEL::NORM_POLYHED; +} + +/*! + * Cell with 'conn' connectivity has been detected as a good candidate. Full check of this. If yes NORM_TETRA4 is returned. + * If fails a POLYHED is returned. + */ +INTERP_KERNEL::NormalizedCellType CellSimplify::tryToUnPolyTetra4(const int *conn, int nbOfFaces, int lgth, int *retConn, int& retLgth) +{ + if(std::find_if(conn+lgth,conn+lgth+nbOfFaces,std::bind2nd(std::not_equal_to(),(int)INTERP_KERNEL::NORM_TRI3))==conn+lgth+nbOfFaces) + { + std::set tribase(conn,conn+3); + int 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_intersection(conn2.begin(),conn2.end(),tribase.begin(),tribase.end(),std::back_insert_iterator< std::vector >(tmp)); + ok=tmp.size()==2; + tmp.clear(); + std::set_difference(conn2.begin(),conn2.end(),tribase.begin(),tribase.end(),std::back_insert_iterator< std::vector >(tmp)); + ok=ok && tmp.size()==1; + if(ok) + { + if(point>=0) + ok=point==tmp[0]; + else + point=tmp[0]; + } + } + if(ok && point>=0) + { + std::copy(conn,conn+3,retConn); + retConn[3]=point; + retLgth=4; + return INTERP_KERNEL::NORM_TETRA4; + } + } + retLgth=lgth; + std::copy(conn,conn+lgth,retConn); + return INTERP_KERNEL::NORM_POLYHED; +} diff --git a/src/INTERP_KERNEL/InterpKernelCellSimplify.hxx b/src/INTERP_KERNEL/InterpKernelCellSimplify.hxx new file mode 100644 index 000000000..9b295e536 --- /dev/null +++ b/src/INTERP_KERNEL/InterpKernelCellSimplify.hxx @@ -0,0 +1,48 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef __INTERPKERNELCELLSIMPLIFY_HXX__ +#define __INTERPKERNELCELLSIMPLIFY_HXX__ + +#include "NormalizedUnstructuredMesh.hxx" +#include "InterpKernelException.hxx" + +namespace INTERP_KERNEL +{ + class CellSimplify + { + public: + static INTERP_KERNEL::NormalizedCellType simplifyDegeneratedCell(INTERP_KERNEL::NormalizedCellType type, const int *conn, int lgth, + int *retConn, int& retLgth) throw(INTERP_KERNEL::Exception); + static int *getFullPolyh3DCell(INTERP_KERNEL::NormalizedCellType type, const int *conn, int lgth, + int& retNbOfFaces, int& retLgth); + static INTERP_KERNEL::NormalizedCellType tryToUnPoly2D(const int *conn, int lgth, int *retConn, int& retLgth); + static INTERP_KERNEL::NormalizedCellType tryToUnPoly3D(const int *conn, int nbOfFaces, int lgth, int *retConn, int& retLgth); + static INTERP_KERNEL::NormalizedCellType tryToUnPolyHex8(const int *conn, int nbOfFaces, int lgth, int *retConn, int& retLgth); + static INTERP_KERNEL::NormalizedCellType tryToUnPolyHexp12(const int *conn, int nbOfFaces, int lgth, int *retConn, int& retLgth); + static INTERP_KERNEL::NormalizedCellType tryToUnPolyPenta6(const int *conn, int nbOfFaces, int lgth, int *retConn, int& retLgth); + static INTERP_KERNEL::NormalizedCellType tryToUnPolyPyra5(const int *conn, int nbOfFaces, int lgth, int *retConn, int& retLgth); + static INTERP_KERNEL::NormalizedCellType tryToUnPolyTetra4(const int *conn, int nbOfFaces, int lgth, int *retConn, int& retLgth); + static bool tryToArrangeOppositeFace(const int *conn, int lgth, int lgthBaseFace, const int *baseFace, const int *oppFaceId, int nbOfFaces, int *retConnOfOppFace); + static bool isWellOriented(const int *baseFace, int *retConn, const int *sideFace, int lgthBaseFace); + static bool orientOppositeFace(const int *baseFace, int *retConn, const int *sideFace, int lgthBaseFace); + }; +} + +#endif diff --git a/src/INTERP_KERNEL/InterpKernelMatrix.hxx b/src/INTERP_KERNEL/InterpKernelMatrix.hxx index b8110641b..a0e2476a8 100755 --- a/src/INTERP_KERNEL/InterpKernelMatrix.hxx +++ b/src/INTERP_KERNEL/InterpKernelMatrix.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __INTERPKERNELMATRIX_HXX_ @@ -51,10 +51,10 @@ namespace INTERP_KERNEL int _val; }; - class Row : public std::vector< typename std::pair > + class Row : public std::vector< std::pair > { public: - Row():std::vector< typename std::pair >(){}; + Row():std::vector< std::pair >(){}; Row (const Row& row) { this->resize(row.size()); @@ -70,12 +70,12 @@ namespace INTERP_KERNEL } typename std::vector< std::pair >::const_iterator find(int elem) const { - return std::find_if(std::vector< typename std::pair >::begin(),std::vector< typename std::pair >::end(),KeyComparator(elem)); + return std::find_if(std::vector< std::pair >::begin(),std::vector< std::pair >::end(),KeyComparator(elem)); } - void erase(int elem) { std::vector< typename std::pair >::erase(std::find_if(std::vector< typename std::pair >::begin(),std::vector< typename std::pair >::end(),KeyComparator(elem))); } + 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) { push_back(myPair); } + void insert(const std::pair& myPair) { vector >::push_back(myPair); } }; private: diff --git a/src/INTERP_KERNEL/InterpKernelMeshQuality.cxx b/src/INTERP_KERNEL/InterpKernelMeshQuality.cxx index 271771edd..0d060a11f 100644 --- a/src/INTERP_KERNEL/InterpKernelMeshQuality.cxx +++ b/src/INTERP_KERNEL/InterpKernelMeshQuality.cxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "InterpKernelMeshQuality.hxx" diff --git a/src/INTERP_KERNEL/InterpKernelMeshQuality.hxx b/src/INTERP_KERNEL/InterpKernelMeshQuality.hxx index 2f11bb4d1..ebba8a1af 100644 --- a/src/INTERP_KERNEL/InterpKernelMeshQuality.hxx +++ b/src/INTERP_KERNEL/InterpKernelMeshQuality.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __INTERPKERNELMESHQUALITY_HXX_ diff --git a/src/INTERP_KERNEL/InterpKernelUtilities.hxx b/src/INTERP_KERNEL/InterpKernelUtilities.hxx index c317cf64e..e847ac773 100644 --- a/src/INTERP_KERNEL/InterpKernelUtilities.hxx +++ b/src/INTERP_KERNEL/InterpKernelUtilities.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __INTERPKERNELUTILITIES_HXX__ diff --git a/src/INTERP_KERNEL/Interpolation.hxx b/src/INTERP_KERNEL/Interpolation.hxx index d5bc563f9..128ca6e3c 100644 --- a/src/INTERP_KERNEL/Interpolation.hxx +++ b/src/INTERP_KERNEL/Interpolation.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __INTERPOLATION_HXX__ diff --git a/src/INTERP_KERNEL/Interpolation.txx b/src/INTERP_KERNEL/Interpolation.txx index 6e59eb88c..fc5d4c30e 100644 --- a/src/INTERP_KERNEL/Interpolation.txx +++ b/src/INTERP_KERNEL/Interpolation.txx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __INTERPOLATION_TXX__ #define __INTERPOLATION_TXX__ diff --git a/src/INTERP_KERNEL/Interpolation1D.hxx b/src/INTERP_KERNEL/Interpolation1D.hxx index d11b202b1..49dde9e64 100755 --- a/src/INTERP_KERNEL/Interpolation1D.hxx +++ b/src/INTERP_KERNEL/Interpolation1D.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __INTERPOLATION1D_HXX__ diff --git a/src/INTERP_KERNEL/Interpolation1D.txx b/src/INTERP_KERNEL/Interpolation1D.txx index 05e57f29a..2d676a481 100644 --- a/src/INTERP_KERNEL/Interpolation1D.txx +++ b/src/INTERP_KERNEL/Interpolation1D.txx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __INTERPOLATION1D_TXX__ #define __INTERPOLATION1D_TXX__ diff --git a/src/INTERP_KERNEL/Interpolation2D.hxx b/src/INTERP_KERNEL/Interpolation2D.hxx index 05508345d..fb748e889 100755 --- a/src/INTERP_KERNEL/Interpolation2D.hxx +++ b/src/INTERP_KERNEL/Interpolation2D.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __INTERPOLATION2D_HXX__ diff --git a/src/INTERP_KERNEL/Interpolation2D.txx b/src/INTERP_KERNEL/Interpolation2D.txx index 7d12de41d..8fcb207b1 100644 --- a/src/INTERP_KERNEL/Interpolation2D.txx +++ b/src/INTERP_KERNEL/Interpolation2D.txx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __INTERPOLATION2D_TXX__ #define __INTERPOLATION2D_TXX__ diff --git a/src/INTERP_KERNEL/Interpolation2DCurve.cxx b/src/INTERP_KERNEL/Interpolation2DCurve.cxx new file mode 100644 index 000000000..dcb61303a --- /dev/null +++ b/src/INTERP_KERNEL/Interpolation2DCurve.cxx @@ -0,0 +1,59 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "Interpolation2DCurve.hxx" +#include "InterpolationCurve.txx" + +namespace INTERP_KERNEL +{ + Interpolation2DCurve::Interpolation2DCurve() + { + // to have non-zero default thickness of target element + InterpolationOptions::setBoundingBoxAdjustmentAbs( InterpolationOptions::getPrecision() ); + } + + Interpolation2DCurve::Interpolation2DCurve + (const InterpolationOptions& io):InterpolationCurve(io) + { + // to have non-zero default thickness of target element + InterpolationOptions::setBoundingBoxAdjustmentAbs( InterpolationOptions::getPrecision() ); + } + + /** + * \brief Function used to set the options for the intersection calculation + * \details The following options can be modified: + * -# Precision: Level of precision of the computations. + * - Values: positive real number. + * - Default: 1.0E-12. + * -# Tolerance: Thickness of target element. + * - Values: positive real number. + * - Default: 1.0E-12. + * -# Median line: Position of the median line where both segments will be projected. + * - Values: real number between 0.0 and 1.0. + * - Default: 0.5 + */ + void Interpolation2DCurve::setOptions (double precision, + double tolerance, + double medianLine) + { + InterpolationOptions::setPrecision(precision); + InterpolationOptions::setBoundingBoxAdjustmentAbs(tolerance); + InterpolationOptions::setMedianPlane(medianLine); + } +} diff --git a/src/INTERP_KERNEL/Interpolation2DCurve.hxx b/src/INTERP_KERNEL/Interpolation2DCurve.hxx index 72a36b6f4..0077fa3b8 100644 --- a/src/INTERP_KERNEL/Interpolation2DCurve.hxx +++ b/src/INTERP_KERNEL/Interpolation2DCurve.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __INTERPOLATION2DCURVE_HXX__ diff --git a/src/INTERP_KERNEL/Interpolation2DCurve.txx b/src/INTERP_KERNEL/Interpolation2DCurve.txx deleted file mode 100644 index 0aafe3f91..000000000 --- a/src/INTERP_KERNEL/Interpolation2DCurve.txx +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#ifndef __INTERPOLATION2DCURVE_TXX__ -#define __INTERPOLATION2DCURVE_TXX__ - -#include "Interpolation2DCurve.hxx" -#include "InterpolationCurve.txx" - -namespace INTERP_KERNEL -{ - Interpolation2DCurve::Interpolation2DCurve() - { - // to have non-zero default thickness of target element - InterpolationOptions::setBoundingBoxAdjustmentAbs( InterpolationOptions::getPrecision() ); - } - - Interpolation2DCurve::Interpolation2DCurve - (const InterpolationOptions& io):InterpolationCurve(io) - { - // to have non-zero default thickness of target element - InterpolationOptions::setBoundingBoxAdjustmentAbs( InterpolationOptions::getPrecision() ); - } - - /** - * \brief Function used to set the options for the intersection calculation - * \details The following options can be modified: - * -# Precision: Level of precision of the computations. - * - Values: positive real number. - * - Default: 1.0E-12. - * -# Tolerance: Thickness of target element. - * - Values: positive real number. - * - Default: 1.0E-12. - * -# Median line: Position of the median line where both segments will be projected. - * - Values: real number between 0.0 and 1.0. - * - Default: 0.5 - */ - void Interpolation2DCurve::setOptions (double precision, - double tolerance, - double medianLine) - { - InterpolationOptions::setPrecision(precision); - InterpolationOptions::setBoundingBoxAdjustmentAbs(tolerance); - InterpolationOptions::setMedianPlane(medianLine); - } -} - -#endif diff --git a/src/INTERP_KERNEL/Interpolation3D.cxx b/src/INTERP_KERNEL/Interpolation3D.cxx new file mode 100644 index 000000000..70e249140 --- /dev/null +++ b/src/INTERP_KERNEL/Interpolation3D.cxx @@ -0,0 +1,40 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "Interpolation3D.hxx" + +namespace INTERP_KERNEL +{ + /** + * \defgroup interpolation3D Interpolation3D + * \class Interpolation3D + * \brief Class used to calculate the volumes of intersection between the elements of two 3D meshes. + * + */ + /** + * Default constructor + * + */ + Interpolation3D::Interpolation3D() + { + } + Interpolation3D::Interpolation3D(const InterpolationOptions& io):Interpolation(io) + { + } +} diff --git a/src/INTERP_KERNEL/Interpolation3D.hxx b/src/INTERP_KERNEL/Interpolation3D.hxx index e054c53f8..d9950547f 100644 --- a/src/INTERP_KERNEL/Interpolation3D.hxx +++ b/src/INTERP_KERNEL/Interpolation3D.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __INTERPOLATION3D_HXX__ diff --git a/src/INTERP_KERNEL/Interpolation3D.txx b/src/INTERP_KERNEL/Interpolation3D.txx index e01aef93a..9e90fe447 100644 --- a/src/INTERP_KERNEL/Interpolation3D.txx +++ b/src/INTERP_KERNEL/Interpolation3D.txx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __INTERPOLATION3D_TXX__ #define __INTERPOLATION3D_TXX__ @@ -49,23 +49,6 @@ namespace INTERP_KERNEL { - /** - * \defgroup interpolation3D Interpolation3D - * \class Interpolation3D - * \brief Class used to calculate the volumes of intersection between the elements of two 3D meshes. - * - */ - /** - * Default constructor - * - */ - Interpolation3D::Interpolation3D() - { - } - Interpolation3D::Interpolation3D(const InterpolationOptions& io):Interpolation(io) - { - } - /** * Calculates the matrix of volumes of intersection between the elements of srcMesh and the elements of targetMesh. * The calculation is done in two steps. First a filtering process reduces the number of pairs of elements for which the diff --git a/src/INTERP_KERNEL/Interpolation3DSurf.cxx b/src/INTERP_KERNEL/Interpolation3DSurf.cxx new file mode 100644 index 000000000..e24f0a731 --- /dev/null +++ b/src/INTERP_KERNEL/Interpolation3DSurf.cxx @@ -0,0 +1,60 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "Interpolation3DSurf.hxx" +#include "InterpolationPlanar.txx" + +namespace INTERP_KERNEL +{ + Interpolation3DSurf::Interpolation3DSurf() + { + } + + Interpolation3DSurf::Interpolation3DSurf(const InterpolationOptions& io):InterpolationPlanar(io) + { + } + + + /** + \brief Function used to set the options for the intersection calculation + \details The following options can be modified: + -# Intersection_type: the type of algorithm to be used in the computation of the cell-cell intersections. + - Values: Triangle, Convex. + - Default: Triangle. + -# MedianPlane: Position of the median plane where both cells will be projected + - Values: between 0 and 1. + - Default: 0.5. + -# DoRotate: rotate the coordinate system such that the target cell is in the Oxy plane. + - Values: true (necessarilly if Intersection_type=Triangle), false. + - Default: true (as default Intersection_type=Triangle) + -# Precision: Level of precision of the computations is precision times the characteristic size of the mesh. + - Values: positive real number. + - Default: 1.0E-12. + -# PrintLevel: Level of verboseness during the computations. + - Values: interger between 0 and 3. + - Default: 0. + */ + void Interpolation3DSurf::setOptions(double precision, int printLevel, double medianPlane, + IntersectionType intersectionType, bool doRotate, int orientation) + { + InterpolationPlanar::setOptions(precision,printLevel,intersectionType, orientation); + InterpolationPlanar::setDoRotate(doRotate); + InterpolationPlanar::setMedianPlane(medianPlane); + } +} diff --git a/src/INTERP_KERNEL/Interpolation3DSurf.hxx b/src/INTERP_KERNEL/Interpolation3DSurf.hxx index b319e81bc..2e52f0f3e 100644 --- a/src/INTERP_KERNEL/Interpolation3DSurf.hxx +++ b/src/INTERP_KERNEL/Interpolation3DSurf.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __INTERPOLATION3DSURF_HXX__ diff --git a/src/INTERP_KERNEL/Interpolation3DSurf.txx b/src/INTERP_KERNEL/Interpolation3DSurf.txx deleted file mode 100644 index 440a95c25..000000000 --- a/src/INTERP_KERNEL/Interpolation3DSurf.txx +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#ifndef __INTERPOLATION3DSURF_TXX__ -#define __INTERPOLATION3DSURF_TXX__ - -#include "Interpolation3DSurf.hxx" -#include "InterpolationPlanar.txx" - -namespace INTERP_KERNEL -{ - Interpolation3DSurf::Interpolation3DSurf() - { - } - - Interpolation3DSurf::Interpolation3DSurf(const InterpolationOptions& io):InterpolationPlanar(io) - { - } - - - /** - \brief Function used to set the options for the intersection calculation - \details The following options can be modified: - -# Intersection_type: the type of algorithm to be used in the computation of the cell-cell intersections. - - Values: Triangle, Convex. - - Default: Triangle. - -# MedianPlane: Position of the median plane where both cells will be projected - - Values: between 0 and 1. - - Default: 0.5. - -# DoRotate: rotate the coordinate system such that the target cell is in the Oxy plane. - - Values: true (necessarilly if Intersection_type=Triangle), false. - - Default: true (as default Intersection_type=Triangle) - -# Precision: Level of precision of the computations is precision times the characteristic size of the mesh. - - Values: positive real number. - - Default: 1.0E-12. - -# PrintLevel: Level of verboseness during the computations. - - Values: interger between 0 and 3. - - Default: 0. - */ - void Interpolation3DSurf::setOptions(double precision, int printLevel, double medianPlane, - IntersectionType intersectionType, bool doRotate, int orientation) - { - InterpolationPlanar::setOptions(precision,printLevel,intersectionType, orientation); - InterpolationPlanar::setDoRotate(doRotate); - InterpolationPlanar::setMedianPlane(medianPlane); - } -} - -#endif diff --git a/src/INTERP_KERNEL/InterpolationCC.hxx b/src/INTERP_KERNEL/InterpolationCC.hxx index 738bdb0c5..1992fe74e 100644 --- a/src/INTERP_KERNEL/InterpolationCC.hxx +++ b/src/INTERP_KERNEL/InterpolationCC.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2009-2010 OPEN CASCADE +// Copyright (C) 2009-2011 OPEN CASCADE // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // File : InterpolationCC.hxx diff --git a/src/INTERP_KERNEL/InterpolationCC.txx b/src/INTERP_KERNEL/InterpolationCC.txx index 9b08c68f6..3f9c8152e 100644 --- a/src/INTERP_KERNEL/InterpolationCC.txx +++ b/src/INTERP_KERNEL/InterpolationCC.txx @@ -1,20 +1,20 @@ -// Copyright (C) 2009-2010 OPEN CASCADE +// Copyright (C) 2009-2011 OPEN CASCADE // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // File : InterpolationCC.txx // Created : Fri Aug 14 11:39:27 2009 diff --git a/src/INTERP_KERNEL/InterpolationCU.hxx b/src/INTERP_KERNEL/InterpolationCU.hxx index ea73b3667..9efa4ebe8 100644 --- a/src/INTERP_KERNEL/InterpolationCU.hxx +++ b/src/INTERP_KERNEL/InterpolationCU.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2009-2010 OPEN CASCADE +// Copyright (C) 2009-2011 OPEN CASCADE // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // File : InterpolationCU.hxx diff --git a/src/INTERP_KERNEL/InterpolationCU.txx b/src/INTERP_KERNEL/InterpolationCU.txx index 18d09ef97..7b7c2415f 100644 --- a/src/INTERP_KERNEL/InterpolationCU.txx +++ b/src/INTERP_KERNEL/InterpolationCU.txx @@ -1,20 +1,20 @@ -// Copyright (C) 2009-2010 OPEN CASCADE +// Copyright (C) 2009-2011 OPEN CASCADE // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // File : InterpolationCU.txx // Created : Mon Dec 14 17:30:25 2009 diff --git a/src/INTERP_KERNEL/InterpolationCurve.hxx b/src/INTERP_KERNEL/InterpolationCurve.hxx index 0c3f11ad3..bc359e622 100644 --- a/src/INTERP_KERNEL/InterpolationCurve.hxx +++ b/src/INTERP_KERNEL/InterpolationCurve.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __INTERPOLATIONCURVE_HXX__ diff --git a/src/INTERP_KERNEL/InterpolationCurve.txx b/src/INTERP_KERNEL/InterpolationCurve.txx index e4b908322..ae8978e4c 100644 --- a/src/INTERP_KERNEL/InterpolationCurve.txx +++ b/src/INTERP_KERNEL/InterpolationCurve.txx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __INTERPOLATIONCURVE_TXX__ #define __INTERPOLATIONCURVE_TXX__ diff --git a/src/INTERP_KERNEL/InterpolationOptions.cxx b/src/INTERP_KERNEL/InterpolationOptions.cxx index 6069bf22d..f4b492320 100644 --- a/src/INTERP_KERNEL/InterpolationOptions.cxx +++ b/src/INTERP_KERNEL/InterpolationOptions.cxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "InterpolationOptions.hxx" diff --git a/src/INTERP_KERNEL/InterpolationOptions.hxx b/src/INTERP_KERNEL/InterpolationOptions.hxx index 667e320b6..9cb706a41 100644 --- a/src/INTERP_KERNEL/InterpolationOptions.hxx +++ b/src/INTERP_KERNEL/InterpolationOptions.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __INTERPOLATIONOPTIONS_HXX__ diff --git a/src/INTERP_KERNEL/InterpolationPlanar.hxx b/src/INTERP_KERNEL/InterpolationPlanar.hxx index 2e54eabe4..5699fbc48 100755 --- a/src/INTERP_KERNEL/InterpolationPlanar.hxx +++ b/src/INTERP_KERNEL/InterpolationPlanar.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __INTERPOLATIONPLANAR_HXX__ diff --git a/src/INTERP_KERNEL/InterpolationPlanar.txx b/src/INTERP_KERNEL/InterpolationPlanar.txx index b41ec15a7..a8ea915f7 100644 --- a/src/INTERP_KERNEL/InterpolationPlanar.txx +++ b/src/INTERP_KERNEL/InterpolationPlanar.txx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __INTERPOLATIONPLANAR_TXX__ #define __INTERPOLATIONPLANAR_TXX__ diff --git a/src/INTERP_KERNEL/InterpolationUtils.hxx b/src/INTERP_KERNEL/InterpolationUtils.hxx index e96f3fc1b..b390d445a 100644 --- a/src/INTERP_KERNEL/InterpolationUtils.hxx +++ b/src/INTERP_KERNEL/InterpolationUtils.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __INTERPOLATIONUTILS_HXX__ @@ -73,11 +73,11 @@ namespace INTERP_KERNEL } /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */ - /* fonction qui calcul le déterminant */ + /* fonction qui calcul le determinant */ /* de deux vecteur(cf doc CGAL). */ /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _*/ - //fonction qui calcul le déterminant des vecteurs: P3P1 et P3P2 + //fonction qui calcul le determinant des vecteurs: P3P1 et P3P2 //(cf doc CGAL). inline double mon_determinant(const double* P_1, @@ -181,8 +181,8 @@ namespace INTERP_KERNEL } /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */ - /* calcul les coordonnées du barycentre d'un polygone */ - /* le vecteur en entrée est constitué des coordonnées */ + /* calcul les coordonnees du barycentre d'un polygone */ + /* le vecteur en entree est constitue des coordonnees */ /* des sommets du polygone */ /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */ @@ -206,6 +206,57 @@ namespace INTERP_KERNEL return Bary; } + + /*! + * Given 6 coeffs of a Tria6 returns the corresponding value of a given pos + */ + inline double computeTria6RefBase(const double *coeffs, const double *pos) + { + return coeffs[0]+coeffs[1]*pos[0]+coeffs[2]*pos[1]+coeffs[3]*pos[0]*pos[0]+coeffs[4]*pos[0]*pos[1]+coeffs[5]*pos[1]*pos[1]; + } + + /*! + * Given xsi,eta in refCoo (length==2) return 6 coeffs in weightedPos. + */ + inline void computeWeightedCoeffsInTria6FromRefBase(const double *refCoo, double *weightedPos) + { + weightedPos[0]=(1.-refCoo[0]-refCoo[1])*(1.-2*refCoo[0]-2.*refCoo[1]); + weightedPos[1]=refCoo[0]*(2.*refCoo[0]-1.); + weightedPos[2]=refCoo[1]*(2.*refCoo[1]-1.); + weightedPos[3]=4.*refCoo[0]*(1.-refCoo[0]-refCoo[1]); + weightedPos[4]=4.*refCoo[0]*refCoo[1]; + weightedPos[5]=4.*refCoo[1]*(1.-refCoo[0]-refCoo[1]); + } + + /*! + * Given 10 coeffs of a Tetra10 returns the corresponding value of a given pos + */ + inline double computeTetra10RefBase(const double *coeffs, const double *pos) + { + return coeffs[0]+coeffs[1]*pos[0]+coeffs[2]*pos[1]+coeffs[3]*pos[2]+ + coeffs[4]*pos[0]*pos[0]+coeffs[5]*pos[0]*pos[1]+coeffs[6]*pos[0]*pos[2]+ + coeffs[7]*pos[1]*pos[1]+coeffs[8]*pos[1]*pos[2]+coeffs[9]*pos[2]*pos[2]; + } + + /*! + * Given xsi,eta,z in refCoo (length==3) return 10 coeffs in weightedPos. + */ + inline void computeWeightedCoeffsInTetra10FromRefBase(const double *refCoo, double *weightedPos) + { + //http://www.cadfamily.com/download/CAE/ABAQUS/The%20Finite%20Element%20Method%20-%20A%20practical%20course%20abaqus.pdf page 217 + //L1=1-refCoo[0]-refCoo[1]-refCoo[2] + //L2=refCoo[0] L3=refCoo[1] L4=refCoo[2] + weightedPos[0]=(-2.*(refCoo[0]+refCoo[1]+refCoo[2])+1)*(1-refCoo[0]-refCoo[1]-refCoo[2]);//(2*L1-1)*L1 + weightedPos[1]=(2.*refCoo[0]-1.)*refCoo[0];//(2*L2-1)*L2 + weightedPos[2]=(2.*refCoo[1]-1.)*refCoo[1];//(2*L3-1)*L3 + weightedPos[3]=(2.*refCoo[2]-1.)*refCoo[2];//(2*L4-1)*L4 + weightedPos[4]=4.*(1-refCoo[0]-refCoo[1]-refCoo[2])*refCoo[0];//4*L1*L2 + weightedPos[5]=4.*refCoo[0]*refCoo[1];//4*L2*L3 + weightedPos[6]=4.*(1-refCoo[0]-refCoo[1]-refCoo[2])*refCoo[1];//4*L1*L3 + weightedPos[7]=4.*(1-refCoo[0]-refCoo[1]-refCoo[2])*refCoo[2];//4*L1*L4 + weightedPos[8]=4.*refCoo[0]*refCoo[2];//4*L2*L4 + weightedPos[9]=4.*refCoo[1]*refCoo[2];//4*L3*L4 + } /*! * \brief Solve system equation in matrix form using Gaussian elimination algorithm @@ -221,37 +272,42 @@ namespace INTERP_KERNEL // make upper triangular matrix (forward elimination) int iR[nbRow];// = { 0, 1, 2 }; - for ( int i = 0; i < (int) nbRow; ++i ) iR[i] = i; - + for ( int i = 0; i < (int) nbRow; ++i ) + iR[i] = i; for ( int i = 0; i < (int)(nbRow-1); ++i ) // nullify nbRow-1 rows { // swap rows to have max value of i-th column in i-th row 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] ); - if ( m > max ) { - max = m; - std::swap( iR[r], iR[i] ); + for ( int r = i+1; r < (int)nbRow; ++r ) + { + double m = std::fabs( M[ iR[r] ][i] ); + if ( m > max ) + { + max = m; + std::swap( iR[r], iR[i] ); + } + } + if ( max < std::numeric_limits::min() ) + { + //sol[0]=1; sol[1]=sol[2]=sol[3]=0; + return false; // no solution } - } - if ( max < std::numeric_limits::min() ) { - //sol[0]=1; sol[1]=sol[2]=sol[3]=0; - return false; // no solution - } // make 0 below M[i][i] (actually we do not modify i-th column) double* tUpRow = M[ iR[i] ]; - for ( int r = i+1; r < (int)nbRow; ++r ) { - double* mRow = M[ iR[r] ]; - double coef = mRow[ i ] / tUpRow[ i ]; - for ( int c = i+1; c < nbCol; ++c ) - mRow[ c ] -= tUpRow[ c ] * coef; - } + for ( int r = i+1; r < (int)nbRow; ++r ) + { + double* mRow = M[ iR[r] ]; + double coef = mRow[ i ] / tUpRow[ i ]; + for ( int c = i+1; c < nbCol; ++c ) + mRow[ c ] -= tUpRow[ c ] * coef; + } } double* mRow = M[ iR[nbRow-1] ]; - if ( std::fabs( mRow[ nbRow-1 ] ) < std::numeric_limits::min() ) { - //sol[0]=1; sol[1]=sol[2]=sol[3]=0; - return false; // no solution - } + if ( std::fabs( mRow[ nbRow-1 ] ) < std::numeric_limits::min() ) + { + //sol[0]=1; sol[1]=sol[2]=sol[3]=0; + return false; // no solution + } mRow[ nbRow ] /= mRow[ nbRow-1 ]; // calculate solution (back substitution) @@ -270,6 +326,60 @@ namespace INTERP_KERNEL return true; } + + /*! + * \brief Solve system equation in matrix form using Gaussian elimination algorithm + * \param M - N x N+NB_OF_VARS matrix + * \param sol - vector of N solutions + * \retval bool - true if succeeded + */ + template + bool solveSystemOfEquations2(const double *matrix, double *solutions, double eps) + { + unsigned k,j; + int nr,n,m,np; + double s,g; + int mb; + // + double B[SZ*(SZ+NB_OF_RES)]; + std::copy(matrix,matrix+SZ*(SZ+NB_OF_RES),B); + // + nr=SZ+NB_OF_RES; + for(k=0;keps) + {/* Rows permutation */ + for(m=0;m(),s)); + for(j=0;j& n, const double* p, double* bc) + /*! + * Calculate barycentric coordinates of a point p with respect to triangle or tetra verices. + * This method makes 2 assumptions : + * - this is a simplex + * - spacedim == meshdim. For TRI3 and TRI6 spaceDim is expected to be equal to 2 and for TETRA4 spaceDim is expected to be equal to 3. + * If not the case (3D surf for example) a previous projection should be done before. + */ + inline void barycentric_coords(const std::vector& n, const double *p, double *bc) { enum { _X, _Y, _Z }; - if ( n.size() == 3 ) // TRIA3 + switch(n.size()) { - // matrix 2x2 - double - T11 = n[0][_X]-n[2][_X], T12 = n[1][_X]-n[2][_X], - T21 = n[0][_Y]-n[2][_Y], T22 = n[1][_Y]-n[2][_Y]; - // matrix determinant - double Tdet = T11*T22 - T12*T21; - if ( std::fabs( Tdet ) < std::numeric_limits::min() ) { - bc[0]=1; bc[1]=bc[2]=0; // no solution - return; + case 3: + { // TRIA3 + // matrix 2x2 + double + T11 = n[0][_X]-n[2][_X], T12 = n[1][_X]-n[2][_X], + T21 = n[0][_Y]-n[2][_Y], T22 = n[1][_Y]-n[2][_Y]; + // matrix determinant + double Tdet = T11*T22 - T12*T21; + if ( std::fabs( Tdet ) < std::numeric_limits::min() ) + { + bc[0]=1; bc[1]=bc[2]=0; // no solution + return; + } + // matrix inverse + double t11 = T22, t12 = -T12, t21 = -T21, t22 = T11; + // vector + double r11 = p[_X]-n[2][_X], r12 = p[_Y]-n[2][_Y]; + // barycentric coordinates: mutiply matrix by vector + bc[0] = (t11 * r11 + t12 * r12)/Tdet; + bc[1] = (t21 * r11 + t22 * r12)/Tdet; + bc[2] = 1. - bc[0] - bc[1]; + break; } - // matrix inverse - double t11 = T22, t12 = -T12, t21 = -T21, t22 = T11; - // vector - double r11 = p[_X]-n[2][_X], r12 = p[_Y]-n[2][_Y]; - // barycentric coordinates: mutiply matrix by vector - bc[0] = (t11 * r11 + t12 * r12)/Tdet; - bc[1] = (t21 * r11 + t22 * r12)/Tdet; - bc[2] = 1. - bc[0] - bc[1]; - } - else // TETRA4 - { - // Find bc by solving system of 3 equations using Gaussian elimination algorithm - // bc1*( x1 - x4 ) + bc2*( x2 - x4 ) + bc3*( x3 - x4 ) = px - x4 - // bc1*( y1 - y4 ) + bc2*( y2 - y4 ) + bc3*( y3 - y4 ) = px - y4 - // bc1*( z1 - z4 ) + bc2*( z2 - z4 ) + bc3*( z3 - z4 ) = px - z4 - - double T[3][4]= - {{ n[0][_X]-n[3][_X], n[1][_X]-n[3][_X], n[2][_X]-n[3][_X], p[_X]-n[3][_X] }, - { n[0][_Y]-n[3][_Y], n[1][_Y]-n[3][_Y], n[2][_Y]-n[3][_Y], p[_Y]-n[3][_Y] }, - { n[0][_Z]-n[3][_Z], n[1][_Z]-n[3][_Z], n[2][_Z]-n[3][_Z], p[_Z]-n[3][_Z] }}; - - if ( !solveSystemOfEquations<3>( T, bc )) - bc[0]=1., bc[1] = bc[2] = bc[3] = 0; - else - bc[ 3 ] = 1. - bc[0] - bc[1] - bc[2]; + case 4: + { // TETRA4 + // Find bc by solving system of 3 equations using Gaussian elimination algorithm + // bc1*( x1 - x4 ) + bc2*( x2 - x4 ) + bc3*( x3 - x4 ) = px - x4 + // bc1*( y1 - y4 ) + bc2*( y2 - y4 ) + bc3*( y3 - y4 ) = px - y4 + // bc1*( z1 - z4 ) + bc2*( z2 - z4 ) + bc3*( z3 - z4 ) = px - z4 + + double T[3][4]= + {{ n[0][_X]-n[3][_X], n[1][_X]-n[3][_X], n[2][_X]-n[3][_X], p[_X]-n[3][_X] }, + { n[0][_Y]-n[3][_Y], n[1][_Y]-n[3][_Y], n[2][_Y]-n[3][_Y], p[_Y]-n[3][_Y] }, + { n[0][_Z]-n[3][_Z], n[1][_Z]-n[3][_Z], n[2][_Z]-n[3][_Z], p[_Z]-n[3][_Z] }}; + + if ( !solveSystemOfEquations<3>( T, bc ) ) + bc[0]=1., bc[1] = bc[2] = bc[3] = 0; + else + bc[ 3 ] = 1. - bc[0] - bc[1] - bc[2]; + break; + } + case 6: + { + // TRIA6 + double matrix2[48]={1., 0., 0., 0., 0., 0., 0., 0., + 1., 0., 0., 0., 0., 0., 1., 0., + 1., 0., 0., 0., 0., 0., 0., 1., + 1., 0., 0., 0., 0., 0., 0.5, 0., + 1., 0., 0., 0., 0., 0., 0.5, 0.5, + 1., 0., 0., 0., 0., 0., 0.,0.5}; + for(int i=0;i<6;i++) + { + matrix2[8*i+1]=n[i][0]; + matrix2[8*i+2]=n[i][1]; + matrix2[8*i+3]=n[i][0]*n[i][0]; + matrix2[8*i+4]=n[i][0]*n[i][1]; + matrix2[8*i+5]=n[i][1]*n[i][1]; + } + double res[12]; + solveSystemOfEquations2<6,2>(matrix2,res,std::numeric_limits::min()); + double refCoo[2]; + refCoo[0]=computeTria6RefBase(res,p); + refCoo[1]=computeTria6RefBase(res+6,p); + computeWeightedCoeffsInTria6FromRefBase(refCoo,bc); + break; + } + case 10: + {//TETRA10 + double matrix2[130]={1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., + 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0., 0., + 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0., + 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., + 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.5, 0., 0., + 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.5, 0.5, 0., + 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,0.5, 0., + 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.5, + 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.5, 0., 0.5, + 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.5, 0.5}; + for(int i=0;i<10;i++) + { + matrix2[13*i+1]=n[i][0]; + matrix2[13*i+2]=n[i][1]; + matrix2[13*i+3]=n[i][2]; + matrix2[13*i+4]=n[i][0]*n[i][0]; + matrix2[13*i+5]=n[i][0]*n[i][1]; + matrix2[13*i+6]=n[i][0]*n[i][2]; + matrix2[13*i+7]=n[i][1]*n[i][1]; + matrix2[13*i+8]=n[i][1]*n[i][2]; + matrix2[13*i+9]=n[i][2]*n[i][2]; + } + double res[30]; + solveSystemOfEquations2<10,3>(matrix2,res,std::numeric_limits::min()); + double refCoo[3]; + refCoo[0]=computeTetra10RefBase(res,p); + refCoo[1]=computeTetra10RefBase(res+10,p); + refCoo[2]=computeTetra10RefBase(res+20,p); + computeWeightedCoeffsInTetra10FromRefBase(refCoo,bc); + break; + } + default: + throw INTERP_KERNEL::Exception("INTERP_KERNEL::barycentric_coords : unrecognized simplex !"); } } @@ -388,7 +566,7 @@ namespace INTERP_KERNEL } /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */ - /*fonction pour vérifier qu'un point n'a pas déja été considérer dans */ + /*fonction pour verifier qu'un point n'a pas deja ete considerer dans */ /* le vecteur et le rajouter au vecteur sinon. */ /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */ @@ -412,7 +590,7 @@ namespace INTERP_KERNEL /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */ /* fonction qui rajoute les sommet du triangle P dans le vecteur V */ - /* si ceux-ci sont compris dans le triangle S et ne sont pas déjà dans */ + /* si ceux-ci sont compris dans le triangle S et ne sont pas deja dans */ /* V. */ /*sommets de P: P_1, P_2, P_3 */ /*sommets de S: P_4, P_5, P_6 */ @@ -439,7 +617,7 @@ namespace INTERP_KERNEL /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _*/ /* calcul de l'intersection de deux segments: segments P1P2 avec P3P4 */ /* . Si l'intersection est non nulle et si celle-ci n'est */ - /* n'est pas déjà contenue dans Vect on la rajoute à Vect */ + /* n'est pas deja contenue dans Vect on la rajoute a Vect */ /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _*/ inline void inters_de_segment(const double * P_1,const double * P_2, @@ -447,7 +625,7 @@ namespace INTERP_KERNEL std::vector& Vect, double dim_caracteristic, double precision) { - // calcul du déterminant de P_1P_2 et P_3P_4. + // 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 absolute_precision = dim_caracteristic*precision; @@ -477,7 +655,7 @@ namespace INTERP_KERNEL /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _*/ /* calcul l'intersection de deux triangles */ /* P_1, P_2, P_3: sommets du premier triangle */ - /* P_4, P_5, P_6: sommets du deuxième triangle */ + /* P_4, P_5, P_6: sommets du deuxi�me triangle */ /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _*/ inline void intersec_de_triangle(const double* P_1,const double* P_2, const double* P_3, @@ -498,7 +676,7 @@ namespace INTERP_KERNEL } /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _*/ - /* fonction pour vérifier qu'un n°de maille n'a pas déja été considérer */ + /* fonction pour verifier qu'un node maille n'a pas deja ete considerer */ /* dans le vecteur et le rajouter au vecteur sinon. */ /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _*/ @@ -540,7 +718,7 @@ namespace INTERP_KERNEL /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */ - /* fonction pour reconstituer un polygone convexe à partir */ + /* fonction pour reconstituer un polygone convexe a partir */ /* d'un nuage de point. */ /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */ @@ -777,8 +955,8 @@ namespace INTERP_KERNEL /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _*/ /* calcul l'intersection de deux polygones COPLANAIRES */ - /* en dimension DIM (2 ou 3). Si DIM=3 l'algorithme ne considère*/ - /* que les deux premières coordonnées de chaque point */ + /* en dimension DIM (2 ou 3). Si DIM=3 l'algorithme ne considere*/ + /* que les deux premieres coordonnees de chaque point */ /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _*/ template inline void intersec_de_polygone(const double * Coords_A, const double * Coords_B, int nb_NodesA, int nb_NodesB, diff --git a/src/INTERP_KERNEL/Intersector3D.hxx b/src/INTERP_KERNEL/Intersector3D.hxx index 9be0b67df..59e70cb8b 100644 --- a/src/INTERP_KERNEL/Intersector3D.hxx +++ b/src/INTERP_KERNEL/Intersector3D.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __INTERSECTOR3D_HXX__ diff --git a/src/INTERP_KERNEL/Intersector3D.txx b/src/INTERP_KERNEL/Intersector3D.txx index 10199d178..ee9b36aee 100644 --- a/src/INTERP_KERNEL/Intersector3D.txx +++ b/src/INTERP_KERNEL/Intersector3D.txx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __INTERSECTOR3D_TXX__ #define __INTERSECTOR3D_TXX__ diff --git a/src/INTERP_KERNEL/Intersector3DP0P0.hxx b/src/INTERP_KERNEL/Intersector3DP0P0.hxx index c685f321b..a5fcfb6d9 100644 --- a/src/INTERP_KERNEL/Intersector3DP0P0.hxx +++ b/src/INTERP_KERNEL/Intersector3DP0P0.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __INTERSECTOR3DP0P0_HXX__ diff --git a/src/INTERP_KERNEL/Intersector3DP0P0.txx b/src/INTERP_KERNEL/Intersector3DP0P0.txx index 396cbafe8..90a52c067 100644 --- a/src/INTERP_KERNEL/Intersector3DP0P0.txx +++ b/src/INTERP_KERNEL/Intersector3DP0P0.txx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __INTERSECTOR3DP0P0_TXX__ #define __INTERSECTOR3DP0P0_TXX__ diff --git a/src/INTERP_KERNEL/Intersector3DP0P1.hxx b/src/INTERP_KERNEL/Intersector3DP0P1.hxx index 82138b69f..480d4d4eb 100644 --- a/src/INTERP_KERNEL/Intersector3DP0P1.hxx +++ b/src/INTERP_KERNEL/Intersector3DP0P1.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __INTERSECTOR3DP0P1_HXX__ diff --git a/src/INTERP_KERNEL/Intersector3DP0P1.txx b/src/INTERP_KERNEL/Intersector3DP0P1.txx index 0b8a07c8d..e0455f433 100644 --- a/src/INTERP_KERNEL/Intersector3DP0P1.txx +++ b/src/INTERP_KERNEL/Intersector3DP0P1.txx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __INTERSECTOR3DP0P1_TXX__ #define __INTERSECTOR3DP0P1_TXX__ diff --git a/src/INTERP_KERNEL/Intersector3DP1P0.hxx b/src/INTERP_KERNEL/Intersector3DP1P0.hxx index aa5489ee8..ef98a9cc2 100644 --- a/src/INTERP_KERNEL/Intersector3DP1P0.hxx +++ b/src/INTERP_KERNEL/Intersector3DP1P0.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __INTERSECTOR3DP1P0_HXX__ diff --git a/src/INTERP_KERNEL/Intersector3DP1P0.txx b/src/INTERP_KERNEL/Intersector3DP1P0.txx index b7492711d..9c53fc9f3 100644 --- a/src/INTERP_KERNEL/Intersector3DP1P0.txx +++ b/src/INTERP_KERNEL/Intersector3DP1P0.txx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __INTERSECTOR3DP1P0_TXX__ #define __INTERSECTOR3DP1P0_TXX__ diff --git a/src/INTERP_KERNEL/Intersector3DP1P0Bary.hxx b/src/INTERP_KERNEL/Intersector3DP1P0Bary.hxx index b47ba5ccd..52cafb685 100644 --- a/src/INTERP_KERNEL/Intersector3DP1P0Bary.hxx +++ b/src/INTERP_KERNEL/Intersector3DP1P0Bary.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __Intersector3DP1P0Bary_HXX__ diff --git a/src/INTERP_KERNEL/Intersector3DP1P0Bary.txx b/src/INTERP_KERNEL/Intersector3DP1P0Bary.txx index f0883fe3c..b4bd89d6f 100644 --- a/src/INTERP_KERNEL/Intersector3DP1P0Bary.txx +++ b/src/INTERP_KERNEL/Intersector3DP1P0Bary.txx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __Intersector3DP1P0Bary_TXX__ #define __Intersector3DP1P0Bary_TXX__ diff --git a/src/INTERP_KERNEL/Intersector3DP1P1.hxx b/src/INTERP_KERNEL/Intersector3DP1P1.hxx index a6961b7f2..e4d8b2ef2 100644 --- a/src/INTERP_KERNEL/Intersector3DP1P1.hxx +++ b/src/INTERP_KERNEL/Intersector3DP1P1.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __Intersector3DP1P1_HXX__ diff --git a/src/INTERP_KERNEL/Intersector3DP1P1.txx b/src/INTERP_KERNEL/Intersector3DP1P1.txx index c41a1d0d4..03dab3b81 100644 --- a/src/INTERP_KERNEL/Intersector3DP1P1.txx +++ b/src/INTERP_KERNEL/Intersector3DP1P1.txx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __Intersector3DP1P1_TXX__ #define __Intersector3DP1P1_TXX__ diff --git a/src/INTERP_KERNEL/IntersectorCU.hxx b/src/INTERP_KERNEL/IntersectorCU.hxx index 75c5d405e..9fe5b4a90 100644 --- a/src/INTERP_KERNEL/IntersectorCU.hxx +++ b/src/INTERP_KERNEL/IntersectorCU.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2009-2010 OPEN CASCADE +// Copyright (C) 2009-2011 OPEN CASCADE // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // File : IntersectorCU.hxx // Created : Thu Dec 17 12:30:17 2009 diff --git a/src/INTERP_KERNEL/IntersectorCU.txx b/src/INTERP_KERNEL/IntersectorCU.txx index f9a3155a4..432d45a7a 100644 --- a/src/INTERP_KERNEL/IntersectorCU.txx +++ b/src/INTERP_KERNEL/IntersectorCU.txx @@ -1,20 +1,20 @@ -// Copyright (C) 2009-2010 OPEN CASCADE +// Copyright (C) 2009-2011 OPEN CASCADE // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email :webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // File : IntersectorCU.txx // Created : Thu Dec 17 12:30:17 2009 diff --git a/src/INTERP_KERNEL/IntersectorCU1D.hxx b/src/INTERP_KERNEL/IntersectorCU1D.hxx index 0da006bcb..2caafbb0c 100644 --- a/src/INTERP_KERNEL/IntersectorCU1D.hxx +++ b/src/INTERP_KERNEL/IntersectorCU1D.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2009-2010 OPEN CASCADE +// Copyright (C) 2009-2011 OPEN CASCADE // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // File : IntersectorCU1D.hxx diff --git a/src/INTERP_KERNEL/IntersectorCU1D.txx b/src/INTERP_KERNEL/IntersectorCU1D.txx index 1eff67400..056581c02 100644 --- a/src/INTERP_KERNEL/IntersectorCU1D.txx +++ b/src/INTERP_KERNEL/IntersectorCU1D.txx @@ -1,20 +1,20 @@ -// Copyright (C) 2009-2010 OPEN CASCADE +// Copyright (C) 2009-2011 OPEN CASCADE // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // File : IntersectorCU1D.txx // Created : Thu Dec 17 14:17:49 2009 diff --git a/src/INTERP_KERNEL/IntersectorCU2D.hxx b/src/INTERP_KERNEL/IntersectorCU2D.hxx index b6f335c2a..aa4a88d22 100644 --- a/src/INTERP_KERNEL/IntersectorCU2D.hxx +++ b/src/INTERP_KERNEL/IntersectorCU2D.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2009-2010 OPEN CASCADE +// Copyright (C) 2009-2011 OPEN CASCADE // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // File : IntersectorCU2D.hxx diff --git a/src/INTERP_KERNEL/IntersectorCU2D.txx b/src/INTERP_KERNEL/IntersectorCU2D.txx index e6174d823..b1b30d0fc 100644 --- a/src/INTERP_KERNEL/IntersectorCU2D.txx +++ b/src/INTERP_KERNEL/IntersectorCU2D.txx @@ -1,20 +1,20 @@ -// Copyright (C) 2009-2010 OPEN CASCADE +// Copyright (C) 2009-2011 OPEN CASCADE // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // File : IntersectorCU2D.txx // Created : Thu Dec 17 14:17:49 2009 @@ -60,7 +60,7 @@ namespace INTERP_KERNEL getUCoordinates( icellT, uCoords ); NormalizedCellType tT = INTER_CU::_meshU.getTypeOfElement( _TMIU(icellT)); - bool is_tgt_quad = CellModel::getCellModel(tT).isQuadratic(); + bool is_tgt_quad = CellModel::GetCellModel(tT).isQuadratic(); double quad[8] = { INTER_CU::_coordsC[0][icellS[0]], INTER_CU::_coordsC[1][icellS[1]], INTER_CU::_coordsC[0][icellS[0]+1], INTER_CU::_coordsC[1][icellS[1]], diff --git a/src/INTERP_KERNEL/IntersectorCU3D.hxx b/src/INTERP_KERNEL/IntersectorCU3D.hxx index c74565220..a011d111f 100644 --- a/src/INTERP_KERNEL/IntersectorCU3D.hxx +++ b/src/INTERP_KERNEL/IntersectorCU3D.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2009-2010 OPEN CASCADE +// Copyright (C) 2009-2011 OPEN CASCADE // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // File : IntersectorCU3D.hxx diff --git a/src/INTERP_KERNEL/IntersectorCU3D.txx b/src/INTERP_KERNEL/IntersectorCU3D.txx index 6a94f91a9..c08e751cb 100644 --- a/src/INTERP_KERNEL/IntersectorCU3D.txx +++ b/src/INTERP_KERNEL/IntersectorCU3D.txx @@ -1,20 +1,20 @@ -// Copyright (C) 2009-2010 OPEN CASCADE +// Copyright (C) 2009-2011 OPEN CASCADE // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // File : IntersectorCU3D.txx // Created : Thu Dec 17 14:17:49 2009 diff --git a/src/INTERP_KERNEL/Log.hxx b/src/INTERP_KERNEL/Log.hxx index b086c743e..f6abeda2c 100644 --- a/src/INTERP_KERNEL/Log.hxx +++ b/src/INTERP_KERNEL/Log.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef _LOG_H_ diff --git a/src/INTERP_KERNEL/Makefile.am b/src/INTERP_KERNEL/Makefile.am index e3dfc56cb..1a7fb539e 100644 --- a/src/INTERP_KERNEL/Makefile.am +++ b/src/INTERP_KERNEL/Makefile.am @@ -1,20 +1,20 @@ -# Copyright (C) 2007-2010 CEA/DEN, EDF R&D +# Copyright (C) 2007-2011 CEA/DEN, EDF R&D # -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. # -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. # -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # # MED files in memory @@ -24,9 +24,9 @@ # include $(top_srcdir)/adm_local/unix/make_common_starter.am -SUBDIRS = Bases Geometric2D ExprEval . +SUBDIRS = Bases Geometric2D ExprEval GaussPoints . -DIST_SUBDIRS = Bases Geometric2D ExprEval +DIST_SUBDIRS = Bases Geometric2D ExprEval GaussPoints lib_LTLIBRARIES = libinterpkernel.la @@ -44,6 +44,7 @@ PointLocator2DIntersector.txx \ INTERPKERNELDefines.hxx \ InterpKernelMatrix.hxx \ InterpKernelMeshQuality.hxx \ +InterpKernelCellSimplify.hxx \ Interpolation.hxx \ Interpolation.txx \ Interpolation2D.hxx \ @@ -51,7 +52,6 @@ Interpolation2D.txx \ Interpolation3D.hxx \ Interpolation3D.txx \ Interpolation3DSurf.hxx \ -Interpolation3DSurf.txx \ InterpolationOptions.hxx \ InterpolationPlanar.hxx \ InterpolationPlanar.txx \ @@ -158,7 +158,6 @@ CurveIntersectorP1P1.txx \ Interpolation1D.hxx \ Interpolation1D.txx \ Interpolation2DCurve.hxx \ -Interpolation2DCurve.txx \ InterpolationCurve.hxx \ InterpolationCurve.txx \ DirectedBoundingBox.hxx @@ -189,14 +188,20 @@ dist_libinterpkernel_la_SOURCES = \ UnitTetraIntersectionBary.cxx \ InterpolationOptions.cxx \ DirectedBoundingBox.cxx \ - InterpKernelMeshQuality.cxx + Interpolation2DCurve.cxx \ + Interpolation3DSurf.cxx \ + Interpolation3D.cxx \ + MeshElement.cxx \ + InterpKernelMeshQuality.cxx \ + InterpKernelCellSimplify.cxx libinterpkernel_la_CPPFLAGS=-I$(srcdir)/Geometric2D -I$(srcdir)/Bases libinterpkernel_la_LDFLAGS= # the geom2D library is included in the interpkernel one -libinterpkernel_la_LIBADD= ./Geometric2D/libInterpGeometric2DAlg.la Bases/libinterpkernelbases.la ExprEval/libinterpkernelexpreval.la +libinterpkernel_la_LIBADD= ./Geometric2D/libInterpGeometric2DAlg.la Bases/libinterpkernelbases.la ExprEval/libinterpkernelexpreval.la \ + GaussPoints/libinterpkernelgauss.la AM_CPPFLAGS += $(libinterpkernel_la_CPPFLAGS) LDADD= $(libinterpkernel_la_LDFLAGS) diff --git a/src/INTERP_KERNEL/MeshElement.hxx b/src/INTERP_KERNEL/MeshElement.hxx index 76d2f3e23..4068324be 100644 --- a/src/INTERP_KERNEL/MeshElement.hxx +++ b/src/INTERP_KERNEL/MeshElement.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __MESHELEMENT_HXX__ diff --git a/src/INTERP_KERNEL/MeshElement.txx b/src/INTERP_KERNEL/MeshElement.txx index ed9bc6536..800ebcdaa 100644 --- a/src/INTERP_KERNEL/MeshElement.txx +++ b/src/INTERP_KERNEL/MeshElement.txx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __MESHELEMENT_TXX__ #define __MESHELEMENT_TXX__ @@ -66,15 +66,6 @@ namespace INTERP_KERNEL ///////////////////////////////////////////////////////////////////// /// ElementBBoxOrder ///////////// ///////////////////////////////////////////////////////////////////// - /** - * Constructor - * - * @param coord BoundingBox coordinate (XMIN, XMAX, etc) on which to base the ordering - */ - ElementBBoxOrder::ElementBBoxOrder(BoundingBox::BoxCoord coord) - : _coord(coord) - { - } /** * Comparison operator based on the bounding boxes of the elements diff --git a/src/INTERP_KERNEL/MeshRegion.hxx b/src/INTERP_KERNEL/MeshRegion.hxx index 4ab573e4a..7ce43f5da 100644 --- a/src/INTERP_KERNEL/MeshRegion.hxx +++ b/src/INTERP_KERNEL/MeshRegion.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __MESHREGION_HXX__ diff --git a/src/INTERP_KERNEL/MeshRegion.txx b/src/INTERP_KERNEL/MeshRegion.txx index a47c3017c..cf213672c 100644 --- a/src/INTERP_KERNEL/MeshRegion.txx +++ b/src/INTERP_KERNEL/MeshRegion.txx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __MESHREGION_TXX__ #define __MESHREGION_TXX__ diff --git a/src/INTERP_KERNEL/MeshUtils.hxx b/src/INTERP_KERNEL/MeshUtils.hxx index d55b5d5de..4291799dd 100644 --- a/src/INTERP_KERNEL/MeshUtils.hxx +++ b/src/INTERP_KERNEL/MeshUtils.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __MESHUTILS_HXX__ diff --git a/src/INTERP_KERNEL/PlanarIntersector.hxx b/src/INTERP_KERNEL/PlanarIntersector.hxx index 62c970f87..12a3455ad 100644 --- a/src/INTERP_KERNEL/PlanarIntersector.hxx +++ b/src/INTERP_KERNEL/PlanarIntersector.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __PLANARINTERSECTOR_HXX__ diff --git a/src/INTERP_KERNEL/PlanarIntersector.txx b/src/INTERP_KERNEL/PlanarIntersector.txx index b7d381397..bdb10f9ac 100644 --- a/src/INTERP_KERNEL/PlanarIntersector.txx +++ b/src/INTERP_KERNEL/PlanarIntersector.txx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __PLANARINTERSECTOR_TXX__ #define __PLANARINTERSECTOR_TXX__ @@ -384,7 +384,7 @@ namespace INTERP_KERNEL } else { - std::cout << " Maille dégénérée " << "epsilon = " << epsilon << std::endl; + std::cout << " Degenerated cell " << "epsilon = " << epsilon << std::endl; std::cout << " i_A1= " << i_A1 << " i_A2= " << i_A2 << std::endl; std::cout << " distance2(Coords_A,&Coords_A[i_A1])= " << distance2(Coords_A,&Coords_A[i_A1]) << std::endl; std::cout << "abs(normal_A) = " << fabs(normal_A[0]) << " ; " <::projectionThis(&sourceCellCoordsTmp[0],quadrangle,sourceCellCoords.size()/SPACEDIM,4); NormalizedCellType tS=PlanarIntersector::_meshS.getTypeOfElement(OTT::indFC(iS)); - double surf=orientation*intersectGeometryWithQuadrangle(quadrangle,sourceCellCoordsTmp,CellModel::getCellModel(tS).isQuadratic()); + double surf=orientation*intersectGeometryWithQuadrangle(quadrangle,sourceCellCoordsTmp,CellModel::GetCellModel(tS).isQuadratic()); surf=PlanarIntersector::getValueRegardingOption(surf); if(surf!=0.) { diff --git a/src/INTERP_KERNEL/PlanarIntersectorP0P1PL.hxx b/src/INTERP_KERNEL/PlanarIntersectorP0P1PL.hxx index 8426e7e6e..7e082f998 100644 --- a/src/INTERP_KERNEL/PlanarIntersectorP0P1PL.hxx +++ b/src/INTERP_KERNEL/PlanarIntersectorP0P1PL.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __PLANARINTERSECTORP0P1PL_HXX__ diff --git a/src/INTERP_KERNEL/PlanarIntersectorP0P1PL.txx b/src/INTERP_KERNEL/PlanarIntersectorP0P1PL.txx index 29dba1bb9..8678f85c7 100644 --- a/src/INTERP_KERNEL/PlanarIntersectorP0P1PL.txx +++ b/src/INTERP_KERNEL/PlanarIntersectorP0P1PL.txx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __PLANARINTERSECTORP0P1PL_TXX__ #define __PLANARINTERSECTORP0P1PL_TXX__ diff --git a/src/INTERP_KERNEL/PlanarIntersectorP1P0.hxx b/src/INTERP_KERNEL/PlanarIntersectorP1P0.hxx index 02fe06137..7779a56dc 100644 --- a/src/INTERP_KERNEL/PlanarIntersectorP1P0.hxx +++ b/src/INTERP_KERNEL/PlanarIntersectorP1P0.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __PLANARINTERSECTORP1P0_HXX__ diff --git a/src/INTERP_KERNEL/PlanarIntersectorP1P0.txx b/src/INTERP_KERNEL/PlanarIntersectorP1P0.txx index 3bc961fa6..5cd13a692 100644 --- a/src/INTERP_KERNEL/PlanarIntersectorP1P0.txx +++ b/src/INTERP_KERNEL/PlanarIntersectorP1P0.txx @@ -1,20 +1,21 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// See http://www.salome-platform.org/ or email :webmaster.salome@opencascade.com #ifndef __PLANARINTERSECTORP1P0_TXX__ #define __PLANARINTERSECTORP1P0_TXX__ @@ -55,7 +56,7 @@ namespace INTERP_KERNEL int orientation=1; PlanarIntersector::getRealTargetCoordinates(OTT::indFC(icellT),targetCellCoords); NormalizedCellType tT=PlanarIntersector::_meshT.getTypeOfElement(OTT::indFC(icellT)); - bool isTargetQuad=CellModel::getCellModel(tT).isQuadratic(); + bool isTargetQuad=CellModel::GetCellModel(tT).isQuadratic(); typename MyMatrix::value_type& resRow=res[icellT]; for(typename std::vector::const_iterator iter=icellsS.begin();iter!=icellsS.end();iter++) { diff --git a/src/INTERP_KERNEL/PlanarIntersectorP1P0Bary.hxx b/src/INTERP_KERNEL/PlanarIntersectorP1P0Bary.hxx index d58cffc9c..ea92461bf 100644 --- a/src/INTERP_KERNEL/PlanarIntersectorP1P0Bary.hxx +++ b/src/INTERP_KERNEL/PlanarIntersectorP1P0Bary.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __PlanarIntersectorP1P0Bary_HXX__ diff --git a/src/INTERP_KERNEL/PlanarIntersectorP1P0Bary.txx b/src/INTERP_KERNEL/PlanarIntersectorP1P0Bary.txx index dd59b8c42..58c82c6ac 100644 --- a/src/INTERP_KERNEL/PlanarIntersectorP1P0Bary.txx +++ b/src/INTERP_KERNEL/PlanarIntersectorP1P0Bary.txx @@ -1,20 +1,21 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// See http://www.salome-platform.org/ or email :webmaster.salome@opencascade.com #ifndef __PlanarIntersectorP1P0Bary_TXX__ #define __PlanarIntersectorP1P0Bary_TXX__ @@ -76,7 +77,7 @@ namespace INTERP_KERNEL std::vector * tgtCoords = & tgtCellCoords; int tgtNbNodes = tgtCellCoords.size()/SPACEDIM; NormalizedCellType tT=PlanarIntersector::_meshT.getTypeOfElement(OTT::indFC(icellT)); - bool isTargetQuad=CellModel::getCellModel(tT).isQuadratic(); + bool isTargetQuad=CellModel::GetCellModel(tT).isQuadratic(); typename MyMatrix::value_type& resRow=res[icellT]; diff --git a/src/INTERP_KERNEL/PlanarIntersectorP1P0PL.hxx b/src/INTERP_KERNEL/PlanarIntersectorP1P0PL.hxx index 31fda104a..91793a29a 100644 --- a/src/INTERP_KERNEL/PlanarIntersectorP1P0PL.hxx +++ b/src/INTERP_KERNEL/PlanarIntersectorP1P0PL.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __PLANARINTERSECTORP1P0PL_HXX__ diff --git a/src/INTERP_KERNEL/PlanarIntersectorP1P0PL.txx b/src/INTERP_KERNEL/PlanarIntersectorP1P0PL.txx index 4973f93d1..0d40ef83e 100644 --- a/src/INTERP_KERNEL/PlanarIntersectorP1P0PL.txx +++ b/src/INTERP_KERNEL/PlanarIntersectorP1P0PL.txx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __PLANARINTERSECTORP1P0PL_TXX__ #define __PLANARINTERSECTORP1P0PL_TXX__ @@ -60,7 +60,7 @@ namespace INTERP_KERNEL else { double littleTargetCell[9]; - std::copy(baryT,baryT+3,littleTargetCell); + std::copy(baryT,baryT+SPACEDIM,littleTargetCell); std::copy(CoordsT.begin(),CoordsT.begin()+3,littleTargetCell+3); std::copy(CoordsT.begin()+3,CoordsT.begin()+6,littleTargetCell+6); PlanarIntersector::projectionThis(&CoordsS[0],littleTargetCell,3,3); diff --git a/src/INTERP_KERNEL/PlanarIntersectorP1P1.hxx b/src/INTERP_KERNEL/PlanarIntersectorP1P1.hxx index 4278bb39a..f4639c928 100644 --- a/src/INTERP_KERNEL/PlanarIntersectorP1P1.hxx +++ b/src/INTERP_KERNEL/PlanarIntersectorP1P1.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __PLANARINTERSECTORP1P1_HXX__ diff --git a/src/INTERP_KERNEL/PlanarIntersectorP1P1.txx b/src/INTERP_KERNEL/PlanarIntersectorP1P1.txx index dcd85a694..8284e5945 100644 --- a/src/INTERP_KERNEL/PlanarIntersectorP1P1.txx +++ b/src/INTERP_KERNEL/PlanarIntersectorP1P1.txx @@ -1,20 +1,21 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// See http://www.salome-platform.org/ or email :webmaster.salome@opencascade.com #ifndef __PLANARINTERSECTORP1P1_TXX__ #define __PLANARINTERSECTORP1P1_TXX__ diff --git a/src/INTERP_KERNEL/PlanarIntersectorP1P1PL.hxx b/src/INTERP_KERNEL/PlanarIntersectorP1P1PL.hxx index a93b16bfa..fd899c290 100644 --- a/src/INTERP_KERNEL/PlanarIntersectorP1P1PL.hxx +++ b/src/INTERP_KERNEL/PlanarIntersectorP1P1PL.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __PLANARINTERSECTORP1P1PL_HXX__ diff --git a/src/INTERP_KERNEL/PlanarIntersectorP1P1PL.txx b/src/INTERP_KERNEL/PlanarIntersectorP1P1PL.txx index 76eaaab10..70d2fd311 100644 --- a/src/INTERP_KERNEL/PlanarIntersectorP1P1PL.txx +++ b/src/INTERP_KERNEL/PlanarIntersectorP1P1PL.txx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __PLANARINTERSECTORP1P1PL_TXX__ #define __PLANARINTERSECTORP1P1PL_TXX__ diff --git a/src/INTERP_KERNEL/PointLocator2DIntersector.hxx b/src/INTERP_KERNEL/PointLocator2DIntersector.hxx index 6ee193353..66197f137 100644 --- a/src/INTERP_KERNEL/PointLocator2DIntersector.hxx +++ b/src/INTERP_KERNEL/PointLocator2DIntersector.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __POINTLOCATORINTERSECTOR_HXX__ diff --git a/src/INTERP_KERNEL/PointLocator2DIntersector.txx b/src/INTERP_KERNEL/PointLocator2DIntersector.txx index f6a329047..1af497b71 100644 --- a/src/INTERP_KERNEL/PointLocator2DIntersector.txx +++ b/src/INTERP_KERNEL/PointLocator2DIntersector.txx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __POINTLOCATORINTERSECTOR_TXX__ #define __POINTLOCATORINTERSECTOR_TXX__ @@ -128,7 +128,7 @@ namespace INTERP_KERNEL std::vector nodes(nbNodes); for(int i=0;i nodes(nbOfPoints); for(int i=0;i::_coordsT+OTT::coo2C(startOfCellNodeConn[i])*SPACEDIM); - if(CellModel::getCellModel(type).isQuadratic()) + if(CellModel::GetCellModel(type).isQuadratic()) return QuadraticPolygon::buildLinearPolygon(nodes); else return QuadraticPolygon::buildArcCirclePolygon(nodes); diff --git a/src/INTERP_KERNEL/PointLocator3DIntersectorP0P0.hxx b/src/INTERP_KERNEL/PointLocator3DIntersectorP0P0.hxx index 7c9df49ed..9ba8bacc3 100644 --- a/src/INTERP_KERNEL/PointLocator3DIntersectorP0P0.hxx +++ b/src/INTERP_KERNEL/PointLocator3DIntersectorP0P0.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __POINTLOCATOR3DINTERSECTORP0P0_HXX__ diff --git a/src/INTERP_KERNEL/PointLocator3DIntersectorP0P0.txx b/src/INTERP_KERNEL/PointLocator3DIntersectorP0P0.txx index b88c0b468..7b74aabb8 100644 --- a/src/INTERP_KERNEL/PointLocator3DIntersectorP0P0.txx +++ b/src/INTERP_KERNEL/PointLocator3DIntersectorP0P0.txx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __POINTLOCATOR3DINTERSECTORP0P0_TXX__ #define __POINTLOCATOR3DINTERSECTORP0P0_TXX__ @@ -63,7 +63,7 @@ namespace INTERP_KERNEL for(typename std::vector::const_iterator iterCellS=srcCells.begin();iterCellS!=srcCells.end();iterCellS++) { NormalizedCellType tS=Intersector3DP0P0::_src_mesh.getTypeOfElement(OTT::indFC(*iterCellS)); - const CellModel& cmTypeS=CellModel::getCellModel(tS); + const CellModel& cmTypeS=CellModel::GetCellModel(tS); std::vector connOfCurCellS; Intersector3DP0P0::getConnOfSourceCell(OTT::indFC(*iterCellS),connOfCurCellS); if(PointLocatorAlgos::isElementContainsPointAlg3D(bary,&connOfCurCellS[0],connOfCurCellS.size(),coordsS,cmTypeS,_precision)) diff --git a/src/INTERP_KERNEL/PointLocator3DIntersectorP0P1.hxx b/src/INTERP_KERNEL/PointLocator3DIntersectorP0P1.hxx index 9b8c986b1..e2f2edef6 100644 --- a/src/INTERP_KERNEL/PointLocator3DIntersectorP0P1.hxx +++ b/src/INTERP_KERNEL/PointLocator3DIntersectorP0P1.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __POINTLOCATOR3DINTERSECTORP0P1_HXX__ diff --git a/src/INTERP_KERNEL/PointLocator3DIntersectorP0P1.txx b/src/INTERP_KERNEL/PointLocator3DIntersectorP0P1.txx index 1f84569d3..399974864 100644 --- a/src/INTERP_KERNEL/PointLocator3DIntersectorP0P1.txx +++ b/src/INTERP_KERNEL/PointLocator3DIntersectorP0P1.txx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __POINTLOCATOR3DINTERSECTORP0P1_TXX__ #define __POINTLOCATOR3DINTERSECTORP0P1_TXX__ @@ -59,7 +59,7 @@ namespace INTERP_KERNEL for(typename std::vector::const_iterator iterCellS=srcCells.begin();iterCellS!=srcCells.end();iterCellS++) { NormalizedCellType tS=Intersector3DP0P1::_src_mesh.getTypeOfElement(OTT::indFC(*iterCellS)); - const CellModel& cmTypeS=CellModel::getCellModel(tS); + const CellModel& cmTypeS=CellModel::GetCellModel(tS); std::vector connOfCurCellS; Intersector3DP0P1::getConnOfSourceCell(OTT::indFC(*iterCellS),connOfCurCellS); for(int nodeIdT=0;nodeIdT::_src_mesh.getTypeOfElement(OTT::indFC(*iterCellS)); if(tS!=NORM_TETRA4) throw INTERP_KERNEL::Exception("Invalid source cell detected for meshdim==3. Only TETRA4 supported !"); - const CellModel& cmTypeS=CellModel::getCellModel(tS); + const CellModel& cmTypeS=CellModel::GetCellModel(tS); std::vector connOfCurCellS; Intersector3DP1P0::getConnOfSourceCell(OTT::indFC(*iterCellS),connOfCurCellS); if( PointLocatorAlgos::isElementContainsPointAlg3D(baryT,&connOfCurCellS[0],connOfCurCellS.size(),coordsS,cmTypeS,_precision) ) diff --git a/src/INTERP_KERNEL/PointLocator3DIntersectorP1P1.hxx b/src/INTERP_KERNEL/PointLocator3DIntersectorP1P1.hxx index 402124fa4..4b1b2d31d 100644 --- a/src/INTERP_KERNEL/PointLocator3DIntersectorP1P1.hxx +++ b/src/INTERP_KERNEL/PointLocator3DIntersectorP1P1.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __POINTLOCATOR3DINTERSECTORP1P1_HXX__ diff --git a/src/INTERP_KERNEL/PointLocator3DIntersectorP1P1.txx b/src/INTERP_KERNEL/PointLocator3DIntersectorP1P1.txx index 78bbb7655..620088815 100644 --- a/src/INTERP_KERNEL/PointLocator3DIntersectorP1P1.txx +++ b/src/INTERP_KERNEL/PointLocator3DIntersectorP1P1.txx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __POINTLOCATOR3DINTERSECTORP1P1_TXX__ #define __POINTLOCATOR3DINTERSECTORP1P1_TXX__ @@ -60,7 +60,7 @@ namespace INTERP_KERNEL NormalizedCellType tS=Intersector3DP1P1::_src_mesh.getTypeOfElement(OTT::indFC(*iterCellS)); if(tS!=NORM_TETRA4) throw INTERP_KERNEL::Exception("Invalid source cell detected for meshdim==3. Only TETRA4 supported !"); - const CellModel& cmTypeS=CellModel::getCellModel(tS); + const CellModel& cmTypeS=CellModel::GetCellModel(tS); const ConnType *startOfCellNodeConnT=Intersector3DP1P1::getStartConnOfTargetCell(targetCell); for(int nodeIdT=0;nodeIdT +#include #include namespace INTERP_KERNEL @@ -167,7 +168,7 @@ namespace INTERP_KERNEL typedef typename MyMeshType::MyConnType ConnType; const NumberingPolicy numPol=MyMeshType::My_numPol; - const CellModel& cmType=CellModel::getCellModel(type); + const CellModel& cmType=CellModel::GetCellModel(type); // if (SPACEDIM==2) { @@ -187,6 +188,7 @@ namespace INTERP_KERNEL { return isElementContainsPointAlg3D(ptToTest,conn_elem,conn_elem_sz,coords,cmType,eps); } + throw INTERP_KERNEL::Exception("Invalid spacedim detected ! Managed spaceDim are 2 and 3 !"); } bool elementContainsPoint(typename MyMeshType::MyConnType i, const double* x, double eps) @@ -217,6 +219,98 @@ namespace INTERP_KERNEL return (min_sign!=-1 || max_sign!=1); } }; + + template + class PointLocatorInSimplex : public PointLocatorAlgos + { + const MyMeshType& _mesh; + public: + PointLocatorInSimplex(const MyMeshType& mesh) + :PointLocatorAlgos(mesh),_mesh(mesh) + { + } + + //================================================================================ + /*! + * \brief Returns nodes composing the simplex the point x is in + */ + //================================================================================ + + virtual std::list locates(const double* x, double eps) + { + typedef typename MyMeshType::MyConnType ConnType; + const NumberingPolicy numPol=MyMeshType::My_numPol; + + std::list simplexNodes; + std::list candidates = PointLocatorAlgos::locates(x,eps); + std::list::iterator eIt = candidates.begin(); + for ( ; eIt != candidates.end(); ++eIt ) + { + const int i = OTT::ind2C( *eIt ); + const double* coords= _mesh.getCoordinatesPtr(); + const ConnType* conn=_mesh.getConnectivityPtr(); + const ConnType* conn_index= _mesh.getConnectivityIndexPtr(); + const ConnType* conn_elem=conn+OTT::ind2C(conn_index[i]); + int conn_elem_sz=conn_index[i+1]-conn_index[i]; + NormalizedCellType type=_mesh.getTypeOfElement(OTT::indFC(i)); + CellModel cell = CellModel::GetCellModel(type); + + if ( cell.isQuadratic() ) + throw Exception("P2 not implemented yet"); + + if ( cell.isSimplex()) + { + for ( int n = 0; n < conn_elem_sz; ++n ) + simplexNodes.push_back( conn_elem[ n ]); + } + else + { + NormalizedCellType simlexType = cell.getDimension()==3 ? NORM_TETRA4 : NORM_TRI3; + std::vector sonNodes; + NormalizedCellType sonType; + const unsigned nbSons = cell.getNumberOfSons2( conn_elem, conn_elem_sz ); + for ( unsigned s = 0; s < nbSons; ++s ) + { + sonNodes.resize( cell.getNumberOfNodesConstituentTheSon2( s, conn_elem, conn_elem_sz )); + cell.fillSonCellNodalConnectivity2( s, conn_elem, conn_elem_sz, &sonNodes[0], sonType ); + std::set sonNodesSet( sonNodes.begin(), sonNodes.end() ); + + std::set< std::set< ConnType > > checkedSonSimplex; + for ( unsigned sn = 0; sn < sonNodes.size(); ++sn ) + { + std::vector< ConnType > simplexConn( cell.getDimension() + 1 ); + unsigned n; + for ( n = 0; n < cell.getDimension()-1; ++n ) + simplexConn[n] = sonNodes[ (sn+n) % sonNodes.size() ]; + + for ( unsigned n2 = 0; n2 < sonNodes.size()-cell.getDimension()+1; ++n2 ) + { + simplexConn[n] = sonNodes[ (sn+n+n2) % sonNodes.size() ]; + std::set< ConnType > sonSimplex( simplexConn.begin(), --simplexConn.end()); + if ( checkedSonSimplex.insert( sonSimplex ).second ) + { + for ( unsigned cn = 0; cn < conn_elem_sz; ++cn ) + if ( !sonNodesSet.count( conn_elem[cn] )) + { + simplexConn.back() = conn_elem[cn]; + if ( isElementContainsPoint( x, simlexType, coords, + &simplexConn[0], simplexConn.size(), eps )) + { + simplexNodes.insert( simplexNodes.end(), + simplexConn.begin(), simplexConn.end()); + return simplexNodes; + } + } + } + } + } + } + } + } + return simplexNodes; + } + + }; } #endif diff --git a/src/INTERP_KERNEL/PolygonAlgorithms.hxx b/src/INTERP_KERNEL/PolygonAlgorithms.hxx index 05bfc42f6..d09ba1755 100644 --- a/src/INTERP_KERNEL/PolygonAlgorithms.hxx +++ b/src/INTERP_KERNEL/PolygonAlgorithms.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __POLYGONALGORITHMS_HXX__ diff --git a/src/INTERP_KERNEL/PolygonAlgorithms.txx b/src/INTERP_KERNEL/PolygonAlgorithms.txx index 099212992..d7aee3976 100644 --- a/src/INTERP_KERNEL/PolygonAlgorithms.txx +++ b/src/INTERP_KERNEL/PolygonAlgorithms.txx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __POLYGONALGORITHMS_TXX__ #define __POLYGONALGORITHMS_TXX__ @@ -78,17 +78,17 @@ namespace INTERP_KERNEL if(fabs(det) > _epsilon) { inv_det = 1/det; - t1=(AC[1]*DC[2]-AC[2]*DC[1])*inv_det; - t2=(AB[1]*AC[2]-AB[2]*AC[1])*inv_det; + t1=(AC[1]*DC[DIM-1]-AC[DIM-1]*DC[1])*inv_det; + t2=(AB[1]*AC[DIM-1]-AB[DIM-1]*AC[1])*inv_det; } else //beware AB and CD may belong to a plane y = constant { - det = AB[0]*DC[2]-AB[2]*DC[0]; + det = AB[0]*DC[DIM-1]-AB[DIM-1]*DC[0]; if(fabs(det) > _epsilon) { inv_det = 1/det; - t1=(AC[0]*DC[2]-AC[2]*DC[0])*inv_det; - t2=(AB[0]*AC[2]-AB[2]*AC[0])*inv_det; + t1=(AC[0]*DC[DIM-1]-AC[DIM-1]*DC[0])*inv_det; + t2=(AB[0]*AC[DIM-1]-AB[DIM-1]*AC[0])*inv_det; } else { diff --git a/src/INTERP_KERNEL/PolyhedronIntersectorP0P0.hxx b/src/INTERP_KERNEL/PolyhedronIntersectorP0P0.hxx index 30d3b2af7..828c61dad 100644 --- a/src/INTERP_KERNEL/PolyhedronIntersectorP0P0.hxx +++ b/src/INTERP_KERNEL/PolyhedronIntersectorP0P0.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __POLYHEDRONINTERSECTORP0P0_HXX__ @@ -43,7 +43,7 @@ namespace INTERP_KERNEL static const NumberingPolicy numPol=MyMeshType::My_numPol; public: - PolyhedronIntersectorP0P0(const MyMeshType& targetMesh, const MyMeshType& srcMesh, SplittingPolicy policy = GENERAL_24); + PolyhedronIntersectorP0P0(const MyMeshType& targetMesh, const MyMeshType& srcMesh, SplittingPolicy policy = PLANAR_FACE_5); ~PolyhedronIntersectorP0P0(); diff --git a/src/INTERP_KERNEL/PolyhedronIntersectorP0P0.txx b/src/INTERP_KERNEL/PolyhedronIntersectorP0P0.txx index 1fde5d1ae..260a4c110 100644 --- a/src/INTERP_KERNEL/PolyhedronIntersectorP0P0.txx +++ b/src/INTERP_KERNEL/PolyhedronIntersectorP0P0.txx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __POLYHEDRONINTERSECTORP0P0_TXX__ #define __POLYHEDRONINTERSECTORP0P0_TXX__ diff --git a/src/INTERP_KERNEL/PolyhedronIntersectorP0P1.hxx b/src/INTERP_KERNEL/PolyhedronIntersectorP0P1.hxx index 194449d90..a6bd815d0 100644 --- a/src/INTERP_KERNEL/PolyhedronIntersectorP0P1.hxx +++ b/src/INTERP_KERNEL/PolyhedronIntersectorP0P1.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __POLYHEDRONINTERSECTORP0P1_HXX__ @@ -43,7 +43,7 @@ namespace INTERP_KERNEL static const NumberingPolicy numPol=MyMeshType::My_numPol; public: - PolyhedronIntersectorP0P1(const MyMeshType& targetMesh, const MyMeshType& srcMesh, SplittingPolicy policy = GENERAL_24); + PolyhedronIntersectorP0P1(const MyMeshType& targetMesh, const MyMeshType& srcMesh, SplittingPolicy policy = PLANAR_FACE_5); ~PolyhedronIntersectorP0P1(); diff --git a/src/INTERP_KERNEL/PolyhedronIntersectorP0P1.txx b/src/INTERP_KERNEL/PolyhedronIntersectorP0P1.txx index 41f8bde6c..4dbf72dc9 100644 --- a/src/INTERP_KERNEL/PolyhedronIntersectorP0P1.txx +++ b/src/INTERP_KERNEL/PolyhedronIntersectorP0P1.txx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __POLYHEDRONINTERSECTORP0P1_TXX__ #define __POLYHEDRONINTERSECTORP0P1_TXX__ diff --git a/src/INTERP_KERNEL/PolyhedronIntersectorP1P0.hxx b/src/INTERP_KERNEL/PolyhedronIntersectorP1P0.hxx index 206d2f999..483b3b166 100644 --- a/src/INTERP_KERNEL/PolyhedronIntersectorP1P0.hxx +++ b/src/INTERP_KERNEL/PolyhedronIntersectorP1P0.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __POLYHEDRONINTERSECTORP1P0_HXX__ @@ -43,7 +43,7 @@ namespace INTERP_KERNEL static const NumberingPolicy numPol=MyMeshType::My_numPol; public: - PolyhedronIntersectorP1P0(const MyMeshType& targetMesh, const MyMeshType& srcMesh, SplittingPolicy policy = GENERAL_24); + PolyhedronIntersectorP1P0(const MyMeshType& targetMesh, const MyMeshType& srcMesh, SplittingPolicy policy = PLANAR_FACE_5); ~PolyhedronIntersectorP1P0(); diff --git a/src/INTERP_KERNEL/PolyhedronIntersectorP1P0.txx b/src/INTERP_KERNEL/PolyhedronIntersectorP1P0.txx index b6aa026cb..43ca2840a 100644 --- a/src/INTERP_KERNEL/PolyhedronIntersectorP1P0.txx +++ b/src/INTERP_KERNEL/PolyhedronIntersectorP1P0.txx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __POLYHEDRONINTERSECTORP1P0_TXX__ #define __POLYHEDRONINTERSECTORP1P0_TXX__ diff --git a/src/INTERP_KERNEL/PolyhedronIntersectorP1P0Bary.hxx b/src/INTERP_KERNEL/PolyhedronIntersectorP1P0Bary.hxx index 899adc731..136e198cf 100644 --- a/src/INTERP_KERNEL/PolyhedronIntersectorP1P0Bary.hxx +++ b/src/INTERP_KERNEL/PolyhedronIntersectorP1P0Bary.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __PolyhedronIntersectorP1P0Bary_HXX__ @@ -43,7 +43,7 @@ namespace INTERP_KERNEL static const NumberingPolicy numPol=MyMeshType::My_numPol; public: - PolyhedronIntersectorP1P0Bary(const MyMeshType& targetMesh, const MyMeshType& srcMesh, SplittingPolicy policy = GENERAL_24); + PolyhedronIntersectorP1P0Bary(const MyMeshType& targetMesh, const MyMeshType& srcMesh, SplittingPolicy policy = PLANAR_FACE_5); ~PolyhedronIntersectorP1P0Bary(); diff --git a/src/INTERP_KERNEL/PolyhedronIntersectorP1P0Bary.txx b/src/INTERP_KERNEL/PolyhedronIntersectorP1P0Bary.txx index c38e16d50..d3ae2560f 100644 --- a/src/INTERP_KERNEL/PolyhedronIntersectorP1P0Bary.txx +++ b/src/INTERP_KERNEL/PolyhedronIntersectorP1P0Bary.txx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __PolyhedronIntersectorP1P0Bary_TXX__ #define __PolyhedronIntersectorP1P0Bary_TXX__ diff --git a/src/INTERP_KERNEL/PolyhedronIntersectorP1P1.hxx b/src/INTERP_KERNEL/PolyhedronIntersectorP1P1.hxx index 736188661..e32d813f0 100644 --- a/src/INTERP_KERNEL/PolyhedronIntersectorP1P1.hxx +++ b/src/INTERP_KERNEL/PolyhedronIntersectorP1P1.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __PolyhedronIntersectorP1P1_HXX__ @@ -43,7 +43,7 @@ namespace INTERP_KERNEL static const NumberingPolicy numPol=MyMeshType::My_numPol; public: - PolyhedronIntersectorP1P1(const MyMeshType& targetMesh, const MyMeshType& srcMesh, SplittingPolicy policy = GENERAL_24); + PolyhedronIntersectorP1P1(const MyMeshType& targetMesh, const MyMeshType& srcMesh, SplittingPolicy policy = PLANAR_FACE_5); ~PolyhedronIntersectorP1P1(); diff --git a/src/INTERP_KERNEL/PolyhedronIntersectorP1P1.txx b/src/INTERP_KERNEL/PolyhedronIntersectorP1P1.txx index f80348924..f98dca961 100644 --- a/src/INTERP_KERNEL/PolyhedronIntersectorP1P1.txx +++ b/src/INTERP_KERNEL/PolyhedronIntersectorP1P1.txx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __PolyhedronIntersectorP1P1_TXX__ #define __PolyhedronIntersectorP1P1_TXX__ diff --git a/src/INTERP_KERNEL/RegionNode.hxx b/src/INTERP_KERNEL/RegionNode.hxx index 4f70d045a..e894260da 100644 --- a/src/INTERP_KERNEL/RegionNode.hxx +++ b/src/INTERP_KERNEL/RegionNode.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __REGIONNODE_HXX__ diff --git a/src/INTERP_KERNEL/SplitterTetra.hxx b/src/INTERP_KERNEL/SplitterTetra.hxx index cbb04457d..5127c6d84 100644 --- a/src/INTERP_KERNEL/SplitterTetra.hxx +++ b/src/INTERP_KERNEL/SplitterTetra.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __SPLITTERTETRA_HXX__ diff --git a/src/INTERP_KERNEL/SplitterTetra.txx b/src/INTERP_KERNEL/SplitterTetra.txx index d1e084876..0372bc4a6 100644 --- a/src/INTERP_KERNEL/SplitterTetra.txx +++ b/src/INTERP_KERNEL/SplitterTetra.txx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __SPLITTERTETRA_TXX__ #define __SPLITTERTETRA_TXX__ @@ -192,7 +192,7 @@ namespace INTERP_KERNEL // get type of cell NormalizedCellType normCellType=_src_mesh.getTypeOfElement(OTT::indFC(element)); - const CellModel& cellModelCell=CellModel::getCellModel(normCellType); + const CellModel& cellModelCell=CellModel::GetCellModel(normCellType); unsigned nbOfNodes4Type=cellModelCell.isDynamic() ? _src_mesh.getNumberOfNodesOfElement(OTT::indFC(element)) : cellModelCell.getNumberOfNodes(); // halfspace filtering bool isOutside[8] = {true, true, true, true, true, true, true, true}; @@ -242,7 +242,7 @@ namespace INTERP_KERNEL { // get sons connectivity NormalizedCellType faceType; - int *faceNodes, nbFaceNodes; + int *faceNodes, nbFaceNodes=-1; if ( cellModelCell.isDynamic() ) { faceNodes=new int[nbOfNodes4Type]; @@ -253,7 +253,7 @@ namespace INTERP_KERNEL else { faceType = cellModelCell.getSonType(ii); - const CellModel& faceModel=CellModel::getCellModel(faceType); + const CellModel& faceModel=CellModel::GetCellModel(faceType); assert(faceModel.getDimension() == 2); faceNodes=new int[faceModel.getNumberOfNodes()]; cellModelCell.fillSonCellNodalConnectivity(ii,cellNodes,faceNodes); @@ -415,7 +415,7 @@ namespace INTERP_KERNEL if(!isTargetOutside) { - const CellModel& cellModelCell=CellModel::getCellModel(NORM_TETRA4); + const CellModel& cellModelCell=CellModel::GetCellModel(NORM_TETRA4); int cellNodes[4] = { 0, 1, 2, 3 }, faceNodes[3]; for(unsigned ii = 0 ; ii < 4 ; ++ii) @@ -709,7 +709,7 @@ namespace INTERP_KERNEL nodes[1] = getCoordsOfSubNode2(faceCenterNode,conn[1]); for(int j = 0; j < 4; ++j) { - const int row = 4*(faceCenterNode - 9) + j; + const int row = 4*(faceCenterNode - 8) + j; nodes[2] = getCoordsOfSubNode2(TETRA_EDGES[2*row],conn[2]); nodes[3] = getCoordsOfSubNode2(TETRA_EDGES[2*row + 1],conn[3]); @@ -795,7 +795,7 @@ namespace INTERP_KERNEL // get type of cell and nb of cell nodes NormalizedCellType normCellType=_target_mesh.getTypeOfElement(OTT::indFC(targetCell)); - const CellModel& cellModelCell=CellModel::getCellModel(normCellType); + const CellModel& cellModelCell=CellModel::GetCellModel(normCellType); unsigned nbOfCellNodes=cellModelCell.isDynamic() ? _target_mesh.getNumberOfNodesOfElement(OTT::indFC(targetCell)) : cellModelCell.getNumberOfNodes(); // get nb of cell sons (faces) @@ -883,7 +883,7 @@ namespace INTERP_KERNEL 1,2,5,6,// sub-node 12 (face) 4,5,6,7,// sub-node 13 (face) 2,3,6,7,// sub-node 14 (face) - 9,10,11,12// sub-node 15 (cell) + 8,9,10,11// sub-node 15 (cell) }; for(int i = 0; i < 7; ++i) diff --git a/src/INTERP_KERNEL/TargetIntersector.hxx b/src/INTERP_KERNEL/TargetIntersector.hxx index d7d2063a2..f41c3d498 100644 --- a/src/INTERP_KERNEL/TargetIntersector.hxx +++ b/src/INTERP_KERNEL/TargetIntersector.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __TARGETINTERSECTOR__HXX__ diff --git a/src/INTERP_KERNEL/TetraAffineTransform.cxx b/src/INTERP_KERNEL/TetraAffineTransform.cxx index b8cae3a7b..e4309fa47 100644 --- a/src/INTERP_KERNEL/TetraAffineTransform.cxx +++ b/src/INTERP_KERNEL/TetraAffineTransform.cxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "TetraAffineTransform.hxx" diff --git a/src/INTERP_KERNEL/TetraAffineTransform.hxx b/src/INTERP_KERNEL/TetraAffineTransform.hxx index 89cd0a060..dfdc39c66 100644 --- a/src/INTERP_KERNEL/TetraAffineTransform.hxx +++ b/src/INTERP_KERNEL/TetraAffineTransform.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __TETRA_AFFINE_TRANSFORM_HXX__ diff --git a/src/INTERP_KERNEL/TransformedTriangle.cxx b/src/INTERP_KERNEL/TransformedTriangle.cxx index 56a47c232..661d71e65 100644 --- a/src/INTERP_KERNEL/TransformedTriangle.cxx +++ b/src/INTERP_KERNEL/TransformedTriangle.cxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "TransformedTriangle.hxx" diff --git a/src/INTERP_KERNEL/TransformedTriangle.hxx b/src/INTERP_KERNEL/TransformedTriangle.hxx index c032faed7..84877b9b9 100644 --- a/src/INTERP_KERNEL/TransformedTriangle.hxx +++ b/src/INTERP_KERNEL/TransformedTriangle.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __TRANSFORMED_TRIANGLE_HXX__ diff --git a/src/INTERP_KERNEL/TransformedTriangleInline.hxx b/src/INTERP_KERNEL/TransformedTriangleInline.hxx index 4ba0a2dca..e6de1e3e6 100644 --- a/src/INTERP_KERNEL/TransformedTriangleInline.hxx +++ b/src/INTERP_KERNEL/TransformedTriangleInline.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __TRANSFORMEDTRIANGLEINLINE_HXX__ diff --git a/src/INTERP_KERNEL/TransformedTriangleIntersect.cxx b/src/INTERP_KERNEL/TransformedTriangleIntersect.cxx index a69afa2c2..faf7c9b61 100644 --- a/src/INTERP_KERNEL/TransformedTriangleIntersect.cxx +++ b/src/INTERP_KERNEL/TransformedTriangleIntersect.cxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "TransformedTriangle.hxx" diff --git a/src/INTERP_KERNEL/TransformedTriangleMath.cxx b/src/INTERP_KERNEL/TransformedTriangleMath.cxx index 2a5373e48..fd8674986 100644 --- a/src/INTERP_KERNEL/TransformedTriangleMath.cxx +++ b/src/INTERP_KERNEL/TransformedTriangleMath.cxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "TransformedTriangle.hxx" diff --git a/src/INTERP_KERNEL/TranslationRotationMatrix.cxx b/src/INTERP_KERNEL/TranslationRotationMatrix.cxx index 0e31b21e0..0aa8ba385 100644 --- a/src/INTERP_KERNEL/TranslationRotationMatrix.cxx +++ b/src/INTERP_KERNEL/TranslationRotationMatrix.cxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "TranslationRotationMatrix.hxx" diff --git a/src/INTERP_KERNEL/TranslationRotationMatrix.hxx b/src/INTERP_KERNEL/TranslationRotationMatrix.hxx index e1108573b..08f3ba9f4 100644 --- a/src/INTERP_KERNEL/TranslationRotationMatrix.hxx +++ b/src/INTERP_KERNEL/TranslationRotationMatrix.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __TRANSLATIONROTATIONMATRIX_HXX__ diff --git a/src/INTERP_KERNEL/TriangulationIntersector.hxx b/src/INTERP_KERNEL/TriangulationIntersector.hxx index f20a884a7..69e72e93d 100644 --- a/src/INTERP_KERNEL/TriangulationIntersector.hxx +++ b/src/INTERP_KERNEL/TriangulationIntersector.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __TRIANGULATIONINTERSECTOR_HXX__ diff --git a/src/INTERP_KERNEL/TriangulationIntersector.txx b/src/INTERP_KERNEL/TriangulationIntersector.txx index de8a83954..1ca2bfd5f 100644 --- a/src/INTERP_KERNEL/TriangulationIntersector.txx +++ b/src/INTERP_KERNEL/TriangulationIntersector.txx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __TRIANGULATIONINTERSECTOR_TXX__ #define __TRIANGULATIONINTERSECTOR_TXX__ @@ -191,8 +191,7 @@ namespace INTERP_KERNEL //Compute the intersection area double inter_area[SPACEDIM], total_area = 0.; - double total_barycenter[SPACEDIM]; - total_barycenter[0]=total_barycenter[1] = 0.; + double total_barycenter[SPACEDIM]={0.,0.}; const ConnType nbNodesT=targetCell.size()/SPACEDIM; for(ConnType iT = 1; iT::coo2C(connec[0]),OTT::coo2C(connec[1]),OTT::coo2C(connec[2]),OTT::coo2C(connec[3]),OTT::coo2C(connec[4]),OTT::coo2C(connec[5]),-1, + OTT::coo2C(connec[6]),OTT::coo2C(connec[11]),OTT::coo2C(connec[10]),OTT::coo2C(connec[9]),OTT::coo2C(connec[8]),OTT::coo2C(connec[7]),-1, + OTT::coo2C(connec[0]),OTT::coo2C(connec[6]),OTT::coo2C(connec[7]),OTT::coo2C(connec[1]),-1, + OTT::coo2C(connec[1]),OTT::coo2C(connec[7]),OTT::coo2C(connec[8]),OTT::coo2C(connec[2]),-1, + OTT::coo2C(connec[2]),OTT::coo2C(connec[8]),OTT::coo2C(connec[9]),OTT::coo2C(connec[3]),-1, + OTT::coo2C(connec[3]),OTT::coo2C(connec[9]),OTT::coo2C(connec[10]),OTT::coo2C(connec[4]),-1, + OTT::coo2C(connec[4]),OTT::coo2C(connec[10]),OTT::coo2C(connec[11]),OTT::coo2C(connec[5]),-1, + OTT::coo2C(connec[5]),OTT::coo2C(connec[11]),OTT::coo2C(connec[6]),OTT::coo2C(connec[0])}; + return calculateVolumeForPolyh2(connecHexa12,43,coords); + } case INTERP_KERNEL::NORM_POLYHED : { return calculateVolumeForPolyh2(connec,lgth,coords); @@ -271,6 +283,20 @@ namespace INTERP_KERNEL barycenterOfPolyhedron(conn,22,coords,res); break; } + case INTERP_KERNEL::NORM_HEXGP12: + { + const int connecHexa12[43]={ + OTT::coo2C(connec[0]),OTT::coo2C(connec[1]),OTT::coo2C(connec[2]),OTT::coo2C(connec[3]),OTT::coo2C(connec[4]),OTT::coo2C(connec[5]),-1, + OTT::coo2C(connec[6]),OTT::coo2C(connec[11]),OTT::coo2C(connec[10]),OTT::coo2C(connec[9]),OTT::coo2C(connec[8]),OTT::coo2C(connec[7]),-1, + OTT::coo2C(connec[0]),OTT::coo2C(connec[6]),OTT::coo2C(connec[7]),OTT::coo2C(connec[1]),-1, + OTT::coo2C(connec[1]),OTT::coo2C(connec[7]),OTT::coo2C(connec[8]),OTT::coo2C(connec[2]),-1, + OTT::coo2C(connec[2]),OTT::coo2C(connec[8]),OTT::coo2C(connec[9]),OTT::coo2C(connec[3]),-1, + OTT::coo2C(connec[3]),OTT::coo2C(connec[9]),OTT::coo2C(connec[10]),OTT::coo2C(connec[4]),-1, + OTT::coo2C(connec[4]),OTT::coo2C(connec[10]),OTT::coo2C(connec[11]),OTT::coo2C(connec[5]),-1, + OTT::coo2C(connec[5]),OTT::coo2C(connec[11]),OTT::coo2C(connec[6]),OTT::coo2C(connec[0])}; + barycenterOfPolyhedron(connecHexa12,43,coords,res); + break; + } case NORM_POLYHED: { barycenterOfPolyhedron(connec,lgth,coords,res); diff --git a/src/MEDCoupling/MEDCoupling.hxx b/src/MEDCoupling/MEDCoupling.hxx index 5f718343a..41a31c5ce 100644 --- a/src/MEDCoupling/MEDCoupling.hxx +++ b/src/MEDCoupling/MEDCoupling.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef _MEDCOUPLING_HXX_ diff --git a/src/MEDCoupling/MEDCouplingAutoRefCountObjectPtr.hxx b/src/MEDCoupling/MEDCouplingAutoRefCountObjectPtr.hxx index 9a30b7d8f..512591b7a 100644 --- a/src/MEDCoupling/MEDCouplingAutoRefCountObjectPtr.hxx +++ b/src/MEDCoupling/MEDCouplingAutoRefCountObjectPtr.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __PARAMEDMEM_MEDCOUPLINGAUTOREFCOUNTOBJECTPTR_HXX__ @@ -31,6 +31,7 @@ namespace ParaMEDMEM MEDCouplingAutoRefCountObjectPtr(const MEDCouplingAutoRefCountObjectPtr& other):_ptr(0) { referPtr(other._ptr); } MEDCouplingAutoRefCountObjectPtr(T *ptr=0):_ptr(ptr) { } ~MEDCouplingAutoRefCountObjectPtr() { destroyPtr(); } + bool operator==(const MEDCouplingAutoRefCountObjectPtr& other) { return _ptr==other._ptr; } MEDCouplingAutoRefCountObjectPtr &operator=(const MEDCouplingAutoRefCountObjectPtr& other) { if(_ptr!=other._ptr) { destroyPtr(); referPtr(other._ptr); } return *this; } MEDCouplingAutoRefCountObjectPtr &operator=(T *ptr) { if(_ptr!=ptr) { destroyPtr(); _ptr=ptr; } return *this; } T *operator->() { return _ptr ; } diff --git a/src/MEDCoupling/MEDCouplingCMesh.cxx b/src/MEDCoupling/MEDCouplingCMesh.cxx index e7d9bcd3a..14791e509 100644 --- a/src/MEDCoupling/MEDCouplingCMesh.cxx +++ b/src/MEDCoupling/MEDCouplingCMesh.cxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "MEDCouplingCMesh.hxx" @@ -37,11 +37,17 @@ MEDCouplingCMesh::MEDCouplingCMesh(const MEDCouplingCMesh& other, bool deepCpy): if(deepCpy) { if(other._x_array) - _x_array=_x_array->deepCopy(); + _x_array=other._x_array->deepCpy(); + else + _x_array=0; if(other._y_array) - _y_array=_y_array->deepCopy(); + _y_array=other._y_array->deepCpy(); + else + _y_array=0; if(other._z_array) - _z_array=_z_array->deepCopy(); + _z_array=other._z_array->deepCpy(); + else + _z_array=0; } else { @@ -82,7 +88,7 @@ MEDCouplingCMesh *MEDCouplingCMesh::clone(bool recDeepCpy) const return new MEDCouplingCMesh(*this,recDeepCpy); } -void MEDCouplingCMesh::updateTime() +void MEDCouplingCMesh::updateTime() const { if(_x_array) updateTimeWith(*_x_array); @@ -207,6 +213,22 @@ void MEDCouplingCMesh::checkCoherency() const throw(INTERP_KERNEL::Exception) } } +void MEDCouplingCMesh::checkCoherency1(double eps) const throw(INTERP_KERNEL::Exception) +{ + checkCoherency(); + if(_x_array) + _x_array->checkMonotonic(eps); + if(_y_array) + _y_array->checkMonotonic(eps); + if(_z_array) + _z_array->checkMonotonic(eps); +} + +void MEDCouplingCMesh::checkCoherency2(double eps) const throw(INTERP_KERNEL::Exception) +{ + checkCoherency1(eps); +} + int MEDCouplingCMesh::getNumberOfCells() const { int ret=1; @@ -275,7 +297,7 @@ int MEDCouplingCMesh::getNodeIdFromPos(int i, int j, int k) const return std::accumulate(tmp,tmp+spaceDim,0); } -void MEDCouplingCMesh::getPosFromId(int nodeId, int spaceDim, const int *split, int *res) +void MEDCouplingCMesh::GetPosFromId(int nodeId, int spaceDim, const int *split, int *res) { int work=nodeId; for(int i=spaceDim-1;i>=0;i--) @@ -318,6 +340,25 @@ INTERP_KERNEL::NormalizedCellType MEDCouplingCMesh::getTypeOfCell(int cellId) co } } +std::set MEDCouplingCMesh::getAllGeoTypes() const +{ + INTERP_KERNEL::NormalizedCellType ret; + switch(getMeshDimension()) + { + case 3: + ret=INTERP_KERNEL::NORM_HEXA8; + case 2: + ret=INTERP_KERNEL::NORM_QUAD4; + case 1: + ret=INTERP_KERNEL::NORM_SEG2; + default: + throw INTERP_KERNEL::Exception("Unexpected dimension for MEDCouplingCMesh::getAllGeoTypes !"); + } + std::set ret2; + ret2.insert(ret); + return ret2; +} + int MEDCouplingCMesh::getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const { int ret=getNumberOfCells(); @@ -351,7 +392,7 @@ void MEDCouplingCMesh::getCoordinatesOfNode(int nodeId, std::vector& coo getSplitNodeValues(tmp); const DataArrayDouble *tabs[3]={getCoordsAt(0),getCoordsAt(1),getCoordsAt(2)}; int tmp2[3]; - getPosFromId(nodeId,spaceDim,tmp,tmp2); + GetPosFromId(nodeId,spaceDim,tmp,tmp2); for(int j=0;jgetConstPointer()[tmp2[j]]); @@ -361,6 +402,11 @@ std::string MEDCouplingCMesh::simpleRepr() const { std::ostringstream ret; ret << "Cartesian mesh with name : \"" << getName() << "\"\n"; + ret << "Description of mesh : \"" << getDescription() << "\"\n"; + int tmpp1,tmpp2; + double tt=getTime(tmpp1,tmpp2); + ret << "Time attached to the mesh [unit] : " << tt << " [" << getTimeUnit() << "]\n"; + ret << "Iteration : " << tmpp1 << " Order : " << tmpp2 << "\n"; ret << "Mesh and SpaceDimension dimension : " << getSpaceDimension() << "\n\nArrays :\n________\n\n"; if(_x_array) { @@ -385,7 +431,22 @@ std::string MEDCouplingCMesh::advancedRepr() const return simpleRepr(); } -DataArrayDouble *MEDCouplingCMesh::getCoordsAt(int i) const throw(INTERP_KERNEL::Exception) +const DataArrayDouble *MEDCouplingCMesh::getCoordsAt(int i) const throw(INTERP_KERNEL::Exception) +{ + switch(i) + { + case 0: + return _x_array; + case 1: + return _y_array; + case 2: + return _z_array; + default: + throw INTERP_KERNEL::Exception("Invalid rank specified must be 0 or 1 or 2."); + } +} + +DataArrayDouble *MEDCouplingCMesh::getCoordsAt(int i) throw(INTERP_KERNEL::Exception) { switch(i) { @@ -400,7 +461,7 @@ DataArrayDouble *MEDCouplingCMesh::getCoordsAt(int i) const throw(INTERP_KERNEL: } } -void MEDCouplingCMesh::setCoordsAt(int i, DataArrayDouble *arr) throw(INTERP_KERNEL::Exception) +void MEDCouplingCMesh::setCoordsAt(int i, const DataArrayDouble *arr) throw(INTERP_KERNEL::Exception) { DataArrayDouble **thisArr[3]={&_x_array,&_y_array,&_z_array}; if(i<0 || i>2) @@ -409,34 +470,71 @@ void MEDCouplingCMesh::setCoordsAt(int i, DataArrayDouble *arr) throw(INTERP_KER { if(*(thisArr[i])) (*(thisArr[i]))->decrRef(); - (*(thisArr[i]))=arr; + (*(thisArr[i]))=const_cast(arr); if(*(thisArr[i])) (*(thisArr[i]))->incrRef(); declareAsNew(); } } -void MEDCouplingCMesh::setCoords(DataArrayDouble *coordsX, DataArrayDouble *coordsY, DataArrayDouble *coordsZ) +void MEDCouplingCMesh::setCoords(const DataArrayDouble *coordsX, const DataArrayDouble *coordsY, const DataArrayDouble *coordsZ) { if(_x_array) _x_array->decrRef(); - _x_array=coordsX; + _x_array=const_cast(coordsX); if(_x_array) _x_array->incrRef(); if(_y_array) _y_array->decrRef(); - _y_array=coordsY; + _y_array=const_cast(coordsY); if(_y_array) _y_array->incrRef(); if(_z_array) _z_array->decrRef(); - _z_array=coordsZ; + _z_array=const_cast(coordsZ); if(_z_array) _z_array->incrRef(); declareAsNew(); } -MEDCouplingUMesh *MEDCouplingCMesh::buildUnstructured() const +/*! + * See MEDCouplingUMesh::checkTypeConsistencyAndContig for more information + */ +DataArrayInt *MEDCouplingCMesh::checkTypeConsistencyAndContig(const std::vector& code, const std::vector& idsPerType) const throw(INTERP_KERNEL::Exception) +{ + int sz=code.size(); + if(sz!=0 && sz!=3) + throw INTERP_KERNEL::Exception("MEDCouplingCMesh::checkTypeConsistencyAndContig : code should be of size 2 exactly !"); + if(code[0]==INTERP_KERNEL::NORM_ERROR) + { + int nbNodes=getNumberOfNodes(); + if(code[2]==-1) + { + if(code[1]==nbNodes) + return 0; + else + throw INTERP_KERNEL::Exception("MEDCouplingCMesh::checkTypeConsistencyAndContig : number of nodes mismatch !"); + } + else + idsPerType[code[2]]->deepCpy(); + } + else + { + int nbCells=getNumberOfCellsWithType((INTERP_KERNEL::NormalizedCellType)code[0]); + if(code[2]==-1) + { + if(code[1]==nbCells) + return 0; + else + throw INTERP_KERNEL::Exception("MEDCouplingCMesh::checkTypeConsistencyAndContig : number of cells mismatch !"); + } + else + idsPerType[code[2]]->deepCpy(); + } + return 0; +} + +MEDCouplingUMesh *MEDCouplingCMesh::buildUnstructured() const throw(INTERP_KERNEL::Exception) { int spaceDim=getSpaceDimension(); MEDCouplingUMesh *ret=MEDCouplingUMesh::New(getName(),spaceDim); @@ -476,13 +574,18 @@ MEDCouplingMesh *MEDCouplingCMesh::buildPartAndReduceNodes(const int *start, con return ret; } +DataArrayInt *MEDCouplingCMesh::simplexize(int policy) throw(INTERP_KERNEL::Exception) +{ + throw INTERP_KERNEL::Exception("MEDCouplingCMesh::simplexize : not available for Cartesian mesh !"); +} + void MEDCouplingCMesh::getBoundingBox(double *bbox) const { int dim=getSpaceDimension(); int j=0; for (int idim=0; idimgetConstPointer(); @@ -517,7 +620,7 @@ MEDCouplingFieldDouble *MEDCouplingCMesh::getMeasureField(bool isAbs) const for(int icell=0;icellgetPointer(); int tmp[3]; getSplitNodeValues(tmp); - DataArrayDouble *tabs[3]={getCoordsAt(0),getCoordsAt(1),getCoordsAt(2)}; + const DataArrayDouble *tabs[3]={getCoordsAt(0),getCoordsAt(1),getCoordsAt(2)}; const double *tabsPtr[3]; for(int j=0;jgetConstPointer(); + { + tabsPtr[j]=tabs[j]->getConstPointer(); + ret->setInfoOnComponent(j,tabs[j]->getInfoOnComponent(0).c_str()); + } int tmp2[3]; for(int i=0;igetPointer(); int tmp[3]; getSplitCellValues(tmp); - DataArrayDouble *tabs[3]={getCoordsAt(0),getCoordsAt(1),getCoordsAt(2)}; + const DataArrayDouble *tabs[3]={getCoordsAt(0),getCoordsAt(1),getCoordsAt(2)}; std::vector tabsPtr[3]; for(int j=0;jgetNbOfElems()-1; + ret->setInfoOnComponent(j,tabs[j]->getInfoOnComponent(0).c_str()); const double *srcPtr=tabs[j]->getConstPointer(); tabsPtr[j].insert(tabsPtr[j].end(),srcPtr,srcPtr+sz); std::transform(tabsPtr[j].begin(),tabsPtr[j].end(),srcPtr+1,tabsPtr[j].begin(),std::plus()); @@ -659,7 +766,7 @@ DataArrayDouble *MEDCouplingCMesh::getBarycenterAndOwner() const int tmp2[3]; for(int i=0;idecrRef(); } -void MEDCouplingCMesh::getTinySerializationInformation(std::vector& tinyInfo, std::vector& littleStrings) const +void MEDCouplingCMesh::getTinySerializationInformation(std::vector& tinyInfoD, std::vector& tinyInfo, std::vector& littleStrings) const { + int it,order; + double time=getTime(it,order); tinyInfo.clear(); + tinyInfoD.clear(); littleStrings.clear(); littleStrings.push_back(getName()); + 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++) { @@ -778,6 +890,9 @@ void MEDCouplingCMesh::getTinySerializationInformation(std::vector& tinyInf tinyInfo.push_back(val); littleStrings.push_back(st); } + tinyInfo.push_back(it); + tinyInfo.push_back(order); + tinyInfoD.push_back(time); } void MEDCouplingCMesh::resizeForUnserialization(const std::vector& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector& littleStrings) const @@ -809,10 +924,12 @@ void MEDCouplingCMesh::serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const a2Ptr=std::copy(thisArr[i]->getConstPointer(),thisArr[i]->getConstPointer()+thisArr[i]->getNumberOfTuples(),a2Ptr); } -void MEDCouplingCMesh::unserialization(const std::vector& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, +void MEDCouplingCMesh::unserialization(const std::vector& tinyInfoD, const std::vector& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, const std::vector& littleStrings) { setName(littleStrings[0].c_str()); + setDescription(littleStrings[1].c_str()); + setTimeUnit(littleStrings[2].c_str()); DataArrayDouble **thisArr[3]={&_x_array,&_y_array,&_z_array}; const double *data=a2->getConstPointer(); for(int i=0;i<3;i++) @@ -821,10 +938,11 @@ void MEDCouplingCMesh::unserialization(const std::vector& tinyInfo, const D { (*(thisArr[i]))=DataArrayDouble::New(); (*(thisArr[i]))->alloc(tinyInfo[i],1); - (*(thisArr[i]))->setInfoOnComponent(0,littleStrings[i+1].c_str()); + (*(thisArr[i]))->setInfoOnComponent(0,littleStrings[i+3].c_str()); std::copy(data,data+tinyInfo[i],(*(thisArr[i]))->getPointer()); data+=tinyInfo[i]; } } + setTime(tinyInfoD[0],tinyInfo[3],tinyInfo[4]); } diff --git a/src/MEDCoupling/MEDCouplingCMesh.hxx b/src/MEDCoupling/MEDCouplingCMesh.hxx index 434091f41..1864a9fb2 100644 --- a/src/MEDCoupling/MEDCouplingCMesh.hxx +++ b/src/MEDCoupling/MEDCouplingCMesh.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __PARAMEDMEM_MEDCOUPLINGCMESH_HXX__ @@ -34,7 +34,7 @@ namespace ParaMEDMEM static MEDCouplingCMesh *New(); MEDCouplingMesh *deepCpy() const; MEDCouplingCMesh *clone(bool recDeepCpy) const; - void updateTime(); + void updateTime() const; MEDCouplingMeshType getType() const { return CARTESIAN; } void copyTinyStringsFrom(const MEDCouplingMesh *other) throw(INTERP_KERNEL::Exception); bool isEqual(const MEDCouplingMesh *other, double prec) const; @@ -44,28 +44,34 @@ namespace ParaMEDMEM void checkDeepEquivalOnSameNodesWith(const MEDCouplingMesh *other, int cellCompPol, double prec, DataArrayInt *&cellCor) const throw(INTERP_KERNEL::Exception); void checkCoherency() const throw(INTERP_KERNEL::Exception); + void checkCoherency1(double eps=1e-12) const throw(INTERP_KERNEL::Exception); + void checkCoherency2(double eps=1e-12) const throw(INTERP_KERNEL::Exception); int getNumberOfCells() const; int getNumberOfNodes() const; int getSpaceDimension() const; int getMeshDimension() const; int getCellIdFromPos(int i, int j, int k) const; int getNodeIdFromPos(int i, int j, int k) const; - static void getPosFromId(int nodeId, int spaceDim, const int *split, int *res); + static void GetPosFromId(int nodeId, int spaceDim, const int *split, int *res); INTERP_KERNEL::NormalizedCellType getTypeOfCell(int cellId) const; + std::set getAllGeoTypes() const; int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const; void getNodeIdsOfCell(int cellId, std::vector& conn) const; void getCoordinatesOfNode(int nodeId, std::vector& coo) const; std::string simpleRepr() const; std::string advancedRepr() const; - DataArrayDouble *getCoordsAt(int i) const throw(INTERP_KERNEL::Exception); - void setCoordsAt(int i, DataArrayDouble *arr) throw(INTERP_KERNEL::Exception); - void setCoords(DataArrayDouble *coordsX, - DataArrayDouble *coordsY=0, - DataArrayDouble *coordsZ=0); + const DataArrayDouble *getCoordsAt(int i) const throw(INTERP_KERNEL::Exception); + DataArrayDouble *getCoordsAt(int i) throw(INTERP_KERNEL::Exception); + void setCoordsAt(int i, const DataArrayDouble *arr) throw(INTERP_KERNEL::Exception); + void setCoords(const DataArrayDouble *coordsX, + const DataArrayDouble *coordsY=0, + const DataArrayDouble *coordsZ=0); // tools - MEDCouplingUMesh *buildUnstructured() const; + DataArrayInt *checkTypeConsistencyAndContig(const std::vector& code, const std::vector& idsPerType) const throw(INTERP_KERNEL::Exception); + MEDCouplingUMesh *buildUnstructured() const throw(INTERP_KERNEL::Exception); MEDCouplingMesh *buildPart(const int *start, const int *end) const; MEDCouplingMesh *buildPartAndReduceNodes(const int *start, const int *end, DataArrayInt*& arr) const; + DataArrayInt *simplexize(int policy) throw(INTERP_KERNEL::Exception); void getBoundingBox(double *bbox) const; MEDCouplingFieldDouble *getMeasureField(bool isAbs) const; MEDCouplingFieldDouble *getMeasureFieldOnNode(bool isAbs) const; @@ -85,10 +91,10 @@ namespace ParaMEDMEM void getSplitCellValues(int *res) const; void getSplitNodeValues(int *res) const; //serialisation-unserialization - void getTinySerializationInformation(std::vector& tinyInfo, std::vector& littleStrings) const; + void getTinySerializationInformation(std::vector& tinyInfoD, std::vector& tinyInfo, std::vector& littleStrings) const; void resizeForUnserialization(const std::vector& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector& littleStrings) const; void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const; - void unserialization(const std::vector& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, + void unserialization(const std::vector& tinyInfoD, const std::vector& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, const std::vector& littleStrings); private: MEDCouplingCMesh(); diff --git a/src/MEDCoupling/MEDCouplingDefinitionTime.cxx b/src/MEDCoupling/MEDCouplingDefinitionTime.cxx new file mode 100644 index 000000000..3ab498bba --- /dev/null +++ b/src/MEDCoupling/MEDCouplingDefinitionTime.cxx @@ -0,0 +1,601 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "MEDCouplingDefinitionTime.hxx" +#include "MEDCouplingFieldDouble.hxx" + +#include + +using namespace ParaMEDMEM; + +const double MEDCouplingDefinitionTime::EPS_DFT=1e-15; + +MEDCouplingDefinitionTimeSlice *MEDCouplingDefinitionTimeSlice::New(const MEDCouplingFieldDouble *f, int meshId, const std::vector& arrId, int fieldId) throw(INTERP_KERNEL::Exception) +{ + static const char msg[]="TimeSlice::New : mismatch of arrays number of a fieldDouble and its policy !!! Internal error !!!"; + if(!f) + throw INTERP_KERNEL::Exception("MEDCouplingDefinitionTimeSlice::New : empty field !"); + switch(f->getTimeDiscretization()) + { + case ONE_TIME: + { + if(arrId.size()!=1) + throw INTERP_KERNEL::Exception(msg); + return new MEDCouplingDefinitionTimeSliceInst(f,meshId,arrId[0],fieldId); + } + case CONST_ON_TIME_INTERVAL: + { + if(arrId.size()!=1) + throw INTERP_KERNEL::Exception(msg); + return new MEDCouplingDefinitionTimeSliceCstOnTI(f,meshId,arrId[0],fieldId); + } + case LINEAR_TIME: + { + if(arrId.size()!=2) + throw INTERP_KERNEL::Exception(msg); + return new MEDCouplingDefinitionTimeSliceLT(f,meshId,arrId[0],arrId[1],fieldId); + } + case NO_TIME: + throw INTERP_KERNEL::Exception("Invalide time discretization ! NO_TIME ! Impossible to build a definition time slice !"); + default: + throw INTERP_KERNEL::Exception("Invalide time discretization : Not recognized !"); + } +} + +MEDCouplingDefinitionTimeSlice *MEDCouplingDefinitionTimeSlice::New(TypeOfTimeDiscretization type, const std::vector& tiI, const std::vector& tiD) throw(INTERP_KERNEL::Exception) +{ + switch(type) + { + case ONE_TIME: + return MEDCouplingDefinitionTimeSliceInst::New(tiI,tiD); + case CONST_ON_TIME_INTERVAL: + return MEDCouplingDefinitionTimeSliceCstOnTI::New(tiI,tiD); + case LINEAR_TIME: + return MEDCouplingDefinitionTimeSliceLT::New(tiI,tiD); + default: + throw INTERP_KERNEL::Exception("MEDCouplingDefinitionTimeSlice::New : unrecognized time discretization type !"); + } +} + +bool MEDCouplingDefinitionTimeSlice::isEqual(const MEDCouplingDefinitionTimeSlice& other, double eps) const +{ + if(_mesh_id!=other._mesh_id) + return false; + if(_array_id!=other._array_id) + return false; + if(_field_id!=other._field_id) + return false; + return true; +} + +int MEDCouplingDefinitionTimeSlice::getStartId() const +{ + return _array_id; +} + +int MEDCouplingDefinitionTimeSlice::getEndId() const +{ + return _array_id; +} + +void MEDCouplingDefinitionTimeSlice::appendRepr(std::ostream& stream) const +{ + stream << " *** MeshId : " << _mesh_id << " ArrayId : " << _array_id; +} + +MEDCouplingDefinitionTimeSlice::MEDCouplingDefinitionTimeSlice(const MEDCouplingFieldDouble *f, int meshId, int arrId, int fieldId) throw(INTERP_KERNEL::Exception):_mesh_id(meshId),_array_id(arrId),_field_id(fieldId) +{ + int tmp1,tmp2; + double t1=f->getStartTime(tmp1,tmp2); + double t2=f->getEndTime(tmp1,tmp2); + if(t2getStartTime(); + double o2=other->getEndTime(); + return o1>t1-eps && o2getStartTime(); + double 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(); + 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(); + return (o1& tiI, const std::vector& tiD) +{ + MEDCouplingDefinitionTimeSliceInst *ret=new MEDCouplingDefinitionTimeSliceInst; + ret->unserialize(tiI,tiD); + return ret; +} + +void MEDCouplingDefinitionTimeSliceInst::getTinySerializationInformation(std::vector& tiI, std::vector& tiD) const +{ + tiI.resize(3); + tiI[0]=_mesh_id; tiI[1]=_array_id; tiI[2]=_field_id; + tiD.resize(1); + tiD[0]=_instant; +} + +void MEDCouplingDefinitionTimeSliceInst::unserialize(const std::vector& tiI, const std::vector& tiD) +{ + _mesh_id=tiI[0]; _array_id=tiI[1]; _field_id=tiI[2]; + _instant=tiD[0]; +} + +TypeOfTimeDiscretization MEDCouplingDefinitionTimeSliceInst::getTimeType() const +{ + return ONE_TIME; +} + +MEDCouplingDefinitionTimeSlice *MEDCouplingDefinitionTimeSliceInst::copy() const +{ + return new MEDCouplingDefinitionTimeSliceInst(*this); +} + +bool MEDCouplingDefinitionTimeSliceInst::isEqual(const MEDCouplingDefinitionTimeSlice& other, double eps) const +{ + if(!MEDCouplingDefinitionTimeSlice::isEqual(other,eps)) + return false; + const MEDCouplingDefinitionTimeSliceInst *otherC=dynamic_cast(&other); + if(!otherC) + return false; + return fabs(otherC->_instant-_instant)& ret) const +{ + ret.resize(1); + ret[0]=_instant; +} + +void MEDCouplingDefinitionTimeSliceInst::getIdsOnTime(double tm, double eps, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception) +{ + meshId=_mesh_id; + arrId=_array_id; + arrIdInField=0; + fieldId=_field_id; +} + +bool MEDCouplingDefinitionTimeSliceInst::isContaining(double tmp, double eps) const +{ + return fabs(tmp-_instant)getStartTime(tmp1,tmp2); + double t2=f->getEndTime(tmp1,tmp2); + double eps=f->getTimeTolerance(); + if(fabs(t1-t2)>eps) + throw INTERP_KERNEL::Exception("MEDCouplingDefinitionTimeSliceInst : times differs in this"); + _instant=t1; +} + +MEDCouplingDefinitionTimeSliceCstOnTI *MEDCouplingDefinitionTimeSliceCstOnTI::New(const std::vector& tiI, const std::vector& tiD) +{ + MEDCouplingDefinitionTimeSliceCstOnTI *ret=new MEDCouplingDefinitionTimeSliceCstOnTI; + ret->unserialize(tiI,tiD); + return ret; +} + +MEDCouplingDefinitionTimeSlice *MEDCouplingDefinitionTimeSliceCstOnTI::copy() const +{ + return new MEDCouplingDefinitionTimeSliceCstOnTI(*this); +} + +bool MEDCouplingDefinitionTimeSliceCstOnTI::isEqual(const MEDCouplingDefinitionTimeSlice& other, double eps) const +{ + if(!MEDCouplingDefinitionTimeSlice::isEqual(other,eps)) + return false; + const MEDCouplingDefinitionTimeSliceCstOnTI *otherC=dynamic_cast(&other); + if(!otherC) + return false; + if(fabs(otherC->_start-_start)>eps) + return false; + return fabs(otherC->_end-_end)& ret) const +{ + ret.resize(1); + ret[0]=(_start+_end)/2.; +} + +void MEDCouplingDefinitionTimeSliceCstOnTI::getIdsOnTime(double tm, double eps, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception) +{ + meshId=_mesh_id; + arrId=_array_id; + arrIdInField=0; + fieldId=_field_id; +} + +bool MEDCouplingDefinitionTimeSliceCstOnTI::isContaining(double tmp, double eps) const +{ + return _start-epstmp; +} + +void MEDCouplingDefinitionTimeSliceCstOnTI::appendRepr(std::ostream& stream) const +{ + stream << "Constant on time interval [" << _start << "," << _end << "]"; + MEDCouplingDefinitionTimeSlice::appendRepr(stream); +} + +double MEDCouplingDefinitionTimeSliceCstOnTI::getStartTime() const +{ + return _start; +} + +double MEDCouplingDefinitionTimeSliceCstOnTI::getEndTime() const +{ + return _end; +} + +void MEDCouplingDefinitionTimeSliceCstOnTI::getTinySerializationInformation(std::vector& tiI, std::vector& tiD) const +{ + tiI.resize(3); + tiI[0]=_mesh_id; tiI[1]=_array_id; tiI[2]=_field_id; + tiD.resize(2); + tiD[0]=_start; tiD[1]=_end; +} + +void MEDCouplingDefinitionTimeSliceCstOnTI::unserialize(const std::vector& tiI, const std::vector& tiD) +{ + _mesh_id=tiI[0]; _array_id=tiI[1]; _field_id=tiI[2]; + _start=tiD[0]; _end=tiD[1]; +} + +TypeOfTimeDiscretization MEDCouplingDefinitionTimeSliceCstOnTI::getTimeType() const +{ + return CONST_ON_TIME_INTERVAL; +} + +MEDCouplingDefinitionTimeSliceCstOnTI::MEDCouplingDefinitionTimeSliceCstOnTI(const MEDCouplingFieldDouble *f, int meshId, int arrId, int fieldId) throw(INTERP_KERNEL::Exception):MEDCouplingDefinitionTimeSlice(f,meshId,arrId,fieldId) +{ + int tmp1,tmp2; + double t1=f->getStartTime(tmp1,tmp2); + double t2=f->getEndTime(tmp1,tmp2); + _start=t1; + _end=t2; +} + +MEDCouplingDefinitionTimeSliceLT *MEDCouplingDefinitionTimeSliceLT::New(const std::vector& tiI, const std::vector& tiD) +{ + MEDCouplingDefinitionTimeSliceLT *ret=new MEDCouplingDefinitionTimeSliceLT; + ret->unserialize(tiI,tiD); + return ret; +} + +MEDCouplingDefinitionTimeSlice *MEDCouplingDefinitionTimeSliceLT::copy() const +{ + return new MEDCouplingDefinitionTimeSliceLT(*this); +} + +bool MEDCouplingDefinitionTimeSliceLT::isEqual(const MEDCouplingDefinitionTimeSlice& other, double eps) const +{ + if(!MEDCouplingDefinitionTimeSlice::isEqual(other,eps)) + return false; + const MEDCouplingDefinitionTimeSliceLT *otherC=dynamic_cast(&other); + if(!otherC) + return false; + if(_array_id_end!=otherC->_array_id_end) + return false; + if(fabs(otherC->_start-_start)>eps) + return false; + return fabs(otherC->_end-_end)& ret) const +{ + ret.resize(2); + ret[0]=_start; + ret[1]=_end; +} + +void MEDCouplingDefinitionTimeSliceLT::getIdsOnTime(double tm, double eps, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception) +{ + if(fabs(tm-_start)tmp; +} + +void MEDCouplingDefinitionTimeSliceLT::appendRepr(std::ostream& stream) const +{ + stream << "Linear on time interval [" << _start << "," << _end << "]"; + MEDCouplingDefinitionTimeSlice::appendRepr(stream); + stream << " EndArrayId : " << _array_id_end; +} + +double MEDCouplingDefinitionTimeSliceLT::getStartTime() const +{ + return _start; +} + +double MEDCouplingDefinitionTimeSliceLT::getEndTime() const +{ + return _end; +} + +int MEDCouplingDefinitionTimeSliceLT::getEndId() const +{ + return _array_id_end; +} + +void MEDCouplingDefinitionTimeSliceLT::getTinySerializationInformation(std::vector& tiI, std::vector& tiD) const +{ + tiI.resize(4); + tiI[0]=_mesh_id; tiI[1]=_array_id; tiI[2]=_field_id; tiI[3]=_array_id_end; + tiD.resize(2); + tiD[0]=_start; tiD[1]=_end; +} + +void MEDCouplingDefinitionTimeSliceLT::unserialize(const std::vector& tiI, const std::vector& tiD) +{ + _mesh_id=tiI[0]; _array_id=tiI[1]; _field_id=tiI[2]; _array_id_end=tiI[3]; + _start=tiD[0]; _end=tiD[1]; +} + +TypeOfTimeDiscretization MEDCouplingDefinitionTimeSliceLT::getTimeType() const +{ + return LINEAR_TIME; +} + +MEDCouplingDefinitionTimeSliceLT::MEDCouplingDefinitionTimeSliceLT(const MEDCouplingFieldDouble *f, int meshId, int arrId, int arr2Id, int fieldId) throw(INTERP_KERNEL::Exception):MEDCouplingDefinitionTimeSlice(f,meshId,arrId,fieldId),_array_id_end(arr2Id) +{ + int tmp1,tmp2; + double t1=f->getStartTime(tmp1,tmp2); + double t2=f->getEndTime(tmp1,tmp2); + _start=t1; + _end=t2; +} + +MEDCouplingDefinitionTime::MEDCouplingDefinitionTime():_eps(EPS_DFT) +{ +} + +MEDCouplingDefinitionTime::MEDCouplingDefinitionTime(const std::vector& fs, const std::vector& meshRefs, const std::vector >& arrRefs) throw(INTERP_KERNEL::Exception) +{ + std::size_t sz=fs.size(); + if(sz!=arrRefs.size()) + throw INTERP_KERNEL::Exception("MEDCouplingDefinitionTime constructor : internal error ! should never happen !"); + _slices.resize(sz); + for(std::size_t i=0;igetTimeTolerance(); + for(std::size_t i=1;iisAfterMe(_slices[i],_eps)) + throw INTERP_KERNEL::Exception("MEDCouplingDefinitionTime constructors : the sequences of fields does NOT defines a stricly ascendant monotonic time sequence !"); + // double t1=ref->getEndTime(); + // double t2=_slices[i]->getStartTime(); + // if(fabs(t1-t2)<_eps) + // if(ref->getEndId() != _slices[i]->getStartId()) + // throw INTERP_KERNEL::Exception("MEDCouplingDefinitionTime constructor : 2 slices refers to the same time and underlying arrays differs !"); + ref=_slices[i]; + } +} + +void MEDCouplingDefinitionTime::assign(const MEDCouplingDefinitionTime& other) +{ + std::size_t sz=other._slices.size(); + _slices.resize(sz); + for(std::size_t i=0;icopy(); +} + +bool MEDCouplingDefinitionTime::isEqual(const MEDCouplingDefinitionTime& other) const +{ + std::size_t sz=_slices.size(); + if(sz!=other._slices.size()) + return false; + for(std::size_t i=0;iisEqual(*other._slices[i],_eps)) + return false; + return true; +} + +void MEDCouplingDefinitionTime::getIdsOnTimeRight(double tm, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception) +{ + std::vector meshIds; + std::vector arrIds; + std::vector arrIdsInField; + std::vector fieldIds; + getIdsOnTime(tm,meshIds,arrIds,arrIdsInField,fieldIds); + meshId=meshIds.back(); + arrId=arrIds.back(); + arrIdInField=arrIdsInField.back(); + fieldId=fieldIds.back(); +} + +void MEDCouplingDefinitionTime::getIdsOnTimeLeft(double tm, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception) +{ + std::vector meshIds; + std::vector arrIds; + std::vector arrIdsInField; + std::vector fieldIds; + getIdsOnTime(tm,meshIds,arrIds,arrIdsInField,fieldIds); + meshId=meshIds.front(); + arrId=arrIds.front(); + arrIdInField=arrIdsInField.front(); + fieldId=fieldIds.front(); +} + +void MEDCouplingDefinitionTime::getIdsOnTime(double tm, std::vector& meshIds, std::vector& arrIds, std::vector& arrIdsInField, std::vector& fieldIds) const throw(INTERP_KERNEL::Exception) +{ + std::vector ids; + int id=0; + for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator 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 !"); + int sz=ids.size(); + if(sz>2) + throw INTERP_KERNEL::Exception("MEDCouplingDefinitionTime::getIdsOnTime : Too many slices match this time !"); + // + meshIds.resize(sz); + arrIds.resize(sz); + arrIdsInField.resize(sz); + fieldIds.resize(sz); + for(int i=0;igetIdsOnTime(tm,_eps,meshIds[i],arrIds[i],arrIdsInField[i],fieldIds[i]); +} + +std::vector MEDCouplingDefinitionTime::getHotSpotsTime() const +{ + std::vector ret; + for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_slices.begin();it!=_slices.end();it++) + { + std::vector tmp; + (*it)->getHotSpotsTime(tmp); + if(!ret.empty()) + { + if(fabs(ret.back()-tmp.front())>_eps) + ret.insert(ret.end(),tmp.begin(),tmp.end()); + else + ret.insert(ret.end(),tmp.begin()+1,tmp.end()); + } + else + ret.insert(ret.end(),tmp.begin(),tmp.end()); + } + return ret; +} + +void MEDCouplingDefinitionTime::appendRepr(std::ostream& stream) const +{ + stream << "Time definition :\n"; + for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_slices.begin();it!=_slices.end();it++) + { + stream << " - "; + (*it)->appendRepr(stream); + stream << std::endl; + } +} + +void MEDCouplingDefinitionTime::getTinySerializationInformation(std::vector& tinyInfoI, std::vector& tinyInfoD) const +{ + int sz=_slices.size(); + tinyInfoD.resize(1); + tinyInfoD[0]=_eps; + tinyInfoI.resize(3*sz+2); + tinyInfoI[0]=sz; + std::vector coreData; + for(int i=0;i tmp1; + std::vector tmp2; + tinyInfoI[i+2]=(int)_slices[i]->getTimeType(); + _slices[i]->getTinySerializationInformation(tmp1,tmp2); + tinyInfoI[i+sz+2]=tmp1.size(); + tinyInfoI[i+2*sz+2]=tmp2.size(); + coreData.insert(coreData.end(),tmp1.begin(),tmp1.end()); + tinyInfoD.insert(tinyInfoD.end(),tmp2.begin(),tmp2.end()); + } + tinyInfoI[1]=coreData.size(); + tinyInfoI.insert(tinyInfoI.end(),coreData.begin(),coreData.end()); +} + +void MEDCouplingDefinitionTime::unserialize(const std::vector& tinyInfoI, const std::vector& tinyInfoD) +{ + int 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); + MEDCouplingDefinitionTimeSlice *pt=MEDCouplingDefinitionTimeSlice::New(ty,tmp1,tmp2); + _slices[i]=pt; + offset1+=sz1; + offset2+=sz2; + } +} + diff --git a/src/MEDCoupling/MEDCouplingDefinitionTime.hxx b/src/MEDCoupling/MEDCouplingDefinitionTime.hxx new file mode 100644 index 000000000..dbe8e2320 --- /dev/null +++ b/src/MEDCoupling/MEDCouplingDefinitionTime.hxx @@ -0,0 +1,162 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef __PARAMEDMEM_MEDCOUPLINGDEFINITIONTIME_HXX__ +#define __PARAMEDMEM_MEDCOUPLINGDEFINITIONTIME_HXX__ + +#include "MEDCouplingRefCountObject.hxx" +#include "MEDCouplingAutoRefCountObjectPtr.hxx" + +#include "InterpKernelException.hxx" + +#include +#include + +namespace ParaMEDMEM +{ + class MEDCouplingFieldDouble; + + class MEDCouplingDefinitionTimeSlice : public RefCountObject + { + public: + static MEDCouplingDefinitionTimeSlice *New(const MEDCouplingFieldDouble *f, int meshId, const std::vector& arrId, int fieldId) throw(INTERP_KERNEL::Exception); + static MEDCouplingDefinitionTimeSlice *New(TypeOfTimeDiscretization type, const std::vector& tiI, const std::vector& tiD) throw(INTERP_KERNEL::Exception); + int getArrayId() const { return _array_id; } + virtual MEDCouplingDefinitionTimeSlice *copy() const = 0; + virtual bool isEqual(const MEDCouplingDefinitionTimeSlice& other, double eps) const; + virtual void getHotSpotsTime(std::vector& ret) const = 0; + virtual void getIdsOnTime(double tm, double eps, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception) = 0; + virtual bool isContaining(double tmp, double eps) const = 0; + virtual int getStartId() const; + virtual int getEndId() const; + virtual void appendRepr(std::ostream& stream) const; + virtual double getStartTime() const = 0; + virtual double getEndTime() const = 0; + virtual void getTinySerializationInformation(std::vector& tiI, std::vector& tiD) const = 0; + virtual TypeOfTimeDiscretization getTimeType() const = 0; + bool isFullyIncludedInMe(const MEDCouplingDefinitionTimeSlice *other, double eps) const; + bool isOverllapingWithMe(const MEDCouplingDefinitionTimeSlice *other, double eps) const; + bool isAfterMe(const MEDCouplingDefinitionTimeSlice *other, double eps) const; + bool isBeforeMe(const MEDCouplingDefinitionTimeSlice *other, double eps) const; + protected: + MEDCouplingDefinitionTimeSlice() { } + MEDCouplingDefinitionTimeSlice(const MEDCouplingFieldDouble *f, int meshId, int arrId, int fieldId) throw(INTERP_KERNEL::Exception); + protected: + int _mesh_id; + int _array_id; + int _field_id; + }; + + class MEDCouplingDefinitionTimeSliceInst : public MEDCouplingDefinitionTimeSlice + { + public: + static MEDCouplingDefinitionTimeSliceInst *New(const std::vector& tiI, const std::vector& tiD); + 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 throw(INTERP_KERNEL::Exception); + 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; + void unserialize(const std::vector& tiI, const std::vector& tiD); + TypeOfTimeDiscretization getTimeType() const; + public: + MEDCouplingDefinitionTimeSliceInst(const MEDCouplingFieldDouble *f, int meshId, int arrId, int fieldId) throw(INTERP_KERNEL::Exception); + protected: + MEDCouplingDefinitionTimeSliceInst() { } + protected: + double _instant; + }; + + class MEDCouplingDefinitionTimeSliceCstOnTI : public MEDCouplingDefinitionTimeSlice + { + public: + static MEDCouplingDefinitionTimeSliceCstOnTI *New(const std::vector& tiI, const std::vector& tiD); + 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 throw(INTERP_KERNEL::Exception); + 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; + void unserialize(const std::vector& tiI, const std::vector& tiD); + TypeOfTimeDiscretization getTimeType() const; + public: + MEDCouplingDefinitionTimeSliceCstOnTI(const MEDCouplingFieldDouble *f, int meshId, int arrId, int fieldId) throw(INTERP_KERNEL::Exception); + protected: + MEDCouplingDefinitionTimeSliceCstOnTI() { } + protected: + double _start; + double _end; + }; + + class MEDCouplingDefinitionTimeSliceLT : public MEDCouplingDefinitionTimeSlice + { + public: + static MEDCouplingDefinitionTimeSliceLT *New(const std::vector& tiI, const std::vector& tiD); + 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 throw(INTERP_KERNEL::Exception); + 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; + void unserialize(const std::vector& tiI, const std::vector& tiD); + TypeOfTimeDiscretization getTimeType() const; + public: + MEDCouplingDefinitionTimeSliceLT(const MEDCouplingFieldDouble *f, int meshId, int arrId, int arr2Id, int fieldId) throw(INTERP_KERNEL::Exception); + protected: + MEDCouplingDefinitionTimeSliceLT() { } + protected: + int _array_id_end; + double _start; + double _end; + }; + + class MEDCouplingDefinitionTime + { + public: + MEDCouplingDefinitionTime(); + MEDCouplingDefinitionTime(const std::vector& fs, const std::vector& meshRefs, const std::vector >& arrRefs) throw(INTERP_KERNEL::Exception); + void assign(const MEDCouplingDefinitionTime& other); + bool isEqual(const MEDCouplingDefinitionTime& other) const; + double getTimeResolution() const { return _eps; } + void getIdsOnTimeRight(double tm, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception); + void getIdsOnTimeLeft(double tm, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception); + void getIdsOnTime(double tm, std::vector& meshIds, std::vector& arrIds, std::vector& arrIdsInField, std::vector& fieldIds) const throw(INTERP_KERNEL::Exception); + std::vector getHotSpotsTime() const; + void appendRepr(std::ostream& stream) const; + public: + void getTinySerializationInformation(std::vector& tinyInfoI, std::vector& tinyInfoD) const; + void unserialize(const std::vector& tinyInfoI, const std::vector& tinyInfoD); + private: + double _eps; + std::vector< MEDCouplingAutoRefCountObjectPtr > _slices; + static const double EPS_DFT; + }; +} + +#endif diff --git a/src/MEDCoupling/MEDCouplingExtrudedMesh.cxx b/src/MEDCoupling/MEDCouplingExtrudedMesh.cxx index d01e29149..1615957cc 100644 --- a/src/MEDCoupling/MEDCouplingExtrudedMesh.cxx +++ b/src/MEDCoupling/MEDCouplingExtrudedMesh.cxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "MEDCouplingExtrudedMesh.hxx" @@ -104,7 +104,7 @@ MEDCouplingExtrudedMesh::MEDCouplingExtrudedMesh(const MEDCouplingExtrudedMesh& { _mesh2D=other._mesh2D->clone(true); _mesh1D=other._mesh1D->clone(true); - _mesh3D_ids=other._mesh3D_ids->deepCopy(); + _mesh3D_ids=other._mesh3D_ids->deepCpy(); } else { @@ -206,7 +206,16 @@ INTERP_KERNEL::NormalizedCellType MEDCouplingExtrudedMesh::getTypeOfCell(int cel int nbOfCells2D=_mesh2D->getNumberOfCells(); int locId=std::distance(ids,where)%nbOfCells2D; INTERP_KERNEL::NormalizedCellType tmp=_mesh2D->getTypeOfCell(locId); - return INTERP_KERNEL::CellModel::getCellModel(tmp).getExtrudedType(); + return INTERP_KERNEL::CellModel::GetCellModel(tmp).getExtrudedType(); +} + +std::set MEDCouplingExtrudedMesh::getAllGeoTypes() const +{ + const std::set& ret2D=_mesh2D->getAllTypes(); + std::set ret; + for(std::set::const_iterator it=ret2D.begin();it!=ret2D.end();it++) + ret.insert(INTERP_KERNEL::CellModel::GetCellModel(*it).getExtrudedType()); + return ret; } int MEDCouplingExtrudedMesh::getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const @@ -216,7 +225,7 @@ int MEDCouplingExtrudedMesh::getNumberOfCellsWithType(INTERP_KERNEL::NormalizedC for(int i=0;igetTypeOfCell(i); - if(INTERP_KERNEL::CellModel::getCellModel(t).getExtrudedType()==type) + if(INTERP_KERNEL::CellModel::GetCellModel(t).getExtrudedType()==type) ret++; } return ret*_mesh1D->getNumberOfCells(); @@ -257,6 +266,11 @@ std::string MEDCouplingExtrudedMesh::simpleRepr() const { std::ostringstream ret; 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); + 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"; ret << "Number of cells : " << getNumberOfCells() << "(" << _mesh2D->getNumberOfCells() << "x" << _mesh1D->getNumberOfCells() << ")\n"; ret << "1D Mesh info : _____________________\n\n\n"; @@ -269,6 +283,11 @@ std::string MEDCouplingExtrudedMesh::advancedRepr() const { std::ostringstream ret; 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); + 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"; ret << "Number of cells : " << getNumberOfCells() << "(" << _mesh2D->getNumberOfCells() << "x" << _mesh1D->getNumberOfCells() << ")\n"; ret << "1D Mesh info : _____________________\n\n\n"; @@ -282,6 +301,16 @@ void MEDCouplingExtrudedMesh::checkCoherency() const throw (INTERP_KERNEL::Excep { } +void MEDCouplingExtrudedMesh::checkCoherency1(double eps) const throw(INTERP_KERNEL::Exception) +{ + checkCoherency(); +} + +void MEDCouplingExtrudedMesh::checkCoherency2(double eps) const throw(INTERP_KERNEL::Exception) +{ + checkCoherency1(eps); +} + void MEDCouplingExtrudedMesh::getBoundingBox(double *bbox) const { double bbox2D[6]; @@ -304,7 +333,7 @@ void MEDCouplingExtrudedMesh::getBoundingBox(double *bbox) const bbox[2*id+1]+=tmp[id]; } -void MEDCouplingExtrudedMesh::updateTime() +void MEDCouplingExtrudedMesh::updateTime() const { if(_mesh2D) { @@ -323,13 +352,18 @@ void MEDCouplingExtrudedMesh::renumberCells(const int *old2NewBg, bool check) th MEDCouplingUMesh *MEDCouplingExtrudedMesh::build3DUnstructuredMesh() const { - MEDCouplingUMesh *ret=_mesh2D->buildExtrudedMeshFromThis(_mesh1D,0); + MEDCouplingUMesh *ret=_mesh2D->buildExtrudedMesh(_mesh1D,0); const int *renum=_mesh3D_ids->getConstPointer(); ret->renumberCells(renum,false); ret->setName(getName()); return ret; } +MEDCouplingUMesh *MEDCouplingExtrudedMesh::buildUnstructured() const throw(INTERP_KERNEL::Exception) +{ + return build3DUnstructuredMesh(); +} + MEDCouplingFieldDouble *MEDCouplingExtrudedMesh::getMeasureField(bool) const { std::string name="MeasureOfMesh_"; @@ -371,8 +405,7 @@ MEDCouplingFieldDouble *MEDCouplingExtrudedMesh::buildOrthogonalField() const int MEDCouplingExtrudedMesh::getCellContainingPoint(const double *pos, double eps) const { - //not implemented yet - return -1; + throw INTERP_KERNEL::Exception("MEDCouplingExtrudedMesh::getCellContainingPoint : not implemented yet !"); } MEDCouplingExtrudedMesh::~MEDCouplingExtrudedMesh() @@ -494,7 +527,7 @@ void MEDCouplingExtrudedMesh::computeBaryCenterOfFace(const std::vector& no std::transform(zoneToUpdate,zoneToUpdate+3,zoneToUpdate,std::bind2nd(std::multiplies(),(double)(1./nodalConnec.size()))); } -int MEDCouplingExtrudedMesh::findCorrespCellByNodalConn(const std::vector& nodalConnec, const int *revNodalPtr, const int *revNodalIndxPtr) throw(INTERP_KERNEL::Exception) +int MEDCouplingExtrudedMesh::FindCorrespCellByNodalConn(const std::vector& nodalConnec, const int *revNodalPtr, const int *revNodalIndxPtr) throw(INTERP_KERNEL::Exception) { std::vector::const_iterator iter=nodalConnec.begin(); std::set s1(revNodalPtr+revNodalIndxPtr[*iter],revNodalPtr+revNodalIndxPtr[*iter+1]); @@ -528,11 +561,11 @@ int MEDCouplingExtrudedMesh::findCorrespCellByNodalConn(const std::vector& * @param v is the output normalized vector of the common direction of 'm1' and 'm2' * @throw in case that m1 and m2 are not compatible each other. */ -void MEDCouplingExtrudedMesh::project1DMeshes(const MEDCouplingUMesh *m1, const MEDCouplingUMesh *m2, double eps, +void MEDCouplingExtrudedMesh::Project1DMeshes(const MEDCouplingUMesh *m1, const MEDCouplingUMesh *m2, double eps, MEDCouplingUMesh *&m1r, MEDCouplingUMesh *&m2r, double *v) throw(INTERP_KERNEL::Exception) { if(m1->getSpaceDimension()!=3 || m1->getSpaceDimension()!=3) - throw INTERP_KERNEL::Exception("Input meshes are expected to have a spaceDim==3 for projec1D !"); + throw INTERP_KERNEL::Exception("Input meshes are expected to have a spaceDim==3 for Projec1D !"); m1r=m1->clone(true); m2r=m2->clone(true); m1r->changeSpaceDimension(1); @@ -568,6 +601,11 @@ void MEDCouplingExtrudedMesh::scale(const double *point, double factor) _mesh1D->scale(point,factor); } +DataArrayInt *MEDCouplingExtrudedMesh::checkTypeConsistencyAndContig(const std::vector& code, const std::vector& idsPerType) const throw(INTERP_KERNEL::Exception) +{ + throw INTERP_KERNEL::Exception("Not implemented yet !"); +} + MEDCouplingMesh *MEDCouplingExtrudedMesh::buildPart(const int *start, const int *end) const { // not implemented yet ! @@ -580,6 +618,11 @@ MEDCouplingMesh *MEDCouplingExtrudedMesh::buildPartAndReduceNodes(const int *sta return 0; } +DataArrayInt *MEDCouplingExtrudedMesh::simplexize(int policy) throw(INTERP_KERNEL::Exception) +{ + throw INTERP_KERNEL::Exception("MEDCouplingExtrudedMesh::simplexize : unavailable for such a type of mesh : Extruded !"); +} + MEDCouplingMesh *MEDCouplingExtrudedMesh::mergeMyselfWith(const MEDCouplingMesh *other) const { // not implemented yet ! @@ -655,7 +698,7 @@ void MEDCouplingExtrudedMesh::computeExtrusionAlg(const MEDCouplingUMesh *mesh3D std::vector nodalConnec(nodal2D+nodal2DIndx[i]+1,nodal2D+nodal2DIndx[i+1]); try { - idInSubMesh=findCorrespCellByNodalConn(nodalConnec,revNodal2DPtr,revNodalIndx2DPtr); + idInSubMesh=FindCorrespCellByNodalConn(nodalConnec,revNodal2DPtr,revNodalIndx2DPtr); } catch(INTERP_KERNEL::Exception& e) { @@ -675,14 +718,16 @@ void MEDCouplingExtrudedMesh::computeExtrusionAlg(const MEDCouplingUMesh *mesh3D revDescIndx->decrRef(); } -void MEDCouplingExtrudedMesh::getTinySerializationInformation(std::vector& tinyInfo, std::vector& littleStrings) const +void MEDCouplingExtrudedMesh::getTinySerializationInformation(std::vector& tinyInfoD, std::vector& tinyInfo, std::vector& littleStrings) const { std::vector tinyInfo1; std::vector ls1; - _mesh2D->getTinySerializationInformation(tinyInfo1,ls1); + std::vector ls3; + _mesh2D->getTinySerializationInformation(ls3,tinyInfo1,ls1); std::vector tinyInfo2; std::vector ls2; - _mesh1D->getTinySerializationInformation(tinyInfo2,ls2); + std::vector ls4; + _mesh1D->getTinySerializationInformation(ls4,tinyInfo2,ls2); tinyInfo.clear(); littleStrings.clear(); tinyInfo.insert(tinyInfo.end(),tinyInfo1.begin(),tinyInfo1.end()); littleStrings.insert(littleStrings.end(),ls1.begin(),ls1.end()); @@ -692,6 +737,7 @@ void MEDCouplingExtrudedMesh::getTinySerializationInformation(std::vector& tinyInfo.push_back(tinyInfo1.size()); tinyInfo.push_back(_mesh3D_ids->getNbOfElems()); littleStrings.push_back(getName()); + littleStrings.push_back(getDescription()); } void MEDCouplingExtrudedMesh::resizeForUnserialization(const std::vector& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector& littleStrings) const @@ -716,7 +762,7 @@ void MEDCouplingExtrudedMesh::resizeForUnserialization(const std::vector& t // a1->alloc(la1+tinyInfo[sz-1],1); a2->alloc(la2,1); - littleStrings.resize(ls1.size()+ls2.size()+1); + littleStrings.resize(ls1.size()+ls2.size()+2); } void MEDCouplingExtrudedMesh::serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const @@ -741,9 +787,10 @@ void MEDCouplingExtrudedMesh::serialize(DataArrayInt *&a1, DataArrayDouble *&a2) a2_2->decrRef(); } -void MEDCouplingExtrudedMesh::unserialization(const std::vector& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, const std::vector& littleStrings) +void MEDCouplingExtrudedMesh::unserialization(const std::vector& tinyInfoD, const std::vector& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, const std::vector& littleStrings) { - setName(littleStrings.back().c_str()); + setName(littleStrings[littleStrings.size()-2].c_str()); + setDescription(littleStrings.back().c_str()); int sz=tinyInfo.size(); int sz1=tinyInfo[sz-2]; _cell_2D_id=tinyInfo[sz-3]; @@ -761,18 +808,19 @@ void MEDCouplingExtrudedMesh::unserialization(const std::vector& tinyInfo, a2Ptr+=a2tmp->getNbOfElems(); a1Ptr+=a1tmp->getNbOfElems(); ls2.insert(ls2.end(),littleStrings.begin(),littleStrings.begin()+ls1.size()); - _mesh2D->unserialization(ti1,a1tmp,a2tmp,ls2); + std::vector d1(1); + _mesh2D->unserialization(d1,ti1,a1tmp,a2tmp,ls2); a1tmp->decrRef(); a2tmp->decrRef(); // ls2.clear(); - ls2.insert(ls2.end(),littleStrings.begin()+ls1.size(),littleStrings.end()-1); + ls2.insert(ls2.end(),littleStrings.begin()+ls1.size(),littleStrings.end()-2); _mesh1D=MEDCouplingUMesh::New(); a1tmp=DataArrayInt::New(); a2tmp=DataArrayDouble::New(); _mesh1D->resizeForUnserialization(ti2,a1tmp,a2tmp,ls1); std::copy(a2Ptr,a2Ptr+a2tmp->getNbOfElems(),a2tmp->getPointer()); std::copy(a1Ptr,a1Ptr+a1tmp->getNbOfElems(),a1tmp->getPointer()); a1Ptr+=a1tmp->getNbOfElems(); - _mesh1D->unserialization(ti2,a1tmp,a2tmp,ls2); + _mesh1D->unserialization(d1,ti2,a1tmp,a2tmp,ls2); a1tmp->decrRef(); a2tmp->decrRef(); // _mesh3D_ids=DataArrayInt::New(); diff --git a/src/MEDCoupling/MEDCouplingExtrudedMesh.hxx b/src/MEDCoupling/MEDCouplingExtrudedMesh.hxx index 39a0dbf47..926ded6b4 100644 --- a/src/MEDCoupling/MEDCouplingExtrudedMesh.hxx +++ b/src/MEDCoupling/MEDCouplingExtrudedMesh.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __PARAMEDMEM_MEDCOUPLINGEXTRUDEDMESH_HXX__ @@ -52,40 +52,46 @@ namespace ParaMEDMEM void checkDeepEquivalOnSameNodesWith(const MEDCouplingMesh *other, int cellCompPol, double prec, DataArrayInt *&cellCor) const throw(INTERP_KERNEL::Exception); INTERP_KERNEL::NormalizedCellType getTypeOfCell(int cellId) const; + std::set getAllGeoTypes() const; int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const; void getNodeIdsOfCell(int cellId, std::vector& conn) const; void getCoordinatesOfNode(int nodeId, std::vector& coo) const; std::string simpleRepr() const; std::string advancedRepr() const; void checkCoherency() const throw (INTERP_KERNEL::Exception); + void checkCoherency1(double eps=1e-12) const throw(INTERP_KERNEL::Exception); + void checkCoherency2(double eps=1e-12) const throw(INTERP_KERNEL::Exception); void getBoundingBox(double *bbox) const; - void updateTime(); + void updateTime() const; void renumberCells(const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception); MEDCouplingUMesh *getMesh2D() const { return _mesh2D; } MEDCouplingUMesh *getMesh1D() const { return _mesh1D; } DataArrayInt *getMesh3DIds() const { return _mesh3D_ids; } MEDCouplingUMesh *build3DUnstructuredMesh() const; + MEDCouplingUMesh *buildUnstructured() const throw(INTERP_KERNEL::Exception); MEDCouplingFieldDouble *getMeasureField(bool) const; MEDCouplingFieldDouble *getMeasureFieldOnNode(bool) const; MEDCouplingFieldDouble *buildOrthogonalField() const; int getCellContainingPoint(const double *pos, double eps) const; - static int findCorrespCellByNodalConn(const std::vector& nodalConnec, + static int FindCorrespCellByNodalConn(const std::vector& nodalConnec, const int *revNodalPtr, const int *revNodalIndxPtr) throw(INTERP_KERNEL::Exception); - static void project1DMeshes(const MEDCouplingUMesh *m1, const MEDCouplingUMesh *m2, double eps, + static void Project1DMeshes(const MEDCouplingUMesh *m1, const MEDCouplingUMesh *m2, double eps, MEDCouplingUMesh *&m1r, MEDCouplingUMesh *&m2r, double *v) throw(INTERP_KERNEL::Exception); void rotate(const double *center, const double *vector, double angle); void translate(const double *vector); void scale(const double *point, double factor); + DataArrayInt *checkTypeConsistencyAndContig(const std::vector& code, const std::vector& idsPerType) const throw(INTERP_KERNEL::Exception); MEDCouplingMesh *buildPart(const int *start, const int *end) const; MEDCouplingMesh *buildPartAndReduceNodes(const int *start, const int *end, DataArrayInt*& arr) const; + DataArrayInt *simplexize(int policy) throw(INTERP_KERNEL::Exception); MEDCouplingMesh *mergeMyselfWith(const MEDCouplingMesh *other) const; DataArrayDouble *getCoordinatesAndOwner() const; DataArrayDouble *getBarycenterAndOwner() const; //Serialization unserialisation - void getTinySerializationInformation(std::vector& tinyInfo, std::vector& littleStrings) const; + void getTinySerializationInformation(std::vector& tinyInfoD, std::vector& tinyInfo, std::vector& littleStrings) const; void resizeForUnserialization(const std::vector& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector& littleStrings) const; void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const; - void unserialization(const std::vector& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, + void unserialization(const std::vector& tinyInfoD, const std::vector& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, const std::vector& littleStrings); private: MEDCouplingExtrudedMesh(const MEDCouplingUMesh *mesh3D, MEDCouplingUMesh *mesh2D, int cell2DId) throw(INTERP_KERNEL::Exception); diff --git a/src/MEDCoupling/MEDCouplingField.cxx b/src/MEDCoupling/MEDCouplingField.cxx index 41c3029f3..67ef211c1 100644 --- a/src/MEDCoupling/MEDCouplingField.cxx +++ b/src/MEDCoupling/MEDCouplingField.cxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "MEDCouplingField.hxx" @@ -29,6 +29,8 @@ bool MEDCouplingField::isEqual(const MEDCouplingField *other, double meshPrec, d return false; if(_desc!=other->_desc) return false; + if(_nature!=other->_nature) + return false; if(!_type->isEqual(other->_type,valsPrec)) return false; if(_mesh==0 && other->_mesh==0) @@ -44,6 +46,8 @@ bool MEDCouplingField::isEqualWithoutConsideringStr(const MEDCouplingField *othe { if(!_type->isEqualWithoutConsideringStr(other->_type,valsPrec)) return false; + if(_nature!=other->_nature) + return false; if(_mesh==0 && other->_mesh==0) return true; if(_mesh==0 || other->_mesh==0) @@ -62,6 +66,8 @@ bool MEDCouplingField::areCompatibleForMerge(const MEDCouplingField *other) cons { if(!_type->isEqual(other->_type,1.)) return false; + if(_nature!=other->_nature) + return false; if(_mesh==other->_mesh) return true; return _mesh->areCompatibleForMerge(other->_mesh); @@ -75,10 +81,12 @@ bool MEDCouplingField::areStrictlyCompatible(const MEDCouplingField *other) cons { if(!_type->isEqual(other->_type,1.e-12)) return false; + if(_nature!=other->_nature) + return false; return _mesh==other->_mesh; } -void MEDCouplingField::updateTime() +void MEDCouplingField::updateTime() const { if(_mesh) updateTimeWith(*_mesh); @@ -91,6 +99,24 @@ TypeOfField MEDCouplingField::getTypeOfField() const return _type->getEnum(); } +void MEDCouplingField::setNature(NatureOfField nat) throw(INTERP_KERNEL::Exception) +{ + _nature=nat; +} + +/*! + * This method returns is case of success an instance of DataArrayDouble the user is in reponsability to deal with. + * If 'this->_mesh' is not set an exception will be thrown. + * For a field on node the array of coords will be returned. For a field on cell a ParaMEDMEM::DataArrayDouble instance + * containing the barycenter of cells will be returned. And for a field on gauss point the explicit position of gauss points. + */ +DataArrayDouble *MEDCouplingField::getLocalizationOfDiscr() const throw(INTERP_KERNEL::Exception) +{ + if(!_mesh) + throw INTERP_KERNEL::Exception("MEDCouplingField::getLocalizationOfDiscr : No mesh set !"); + return _type->getLocalizationOfDiscValues(_mesh); +} + /*! * This method retrieves the measure field of 'this'. If no '_mesh' is defined an exception will be thrown. * Warning the retrieved field life cycle is the responsability of caller. @@ -244,15 +270,15 @@ MEDCouplingField::~MEDCouplingField() delete _type; } -MEDCouplingField::MEDCouplingField(MEDCouplingFieldDiscretization *type):_mesh(0),_type(type) +MEDCouplingField::MEDCouplingField(MEDCouplingFieldDiscretization *type, NatureOfField nature):_nature(nature),_mesh(0),_type(type) { } -MEDCouplingField::MEDCouplingField(TypeOfField type):_mesh(0),_type(MEDCouplingFieldDiscretization::New(type)) +MEDCouplingField::MEDCouplingField(TypeOfField type):_nature(NoNature),_mesh(0),_type(MEDCouplingFieldDiscretization::New(type)) { } -MEDCouplingField::MEDCouplingField(const MEDCouplingField& other):_name(other._name),_desc(other._desc), +MEDCouplingField::MEDCouplingField(const MEDCouplingField& other):_name(other._name),_desc(other._desc),_nature(other._nature), _mesh(0),_type(other._type->clone()) { if(other._mesh) @@ -270,3 +296,27 @@ MEDCouplingMesh *MEDCouplingField::buildSubMeshData(const int *start, const int { return _type->buildSubMeshData(_mesh,start,end,di); } + +/*! + * This method returns number of tuples expected regarding its discretization and its _mesh attribute. + * This method expected a not null _mesh instance. If null, an exception will be thrown. + */ +int MEDCouplingField::getNumberOfTuplesExpected() const throw(INTERP_KERNEL::Exception) +{ + if(_mesh) + return _type->getNumberOfTuples(_mesh); + else + throw INTERP_KERNEL::Exception("MEDCouplingField::getNumberOfTuplesExpected : Empty mesh !"); +} + +/*! + * This method returns number of mesh placed expected regarding its discretization and its _mesh attribute. + * This method expected a not null _mesh instance. If null, an exception will be thrown. + */ +int MEDCouplingField::getNumberOfMeshPlacesExpected() const throw(INTERP_KERNEL::Exception) +{ + if(_mesh) + return _type->getNumberOfMeshPlaces(_mesh); + else + throw INTERP_KERNEL::Exception("MEDCouplingField::getNumberOfMeshPlacesExpected : Empty mesh !"); +} diff --git a/src/MEDCoupling/MEDCouplingField.hxx b/src/MEDCoupling/MEDCouplingField.hxx index e6eedb5bc..1b27c032c 100644 --- a/src/MEDCoupling/MEDCouplingField.hxx +++ b/src/MEDCoupling/MEDCouplingField.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __PARAMEDMEM_MEDCOUPLINGFIELD_HXX__ @@ -22,6 +22,7 @@ #include "MEDCoupling.hxx" #include "MEDCouplingTimeLabel.hxx" +#include "MEDCouplingNatureOfField.hxx" #include "MEDCouplingRefCountObject.hxx" #include "NormalizedUnstructuredMesh.hxx" #include "InterpKernelException.hxx" @@ -32,6 +33,7 @@ namespace ParaMEDMEM { class DataArrayInt; + class DataArrayDouble; class MEDCouplingMesh; class MEDCouplingFieldDouble; class MEDCouplingFieldDiscretization; @@ -52,9 +54,14 @@ namespace ParaMEDMEM void setDescription(const char *desc) { _desc=desc; } const char *getName() const { return _name.c_str(); } TypeOfField getTypeOfField() const; + NatureOfField getNature() const { return _nature; } + virtual void setNature(NatureOfField nat) throw(INTERP_KERNEL::Exception); + DataArrayDouble *getLocalizationOfDiscr() const throw(INTERP_KERNEL::Exception); MEDCouplingFieldDouble *buildMeasureField(bool isAbs) const throw(INTERP_KERNEL::Exception); MEDCouplingMesh *buildSubMeshData(const int *start, const int *end, DataArrayInt *&di) const; MEDCouplingFieldDiscretization *getDiscretization() const { return _type; } + int getNumberOfTuplesExpected() const throw(INTERP_KERNEL::Exception); + int getNumberOfMeshPlacesExpected() const throw(INTERP_KERNEL::Exception); // Gauss point specific methods void setGaussLocalizationOnType(INTERP_KERNEL::NormalizedCellType type, const std::vector& refCoo, const std::vector& gsCoo, const std::vector& wg) throw(INTERP_KERNEL::Exception); @@ -68,15 +75,16 @@ namespace ParaMEDMEM void getCellIdsHavingGaussLocalization(int locId, std::vector& cellIds) const throw(INTERP_KERNEL::Exception); const MEDCouplingGaussLocalization& getGaussLocalization(int locId) const throw(INTERP_KERNEL::Exception); protected: - void updateTime(); + void updateTime() const; protected: MEDCouplingField(TypeOfField type); MEDCouplingField(const MEDCouplingField& other); - MEDCouplingField(MEDCouplingFieldDiscretization *type); + MEDCouplingField(MEDCouplingFieldDiscretization *type, NatureOfField nature=NoNature); virtual ~MEDCouplingField(); protected: std::string _name; std::string _desc; + NatureOfField _nature; const MEDCouplingMesh *_mesh; MEDCouplingFieldDiscretization *_type; }; diff --git a/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx b/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx index dfa7049cc..d9c573450 100644 --- a/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx +++ b/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx @@ -1,30 +1,35 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "MEDCouplingFieldDiscretization.hxx" #include "MEDCouplingCMesh.hxx" +#include "MEDCouplingUMesh.hxx" #include "MEDCouplingFieldDouble.hxx" -#include "CellModel.hxx" +#include "MEDCouplingAutoRefCountObjectPtr.hxx" +#include "CellModel.hxx" #include "InterpolationUtils.hxx" +#include "InterpKernelAutoPtr.hxx" +#include "InterpKernelGaussCoords.hxx" #include +#include #include #include #include @@ -41,6 +46,8 @@ const char MEDCouplingFieldDiscretizationP1::REPR[]="P1"; const TypeOfField MEDCouplingFieldDiscretizationP1::TYPE=ON_NODES; +const int MEDCouplingFieldDiscretizationPerCell::DFT_INVALID_LOCID_VALUE=-1; + const char MEDCouplingFieldDiscretizationGauss::REPR[]="GAUSS"; const TypeOfField MEDCouplingFieldDiscretizationGauss::TYPE=ON_GAUSS_PT; @@ -92,7 +99,7 @@ bool MEDCouplingFieldDiscretization::isEqualWithoutConsideringStr(const MEDCoupl /*! * Excepted for MEDCouplingFieldDiscretizationPerCell no underlying TimeLabel object : nothing to do in generally. */ -void MEDCouplingFieldDiscretization::updateTime() +void MEDCouplingFieldDiscretization::updateTime() const { } @@ -254,16 +261,17 @@ void MEDCouplingFieldDiscretization::getCellIdsHavingGaussLocalization(int locId throw INTERP_KERNEL::Exception("Invalid method for the corresponding field discretization : available only for GaussPoint discretization !"); } -void MEDCouplingFieldDiscretization::renumberEntitiesFromO2NArr(const int *old2NewPtr, DataArrayDouble *arr, const char *msg) +void MEDCouplingFieldDiscretization::renumberEntitiesFromO2NArr(double eps, const int *old2NewPtr, DataArrayDouble *arr, const char *msg) { int oldNbOfElems=arr->getNumberOfTuples(); int nbOfComp=arr->getNumberOfComponents(); int newNbOfTuples=(*std::max_element(old2NewPtr,old2NewPtr+oldNbOfElems))+1; - DataArrayDouble *arrCpy=arr->deepCopy(); + DataArrayDouble *arrCpy=arr->deepCpy(); const double *ptSrc=arrCpy->getConstPointer(); arr->reAlloc(newNbOfTuples); double *ptToFill=arr->getPointer(); std::fill(ptToFill,ptToFill+nbOfComp*newNbOfTuples,std::numeric_limits::max()); + INTERP_KERNEL::AutoPtr tmp=new double[nbOfComp]; for(int i=0;i()); + std::transform((double *)tmp,((double *)tmp)+nbOfComp,(double *)tmp,std::ptr_fun(fabs)); + //if(!std::equal(ptSrc+i*nbOfComp,ptSrc+(i+1)*nbOfComp,ptToFill+newNb*nbOfComp)) + if(*std::max_element((double *)tmp,((double *)tmp)+nbOfComp)>eps) { arrCpy->decrRef(); std::ostringstream oss; @@ -288,6 +299,21 @@ void MEDCouplingFieldDiscretization::renumberEntitiesFromO2NArr(const int *old2N arrCpy->decrRef(); } +void MEDCouplingFieldDiscretization::renumberEntitiesFromN2OArr(const int *new2OldPtr, int new2OldSz, DataArrayDouble *arr, const char *msg) +{ + int nbOfComp=arr->getNumberOfComponents(); + DataArrayDouble *arrCpy=arr->deepCpy(); + const double *ptSrc=arrCpy->getConstPointer(); + arr->reAlloc(new2OldSz); + double *ptToFill=arr->getPointer(); + for(int i=0;idecrRef(); +} + MEDCouplingFieldDiscretization::~MEDCouplingFieldDiscretization() { } @@ -318,12 +344,26 @@ int MEDCouplingFieldDiscretizationP0::getNumberOfTuples(const MEDCouplingMesh *m return mesh->getNumberOfCells(); } +int MEDCouplingFieldDiscretizationP0::getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const +{ + return mesh->getNumberOfCells(); +} + +DataArrayInt *MEDCouplingFieldDiscretizationP0::getOffsetArr(const MEDCouplingMesh *mesh) const +{ + int nbOfTuples=mesh->getNumberOfCells(); + DataArrayInt *ret=DataArrayInt::New(); + ret->alloc(nbOfTuples+1,1); + ret->iota(0); + return ret; +} + void MEDCouplingFieldDiscretizationP0::renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector& arrays, const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception) { const int *array=old2NewBg; if(check) - array=DataArrayInt::checkAndPreparePermutation(old2NewBg,old2NewBg+mesh->getNumberOfCells()); + array=DataArrayInt::CheckAndPreparePermutation(old2NewBg,old2NewBg+mesh->getNumberOfCells()); for(std::vector::const_iterator it=arrays.begin();it!=arrays.end();it++) { if(*it) @@ -383,16 +423,44 @@ void MEDCouplingFieldDiscretizationP0::getValueOnPos(const DataArrayDouble *arr, arr->getTuple(id,res); } +DataArrayDouble *MEDCouplingFieldDiscretizationP0::getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const +{ + std::vector elts,eltsIndex; + mesh->getCellsContainingPoints(loc,nbOfPoints,_precision,elts,eltsIndex); + int spaceDim=mesh->getSpaceDimension(); + int nbOfComponents=arr->getNumberOfComponents(); + MEDCouplingAutoRefCountObjectPtr ret=DataArrayDouble::New(); + ret->alloc(nbOfPoints,nbOfComponents); + double *ptToFill=ret->getPointer(); + for(int i=0;i=1) + arr->getTuple(elts[eltsIndex[i]],ptToFill); + else + { + std::ostringstream oss; oss << "Point #" << i << " with coordinates : ("; + std::copy(loc+i*spaceDim,loc+(i+1)*spaceDim,std::ostream_iterator(oss,", ")); + oss << ") detected outside mesh : unable to apply P0::getValueOnMulti ! "; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + ret->incrRef(); + return ret; +} + /*! * Nothing to do. It's not a bug. */ -void MEDCouplingFieldDiscretizationP0::renumberValuesOnNodes(const int *, DataArrayDouble *) const +void MEDCouplingFieldDiscretizationP0::renumberValuesOnNodes(double , const int *, DataArrayDouble *) const { } -void MEDCouplingFieldDiscretizationP0::renumberValuesOnCells(const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const +void MEDCouplingFieldDiscretizationP0::renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const { - renumberEntitiesFromO2NArr(old2New,arr,"Cell"); + renumberEntitiesFromO2NArr(epsOnVals,old2New,arr,"Cell"); +} + +void MEDCouplingFieldDiscretizationP0::renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const int *new2old, int newSz, DataArrayDouble *arr) const +{ + renumberEntitiesFromN2OArr(new2old,newSz,arr,"Cell"); } /*! @@ -444,6 +512,20 @@ int MEDCouplingFieldDiscretizationP1::getNumberOfTuples(const MEDCouplingMesh *m return mesh->getNumberOfNodes(); } +int MEDCouplingFieldDiscretizationP1::getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const +{ + return mesh->getNumberOfNodes(); +} + +DataArrayInt *MEDCouplingFieldDiscretizationP1::getOffsetArr(const MEDCouplingMesh *mesh) const +{ + int nbOfTuples=mesh->getNumberOfNodes(); + DataArrayInt *ret=DataArrayInt::New(); + ret->alloc(nbOfTuples+1,1); + ret->iota(0); + return ret; +} + DataArrayDouble *MEDCouplingFieldDiscretizationP1::getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const { return mesh->getCoordinatesAndOwner(); @@ -485,9 +567,18 @@ void MEDCouplingFieldDiscretizationP1::getValueOn(const DataArrayDouble *arr, co INTERP_KERNEL::NormalizedCellType 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); +} + +/*! + * This method localizes a point defined by 'loc' in a cell with id 'cellId' into mesh 'mesh'. + * The result is put into res expected to be of size at least arr->getNumberOfComponents() + */ +void MEDCouplingFieldDiscretizationP1::getValueInCell(const MEDCouplingMesh *mesh, int cellId, const DataArrayDouble *arr, const double *loc, double *res) const +{ std::vector conn; std::vector coo; - mesh->getNodeIdsOfCell(id,conn); + mesh->getNodeIdsOfCell(cellId,conn); for(std::vector::const_iterator iter=conn.begin();iter!=conn.end();iter++) mesh->getCoordinatesOfNode(*iter,coo); int spaceDim=mesh->getSpaceDimension(); @@ -495,19 +586,17 @@ void MEDCouplingFieldDiscretizationP1::getValueOn(const DataArrayDouble *arr, co std::vector vec(nbOfNodes); for(int i=0;i tmp=new double[nbOfNodes]; INTERP_KERNEL::barycentric_coords(vec,loc,tmp); int sz=arr->getNumberOfComponents(); - double *tmp2=new double[sz]; + INTERP_KERNEL::AutoPtr tmp2=new double[sz]; std::fill(res,res+sz,0.); for(int i=0;igetTuple(conn[i],tmp2); - std::transform(tmp2,tmp2+sz,tmp2,std::bind2nd(std::multiplies(),tmp[i])); - std::transform(res,res+sz,tmp2,res,std::plus()); + arr->getTuple(conn[i],(double *)tmp2); + std::transform((double *)tmp2,((double *)tmp2)+sz,(double *)tmp2,std::bind2nd(std::multiplies(),tmp[i])); + std::transform(res,res+sz,(double *)tmp2,res,std::plus()); } - delete [] tmp; - delete [] tmp2; } void MEDCouplingFieldDiscretizationP1::getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const @@ -519,15 +608,45 @@ void MEDCouplingFieldDiscretizationP1::getValueOnPos(const DataArrayDouble *arr, arr->getTuple(id,res); } -void MEDCouplingFieldDiscretizationP1::renumberValuesOnNodes(const int *old2NewPtr, DataArrayDouble *arr) const +DataArrayDouble *MEDCouplingFieldDiscretizationP1::getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const +{ + std::vector elts,eltsIndex; + mesh->getCellsContainingPoints(loc,nbOfPoints,_precision,elts,eltsIndex); + int spaceDim=mesh->getSpaceDimension(); + int nbOfComponents=arr->getNumberOfComponents(); + MEDCouplingAutoRefCountObjectPtr ret=DataArrayDouble::New(); + ret->alloc(nbOfPoints,nbOfComponents); + double *ptToFill=ret->getPointer(); + for(int i=0;i=1) + getValueInCell(mesh,elts[eltsIndex[i]],arr,loc+i*spaceDim,ptToFill+i*nbOfComponents); + else + { + std::ostringstream oss; oss << "Point #" << i << " with coordinates : ("; + std::copy(loc+i*spaceDim,loc+(i+1)*spaceDim,std::ostream_iterator(oss,", ")); + oss << ") detected outside mesh : unable to apply P1::getValueOnMulti ! "; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + ret->incrRef(); + return ret; +} + +void MEDCouplingFieldDiscretizationP1::renumberValuesOnNodes(double epsOnVals, const int *old2NewPtr, DataArrayDouble *arr) const +{ + renumberEntitiesFromO2NArr(epsOnVals,old2NewPtr,arr,"Node"); +} + +/*! + * Nothing to do it's not a bug. + */ +void MEDCouplingFieldDiscretizationP1::renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const { - renumberEntitiesFromO2NArr(old2NewPtr,arr,"Node"); } /*! * Nothing to do it's not a bug. */ -void MEDCouplingFieldDiscretizationP1::renumberValuesOnCells(const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const +void MEDCouplingFieldDiscretizationP1::renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const int *new2old, int newSz, DataArrayDouble *arr) const { } @@ -559,10 +678,10 @@ MEDCouplingFieldDiscretizationPerCell::MEDCouplingFieldDiscretizationPerCell(con { DataArrayInt *arr=other._discr_per_cell; if(arr) - _discr_per_cell=arr->deepCopy(); + _discr_per_cell=arr->deepCpy(); } -void MEDCouplingFieldDiscretizationPerCell::updateTime() +void MEDCouplingFieldDiscretizationPerCell::updateTime() const { if(_discr_per_cell) updateTimeWith(*_discr_per_cell); @@ -610,7 +729,7 @@ void MEDCouplingFieldDiscretizationPerCell::renumberCells(const int *old2NewBg, int nbCells=_discr_per_cell->getNumberOfTuples(); const int *array=old2NewBg; if(check) - array=DataArrayInt::checkAndPreparePermutation(old2NewBg,old2NewBg+nbCells); + array=DataArrayInt::CheckAndPreparePermutation(old2NewBg,old2NewBg+nbCells); // DataArrayInt *dpc=_discr_per_cell->renumber(array); _discr_per_cell->decrRef(); @@ -628,10 +747,24 @@ void MEDCouplingFieldDiscretizationPerCell::buildDiscrPerCellIfNecessary(const M int nbTuples=m->getNumberOfCells(); _discr_per_cell->alloc(nbTuples,1); int *ptr=_discr_per_cell->getPointer(); - std::fill(ptr,ptr+nbTuples,-1); + std::fill(ptr,ptr+nbTuples,DFT_INVALID_LOCID_VALUE); } } +void MEDCouplingFieldDiscretizationPerCell::checkNoOrphanCells() const throw(INTERP_KERNEL::Exception) +{ + if(!_discr_per_cell) + throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationPerCell::checkNoOrphanCells : no discretization defined !"); + MEDCouplingAutoRefCountObjectPtr test=_discr_per_cell->getIdsEqual(DFT_INVALID_LOCID_VALUE); + if(test->getNumberOfTuples()!=0) + throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationPerCell::checkNoOrphanCells : presence of orphan cells !"); +} + +const DataArrayInt *MEDCouplingFieldDiscretizationPerCell::getArrayOfDiscIds() const +{ + return _discr_per_cell; +} + MEDCouplingFieldDiscretizationGauss::MEDCouplingFieldDiscretizationGauss() { } @@ -697,12 +830,30 @@ int MEDCouplingFieldDiscretizationGauss::getNumberOfTuples(const MEDCouplingMesh return ret; } +int MEDCouplingFieldDiscretizationGauss::getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const +{ + return mesh->getNumberOfCells(); +} + +DataArrayInt *MEDCouplingFieldDiscretizationGauss::getOffsetArr(const MEDCouplingMesh *mesh) const +{ + int nbOfTuples=mesh->getNumberOfCells(); + DataArrayInt *ret=DataArrayInt::New(); + ret->alloc(nbOfTuples+1,1); + int *retPtr=ret->getPointer(); + const int *start=_discr_per_cell->getConstPointer(); + retPtr[0]=0; + for(int i=0;i& arrays, const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception) { const int *array=old2NewBg; if(check) - array=DataArrayInt::checkAndPreparePermutation(old2NewBg,old2NewBg+mesh->getNumberOfCells()); + array=DataArrayInt::CheckAndPreparePermutation(old2NewBg,old2NewBg+mesh->getNumberOfCells()); int nbOfCells=_discr_per_cell->getNumberOfTuples(); int nbOfTuples=getNumberOfTuples(0); const int *dcPtr=_discr_per_cell->getConstPointer(); @@ -729,7 +880,44 @@ void MEDCouplingFieldDiscretizationGauss::renumberArraysForCell(const MEDCouplin DataArrayDouble *MEDCouplingFieldDiscretizationGauss::getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const { - throw INTERP_KERNEL::Exception("Not implemented yet !"); + checkNoOrphanCells(); + MEDCouplingAutoRefCountObjectPtr umesh=mesh->buildUnstructured();//in general do nothing + int nbOfTuples=getNumberOfTuples(mesh); + DataArrayDouble *ret=DataArrayDouble::New(); + int spaceDim=mesh->getSpaceDimension(); + ret->alloc(nbOfTuples,spaceDim); + std::vector< std::vector > locIds; + std::vector parts=splitIntoSingleGaussDicrPerCellType(locIds); + std::vector< MEDCouplingAutoRefCountObjectPtr > parts2(parts.size()); + std::copy(parts.begin(),parts.end(),parts2.begin()); + MEDCouplingAutoRefCountObjectPtr offsets=buildNbOfGaussPointPerCellField(); + offsets->computeOffsets(); + const int *ptrOffsets=offsets->getConstPointer(); + const double *coords=umesh->getCoords()->getConstPointer(); + const int *connI=umesh->getNodalConnectivityIndex()->getConstPointer(); + const int *conn=umesh->getNodalConnectivity()->getConstPointer(); + double *valsToFill=ret->getPointer(); + for(std::size_t i=0;i::const_iterator it=locIds[i].begin();it!=locIds[i].end();it++) + { + const MEDCouplingGaussLocalization& cli=_loc[*it];//curLocInfo + INTERP_KERNEL::NormalizedCellType typ=cli.getType(); + const std::vector& wg=cli.getWeights(); + calculator.addGaussInfo(typ,INTERP_KERNEL::CellModel::GetCellModel(typ).getDimension(), + &cli.getGaussCoords()[0],wg.size(),&cli.getRefCoords()[0], + INTERP_KERNEL::CellModel::GetCellModel(typ).getNumberOfNodes()); + } + int nbt=parts2[i]->getNumberOfTuples(); + for(const int *w=parts2[i]->getConstPointer();w!=parts2[i]->getConstPointer()+nbt;w++) + { + const MEDCouplingGaussLocalization& cli=_loc[*w]; + calculator.calculateCoords(cli.getType(),coords,spaceDim,conn+connI[*w]+1,valsToFill+spaceDim*(ptrOffsets[*w])); + } + } + ret->copyStringInfoFrom(*umesh->getCoords()); + return ret; } void MEDCouplingFieldDiscretizationGauss::computeMeshRestrictionFromTupleIds(const MEDCouplingMesh *mesh, const int *partBg, const int *partEnd, @@ -793,7 +981,7 @@ void MEDCouplingFieldDiscretizationGauss::resizeForUnserialization(const std::ve for(int i=0;i tmp(tinyInfo.begin()+3+i*delta,tinyInfo.begin()+3+(i+1)*delta); - MEDCouplingGaussLocalization elt=MEDCouplingGaussLocalization::buildNewInstanceFromTinyInfo(dim,tmp); + MEDCouplingGaussLocalization elt=MEDCouplingGaussLocalization::BuildNewInstanceFromTinyInfo(dim,tmp); _loc.push_back(elt); } } @@ -864,6 +1052,11 @@ void MEDCouplingFieldDiscretizationGauss::getValueOnPos(const DataArrayDouble *a throw INTERP_KERNEL::Exception("getValueOnPos(i,j,k) : Not applyable for Gauss points !"); } +DataArrayDouble *MEDCouplingFieldDiscretizationGauss::getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const +{ + throw INTERP_KERNEL::Exception("getValueOnMulti : Not implemented yet for gauss points !"); +} + MEDCouplingMesh *MEDCouplingFieldDiscretizationGauss::buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const { throw INTERP_KERNEL::Exception("Not implemented yet !"); @@ -872,18 +1065,30 @@ MEDCouplingMesh *MEDCouplingFieldDiscretizationGauss::buildSubMeshData(const MED /*! * No implementation needed ! */ -void MEDCouplingFieldDiscretizationGauss::renumberValuesOnNodes(const int *, DataArrayDouble *) const +void MEDCouplingFieldDiscretizationGauss::renumberValuesOnNodes(double , const int *, DataArrayDouble *) const { } -void MEDCouplingFieldDiscretizationGauss::renumberValuesOnCells(const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const +void MEDCouplingFieldDiscretizationGauss::renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const { throw INTERP_KERNEL::Exception("Not implemented yet !"); } +void MEDCouplingFieldDiscretizationGauss::renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const int *new2old, int 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 !"); +} + void MEDCouplingFieldDiscretizationGauss::setGaussLocalizationOnType(const MEDCouplingMesh *m, INTERP_KERNEL::NormalizedCellType type, const std::vector& refCoo, const std::vector& gsCoo, const std::vector& wg) throw(INTERP_KERNEL::Exception) { + const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(type); + if((int)cm.getDimension()!=m->getMeshDimension()) + { + std::ostringstream oss; oss << "MEDCouplingFieldDiscretizationGauss::setGaussLocalizationOnType : mismatch of dimensions ! MeshDim==" << m->getMeshDimension(); + oss << " whereas Type '" << cm.getRepr() << "' has dimension " << cm.getDimension() << " !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } buildDiscrPerCellIfNecessary(m); int id=_loc.size(); MEDCouplingGaussLocalization elt(type,refCoo,gsCoo,wg); @@ -1001,6 +1206,30 @@ int MEDCouplingFieldDiscretizationGauss::getOffsetOfCell(int cellId) const throw return ret; } +/*! + * This method do the assumption that there is no orphan cell. If there is an exception is thrown. + * This method makes the assumption too that '_discr_per_cell' is defined. If not an exception is thrown. + * This method returns a newly created array with number of tuples equals to '_discr_per_cell->getNumberOfTuples' and number of components equal to 1. + * The i_th tuple in returned array is the number of gauss point if the corresponding cell. + */ +DataArrayInt *MEDCouplingFieldDiscretizationGauss::buildNbOfGaussPointPerCellField() const throw(INTERP_KERNEL::Exception) +{ + if(!_discr_per_cell) + throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGauss::buildNbOfGaussPointPerCellField : no discretization array set !"); + int nbOfTuples=_discr_per_cell->getNumberOfTuples(); + MEDCouplingAutoRefCountObjectPtr ret=DataArrayInt::New(); + const int *w=_discr_per_cell->getConstPointer(); + ret->alloc(nbOfTuples,1); + int *valsToFill=ret->getPointer(); + for(int i=0;iincrRef(); + return ret; +} + /*! * This method makes the assumption that _discr_per_cell is set. * This method reduces as much as possible number size of _loc. @@ -1036,6 +1265,68 @@ void MEDCouplingFieldDiscretizationGauss::zipGaussLocalizations() _loc=tmpLoc; } +/*! + * This method is usefull when 'this' describes a field discretization with several gauss discretization on a \b same cell type. + * For example same NORM_TRI3 cells having 6 gauss points and others with 12 gauss points. + * This method returns 2 arrays with same size : the return value and 'locIds' output parameter. + * For a given i into [0,locIds.size) ret[i] represents the set of cell ids of i_th set an locIds[i] represents the set of discretisation of the set. + * The return vector contains a set of newly created instance to deal with. + * The returned vector represents a \b partition of cells ids with a gauss discretization set. + * + * If no descretization is set in 'this' and exception will be thrown. + */ +std::vector MEDCouplingFieldDiscretizationGauss::splitIntoSingleGaussDicrPerCellType(std::vector< std::vector >& locIds) const throw(INTERP_KERNEL::Exception) +{ + if(!_discr_per_cell) + throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGauss::splitIntoSingleGaussDicrPerCellType : no descretization set !"); + locIds.clear(); + std::vector ret; + const int *discrPerCell=_discr_per_cell->getConstPointer(); + MEDCouplingAutoRefCountObjectPtr ret2=_discr_per_cell->getIdsNotEqual(-1); + int nbOfTuplesSet=ret2->getNumberOfTuples(); + std::list idsRemaining(ret2->getConstPointer(),ret2->getConstPointer()+nbOfTuplesSet); + std::list::iterator it=idsRemaining.begin(); + while(it!=idsRemaining.end()) + { + std::vector ids; + std::set curLocIds; + std::set curCellTypes; + while(it!=idsRemaining.end()) + { + int curDiscrId=discrPerCell[*it]; + INTERP_KERNEL::NormalizedCellType typ=_loc[curDiscrId].getType(); + if(curCellTypes.find(typ)!=curCellTypes.end()) + { + if(curLocIds.find(curDiscrId)!=curLocIds.end()) + { + curLocIds.insert(curDiscrId); + curCellTypes.insert(typ); + ids.push_back(*it); + it=idsRemaining.erase(it); + } + else + it++; + } + else + { + curLocIds.insert(curDiscrId); + curCellTypes.insert(typ); + ids.push_back(*it); + it=idsRemaining.erase(it); + } + } + it=idsRemaining.begin(); + ret.resize(ret.size()+1); + DataArrayInt *part=DataArrayInt::New(); + part->alloc(ids.size(),1); + std::copy(ids.begin(),ids.end(),part->getPointer()); + ret.back()=part; + locIds.resize(locIds.size()+1); + locIds.back().insert(locIds.back().end(),curLocIds.begin(),curLocIds.end()); + } + return ret; +} + MEDCouplingFieldDiscretizationGaussNE::MEDCouplingFieldDiscretizationGaussNE() { } @@ -1068,7 +1359,7 @@ int MEDCouplingFieldDiscretizationGaussNE::getNumberOfTuples(const MEDCouplingMe for(int i=0;igetTypeOfCell(i); - const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::getCellModel(type); + 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 !"); ret+=cm.getNumberOfNodes(); @@ -1076,12 +1367,35 @@ int MEDCouplingFieldDiscretizationGaussNE::getNumberOfTuples(const MEDCouplingMe return ret; } +int MEDCouplingFieldDiscretizationGaussNE::getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const +{ + return mesh->getNumberOfCells(); +} + +DataArrayInt *MEDCouplingFieldDiscretizationGaussNE::getOffsetArr(const MEDCouplingMesh *mesh) const +{ + int nbOfTuples=mesh->getNumberOfCells(); + DataArrayInt *ret=DataArrayInt::New(); + ret->alloc(nbOfTuples+1,1); + int *retPtr=ret->getPointer(); + retPtr[0]=0; + for(int i=0;igetTypeOfCell(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 !"); + retPtr[i+1]=retPtr[i]+cm.getNumberOfNodes(); + } + return ret; +} + void MEDCouplingFieldDiscretizationGaussNE::renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector& arrays, const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception) { const int *array=old2NewBg; if(check) - array=DataArrayInt::checkAndPreparePermutation(old2NewBg,old2NewBg+mesh->getNumberOfCells()); + array=DataArrayInt::CheckAndPreparePermutation(old2NewBg,old2NewBg+mesh->getNumberOfCells()); int nbOfCells=mesh->getNumberOfCells(); int nbOfTuples=getNumberOfTuples(mesh); int *array2=new int[nbOfTuples];//stores the final conversion array old2New to give to arrays in renumberInPlace. @@ -1090,14 +1404,14 @@ void MEDCouplingFieldDiscretizationGaussNE::renumberArraysForCell(const MEDCoupl for(int i=1;igetTypeOfCell(std::distance(array,std::find(array,array+nbOfCells,i-1))); - const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::getCellModel(type); + const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(type); array3[i]=array3[i-1]+cm.getNumberOfNodes(); } int j=0; for(int i=0;igetTypeOfCell(i); - const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::getCellModel(type); + const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(type); for(int k=0;k<(int)cm.getNumberOfNodes();k++,j++) array2[j]=array3[array[i]]+k; } @@ -1132,7 +1446,7 @@ double MEDCouplingFieldDiscretizationGaussNE::getIJK(const MEDCouplingMesh *mesh for(int i=0;igetTypeOfCell(i); - const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::getCellModel(type); + const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(type); offset+=cm.getNumberOfNodes(); } return da->getIJ(offset+nodeIdInCell,compoId); @@ -1163,6 +1477,11 @@ void MEDCouplingFieldDiscretizationGaussNE::getValueOnPos(const DataArrayDouble throw INTERP_KERNEL::Exception("getValueOnPos(i,j,k) : Not applyable for Gauss points !"); } +DataArrayDouble *MEDCouplingFieldDiscretizationGaussNE::getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const +{ + throw INTERP_KERNEL::Exception("getValueOnMulti : Not implemented for Gauss NE !"); +} + MEDCouplingMesh *MEDCouplingFieldDiscretizationGaussNE::buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const { throw INTERP_KERNEL::Exception("Not implemented yet !"); @@ -1171,11 +1490,16 @@ MEDCouplingMesh *MEDCouplingFieldDiscretizationGaussNE::buildSubMeshData(const M /*! * No implementation needed ! */ -void MEDCouplingFieldDiscretizationGaussNE::renumberValuesOnNodes(const int *, DataArrayDouble *) const +void MEDCouplingFieldDiscretizationGaussNE::renumberValuesOnNodes(double , const int *, DataArrayDouble *) const { } -void MEDCouplingFieldDiscretizationGaussNE::renumberValuesOnCells(const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const +void MEDCouplingFieldDiscretizationGaussNE::renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const +{ + throw INTERP_KERNEL::Exception("Not implemented yet !"); +} + +void MEDCouplingFieldDiscretizationGaussNE::renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const int *new2old, int newSz, DataArrayDouble *arr) const { throw INTERP_KERNEL::Exception("Not implemented yet !"); } diff --git a/src/MEDCoupling/MEDCouplingFieldDiscretization.hxx b/src/MEDCoupling/MEDCouplingFieldDiscretization.hxx index 316fa753d..240619acd 100644 --- a/src/MEDCoupling/MEDCouplingFieldDiscretization.hxx +++ b/src/MEDCoupling/MEDCouplingFieldDiscretization.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __PARAMEDMEM_MEDCOUPLINGFIELDDISCRETIZATION_HXX__ @@ -42,7 +42,7 @@ namespace ParaMEDMEM static MEDCouplingFieldDiscretization *New(TypeOfField type); double getPrecision() const { return _precision; } void setPrecision(double val) { _precision=val; } - void updateTime(); + void updateTime() const; static TypeOfField getTypeOfFieldFromStringRepr(const char *repr) throw(INTERP_KERNEL::Exception); virtual TypeOfField getEnum() const = 0; virtual bool isEqual(const MEDCouplingFieldDiscretization *other, double eps) const = 0; @@ -50,6 +50,8 @@ namespace ParaMEDMEM virtual MEDCouplingFieldDiscretization *clone() const = 0; virtual const char *getStringRepr() const = 0; virtual int getNumberOfTuples(const MEDCouplingMesh *mesh) const = 0; + virtual int getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const = 0; + virtual DataArrayInt *getOffsetArr(const MEDCouplingMesh *mesh) const = 0; virtual void normL1(const MEDCouplingMesh *mesh, const DataArrayDouble *arr, double *res) const throw(INTERP_KERNEL::Exception); virtual void normL2(const MEDCouplingMesh *mesh, const DataArrayDouble *arr, double *res) const throw(INTERP_KERNEL::Exception); virtual void integral(const MEDCouplingMesh *mesh, const DataArrayDouble *arr, bool isWAbs, double *res) const throw(INTERP_KERNEL::Exception); @@ -65,9 +67,11 @@ namespace ParaMEDMEM virtual MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const = 0; virtual void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const = 0; virtual void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const = 0; + virtual DataArrayDouble *getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const = 0; virtual MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const = 0; - virtual void renumberValuesOnNodes(const int *old2New, DataArrayDouble *arr) const = 0; - virtual void renumberValuesOnCells(const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const = 0; + virtual void renumberValuesOnNodes(double epsOnVals, const int *old2New, DataArrayDouble *arr) const = 0; + virtual void renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const = 0; + virtual void renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const int *new2old, int newSz, DataArrayDouble *arr) const = 0; virtual void getSerializationIntArray(DataArrayInt *& arr) const; virtual void getTinySerializationIntInformation(std::vector& tinyInfo) const; virtual void getTinySerializationDbleInformation(std::vector& tinyInfo) const; @@ -87,7 +91,8 @@ namespace ParaMEDMEM virtual ~MEDCouplingFieldDiscretization(); protected: MEDCouplingFieldDiscretization(); - static void renumberEntitiesFromO2NArr(const int *old2NewPtr, DataArrayDouble *arr, const char *msg); + static void renumberEntitiesFromO2NArr(double epsOnVals, const int *old2NewPtr, DataArrayDouble *arr, const char *msg); + static void renumberEntitiesFromN2OArr(const int *new2OldPtr, int new2OldSz, DataArrayDouble *arr, const char *msg); protected: double _precision; static const double DFLT_PRECISION; @@ -101,6 +106,8 @@ namespace ParaMEDMEM const char *getStringRepr() const; bool isEqual(const MEDCouplingFieldDiscretization *other, double eps) const; int getNumberOfTuples(const MEDCouplingMesh *mesh) const; + int getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const; + DataArrayInt *getOffsetArr(const MEDCouplingMesh *mesh) const; void renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector& arrays, const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception); DataArrayDouble *getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const; @@ -111,8 +118,10 @@ namespace ParaMEDMEM MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const; void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const; void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const; - void renumberValuesOnNodes(const int *old2New, DataArrayDouble *arr) const; - void renumberValuesOnCells(const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const; + DataArrayDouble *getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const; + void renumberValuesOnNodes(double epsOnVals, const int *old2New, DataArrayDouble *arr) const; + void renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const; + void renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const int *new2old, int newSz, DataArrayDouble *arr) const; MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const; public: static const char REPR[]; @@ -127,6 +136,8 @@ namespace ParaMEDMEM const char *getStringRepr() const; bool isEqual(const MEDCouplingFieldDiscretization *other, double eps) const; int getNumberOfTuples(const MEDCouplingMesh *mesh) const; + int getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const; + DataArrayInt *getOffsetArr(const MEDCouplingMesh *mesh) const; void renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector& arrays, const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception); DataArrayDouble *getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const; @@ -137,9 +148,13 @@ namespace ParaMEDMEM MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const; void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const; void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const; + DataArrayDouble *getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const; MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const; - void renumberValuesOnNodes(const int *old2New, DataArrayDouble *arr) const; - void renumberValuesOnCells(const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const; + void renumberValuesOnNodes(double epsOnVals, const int *old2New, DataArrayDouble *arr) const; + void renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const; + void renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const int *new2old, int newSz, DataArrayDouble *arr) const; + protected: + void getValueInCell(const MEDCouplingMesh *mesh, int cellId, const DataArrayDouble *arr, const double *loc, double *res) const; public: static const char REPR[]; static const TypeOfField TYPE; @@ -151,19 +166,23 @@ namespace ParaMEDMEM */ class MEDCOUPLING_EXPORT MEDCouplingFieldDiscretizationPerCell : public MEDCouplingFieldDiscretization { + public: + const DataArrayInt *getArrayOfDiscIds() const; protected: MEDCouplingFieldDiscretizationPerCell(); MEDCouplingFieldDiscretizationPerCell(const MEDCouplingFieldDiscretizationPerCell& other); ~MEDCouplingFieldDiscretizationPerCell(); - void updateTime(); + void updateTime() const; void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception); bool isEqual(const MEDCouplingFieldDiscretization *other, double eps) const; bool isEqualWithoutConsideringStr(const MEDCouplingFieldDiscretization *other, double eps) const; void renumberCells(const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception); + void checkNoOrphanCells() const throw(INTERP_KERNEL::Exception); protected: void buildDiscrPerCellIfNecessary(const MEDCouplingMesh *m); protected: DataArrayInt *_discr_per_cell; + static const int DFT_INVALID_LOCID_VALUE; }; class MEDCOUPLING_EXPORT MEDCouplingFieldDiscretizationGauss : public MEDCouplingFieldDiscretizationPerCell @@ -176,6 +195,8 @@ namespace ParaMEDMEM MEDCouplingFieldDiscretization *clone() const; const char *getStringRepr() const; int getNumberOfTuples(const MEDCouplingMesh *mesh) const; + int getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const; + DataArrayInt *getOffsetArr(const MEDCouplingMesh *mesh) const; void renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector& arrays, const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception); DataArrayDouble *getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const; @@ -192,9 +213,11 @@ namespace ParaMEDMEM MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const; void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const; void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const; + DataArrayDouble *getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const; MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const; - void renumberValuesOnNodes(const int *old2New, DataArrayDouble *arr) const; - void renumberValuesOnCells(const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const; + void renumberValuesOnNodes(double epsOnVals, const int *old2New, DataArrayDouble *arr) const; + void renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const; + void renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const int *new2old, int newSz, DataArrayDouble *arr) const; void setGaussLocalizationOnType(const MEDCouplingMesh *m, INTERP_KERNEL::NormalizedCellType type, const std::vector& refCoo, const std::vector& gsCoo, const std::vector& wg) throw(INTERP_KERNEL::Exception); void setGaussLocalizationOnCells(const MEDCouplingMesh *m, const int *begin, const int *end, const std::vector& refCoo, @@ -206,6 +229,8 @@ namespace ParaMEDMEM int getGaussLocalizationIdOfOneType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception); void getCellIdsHavingGaussLocalization(int locId, std::vector& cellIds) const throw(INTERP_KERNEL::Exception); const MEDCouplingGaussLocalization& getGaussLocalization(int locId) const throw(INTERP_KERNEL::Exception); + std::vector splitIntoSingleGaussDicrPerCellType(std::vector< std::vector >& locIds) const throw(INTERP_KERNEL::Exception); + DataArrayInt *buildNbOfGaussPointPerCellField() const throw(INTERP_KERNEL::Exception); protected: MEDCouplingFieldDiscretizationGauss(const MEDCouplingFieldDiscretizationGauss& other); void zipGaussLocalizations(); @@ -230,6 +255,8 @@ namespace ParaMEDMEM const char *getStringRepr() const; bool isEqual(const MEDCouplingFieldDiscretization *other, double eps) const; int getNumberOfTuples(const MEDCouplingMesh *mesh) const; + int getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const; + DataArrayInt *getOffsetArr(const MEDCouplingMesh *mesh) const; void renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector& arrays, const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception); DataArrayDouble *getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const; @@ -241,9 +268,11 @@ namespace ParaMEDMEM MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const; void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const; void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const; + DataArrayDouble *getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const; MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const; - void renumberValuesOnNodes(const int *old2New, DataArrayDouble *arr) const; - void renumberValuesOnCells(const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const; + void renumberValuesOnNodes(double epsOnVals, const int *old2New, DataArrayDouble *arr) const; + void renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const; + void renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const int *new2old, int newSz, DataArrayDouble *arr) const; protected: MEDCouplingFieldDiscretizationGaussNE(const MEDCouplingFieldDiscretizationGaussNE& other); public: diff --git a/src/MEDCoupling/MEDCouplingFieldDouble.cxx b/src/MEDCoupling/MEDCouplingFieldDouble.cxx index 2c62b3f44..f5eab6bfe 100644 --- a/src/MEDCoupling/MEDCouplingFieldDouble.cxx +++ b/src/MEDCoupling/MEDCouplingFieldDouble.cxx @@ -1,23 +1,24 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "MEDCouplingFieldDouble.hxx" +#include "MEDCouplingFieldTemplate.hxx" #include "MEDCouplingUMesh.hxx" #include "MEDCouplingTimeDiscretization.hxx" #include "MEDCouplingFieldDiscretization.hxx" @@ -35,6 +36,21 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::New(TypeOfField type, TypeOfTime return new MEDCouplingFieldDouble(type,td); } +MEDCouplingFieldDouble *MEDCouplingFieldDouble::New(const MEDCouplingFieldTemplate *ft, TypeOfTimeDiscretization td) +{ + return new MEDCouplingFieldDouble(ft,td); +} + +void MEDCouplingFieldDouble::setTimeUnit(const char *unit) +{ + _time_discr->setTimeUnit(unit); +} + +const char *MEDCouplingFieldDouble::getTimeUnit() const +{ + return _time_discr->getTimeUnit(); +} + MEDCouplingFieldDouble *MEDCouplingFieldDouble::clone(bool recDeepCpy) const { return new MEDCouplingFieldDouble(*this,recDeepCpy); @@ -52,9 +68,14 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::cloneWithMesh(bool recDeepCpy) c return ret; } +MEDCouplingFieldDouble *MEDCouplingFieldDouble::deepCpy() const +{ + return cloneWithMesh(true); +} + MEDCouplingFieldDouble *MEDCouplingFieldDouble::buildNewTimeReprFromThis(TypeOfTimeDiscretization td, bool deepCpy) const { - MEDCouplingTimeDiscretization *tdo=_time_discr->buildNewTimeReprFromThis(_time_discr,td,deepCpy); + MEDCouplingTimeDiscretization *tdo=_time_discr->buildNewTimeReprFromThis(td,deepCpy); MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(getNature(),tdo,_type->clone()); ret->setMesh(getMesh()); ret->setName(getName()); @@ -75,6 +96,17 @@ void MEDCouplingFieldDouble::copyTinyStringsFrom(const MEDCouplingFieldDouble *o } } +/*! + * Copy only times, order, iteration from other. The underlying mesh is not impacted by this method. + */ +void MEDCouplingFieldDouble::copyTinyAttrFrom(const MEDCouplingFieldDouble *other) throw(INTERP_KERNEL::Exception) +{ + if(other) + { + _time_discr->copyTinyAttrFrom(*other->_time_discr); + } +} + std::string MEDCouplingFieldDouble::simpleRepr() const { std::ostringstream ret; @@ -132,8 +164,6 @@ bool MEDCouplingFieldDouble::isEqual(const MEDCouplingField *other, double meshP const MEDCouplingFieldDouble *otherC=dynamic_cast(other); if(!otherC) return false; - if(_nature!=otherC->_nature) - return false; if(!MEDCouplingField::isEqual(other,meshPrec,valsPrec)) return false; if(!_time_discr->isEqual(otherC->_time_discr,valsPrec)) @@ -146,8 +176,6 @@ bool MEDCouplingFieldDouble::isEqualWithoutConsideringStr(const MEDCouplingField const MEDCouplingFieldDouble *otherC=dynamic_cast(other); if(!otherC) return false; - if(_nature!=otherC->_nature) - return false; if(!MEDCouplingField::isEqualWithoutConsideringStr(other,meshPrec,valsPrec)) return false; if(!_time_discr->isEqualWithoutConsideringStr(otherC->_time_discr,valsPrec)) @@ -167,8 +195,6 @@ bool MEDCouplingFieldDouble::areCompatibleForMerge(const MEDCouplingField *other const MEDCouplingFieldDouble *otherC=dynamic_cast(other); if(!otherC) return false; - if(_nature!=otherC->_nature) - return false; if(!_time_discr->areCompatible(otherC->_time_discr)) return false; return true; @@ -185,8 +211,6 @@ bool MEDCouplingFieldDouble::areStrictlyCompatible(const MEDCouplingField *other const MEDCouplingFieldDouble *otherC=dynamic_cast(other); if(!otherC) return false; - if(_nature!=otherC->_nature) - return false; if(!_time_discr->areStrictlyCompatible(otherC->_time_discr)) return false; return true; @@ -203,13 +227,40 @@ bool MEDCouplingFieldDouble::areCompatibleForMul(const MEDCouplingField *other) const MEDCouplingFieldDouble *otherC=dynamic_cast(other); if(!otherC) return false; - if(_nature!=otherC->_nature) - return false; if(!_time_discr->areStrictlyCompatibleForMul(otherC->_time_discr)) return false; return true; } +/*! + * Method with same principle than MEDCouplingFieldDouble::areStrictlyCompatible method except that + * number of components between 'this' and 'other' can be different here (for operator/). + */ +bool MEDCouplingFieldDouble::areCompatibleForDiv(const MEDCouplingField *other) const +{ + if(!MEDCouplingField::areStrictlyCompatible(other)) + return false; + const MEDCouplingFieldDouble *otherC=dynamic_cast(other); + if(!otherC) + return false; + if(!_time_discr->areStrictlyCompatibleForDiv(otherC->_time_discr)) + return false; + return true; +} + +/*! + * This method is invocated before any attempt of melding. This method is very close to areStrictlyCompatible, + * except that 'this' and other can have different number of components. + */ +bool MEDCouplingFieldDouble::areCompatibleForMeld(const MEDCouplingFieldDouble *other) const +{ + if(!MEDCouplingField::areStrictlyCompatible(other)) + return false; + if(!_time_discr->areCompatibleForMeld(other->_time_discr)) + return false; + return true; +} + /*! * This method performs a clone of mesh and a renumbering of underlying cells of it. The number of cells remains the same. * The values of field are impacted in consequence to have the same geometrical field. @@ -263,13 +314,13 @@ void MEDCouplingFieldDouble::renumberNodes(const int *old2NewBg) throw(INTERP_KE * This method performs half job of MEDCouplingFieldDouble::renumberNodes. That is to say no permutation of cells is done on underlying mesh. * That is to say, the field content is changed by this method. */ -void MEDCouplingFieldDouble::renumberNodesWithoutMesh(const int *old2NewBg) throw(INTERP_KERNEL::Exception) +void MEDCouplingFieldDouble::renumberNodesWithoutMesh(const int *old2NewBg, double eps) throw(INTERP_KERNEL::Exception) { std::vector arrays; _time_discr->getArrays(arrays); for(std::vector::const_iterator iter=arrays.begin();iter!=arrays.end();iter++) if(*iter) - _type->renumberValuesOnNodes(old2NewBg,*iter); + _type->renumberValuesOnNodes(eps,old2NewBg,*iter); } /*! @@ -340,18 +391,22 @@ TypeOfTimeDiscretization MEDCouplingFieldDouble::getTimeDiscretization() const return _time_discr->getEnum(); } -MEDCouplingFieldDouble::MEDCouplingFieldDouble(TypeOfField type, TypeOfTimeDiscretization td):MEDCouplingField(type),_nature(NoNature), +MEDCouplingFieldDouble::MEDCouplingFieldDouble(TypeOfField type, TypeOfTimeDiscretization td):MEDCouplingField(type), _time_discr(MEDCouplingTimeDiscretization::New(td)) { } -MEDCouplingFieldDouble::MEDCouplingFieldDouble(const MEDCouplingFieldDouble& other, bool deepCpy):MEDCouplingField(other),_nature(other._nature), +MEDCouplingFieldDouble::MEDCouplingFieldDouble(const MEDCouplingFieldTemplate *ft, TypeOfTimeDiscretization td):MEDCouplingField(*ft), + _time_discr(MEDCouplingTimeDiscretization::New(td)) +{ +} + +MEDCouplingFieldDouble::MEDCouplingFieldDouble(const MEDCouplingFieldDouble& other, bool deepCpy):MEDCouplingField(other), _time_discr(other._time_discr->performCpy(deepCpy)) { } -MEDCouplingFieldDouble::MEDCouplingFieldDouble(NatureOfField n, MEDCouplingTimeDiscretization *td, MEDCouplingFieldDiscretization *type):MEDCouplingField(type), - _nature(n),_time_discr(td) +MEDCouplingFieldDouble::MEDCouplingFieldDouble(NatureOfField n, MEDCouplingTimeDiscretization *td, MEDCouplingFieldDiscretization *type):MEDCouplingField(type,n),_time_discr(td) { } @@ -666,6 +721,8 @@ void MEDCouplingFieldDouble::integral(bool isWAbs, double *res) const throw(INTE void MEDCouplingFieldDouble::getValueOnPos(int i, int j, int k, double *res) const throw(INTERP_KERNEL::Exception) { const DataArrayDouble *arr=_time_discr->getArray(); + if(!_mesh) + throw INTERP_KERNEL::Exception("No mesh underlying this field to perform getValueOnPos"); _type->getValueOnPos(arr,_mesh,i,j,k,res); } @@ -676,9 +733,22 @@ void MEDCouplingFieldDouble::getValueOnPos(int i, int j, int k, double *res) con void MEDCouplingFieldDouble::getValueOn(const double *spaceLoc, double *res) const throw(INTERP_KERNEL::Exception) { const DataArrayDouble *arr=_time_discr->getArray(); + if(!_mesh) + throw INTERP_KERNEL::Exception("No mesh underlying this field to perform getValueOn"); _type->getValueOn(arr,_mesh,spaceLoc,res); } +/*! + * Returns a newly allocated array with 'nbOfPoints' tuples and nb of components equal to 'this->getNumberOfComponents()'. + */ +DataArrayDouble *MEDCouplingFieldDouble::getValueOnMulti(const double *spaceLoc, int nbOfPoints) const throw(INTERP_KERNEL::Exception) +{ + const DataArrayDouble *arr=_time_discr->getArray(); + if(!_mesh) + throw INTERP_KERNEL::Exception("No mesh underlying this field to perform getValueOnMulti"); + return _type->getValueOnMulti(arr,_mesh,spaceLoc,nbOfPoints); +} + /*! * Returns value of 'this' on time 'time' of point 'spaceLoc' using spatial discretization. * If 'time' is not covered by this->_time_discr an exception will be thrown. @@ -687,6 +757,8 @@ void MEDCouplingFieldDouble::getValueOn(const double *spaceLoc, double *res) con void MEDCouplingFieldDouble::getValueOn(const double *spaceLoc, double time, double *res) const throw(INTERP_KERNEL::Exception) { std::vector< const DataArrayDouble *> arrs=_time_discr->getArraysForTime(time); + if(!_mesh) + throw INTERP_KERNEL::Exception("No mesh underlying this field to perform getValueOn"); std::vector res2; for(std::vector< const DataArrayDouble *>::const_iterator iter=arrs.begin();iter!=arrs.end();iter++) { @@ -745,6 +817,32 @@ void MEDCouplingFieldDouble::fillFromAnalytic(int nbOfComp, const char *func) th _time_discr->fillFromAnalytic(loc,nbOfComp,func); } +/*! + * This method is very similar to this one MEDCouplingMesh::fillFromAnalytic2. + * The main difference is that the field as been started to be constructed here. + * An exception is throw if no underlying mesh is set before the call of this method. + */ +void MEDCouplingFieldDouble::fillFromAnalytic2(int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception) +{ + if(!_mesh) + throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::fillFromAnalytic2 : no mesh defined !"); + MEDCouplingAutoRefCountObjectPtr loc=_type->getLocalizationOfDiscValues(_mesh); + _time_discr->fillFromAnalytic2(loc,nbOfComp,func); +} + +/*! + * This method is very similar to this one MEDCouplingMesh::fillFromAnalytic3. + * The main difference is that the field as been started to be constructed here. + * An exception is throw if no underlying mesh is set before the call of this method. + */ +void MEDCouplingFieldDouble::fillFromAnalytic3(int nbOfComp, const std::vector& varsOrder, const char *func) throw(INTERP_KERNEL::Exception) +{ + if(!_mesh) + throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::fillFromAnalytic2 : no mesh defined !"); + MEDCouplingAutoRefCountObjectPtr loc=_type->getLocalizationOfDiscValues(_mesh); + _time_discr->fillFromAnalytic3(loc,nbOfComp,varsOrder,func); +} + /*! * Applyies the function specified by pointer 'func' on each tuples on all arrays contained in _time_discr. * If '*func' returns false during one evaluation an exception will be thrown. @@ -771,17 +869,35 @@ void MEDCouplingFieldDouble::applyFunc(int nbOfComp, double val) * If '*func' fails in evaluation during one evaluation an exception will be thrown. * The field will contain 'nbOfComp' components after the call. */ -void MEDCouplingFieldDouble::applyFunc(int nbOfComp, const char *func) +void MEDCouplingFieldDouble::applyFunc(int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception) { _time_discr->applyFunc(nbOfComp,func); } +/*! + * This method is equivalent to MEDCouplingFieldDouble::applyFunc, except that here components info are used to determine variables position in 'func'. + * If there is vars detected in 'func' that is not in an info on components an exception will be thrown. + */ +void MEDCouplingFieldDouble::applyFunc2(int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception) +{ + _time_discr->applyFunc2(nbOfComp,func); +} + +/*! + * This method is equivalent to MEDCouplingFieldDouble::applyFunc, except that here 'varsOrder' is used to determine variables position in 'func'. + * If there is vars detected in 'func' that is not in 'varsOrder' an exception will be thrown. + */ +void MEDCouplingFieldDouble::applyFunc3(int nbOfComp, const std::vector& varsOrder, const char *func) throw(INTERP_KERNEL::Exception) +{ + _time_discr->applyFunc3(nbOfComp,varsOrder,func); +} + /*! * Applyies the function specified by the string repr 'func' on each tuples on all arrays contained in _time_discr. * If '*func' fails in evaluation during one evaluation an exception will be thrown. * The field will contain exactly the same number of components after the call. */ -void MEDCouplingFieldDouble::applyFunc(const char *func) +void MEDCouplingFieldDouble::applyFunc(const char *func) throw(INTERP_KERNEL::Exception) { _time_discr->applyFunc(func); } @@ -844,7 +960,7 @@ int MEDCouplingFieldDouble::getNumberOfValues() const throw(INTERP_KERNEL::Excep return getArray()->getNbOfElems(); } -void MEDCouplingFieldDouble::updateTime() +void MEDCouplingFieldDouble::updateTime() const { MEDCouplingField::updateTime(); updateTimeWith(*_time_discr); @@ -852,8 +968,8 @@ void MEDCouplingFieldDouble::updateTime() void MEDCouplingFieldDouble::setNature(NatureOfField nat) throw(INTERP_KERNEL::Exception) { + MEDCouplingField::setNature(nat); _type->checkCompatibilityWithNature(nat); - _nature=nat; } double MEDCouplingFieldDouble::getIJK(int cellId, int nodeIdInCell, int compoId) const @@ -871,12 +987,18 @@ void MEDCouplingFieldDouble::setEndArray(DataArrayDouble *array) _time_discr->setEndArray(array,this); } +void MEDCouplingFieldDouble::setArrays(const std::vector& arrs) throw(INTERP_KERNEL::Exception) +{ + _time_discr->setArrays(arrs,this); +} + void MEDCouplingFieldDouble::getTinySerializationStrInformation(std::vector& tinyInfo) const { tinyInfo.clear(); _time_discr->getTinySerializationStrInformation(tinyInfo); tinyInfo.push_back(_name); tinyInfo.push_back(_desc); + tinyInfo.push_back(getTimeUnit()); } /*! @@ -945,8 +1067,9 @@ void MEDCouplingFieldDouble::finishUnserialization(const std::vector& tinyI _nature=(NatureOfField)tinyInfoI[2]; _type->finishUnserialization(tmp2); int nbOfElemS=tinyInfoS.size(); - _name=tinyInfoS[nbOfElemS-2]; - _desc=tinyInfoS[nbOfElemS-1]; + _name=tinyInfoS[nbOfElemS-3]; + _desc=tinyInfoS[nbOfElemS-2]; + setTimeUnit(tinyInfoS[nbOfElemS-1].c_str()); } /*! @@ -969,7 +1092,7 @@ void MEDCouplingFieldDouble::changeUnderlyingMesh(const MEDCouplingMesh *other, if(_mesh==0 || other==0) throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::changeUnderlyingMesh : is expected to operate on not null meshes !"); DataArrayInt *cellCor,*nodeCor; - _mesh->checkGeoEquivalWith(other,levOfCheck,prec,cellCor,nodeCor); + other->checkGeoEquivalWith(_mesh,levOfCheck,prec,cellCor,nodeCor); if(cellCor) { renumberCellsWithoutMesh(cellCor->getConstPointer(),false); @@ -1001,8 +1124,10 @@ void MEDCouplingFieldDouble::substractInPlaceDM(const MEDCouplingFieldDouble *f, /*! * Merge nodes of underlying mesh. In case of some node will be merged the underlying mesh instance will change. + * The first 'eps' stands for geometric approximation. The second 'epsOnVals' is for epsilon on values in case of node merging. + * If 2 nodes distant from less than 'eps' and with value different with more than 'epsOnVals' an exception will be thrown. */ -bool MEDCouplingFieldDouble::mergeNodes(double eps) throw(INTERP_KERNEL::Exception) +bool MEDCouplingFieldDouble::mergeNodes(double eps, double epsOnVals) throw(INTERP_KERNEL::Exception) { const MEDCouplingPointSet *meshC=dynamic_cast(_mesh); if(!meshC) @@ -1017,7 +1142,32 @@ bool MEDCouplingFieldDouble::mergeNodes(double eps) throw(INTERP_KERNEL::Excepti _time_discr->getArrays(arrays); for(std::vector::const_iterator iter=arrays.begin();iter!=arrays.end();iter++) if(*iter) - _type->renumberValuesOnNodes(arr->getConstPointer(),*iter); + _type->renumberValuesOnNodes(epsOnVals,arr->getConstPointer(),*iter); + setMesh(meshC2); + return true; +} + +/*! + * Merge nodes with (barycenter computation) of underlying mesh. In case of some node will be merged the underlying mesh instance will change. + * The first 'eps' stands for geometric approximation. The second 'epsOnVals' is for epsilon on values in case of node merging. + * If 2 nodes distant from less than 'eps' and with value different with more than 'epsOnVals' an exception will be thrown. + */ +bool MEDCouplingFieldDouble::mergeNodes2(double eps, double epsOnVals) throw(INTERP_KERNEL::Exception) +{ + const MEDCouplingPointSet *meshC=dynamic_cast(_mesh); + if(!meshC) + throw INTERP_KERNEL::Exception("Invalid support mesh to apply mergeNodes on it : must be a MEDCouplingPointSet one !"); + MEDCouplingAutoRefCountObjectPtr meshC2((MEDCouplingPointSet *)meshC->deepCpy()); + bool ret; + int ret2; + MEDCouplingAutoRefCountObjectPtr arr=meshC2->mergeNodes2(eps,ret,ret2); + if(!ret)//no nodes have been merged. + return ret; + std::vector arrays; + _time_discr->getArrays(arrays); + for(std::vector::const_iterator iter=arrays.begin();iter!=arrays.end();iter++) + if(*iter) + _type->renumberValuesOnNodes(epsOnVals,arr->getConstPointer(),*iter); setMesh(meshC2); return true; } @@ -1025,8 +1175,9 @@ bool MEDCouplingFieldDouble::mergeNodes(double eps) throw(INTERP_KERNEL::Excepti /*! * This method applyies ParaMEDMEM::MEDCouplingPointSet::zipCoords method on 'this->_mesh' that should be set and of type ParaMEDMEM::MEDCouplingPointSet. * If some nodes have disappeared true is returned. + * 'epsOnVals' stands for epsilon in case of merge of cells. This value is used as tolerance in case the corresponding values differ. */ -bool MEDCouplingFieldDouble::zipCoords() throw(INTERP_KERNEL::Exception) +bool MEDCouplingFieldDouble::zipCoords(double epsOnVals) throw(INTERP_KERNEL::Exception) { const MEDCouplingPointSet *meshC=dynamic_cast(_mesh); if(!meshC) @@ -1040,7 +1191,7 @@ bool MEDCouplingFieldDouble::zipCoords() throw(INTERP_KERNEL::Exception) _time_discr->getArrays(arrays); for(std::vector::const_iterator iter=arrays.begin();iter!=arrays.end();iter++) if(*iter) - _type->renumberValuesOnNodes(arr->getConstPointer(),*iter); + _type->renumberValuesOnNodes(epsOnVals,arr->getConstPointer(),*iter); setMesh(meshC2); return true; } @@ -1050,8 +1201,9 @@ bool MEDCouplingFieldDouble::zipCoords() throw(INTERP_KERNEL::Exception) /*! * This method applyies ParaMEDMEM::MEDCouplingUMesh::zipConnectivityTraducer on 'this->_mesh' that should be set and of type ParaMEDMEM::MEDCouplingUMesh. * The semantic of 'compType' is given in ParaMEDMEM::MEDCouplingUMesh::zipConnectivityTraducer method. + * 'epsOnVals' stands for epsilon in case of merge of cells. This value is used as tolerance in case the corresponding values differ. */ -bool MEDCouplingFieldDouble::zipConnectivity(int compType) throw(INTERP_KERNEL::Exception) +bool MEDCouplingFieldDouble::zipConnectivity(int compType, double epsOnVals) throw(INTERP_KERNEL::Exception) { const MEDCouplingUMesh *meshC=dynamic_cast(_mesh); if(!meshC) @@ -1065,13 +1217,34 @@ bool MEDCouplingFieldDouble::zipConnectivity(int compType) throw(INTERP_KERNEL:: _time_discr->getArrays(arrays); for(std::vector::const_iterator iter=arrays.begin();iter!=arrays.end();iter++) if(*iter) - _type->renumberValuesOnCells(meshC,arr->getConstPointer(),*iter); + _type->renumberValuesOnCells(epsOnVals,meshC,arr->getConstPointer(),*iter); setMesh(meshC2); return true; } return false; } +/*! + * This method applyies ParaMEDMEM::MEDCouplingUMesh::simplexize on 'this->_mesh'. + * The semantic of 'policy' is given in ParaMEDMEM::MEDCouplingUMesh::simplexize method. + */ +bool MEDCouplingFieldDouble::simplexize(int policy) throw(INTERP_KERNEL::Exception) +{ + int oldNbOfCells=_mesh->getNumberOfCells(); + MEDCouplingAutoRefCountObjectPtr meshC2(_mesh->deepCpy()); + MEDCouplingAutoRefCountObjectPtr arr=meshC2->simplexize(policy); + int newNbOfCells=meshC2->getNumberOfCells(); + if(oldNbOfCells==newNbOfCells) + return false; + std::vector arrays; + _time_discr->getArrays(arrays); + for(std::vector::const_iterator iter=arrays.begin();iter!=arrays.end();iter++) + if(*iter) + _type->renumberValuesOnCellsR(_mesh,arr->getConstPointer(),arr->getNbOfElems(),*iter); + setMesh(meshC2); + return true; +} + MEDCouplingFieldDouble *MEDCouplingFieldDouble::doublyContractedProduct() const throw(INTERP_KERNEL::Exception) { MEDCouplingTimeDiscretization *td=_time_discr->doublyContractedProduct(); @@ -1189,14 +1362,15 @@ void MEDCouplingFieldDouble::sortPerTuple(bool asc) throw(INTERP_KERNEL::Excepti _time_discr->sortPerTuple(asc); } -MEDCouplingFieldDouble *MEDCouplingFieldDouble::mergeFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) +MEDCouplingFieldDouble *MEDCouplingFieldDouble::MergeFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception) { if(!f1->areCompatibleForMerge(f2)) - throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply mergeFields on them !"); + throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply MergeFields on them !"); const MEDCouplingMesh *m1=f1->getMesh(); const MEDCouplingMesh *m2=f2->getMesh(); MEDCouplingMesh *m=m1->mergeMyselfWith(m2); MEDCouplingTimeDiscretization *td=f1->_time_discr->aggregate(f2->_time_discr); + td->copyTinyAttrFrom(*f1->_time_discr); MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone()); ret->setMesh(m); m->decrRef(); @@ -1205,10 +1379,51 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::mergeFields(const MEDCouplingFie return ret; } -MEDCouplingFieldDouble *MEDCouplingFieldDouble::dotFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) +MEDCouplingFieldDouble *MEDCouplingFieldDouble::MergeFields(const std::vector& a) throw(INTERP_KERNEL::Exception) +{ + if(a.size()<=1) + throw INTERP_KERNEL::Exception("FieldDouble::MergeFields : size of array must be > 1 !"); + std::vector< MEDCouplingAutoRefCountObjectPtr > ms(a.size()); + std::vector< const MEDCouplingUMesh *> ms2(a.size()); + std::vector< const MEDCouplingTimeDiscretization *> tds(a.size()); + std::vector::const_iterator it=a.begin(); + const MEDCouplingFieldDouble *ref=(*it++); + for(;it!=a.end();it++) + if(!ref->areCompatibleForMerge(*it)) + throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply MergeFields on them !"); + for(int i=0;i<(int)a.size();i++) + { + if(!a[i]->getMesh()) + throw INTERP_KERNEL::Exception("MergeFields : A field as no underlying mesh !"); + ms[i]=a[i]->getMesh()->buildUnstructured(); + ms2[i]=ms[i]; + tds[i]=a[i]->_time_discr; + } + MEDCouplingAutoRefCountObjectPtr m=MEDCouplingUMesh::MergeUMeshes(ms2); + MEDCouplingTimeDiscretization *td=tds[0]->aggregate(tds); + td->copyTinyAttrFrom(*(a[0]->_time_discr)); + MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(a[0]->getNature(),td,a[0]->_type->clone()); + ret->setMesh(m); + ret->setName(a[0]->getName()); + ret->setDescription(a[0]->getDescription()); + return ret; +} + +MEDCouplingFieldDouble *MEDCouplingFieldDouble::MeldFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception) +{ + if(!f1->areCompatibleForMeld(f2)) + throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply MeldFields on them !"); + MEDCouplingTimeDiscretization *td=f1->_time_discr->meld(f2->_time_discr); + td->copyTinyAttrFrom(*f1->_time_discr); + MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone()); + ret->setMesh(f1->getMesh()); + return ret; +} + +MEDCouplingFieldDouble *MEDCouplingFieldDouble::DotFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception) { if(!f1->areStrictlyCompatible(f2)) - throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply dotFields on them !"); + throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply DotFields on them !"); MEDCouplingTimeDiscretization *td=f1->_time_discr->dot(f2->_time_discr); td->copyTinyAttrFrom(*f1->_time_discr); MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone()); @@ -1216,10 +1431,10 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::dotFields(const MEDCouplingField return ret; } -MEDCouplingFieldDouble *MEDCouplingFieldDouble::crossProductFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) +MEDCouplingFieldDouble *MEDCouplingFieldDouble::CrossProductFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception) { if(!f1->areStrictlyCompatible(f2)) - throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply crossProductFields on them !"); + throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply CrossProductFields on them !"); MEDCouplingTimeDiscretization *td=f1->_time_discr->crossProduct(f2->_time_discr); td->copyTinyAttrFrom(*f1->_time_discr); MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone()); @@ -1227,10 +1442,10 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::crossProductFields(const MEDCoup return ret; } -MEDCouplingFieldDouble *MEDCouplingFieldDouble::maxFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) +MEDCouplingFieldDouble *MEDCouplingFieldDouble::MaxFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception) { if(!f1->areStrictlyCompatible(f2)) - throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply maxFields on them !"); + throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply MaxFields on them !"); MEDCouplingTimeDiscretization *td=f1->_time_discr->max(f2->_time_discr); td->copyTinyAttrFrom(*f1->_time_discr); MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone()); @@ -1238,10 +1453,10 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::maxFields(const MEDCouplingField return ret; } -MEDCouplingFieldDouble *MEDCouplingFieldDouble::minFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) +MEDCouplingFieldDouble *MEDCouplingFieldDouble::MinFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception) { if(!f1->areStrictlyCompatible(f2)) - throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply minFields on them !"); + throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply MinFields on them !"); MEDCouplingTimeDiscretization *td=f1->_time_discr->min(f2->_time_discr); td->copyTinyAttrFrom(*f1->_time_discr); MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone()); @@ -1249,10 +1464,10 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::minFields(const MEDCouplingField return ret; } -MEDCouplingFieldDouble *MEDCouplingFieldDouble::addFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) +MEDCouplingFieldDouble *MEDCouplingFieldDouble::AddFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception) { if(!f1->areStrictlyCompatible(f2)) - throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply addFields on them !"); + throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply AddFields on them !"); MEDCouplingTimeDiscretization *td=f1->_time_discr->add(f2->_time_discr); td->copyTinyAttrFrom(*f1->_time_discr); MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone()); @@ -1260,7 +1475,7 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::addFields(const MEDCouplingField return ret; } -const MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator+=(const MEDCouplingFieldDouble& other) +const MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator+=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception) { if(!areStrictlyCompatible(&other)) throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply += on them !"); @@ -1268,10 +1483,10 @@ const MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator+=(const MEDCoupli return *this; } -MEDCouplingFieldDouble *MEDCouplingFieldDouble::substractFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) +MEDCouplingFieldDouble *MEDCouplingFieldDouble::SubstractFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception) { if(!f1->areStrictlyCompatible(f2)) - throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply substractFields on them !"); + throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply SubstractFields on them !"); MEDCouplingTimeDiscretization *td=f1->_time_discr->substract(f2->_time_discr); td->copyTinyAttrFrom(*f1->_time_discr); MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone()); @@ -1279,7 +1494,7 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::substractFields(const MEDCouplin return ret; } -const MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator-=(const MEDCouplingFieldDouble& other) +const MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator-=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception) { if(!areStrictlyCompatible(&other)) throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply -= on them !"); @@ -1287,10 +1502,10 @@ const MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator-=(const MEDCoupli return *this; } -MEDCouplingFieldDouble *MEDCouplingFieldDouble::multiplyFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) +MEDCouplingFieldDouble *MEDCouplingFieldDouble::MultiplyFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception) { if(!f1->areCompatibleForMul(f2)) - throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply multiplyFields on them !"); + throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply MultiplyFields on them !"); MEDCouplingTimeDiscretization *td=f1->_time_discr->multiply(f2->_time_discr); td->copyTinyAttrFrom(*f1->_time_discr); MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone()); @@ -1298,7 +1513,7 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::multiplyFields(const MEDCoupling return ret; } -const MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator*=(const MEDCouplingFieldDouble& other) +const MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator*=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception) { if(!areCompatibleForMul(&other)) throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply *= on them !"); @@ -1306,10 +1521,10 @@ const MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator*=(const MEDCoupli return *this; } -MEDCouplingFieldDouble *MEDCouplingFieldDouble::divideFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) +MEDCouplingFieldDouble *MEDCouplingFieldDouble::DivideFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception) { - if(!f1->areStrictlyCompatible(f2)) - throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply divideFields on them !"); + if(!f1->areCompatibleForDiv(f2)) + throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply DivideFields on them !"); MEDCouplingTimeDiscretization *td=f1->_time_discr->divide(f2->_time_discr); td->copyTinyAttrFrom(*f1->_time_discr); MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone()); @@ -1317,9 +1532,9 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::divideFields(const MEDCouplingFi return ret; } -const MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator/=(const MEDCouplingFieldDouble& other) +const MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator/=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception) { - if(!areStrictlyCompatible(&other)) + if(!areCompatibleForDiv(&other)) throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply /= on them !"); _time_discr->divideEqual(other._time_discr); return *this; diff --git a/src/MEDCoupling/MEDCouplingFieldDouble.hxx b/src/MEDCoupling/MEDCouplingFieldDouble.hxx index 48c0bace0..024cf7847 100644 --- a/src/MEDCoupling/MEDCouplingFieldDouble.hxx +++ b/src/MEDCoupling/MEDCouplingFieldDouble.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __PARAMEDMEM_MEDCOUPLINGFIELDDOUBLE_HXX__ @@ -23,16 +23,21 @@ #include "MEDCoupling.hxx" #include "MEDCouplingField.hxx" #include "MEDCouplingTimeDiscretization.hxx" -#include "MEDCouplingNatureOfField.hxx" #include "MEDCouplingMemArray.hxx" namespace ParaMEDMEM { + class MEDCouplingFieldTemplate; + class MEDCOUPLING_EXPORT MEDCouplingFieldDouble : public MEDCouplingField { public: static MEDCouplingFieldDouble *New(TypeOfField type, TypeOfTimeDiscretization td=NO_TIME); + static MEDCouplingFieldDouble *New(const MEDCouplingFieldTemplate *ft, TypeOfTimeDiscretization td=NO_TIME); + void setTimeUnit(const char *unit); + const char *getTimeUnit() const; void copyTinyStringsFrom(const MEDCouplingFieldDouble *other) throw(INTERP_KERNEL::Exception); + void copyTinyAttrFrom(const MEDCouplingFieldDouble *other) throw(INTERP_KERNEL::Exception); std::string simpleRepr() const; std::string advancedRepr() const; bool isEqual(const MEDCouplingField *other, double meshPrec, double valsPrec) const; @@ -40,20 +45,30 @@ namespace ParaMEDMEM bool areCompatibleForMerge(const MEDCouplingField *other) const; bool areStrictlyCompatible(const MEDCouplingField *other) const; bool areCompatibleForMul(const MEDCouplingField *other) const; + bool areCompatibleForDiv(const MEDCouplingField *other) const; + bool areCompatibleForMeld(const MEDCouplingFieldDouble *other) const; void renumberCells(const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception); void renumberCellsWithoutMesh(const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception); void renumberNodes(const int *old2NewBg) throw(INTERP_KERNEL::Exception); - void renumberNodesWithoutMesh(const int *old2NewBg) throw(INTERP_KERNEL::Exception); + void renumberNodesWithoutMesh(const int *old2NewBg, double eps=1e-15) throw(INTERP_KERNEL::Exception); DataArrayInt *getIdsInRange(double vmin, double vmax) const throw(INTERP_KERNEL::Exception); MEDCouplingFieldDouble *buildSubPart(const DataArrayInt *part) const throw(INTERP_KERNEL::Exception); MEDCouplingFieldDouble *buildSubPart(const int *partBg, const int *partEnd) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *deepCpy() const; MEDCouplingFieldDouble *clone(bool recDeepCpy) const; MEDCouplingFieldDouble *cloneWithMesh(bool recDeepCpy) const; MEDCouplingFieldDouble *buildNewTimeReprFromThis(TypeOfTimeDiscretization td, bool deepCpy) const; TypeOfTimeDiscretization getTimeDiscretization() const; void checkCoherency() const throw(INTERP_KERNEL::Exception); - NatureOfField getNature() const { return _nature; } void setNature(NatureOfField nat) throw(INTERP_KERNEL::Exception); + void setTimeTolerance(double val) { _time_discr->setTimeTolerance(val); } + double getTimeTolerance() const { return _time_discr->getTimeTolerance(); } + void setIteration(int it) throw(INTERP_KERNEL::Exception) { _time_discr->setIteration(it); } + void setEndIteration(int it) throw(INTERP_KERNEL::Exception) { _time_discr->setEndIteration(it); } + void setOrder(int order) throw(INTERP_KERNEL::Exception) { _time_discr->setOrder(order); } + void setEndOrder(int order) throw(INTERP_KERNEL::Exception) { _time_discr->setEndOrder(order); } + void setTimeValue(double val) throw(INTERP_KERNEL::Exception) { _time_discr->setTimeValue(val); } + void setEndTimeValue(double val) throw(INTERP_KERNEL::Exception) { _time_discr->setEndTimeValue(val); } void setTime(double val, int iteration, int order) { _time_discr->setTime(val,iteration,order); } void setStartTime(double val, int iteration, int order) { _time_discr->setStartTime(val,iteration,order); } void setEndTime(double val, int iteration, int order) { _time_discr->setEndTime(val,iteration,order); } @@ -64,8 +79,12 @@ namespace ParaMEDMEM double getIJK(int cellId, int nodeIdInCell, int compoId) const; void setArray(DataArrayDouble *array); void setEndArray(DataArrayDouble *array); - DataArrayDouble *getArray() const { return _time_discr->getArray(); } - DataArrayDouble *getEndArray() const { return _time_discr->getEndArray(); } + void setArrays(const std::vector& arrs) throw(INTERP_KERNEL::Exception); + const DataArrayDouble *getArray() const { return _time_discr->getArray(); } + DataArrayDouble *getArray() { return _time_discr->getArray(); } + const DataArrayDouble *getEndArray() const { return _time_discr->getEndArray(); } + DataArrayDouble *getEndArray() { return _time_discr->getEndArray(); } + std::vector getArrays() const { std::vector ret; _time_discr->getArrays(ret); return ret; } double accumulate(int compId) const; void accumulate(double *res) const; double getMaxValue() const throw(INTERP_KERNEL::Exception); @@ -83,21 +102,26 @@ namespace ParaMEDMEM void getValueOnPos(int i, int j, int k, double *res) const throw(INTERP_KERNEL::Exception); void getValueOn(const double *spaceLoc, double *res) const throw(INTERP_KERNEL::Exception); void getValueOn(const double *spaceLoc, double time, double *res) const throw(INTERP_KERNEL::Exception); + DataArrayDouble *getValueOnMulti(const double *spaceLoc, int nbOfPoints) const throw(INTERP_KERNEL::Exception); //! \b temporary void applyLin(double a, double b, int compoId); MEDCouplingFieldDouble &operator=(double value) throw(INTERP_KERNEL::Exception); void fillFromAnalytic(int nbOfComp, FunctionToEvaluate func) throw(INTERP_KERNEL::Exception); void fillFromAnalytic(int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception); + void fillFromAnalytic2(int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception); + void fillFromAnalytic3(int nbOfComp, const std::vector& varsOrder, const char *func) throw(INTERP_KERNEL::Exception); void applyFunc(int nbOfComp, FunctionToEvaluate func); void applyFunc(int nbOfComp, double val); - void applyFunc(int nbOfComp, const char *func); - void applyFunc(const char *func); + void applyFunc(int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception); + void applyFunc2(int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception); + void applyFunc3(int nbOfComp, const std::vector& varsOrder, const char *func) throw(INTERP_KERNEL::Exception); + void applyFunc(const char *func) throw(INTERP_KERNEL::Exception); void applyFuncFast32(const char *func) throw(INTERP_KERNEL::Exception); void applyFuncFast64(const char *func) throw(INTERP_KERNEL::Exception); int getNumberOfComponents() const throw(INTERP_KERNEL::Exception); int getNumberOfTuples() const throw(INTERP_KERNEL::Exception); int getNumberOfValues() const throw(INTERP_KERNEL::Exception); - void updateTime(); + void updateTime() const; // void getTinySerializationIntInformation(std::vector& tinyInfo) const; void getTinySerializationDbleInformation(std::vector& tinyInfo) const; @@ -108,9 +132,11 @@ namespace ParaMEDMEM // void changeUnderlyingMesh(const MEDCouplingMesh *other, int levOfCheck, double prec) throw(INTERP_KERNEL::Exception); void substractInPlaceDM(const MEDCouplingFieldDouble *f, int levOfCheck, double prec) throw(INTERP_KERNEL::Exception); - bool mergeNodes(double eps) throw(INTERP_KERNEL::Exception); - bool zipCoords() throw(INTERP_KERNEL::Exception); - bool zipConnectivity(int compType) throw(INTERP_KERNEL::Exception); + bool mergeNodes(double eps, double epsOnVals=1e-15) throw(INTERP_KERNEL::Exception); + bool mergeNodes2(double eps, double epsOnVals=1e-15) throw(INTERP_KERNEL::Exception); + bool zipCoords(double epsOnVals=1e-15) throw(INTERP_KERNEL::Exception); + bool zipConnectivity(int compType, double epsOnVals=1e-15) throw(INTERP_KERNEL::Exception); + bool simplexize(int policy) throw(INTERP_KERNEL::Exception); MEDCouplingFieldDouble *doublyContractedProduct() const throw(INTERP_KERNEL::Exception); MEDCouplingFieldDouble *determinant() const throw(INTERP_KERNEL::Exception); MEDCouplingFieldDouble *eigenValues() const throw(INTERP_KERNEL::Exception); @@ -124,34 +150,39 @@ namespace ParaMEDMEM MEDCouplingFieldDouble *keepSelectedComponents(const std::vector& compoIds) const throw(INTERP_KERNEL::Exception); void setSelectedComponents(const MEDCouplingFieldDouble *f, const std::vector& compoIds) throw(INTERP_KERNEL::Exception); void sortPerTuple(bool asc) throw(INTERP_KERNEL::Exception); - static MEDCouplingFieldDouble *mergeFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2); - static MEDCouplingFieldDouble *dotFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2); - MEDCouplingFieldDouble *dot(const MEDCouplingFieldDouble& other) const { return dotFields(this,&other); } - static MEDCouplingFieldDouble *crossProductFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2); - MEDCouplingFieldDouble *crossProduct(const MEDCouplingFieldDouble& other) const { return crossProductFields(this,&other); } - static MEDCouplingFieldDouble *maxFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2); - MEDCouplingFieldDouble *max(const MEDCouplingFieldDouble& other) const { return maxFields(this,&other); } - static MEDCouplingFieldDouble *minFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2); - MEDCouplingFieldDouble *min(const MEDCouplingFieldDouble& other) const { return minFields(this,&other); } - MEDCouplingFieldDouble *operator+(const MEDCouplingFieldDouble& other) const { return addFields(this,&other); } - const MEDCouplingFieldDouble &operator+=(const MEDCouplingFieldDouble& other); - static MEDCouplingFieldDouble *addFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2); - MEDCouplingFieldDouble *operator-(const MEDCouplingFieldDouble& other) const { return substractFields(this,&other); } - const MEDCouplingFieldDouble &operator-=(const MEDCouplingFieldDouble& other); - static MEDCouplingFieldDouble *substractFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2); - MEDCouplingFieldDouble *operator*(const MEDCouplingFieldDouble& other) const { return multiplyFields(this,&other); } - const MEDCouplingFieldDouble &operator*=(const MEDCouplingFieldDouble& other); - static MEDCouplingFieldDouble *multiplyFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2); - MEDCouplingFieldDouble *operator/(const MEDCouplingFieldDouble& other) const { return divideFields(this,&other); } - const MEDCouplingFieldDouble &operator/=(const MEDCouplingFieldDouble& other); - static MEDCouplingFieldDouble *divideFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2); + static MEDCouplingFieldDouble *MergeFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception); + static MEDCouplingFieldDouble *MergeFields(const std::vector& a) throw(INTERP_KERNEL::Exception); + static MEDCouplingFieldDouble *MeldFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception); + static MEDCouplingFieldDouble *DotFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *dot(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return DotFields(this,&other); } + static MEDCouplingFieldDouble *CrossProductFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *crossProduct(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return CrossProductFields(this,&other); } + static MEDCouplingFieldDouble *MaxFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *max(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return MaxFields(this,&other); } + static MEDCouplingFieldDouble *MinFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *min(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return MinFields(this,&other); } + MEDCouplingFieldDouble *operator+(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return AddFields(this,&other); } + const MEDCouplingFieldDouble &operator+=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception); + static MEDCouplingFieldDouble *AddFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *operator-(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return SubstractFields(this,&other); } + const MEDCouplingFieldDouble &operator-=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception); + static MEDCouplingFieldDouble *SubstractFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *operator*(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return MultiplyFields(this,&other); } + const MEDCouplingFieldDouble &operator*=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception); + static MEDCouplingFieldDouble *MultiplyFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *operator/(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return DivideFields(this,&other); } + const MEDCouplingFieldDouble &operator/=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception); + static MEDCouplingFieldDouble *DivideFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception); + public: + const MEDCouplingTimeDiscretization *getTimeDiscretizationUnderGround() const { return _time_discr; } + MEDCouplingTimeDiscretization *getTimeDiscretizationUnderGround() { return _time_discr; } private: MEDCouplingFieldDouble(TypeOfField type, TypeOfTimeDiscretization td); + MEDCouplingFieldDouble(const MEDCouplingFieldTemplate *ft, TypeOfTimeDiscretization td); MEDCouplingFieldDouble(const MEDCouplingFieldDouble& other, bool deepCpy); MEDCouplingFieldDouble(NatureOfField n, MEDCouplingTimeDiscretization *td, MEDCouplingFieldDiscretization *type); ~MEDCouplingFieldDouble(); private: - NatureOfField _nature; MEDCouplingTimeDiscretization *_time_discr; }; } diff --git a/src/MEDCoupling/MEDCouplingFieldOverTime.cxx b/src/MEDCoupling/MEDCouplingFieldOverTime.cxx new file mode 100644 index 000000000..960fd0d0e --- /dev/null +++ b/src/MEDCoupling/MEDCouplingFieldOverTime.cxx @@ -0,0 +1,164 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "MEDCouplingFieldOverTime.hxx" +#include "MEDCouplingMesh.hxx" + +#include + +using namespace ParaMEDMEM; + +MEDCouplingFieldOverTime *MEDCouplingFieldOverTime::New(const std::vector& fs) throw(INTERP_KERNEL::Exception) +{ + return new MEDCouplingFieldOverTime(fs); +} + +double MEDCouplingFieldOverTime::getTimeTolerance() const throw(INTERP_KERNEL::Exception) +{ + std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_fs.begin(); + if(_fs.empty()) + throw INTERP_KERNEL::Exception("MEDCouplingFieldOverTime::getTimeTolerance : empty set !"); + for(;it!=_fs.end();it++) + if((const MEDCouplingFieldDouble *)(*it)!=0) + return (*it)->getTimeTolerance(); + throw INTERP_KERNEL::Exception("MEDCouplingFieldOverTime::getTimeTolerance : only empty fields in this !"); +} + +void MEDCouplingFieldOverTime::checkCoherency() const throw(INTERP_KERNEL::Exception) +{ + MEDCouplingMultiFields::checkCoherency(); + std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_fs.begin(); + for(;it!=_fs.end();it++) + if((*it)->getTimeDiscretization()==NO_TIME) + { + std::ostringstream oss; oss << "MEDCouplingFieldOverTime::checkCoherency : At rank #" << std::distance(_fs.begin(),it) << " the field has no time !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + if(_fs.empty()) + return ; + it=_fs.begin(); + const MEDCouplingFieldDouble& ref=*(*(it++)); + int tt1,tt2; + double reft=ref.getEndTime(tt1,tt2); + double eps=getTimeTolerance(); + int id=1; + for(;it!=_fs.end();it++,id++) + { + if(!ref.getMesh()->areCompatibleForMerge((*it)->getMesh())) + { + 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); + if(curtgetEndTime(tt1,tt2); + } +} + +std::string MEDCouplingFieldOverTime::simpleRepr() const +{ + std::ostringstream ret; + ret << "MEDCouplingFieldOverTime with name : \"" << getName() << "\"\n"; + ret << "Description of MEDCouplingFieldOverTime is : \"" << getDescription() << "\"\n"; + ret << "Number of discretization : " << _fs.size() << "\n"; + ret << "Number of different meshes : "; + std::vector ms; + std::vector refms; + try + { + ms=getDifferentMeshes(refms); + ret << ms.size() << "\n"; + } + catch(INTERP_KERNEL::Exception& e) + { ret << "Current instance is INVALID !\n"; } + try + { + MEDCouplingDefinitionTime dt=getDefinitionTimeZone(); + dt.appendRepr(ret); + } + catch(INTERP_KERNEL::Exception& e) + { ret << "Definition zone is INVALID !\n"; } + return ret.str(); +} + +bool MEDCouplingFieldOverTime::isEqual(const MEDCouplingMultiFields *other, double meshPrec, double valsPrec) const +{ + if(!MEDCouplingMultiFields::isEqual(other,meshPrec,valsPrec)) + return false; + const MEDCouplingFieldOverTime *otherC=dynamic_cast(other); + if(!otherC) + return false; + // to implement + return true; +} + +bool MEDCouplingFieldOverTime::isEqualWithoutConsideringStr(const MEDCouplingMultiFields *other, double meshPrec, double valsPrec) const +{ + if(!MEDCouplingMultiFields::isEqualWithoutConsideringStr(other,meshPrec,valsPrec)) + return false; + const MEDCouplingFieldOverTime *otherC=dynamic_cast(other); + if(!otherC) + return false; + // to implement + return true; +} + +std::vector MEDCouplingFieldOverTime::getMeshes() const throw(INTERP_KERNEL::Exception) +{ + checkCoherency(); + return MEDCouplingMultiFields::getMeshes(); +} + +std::vector MEDCouplingFieldOverTime::getDifferentMeshes(std::vector& refs) const throw(INTERP_KERNEL::Exception) +{ + checkCoherency(); + return MEDCouplingMultiFields::getDifferentMeshes(refs); +} + +std::vector MEDCouplingFieldOverTime::getArrays() const throw(INTERP_KERNEL::Exception) +{ + checkCoherency(); + return MEDCouplingMultiFields::getArrays(); +} + +std::vector MEDCouplingFieldOverTime::getDifferentArrays(std::vector< std::vector >& refs) const throw(INTERP_KERNEL::Exception) +{ + checkCoherency(); + return MEDCouplingMultiFields::getDifferentArrays(refs); +} + +MEDCouplingDefinitionTime MEDCouplingFieldOverTime::getDefinitionTimeZone() const +{ + std::vector< std::vector > tmp; + getDifferentArrays(tmp); + std::vector tmp2(_fs.begin(),_fs.end()); + std::vector tmp3; + getDifferentMeshes(tmp3); + return MEDCouplingDefinitionTime(tmp2,tmp3,tmp); +} + +MEDCouplingFieldOverTime::MEDCouplingFieldOverTime(const std::vector& fs) throw(INTERP_KERNEL::Exception):MEDCouplingMultiFields(fs) +{ + checkCoherency(); +} + +MEDCouplingFieldOverTime::MEDCouplingFieldOverTime() +{ +} diff --git a/src/MEDCoupling/MEDCouplingFieldOverTime.hxx b/src/MEDCoupling/MEDCouplingFieldOverTime.hxx new file mode 100644 index 000000000..e017b58ef --- /dev/null +++ b/src/MEDCoupling/MEDCouplingFieldOverTime.hxx @@ -0,0 +1,55 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef __PARAMEDMEM_MEDCOUPLINGFIELDOVERTIME_HXX__ +#define __PARAMEDMEM_MEDCOUPLINGFIELDOVERTIME_HXX__ + +#include "MEDCouplingMultiFields.hxx" +#include "MEDCouplingDefinitionTime.hxx" +#include "MEDCouplingFieldDouble.hxx" + +#include + +namespace ParaMEDMEM +{ + class MEDCouplingFieldOverTime : public MEDCouplingMultiFields + { + public: + static MEDCouplingFieldOverTime *New(const std::vector& fs) throw(INTERP_KERNEL::Exception); + void checkCoherency() const throw(INTERP_KERNEL::Exception); + double getTimeTolerance() const throw(INTERP_KERNEL::Exception); + std::string simpleRepr() const; + bool isEqual(const MEDCouplingMultiFields *other, double meshPrec, double valsPrec) const; + bool isEqualWithoutConsideringStr(const MEDCouplingMultiFields *other, double meshPrec, double valsPrec) const; + //void getIdsToFetch(double time, int& fieldId, int& arrId, int& meshId) const; + //void setFieldOnId(int fieldId, MEDCouplingFieldDouble *f); + //void dispatchPointers(); + std::vector getMeshes() const throw(INTERP_KERNEL::Exception); + std::vector getDifferentMeshes(std::vector& refs) const throw(INTERP_KERNEL::Exception); + std::vector getArrays() const throw(INTERP_KERNEL::Exception); + std::vector getDifferentArrays(std::vector< std::vector >& refs) const throw(INTERP_KERNEL::Exception); + MEDCouplingDefinitionTime getDefinitionTimeZone() const; + protected: + MEDCouplingFieldOverTime(); + private: + MEDCouplingFieldOverTime(const std::vector& fs) throw(INTERP_KERNEL::Exception); + }; +} + +#endif diff --git a/src/MEDCoupling/MEDCouplingFieldTemplate.cxx b/src/MEDCoupling/MEDCouplingFieldTemplate.cxx new file mode 100644 index 000000000..fb6680a86 --- /dev/null +++ b/src/MEDCoupling/MEDCouplingFieldTemplate.cxx @@ -0,0 +1,117 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "MEDCouplingFieldTemplate.hxx" +#include "MEDCouplingMesh.hxx" +#include "MEDCouplingFieldDouble.hxx" +#include "MEDCouplingFieldDiscretization.hxx" + +using namespace ParaMEDMEM; + +MEDCouplingFieldTemplate *MEDCouplingFieldTemplate::New(const MEDCouplingFieldDouble *f) throw(INTERP_KERNEL::Exception) +{ + return new MEDCouplingFieldTemplate(f); +} + +/*! + * The user should \b not use this method. Only useful for CORBA serialization/unserialization. + */ +MEDCouplingFieldTemplate *MEDCouplingFieldTemplate::New(TypeOfField type) +{ + return new MEDCouplingFieldTemplate(type); +} + +MEDCouplingFieldTemplate::MEDCouplingFieldTemplate(const MEDCouplingFieldDouble *f) throw(INTERP_KERNEL::Exception):MEDCouplingField(*f) +{ + checkCoherency(); +} + +MEDCouplingFieldTemplate::MEDCouplingFieldTemplate(TypeOfField type):MEDCouplingField(type) +{ +} + +void MEDCouplingFieldTemplate::checkCoherency() const throw(INTERP_KERNEL::Exception) +{ + if(_mesh==0) + throw INTERP_KERNEL::Exception("MEDCouplingFieldTemplate::checkCoherency : Empty mesh !"); +} + +std::string MEDCouplingFieldTemplate::simpleRepr() const +{ + std::ostringstream ret; + ret << "FieldTemplate with name : \"" << getName() << "\"\n"; + ret << "Description of field is : \"" << getDescription() << "\"\n"; + ret << "FieldTemplate space discretization is : " << _type->getStringRepr() << "\n"; + ret << "FieldTemplate nature of field is : " << MEDCouplingNatureOfField::getRepr(_nature) << "\n"; + if(_mesh) + ret << "Mesh support information :\n__________________________\n" << _mesh->simpleRepr(); + else + ret << "Mesh support information : No mesh set !\n"; + return ret.str(); +} + +std::string MEDCouplingFieldTemplate::advancedRepr() const +{ + return simpleRepr(); +} + +void MEDCouplingFieldTemplate::getTinySerializationIntInformation(std::vector& tinyInfo) const +{ + tinyInfo.clear(); + tinyInfo.push_back((int)_type->getEnum()); + tinyInfo.push_back((int)_nature); + std::vector tinyInfo2; + _type->getTinySerializationIntInformation(tinyInfo2); + tinyInfo.insert(tinyInfo.end(),tinyInfo2.begin(),tinyInfo2.end()); + tinyInfo.push_back(tinyInfo2.size()); +} + +void MEDCouplingFieldTemplate::getTinySerializationDbleInformation(std::vector& tinyInfo) const +{ + tinyInfo.clear(); + _type->getTinySerializationDbleInformation(tinyInfo); +} + +void MEDCouplingFieldTemplate::getTinySerializationStrInformation(std::vector& tinyInfo) const +{ + tinyInfo.clear(); + tinyInfo.push_back(_name); + tinyInfo.push_back(_desc); +} + +void MEDCouplingFieldTemplate::resizeForUnserialization(const std::vector& tinyInfoI, DataArrayInt *&dataInt) +{ + dataInt=0; + std::vector tinyInfoITmp(tinyInfoI.begin()+2,tinyInfoI.end()); + _type->resizeForUnserialization(tinyInfoITmp,dataInt); +} + +void MEDCouplingFieldTemplate::finishUnserialization(const std::vector& tinyInfoI, const std::vector& tinyInfoD, const std::vector& tinyInfoS) +{ + _nature=(NatureOfField)tinyInfoI[1]; + _type->finishUnserialization(tinyInfoD); + _name=tinyInfoS[0]; + _desc=tinyInfoS[1]; +} + +void MEDCouplingFieldTemplate::serialize(DataArrayInt *&dataInt) const +{ + _type->getSerializationIntArray(dataInt); +} + diff --git a/src/MEDCoupling/MEDCouplingFieldTemplate.hxx b/src/MEDCoupling/MEDCouplingFieldTemplate.hxx new file mode 100644 index 000000000..43f76e860 --- /dev/null +++ b/src/MEDCoupling/MEDCouplingFieldTemplate.hxx @@ -0,0 +1,51 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef __PARAMEDMEM_MEDCOUPLINGFIELDTEMPLATE_HXX__ +#define __PARAMEDMEM_MEDCOUPLINGFIELDTEMPLATE_HXX__ + +#include "MEDCouplingField.hxx" + +namespace ParaMEDMEM +{ + class MEDCouplingFieldDouble; + + class MEDCouplingFieldTemplate : public MEDCouplingField + { + public: + static MEDCouplingFieldTemplate *New(const MEDCouplingFieldDouble *f) throw(INTERP_KERNEL::Exception); + static MEDCouplingFieldTemplate *New(TypeOfField type); + std::string simpleRepr() const; + std::string advancedRepr() const; + void checkCoherency() const throw(INTERP_KERNEL::Exception); + // + void getTinySerializationIntInformation(std::vector& tinyInfo) const; + void getTinySerializationDbleInformation(std::vector& tinyInfo) const; + void getTinySerializationStrInformation(std::vector& tinyInfo) const; + void resizeForUnserialization(const std::vector& tinyInfoI, DataArrayInt *&dataInt); + void finishUnserialization(const std::vector& tinyInfoI, const std::vector& tinyInfoD, const std::vector& tinyInfoS); + void serialize(DataArrayInt *&dataInt) const; + // + private: + MEDCouplingFieldTemplate(const MEDCouplingFieldDouble *f) throw(INTERP_KERNEL::Exception); + MEDCouplingFieldTemplate(TypeOfField type); + }; +} + +#endif diff --git a/src/MEDCoupling/MEDCouplingGaussLocalization.cxx b/src/MEDCoupling/MEDCouplingGaussLocalization.cxx index 68c9a0611..ff0dc2d61 100644 --- a/src/MEDCoupling/MEDCouplingGaussLocalization.cxx +++ b/src/MEDCoupling/MEDCouplingGaussLocalization.cxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "MEDCouplingGaussLocalization.hxx" @@ -42,7 +42,7 @@ catch(INTERP_KERNEL::Exception& e) void ParaMEDMEM::MEDCouplingGaussLocalization::checkCoherency() const throw(INTERP_KERNEL::Exception) { - const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::getCellModel(_type); + const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_type); int nbNodes=cm.getNumberOfNodes(); int dim=cm.getDimension(); if(!cm.isDynamic()) @@ -79,18 +79,18 @@ bool ParaMEDMEM::MEDCouplingGaussLocalization::isEqual(const MEDCouplingGaussLoc { if(_type!=other._type) return false; - if(!areAlmostEqual(_ref_coord,other._ref_coord,eps)) + if(!AreAlmostEqual(_ref_coord,other._ref_coord,eps)) return false; - if(!areAlmostEqual(_gauss_coord,other._gauss_coord,eps)) + if(!AreAlmostEqual(_gauss_coord,other._gauss_coord,eps)) return false; - if(!areAlmostEqual(_weight,other._weight,eps)) + if(!AreAlmostEqual(_weight,other._weight,eps)) return false; return true; } double ParaMEDMEM::MEDCouplingGaussLocalization::getRefCoord(int ptIdInCell, int comp) const throw(INTERP_KERNEL::Exception) { - const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::getCellModel(_type); + const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_type); int nbNodes=cm.getNumberOfNodes(); int dim=cm.getDimension(); if(ptIdInCell<0 || ptIdInCell>=nbNodes) @@ -160,7 +160,7 @@ const double *ParaMEDMEM::MEDCouplingGaussLocalization::fillWithValues(const dou */ void ParaMEDMEM::MEDCouplingGaussLocalization::setRefCoord(int ptIdInCell, int comp, double newVal) throw(INTERP_KERNEL::Exception) { - const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::getCellModel(_type); + const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_type); int nbNodes=cm.getNumberOfNodes(); int dim=cm.getDimension(); if(ptIdInCell<0 || ptIdInCell>=nbNodes) @@ -185,7 +185,7 @@ void ParaMEDMEM::MEDCouplingGaussLocalization::setWeight(int gaussPtIdInCell, do /*! * The format of 'tinyData' parameter is the same than pushed in method ParaMEDMEM::MEDCouplingGaussLocalization::pushTinySerializationIntInfo. */ -ParaMEDMEM::MEDCouplingGaussLocalization ParaMEDMEM::MEDCouplingGaussLocalization::buildNewInstanceFromTinyInfo(int dim, const std::vector& tinyData) +ParaMEDMEM::MEDCouplingGaussLocalization ParaMEDMEM::MEDCouplingGaussLocalization::BuildNewInstanceFromTinyInfo(int dim, const std::vector& tinyData) { std::vector v1(dim*tinyData[1]),v2(dim*tinyData[2]),v3(tinyData[2]); return ParaMEDMEM::MEDCouplingGaussLocalization((INTERP_KERNEL::NormalizedCellType)tinyData[0],v1,v2,v3); @@ -193,7 +193,7 @@ ParaMEDMEM::MEDCouplingGaussLocalization ParaMEDMEM::MEDCouplingGaussLocalizatio int ParaMEDMEM::MEDCouplingGaussLocalization::checkCoherencyOfRequest(int gaussPtIdInCell, int comp) const throw(INTERP_KERNEL::Exception) { - const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::getCellModel(_type); + const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_type); int dim=cm.getDimension(); int nbGsPts=getNumberOfGaussPt(); if(gaussPtIdInCell<0 || gaussPtIdInCell>=nbGsPts) @@ -203,7 +203,7 @@ int ParaMEDMEM::MEDCouplingGaussLocalization::checkCoherencyOfRequest(int gaussP return dim; } -bool ParaMEDMEM::MEDCouplingGaussLocalization::areAlmostEqual(const std::vector& v1, const std::vector& v2, double eps) +bool ParaMEDMEM::MEDCouplingGaussLocalization::AreAlmostEqual(const std::vector& v1, const std::vector& v2, double eps) { int sz=v1.size(); if(sz!=(int)v2.size()) diff --git a/src/MEDCoupling/MEDCouplingGaussLocalization.hxx b/src/MEDCoupling/MEDCouplingGaussLocalization.hxx index 791e24355..f853eba10 100644 --- a/src/MEDCoupling/MEDCouplingGaussLocalization.hxx +++ b/src/MEDCoupling/MEDCouplingGaussLocalization.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __PARAMEDMEM_MEDCOUPLINGGAUSSLOCALIZATION_HXX__ @@ -55,10 +55,10 @@ namespace ParaMEDMEM void setGaussCoord(int gaussPtIdInCell, int comp, double newVal) throw(INTERP_KERNEL::Exception); void setWeight(int gaussPtIdInCell, double newVal) throw(INTERP_KERNEL::Exception); // - static MEDCouplingGaussLocalization buildNewInstanceFromTinyInfo(int dim, const std::vector& tinyData); + static MEDCouplingGaussLocalization BuildNewInstanceFromTinyInfo(int dim, const std::vector& tinyData); + static bool AreAlmostEqual(const std::vector& v1, const std::vector& v2, double eps); private: int checkCoherencyOfRequest(int gaussPtIdInCell, int comp) const throw(INTERP_KERNEL::Exception); - static bool areAlmostEqual(const std::vector& v1, const std::vector& v2, double eps); private: INTERP_KERNEL::NormalizedCellType _type; std::vector _ref_coord; diff --git a/src/MEDCoupling/MEDCouplingMemArray.cxx b/src/MEDCoupling/MEDCouplingMemArray.cxx index 5365cb97c..e9d9b6d8f 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.cxx +++ b/src/MEDCoupling/MEDCouplingMemArray.cxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "MEDCouplingMemArray.txx" @@ -25,6 +25,7 @@ #include #include +#include #include #include @@ -86,13 +87,31 @@ bool DataArray::areInfoEquals(const DataArray& other) const void DataArray::reprWithoutNameStream(std::ostream& stream) const { - stream << "Nb of components : "<< getNumberOfComponents() << "\n"; + 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 << "\" "; stream << "\n"; } +std::vector DataArray::getVarsOnComponent() const +{ + int nbOfCompo=(int)_info_on_compo.size(); + std::vector ret(nbOfCompo); + for(int i=0;i DataArray::getUnitsOnComponent() const +{ + int nbOfCompo=(int)_info_on_compo.size(); + std::vector ret(nbOfCompo); + for(int i=0;ip2) + return st0; + if(p1==0) + return std::string(); + std::size_t p3=st0.find_last_not_of(' ',p1-1); + return st0.substr(0,p3+1); + } + else + { + std::ostringstream oss; oss << "getVarOnComponent : Invalid component id transmitted (" << i << ") >= " << (int) _info_on_compo.size(); + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } +} + +/*! + * In the info part of i_th component this method returns the var part. + * For example, if getInfoOnComponent(0) return "SIGXY (N/m^2)", getUnitOnComponent(0) will return "N/m^2" + */ +std::string DataArray::getUnitOnComponent(int i) const throw(INTERP_KERNEL::Exception) +{ + if(i<(int)_info_on_compo.size()) + { + std::string st0=_info_on_compo[i]; + std::size_t p1=st0.find_last_of('['); + std::size_t p2=st0.find_last_of(']'); + if(p1==std::string::npos || p2==std::string::npos) + return std::string(); + if(p1>p2) + return std::string(); + return st0.substr(p1+1,p2-p1-1); + } + else + { + std::ostringstream oss; oss << "getUnitOnComponent : Invalid component id transmitted (" << i << ") >= " << (int) _info_on_compo.size(); + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } +} + void DataArray::setInfoOnComponent(int i, const char *info) throw(INTERP_KERNEL::Exception) { if(i<(int)_info_on_compo.size()) @@ -115,20 +185,101 @@ void DataArray::setInfoOnComponent(int i, const char *info) throw(INTERP_KERNEL: } } +void DataArray::checkNbOfTuplesAndComp(const DataArray& other, const char *msg) const throw(INTERP_KERNEL::Exception) +{ + if(getNumberOfTuples()!=other.getNumberOfTuples()) + { + std::ostringstream oss; oss << msg << " : mismatch number of tuples : expected " << other.getNumberOfTuples() << " having " << getNumberOfTuples() << " !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + if(getNumberOfComponents()!=other.getNumberOfComponents()) + { + std::ostringstream oss; oss << msg << " : mismatch number of components : expected " << other.getNumberOfComponents() << " having " << getNumberOfComponents() << " !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } +} + +void DataArray::checkNbOfTuplesAndComp(int nbOfTuples, int nbOfCompo, const char *msg) const throw(INTERP_KERNEL::Exception) +{ + if(getNumberOfTuples()!=nbOfTuples) + { + std::ostringstream oss; oss << msg << " : mismatch number of tuples : expected " << nbOfTuples << " having " << getNumberOfTuples() << " !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + if(getNumberOfComponents()!=nbOfCompo) + { + std::ostringstream oss; oss << msg << " : mismatch number of components : expected " << nbOfCompo << " having " << getNumberOfComponents() << " !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } +} + +void DataArray::checkNbOfElems(int nbOfElems, const char *msg) const throw(INTERP_KERNEL::Exception) +{ + if(getNbOfElems()!=nbOfElems) + { + std::ostringstream oss; oss << msg << " : mismatch number of elems : Expected " << nbOfElems << " having " << getNbOfElems() << " !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } +} + +void DataArray::CheckValueInRange(int ref, int value, const char *msg) throw(INTERP_KERNEL::Exception) +{ + if(value<0 || value>=ref) + { + std::ostringstream oss; oss << "DataArray::CheckValueInRange : " << msg << " ! Expected in range [0," << ref << ") having " << value << " !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } +} + +void DataArray::CheckClosingParInRange(int ref, int value, const char *msg) throw(INTERP_KERNEL::Exception) +{ + if(value<0 || value>ref) + { + std::ostringstream oss; oss << "DataArray::CheckClosingParInRange : " << msg << " ! Expected a range in [0," << ref << ") having closing open parenthesis " << value << " !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } +} + +int DataArray::GetNumberOfItemGivenBES(int begin, int end, int step, const char *msg) throw(INTERP_KERNEL::Exception) +{ + if(end 0 !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + return (end-1-begin)/step+1; +} + DataArrayDouble *DataArrayDouble::New() { return new DataArrayDouble; } -DataArrayDouble *DataArrayDouble::deepCopy() const +bool DataArrayDouble::isAllocated() const +{ + return getConstPointer()!=0; +} + +void DataArrayDouble::checkAllocated() const throw(INTERP_KERNEL::Exception) +{ + if(!isAllocated()) + throw INTERP_KERNEL::Exception("DataArrayDouble::checkAllocated : Array is defined but not allocated ! Call alloc or setValues method first !"); +} + +DataArrayDouble *DataArrayDouble::deepCpy() const { return new DataArrayDouble(*this); } -DataArrayDouble *DataArrayDouble::performCpy(bool deepCpy) const +DataArrayDouble *DataArrayDouble::performCpy(bool dCpy) const { - if(deepCpy) - return deepCopy(); + if(dCpy) + return deepCpy(); else { incrRef(); @@ -136,6 +287,31 @@ DataArrayDouble *DataArrayDouble::performCpy(bool deepCpy) const } } +void DataArrayDouble::cpyFrom(const DataArrayDouble& other) throw(INTERP_KERNEL::Exception) +{ + other.checkAllocated(); + int nbOfTuples=other.getNumberOfTuples(); + int nbOfComp=other.getNumberOfComponents(); + allocIfNecessary(nbOfTuples,nbOfComp); + int nbOfElems=nbOfTuples*nbOfComp; + double *pt=getPointer(); + const double *ptI=other.getConstPointer(); + for(int i=0;ivmax) + return false; + return true; +} + +void DataArrayDouble::sort() throw(INTERP_KERNEL::Exception) +{ + checkAllocated(); + if(getNumberOfComponents()!=1) + throw INTERP_KERNEL::Exception("DataArrayDouble::sort : only supported with 'this' array with ONE component !"); + _mem.sort(); +} + +void DataArrayDouble::checkMonotonic(double eps) const throw(INTERP_KERNEL::Exception) +{ + if(!isMonotonic(eps)) + throw INTERP_KERNEL::Exception("DataArrayDouble::checkMonotonic : 'this' is not monotonic !"); +} + +bool DataArrayDouble::isMonotonic(double eps) const throw(INTERP_KERNEL::Exception) +{ + checkAllocated(); + if(getNumberOfComponents()!=1) + throw INTERP_KERNEL::Exception("DataArrayDouble::isMonotonic : only supported with 'this' array with ONE component !"); + int nbOfElements=getNumberOfTuples(); + const double *ptr=getConstPointer(); + if(nbOfElements==0) + return true; + double ref=ptr[0]; + for(int i=1;iuseArray(tab,true,CPP_DEALLOC,getNumberOfTuples(),getNumberOfComponents()); + return ret; +} + +DataArrayDouble *DataArrayDouble::toNoInterlace() const throw(INTERP_KERNEL::Exception) +{ + if(_mem.isNull()) + throw INTERP_KERNEL::Exception("DataArrayDouble::fromNoInterlace : Not defined array !"); + double *tab=_mem.toNoInterlace(getNumberOfComponents()); + DataArrayDouble *ret=DataArrayDouble::New(); + ret->useArray(tab,true,CPP_DEALLOC,getNumberOfTuples(),getNumberOfComponents()); + return ret; +} + /*! * This method does \b not change the number of tuples after this call. * Only a permutation is done. If a permutation reduction is needed substr, or selectByTupleId should be used. @@ -342,6 +601,53 @@ DataArrayDouble *DataArrayDouble::selectByTupleId(const int *new2OldBg, const in return ret; } +/*! + * This method is equivalent to DataArrayDouble::selectByTupleId except that an analyze to the content of input range to check that it will not lead to memory corruption ! + */ +DataArrayDouble *DataArrayDouble::selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const throw(INTERP_KERNEL::Exception) +{ + MEDCouplingAutoRefCountObjectPtr ret=DataArrayDouble::New(); + int nbComp=getNumberOfComponents(); + int oldNbOfTuples=getNumberOfTuples(); + ret->alloc(std::distance(new2OldBg,new2OldEnd),nbComp); + ret->copyStringInfoFrom(*this); + double *pt=ret->getPointer(); + const double *srcPt=getConstPointer(); + int i=0; + for(const int *w=new2OldBg;w!=new2OldEnd;w++,i++) + if(*w>=0 && *wgetNumberOfTuples) !"); + ret->copyStringInfoFrom(*this); + ret->incrRef(); + return ret; +} + +/*! + * Idem than DataArrayInt::selectByTupleIdSafe except that the input array is not constructed explicitely. + * The convention is as python one. ['bg','end') with steps of 'step'. + * Returns a newly created array. + */ +DataArrayDouble *DataArrayDouble::selectByTupleId2(int bg, int end, int step) const throw(INTERP_KERNEL::Exception) +{ + if(end 0 !"); + MEDCouplingAutoRefCountObjectPtr ret=DataArrayDouble::New(); + int nbComp=getNumberOfComponents(); + int newNbOfTuples=(end-1-bg)/step+1; + ret->alloc(newNbOfTuples,nbComp); + double *pt=ret->getPointer(); + const double *srcPt=getConstPointer()+bg*nbComp; + for(int i=0;icopyStringInfoFrom(*this); + ret->incrRef(); + return ret; +} + /*! * This methods has a similar behaviour than std::string::substr. This method returns a newly created DataArrayInt that is part of this with same number of components. * The intervall is specified by [tupleIdBg,tupleIdEnd) except if tupleIdEnd ==-1 in this case the [tupleIdBg,this->end()) will be kept. @@ -352,8 +658,8 @@ DataArrayDouble *DataArrayDouble::substr(int tupleIdBg, int tupleIdEnd) const th int nbt=getNumberOfTuples(); if(tupleIdBg<0) throw INTERP_KERNEL::Exception("DataArrayInt::substr : The tupleIdBg parameter must be greater than 0 !"); - if(tupleIdBg>=nbt) - throw INTERP_KERNEL::Exception("DataArrayInt::substr : The tupleIdBg parameter is greater or equal than number of tuples !"); + if(tupleIdBg>nbt) + throw INTERP_KERNEL::Exception("DataArrayInt::substr : The tupleIdBg parameter is greater than number of tuples !"); int trueEnd=tupleIdEnd; if(tupleIdEnd!=-1) { @@ -377,6 +683,7 @@ DataArrayDouble *DataArrayDouble::substr(int tupleIdBg, int tupleIdEnd) const th */ DataArrayDouble *DataArrayDouble::changeNbOfComponents(int newNbOfComp, double dftValue) const throw(INTERP_KERNEL::Exception) { + checkAllocated(); DataArrayDouble *ret=DataArrayDouble::New(); ret->alloc(getNumberOfTuples(),newNbOfComp); const double *oldc=getConstPointer(); @@ -399,11 +706,37 @@ DataArrayDouble *DataArrayDouble::changeNbOfComponents(int newNbOfComp, double d return ret; } +/*! + * Contrary to DataArrayDouble::changeNbOfComponents method this method is \b not const. The content + * This method \b do \b not change the content of data but changes the splitting of this data seen by the caller. + * This method makes the assumption that 'this' is already allocated. If not an exception will be thrown. + * This method checks that getNbOfElems()%newNbOfCompo==0. If not an exception will be throw ! + * This method erases all components info set before call ! + */ +void DataArrayDouble::rearrange(int newNbOfCompo) throw(INTERP_KERNEL::Exception) +{ + checkAllocated(); + int nbOfElems=getNbOfElems(); + if(nbOfElems%newNbOfCompo!=0) + throw INTERP_KERNEL::Exception("DataArrayDouble::rearrange : nbOfElems%newNbOfCompo!=0 !"); + _nb_of_tuples=nbOfElems/newNbOfCompo; + _info_on_compo.clear(); + _info_on_compo.resize(newNbOfCompo); + declareAsNew(); +} + DataArrayDouble *DataArrayDouble::keepSelectedComponents(const std::vector& compoIds) const throw(INTERP_KERNEL::Exception) { + checkAllocated(); MEDCouplingAutoRefCountObjectPtr ret(DataArrayDouble::New()); int newNbOfCompo=compoIds.size(); int oldNbOfCompo=getNumberOfComponents(); + for(std::vector::const_iterator it=compoIds.begin();it!=compoIds.end();it++) + if((*it)<0 || (*it)>=oldNbOfCompo) + { + std::ostringstream oss; oss << "DataArrayDouble::keepSelectedComponents : invalid requested component : " << *it << " whereas it should be in [0," << oldNbOfCompo << ") !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } int nbOfTuples=getNumberOfTuples(); ret->alloc(nbOfTuples,newNbOfCompo); ret->copyPartOfStringInfoFrom(*this,compoIds); @@ -416,6 +749,37 @@ DataArrayDouble *DataArrayDouble::keepSelectedComponents(const std::vector& return ret; } +/*! + * This method melds the components of 'this' with components of 'other'. + * After this call in case of success, 'this' will contain a number of components equal to the sum of 'this' + * before the call and the number of components of 'other'. + * This method expects that 'this' and 'other' have exactly the same number of tuples. If not an exception is thrown. + */ +void DataArrayDouble::meldWith(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception) +{ + checkAllocated(); + other->checkAllocated(); + int nbOfTuples=getNumberOfTuples(); + if(nbOfTuples!=other->getNumberOfTuples()) + throw INTERP_KERNEL::Exception("DataArrayDouble::meldWith : mismatch of number of tuples !"); + int nbOfComp1=getNumberOfComponents(); + int nbOfComp2=other->getNumberOfComponents(); + double *newArr=new double[nbOfTuples*(nbOfComp1+nbOfComp2)]; + double *w=newArr; + const double *inp1=getConstPointer(); + const double *inp2=other->getConstPointer(); + for(int i=0;i compIds(nbOfComp2); + for(int i=0;i& compoIds) throw(INTERP_KERNEL::Exception) { copyPartOfStringInfoFrom2(compoIds,*a); @@ -429,7 +793,151 @@ void DataArrayDouble::setSelectedComponents(const DataArrayDouble *a, const std: nc[nbOfCompo*i+compoIds[j]]=*ac; } -void DataArrayDouble::setArrayIn(DataArrayDouble *newArray, DataArrayDouble* &arrayToSet) +/*! + * This method performs a partial assignment of 'this' using 'a' as input. Other input parameters specifies the subpart being considered by the assignment. + * 'strictCompoCompare' specifies if DataArray 'a' should have exactly same number of components and tuples than 'this' (true) or not (false). By default set to true with maximal test. + */ +void DataArrayDouble::setPartOfValues1(const DataArrayDouble *a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare) throw(INTERP_KERNEL::Exception) +{ + const char msg[]="DataArrayDouble::setPartOfValues1"; + checkAllocated(); + a->checkAllocated(); + int newNbOfTuples=DataArray::GetNumberOfItemGivenBES(bgTuples,endTuples,stepTuples,msg); + int newNbOfComp=DataArray::GetNumberOfItemGivenBES(bgComp,endComp,stepComp,msg); + int nbComp=getNumberOfComponents(); + int nbOfTuples=getNumberOfTuples(); + DataArray::CheckValueInRange(nbOfTuples,bgTuples,"invalid begin tuple value"); + DataArray::CheckClosingParInRange(nbOfTuples,endTuples,"invalid end tuple value"); + DataArray::CheckValueInRange(nbComp,bgComp,"invalid begin component value"); + DataArray::CheckClosingParInRange(nbComp,endComp,"invalid end component value"); + a->checkNbOfElems(newNbOfTuples*newNbOfComp,msg); + if(strictCompoCompare) + a->checkNbOfTuplesAndComp(newNbOfTuples,newNbOfComp,msg); + double *pt=getPointer()+bgTuples*nbComp+bgComp; + const double *srcPt=a->getConstPointer(); + for(int i=0;icheckAllocated(); + int nbComp=getNumberOfComponents(); + int nbOfTuples=getNumberOfTuples(); + for(const int *z=bgComp;z!=endComp;z++) + DataArray::CheckValueInRange(nbComp,*z,"invalid component id"); + int newNbOfTuples=std::distance(bgTuples,endTuples); + int newNbOfComp=std::distance(bgComp,endComp); + a->checkNbOfElems(newNbOfTuples*newNbOfComp,msg); + if(strictCompoCompare) + a->checkNbOfTuplesAndComp(newNbOfTuples,newNbOfComp,msg); + double *pt=getPointer(); + const double *srcPt=a->getConstPointer(); + for(const int *w=bgTuples;w!=endTuples;w++) + for(const int *z=bgComp;z!=endComp;z++,srcPt++) + { + DataArray::CheckValueInRange(nbOfTuples,*w,"invalid tuple id"); + pt[(*w)*nbComp+(*z)]=*srcPt; + } +} + +/*! + * This method performs a partial assignment of 'this' using 'a' as input. Other input parameters specifies the subpart being considered by the assignment. + */ +void DataArrayDouble::setPartOfValuesSimple2(double a, const int *bgTuples, const int *endTuples, const int *bgComp, const int *endComp) throw(INTERP_KERNEL::Exception) +{ + checkAllocated(); + int nbComp=getNumberOfComponents(); + int nbOfTuples=getNumberOfTuples(); + for(const int *z=bgComp;z!=endComp;z++) + DataArray::CheckValueInRange(nbComp,*z,"invalid component id"); + double *pt=getPointer(); + for(const int *w=bgTuples;w!=endTuples;w++) + for(const int *z=bgComp;z!=endComp;z++) + { + DataArray::CheckValueInRange(nbOfTuples,*w,"invalid tuple id"); + pt[(*w)*nbComp+(*z)]=a; + } +} + +/*! + * This method performs a partial assignment of 'this' using 'a' as input. Other input parameters specifies the subpart being considered by the assignment. + * 'strictCompoCompare' specifies if DataArray 'a' should have exactly same number of components and tuples than 'this' (true) or not (false). By default set to true with maximal test. + */ +void DataArrayDouble::setPartOfValues3(const DataArrayDouble *a, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare) throw(INTERP_KERNEL::Exception) +{ + const char msg[]="DataArrayDouble::setPartOfValues3"; + checkAllocated(); + a->checkAllocated(); + int newNbOfComp=DataArray::GetNumberOfItemGivenBES(bgComp,endComp,stepComp,msg); + int nbComp=getNumberOfComponents(); + int nbOfTuples=getNumberOfTuples(); + DataArray::CheckValueInRange(nbComp,bgComp,"invalid begin component value"); + DataArray::CheckClosingParInRange(nbComp,endComp,"invalid end component value"); + int newNbOfTuples=std::distance(bgTuples,endTuples); + a->checkNbOfElems(newNbOfTuples*newNbOfComp,msg); + if(strictCompoCompare) + a->checkNbOfTuplesAndComp(newNbOfTuples,newNbOfComp,msg); + double *pt=getPointer()+bgComp; + const double *srcPt=a->getConstPointer(); + for(const int *w=bgTuples;w!=endTuples;w++) + for(int j=0;j 0 !"); @@ -483,7 +991,7 @@ double DataArrayDouble::getMaxValue2(DataArrayInt*& tupleIds) const throw(INTERP double DataArrayDouble::getMinValue(int& tupleId) const throw(INTERP_KERNEL::Exception) { if(getNumberOfComponents()!=1) - throw INTERP_KERNEL::Exception("DataArrayDouble::getMinValue : must be applied on DataArrayDouble with only one component !"); + throw INTERP_KERNEL::Exception("DataArrayDouble::getMinValue : must be applied on DataArrayDouble with only one component, you can call 'rearrange' method before !"); int nbOfTuples=getNumberOfTuples(); if(nbOfTuples<=0) throw INTERP_KERNEL::Exception("DataArrayDouble::getMinValue : array exists but number of tuples must be > 0 !"); @@ -505,7 +1013,7 @@ double DataArrayDouble::getMinValue2(DataArrayInt*& tupleIds) const throw(INTERP double DataArrayDouble::getAverageValue() const throw(INTERP_KERNEL::Exception) { if(getNumberOfComponents()!=1) - throw INTERP_KERNEL::Exception("DataArrayDouble::getAverageValue : must be applied on DataArrayDouble with only one component !"); + throw INTERP_KERNEL::Exception("DataArrayDouble::getAverageValue : must be applied on DataArrayDouble with only one component, you can call 'rearrange' method before !"); int nbOfTuples=getNumberOfTuples(); if(nbOfTuples<=0) throw INTERP_KERNEL::Exception("DataArrayDouble::getAverageValue : array exists but number of tuples must be > 0 !"); @@ -514,8 +1022,9 @@ double DataArrayDouble::getAverageValue() const throw(INTERP_KERNEL::Exception) return ret/nbOfTuples; } -void DataArrayDouble::accumulate(double *res) const +void DataArrayDouble::accumulate(double *res) const throw(INTERP_KERNEL::Exception) { + checkAllocated(); const double *ptr=getConstPointer(); int nbTuple=getNumberOfTuples(); int nbComps=getNumberOfComponents(); @@ -524,8 +1033,9 @@ void DataArrayDouble::accumulate(double *res) const std::transform(ptr+i*nbComps,ptr+(i+1)*nbComps,res,res,std::plus()); } -double DataArrayDouble::accumulate(int compId) const +double DataArrayDouble::accumulate(int compId) const throw(INTERP_KERNEL::Exception) { + checkAllocated(); const double *ptr=getConstPointer(); int nbTuple=getNumberOfTuples(); int nbComps=getNumberOfComponents(); @@ -537,36 +1047,94 @@ double DataArrayDouble::accumulate(int compId) const return ret; } -DataArrayDouble *DataArrayDouble::doublyContractedProduct() const throw(INTERP_KERNEL::Exception) +DataArrayDouble *DataArrayDouble::fromPolarToCart() const throw(INTERP_KERNEL::Exception) { int nbOfComp=getNumberOfComponents(); - if(nbOfComp!=6) - throw INTERP_KERNEL::Exception("DataArrayDouble::doublyContractedProduct : must be an array with exactly 6 components !"); - DataArrayDouble *ret=DataArrayDouble::New(); + if(nbOfComp!=2) + throw INTERP_KERNEL::Exception("DataArrayDouble::fromPolarToCart : must be an array with exactly 2 components !"); int nbOfTuple=getNumberOfTuples(); - ret->alloc(nbOfTuple,1); - const double *src=getConstPointer(); - double *dest=ret->getPointer(); - for(int i=0;ialloc(nbOfTuple,2); + double *w=ret->getPointer(); + const double *wIn=getConstPointer(); + for(int i=0;ialloc(nbOfTuple,1); - const double *src=getConstPointer(); - double *dest=ret->getPointer(); - switch(getNumberOfComponents()) + DataArrayDouble *ret=DataArrayDouble::New(); + ret->alloc(getNumberOfTuples(),3); + double *w=ret->getPointer(); + const double *wIn=getConstPointer(); + for(int i=0;isetInfoOnComponent(2,getInfoOnComponent(2).c_str()); + return ret; +} + +DataArrayDouble *DataArrayDouble::fromSpherToCart() const throw(INTERP_KERNEL::Exception) +{ + int nbOfComp=getNumberOfComponents(); + if(nbOfComp!=3) + throw INTERP_KERNEL::Exception("DataArrayDouble::fromSpherToCart : must be an array with exactly 3 components !"); + int nbOfTuple=getNumberOfTuples(); + DataArrayDouble *ret=DataArrayDouble::New(); + ret->alloc(getNumberOfTuples(),3); + double *w=ret->getPointer(); + const double *wIn=getConstPointer(); + for(int i=0;ialloc(nbOfTuple,1); + const double *src=getConstPointer(); + double *dest=ret->getPointer(); + for(int i=0;ialloc(nbOfTuple,1); + const double *src=getConstPointer(); + double *dest=ret->getPointer(); + switch(getNumberOfComponents()) + { + case 6: + for(int i=0;i vars; @@ -792,7 +1402,7 @@ DataArrayDouble *DataArrayDouble::applyFunc(int nbOfComp, const char *func) cons int oldNbOfComp=getNumberOfComponents(); if((int)vars.size()>oldNbOfComp) { - std::ostringstream oss; oss << "The field has a " << oldNbOfComp << " components and there are "; + std::ostringstream oss; oss << "The field has " << oldNbOfComp << " components and there are "; oss << vars.size() << " variables : "; std::copy(vars.begin(),vars.end(),std::ostream_iterator(oss," ")); throw INTERP_KERNEL::Exception(oss.str().c_str()); @@ -825,6 +1435,7 @@ DataArrayDouble *DataArrayDouble::applyFunc(int nbOfComp, const char *func) cons DataArrayDouble *DataArrayDouble::applyFunc(const char *func) const throw(INTERP_KERNEL::Exception) { + checkAllocated(); INTERP_KERNEL::ExprParser expr(func); expr.parse(); expr.prepareExprEvaluationVec(); @@ -853,12 +1464,102 @@ DataArrayDouble *DataArrayDouble::applyFunc(const char *func) const throw(INTERP return newArr; } -void DataArrayDouble::applyFuncFast32(const char *func) +/*! + * This method is equivalent than DataArrayDouble::applyFunc, except that here components names are used to determine vars orders. + * If 'func' contains vars that are not in \c this->getInfoOnComponent() an exception will be thrown. + */ +DataArrayDouble *DataArrayDouble::applyFunc2(int nbOfComp, const char *func) const throw(INTERP_KERNEL::Exception) +{ + checkAllocated(); + INTERP_KERNEL::ExprParser expr(func); + expr.parse(); + std::set vars; + expr.getTrueSetOfVars(vars); + int oldNbOfComp=getNumberOfComponents(); + if((int)vars.size()>oldNbOfComp) + { + std::ostringstream oss; oss << "The field has " << oldNbOfComp << " components and there are "; + oss << vars.size() << " variables : "; + std::copy(vars.begin(),vars.end(),std::ostream_iterator(oss," ")); + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + expr.prepareExprEvaluation(getVarsOnComponent()); + // + DataArrayDouble *newArr=DataArrayDouble::New(); + int nbOfTuples=getNumberOfTuples(); + newArr->alloc(nbOfTuples,nbOfComp); + const double *ptr=getConstPointer(); + double *ptrToFill=newArr->getPointer(); + for(int i=0;i(oss,", ")); + oss << ") : Evaluation of function failed !" << e.what(); + newArr->decrRef(); + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + } + return newArr; +} + +/*! + * This method is equivalent than DataArrayDouble::applyFunc, except that here order of vars is passed explicitely in parameter. + * In 'func' contains vars not in 'varsOrder' an exception will be thrown. + */ +DataArrayDouble *DataArrayDouble::applyFunc3(int nbOfComp, const std::vector& varsOrder, const char *func) const throw(INTERP_KERNEL::Exception) +{ + checkAllocated(); + INTERP_KERNEL::ExprParser expr(func); + expr.parse(); + std::set vars; + expr.getTrueSetOfVars(vars); + int oldNbOfComp=getNumberOfComponents(); + if((int)vars.size()>oldNbOfComp) + { + std::ostringstream oss; oss << "The field has " << oldNbOfComp << " components and there are "; + oss << vars.size() << " variables : "; + std::copy(vars.begin(),vars.end(),std::ostream_iterator(oss," ")); + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + expr.prepareExprEvaluation(varsOrder); + // + DataArrayDouble *newArr=DataArrayDouble::New(); + int nbOfTuples=getNumberOfTuples(); + newArr->alloc(nbOfTuples,nbOfComp); + const double *ptr=getConstPointer(); + double *ptrToFill=newArr->getPointer(); + for(int i=0;i(oss,", ")); + oss << ") : Evaluation of function failed !" << e.what(); + newArr->decrRef(); + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + } + return newArr; +} + +void DataArrayDouble::applyFuncFast32(const char *func) throw(INTERP_KERNEL::Exception) { + checkAllocated(); INTERP_KERNEL::ExprParser expr(func); expr.parse(); char *funcStr=expr.compileX86(); - MYFUNCPTR funcPtr=(MYFUNCPTR)funcStr;//he he... + MYFUNCPTR funcPtr; + *((void **)&funcPtr)=funcStr;//he he... // double *ptr=getPointer(); int nbOfComp=getNumberOfComponents(); @@ -869,12 +1570,14 @@ void DataArrayDouble::applyFuncFast32(const char *func) declareAsNew(); } -void DataArrayDouble::applyFuncFast64(const char *func) +void DataArrayDouble::applyFuncFast64(const char *func) throw(INTERP_KERNEL::Exception) { + checkAllocated(); INTERP_KERNEL::ExprParser expr(func); expr.parse(); char *funcStr=expr.compileX86_64(); - MYFUNCPTR funcPtr=(MYFUNCPTR)funcStr;//he he... + MYFUNCPTR funcPtr; + *((void **)&funcPtr)=funcStr;//he he... // double *ptr=getPointer(); int nbOfComp=getNumberOfComponents(); @@ -888,7 +1591,7 @@ void DataArrayDouble::applyFuncFast64(const char *func) DataArrayInt *DataArrayDouble::getIdsInRange(double vmin, double vmax) const throw(INTERP_KERNEL::Exception) { if(getNumberOfComponents()!=1) - throw INTERP_KERNEL::Exception("DataArrayDouble::getIdsInRange : the default array must have only one component !"); + throw INTERP_KERNEL::Exception("DataArrayDouble::getIdsInRange : this must have exactly one component !"); const double *cptr=getConstPointer(); std::vector res; int nbOfTuples=getNumberOfTuples(); @@ -901,29 +1604,89 @@ DataArrayInt *DataArrayDouble::getIdsInRange(double vmin, double vmax) const thr return ret; } -DataArrayDouble *DataArrayDouble::aggregate(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception) +DataArrayDouble *DataArrayDouble::Aggregate(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception) { - int nbOfComp=a1->getNumberOfComponents(); - if(nbOfComp!=a2->getNumberOfComponents()) - throw INTERP_KERNEL::Exception("Nb of components mismatch for array aggregation !"); - int nbOfTuple1=a1->getNumberOfTuples(); - int nbOfTuple2=a2->getNumberOfTuples(); + std::vector tmp(2); + tmp[0]=a1; tmp[1]=a2; + return Aggregate(tmp); +} + +DataArrayDouble *DataArrayDouble::Aggregate(const std::vector& a) throw(INTERP_KERNEL::Exception) +{ + if(a.empty()) + throw INTERP_KERNEL::Exception("DataArrayDouble::Aggregate : input list must be NON EMPTY !"); + std::vector::const_iterator it=a.begin(); + int nbOfComp=(*it)->getNumberOfComponents(); + int nbt=(*it++)->getNumberOfTuples(); + for(int i=1;it!=a.end();it++,i++) + { + if((*it)->getNumberOfComponents()!=nbOfComp) + throw INTERP_KERNEL::Exception("DataArrayDouble::Aggregate : Nb of components mismatch for array aggregation !"); + nbt+=(*it)->getNumberOfTuples(); + } DataArrayDouble *ret=DataArrayDouble::New(); - ret->alloc(nbOfTuple1+nbOfTuple2,nbOfComp); - double *pt=std::copy(a1->getConstPointer(),a1->getConstPointer()+nbOfTuple1*nbOfComp,ret->getPointer()); - std::copy(a2->getConstPointer(),a2->getConstPointer()+nbOfTuple2*nbOfComp,pt); - ret->copyStringInfoFrom(*a1); + ret->alloc(nbt,nbOfComp); + double *pt=ret->getPointer(); + for(it=a.begin();it!=a.end();it++) + pt=std::copy((*it)->getConstPointer(),(*it)->getConstPointer()+(*it)->getNbOfElems(),pt); + ret->copyStringInfoFrom(*(a[0])); + return ret; +} + +DataArrayDouble *DataArrayDouble::Meld(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception) +{ + std::vector arr(2); + arr[0]=a1; arr[1]=a2; + return Meld(arr); +} + +DataArrayDouble *DataArrayDouble::Meld(const std::vector& a) throw(INTERP_KERNEL::Exception) +{ + if(a.empty()) + throw INTERP_KERNEL::Exception("DataArrayDouble::Meld : array must be NON empty !"); + std::vector::const_iterator it; + for(it=a.begin();it!=a.end();it++) + (*it)->checkAllocated(); + it=a.begin(); + int nbOfTuples=(*it)->getNumberOfTuples(); + std::vector nbc(a.size()); + std::vector pts(a.size()); + nbc[0]=(*it)->getNumberOfComponents(); + pts[0]=(*it++)->getConstPointer(); + for(int i=1;it!=a.end();it++,i++) + { + if(nbOfTuples!=(*it)->getNumberOfTuples()) + throw INTERP_KERNEL::Exception("DataArrayDouble::Meld : mismatch of number of tuples !"); + nbc[i]=(*it)->getNumberOfComponents(); + pts[i]=(*it)->getConstPointer(); + } + int totalNbOfComp=std::accumulate(nbc.begin(),nbc.end(),0); + DataArrayDouble *ret=DataArrayDouble::New(); + ret->alloc(nbOfTuples,totalNbOfComp); + double *retPtr=ret->getPointer(); + for(int i=0;isetInfoOnComponent(k,a[i]->getInfoOnComponent(j).c_str()); return ret; } -DataArrayDouble *DataArrayDouble::dot(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception) +DataArrayDouble *DataArrayDouble::Dot(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception) { + a1->checkAllocated(); + a2->checkAllocated(); int nbOfComp=a1->getNumberOfComponents(); if(nbOfComp!=a2->getNumberOfComponents()) - throw INTERP_KERNEL::Exception("Nb of components mismatch for array dot !"); + throw INTERP_KERNEL::Exception("Nb of components mismatch for array Dot !"); int nbOfTuple=a1->getNumberOfTuples(); if(nbOfTuple!=a2->getNumberOfTuples()) - throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array dot !"); + throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array Dot !"); DataArrayDouble *ret=DataArrayDouble::New(); ret->alloc(nbOfTuple,1); double *retPtr=ret->getPointer(); @@ -941,7 +1704,7 @@ DataArrayDouble *DataArrayDouble::dot(const DataArrayDouble *a1, const DataArray return ret; } -DataArrayDouble *DataArrayDouble::crossProduct(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception) +DataArrayDouble *DataArrayDouble::CrossProduct(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception) { int nbOfComp=a1->getNumberOfComponents(); if(nbOfComp!=a2->getNumberOfComponents()) @@ -966,14 +1729,14 @@ DataArrayDouble *DataArrayDouble::crossProduct(const DataArrayDouble *a1, const return ret; } -DataArrayDouble *DataArrayDouble::max(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception) +DataArrayDouble *DataArrayDouble::Max(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception) { int nbOfComp=a1->getNumberOfComponents(); if(nbOfComp!=a2->getNumberOfComponents()) - throw INTERP_KERNEL::Exception("Nb of components mismatch for array max !"); + throw INTERP_KERNEL::Exception("Nb of components mismatch for array Max !"); int nbOfTuple=a1->getNumberOfTuples(); if(nbOfTuple!=a2->getNumberOfTuples()) - throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array max !"); + throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array Max !"); DataArrayDouble *ret=DataArrayDouble::New(); ret->alloc(nbOfTuple,nbOfComp); double *retPtr=ret->getPointer(); @@ -986,7 +1749,7 @@ DataArrayDouble *DataArrayDouble::max(const DataArrayDouble *a1, const DataArray return ret; } -DataArrayDouble *DataArrayDouble::min(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception) +DataArrayDouble *DataArrayDouble::Min(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception) { int nbOfComp=a1->getNumberOfComponents(); if(nbOfComp!=a2->getNumberOfComponents()) @@ -1006,14 +1769,11 @@ DataArrayDouble *DataArrayDouble::min(const DataArrayDouble *a1, const DataArray return ret; } -DataArrayDouble *DataArrayDouble::add(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception) +DataArrayDouble *DataArrayDouble::Add(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception) { - int nbOfComp=a1->getNumberOfComponents(); - if(nbOfComp!=a2->getNumberOfComponents()) - throw INTERP_KERNEL::Exception("Nb of components mismatch for array add !"); - int nbOfTuple=a1->getNumberOfTuples(); - if(nbOfTuple!=a2->getNumberOfTuples()) - throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array add !"); + int nbOfTuple=a2->getNumberOfTuples(); + int nbOfComp=a2->getNumberOfComponents(); + a1->checkNbOfTuplesAndComp(nbOfTuple,nbOfComp,"Nb of components mismatch for array Add !"); DataArrayDouble *ret=DataArrayDouble::New(); ret->alloc(nbOfTuple,nbOfComp); std::transform(a1->getConstPointer(),a1->getConstPointer()+nbOfTuple*nbOfComp,a2->getConstPointer(),ret->getPointer(),std::plus()); @@ -1023,24 +1783,18 @@ DataArrayDouble *DataArrayDouble::add(const DataArrayDouble *a1, const DataArray void DataArrayDouble::addEqual(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception) { - int nbOfComp=getNumberOfComponents(); - if(nbOfComp!=other->getNumberOfComponents()) - throw INTERP_KERNEL::Exception("Nb of components mismatch for array add !"); - int nbOfTuple=getNumberOfTuples(); - if(nbOfTuple!=other->getNumberOfTuples()) - throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array add !"); + int nbOfTuple=other->getNumberOfTuples(); + int nbOfComp=other->getNumberOfComponents(); + checkNbOfTuplesAndComp(nbOfTuple,nbOfComp,"Nb of components mismatch for array add equal !"); std::transform(getConstPointer(),getConstPointer()+nbOfTuple*nbOfComp,other->getConstPointer(),getPointer(),std::plus()); declareAsNew(); } -DataArrayDouble *DataArrayDouble::substract(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception) +DataArrayDouble *DataArrayDouble::Substract(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception) { - int nbOfComp=a1->getNumberOfComponents(); - if(nbOfComp!=a2->getNumberOfComponents()) - throw INTERP_KERNEL::Exception("Nb of components mismatch for array substract !"); - int nbOfTuple=a1->getNumberOfTuples(); - if(nbOfTuple!=a2->getNumberOfTuples()) - throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array substract !"); + int nbOfTuple=a2->getNumberOfTuples(); + int nbOfComp=a2->getNumberOfComponents(); + a1->checkNbOfTuplesAndComp(nbOfTuple,nbOfComp,"Nb of components mismatch for array Substract !"); DataArrayDouble *ret=DataArrayDouble::New(); ret->alloc(nbOfTuple,nbOfComp); std::transform(a1->getConstPointer(),a1->getConstPointer()+nbOfTuple*nbOfComp,a2->getConstPointer(),ret->getPointer(),std::minus()); @@ -1050,24 +1804,21 @@ DataArrayDouble *DataArrayDouble::substract(const DataArrayDouble *a1, const Dat void DataArrayDouble::substractEqual(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception) { - int nbOfComp=getNumberOfComponents(); - if(nbOfComp!=other->getNumberOfComponents()) - throw INTERP_KERNEL::Exception("Nb of components mismatch for array substract !"); - int nbOfTuple=getNumberOfTuples(); - if(nbOfTuple!=other->getNumberOfTuples()) - throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array substract !"); + int nbOfTuple=other->getNumberOfTuples(); + int nbOfComp=other->getNumberOfComponents(); + checkNbOfTuplesAndComp(nbOfTuple,nbOfComp,"Nb of components mismatch for array substract equal !"); std::transform(getConstPointer(),getConstPointer()+nbOfTuple*nbOfComp,other->getConstPointer(),getPointer(),std::minus()); declareAsNew(); } -DataArrayDouble *DataArrayDouble::multiply(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception) +DataArrayDouble *DataArrayDouble::Multiply(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception) { int nbOfTuple=a1->getNumberOfTuples(); int nbOfTuple2=a2->getNumberOfTuples(); int nbOfComp=a1->getNumberOfComponents(); int nbOfComp2=a2->getNumberOfComponents(); if(nbOfTuple!=nbOfTuple2) - throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array multiply !"); + throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array Multiply !"); DataArrayDouble *ret=0; if(nbOfComp==nbOfComp2) { @@ -1102,7 +1853,7 @@ DataArrayDouble *DataArrayDouble::multiply(const DataArrayDouble *a1, const Data ret->copyStringInfoFrom(*aMax); } else - throw INTERP_KERNEL::Exception("Nb of components mismatch for array multiply !"); + throw INTERP_KERNEL::Exception("Nb of components mismatch for array Multiply !"); } return ret; } @@ -1134,63 +1885,204 @@ void DataArrayDouble::multiplyEqual(const DataArrayDouble *other) throw(INTERP_K declareAsNew(); } -DataArrayDouble *DataArrayDouble::divide(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception) +DataArrayDouble *DataArrayDouble::Divide(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception) { - int nbOfComp=a1->getNumberOfComponents(); - if(nbOfComp!=a2->getNumberOfComponents()) - throw INTERP_KERNEL::Exception("Nb of components mismatch for array divide !"); int nbOfTuple=a1->getNumberOfTuples(); - if(nbOfTuple!=a2->getNumberOfTuples()) - throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array divide !"); - DataArrayDouble *ret=DataArrayDouble::New(); - ret->alloc(nbOfTuple,nbOfComp); - std::transform(a1->getConstPointer(),a1->getConstPointer()+nbOfTuple*nbOfComp,a2->getConstPointer(),ret->getPointer(),std::divides()); - ret->copyStringInfoFrom(*a1); + int nbOfTuple2=a2->getNumberOfTuples(); + int nbOfComp=a1->getNumberOfComponents(); + int nbOfComp2=a2->getNumberOfComponents(); + if(nbOfTuple!=nbOfTuple2) + throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array Divide !"); + DataArrayDouble *ret=0; + if(nbOfComp==nbOfComp2) + { + ret=DataArrayDouble::New(); + ret->alloc(nbOfTuple,nbOfComp); + std::transform(a1->getConstPointer(),a1->getConstPointer()+nbOfTuple*nbOfComp,a2->getConstPointer(),ret->getPointer(),std::divides()); + ret->copyStringInfoFrom(*a1); + } + else + { + if(nbOfComp2==1) + { + ret=DataArrayDouble::New(); + ret->alloc(nbOfTuple,nbOfComp); + const double *a2Ptr=a2->getConstPointer(); + const double *a1Ptr=a1->getConstPointer(); + double *res=ret->getPointer(); + for(int i=0;i(),a2Ptr[i])); + ret->copyStringInfoFrom(*a1); + } + else + throw INTERP_KERNEL::Exception("Nb of components mismatch for array Divide !"); + } return ret; } void DataArrayDouble::divideEqual(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception) { - int nbOfComp=getNumberOfComponents(); - if(nbOfComp!=other->getNumberOfComponents()) - throw INTERP_KERNEL::Exception("Nb of components mismatch for array divideEqual !"); int nbOfTuple=getNumberOfTuples(); - if(nbOfTuple!=other->getNumberOfTuples()) + int nbOfTuple2=other->getNumberOfTuples(); + int nbOfComp=getNumberOfComponents(); + int nbOfComp2=other->getNumberOfComponents(); + if(nbOfTuple!=nbOfTuple2) throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array divideEqual !"); - std::transform(getConstPointer(),getConstPointer()+nbOfTuple*nbOfComp,other->getConstPointer(),getPointer(),std::divides()); + if(nbOfComp==nbOfComp2) + { + std::transform(getConstPointer(),getConstPointer()+nbOfTuple*nbOfComp,other->getConstPointer(),getPointer(),std::divides()); + } + else + { + if(nbOfComp2==1) + { + const double *ptr=other->getConstPointer(); + double *myPtr=getPointer(); + for(int i=0;i(),ptr[i])); + } + else + throw INTERP_KERNEL::Exception("Nb of components mismatch for array divideEqual !"); + } declareAsNew(); } -DataArrayInt *DataArrayInt::New() -{ - return new DataArrayInt; -} - -DataArrayInt *DataArrayInt::deepCopy() const +/*! + * Useless method for end user. Only for MPI/Corba/File serialsation for multi arrays class. + * Server side. + */ +void DataArrayDouble::getTinySerializationIntInformation(std::vector& tinyInfo) const { - return new DataArrayInt(*this); + tinyInfo.resize(2); + if(isAllocated()) + { + tinyInfo[0]=getNumberOfTuples(); + tinyInfo[1]=getNumberOfComponents(); + } + else + { + tinyInfo[0]=-1; + tinyInfo[1]=-1; + } } -DataArrayInt *DataArrayInt::performCpy(bool deepCpy) const +/*! + * Useless method for end user. Only for MPI/Corba/File serialsation for multi arrays class. + * Server side. + */ +void DataArrayDouble::getTinySerializationStrInformation(std::vector& tinyInfo) const { - if(deepCpy) - return deepCopy(); + if(isAllocated()) + { + int nbOfCompo=getNumberOfComponents(); + tinyInfo.resize(nbOfCompo+1); + tinyInfo[0]=getName(); + for(int i=0;i(this); + tinyInfo.resize(1); + tinyInfo[0]=getName(); } } -void DataArrayInt::alloc(int nbOfTuple, int nbOfCompo) +/*! + * Useless method for end user. Only for MPI/Corba/File serialsation for multi arrays class. + * This method returns if a feeding is needed. + */ +bool DataArrayDouble::resizeForUnserialization(const std::vector& tinyInfoI) { - _nb_of_tuples=nbOfTuple; - _info_on_compo.resize(nbOfCompo); - _mem.alloc(nbOfCompo*_nb_of_tuples); - declareAsNew(); + int nbOfTuple=tinyInfoI[0]; + int nbOfComp=tinyInfoI[1]; + if(nbOfTuple!=-1 || nbOfComp!=-1) + { + alloc(nbOfTuple,nbOfComp); + return true; + } + return false; } -void DataArrayInt::fillWithZero() +/*! + * 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) +{ + setName(tinyInfoS[0].c_str()); + if(isAllocated()) + { + int nbOfCompo=getNumberOfComponents(); + for(int i=0;i(this); + } +} + +void DataArrayInt::cpyFrom(const DataArrayInt& other) throw(INTERP_KERNEL::Exception) +{ + other.checkAllocated(); + int nbOfTuples=other.getNumberOfTuples(); + int nbOfComp=other.getNumberOfComponents(); + allocIfNecessary(nbOfTuples,nbOfComp); + int nbOfElems=nbOfTuples*nbOfComp; + int *pt=getPointer(); + const int *ptI=other.getConstPointer(); + for(int i=0;i=0 && *pt ret=DataArrayInt::New(); + ret->alloc(nbOfTuples,1); + ret->fillWithValue(-1); + int *tmp=ret->getPointer(); + for(int i=0;i=0 && posincrRef(); + return ret; } /*! @@ -1294,6 +2235,60 @@ bool DataArrayInt::isEqualWithoutConsideringStr(const DataArrayInt& other) const return _mem.isEqual(other._mem,0); } +bool DataArrayInt::isEqualWithoutConsideringStrAndOrder(const DataArrayInt& other) const throw(INTERP_KERNEL::Exception) +{ + MEDCouplingAutoRefCountObjectPtr a=deepCpy(); + MEDCouplingAutoRefCountObjectPtr b=other.deepCpy(); + a->sort(); + b->sort(); + return a->isEqualWithoutConsideringStr(*b); +} + +void DataArrayInt::sort() throw(INTERP_KERNEL::Exception) +{ + checkAllocated(); + if(getNumberOfComponents()!=1) + throw INTERP_KERNEL::Exception("DataArrayInt::sort : only supported with 'this' array with ONE component !"); + _mem.sort(); +} + +/*! + * This method expects that 'this' and 'other' have the same number of tuples and exactly one component both. If not an exception will be thrown. + * This method retrieves a newly created array with same number of tuples than 'this' and 'other' with one component. + * The returned array 'ret' contains the correspondance from 'this' to 'other' that is to say for every i so that 0<=igetIJ(ret->getIJ(i),0) + * If such permutation is not possible because it exists some elements in 'other' not in 'this', an exception will be thrown. + */ +DataArrayInt *DataArrayInt::buildPermutationArr(const DataArrayInt& other) const throw(INTERP_KERNEL::Exception) +{ + if(getNumberOfComponents()!=1 || other.getNumberOfComponents()!=1) + throw INTERP_KERNEL::Exception("DataArrayInt::buildPermutationArr : 'this' and 'other' have to have exactly ONE component !"); + int nbTuple=getNumberOfTuples(); + if(nbTuple!=other.getNumberOfTuples()) + throw INTERP_KERNEL::Exception("DataArrayInt::buildPermutationArr : 'this' and 'other' must have the same number of tuple !"); + MEDCouplingAutoRefCountObjectPtr ret=DataArrayInt::New(); + ret->alloc(nbTuple,1); + ret->fillWithValue(-1); + const int *pt=getConstPointer(); + std::map mm; + for(int i=0;igetPointer(); + for(int i=0;i::const_iterator it=mm.find(pt[i]); + if(it==mm.end()) + { + std::ostringstream oss; oss << "DataArrayInt::buildPermutationArr : Arrays mismatch : element (" << pt[i] << ") in 'other' not findable in 'this' !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + retToFill[i]=(*it).second; + } + ret->incrRef(); + return ret; +} + void DataArrayInt::useArray(const int *array, bool ownership, DeallocType type, int nbOfTuple, int nbOfCompo) { _nb_of_tuples=nbOfTuple; @@ -1302,6 +2297,26 @@ void DataArrayInt::useArray(const int *array, bool ownership, DeallocType type, declareAsNew(); } +DataArrayInt *DataArrayInt::fromNoInterlace() const throw(INTERP_KERNEL::Exception) +{ + if(_mem.isNull()) + throw INTERP_KERNEL::Exception("DataArrayInt::fromNoInterlace : Not defined array !"); + int *tab=_mem.fromNoInterlace(getNumberOfComponents()); + DataArrayInt *ret=DataArrayInt::New(); + ret->useArray(tab,true,CPP_DEALLOC,getNumberOfTuples(),getNumberOfComponents()); + return ret; +} + +DataArrayInt *DataArrayInt::toNoInterlace() const throw(INTERP_KERNEL::Exception) +{ + if(_mem.isNull()) + throw INTERP_KERNEL::Exception("DataArrayInt::toNoInterlace : Not defined array !"); + int *tab=_mem.toNoInterlace(getNumberOfComponents()); + DataArrayInt *ret=DataArrayInt::New(); + ret->useArray(tab,true,CPP_DEALLOC,getNumberOfTuples(),getNumberOfComponents()); + return ret; +} + void DataArrayInt::renumberInPlace(const int *old2New) { int nbTuples=getNumberOfTuples(); @@ -1328,6 +2343,11 @@ void DataArrayInt::renumberInPlaceR(const int *new2Old) declareAsNew(); } +/*! + * This method expects that 'this' is allocated, if not an exception is thrown. + * This method in case of success returns a newly created array the user should deal with. + * In the case of having a renumber array in "old to new" format. More info on renumbering \ref MEDCouplingArrayRenumbering "here". + */ DataArrayInt *DataArrayInt::renumber(const int *old2New) const { int nbTuples=getNumberOfTuples(); @@ -1401,6 +2421,174 @@ DataArrayInt *DataArrayInt::selectByTupleId(const int *new2OldBg, const int *new return ret; } +/*! + * This method is equivalent to DataArrayInt::selectByTupleId except that an analyze to the content of input range to check that it will not lead to memory corruption ! + */ +DataArrayInt *DataArrayInt::selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const throw(INTERP_KERNEL::Exception) +{ + MEDCouplingAutoRefCountObjectPtr ret=DataArrayInt::New(); + int nbComp=getNumberOfComponents(); + int oldNbOfTuples=getNumberOfTuples(); + ret->alloc(std::distance(new2OldBg,new2OldEnd),nbComp); + ret->copyStringInfoFrom(*this); + int *pt=ret->getPointer(); + const int *srcPt=getConstPointer(); + int i=0; + for(const int *w=new2OldBg;w!=new2OldEnd;w++,i++) + if(*w>=0 && *wgetNumberOfTuples) !"); + ret->copyStringInfoFrom(*this); + ret->incrRef(); + return ret; +} + +/*! + * Idem than DataArrayInt::selectByTupleIdSafe except that the input array is not constructed explicitely. + * The convention is as python one. ['bg','end') with steps of 'step'. + * Returns a newly created array. + */ +DataArrayInt *DataArrayInt::selectByTupleId2(int bg, int end, int step) const throw(INTERP_KERNEL::Exception) +{ + if(end 0 !"); + MEDCouplingAutoRefCountObjectPtr ret=DataArrayInt::New(); + int nbComp=getNumberOfComponents(); + int newNbOfTuples=(end+1-bg)/step-1; + ret->alloc(newNbOfTuples,nbComp); + int *pt=ret->getPointer(); + const int *srcPt=getConstPointer()+bg*nbComp; + for(int i=0;icopyStringInfoFrom(*this); + ret->incrRef(); + return ret; +} + +/*! + * This method works only for arrays having single component. + * If this contains the array a1 containing [9,10,0,6,4,11,3,7] this method returns an array a2 [5,6,0,3,2,7,1,4]. + * By doing a1.renumber(a2) the user will obtain array a3 equal to a1 sorted. + * This method is useful for renumbering (in MED file for example). This method is used by MEDCouplingFieldDouble::renumberCells when check is set to true. + * This method throws an exception if more 2 or more elements in 'this' are same. + */ +DataArrayInt *DataArrayInt::checkAndPreparePermutation() const throw(INTERP_KERNEL::Exception) +{ + checkAllocated(); + if(getNumberOfComponents()!=1) + throw INTERP_KERNEL::Exception("DataArrayInt::checkAndPreparePermutation : number of components must == 1 !"); + int nbTuples=getNumberOfTuples(); + const int *pt=getConstPointer(); + int *pt2=CheckAndPreparePermutation(pt,pt+nbTuples); + DataArrayInt *ret=DataArrayInt::New(); + ret->useArray(pt2,true,CPP_DEALLOC,nbTuples,1); + return ret; +} + +/*! + * This method makes the assumption that 'this' is correctly set, and has exactly one component. If not an exception will be thrown. + * Given a sujective application defined by 'this' from a set of size this->getNumberOfTuples() to a set of size targetNb. + * 'targetNb'getNumberOfTuples(). 'this' should be surjective that is to say for each id in [0,'targetNb') it exists at least one tupleId tid + * so that this->getIJ(tid,0)==id. + * If not an exception will be thrown. + * This method returns 2 newly allocated arrays 'arr' and 'arrI', corresponding respectively to array and its corresponding index. + * This method is usefull for methods that returns old2New numbering concecutive to a reduction ( MEDCouplingUMesh::zipConnectivityTraducer, MEDCouplingUMesh::zipConnectivityTraducer for example) + * Example : if 'this' equals [0,3,2,3,2,2,1,2] this method will return arrI=[0,1,2,6,8] arr=[0, 6, 2,4,5,7, 1,3] + * That is to say elt id 2 has arrI[2+1]-arrI[2]=4 places in 'this'. The corresponding tuple ids are [2,4,5,7]. + */ +void DataArrayInt::changeSurjectiveFormat(int targetNb, DataArrayInt *&arr, DataArrayInt *&arrI) const throw(INTERP_KERNEL::Exception) +{ + checkAllocated(); + if(getNumberOfComponents()!=1) + throw INTERP_KERNEL::Exception("DataArrayInt::changeSurjectiveFormat : number of components must == 1 !"); + int nbOfTuples=getNumberOfTuples(); + MEDCouplingAutoRefCountObjectPtr ret(DataArrayInt::New()); + MEDCouplingAutoRefCountObjectPtr retI(DataArrayInt::New()); + retI->alloc(targetNb+1,1); + const int *input=getConstPointer(); + std::vector< std::vector > tmp(targetNb); + for(int i=0;igetPointer(); + *retIPtr=0; + for(std::vector< std::vector >::const_iterator it1=tmp.begin();it1!=tmp.end();it1++,retIPtr++) + retIPtr[1]=retIPtr[0]+(*it1).size(); + if(nbOfTuples!=retI->getIJ(targetNb,0)) + throw INTERP_KERNEL::Exception("DataArrayInt::changeSurjectiveFormat : big problem should never happen !"); + ret->alloc(nbOfTuples,1); + int *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); + ret->incrRef(); + retI->incrRef(); + arr=ret; + arrI=retI; +} + +/*! + * This method expects that 'this' is allocated and with only one component. If not an exception will be thrown. + * This method returns a newly created array with 'this->getNumberOfTuples()' tuples and 1 component. + * This methods returns an 'old2New' corresponding array that allows to follow the following rules : + * - Lower a value in tuple in 'this' is, higher is its priority. + * - If two tuples i and j have same value if igetNumberOfTuples()-1' + * + * Example if 'this' contains the following array : [2,0,1,1,0,1,2,0,1,1,0,0] this method returns [10,0,5,6,1,7,11,2,8,9,3,4] + */ +DataArrayInt *DataArrayInt::buildPermArrPerLevel() const throw(INTERP_KERNEL::Exception) +{ + checkAllocated(); + if(getNumberOfComponents()!=1) + throw INTERP_KERNEL::Exception("DataArrayInt::buildPermArrPerLevel : number of components must == 1 !"); + int nbOfTuples=getNumberOfTuples(); + const int *pt=getConstPointer(); + std::map m; + MEDCouplingAutoRefCountObjectPtr ret=DataArrayInt::New(); + ret->alloc(nbOfTuples,1); + int *opt=ret->getPointer(); + for(int i=0;i::iterator it=m.find(val); + if(it!=m.end()) + { + *opt=(*it).second; + (*it).second++; + } + else + { + *opt=0; + m.insert(std::pair(val,1)); + } + } + int sum=0; + for(std::map::iterator it=m.begin();it!=m.end();it++) + { + int vt=(*it).second; + (*it).second=sum; + sum+=vt; + } + pt=getConstPointer(); + opt=ret->getPointer(); + for(int i=0;iincrRef(); + return ret; +} + /*! * This method checks that 'this' is with numberofcomponents == 1 and that it is equal to * stdext::iota() of size getNumberOfTuples. This method is particalary usefull for DataArrayInt instances @@ -1418,6 +2606,19 @@ bool DataArrayInt::isIdentity() const return true; } +bool DataArrayInt::isUniform(int val) const +{ + if(getNumberOfComponents()!=1) + throw INTERP_KERNEL::Exception("DataArrayInt::isUniform : must be applied on DataArrayInt with only one component, you can call 'rearrange' method before !"); + int nbOfTuples=getNumberOfTuples(); + const int *w=getConstPointer(); + const int *end=w+nbOfTuples; + for(;w!=end;w++) + if(*w!=val) + return false; + return true; +} + DataArrayDouble *DataArrayInt::convertToDblArr() const { DataArrayDouble *ret=DataArrayDouble::New(); @@ -1440,8 +2641,8 @@ DataArrayInt *DataArrayInt::substr(int tupleIdBg, int tupleIdEnd) const throw(IN int nbt=getNumberOfTuples(); if(tupleIdBg<0) throw INTERP_KERNEL::Exception("DataArrayInt::substr : The tupleIdBg parameter must be greater than 0 !"); - if(tupleIdBg>=nbt) - throw INTERP_KERNEL::Exception("DataArrayInt::substr : The tupleIdBg parameter is greater or equal than number of tuples !"); + if(tupleIdBg>nbt) + throw INTERP_KERNEL::Exception("DataArrayInt::substr : The tupleIdBg parameter is greater than number of tuples !"); int trueEnd=tupleIdEnd; if(tupleIdEnd!=-1) { @@ -1458,6 +2659,25 @@ DataArrayInt *DataArrayInt::substr(int tupleIdBg, int tupleIdEnd) const throw(IN return ret; } +/*! + * Contrary to DataArrayInt::changeNbOfComponents method this method is \b not const. The content + * This method \b do \b not change the content of data but changes the splitting of this data seen by the caller. + * This method makes the assumption that 'this' is already allocated. If not an exception will be thrown. + * This method checks that getNbOfElems()%newNbOfCompo==0. If not an exception will be throw ! + * This method erases all components info set before call ! + */ +void DataArrayInt::rearrange(int newNbOfCompo) throw(INTERP_KERNEL::Exception) +{ + checkAllocated(); + int nbOfElems=getNbOfElems(); + if(nbOfElems%newNbOfCompo!=0) + throw INTERP_KERNEL::Exception("DataArrayInt::rearrange : nbOfElems%newNbOfCompo!=0 !"); + _nb_of_tuples=nbOfElems/newNbOfCompo; + _info_on_compo.clear(); + _info_on_compo.resize(newNbOfCompo); + declareAsNew(); +} + /*! * This method builds a new instance of DataArrayInt (to deal with) that is reduction or an extension of 'this'. * if 'newNbOfComp' < this->getNumberOfComponents() a reduction is done and for each tuple 'newNbOfComp' first components are kept. @@ -1465,6 +2685,7 @@ DataArrayInt *DataArrayInt::substr(int tupleIdBg, int tupleIdEnd) const throw(IN */ DataArrayInt *DataArrayInt::changeNbOfComponents(int newNbOfComp, int dftValue) const throw(INTERP_KERNEL::Exception) { + checkAllocated(); DataArrayInt *ret=DataArrayInt::New(); ret->alloc(getNumberOfTuples(),newNbOfComp); const int *oldc=getConstPointer(); @@ -1487,8 +2708,9 @@ DataArrayInt *DataArrayInt::changeNbOfComponents(int newNbOfComp, int dftValue) return ret; } -void DataArrayInt::reAlloc(int nbOfTuples) +void DataArrayInt::reAlloc(int nbOfTuples) throw(INTERP_KERNEL::Exception) { + checkAllocated(); _mem.reAlloc(_info_on_compo.size()*nbOfTuples); _nb_of_tuples=nbOfTuples; declareAsNew(); @@ -1496,9 +2718,12 @@ void DataArrayInt::reAlloc(int nbOfTuples) DataArrayInt *DataArrayInt::keepSelectedComponents(const std::vector& compoIds) const throw(INTERP_KERNEL::Exception) { + checkAllocated(); MEDCouplingAutoRefCountObjectPtr ret(DataArrayInt::New()); int newNbOfCompo=compoIds.size(); int oldNbOfCompo=getNumberOfComponents(); + for(std::vector::const_iterator it=compoIds.begin();it!=compoIds.end();it++) + DataArray::CheckValueInRange(oldNbOfCompo,(*it),"keepSelectedComponents invalid requested component"); int nbOfTuples=getNumberOfTuples(); ret->alloc(nbOfTuples,newNbOfCompo); ret->copyPartOfStringInfoFrom(*this,compoIds); @@ -1511,6 +2736,37 @@ DataArrayInt *DataArrayInt::keepSelectedComponents(const std::vector& compo return ret; } +/*! + * This method melds the components of 'this' with components of 'other'. + * After this call in case of success, 'this' will contain a number of components equal to the sum of 'this' + * before the call and the number of components of 'other'. + * This method expects that 'this' and 'other' have exactly the same number of tuples. If not an exception is thrown. + */ +void DataArrayInt::meldWith(const DataArrayInt *other) throw(INTERP_KERNEL::Exception) +{ + checkAllocated(); + other->checkAllocated(); + int nbOfTuples=getNumberOfTuples(); + if(nbOfTuples!=other->getNumberOfTuples()) + throw INTERP_KERNEL::Exception("DataArrayInt::meldWith : mismatch of number of tuples !"); + int nbOfComp1=getNumberOfComponents(); + int nbOfComp2=other->getNumberOfComponents(); + int *newArr=new int[nbOfTuples*(nbOfComp1+nbOfComp2)]; + int *w=newArr; + const int *inp1=getConstPointer(); + const int *inp2=other->getConstPointer(); + for(int i=0;i compIds(nbOfComp2); + for(int i=0;i& compoIds) throw(INTERP_KERNEL::Exception) { copyPartOfStringInfoFrom2(compoIds,*a); @@ -1524,59 +2780,474 @@ void DataArrayInt::setSelectedComponents(const DataArrayInt *a, const std::vecto nc[nbOfCompo*i+compoIds[j]]=*ac; } -void DataArrayInt::setArrayIn(DataArrayInt *newArray, DataArrayInt* &arrayToSet) +/*! + * This method performs a partial assignment of 'this' using 'a' as input. Other input parameters specifies the subpart being considered by the assignment. + * 'strictCompoCompare' specifies if DataArray 'a' should have exactly same number of components and tuples than 'this' (true) or not (false). By default set to true with maximal test. + */ +void DataArrayInt::setPartOfValues1(const DataArrayInt *a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare) throw(INTERP_KERNEL::Exception) { - if(newArray!=arrayToSet) - { - if(arrayToSet) - arrayToSet->decrRef(); - arrayToSet=newArray; - if(arrayToSet) - arrayToSet->incrRef(); - } + const char msg[]="DataArrayInt::setPartOfValues1"; + checkAllocated(); + a->checkAllocated(); + int newNbOfTuples=DataArray::GetNumberOfItemGivenBES(bgTuples,endTuples,stepTuples,msg); + int newNbOfComp=DataArray::GetNumberOfItemGivenBES(bgComp,endComp,stepComp,msg); + int nbComp=getNumberOfComponents(); + int nbOfTuples=getNumberOfTuples(); + DataArray::CheckValueInRange(nbOfTuples,bgTuples,"invalid begin tuple value"); + DataArray::CheckClosingParInRange(nbOfTuples,endTuples,"invalid end tuple value"); + DataArray::CheckValueInRange(nbComp,bgComp,"invalid begin component value"); + DataArray::CheckClosingParInRange(nbComp,endComp,"invalid end component value"); + a->checkNbOfElems(newNbOfTuples*newNbOfComp,msg); + if(strictCompoCompare) + a->checkNbOfTuplesAndComp(newNbOfTuples,newNbOfComp,msg); + int *pt=getPointer()+bgTuples*nbComp+bgComp; + const int *srcPt=a->getConstPointer(); + for(int i=0;igetNumberOfComponents(); - if(nbOfComp!=a2->getNumberOfComponents()) - throw INTERP_KERNEL::Exception("Nb of components mismatch for array aggregation !"); - int nbOfTuple1=a1->getNumberOfTuples(); - int nbOfTuple2=a2->getNumberOfTuples(); - DataArrayInt *ret=DataArrayInt::New(); - ret->alloc(nbOfTuple1+nbOfTuple2-offsetA2,nbOfComp); - int *pt=std::copy(a1->getConstPointer(),a1->getConstPointer()+nbOfTuple1*nbOfComp,ret->getPointer()); - std::copy(a2->getConstPointer()+offsetA2*nbOfComp,a2->getConstPointer()+nbOfTuple2*nbOfComp,pt); - ret->copyStringInfoFrom(*a1); - return ret; + const char msg[]="DataArrayInt::setPartOfValuesSimple1"; + checkAllocated(); + int newNbOfTuples=DataArray::GetNumberOfItemGivenBES(bgTuples,endTuples,stepTuples,msg); + int newNbOfComp=DataArray::GetNumberOfItemGivenBES(bgComp,endComp,stepComp,msg); + int nbComp=getNumberOfComponents(); + int nbOfTuples=getNumberOfTuples(); + DataArray::CheckValueInRange(nbOfTuples,bgTuples,"invalid begin tuple value"); + DataArray::CheckClosingParInRange(nbOfTuples,endTuples,"invalid end tuple value"); + DataArray::CheckValueInRange(nbComp,bgComp,"invalid begin component value"); + DataArray::CheckClosingParInRange(nbComp,endComp,"invalid end component value"); + int *pt=getPointer()+bgTuples*nbComp+bgComp; + for(int i=0;i& groups, int newNb, std::vector< std::vector >& fidsOfGroups) +void DataArrayInt::setPartOfValues2(const DataArrayInt *a, const int *bgTuples, const int *endTuples, const int *bgComp, const int *endComp, bool strictCompoCompare) throw(INTERP_KERNEL::Exception) { - DataArrayInt *ret=DataArrayInt::New(); - ret->alloc(newNb,1); - int *retPtr=ret->getPointer(); - std::fill(retPtr,retPtr+newNb,0); - int fid=1; - for(std::vector::const_iterator iter=groups.begin();iter!=groups.end();iter++) - { - const int *ptr=(*iter)->getConstPointer(); - int nbOfElem=(*iter)->getNbOfElems(); - int sfid=fid; - for(int j=0;jcheckAllocated(); + int nbComp=getNumberOfComponents(); + int nbOfTuples=getNumberOfTuples(); + for(const int *z=bgComp;z!=endComp;z++) + DataArray::CheckValueInRange(nbComp,*z,"invalid component id"); + int newNbOfTuples=std::distance(bgTuples,endTuples); + int newNbOfComp=std::distance(bgComp,endComp); + a->checkNbOfElems(newNbOfTuples*newNbOfComp,msg); + if(strictCompoCompare) + a->checkNbOfTuplesAndComp(newNbOfTuples,newNbOfComp,msg); + int *pt=getPointer(); + const int *srcPt=a->getConstPointer(); + for(const int *w=bgTuples;w!=endTuples;w++) + for(const int *z=bgComp;z!=endComp;z++,srcPt++) + { + DataArray::CheckValueInRange(nbOfTuples,*w,"invalid tuple id"); + pt[(*w)*nbComp+(*z)]=*srcPt; + } +} + +/*! + * This method performs a partial assignment of 'this' using 'a' as input. Other input parameters specifies the subpart being considered by the assignment. + */ +void DataArrayInt::setPartOfValuesSimple2(int a, const int *bgTuples, const int *endTuples, const int *bgComp, const int *endComp) throw(INTERP_KERNEL::Exception) +{ + checkAllocated(); + int nbComp=getNumberOfComponents(); + int nbOfTuples=getNumberOfTuples(); + for(const int *z=bgComp;z!=endComp;z++) + DataArray::CheckValueInRange(nbComp,*z,"invalid component id"); + int *pt=getPointer(); + for(const int *w=bgTuples;w!=endTuples;w++) + for(const int *z=bgComp;z!=endComp;z++) + { + DataArray::CheckValueInRange(nbOfTuples,*w,"invalid tuple id"); + pt[(*w)*nbComp+(*z)]=a; + } +} + +/*! + * This method performs a partial assignment of 'this' using 'a' as input. Other input parameters specifies the subpart being considered by the assignment. + * 'strictCompoCompare' specifies if DataArray 'a' should have exactly same number of components and tuples than 'this' (true) or not (false). By default set to true with maximal test. + */ +void DataArrayInt::setPartOfValues3(const DataArrayInt *a, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare) throw(INTERP_KERNEL::Exception) +{ + const char msg[]="DataArrayInt::setPartOfValues3"; + checkAllocated(); + a->checkAllocated(); + int newNbOfComp=DataArray::GetNumberOfItemGivenBES(bgComp,endComp,stepComp,msg); + int nbComp=getNumberOfComponents(); + int nbOfTuples=getNumberOfTuples(); + DataArray::CheckValueInRange(nbComp,bgComp,"invalid begin component value"); + DataArray::CheckClosingParInRange(nbComp,endComp,"invalid end component value"); + int newNbOfTuples=std::distance(bgTuples,endTuples); + a->checkNbOfElems(newNbOfTuples*newNbOfComp,msg); + if(strictCompoCompare) + a->checkNbOfTuplesAndComp(newNbOfTuples,newNbOfComp,msg); + int *pt=getPointer()+bgComp; + const int *srcPt=a->getConstPointer(); + for(const int *w=bgTuples;w!=endTuples;w++) + for(int j=0;jdecrRef(); + arrayToSet=newArray; + if(arrayToSet) + arrayToSet->incrRef(); + } +} + +DataArrayInt *DataArrayInt::getIdsEqual(int val) const throw(INTERP_KERNEL::Exception) +{ + if(getNumberOfComponents()!=1) + throw INTERP_KERNEL::Exception("DataArrayInt::getIdsEqual : the array must have only one component, you can call 'rearrange' method before !"); + const int *cptr=getConstPointer(); + std::vector res; + int nbOfTuples=getNumberOfTuples(); + for(int i=0;ialloc(res.size(),1); + std::copy(res.begin(),res.end(),ret->getPointer()); + return ret; +} + +DataArrayInt *DataArrayInt::getIdsNotEqual(int val) const throw(INTERP_KERNEL::Exception) +{ + if(getNumberOfComponents()!=1) + throw INTERP_KERNEL::Exception("DataArrayInt::getIdsNotEqual : the array must have only one component, you can call 'rearrange' method before !"); + const int *cptr=getConstPointer(); + std::vector res; + int nbOfTuples=getNumberOfTuples(); + for(int i=0;ialloc(res.size(),1); + std::copy(res.begin(),res.end(),ret->getPointer()); + return ret; +} + +DataArrayInt *DataArrayInt::getIdsEqualList(const std::vector& vals) const throw(INTERP_KERNEL::Exception) +{ + if(getNumberOfComponents()!=1) + throw INTERP_KERNEL::Exception("DataArrayInt::getIdsEqualList : the array must have only one component, you can call 'rearrange' method before !"); + std::set vals2(vals.begin(),vals.end()); + const int *cptr=getConstPointer(); + std::vector res; + int nbOfTuples=getNumberOfTuples(); + for(int i=0;ialloc(res.size(),1); + std::copy(res.begin(),res.end(),ret->getPointer()); + return ret; +} + +DataArrayInt *DataArrayInt::getIdsNotEqualList(const std::vector& vals) const throw(INTERP_KERNEL::Exception) +{ + if(getNumberOfComponents()!=1) + throw INTERP_KERNEL::Exception("DataArrayInt::getIdsNotEqualList : the array must have only one component, you can call 'rearrange' method before !"); + std::set vals2(vals.begin(),vals.end()); + const int *cptr=getConstPointer(); + std::vector res; + int nbOfTuples=getNumberOfTuples(); + for(int i=0;ialloc(res.size(),1); + std::copy(res.begin(),res.end(),ret->getPointer()); + return ret; +} + +/*! + * This method expects to be called when number of components of this is equal to one. + * This method returns true if it exists a tuple so that the value is contained in 'vals'. + * If not any tuple contains one of the values contained in 'vals' false is returned. + */ +bool DataArrayInt::presenceOfValue(const std::vector& vals) const throw(INTERP_KERNEL::Exception) +{ + if(getNumberOfComponents()!=1) + throw INTERP_KERNEL::Exception("DataArrayInt::presenceOfValue : the array must have only one component, you can call 'rearrange' method before !"); + std::set vals2(vals.begin(),vals.end()); + const int *cptr=getConstPointer(); + int nbOfTuples=getNumberOfTuples(); + bool found=false; + for(const int *w=cptr;w!=cptr+nbOfTuples && !found;w++) + found=(vals2.find(*w)!=vals2.end()); + return found; +} + +DataArrayInt *DataArrayInt::Aggregate(const DataArrayInt *a1, const DataArrayInt *a2, int offsetA2) +{ + int nbOfComp=a1->getNumberOfComponents(); + if(nbOfComp!=a2->getNumberOfComponents()) + throw INTERP_KERNEL::Exception("Nb of components mismatch for array Aggregation !"); + int nbOfTuple1=a1->getNumberOfTuples(); + int nbOfTuple2=a2->getNumberOfTuples(); + DataArrayInt *ret=DataArrayInt::New(); + ret->alloc(nbOfTuple1+nbOfTuple2-offsetA2,nbOfComp); + int *pt=std::copy(a1->getConstPointer(),a1->getConstPointer()+nbOfTuple1*nbOfComp,ret->getPointer()); + std::copy(a2->getConstPointer()+offsetA2*nbOfComp,a2->getConstPointer()+nbOfTuple2*nbOfComp,pt); + ret->copyStringInfoFrom(*a1); + return ret; +} + +DataArrayInt *DataArrayInt::Aggregate(const std::vector& a) throw(INTERP_KERNEL::Exception) +{ + if(a.empty()) + throw INTERP_KERNEL::Exception("DataArrayInt::Aggregate : input list must be NON EMPTY !"); + std::vector::const_iterator it=a.begin(); + int nbOfComp=(*it)->getNumberOfComponents(); + int nbt=(*it++)->getNumberOfTuples(); + for(int i=1;it!=a.end();it++,i++) + { + if((*it)->getNumberOfComponents()!=nbOfComp) + throw INTERP_KERNEL::Exception("DataArrayInt::Aggregate : Nb of components mismatch for array aggregation !"); + nbt+=(*it)->getNumberOfTuples(); + } + DataArrayInt *ret=DataArrayInt::New(); + ret->alloc(nbt,nbOfComp); + int *pt=ret->getPointer(); + for(it=a.begin();it!=a.end();it++) + pt=std::copy((*it)->getConstPointer(),(*it)->getConstPointer()+(*it)->getNbOfElems(),pt); + ret->copyStringInfoFrom(*(a[0])); + return ret; +} + +int DataArrayInt::getMaxValue(int& tupleId) const throw(INTERP_KERNEL::Exception) +{ + if(getNumberOfComponents()!=1) + throw INTERP_KERNEL::Exception("DataArrayDouble::getMaxValue : must be applied on DataArrayDouble with only one component !"); + int nbOfTuples=getNumberOfTuples(); + if(nbOfTuples<=0) + throw INTERP_KERNEL::Exception("DataArrayDouble::getMaxValue : array exists but number of tuples must be > 0 !"); + const int *vals=getConstPointer(); + const int *loc=std::max_element(vals,vals+nbOfTuples); + tupleId=std::distance(vals,loc); + return *loc; +} + +int DataArrayInt::getMinValue(int& tupleId) const throw(INTERP_KERNEL::Exception) +{ + if(getNumberOfComponents()!=1) + throw INTERP_KERNEL::Exception("DataArrayDouble::getMaxValue : must be applied on DataArrayDouble with only one component !"); + int nbOfTuples=getNumberOfTuples(); + if(nbOfTuples<=0) + throw INTERP_KERNEL::Exception("DataArrayDouble::getMaxValue : array exists but number of tuples must be > 0 !"); + const int *vals=getConstPointer(); + const int *loc=std::min_element(vals,vals+nbOfTuples); + tupleId=std::distance(vals,loc); + return *loc; +} + +void DataArrayInt::applyLin(int a, int b, int compoId) throw(INTERP_KERNEL::Exception) +{ + checkAllocated(); + int *ptr=getPointer()+compoId; + int nbOfComp=getNumberOfComponents(); + int nbOfTuple=getNumberOfTuples(); + for(int i=0;i(),val)); + declareAsNew(); +} + +void DataArrayInt::applyModulus(int val) throw(INTERP_KERNEL::Exception) +{ + if(val<=0) + throw INTERP_KERNEL::Exception("DataArrayInt::applyDivideBy : Trying to operate modulus on value <= 0 !"); + checkAllocated(); + int *ptr=getPointer(); + int nbOfElems=getNbOfElems(); + std::transform(ptr,ptr+nbOfElems,ptr,std::bind2nd(std::modulus(),val)); + declareAsNew(); +} + +/*! + * This method applies the operation 'numerator%x' for each element 'x' in 'this'. + * If there is a value in 'this' exactly equals or lower than 0. an exception is thrown. + * Warning if presence of null this is modified for each values previous than place where exception was thrown ! + */ +void DataArrayInt::applyRModulus(int val) throw(INTERP_KERNEL::Exception) +{ + checkAllocated(); + int *ptr=getPointer(); + int nbOfElems=getNbOfElems(); + for(int i=0;i0) + { + *ptr=val%(*ptr); + } + else + { + std::ostringstream oss; oss << "DataArrayInt::applyRModulus : presence of value <=0 in tuple #" << i/getNumberOfComponents() << " component #" << i%getNumberOfComponents(); + oss << " !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + } + declareAsNew(); +} + +DataArrayInt *DataArrayInt::Meld(const DataArrayInt *a1, const DataArrayInt *a2) throw(INTERP_KERNEL::Exception) +{ + std::vector arr(2); + arr[0]=a1; arr[1]=a2; + return Meld(arr); +} + +DataArrayInt *DataArrayInt::Meld(const std::vector& a) throw(INTERP_KERNEL::Exception) +{ + if(a.empty()) + throw INTERP_KERNEL::Exception("DataArrayInt::Meld : array must be NON empty !"); + std::vector::const_iterator it; + for(it=a.begin();it!=a.end();it++) + (*it)->checkAllocated(); + it=a.begin(); + int nbOfTuples=(*it)->getNumberOfTuples(); + std::vector nbc(a.size()); + std::vector pts(a.size()); + nbc[0]=(*it)->getNumberOfComponents(); + pts[0]=(*it++)->getConstPointer(); + for(int i=1;it!=a.end();it++,i++) + { + if(nbOfTuples!=(*it)->getNumberOfTuples()) + throw INTERP_KERNEL::Exception("DataArrayInt::meld : mismatch of number of tuples !"); + nbc[i]=(*it)->getNumberOfComponents(); + pts[i]=(*it)->getConstPointer(); + } + int totalNbOfComp=std::accumulate(nbc.begin(),nbc.end(),0); + DataArrayInt *ret=DataArrayInt::New(); + ret->alloc(nbOfTuples,totalNbOfComp); + int *retPtr=ret->getPointer(); + for(int i=0;isetInfoOnComponent(k,a[i]->getInfoOnComponent(j).c_str()); + return ret; +} + +/*! + * This method create a minimal partition of groups 'groups' the std::iota array of size 'newNb'. + * This method returns an array of size 'newNb' that specifies for each item at which familyId it owns to, and this method returns + * for each group the familyId it contains. If an id so that id& groups, int newNb, std::vector< std::vector >& fidsOfGroups) +{ + DataArrayInt *ret=DataArrayInt::New(); + ret->alloc(newNb,1); + int *retPtr=ret->getPointer(); + std::fill(retPtr,retPtr+newNb,0); + int fid=1; + for(std::vector::const_iterator iter=groups.begin();iter!=groups.end();iter++) + { + const int *ptr=(*iter)->getConstPointer(); + int nbOfElem=(*iter)->getNbOfElems(); + int sfid=fid; + for(int j=0;j& gro fidsOfGroups.clear(); fidsOfGroups.resize(groups.size()); int grId=0; - for(std::vector::const_iterator iter=groups.begin();iter!=groups.end();iter++,grId++) + for(std::vector::const_iterator iter=groups.begin();iter!=groups.end();iter++,grId++) { std::set tmp; const int *ptr=(*iter)->getConstPointer(); @@ -1602,7 +3273,389 @@ DataArrayInt *DataArrayInt::makePartition(const std::vector& gro return ret; } -int *DataArrayInt::checkAndPreparePermutation(const int *start, const int *end) +DataArrayInt *DataArrayInt::BuildUnion(const std::vector& a) throw(INTERP_KERNEL::Exception) +{ + int valm=std::numeric_limits::max(); + for(std::vector::const_iterator it=a.begin();it!=a.end();it++) + { + (*it)->checkAllocated(); + if((*it)->getNumberOfComponents()!=1) + throw INTERP_KERNEL::Exception("DataArrayInt::BuildUnion : only single component allowed !"); + int tmp1; + valm=std::min((*it)->getMinValue(tmp1),valm); + } + if(valm<0) + throw INTERP_KERNEL::Exception("DataArrayInt::BuildUnion : a negative value has been detected !"); + // + std::set r; + for(std::vector::const_iterator it=a.begin();it!=a.end();it++) + { + const int *pt=(*it)->getConstPointer(); + int nbOfTuples=(*it)->getNumberOfTuples(); + r.insert(pt,pt+nbOfTuples); + } + DataArrayInt *ret=DataArrayInt::New(); + ret->alloc(r.size(),1); + std::copy(r.begin(),r.end(),ret->getPointer()); + return ret; +} + +DataArrayInt *DataArrayInt::BuildIntersection(const std::vector& a) throw(INTERP_KERNEL::Exception) +{ + int valm=std::numeric_limits::max(); + for(std::vector::const_iterator it=a.begin();it!=a.end();it++) + { + (*it)->checkAllocated(); + if((*it)->getNumberOfComponents()!=1) + throw INTERP_KERNEL::Exception("DataArrayInt::BuildUnion : only single component allowed !"); + int tmp1; + valm=std::min((*it)->getMinValue(tmp1),valm); + } + if(valm<0) + throw INTERP_KERNEL::Exception("DataArrayInt::BuildUnion : a negative value has been detected !"); + // + std::set r; + for(std::vector::const_iterator it=a.begin();it!=a.end();it++) + { + const int *pt=(*it)->getConstPointer(); + int nbOfTuples=(*it)->getNumberOfTuples(); + std::set s1(pt,pt+nbOfTuples); + if(it!=a.begin()) + { + std::set r2; + std::set_intersection(r.begin(),r.end(),s1.begin(),s1.end(),inserter(r2,r2.end())); + r=r2; + } + else + r=s1; + } + DataArrayInt *ret=DataArrayInt::New(); + ret->alloc(r.size(),1); + std::copy(r.begin(),r.end(),ret->getPointer()); + return ret; +} + +DataArrayInt *DataArrayInt::buildComplement(int nbOfElement) const throw(INTERP_KERNEL::Exception) +{ + checkAllocated(); + if(getNumberOfComponents()!=1) + throw INTERP_KERNEL::Exception("DataArrayInt::buildComplement : only single component allowed !"); + std::vector tmp(nbOfElement); + const int *pt=getConstPointer(); + int nbOfTuples=getNumberOfTuples(); + for(const int *w=pt;w!=pt+nbOfTuples;w++) + if(*w>=0 && *walloc(nbOfRetVal,1); + int j=0; + int *retPtr=ret->getPointer(); + for(int i=0;icheckAllocated(); + if(getNumberOfComponents()!=1) + throw INTERP_KERNEL::Exception("DataArrayInt::buildSubstraction : only single component allowed !"); + if(other->getNumberOfComponents()!=1) + throw INTERP_KERNEL::Exception("DataArrayInt::buildSubstraction : only single component allowed for other type !"); + const int *pt=getConstPointer(); + int nbOfTuples=getNumberOfTuples(); + std::set s1(pt,pt+nbOfTuples); + pt=other->getConstPointer(); + nbOfTuples=other->getNumberOfTuples(); + std::set s2(pt,pt+nbOfTuples); + std::vector r; + std::set_difference(s1.begin(),s1.end(),s2.begin(),s2.end(),std::back_insert_iterator< std::vector >(r)); + DataArrayInt *ret=DataArrayInt::New(); + ret->alloc(r.size(),1); + std::copy(r.begin(),r.end(),ret->getPointer()); + return ret; +} + +DataArrayInt *DataArrayInt::buildUnion(const DataArrayInt *other) const throw(INTERP_KERNEL::Exception) +{ + std::vectorarrs(2); + arrs[0]=this; arrs[1]=other; + return BuildUnion(arrs); +} + +DataArrayInt *DataArrayInt::buildIntersection(const DataArrayInt *other) const throw(INTERP_KERNEL::Exception) +{ + std::vectorarrs(2); + arrs[0]=this; arrs[1]=other; + return BuildIntersection(arrs); +} + +/*! + * This method could be usefull for returned DataArrayInt marked as index. Some methods that generate such DataArrayInt instances: + * - ParaMEDMEM::MEDCouplingUMesh::buildDescendingConnectivity + * - ParaMEDMEM::MEDCouplingUMesh::getNodalConnectivityIndex + * This method makes the assumption that 'this' is allocated and has exactly one component and 2 or more tuples. If not an exception is thrown. + * This method retrives a newly created DataArrayInt instance with 1 component and this->getNumberOfTuples()-1 tuples. + * If this contains [1,3,6,7,7,9,15] -> returned array will contain [2,3,1,0,2,6]. + */ +DataArrayInt *DataArrayInt::deltaShiftIndex() const throw(INTERP_KERNEL::Exception) +{ + checkAllocated(); + if(getNumberOfComponents()!=1) + throw INTERP_KERNEL::Exception("DataArrayInt::deltaShiftIndex : only single component allowed !"); + int nbOfTuples=getNumberOfTuples(); + if(nbOfTuples<2) + throw INTERP_KERNEL::Exception("DataArrayInt::deltaShiftIndex : 1 tuple at least must be present in 'this' !"); + const int *ptr=getPointer(); + DataArrayInt *ret=DataArrayInt::New(); + ret->alloc(nbOfTuples-1,1); + int *out=ret->getPointer(); + std::transform(ptr+1,ptr+nbOfTuples,ptr,out,std::minus()); + return ret; +} + +/*! + * This method performs the work on itself. This method works on array with number of component equal to one and allocated. If not an exception is thrown. + * This method conserves the number of tuples and number of components (1). No reallocation is done. + * For an array [3,5,1,2,0,8] it becomes [0,3,8,9,11,11]. For each i>0 new[i]=new[i-1]+old[i-1] for i==0 new[i]=0. + * This could be usefull for allToAllV in MPI with contiguous policy. + */ +void DataArrayInt::computeOffsets() throw(INTERP_KERNEL::Exception) +{ + checkAllocated(); + if(getNumberOfComponents()!=1) + throw INTERP_KERNEL::Exception("DataArrayInt::computeOffsets : only single component allowed !"); + int nbOfTuples=getNumberOfTuples(); + if(nbOfTuples==0) + return ; + int *work=getPointer(); + int tmp=work[0]; + work[0]=0; + for(int i=1;i DataArrayInt::getDifferentValues() const throw(INTERP_KERNEL::Exception) +{ + checkAllocated(); + std::set ret; + ret.insert(getConstPointer(),getConstPointer()+getNbOfElems()); + return ret; +} + +DataArrayInt *DataArrayInt::Add(const DataArrayInt *a1, const DataArrayInt *a2) throw(INTERP_KERNEL::Exception) +{ + int nbOfTuple=a2->getNumberOfTuples(); + int nbOfComp=a2->getNumberOfComponents(); + a1->checkNbOfTuplesAndComp(nbOfTuple,nbOfComp,"Nb of components mismatch for array Add !"); + DataArrayInt *ret=DataArrayInt::New(); + ret->alloc(nbOfTuple,nbOfComp); + std::transform(a1->getConstPointer(),a1->getConstPointer()+nbOfTuple*nbOfComp,a2->getConstPointer(),ret->getPointer(),std::plus()); + ret->copyStringInfoFrom(*a1); + return ret; +} + +void DataArrayInt::addEqual(const DataArrayInt *other) throw(INTERP_KERNEL::Exception) +{ + int nbOfTuple=other->getNumberOfTuples(); + int nbOfComp=other->getNumberOfComponents(); + checkNbOfTuplesAndComp(nbOfTuple,nbOfComp,"Nb of components mismatch for array add equal !"); + std::transform(getConstPointer(),getConstPointer()+nbOfTuple*nbOfComp,other->getConstPointer(),getPointer(),std::plus()); + declareAsNew(); +} + +DataArrayInt *DataArrayInt::Substract(const DataArrayInt *a1, const DataArrayInt *a2) throw(INTERP_KERNEL::Exception) +{ + int nbOfTuple=a2->getNumberOfTuples(); + int nbOfComp=a2->getNumberOfComponents(); + a1->checkNbOfTuplesAndComp(nbOfTuple,nbOfComp,"Nb of components mismatch for array Substract !"); + DataArrayInt *ret=DataArrayInt::New(); + ret->alloc(nbOfTuple,nbOfComp); + std::transform(a1->getConstPointer(),a1->getConstPointer()+nbOfTuple*nbOfComp,a2->getConstPointer(),ret->getPointer(),std::minus()); + ret->copyStringInfoFrom(*a1); + return ret; +} + +void DataArrayInt::substractEqual(const DataArrayInt *other) throw(INTERP_KERNEL::Exception) +{ + int nbOfTuple=other->getNumberOfTuples(); + int nbOfComp=other->getNumberOfComponents(); + checkNbOfTuplesAndComp(nbOfTuple,nbOfComp,"Nb of components mismatch for array substract equal !"); + std::transform(getConstPointer(),getConstPointer()+nbOfTuple*nbOfComp,other->getConstPointer(),getPointer(),std::minus()); + declareAsNew(); +} + +DataArrayInt *DataArrayInt::Multiply(const DataArrayInt *a1, const DataArrayInt *a2) throw(INTERP_KERNEL::Exception) +{ + int nbOfTuple=a1->getNumberOfTuples(); + int nbOfTuple2=a2->getNumberOfTuples(); + int nbOfComp=a1->getNumberOfComponents(); + int nbOfComp2=a2->getNumberOfComponents(); + if(nbOfTuple!=nbOfTuple2) + throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array Multiply !"); + DataArrayInt *ret=0; + if(nbOfComp==nbOfComp2) + { + ret=DataArrayInt::New(); + ret->alloc(nbOfTuple,nbOfComp); + std::transform(a1->getConstPointer(),a1->getConstPointer()+nbOfTuple*nbOfComp,a2->getConstPointer(),ret->getPointer(),std::multiplies()); + ret->copyStringInfoFrom(*a1); + } + else + { + int nbOfCompMin,nbOfCompMax; + const DataArrayInt *aMin, *aMax; + if(nbOfComp>nbOfComp2) + { + nbOfCompMin=nbOfComp2; nbOfCompMax=nbOfComp; + aMin=a2; aMax=a1; + } + else + { + nbOfCompMin=nbOfComp; nbOfCompMax=nbOfComp2; + aMin=a1; aMax=a2; + } + if(nbOfCompMin==1) + { + ret=DataArrayInt::New(); + ret->alloc(nbOfTuple,nbOfCompMax); + const int *aMinPtr=aMin->getConstPointer(); + const int *aMaxPtr=aMax->getConstPointer(); + int *res=ret->getPointer(); + for(int i=0;i(),aMinPtr[i])); + ret->copyStringInfoFrom(*aMax); + } + else + throw INTERP_KERNEL::Exception("Nb of components mismatch for array Multiply !"); + } + return ret; +} + +void DataArrayInt::multiplyEqual(const DataArrayInt *other) throw(INTERP_KERNEL::Exception) +{ + int nbOfTuple=getNumberOfTuples(); + int nbOfTuple2=other->getNumberOfTuples(); + int nbOfComp=getNumberOfComponents(); + int nbOfComp2=other->getNumberOfComponents(); + if(nbOfTuple!=nbOfTuple2) + throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array multiplyEqual !"); + if(nbOfComp==nbOfComp2) + { + std::transform(getConstPointer(),getConstPointer()+nbOfTuple*nbOfComp,other->getConstPointer(),getPointer(),std::multiplies()); + } + else + { + if(nbOfComp2==1) + { + const int *ptr=other->getConstPointer(); + int *myPtr=getPointer(); + for(int i=0;i(),ptr[i])); + } + else + throw INTERP_KERNEL::Exception("Nb of components mismatch for array multiplyEqual !"); + } + declareAsNew(); +} + +DataArrayInt *DataArrayInt::Divide(const DataArrayInt *a1, const DataArrayInt *a2) throw(INTERP_KERNEL::Exception) +{ + int nbOfTuple=a1->getNumberOfTuples(); + int nbOfTuple2=a2->getNumberOfTuples(); + int nbOfComp=a1->getNumberOfComponents(); + int nbOfComp2=a2->getNumberOfComponents(); + if(nbOfTuple!=nbOfTuple2) + throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array Divide !"); + DataArrayInt *ret=0; + if(nbOfComp==nbOfComp2) + { + ret=DataArrayInt::New(); + ret->alloc(nbOfTuple,nbOfComp); + std::transform(a1->getConstPointer(),a1->getConstPointer()+nbOfTuple*nbOfComp,a2->getConstPointer(),ret->getPointer(),std::divides()); + ret->copyStringInfoFrom(*a1); + } + else + { + if(nbOfComp2==1) + { + ret=DataArrayInt::New(); + ret->alloc(nbOfTuple,nbOfComp); + const int *a2Ptr=a2->getConstPointer(); + const int *a1Ptr=a1->getConstPointer(); + int *res=ret->getPointer(); + for(int i=0;i(),a2Ptr[i])); + ret->copyStringInfoFrom(*a1); + } + else + throw INTERP_KERNEL::Exception("Nb of components mismatch for array Divide !"); + } + return ret; +} + +void DataArrayInt::divideEqual(const DataArrayInt *other) throw(INTERP_KERNEL::Exception) +{ + int nbOfTuple=getNumberOfTuples(); + int nbOfTuple2=other->getNumberOfTuples(); + int nbOfComp=getNumberOfComponents(); + int nbOfComp2=other->getNumberOfComponents(); + if(nbOfTuple!=nbOfTuple2) + throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array divideEqual !"); + if(nbOfComp==nbOfComp2) + { + std::transform(getConstPointer(),getConstPointer()+nbOfTuple*nbOfComp,other->getConstPointer(),getPointer(),std::divides()); + } + else + { + if(nbOfComp2==1) + { + const int *ptr=other->getConstPointer(); + int *myPtr=getPointer(); + for(int i=0;i(),ptr[i])); + } + else + throw INTERP_KERNEL::Exception("Nb of components mismatch for array divideEqual !"); + } + declareAsNew(); +} + +DataArrayInt *DataArrayInt::Modulus(const DataArrayInt *a1, const DataArrayInt *a2) throw(INTERP_KERNEL::Exception) +{ + int nbOfTuple=a2->getNumberOfTuples(); + int nbOfComp=a2->getNumberOfComponents(); + a1->checkNbOfTuplesAndComp(nbOfTuple,nbOfComp,"Nb of components mismatch for array Modulus"); + DataArrayInt *ret=DataArrayInt::New(); + ret->alloc(nbOfTuple,nbOfComp); + std::transform(a1->getConstPointer(),a1->getConstPointer()+nbOfTuple*nbOfComp,a2->getConstPointer(),ret->getPointer(),std::modulus()); + ret->copyStringInfoFrom(*a1); + return ret; +} + +void DataArrayInt::modulusEqual(const DataArrayInt *other) throw(INTERP_KERNEL::Exception) +{ + int nbOfTuple=other->getNumberOfTuples(); + int nbOfComp=other->getNumberOfComponents(); + checkNbOfTuplesAndComp(nbOfTuple,nbOfComp,"Nb of components mismatch for array modulus equal"); + std::transform(getConstPointer(),getConstPointer()+nbOfTuple*nbOfComp,other->getConstPointer(),getPointer(),std::modulus()); + declareAsNew(); +} + +int *DataArrayInt::CheckAndPreparePermutation(const int *start, const int *end) { int sz=std::distance(start,end); int *ret=new int[sz]; @@ -1621,3 +3674,74 @@ int *DataArrayInt::checkAndPreparePermutation(const int *start, const int *end) delete [] work; return ret; } + +/*! + * Useless method for end user. Only for MPI/Corba/File serialsation for multi arrays class. + * Server side. + */ +void DataArrayInt::getTinySerializationIntInformation(std::vector& tinyInfo) const +{ + tinyInfo.resize(2); + if(isAllocated()) + { + tinyInfo[0]=getNumberOfTuples(); + tinyInfo[1]=getNumberOfComponents(); + } + else + { + tinyInfo[0]=-1; + tinyInfo[1]=-1; + } +} + +/*! + * Useless method for end user. Only for MPI/Corba/File serialsation for multi arrays class. + * Server side. + */ +void DataArrayInt::getTinySerializationStrInformation(std::vector& tinyInfo) const +{ + if(isAllocated()) + { + int nbOfCompo=getNumberOfComponents(); + tinyInfo.resize(nbOfCompo+1); + tinyInfo[0]=getName(); + for(int i=0;i& tinyInfoI) +{ + int nbOfTuple=tinyInfoI[0]; + int nbOfComp=tinyInfoI[1]; + if(nbOfTuple!=-1 || nbOfComp!=-1) + { + alloc(nbOfTuple,nbOfComp); + return true; + } + return false; +} + +/*! + * Useless method for end user. Only for MPI/Corba/File serialsation for multi arrays class. + * This method returns if a feeding is needed. + */ +void DataArrayInt::finishUnserialization(const std::vector& tinyInfoI, const std::vector& tinyInfoS) +{ + setName(tinyInfoS[0].c_str()); + if(isAllocated()) + { + int nbOfCompo=getNumberOfComponents(); + for(int i=0;i #include #include #include @@ -54,6 +55,7 @@ namespace ParaMEDMEM public: MemArray():_nb_of_elem(-1),_ownership(false),_dealloc(CPP_DEALLOC) { } MemArray(const MemArray& other); + bool isNull() const { return _pointer.isNull(); } const T *getConstPointerLoc(int offset) const { return _pointer.getConstPointerLoc(offset); } const T *getConstPointer() const { return _pointer.getConstPointer(); } T *getPointer() const { return _pointer.getPointer(); } @@ -64,6 +66,9 @@ namespace ParaMEDMEM void repr(int sl, std::ostream& stream) const; void reprZip(int sl, std::ostream& stream) const; void fillWithValue(const T& val); + T *fromNoInterlace(int nbOfComp) const; + T *toNoInterlace(int nbOfComp) const; + void sort(); void alloc(int nbOfElements); void reAlloc(int newNbOfElements); void useArray(const T *array, bool ownership, DeallocType type, int nbOfElem); @@ -90,13 +95,24 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT void reprWithoutNameStream(std::ostream& stream) const; MEDCOUPLING_EXPORT std::string getName() const { return _name; } MEDCOUPLING_EXPORT const std::vector &getInfoOnComponent() const { return _info_on_compo; } + MEDCOUPLING_EXPORT std::vector getVarsOnComponent() const; + MEDCOUPLING_EXPORT std::vector getUnitsOnComponent() const; MEDCOUPLING_EXPORT std::string getInfoOnComponent(int i) const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT std::string getVarOnComponent(int i) const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT std::string getUnitOnComponent(int i) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void setInfoOnComponent(int i, const char *info) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT int getNumberOfComponents() const { return _info_on_compo.size(); } MEDCOUPLING_EXPORT int getNumberOfTuples() const { return _nb_of_tuples; } MEDCOUPLING_EXPORT int getNbOfElems() const { return _info_on_compo.size()*_nb_of_tuples; } + MEDCOUPLING_EXPORT void checkNbOfTuplesAndComp(const DataArray& other, const char *msg) const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT void checkNbOfTuplesAndComp(int nbOfTuples, int nbOfCompo, const char *msg) const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT void checkNbOfElems(int nbOfElems, const char *msg) const throw(INTERP_KERNEL::Exception); protected: DataArray():_nb_of_tuples(-1) { } + protected: + static void CheckValueInRange(int ref, int value, const char *msg) throw(INTERP_KERNEL::Exception); + static void CheckClosingParInRange(int ref, int value, const char *msg) throw(INTERP_KERNEL::Exception); + static int GetNumberOfItemGivenBES(int begin, int end, int step, const char *msg) throw(INTERP_KERNEL::Exception); protected: int _nb_of_tuples; std::string _name; @@ -113,11 +129,20 @@ namespace ParaMEDMEM { public: MEDCOUPLING_EXPORT static DataArrayDouble *New(); - MEDCOUPLING_EXPORT DataArrayDouble *deepCopy() const; + MEDCOUPLING_EXPORT bool isAllocated() const; + MEDCOUPLING_EXPORT void checkAllocated() const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT DataArrayDouble *deepCpy() const; MEDCOUPLING_EXPORT DataArrayDouble *performCpy(bool deepCpy) const; + MEDCOUPLING_EXPORT void cpyFrom(const DataArrayDouble& other) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void alloc(int nbOfTuple, int nbOfCompo); - MEDCOUPLING_EXPORT void fillWithZero(); - MEDCOUPLING_EXPORT void fillWithValue(double val); + MEDCOUPLING_EXPORT void allocIfNecessary(int nbOfTuple, int nbOfCompo); + MEDCOUPLING_EXPORT void fillWithZero() throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT void fillWithValue(double val) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT void iota(double init=0.) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT bool isUniform(double val, double eps) const; + MEDCOUPLING_EXPORT void sort() throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT void checkMonotonic(double eps) const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT bool isMonotonic(double eps) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT std::string repr() const; MEDCOUPLING_EXPORT std::string reprZip() const; MEDCOUPLING_EXPORT void reprStream(std::ostream& stream) const; @@ -127,23 +152,36 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT bool isEqual(const DataArrayDouble& other, double prec) const; MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const DataArrayDouble& other, double prec) const; //!alloc or useArray should have been called before. - MEDCOUPLING_EXPORT void reAlloc(int nbOfTuples); + MEDCOUPLING_EXPORT void reAlloc(int nbOfTuples) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT DataArrayInt *convertToIntArr() const; + MEDCOUPLING_EXPORT DataArrayDouble *fromNoInterlace() const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT DataArrayDouble *toNoInterlace() const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void renumberInPlace(const int *old2New); MEDCOUPLING_EXPORT void renumberInPlaceR(const int *new2Old); MEDCOUPLING_EXPORT DataArrayDouble *renumber(const int *old2New) const; MEDCOUPLING_EXPORT DataArrayDouble *renumberR(const int *new2Old) const; MEDCOUPLING_EXPORT DataArrayDouble *renumberAndReduce(const int *old2New, int newNbOfTuple) const; MEDCOUPLING_EXPORT DataArrayDouble *selectByTupleId(const int *new2OldBg, const int *new2OldEnd) const; + MEDCOUPLING_EXPORT DataArrayDouble *selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT DataArrayDouble *selectByTupleId2(int bg, int end, int step) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT DataArrayDouble *substr(int tupleIdBg, int tupleIdEnd=-1) const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT void rearrange(int newNbOfCompo) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT DataArrayDouble *changeNbOfComponents(int newNbOfComp, double dftValue) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT DataArrayDouble *keepSelectedComponents(const std::vector& compoIds) const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT void meldWith(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void setSelectedComponents(const DataArrayDouble *a, const std::vector& compoIds) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT void setPartOfValues1(const DataArrayDouble *a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare=true) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT void setPartOfValuesSimple1(double a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT void setPartOfValues2(const DataArrayDouble *a, const int *bgTuples, const int *endTuples, const int *bgComp, const int *endComp, bool strictCompoCompare=true) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT void setPartOfValuesSimple2(double a, const int *bgTuples, const int *endTuples, const int *bgComp, const int *endComp) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT void setPartOfValues3(const DataArrayDouble *a, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare=true) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT void setPartOfValuesSimple3(double a, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void getTuple(int tupleId, double *res) const { std::copy(_mem.getConstPointerLoc(tupleId*_info_on_compo.size()),_mem.getConstPointerLoc((tupleId+1)*_info_on_compo.size()),res); } MEDCOUPLING_EXPORT double getIJ(int tupleId, int compoId) const { return _mem[tupleId*_info_on_compo.size()+compoId]; } MEDCOUPLING_EXPORT void setIJ(int tupleId, int compoId, double newVal) { _mem[tupleId*_info_on_compo.size()+compoId]=newVal; declareAsNew(); } + MEDCOUPLING_EXPORT void setIJSilent(int tupleId, int compoId, double newVal) { _mem[tupleId*_info_on_compo.size()+compoId]=newVal; } MEDCOUPLING_EXPORT double *getPointer() const { return _mem.getPointer(); } - MEDCOUPLING_EXPORT static void setArrayIn(DataArrayDouble *newArray, DataArrayDouble* &arrayToSet); + MEDCOUPLING_EXPORT static void SetArrayIn(DataArrayDouble *newArray, DataArrayDouble* &arrayToSet); MEDCOUPLING_EXPORT const double *getConstPointer() const { return _mem.getConstPointer(); } MEDCOUPLING_EXPORT void useArray(const double *array, bool ownership, DeallocType type, int nbOfTuple, int nbOfCompo); MEDCOUPLING_EXPORT void writeOnPlace(int id, double element0, const double *others, int sizeOfOthers) { _mem.writeOnPlace(id,element0,others,sizeOfOthers); } @@ -153,8 +191,11 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT double getMaxValue2(DataArrayInt*& tupleIds) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT double getMinValue2(DataArrayInt*& tupleIds) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT double getAverageValue() const throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT void accumulate(double *res) const; - MEDCOUPLING_EXPORT double accumulate(int compId) const; + MEDCOUPLING_EXPORT void accumulate(double *res) const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT double accumulate(int compId) const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT DataArrayDouble *fromPolarToCart() const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT DataArrayDouble *fromCylToCart() const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT DataArrayDouble *fromSpherToCart() const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT DataArrayDouble *doublyContractedProduct() const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT DataArrayDouble *determinant() const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT DataArrayDouble *eigenValues() const throw(INTERP_KERNEL::Exception); @@ -165,28 +206,40 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT DataArrayDouble *magnitude() const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT DataArrayDouble *maxPerTuple() const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void sortPerTuple(bool asc) throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT void applyLin(double a, double b, int compoId); + MEDCOUPLING_EXPORT void applyLin(double a, double b, int compoId) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT void applyLin(double a, double b) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT void applyInv(double numerator) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT DataArrayDouble *applyFunc(int nbOfComp, FunctionToEvaluate func) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT DataArrayDouble *applyFunc(int nbOfComp, const char *func) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT DataArrayDouble *applyFunc(const char *func) const throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT void applyFuncFast32(const char *func); - MEDCOUPLING_EXPORT void applyFuncFast64(const char *func); + MEDCOUPLING_EXPORT DataArrayDouble *applyFunc2(int nbOfComp, const char *func) const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT DataArrayDouble *applyFunc3(int nbOfComp, const std::vector& varsOrder, const char *func) const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT void applyFuncFast32(const char *func) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT void applyFuncFast64(const char *func) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT DataArrayInt *getIdsInRange(double vmin, double vmax) const throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT static DataArrayDouble *aggregate(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT static DataArrayDouble *dot(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT static DataArrayDouble *crossProduct(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT static DataArrayDouble *max(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT static DataArrayDouble *min(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT static DataArrayDouble *add(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT static DataArrayDouble *Aggregate(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT static DataArrayDouble *Aggregate(const std::vector& a) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT static DataArrayDouble *Meld(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT static DataArrayDouble *Meld(const std::vector& a) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT static DataArrayDouble *Dot(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT static DataArrayDouble *CrossProduct(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT static DataArrayDouble *Max(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT static DataArrayDouble *Min(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT static DataArrayDouble *Add(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void addEqual(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT static DataArrayDouble *substract(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT static DataArrayDouble *Substract(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void substractEqual(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT static DataArrayDouble *multiply(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT static DataArrayDouble *Multiply(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void multiplyEqual(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT static DataArrayDouble *divide(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT static DataArrayDouble *Divide(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void divideEqual(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception); //! nothing to do here because this class does not aggregate any TimeLabel instance. - MEDCOUPLING_EXPORT void updateTime() { } + MEDCOUPLING_EXPORT void updateTime() const { } + public: + void getTinySerializationIntInformation(std::vector& tinyInfo) const; + void getTinySerializationStrInformation(std::vector& tinyInfo) const; + bool resizeForUnserialization(const std::vector& tinyInfoI); + void finishUnserialization(const std::vector& tinyInfoI, const std::vector& tinyInfoS); private: DataArrayDouble() { } private: @@ -197,50 +250,116 @@ namespace ParaMEDMEM { public: MEDCOUPLING_EXPORT static DataArrayInt *New(); - MEDCOUPLING_EXPORT DataArrayInt *deepCopy() const; + MEDCOUPLING_EXPORT bool isAllocated() const; + MEDCOUPLING_EXPORT void checkAllocated() const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT DataArrayInt *deepCpy() const; MEDCOUPLING_EXPORT DataArrayInt *performCpy(bool deepCpy) const; + MEDCOUPLING_EXPORT void cpyFrom(const DataArrayInt& other) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void alloc(int nbOfTuple, int nbOfCompo); + MEDCOUPLING_EXPORT void allocIfNecessary(int nbOfTuple, int nbOfCompo); MEDCOUPLING_EXPORT bool isEqual(const DataArrayInt& other) const; MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const DataArrayInt& other) const; + MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStrAndOrder(const DataArrayInt& other) const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT DataArrayInt *buildPermutationArr(const DataArrayInt& other) const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT void sort() throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void fillWithZero(); MEDCOUPLING_EXPORT void fillWithValue(int val); + MEDCOUPLING_EXPORT void iota(int init=0) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT std::string repr() const; MEDCOUPLING_EXPORT std::string reprZip() const; MEDCOUPLING_EXPORT void reprStream(std::ostream& stream) const; MEDCOUPLING_EXPORT void reprZipStream(std::ostream& stream) const; MEDCOUPLING_EXPORT void reprWithoutNameStream(std::ostream& stream) const; MEDCOUPLING_EXPORT void reprZipWithoutNameStream(std::ostream& stream) const; - MEDCOUPLING_EXPORT void transformWithIndArr(const int *indArr); + MEDCOUPLING_EXPORT void transformWithIndArr(const int *indArrBg, const int *indArrEnd) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT DataArrayInt *transformWithIndArrR(const int *indArrBg, const int *indArrEnd) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT DataArrayInt *invertArrayO2N2N2O(int newNbOfElem) const; MEDCOUPLING_EXPORT DataArrayInt *invertArrayN2O2O2N(int oldNbOfElem) const; //!alloc or useArray should have been called before. - MEDCOUPLING_EXPORT void reAlloc(int nbOfTuples); + MEDCOUPLING_EXPORT void reAlloc(int nbOfTuples) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT DataArrayDouble *convertToDblArr() const; + MEDCOUPLING_EXPORT DataArrayInt *fromNoInterlace() const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT DataArrayInt *toNoInterlace() const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void renumberInPlace(const int *old2New); MEDCOUPLING_EXPORT void renumberInPlaceR(const int *new2Old); MEDCOUPLING_EXPORT DataArrayInt *renumber(const int *old2New) const; MEDCOUPLING_EXPORT DataArrayInt *renumberR(const int *new2Old) const; MEDCOUPLING_EXPORT DataArrayInt *renumberAndReduce(const int *old2NewBg, int newNbOfTuple) const; MEDCOUPLING_EXPORT DataArrayInt *selectByTupleId(const int *new2OldBg, const int *new2OldEnd) const; + MEDCOUPLING_EXPORT DataArrayInt *selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT DataArrayInt *selectByTupleId2(int bg, int end, int step) const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT DataArrayInt *checkAndPreparePermutation() const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT void changeSurjectiveFormat(int targetNb, DataArrayInt *&arr, DataArrayInt *&arrI) const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT DataArrayInt *buildPermArrPerLevel() const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT bool isIdentity() const; + MEDCOUPLING_EXPORT bool isUniform(int val) const; MEDCOUPLING_EXPORT DataArrayInt *substr(int tupleIdBg, int tupleIdEnd=-1) const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT void rearrange(int newNbOfCompo) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT DataArrayInt *changeNbOfComponents(int newNbOfComp, int dftValue) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT DataArrayInt *keepSelectedComponents(const std::vector& compoIds) const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT void meldWith(const DataArrayInt *other) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void setSelectedComponents(const DataArrayInt *a, const std::vector& compoIds) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT void setPartOfValues1(const DataArrayInt *a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare=true) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT void setPartOfValuesSimple1(int a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT void setPartOfValues2(const DataArrayInt *a, const int *bgTuples, const int *endTuples, const int *bgComp, const int *endComp, bool strictCompoCompare=true) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT void setPartOfValuesSimple2(int a, const int *bgTuples, const int *endTuples, const int *bgComp, const int *endComp) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT void setPartOfValues3(const DataArrayInt *a, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare=true) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT void setPartOfValuesSimple3(int a, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void getTuple(int tupleId, int *res) const { std::copy(_mem.getConstPointerLoc(tupleId*_info_on_compo.size()),_mem.getConstPointerLoc((tupleId+1)*_info_on_compo.size()),res); } MEDCOUPLING_EXPORT int getIJ(int tupleId, int compoId) const { return _mem[tupleId*_info_on_compo.size()+compoId]; } - MEDCOUPLING_EXPORT void setIJ(int tupleId, int compoId, int newVal) { _mem[tupleId*_info_on_compo.size()+compoId]=newVal; } + MEDCOUPLING_EXPORT void setIJ(int tupleId, int compoId, int newVal) { _mem[tupleId*_info_on_compo.size()+compoId]=newVal; declareAsNew(); } + MEDCOUPLING_EXPORT void setIJSilent(int tupleId, int compoId, int newVal) { _mem[tupleId*_info_on_compo.size()+compoId]=newVal; } MEDCOUPLING_EXPORT int *getPointer() const { return _mem.getPointer(); } - MEDCOUPLING_EXPORT static void setArrayIn(DataArrayInt *newArray, DataArrayInt* &arrayToSet); + MEDCOUPLING_EXPORT static void SetArrayIn(DataArrayInt *newArray, DataArrayInt* &arrayToSet); MEDCOUPLING_EXPORT const int *getConstPointer() const { return _mem.getConstPointer(); } - MEDCOUPLING_EXPORT static DataArrayInt *aggregate(const DataArrayInt *a1, const DataArrayInt *a2, int offsetA2); - MEDCOUPLING_EXPORT static DataArrayInt *makePartition(const std::vector& groups, int newNb, std::vector< std::vector >& fidsOfGroups); + MEDCOUPLING_EXPORT DataArrayInt *getIdsEqual(int val) const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT DataArrayInt *getIdsNotEqual(int val) const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT DataArrayInt *getIdsEqualList(const std::vector& vals) const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT DataArrayInt *getIdsNotEqualList(const std::vector& vals) const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT bool presenceOfValue(const std::vector& vals) const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT int getMaxValue(int& tupleId) const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT int getMinValue(int& tupleId) const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT void applyLin(int a, int b, int compoId) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT void applyLin(int a, int b) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT void applyInv(int numerator) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT void applyDivideBy(int val) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT void applyModulus(int val) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT void applyRModulus(int val) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT static DataArrayInt *Aggregate(const DataArrayInt *a1, const DataArrayInt *a2, int offsetA2); + MEDCOUPLING_EXPORT static DataArrayInt *Aggregate(const std::vector& a) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT static DataArrayInt *Meld(const DataArrayInt *a1, const DataArrayInt *a2) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT static DataArrayInt *Meld(const std::vector& a) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT static DataArrayInt *MakePartition(const std::vector& groups, int newNb, std::vector< std::vector >& fidsOfGroups); + MEDCOUPLING_EXPORT static DataArrayInt *BuildUnion(const std::vector& a) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT static DataArrayInt *BuildIntersection(const std::vector& a) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT DataArrayInt *buildComplement(int nbOfElement) const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT DataArrayInt *buildSubstraction(const DataArrayInt *other) const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT DataArrayInt *buildUnion(const DataArrayInt *other) const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT DataArrayInt *buildIntersection(const DataArrayInt *other) const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT DataArrayInt *deltaShiftIndex() const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT void computeOffsets() throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT std::set getDifferentValues() const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void useArray(const int *array, bool ownership, DeallocType type, int nbOfTuple, int nbOfCompo); MEDCOUPLING_EXPORT void writeOnPlace(int id, int element0, const int *others, int sizeOfOthers) { _mem.writeOnPlace(id,element0,others,sizeOfOthers); } + MEDCOUPLING_EXPORT static DataArrayInt *Add(const DataArrayInt *a1, const DataArrayInt *a2) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT void addEqual(const DataArrayInt *other) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT static DataArrayInt *Substract(const DataArrayInt *a1, const DataArrayInt *a2) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT void substractEqual(const DataArrayInt *other) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT static DataArrayInt *Multiply(const DataArrayInt *a1, const DataArrayInt *a2) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT void multiplyEqual(const DataArrayInt *other) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT static DataArrayInt *Divide(const DataArrayInt *a1, const DataArrayInt *a2) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT void divideEqual(const DataArrayInt *other) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT static DataArrayInt *Modulus(const DataArrayInt *a1, const DataArrayInt *a2) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT void modulusEqual(const DataArrayInt *other) throw(INTERP_KERNEL::Exception); //! nothing to do here because this class does not aggregate any TimeLabel instance. - MEDCOUPLING_EXPORT void updateTime() { } + MEDCOUPLING_EXPORT void updateTime() const { } + public: + MEDCOUPLING_EXPORT static int *CheckAndPreparePermutation(const int *start, const int *end); public: - MEDCOUPLING_EXPORT static int *checkAndPreparePermutation(const int *start, const int *end); + void getTinySerializationIntInformation(std::vector& tinyInfo) const; + void getTinySerializationStrInformation(std::vector& tinyInfo) const; + bool resizeForUnserialization(const std::vector& tinyInfoI); + void finishUnserialization(const std::vector& tinyInfoI, const std::vector& tinyInfoS); private: DataArrayInt() { } private: diff --git a/src/MEDCoupling/MEDCouplingMemArray.txx b/src/MEDCoupling/MEDCouplingMemArray.txx index 5a1a048d5..197798b51 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.txx +++ b/src/MEDCoupling/MEDCouplingMemArray.txx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __PARAMEDMEM_MEDCOUPLINGMEMARRAY_TXX__ #define __PARAMEDMEM_MEDCOUPLINGMEMARRAY_TXX__ @@ -180,6 +180,39 @@ namespace ParaMEDMEM T *pt=_pointer.getPointer(); std::fill(pt,pt+_nb_of_elem,val); } + + template + T *MemArray::fromNoInterlace(int nbOfComp) const + { + const T *pt=_pointer.getConstPointer(); + int nbOfTuples=_nb_of_elem/nbOfComp; + T *ret=new T[_nb_of_elem]; + T *w=ret; + for(int i=0;i + T *MemArray::toNoInterlace(int nbOfComp) const + { + const T *pt=_pointer.getConstPointer(); + int nbOfTuples=_nb_of_elem/nbOfComp; + T *ret=new T[_nb_of_elem]; + T *w=ret; + for(int i=0;i + void MemArray::sort() + { + T *pt=_pointer.getPointer(); + std::sort(pt,pt+_nb_of_elem); + } template void MemArray::alloc(int nbOfElements) diff --git a/src/MEDCoupling/MEDCouplingMesh.cxx b/src/MEDCoupling/MEDCouplingMesh.cxx index cd3157568..56ca47955 100644 --- a/src/MEDCoupling/MEDCouplingMesh.cxx +++ b/src/MEDCoupling/MEDCouplingMesh.cxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "MEDCouplingMesh.hxx" @@ -24,11 +24,22 @@ #include "MEDCouplingAutoRefCountObjectPtr.hxx" #include +#include #include #include using namespace ParaMEDMEM; +MEDCouplingMesh::MEDCouplingMesh():_time(0.),_iteration(-1),_order(-1) +{ +} + +MEDCouplingMesh::MEDCouplingMesh(const MEDCouplingMesh& other):_name(other._name),_description(other._description), + _time(other._time),_iteration(other._iteration), + _order(other._order),_time_unit(other._time_unit) +{ +} + /*! * This method is only for ParaMEDMEM in ParaFIELD constructor. */ @@ -39,7 +50,8 @@ bool MEDCouplingMesh::isStructured() const bool MEDCouplingMesh::isEqual(const MEDCouplingMesh *other, double prec) const { - return _name==other->_name; + return _name==other->_name && _description==other->_description && _iteration==other->_iteration + && _order==other->_order && _time_unit==other->_time_unit && fabs(_time-other->_time)<1e-12; } /*! @@ -183,6 +195,20 @@ MEDCouplingFieldDouble *MEDCouplingMesh::fillFromAnalytic(TypeOfField t, int nbO void MEDCouplingMesh::copyTinyStringsFrom(const MEDCouplingMesh *other) throw(INTERP_KERNEL::Exception) { _name=other->_name; + _description=other->_description; + _time_unit=other->_time_unit; +} + +/*! + * This method copies all attributes that are \b NOT arrays in this. + * All tiny attributes not usefully for state of 'this' are ignored. + */ +void MEDCouplingMesh::copyTinyInfoFrom(const MEDCouplingMesh *other) throw(INTERP_KERNEL::Exception) +{ + copyTinyStringsFrom(other); + _time=other->_time; + _iteration=other->_iteration; + _order=other->_order; } /*! @@ -204,11 +230,77 @@ MEDCouplingFieldDouble *MEDCouplingMesh::fillFromAnalytic(TypeOfField t, int nbO return ret; } +/*! + * This method builds a field lying on 'this' with 'nbOfComp' components. + * 'func' is a string that is the expression to evaluate. + * The return field will have type specified by 't'. 't' is also used to determine where values of field will be + * evaluate. This method is different than MEDCouplingMesh::fillFromAnalytic, because the info on components are used here to determine vars pos in 'func'. + * + * @param t type of field returned and specifies where the evaluation of func will be done. + * @param nbOfComp number of components of returned field. + * @param func expression. + * @return field with counter = 1. + */ +MEDCouplingFieldDouble *MEDCouplingMesh::fillFromAnalytic2(TypeOfField t, int nbOfComp, const char *func) const +{ + MEDCouplingAutoRefCountObjectPtr ret=MEDCouplingFieldDouble::New(t,NO_TIME); + ret->setMesh(this); + ret->fillFromAnalytic2(nbOfComp,func); + ret->incrRef(); + return ret; +} + +/*! + * This method builds a field lying on 'this' with 'nbOfComp' components. + * 'func' is a string that is the expression to evaluate. + * The return field will have type specified by 't'. 't' is also used to determine where values of field will be + * evaluate. This method is different than MEDCouplingMesh::fillFromAnalytic, because 'varsOrder' specifies the pos to assign of vars in 'func'. + * + * @param t type of field returned and specifies where the evaluation of func will be done. + * @param nbOfComp number of components of returned field. + * @param func expression. + * @return field with counter = 1. + */ +MEDCouplingFieldDouble *MEDCouplingMesh::fillFromAnalytic3(TypeOfField t, int nbOfComp, const std::vector& varsOrder, const char *func) const +{ + MEDCouplingAutoRefCountObjectPtr ret=MEDCouplingFieldDouble::New(t,NO_TIME); + ret->setMesh(this); + ret->fillFromAnalytic3(nbOfComp,varsOrder,func); + ret->incrRef(); + return ret; +} + /*! * retruns a newly created mesh with counter=1 * that is the union of mesh1 and mesh2 if possible. The cells of mesh2 will appear after cells of 'mesh1'. Idem for nodes. */ -MEDCouplingMesh *MEDCouplingMesh::mergeMeshes(const MEDCouplingMesh *mesh1, const MEDCouplingMesh *mesh2) +MEDCouplingMesh *MEDCouplingMesh::MergeMeshes(const MEDCouplingMesh *mesh1, const MEDCouplingMesh *mesh2) { return mesh1->mergeMyselfWith(mesh2); } + +void MEDCouplingMesh::getCellsContainingPoint(const double *pos, double eps, std::vector& elts) const +{ + int ret=getCellContainingPoint(pos,eps); + elts.push_back(ret); +} + +void MEDCouplingMesh::getCellsContainingPoints(const double *pos, int nbOfPoints, double eps, std::vector& elts, std::vector& eltsIndex) const +{ + eltsIndex.resize(nbOfPoints+1); + eltsIndex[0]=0; + elts.clear(); + int spaceDim=getSpaceDimension(); + const double *work=pos; + for(int i=0;i=0) + { + elts.push_back(ret); + eltsIndex[i+1]=eltsIndex[i]+1; + } + else + eltsIndex[i+1]=eltsIndex[i]; + } +} diff --git a/src/MEDCoupling/MEDCouplingMesh.hxx b/src/MEDCoupling/MEDCouplingMesh.hxx index 524c23017..182dce853 100644 --- a/src/MEDCoupling/MEDCouplingMesh.hxx +++ b/src/MEDCoupling/MEDCouplingMesh.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __PARAMEDMEM_MEDCOUPLINGMESH_HXX__ @@ -26,6 +26,7 @@ #include "NormalizedUnstructuredMesh.hxx" #include "InterpKernelException.hxx" +#include #include namespace ParaMEDMEM @@ -40,6 +41,7 @@ namespace ParaMEDMEM class DataArrayInt; class DataArrayDouble; + class MEDCouplingUMesh; class MEDCouplingFieldDouble; class MEDCOUPLING_EXPORT MEDCouplingMesh : public RefCountObject, public TimeLabel @@ -47,10 +49,17 @@ namespace ParaMEDMEM public: void setName(const char *name) { _name=name; } const char *getName() const { return _name.c_str(); } + void setDescription(const char *descr) { _description=descr; } + const char *getDescription() const { return _description.c_str(); } + double getTime(int& iteration, int& order) const { iteration=_iteration; order=_order; return _time; } + void setTime(double val, int iteration, int order) { _time=val; _iteration=iteration; _order=order; } + void setTimeUnit(const char *unit) { _time_unit=unit; } + const char *getTimeUnit() const { return _time_unit.c_str(); } virtual MEDCouplingMesh *deepCpy() const = 0; virtual MEDCouplingMeshType getType() const = 0; bool isStructured() const; virtual void copyTinyStringsFrom(const MEDCouplingMesh *other) throw(INTERP_KERNEL::Exception); + virtual void copyTinyInfoFrom(const MEDCouplingMesh *other) throw(INTERP_KERNEL::Exception); // comparison methods virtual bool isEqual(const MEDCouplingMesh *other, double prec) const; virtual bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const = 0; @@ -63,6 +72,8 @@ namespace ParaMEDMEM DataArrayInt *&cellCor, DataArrayInt *&nodeCor) const throw(INTERP_KERNEL::Exception); // virtual void checkCoherency() const throw(INTERP_KERNEL::Exception) = 0; + virtual void checkCoherency1(double eps=1e-12) const throw(INTERP_KERNEL::Exception) = 0; + virtual void checkCoherency2(double eps=1e-12) const throw(INTERP_KERNEL::Exception) = 0; virtual int getNumberOfCells() const = 0; virtual int getNumberOfNodes() const = 0; virtual int getSpaceDimension() const = 0; @@ -71,18 +82,24 @@ namespace ParaMEDMEM virtual DataArrayDouble *getBarycenterAndOwner() const = 0; virtual int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const = 0; virtual INTERP_KERNEL::NormalizedCellType getTypeOfCell(int cellId) const = 0; + virtual std::set getAllGeoTypes() const = 0; virtual void getNodeIdsOfCell(int cellId, std::vector& conn) const = 0; virtual DataArrayInt *getCellIdsFullyIncludedInNodeIds(const int *partBg, const int *partEnd) const; virtual void getCoordinatesOfNode(int nodeId, std::vector& coo) const = 0; virtual std::string simpleRepr() const = 0; virtual std::string advancedRepr() const = 0; // tools + virtual DataArrayInt *checkTypeConsistencyAndContig(const std::vector& code, const std::vector& idsPerType) const throw(INTERP_KERNEL::Exception) = 0; virtual void getBoundingBox(double *bbox) const = 0; virtual MEDCouplingFieldDouble *getMeasureField(bool isAbs) const = 0; virtual MEDCouplingFieldDouble *getMeasureFieldOnNode(bool isAbs) const = 0; virtual int getCellContainingPoint(const double *pos, double eps) const = 0; + virtual void getCellsContainingPoint(const double *pos, double eps, std::vector& elts) const; + virtual void getCellsContainingPoints(const double *pos, int nbOfPoints, double eps, std::vector& elts, std::vector& eltsIndex) const; virtual MEDCouplingFieldDouble *fillFromAnalytic(TypeOfField t, int nbOfComp, FunctionToEvaluate func) const; virtual MEDCouplingFieldDouble *fillFromAnalytic(TypeOfField t, int nbOfComp, const char *func) const; + virtual MEDCouplingFieldDouble *fillFromAnalytic2(TypeOfField t, int nbOfComp, const char *func) const; + virtual MEDCouplingFieldDouble *fillFromAnalytic3(TypeOfField t, int nbOfComp, const std::vector& varsOrder, const char *func) const; virtual MEDCouplingFieldDouble *buildOrthogonalField() const = 0; virtual void rotate(const double *center, const double *vector, double angle) = 0; virtual void translate(const double *vector) = 0; @@ -91,20 +108,27 @@ namespace ParaMEDMEM virtual MEDCouplingMesh *mergeMyselfWith(const MEDCouplingMesh *other) const = 0; virtual MEDCouplingMesh *buildPart(const int *start, const int *end) const = 0; virtual MEDCouplingMesh *buildPartAndReduceNodes(const int *start, const int *end, DataArrayInt*& arr) const = 0; + virtual MEDCouplingUMesh *buildUnstructured() const throw(INTERP_KERNEL::Exception) = 0; + virtual DataArrayInt *simplexize(int policy) throw(INTERP_KERNEL::Exception) = 0; virtual bool areCompatibleForMerge(const MEDCouplingMesh *other) const; - static MEDCouplingMesh *mergeMeshes(const MEDCouplingMesh *mesh1, const MEDCouplingMesh *mesh2); + static MEDCouplingMesh *MergeMeshes(const MEDCouplingMesh *mesh1, const MEDCouplingMesh *mesh2); //serialisation-unserialization - virtual void getTinySerializationInformation(std::vector& tinyInfo, std::vector& littleStrings) const = 0; + virtual void getTinySerializationInformation(std::vector& tinyInfoD, std::vector& tinyInfo, std::vector& littleStrings) const = 0; virtual void resizeForUnserialization(const std::vector& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector& littleStrings) const = 0; virtual void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const = 0; - virtual void unserialization(const std::vector& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, + virtual void unserialization(const std::vector& tinyInfoD, const std::vector& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, const std::vector& littleStrings) = 0; protected: - MEDCouplingMesh() { } - MEDCouplingMesh(const MEDCouplingMesh& other):_name(other._name) { } + MEDCouplingMesh(); + MEDCouplingMesh(const MEDCouplingMesh& other); virtual ~MEDCouplingMesh() { } private: std::string _name; + std::string _description; + double _time; + int _iteration; + int _order; + std::string _time_unit; }; } diff --git a/src/MEDCoupling/MEDCouplingMultiFields.cxx b/src/MEDCoupling/MEDCouplingMultiFields.cxx new file mode 100644 index 000000000..86b495559 --- /dev/null +++ b/src/MEDCoupling/MEDCouplingMultiFields.cxx @@ -0,0 +1,443 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "MEDCouplingMultiFields.hxx" +#include "MEDCouplingFieldTemplate.hxx" +#include "MEDCouplingFieldDouble.hxx" +#include "MEDCouplingMesh.hxx" +#include "MEDCouplingAutoRefCountObjectPtr.hxx" + +using namespace ParaMEDMEM; + +MEDCouplingMultiFields *MEDCouplingMultiFields::New(const std::vector& fs) throw(INTERP_KERNEL::Exception) +{ + return new MEDCouplingMultiFields(fs); +} + +MEDCouplingMultiFields *MEDCouplingMultiFields::New() +{ + return new MEDCouplingMultiFields; +} + +MEDCouplingMultiFields *MEDCouplingMultiFields::deepCpy() const +{ + return new MEDCouplingMultiFields(*this); +} + +bool MEDCouplingMultiFields::isEqual(const MEDCouplingMultiFields *other, double meshPrec, double valsPrec) const +{ + std::size_t 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) + 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); + 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); + if(das1.size()!=das2.size()) + return false; + if(refs3!=refs4) + return false; + return true; +} + +std::string MEDCouplingMultiFields::getName() const +{ + std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_fs.begin(); + for(;it!=_fs.end();it++) + if((const MEDCouplingFieldDouble *)(*it)) + return (*it)->getName(); + return std::string(); +} + +std::string MEDCouplingMultiFields::getDescription() const +{ + std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_fs.begin(); + for(;it!=_fs.end();it++) + if((const MEDCouplingFieldDouble *)(*it)) + return (*it)->getDescription(); + return std::string(); +} + +std::string MEDCouplingMultiFields::getTimeUnit() const +{ + std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_fs.begin(); + for(;it!=_fs.end();it++) + if((const MEDCouplingFieldDouble *)(*it)) + return (*it)->getTimeUnit(); + return std::string(); +} + +double MEDCouplingMultiFields::getTimeResolution() const throw(INTERP_KERNEL::Exception) +{ + std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_fs.begin(); + for(;it!=_fs.end();it++) + if((const MEDCouplingFieldDouble *)(*it)) + return (*it)->getTimeTolerance(); + throw INTERP_KERNEL::Exception("MEDCouplingMultiFields::getTimeResolution : no not null field !"); +} + +std::string MEDCouplingMultiFields::simpleRepr() const +{ + std::ostringstream ret; + ret << "MEDCouplingMultiFields with name : \"" << getName() << "\"\n"; + ret << "Description of MEDCouplingMultiFields is : \"" << getDescription() << "\"\n"; + ret << "Number of discretization : " << _fs.size() << "\n"; + ret << "Number of different meshes : "; + std::vector ms; + std::vector refms; + try + { + ms=getDifferentMeshes(refms); + ret << ms.size() << "\n"; + } + catch(INTERP_KERNEL::Exception& e) + { ret << "Current instance is INVALID !\n"; } + return ret.str(); +} + +std::string MEDCouplingMultiFields::advancedRepr() const +{ + return simpleRepr(); +} + +bool MEDCouplingMultiFields::isEqualWithoutConsideringStr(const MEDCouplingMultiFields *other, double meshPrec, double valsPrec) const +{ + std::size_t sz=_fs.size(); + if(sz!=other->_fs.size()) + return false; + for(std::size_t i=0;iisEqualWithoutConsideringStr(other->_fs[i],meshPrec,valsPrec)) + return false; + return true; +} + +const MEDCouplingFieldDouble *MEDCouplingMultiFields::getFieldWithId(int id) const throw(INTERP_KERNEL::Exception) +{ + if(id>=(int)_fs.size() || id < 0) + throw INTERP_KERNEL::Exception("MEDCouplingMultiFields::getFieldWithId : invalid id outside boundaries !"); + return _fs[id]; +} + +std::vector MEDCouplingMultiFields::getFields() const +{ + std::vector ret(_fs.size()); + std::copy(_fs.begin(),_fs.end(),ret.begin()); + return ret; +} + +int MEDCouplingMultiFields::getNumberOfFields() const +{ + return _fs.size(); +} + +const MEDCouplingFieldDouble *MEDCouplingMultiFields::getFieldAtPos(int id) const throw(INTERP_KERNEL::Exception) +{ + if(id<0 || id>=(int)_fs.size()) + { + std::ostringstream oss; oss << "MEDCouplingMultiFields::getFieldAtPos : Invalid given pos : should be >=0 and < " << _fs.size() << " !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + return _fs[id]; +} + +void MEDCouplingMultiFields::updateTime() const +{ + std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_fs.begin(); + for(;it!=_fs.end();it++) + if((const MEDCouplingFieldDouble *)(*it)) + (*it)->updateTime(); + it=_fs.begin(); + for(;it!=_fs.end();it++) + if((const MEDCouplingFieldDouble *)(*it)) + updateTimeWith(*(*it)); +} + +std::vector MEDCouplingMultiFields::getMeshes() const throw(INTERP_KERNEL::Exception) +{ + std::vector ms; + for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_fs.begin();it!=_fs.end();it++) + { + const MEDCouplingMesh *m=0; + if((const MEDCouplingFieldDouble *)(*it)) + m=(*it)->getMesh(); + ms.push_back(const_cast(m)); + } + return ms; +} + +std::vector MEDCouplingMultiFields::getDifferentMeshes(std::vector& refs) const throw(INTERP_KERNEL::Exception) +{ + refs.resize(_fs.size()); + std::vector ms; + int id=0; + for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_fs.begin();it!=_fs.end();it++,id++) + { + const MEDCouplingMesh *m=0; + if((const MEDCouplingFieldDouble *)(*it)) + m=(*it)->getMesh(); + if(m) + { + std::vector::iterator it=std::find(ms.begin(),ms.end(),m); + if(it==ms.end()) + { + ms.push_back(const_cast(m)); + refs[id]=ms.size()-1; + } + else + refs[id]=std::distance(ms.begin(),it); + } + else + refs[id]=-1; + } + return ms; +} + +std::vector MEDCouplingMultiFields::getArrays() const throw(INTERP_KERNEL::Exception) +{ + std::vector tmp; + for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_fs.begin();it!=_fs.end();it++) + { + std::vector tmp2=(*it)->getArrays(); + tmp.insert(tmp.end(),tmp2.begin(),tmp2.end()); + } + return tmp; +} + +std::vector MEDCouplingMultiFields::getDifferentArrays(std::vector< std::vector >& refs) const throw(INTERP_KERNEL::Exception) +{ + refs.resize(_fs.size()); + int id=0; + std::vector ret; + for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_fs.begin();it!=_fs.end();it++,id++) + { + std::vector tmp2; + if((const MEDCouplingFieldDouble *)(*it)) + { + tmp2=(*it)->getArrays(); + refs[id].resize(tmp2.size()); + } + else + refs[id].clear(); + int id2=0; + for(std::vector::const_iterator it2=tmp2.begin();it2!=tmp2.end();it2++,id2++) + { + if(*it2) + { + std::vector::iterator it3=std::find(ret.begin(),ret.end(),*it2); + if(it3==ret.end()) + { + ret.push_back(*it2); + refs[id][id2]=ret.size()-1; + } + else + refs[id][id2]=std::distance(ret.begin(),it3); + } + else + refs[id][id2]=-1; + } + } + return ret; +} + +void MEDCouplingMultiFields::checkCoherency() const throw(INTERP_KERNEL::Exception) +{ + std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_fs.begin(); + for(;it!=_fs.end();it++) + { + if((const MEDCouplingFieldDouble *)(*it)==0) + throw INTERP_KERNEL::Exception("MEDCouplingMultiFields::checkCoherency : There is an empty Field in array..."); + (*it)->checkCoherency(); + } +} + +MEDCouplingMultiFields::MEDCouplingMultiFields(const std::vector& fs) throw(INTERP_KERNEL::Exception):_fs(fs.size()) +{ + int id=0; + for(std::vector< MEDCouplingFieldDouble * >::const_iterator it=fs.begin();it!=fs.end();it++,id++) + { + if(*it) + (*it)->incrRef(); + else + throw INTERP_KERNEL::Exception("MEDCouplingMultiFields constructor : empty field found in vector !"); + (*it)->checkCoherency(); + _fs[id]=*it; + } +} + + +/*! + * Performs deepCpy. + */ +MEDCouplingMultiFields::MEDCouplingMultiFields(const MEDCouplingMultiFields& other) +{ + int sz=other._fs.size(); + _fs.resize(sz); + std::vector refs; + std::vector< std::vector > refs2; + std::vector ms=other.getDifferentMeshes(refs); + int msLgh=ms.size(); + std::vector< MEDCouplingAutoRefCountObjectPtr > ms2(msLgh); + for(int i=0;ideepCpy(); + std::vector das=other.getDifferentArrays(refs2); + int dasLgth=das.size(); + std::vector< MEDCouplingAutoRefCountObjectPtr > das2(dasLgth); + for(int i=0;ideepCpy(); + for(int i=0;igetTimeDiscretization()); + tmp->decrRef(); + if(refs[i]!=-1) + _fs[i]->setMesh(ms2[refs[i]]); + int nbOfArr=refs2[i].size(); + std::vector tmp2(nbOfArr); + for(int j=0;jsetArrays(tmp2); + std::vector tinyInfo; + std::vector tinyInfo2; + other._fs[i]->getTimeDiscretizationUnderGround()->getTinySerializationIntInformation2(tinyInfo); + other._fs[i]->getTimeDiscretizationUnderGround()->getTinySerializationDbleInformation2(tinyInfo2); + _fs[i]->getTimeDiscretizationUnderGround()->finishUnserialization2(tinyInfo,tinyInfo2); + } + } +} + +MEDCouplingMultiFields::MEDCouplingMultiFields() +{ +} + +void MEDCouplingMultiFields::getTinySerializationInformation(std::vector& tinyInfo, std::vector& tinyInfo2, int& nbOfDiffMeshes, int& nbOfDiffArr) const +{ + std::vector refs; + std::vector ms=getDifferentMeshes(refs); + nbOfDiffMeshes=ms.size(); + std::vector< std::vector > refs2; + std::vector fs=getDifferentArrays(refs2); + nbOfDiffArr=fs.size(); + // + int sz=refs.size();//==_fs.size() + int sz2=0; + for(int i=0;i doubleDaInd(sz); + std::vector timeDiscrInt; + tinyInfo.resize(sz2+5*sz+3); + tinyInfo[0]=sz; + tinyInfo[1]=sz2; + for(int i=0;i tmp; + std::vector tmp2; + _fs[i]->getTimeDiscretizationUnderGround()->getTinySerializationDbleInformation2(tmp); + _fs[i]->getTimeDiscretizationUnderGround()->getTinySerializationIntInformation2(tmp2); + tinyInfo[3*sz+3+i]=tmp.size(); + tinyInfo[4*sz+3+i]=tmp2.size(); + tinyInfo2.insert(tinyInfo2.end(),tmp.begin(),tmp.end()); + timeDiscrInt.insert(timeDiscrInt.end(),tmp2.begin(),tmp2.end()); + } + int sz3=timeDiscrInt.size(); + tinyInfo[2]=sz3; + // + for(int i=0;igetTimeDiscretization(); + int k=0; + for(int i=0;i::const_iterator it=refs2[i].begin();it!=refs2[i].end();it++,k++) + tinyInfo[5*sz+k+3]=*it; + tinyInfo.insert(tinyInfo.end(),timeDiscrInt.begin(),timeDiscrInt.end());//tinyInfo has lgth==sz3+sz2+5*sz+3 +} + +void MEDCouplingMultiFields::finishUnserialization(const std::vector& tinyInfoI, const std::vector& tinyInfoD, + const std::vector& ft, const std::vector& ms, + const std::vector& das) +{ + int sz=tinyInfoI[0]; + _fs.resize(sz); + int sz2=tinyInfoI[1]; + // dealing with ft with no mesh set. + for(int i=0;isetMesh(ms[meshId]); + } + // dealing with fieldtemplate->fielddouble + int k=0; + int offI=0; + int offD=0; + for(int i=0;i tmp(sz3); + for(int j=0;jsetArrays(tmp); + // time discr tiny info + int lgthI=tinyInfoI[4*sz+3+i]; + int 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); + _fs[i]->getTimeDiscretizationUnderGround()->finishUnserialization2(tdInfoI,tdInfoD); + // + offI+=lgthI; + offD+=lgthD; + } +} diff --git a/src/MEDCoupling/MEDCouplingMultiFields.hxx b/src/MEDCoupling/MEDCouplingMultiFields.hxx new file mode 100644 index 000000000..39d944754 --- /dev/null +++ b/src/MEDCoupling/MEDCouplingMultiFields.hxx @@ -0,0 +1,76 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef __PARAMEDMEM_MEDCOUPLINGMULTIFIELDS_HXX__ +#define __PARAMEDMEM_MEDCOUPLINGMULTIFIELDS_HXX__ + +#include "MEDCouplingRefCountObject.hxx" +#include "MEDCouplingTimeLabel.hxx" +#include "MEDCouplingAutoRefCountObjectPtr.hxx" + +#include "InterpKernelException.hxx" + +#include + +namespace ParaMEDMEM +{ + class MEDCouplingMesh; + class DataArrayDouble; + class MEDCouplingFieldDouble; + class MEDCouplingFieldTemplate; + + class MEDCouplingMultiFields : public RefCountObject, public TimeLabel + { + public: + static MEDCouplingMultiFields *New(const std::vector& fs) throw(INTERP_KERNEL::Exception); + static MEDCouplingMultiFields *New(); + MEDCouplingMultiFields *deepCpy() const; + std::string getName() const; + std::string getDescription() const; + std::string getTimeUnit() const; + double getTimeResolution() const throw(INTERP_KERNEL::Exception); + virtual std::string simpleRepr() const; + virtual std::string advancedRepr() const; + virtual bool isEqual(const MEDCouplingMultiFields *other, double meshPrec, double valsPrec) const; + virtual bool isEqualWithoutConsideringStr(const MEDCouplingMultiFields *other, double meshPrec, double valsPrec) const; + const MEDCouplingFieldDouble *getFieldWithId(int id) const throw(INTERP_KERNEL::Exception); + std::vector getFields() const; + int getNumberOfFields() const; + const MEDCouplingFieldDouble *getFieldAtPos(int id) const throw(INTERP_KERNEL::Exception); + virtual std::vector getMeshes() const throw(INTERP_KERNEL::Exception); + virtual std::vector getDifferentMeshes(std::vector& refs) const throw(INTERP_KERNEL::Exception); + virtual std::vector getArrays() const throw(INTERP_KERNEL::Exception); + virtual std::vector getDifferentArrays(std::vector< std::vector >& refs) const throw(INTERP_KERNEL::Exception); + void updateTime() const; + void getTinySerializationInformation(std::vector& tinyInfo, std::vector& tinyInfo2, int& nbOfDiffMeshes, int& nbOfDiffArr) const; + void finishUnserialization(const std::vector& tinyInfoI, const std::vector& tinyInfoD, + const std::vector& ft, const std::vector& ms, + const std::vector& das); + virtual void checkCoherency() const throw(INTERP_KERNEL::Exception); + protected: + MEDCouplingMultiFields(const std::vector& fs) throw(INTERP_KERNEL::Exception); + MEDCouplingMultiFields(const MEDCouplingMultiFields& other); + MEDCouplingMultiFields(); + protected: + std::vector< MEDCouplingAutoRefCountObjectPtr > _fs; + }; +} + +#endif + diff --git a/src/MEDCoupling/MEDCouplingNatureOfField.cxx b/src/MEDCoupling/MEDCouplingNatureOfField.cxx index 7969909f1..368e826e9 100644 --- a/src/MEDCoupling/MEDCouplingNatureOfField.cxx +++ b/src/MEDCoupling/MEDCouplingNatureOfField.cxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "MEDCouplingNatureOfField.hxx" diff --git a/src/MEDCoupling/MEDCouplingNatureOfField.hxx b/src/MEDCoupling/MEDCouplingNatureOfField.hxx index 89f9125e0..ff4f34aa2 100644 --- a/src/MEDCoupling/MEDCouplingNatureOfField.hxx +++ b/src/MEDCoupling/MEDCouplingNatureOfField.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __PARAMEDMEM_MEDCOUPLINGNATUREOFFIELD_HXX__ diff --git a/src/MEDCoupling/MEDCouplingNormalizedCartesianMesh.hxx b/src/MEDCoupling/MEDCouplingNormalizedCartesianMesh.hxx index c2643f327..66f7c612b 100644 --- a/src/MEDCoupling/MEDCouplingNormalizedCartesianMesh.hxx +++ b/src/MEDCoupling/MEDCouplingNormalizedCartesianMesh.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __PARAMEDMEM_MEDCOUPLINGNORMALIZEDCARTESIANMESH_HXX__ diff --git a/src/MEDCoupling/MEDCouplingNormalizedCartesianMesh.txx b/src/MEDCoupling/MEDCouplingNormalizedCartesianMesh.txx index 468eea71a..71ff98829 100644 --- a/src/MEDCoupling/MEDCouplingNormalizedCartesianMesh.txx +++ b/src/MEDCoupling/MEDCouplingNormalizedCartesianMesh.txx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // File : MEDCouplingNormalizedCartesianMesh.txx // Created : Mon Aug 17 12:00:38 2009 diff --git a/src/MEDCoupling/MEDCouplingNormalizedUnstructuredMesh.hxx b/src/MEDCoupling/MEDCouplingNormalizedUnstructuredMesh.hxx index 5ebd3ae19..98ac6724e 100644 --- a/src/MEDCoupling/MEDCouplingNormalizedUnstructuredMesh.hxx +++ b/src/MEDCoupling/MEDCouplingNormalizedUnstructuredMesh.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __PARAMEDMEM_MEDCOUPLINGNORMALIZEDUNSTRUCTUREDMESH_HXX__ @@ -36,7 +36,7 @@ public: typedef int MyConnType; static const INTERP_KERNEL::NumberingPolicy My_numPol=INTERP_KERNEL::ALL_C_MODE; public: - MEDCouplingNormalizedUnstructuredMesh(ParaMEDMEM::MEDCouplingUMesh *mesh); + MEDCouplingNormalizedUnstructuredMesh(const ParaMEDMEM::MEDCouplingUMesh *mesh); void getBoundingBox(double *boundingBox) const; INTERP_KERNEL::NormalizedCellType getTypeOfElement(int eltId) const; unsigned char getNumberOfNodesOfElement(int eltId) const; @@ -50,7 +50,7 @@ public: private: void prepare(); private: - ParaMEDMEM::MEDCouplingUMesh *_mesh; + const ParaMEDMEM::MEDCouplingUMesh *_mesh; int *_conn_for_interp; int *_conn_index_for_interp; }; diff --git a/src/MEDCoupling/MEDCouplingNormalizedUnstructuredMesh.txx b/src/MEDCoupling/MEDCouplingNormalizedUnstructuredMesh.txx index ae5ad015e..ffeb9a81e 100644 --- a/src/MEDCoupling/MEDCouplingNormalizedUnstructuredMesh.txx +++ b/src/MEDCoupling/MEDCouplingNormalizedUnstructuredMesh.txx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __MEDCOUPLINGNORMALIZEDUNSTRUCTUREDMESH_TXX__ #define __MEDCOUPLINGNORMALIZEDUNSTRUCTUREDMESH_TXX__ @@ -27,7 +27,7 @@ #include template -MEDCouplingNormalizedUnstructuredMesh::MEDCouplingNormalizedUnstructuredMesh(ParaMEDMEM::MEDCouplingUMesh *mesh):_mesh(mesh) +MEDCouplingNormalizedUnstructuredMesh::MEDCouplingNormalizedUnstructuredMesh(const ParaMEDMEM::MEDCouplingUMesh *mesh):_mesh(mesh) { if(_mesh) _mesh->incrRef(); @@ -42,7 +42,7 @@ void MEDCouplingNormalizedUnstructuredMesh::getBoundingBox(dou boundingBox[i]=std::numeric_limits::max(); boundingBox[SPACEDIM+i]=-std::numeric_limits::max(); } - ParaMEDMEM::DataArrayDouble *array=_mesh->getCoords(); + const ParaMEDMEM::DataArrayDouble *array=_mesh->getCoords(); const double *ptr=array->getConstPointer(); int nbOfPts=array->getNbOfElems()/SPACEDIM; for(int j=0;j::getConnectiv template const double *MEDCouplingNormalizedUnstructuredMesh::getCoordinatesPtr() const { - ParaMEDMEM::DataArrayDouble *array=_mesh->getCoords(); + const ParaMEDMEM::DataArrayDouble *array=_mesh->getCoords(); return array->getConstPointer(); } @@ -114,7 +114,7 @@ template MEDCouplingNormalizedUnstructuredMesh::~MEDCouplingNormalizedUnstructuredMesh() { if(_mesh) - _mesh->decrRef(); + ((ParaMEDMEM::MEDCouplingUMesh *)_mesh)->decrRef(); releaseTempArrays(); } diff --git a/src/MEDCoupling/MEDCouplingPointSet.cxx b/src/MEDCoupling/MEDCouplingPointSet.cxx index 87964cbdf..55bb894aa 100644 --- a/src/MEDCoupling/MEDCouplingPointSet.cxx +++ b/src/MEDCoupling/MEDCouplingPointSet.cxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "MEDCouplingPointSet.hxx" @@ -65,7 +65,7 @@ int MEDCouplingPointSet::getSpaceDimension() const throw INTERP_KERNEL::Exception("Unable to get space dimension because no coordinates specified !"); } -void MEDCouplingPointSet::updateTime() +void MEDCouplingPointSet::updateTime() const { if(_coords) { @@ -73,13 +73,13 @@ void MEDCouplingPointSet::updateTime() } } -void MEDCouplingPointSet::setCoords(DataArrayDouble *coords) +void MEDCouplingPointSet::setCoords(const DataArrayDouble *coords) { if( coords != _coords ) { if (_coords) _coords->decrRef(); - _coords=coords; + _coords=const_cast(coords); if(_coords) _coords->incrRef(); declareAsNew(); @@ -174,7 +174,7 @@ DataArrayInt *MEDCouplingPointSet::buildPermArrayForMergeNode(int limitNodeId, d /*! * This methods searches for each node n1 nodes in _coords that are less far than 'prec' from n1. if any these nodes are stored in params * comm and commIndex. - * @param limitNodeId is the limit node id. All nodes which id is strictly lower than 'limitNodeId' will not be merged. + * @param limitNodeId is the limit node id. All nodes which id is strictly lower than 'limitNodeId' will not be merged each other. * @param comm out parameter (not inout) * @param commIndex out parameter (not inout) */ @@ -209,7 +209,7 @@ void MEDCouplingPointSet::findCommonNodes(int limitNodeId, double prec, DataArra findCommonNodesAlg<1>(bbox,nbNodesOld,limitNodeId,prec,c,cI); break; default: - throw INTERP_KERNEL::Exception("Unexpected spacedim of coords. Must be 1,2 or 3."); + throw INTERP_KERNEL::Exception("Unexpected spacedim of coords. Must be 1, 2 or 3."); } commIndex->alloc(cI.size(),1); std::copy(cI.begin(),cI.end(),commIndex->getPointer()); @@ -217,6 +217,55 @@ void MEDCouplingPointSet::findCommonNodes(int limitNodeId, double prec, DataArra std::copy(c.begin(),c.end(),comm->getPointer()); } +std::vector MEDCouplingPointSet::getNodeIdsNearPoint(const double *pos, double eps) const throw(INTERP_KERNEL::Exception) +{ + std::vector c,cI; + getNodeIdsNearPoints(pos,1,eps,c,cI); + return c; +} + +/*! + * Given a point given by its position 'pos' this method finds the set of node ids that are a a distance lower than eps. + * Position 'pos' is expected to be of size getSpaceDimension()*nbOfNodes. If not the behabiour is not warranted. + * This method throws an exception if no coordiantes are set. + */ +void MEDCouplingPointSet::getNodeIdsNearPoints(const double *pos, int nbOfNodes, double eps, std::vector& c, std::vector& cI) const throw(INTERP_KERNEL::Exception) +{ + if(!_coords) + throw INTERP_KERNEL::Exception("MEDCouplingPointSet::getNodeIdsNearPoint : no coordiantes set !"); + const double *coordsPtr=_coords->getConstPointer(); + if(!coordsPtr) + throw INTERP_KERNEL::Exception("MEDCouplingPointSet::getNodeIdsNearPoint : coordiante array set but no data inside it !"); + int spaceDim=getSpaceDimension(); + int nbNodes=getNumberOfNodes(); + std::vector bbox(2*nbNodes*spaceDim); + for(int i=0;i ret; + c.clear(); + cI.resize(1); cI[0]=0; + switch(spaceDim) + { + case 3: + findNodeIdsNearPointAlg<3>(bbox,pos,nbOfNodes,eps,c,cI); + break; + case 2: + findNodeIdsNearPointAlg<2>(bbox,pos,nbOfNodes,eps,c,cI); + break; + case 1: + findNodeIdsNearPointAlg<1>(bbox,pos,nbOfNodes,eps,c,cI); + break; + default: + throw INTERP_KERNEL::Exception("Unexpected spacedim of coords for getNodeIdsNearPoint. Must be 1, 2 or 3."); + } +} + /*! * @param comm in param in the same format than one returned by findCommonNodes method. * @param commI in param in the same format than one returned by findCommonNodes method. @@ -228,33 +277,28 @@ DataArrayInt *MEDCouplingPointSet::buildNewNumberingFromCommonNodesFormat(const DataArrayInt *ret=DataArrayInt::New(); int nbNodesOld=getNumberOfNodes(); ret->alloc(nbNodesOld,1); - std::fill(ret->getPointer(),ret->getPointer()+nbNodesOld,-1); - int *retPtr=ret->getPointer(); - std::vector commRemain(comm->getConstPointer(),comm->getConstPointer()+comm->getNumberOfTuples()); - std::vector commIRemain(commIndex->getConstPointer(),commIndex->getConstPointer()+commIndex->getNumberOfTuples()); + int *pt=ret->getPointer(); + std::fill(pt,pt+nbNodesOld,-1); + int nbOfGrps=commIndex->getNumberOfTuples()-1; + const int *cIPtr=commIndex->getPointer(); + const int *cPtr=comm->getPointer(); + for(int i=0;i::const_iterator iNode2=commRemain.begin(); - iNode2!=commRemain.begin()+commIRemain[1];iNode2++) - retPtr[*iNode2]=newNb; - int delta=commIRemain[1]; - commRemain.erase(commRemain.begin(),commRemain.begin()+commIRemain[1]); - commIRemain.erase(commIRemain.begin()); - std::transform(commIRemain.begin(),commIRemain.end(),commIRemain.begin(),std::bind2nd(std::minus(),delta)); + if(pt[iNode]==-1) + pt[iNode]=newNb++; + else + { + int grpId=-(pt[iNode]+2); + for(int j=cIPtr[grpId];jgetNumberOfNodes. * newNbOfNodes specifies the *std::max_element(newNodeNumbers,newNodeNumbers+this->getNumberOfNodes()) * This value is asked because often known by the caller of this method. - * @param newNodeNumbers array specifying the new numbering. + * @param newNodeNumbers array specifying the new numbering in old2New convention.. * @param newNbOfNodes the new number of nodes. */ void MEDCouplingPointSet::renumberNodes(const int *newNodeNumbers, int newNbOfNodes) @@ -282,6 +326,38 @@ void MEDCouplingPointSet::renumberNodes(const int *newNodeNumbers, int newNbOfNo newCoords->decrRef(); } +/* + * This method renumber 'this' using 'newNodeNumbers' array of size this->getNumberOfNodes. + * newNbOfNodes specifies the *std::max_element(newNodeNumbers,newNodeNumbers+this->getNumberOfNodes()) + * This value is asked because often known by the caller of this method. + * Contrary to ParaMEDMEM::MEDCouplingPointSet::renumberNodes method for merged nodes the barycenter of them is computed here. + * + * @param newNodeNumbers array specifying the new numbering. + * @param newNbOfNodes the new number of nodes. + */ +void MEDCouplingPointSet::renumberNodes2(const int *newNodeNumbers, int newNbOfNodes) +{ + DataArrayDouble *newCoords=DataArrayDouble::New(); + std::vector div(newNbOfNodes); + int spaceDim=getSpaceDimension(); + newCoords->alloc(newNbOfNodes,spaceDim); + newCoords->copyStringInfoFrom(*_coords); + newCoords->fillWithZero(); + int oldNbOfNodes=getNumberOfNodes(); + double *ptToFill=newCoords->getPointer(); + const double *oldCoordsPtr=_coords->getConstPointer(); + for(int i=0;i()); + div[newNodeNumbers[i]]++; + } + for(int i=0;i(),1./(double)div[i])); + setCoords(newCoords); + newCoords->decrRef(); +} + /*! * This method fills bbox params like that : bbox[0]=XMin, bbox[1]=XMax, bbox[2]=YMin... * The returned bounding box is arranged along trihedron. @@ -469,19 +545,43 @@ void MEDCouplingPointSet::findNodesOnPlane(const double *pt, const double *vec, /*! * merge _coords arrays of m1 and m2 and returns the union. The returned instance is newly created with ref count == 1. */ -DataArrayDouble *MEDCouplingPointSet::mergeNodesArray(const MEDCouplingPointSet *m1, const MEDCouplingPointSet *m2) +DataArrayDouble *MEDCouplingPointSet::MergeNodesArray(const MEDCouplingPointSet *m1, const MEDCouplingPointSet *m2) throw(INTERP_KERNEL::Exception) { int 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()); + throw INTERP_KERNEL::Exception("Mismatch in SpaceDim during call of MergeNodesArray !"); + return DataArrayDouble::Aggregate(m1->getCoords(),m2->getCoords()); +} + +DataArrayDouble *MEDCouplingPointSet::MergeNodesArray(const std::vector& ms) throw(INTERP_KERNEL::Exception) +{ + if(ms.empty()) + throw INTERP_KERNEL::Exception("MEDCouplingPointSet::MergeNodesArray : input array must be NON EMPTY !"); + std::vector::const_iterator it=ms.begin(); + std::vector coo(ms.size()); + int spaceDim=(*it)->getSpaceDimension(); + coo[0]=(*it++)->getCoords(); + for(int i=1;it!=ms.end();it++,i++) + { + const DataArrayDouble *tmp=(*it)->getCoords(); + if(tmp) + { + if((*it)->getSpaceDimension()==spaceDim) + coo[i]=tmp; + else + throw INTERP_KERNEL::Exception("Mismatch in SpaceDim during call of MergeNodesArray !"); + } + else + throw INTERP_KERNEL::Exception("Empty coords detected during call of MergeNodesArray !"); + } + return DataArrayDouble::Aggregate(coo); } /*! * Factory to build new instance of instanciable subclasses of MEDCouplingPointSet. * This method is used during unserialization process. */ -MEDCouplingPointSet *MEDCouplingPointSet::buildInstanceFromMeshType(MEDCouplingMeshType type) +MEDCouplingPointSet *MEDCouplingPointSet::BuildInstanceFromMeshType(MEDCouplingMeshType type) { switch(type) { @@ -497,28 +597,41 @@ MEDCouplingPointSet *MEDCouplingPointSet::buildInstanceFromMeshType(MEDCouplingM /*! * First step of serialization process. Used by ParaMEDMEM and MEDCouplingCorba to transfert data between process. */ -void MEDCouplingPointSet::getTinySerializationInformation(std::vector& tinyInfo, std::vector& littleStrings) const +void MEDCouplingPointSet::getTinySerializationInformation(std::vector& tinyInfoD, std::vector& tinyInfo, std::vector& littleStrings) const { + int it,order; + double time=getTime(it,order); if(_coords) { int spaceDim=getSpaceDimension(); - littleStrings.resize(spaceDim+1); + littleStrings.resize(spaceDim+4); littleStrings[0]=getName(); + littleStrings[1]=getDescription(); + littleStrings[2]=_coords->getName(); + littleStrings[3]=getTimeUnit(); for(int i=0;igetInfoOnComponent(i); + littleStrings[i+4]=getCoords()->getInfoOnComponent(i); tinyInfo.clear(); tinyInfo.push_back(getType()); tinyInfo.push_back(spaceDim); tinyInfo.push_back(getNumberOfNodes()); + tinyInfo.push_back(it); + tinyInfo.push_back(order); + tinyInfoD.push_back(time); } else { - littleStrings.resize(1); + littleStrings.resize(3); littleStrings[0]=getName(); + littleStrings[1]=getDescription(); + littleStrings[2]=getTimeUnit(); tinyInfo.clear(); tinyInfo.push_back(getType()); tinyInfo.push_back(-1); tinyInfo.push_back(-1); + tinyInfo.push_back(it); + tinyInfo.push_back(order); + tinyInfoD.push_back(time); } } @@ -529,7 +642,7 @@ void MEDCouplingPointSet::serialize(DataArrayInt *&a1, DataArrayDouble *&a2) con { if(_coords) { - a2=getCoords(); + a2=const_cast(getCoords()); a2->incrRef(); } else @@ -545,11 +658,11 @@ void MEDCouplingPointSet::resizeForUnserialization(const std::vector& tinyI if(tinyInfo[2]>=0 && tinyInfo[1]>=1) { a2->alloc(tinyInfo[2],tinyInfo[1]); - littleStrings.resize(tinyInfo[1]+1); + littleStrings.resize(tinyInfo[1]+4); } else { - littleStrings.resize(1); + littleStrings.resize(3); } } @@ -557,17 +670,26 @@ void MEDCouplingPointSet::resizeForUnserialization(const std::vector& tinyI * Second and final unserialization process. * @param tinyInfo must be equal to the result given by getTinySerializationInformation method. */ -void MEDCouplingPointSet::unserialization(const std::vector& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, const std::vector& littleStrings) +void MEDCouplingPointSet::unserialization(const std::vector& tinyInfoD, const std::vector& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, const std::vector& littleStrings) { if(tinyInfo[2]>=0 && tinyInfo[1]>=1) { setCoords(a2); setName(littleStrings[0].c_str()); + setDescription(littleStrings[1].c_str()); + a2->setName(littleStrings[2].c_str()); + setTimeUnit(littleStrings[3].c_str()); for(int i=0;isetInfoOnComponent(i,littleStrings[i+1].c_str()); + getCoords()->setInfoOnComponent(i,littleStrings[i+4].c_str()); + setTime(tinyInfoD[0],tinyInfo[3],tinyInfo[4]); } else - setName(littleStrings[0].c_str()); + { + setName(littleStrings[0].c_str()); + setDescription(littleStrings[1].c_str()); + setTimeUnit(littleStrings[2].c_str()); + setTime(tinyInfoD[0],tinyInfo[3],tinyInfo[4]); + } } /*! @@ -640,14 +762,14 @@ void MEDCouplingPointSet::rotate3D(const double *center, const double *vect, dou { double *coords=_coords->getPointer(); int nbNodes=getNumberOfNodes(); - rotate3DAlg(center,vect,angle,nbNodes,coords); + Rotate3DAlg(center,vect,angle,nbNodes,coords); } /*! * Low static method that operates 3D rotation of 'nbNodes' 3D nodes whose coordinates are arranged in 'coords' * around an axe ('center','vect') and with angle 'angle'. */ -void MEDCouplingPointSet::rotate3DAlg(const double *center, const double *vect, double angle, int nbNodes, double *coords) +void MEDCouplingPointSet::Rotate3DAlg(const double *center, const double *vect, double angle, int nbNodes, double *coords) { double sina=sin(angle); double cosa=cos(angle); @@ -687,7 +809,7 @@ void MEDCouplingPointSet::rotate3DAlg(const double *center, const double *vect, */ MEDCouplingMesh *MEDCouplingPointSet::buildPart(const int *start, const int *end) const { - return buildPartOfMySelf(start,end,false); + return buildPartOfMySelf(start,end,true); } /*! @@ -696,6 +818,7 @@ MEDCouplingMesh *MEDCouplingPointSet::buildPart(const int *start, const int *end * behind returned mesh. This cause an overhead but it is lesser in memory. * This method returns an array too. This array allows to the caller to know the mapping between nodeids in 'this' and nodeids in * returned mesh. This is quite usefull for MEDCouplingFieldDouble on nodes for example... + * 'arr' is in old2New format of size ret->getNumberOfCells like MEDCouplingUMesh::zipCoordsTraducer is. * The returned mesh has to be managed by the caller. */ MEDCouplingMesh *MEDCouplingPointSet::buildPartAndReduceNodes(const int *start, const int *end, DataArrayInt*& arr) const @@ -713,14 +836,14 @@ void MEDCouplingPointSet::rotate2D(const double *center, double angle) { double *coords=_coords->getPointer(); int nbNodes=getNumberOfNodes(); - rotate2DAlg(center,angle,nbNodes,coords); + Rotate2DAlg(center,angle,nbNodes,coords); } /*! * Low static method that operates 3D rotation of 'nbNodes' 3D nodes whose coordinates are arranged in 'coords' * around the center point 'center' and with angle 'angle'. */ -void MEDCouplingPointSet::rotate2DAlg(const double *center, double angle, int nbNodes, double *coords) +void MEDCouplingPointSet::Rotate2DAlg(const double *center, double angle, int nbNodes, double *coords) { double cosa=cos(angle); double sina=sin(angle); diff --git a/src/MEDCoupling/MEDCouplingPointSet.hxx b/src/MEDCoupling/MEDCouplingPointSet.hxx index 87a4c04ec..e6125afe1 100644 --- a/src/MEDCoupling/MEDCouplingPointSet.hxx +++ b/src/MEDCoupling/MEDCouplingPointSet.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __PARAMEDMEM_MEDCOUPLINGPOINTSET_HXX__ @@ -34,7 +34,15 @@ namespace ParaMEDMEM { class DataArrayInt; class DataArrayDouble; - + + /*! + * This class is abstract and not instanciable. + * ParaMEDMEM::MEDCouplingUMesh class inherits from this class. + * This class aggregates an array '_coords' containing nodes coordinates. + * So all operations on coordinates are managed by this class. + * This is the case for example for following methods : + * rotation, translation, scaling, getNodeIdsNearPoint, boundingbox... + */ class MEDCOUPLING_EXPORT MEDCouplingPointSet : public MEDCouplingMesh { protected: @@ -42,11 +50,12 @@ namespace ParaMEDMEM MEDCouplingPointSet(const MEDCouplingPointSet& other, bool deepCpy); ~MEDCouplingPointSet(); public: - void updateTime(); + void updateTime() const; int getNumberOfNodes() const; int getSpaceDimension() const; - void setCoords(DataArrayDouble *coords); - DataArrayDouble *getCoords() const { return _coords; } + void setCoords(const DataArrayDouble *coords); + const DataArrayDouble *getCoords() const { return _coords; } + DataArrayDouble *getCoords() { return _coords; } DataArrayDouble *getCoordinatesAndOwner() const; void copyTinyStringsFrom(const MEDCouplingMesh *other) throw(INTERP_KERNEL::Exception); bool isEqual(const MEDCouplingMesh *other, double prec) const; @@ -54,7 +63,10 @@ namespace ParaMEDMEM bool areCoordsEqual(const MEDCouplingPointSet& other, double prec) const; bool areCoordsEqualWithoutConsideringStr(const MEDCouplingPointSet& other, double prec) const; virtual DataArrayInt *mergeNodes(double precision, bool& areNodesMerged, int& newNbOfNodes) = 0; + virtual DataArrayInt *mergeNodes2(double precision, bool& areNodesMerged, int& newNbOfNodes) = 0; DataArrayInt *buildPermArrayForMergeNode(int limitNodeId, double precision, bool& areNodesMerged, int& newNbOfNodes) const; + std::vector getNodeIdsNearPoint(const double *pos, double eps) const throw(INTERP_KERNEL::Exception); + void getNodeIdsNearPoints(const double *pos, int nbOfNodes, double eps, std::vector& c, std::vector& cI) const throw(INTERP_KERNEL::Exception); void findCommonNodes(int limitNodeId, double prec, DataArrayInt *&comm, DataArrayInt *&commIndex) const; DataArrayInt *buildNewNumberingFromCommonNodesFormat(const DataArrayInt *comm, const DataArrayInt *commIndex, int& newNbOfNodes) const; @@ -68,10 +80,11 @@ namespace ParaMEDMEM void tryToShareSameCoords(const MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception); virtual void tryToShareSameCoordsPermute(const MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception) = 0; void findNodesOnPlane(const double *pt, const double *vec, double eps, std::vector& nodes) const throw(INTERP_KERNEL::Exception); - static DataArrayDouble *mergeNodesArray(const MEDCouplingPointSet *m1, const MEDCouplingPointSet *m2); - static MEDCouplingPointSet *buildInstanceFromMeshType(MEDCouplingMeshType type); - static void rotate2DAlg(const double *center, double angle, int nbNodes, double *coords); - static void rotate3DAlg(const double *center, const double *vect, double angle, int nbNodes, double *coords); + static DataArrayDouble *MergeNodesArray(const MEDCouplingPointSet *m1, const MEDCouplingPointSet *m2) throw(INTERP_KERNEL::Exception); + static DataArrayDouble *MergeNodesArray(const std::vector& ms) throw(INTERP_KERNEL::Exception); + static MEDCouplingPointSet *BuildInstanceFromMeshType(MEDCouplingMeshType type); + static void Rotate2DAlg(const double *center, double angle, int nbNodes, double *coords); + static void Rotate3DAlg(const double *center, const double *vect, double angle, int nbNodes, double *coords); MEDCouplingMesh *buildPart(const int *start, const int *end) const; MEDCouplingMesh *buildPartAndReduceNodes(const int *start, const int *end, DataArrayInt*& arr) const; virtual MEDCouplingPointSet *buildPartOfMySelf(const int *start, const int *end, bool keepCoords) const = 0; @@ -80,15 +93,16 @@ namespace ParaMEDMEM virtual void findBoundaryNodes(std::vector& nodes) const = 0; virtual MEDCouplingPointSet *buildBoundaryMesh(bool keepCoords) const = 0; virtual void renumberNodes(const int *newNodeNumbers, int newNbOfNodes); + virtual void renumberNodes2(const int *newNodeNumbers, int newNbOfNodes); virtual bool isEmptyMesh(const std::vector& tinyInfo) const = 0; //! size of returned tinyInfo must be always the same. - void getTinySerializationInformation(std::vector& tinyInfo, std::vector& littleStrings) const; + void getTinySerializationInformation(std::vector& tinyInfoD, std::vector& tinyInfo, std::vector& littleStrings) const; void resizeForUnserialization(const std::vector& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector& littleStrings) const; void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const; - void unserialization(const std::vector& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, + void unserialization(const std::vector& tinyInfoD, const std::vector& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, const std::vector& littleStrings); - virtual void giveElemsInBoundingBox(const double *bbox, double eps, std::vector& elems) = 0; - virtual void giveElemsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bbox, double eps, std::vector& elems) = 0; + virtual void getCellsInBoundingBox(const double *bbox, double eps, std::vector& elems) = 0; + virtual void getCellsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bbox, double eps, std::vector& elems) = 0; virtual DataArrayInt *zipCoordsTraducer() = 0; protected: virtual void checkFullyDefined() const throw(INTERP_KERNEL::Exception) = 0; @@ -101,6 +115,9 @@ namespace ParaMEDMEM template void findCommonNodesAlg(std::vector& bbox, int nbNodes, int limitNodeId, double prec, std::vector& c, std::vector& cI) const; + template + void findNodeIdsNearPointAlg(std::vector& bbox, const double *pos, int nbNodes, double eps, + std::vector& c, std::vector& cI) const; protected: DataArrayDouble *_coords; }; diff --git a/src/MEDCoupling/MEDCouplingPointSet.txx b/src/MEDCoupling/MEDCouplingPointSet.txx index bae195566..9bd37459f 100644 --- a/src/MEDCoupling/MEDCouplingPointSet.txx +++ b/src/MEDCoupling/MEDCouplingPointSet.txx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __PARAMEDMEM_MEDCOUPLINGPOINTSET_TXX__ #define __PARAMEDMEM_MEDCOUPLINGPOINTSET_TXX__ @@ -36,32 +36,63 @@ namespace ParaMEDMEM BBTree myTree(&bbox[0],0,0,nbNodes,-prec); double bb[2*SPACEDIM]; double prec2=prec*prec; + std::vector isDone(nbNodes); + for(int i=0;i intersectingElems; + myTree.getIntersectingElems(bb,intersectingElems); + if(intersectingElems.size()>1) + { + std::vector commonNodes; + for(std::vector::const_iterator it=intersectingElems.begin();it!=intersectingElems.end();it++) + if(*it!=i) + if(*it>=limitNodeId) + if(INTERP_KERNEL::distance2(coordsPtr+SPACEDIM*i,coordsPtr+SPACEDIM*(*it)) + void MEDCouplingPointSet::findNodeIdsNearPointAlg(std::vector& bbox, const double *pos, int nbNodes, double eps, + std::vector& c, std::vector& cI) const + { + const double *coordsPtr=_coords->getConstPointer(); + BBTree myTree(&bbox[0],0,0,getNumberOfNodes(),-eps); + double bb[2*SPACEDIM]; + double eps2=eps*eps; for(int i=0;i intersectingElems; myTree.getIntersectingElems(bb,intersectingElems); - if(intersectingElems.size()>1) - { - std::vector commonNodes; - for(std::vector::const_iterator it=intersectingElems.begin();it!=intersectingElems.end();it++) - if(*it!=i) - if(*it>=limitNodeId) - if(INTERP_KERNEL::distance2(coordsPtr+SPACEDIM*i,coordsPtr+SPACEDIM*(*it)) commonNodes; + for(std::vector::const_iterator it=intersectingElems.begin();it!=intersectingElems.end();it++) + if(INTERP_KERNEL::distance2(pos+SPACEDIM*i,coordsPtr+SPACEDIM*(*it))(srcMesh); _target_mesh=const_cast(targetMesh); _src_mesh->incrRef(); _target_mesh->incrRef(); int meshInterpType=((int)_src_mesh->getType()*16)+(int)_target_mesh->getType(); switch(meshInterpType) @@ -58,6 +59,13 @@ int MEDCouplingRemapper::prepare(const MEDCouplingMesh *srcMesh, const MEDCoupli } } +int MEDCouplingRemapper::prepareEx(const MEDCouplingFieldTemplate *src, const MEDCouplingFieldTemplate *target) throw(INTERP_KERNEL::Exception) +{ + std::string meth(src->getDiscretization()->getStringRepr()); + meth+=target->getDiscretization()->getStringRepr(); + return prepare(src->getMesh(),target->getMesh(),meth.c_str()); +} + void MEDCouplingRemapper::transfer(const MEDCouplingFieldDouble *srcField, MEDCouplingFieldDouble *targetField, double dftValue) throw(INTERP_KERNEL::Exception) { if(_src_method!=srcField->getDiscretization()->getStringRepr()) @@ -316,7 +324,7 @@ int MEDCouplingRemapper::prepareEE(const char *method) throw(INTERP_KERNEL::Exce int nbCols2D=interpolation2D.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,matrix2D,method); MEDCouplingUMesh *s1D,*t1D; double v[3]; - MEDCouplingExtrudedMesh::project1DMeshes(src_mesh->getMesh1D(),target_mesh->getMesh1D(),getPrecision(),s1D,t1D,v); + MEDCouplingExtrudedMesh::Project1DMeshes(src_mesh->getMesh1D(),target_mesh->getMesh1D(),getPrecision(),s1D,t1D,v); MEDCouplingNormalizedUnstructuredMesh<1,1> s1DWrapper(s1D); MEDCouplingNormalizedUnstructuredMesh<1,1> t1DWrapper(t1D); std::vector > matrix1D; @@ -335,7 +343,7 @@ int MEDCouplingRemapper::prepareEE(const char *method) throw(INTERP_KERNEL::Exce return 1; } -void MEDCouplingRemapper::updateTime() +void MEDCouplingRemapper::updateTime() const { } diff --git a/src/MEDCoupling/MEDCouplingRemapper.hxx b/src/MEDCoupling/MEDCouplingRemapper.hxx index 14d402d03..332a26f4c 100644 --- a/src/MEDCoupling/MEDCouplingRemapper.hxx +++ b/src/MEDCoupling/MEDCouplingRemapper.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __PARAMEDMEM_MEDCOUPLINGREMAPPER_HXX__ @@ -34,6 +34,7 @@ namespace ParaMEDMEM class MEDCouplingMesh; class MEDCouplingUMesh; class MEDCouplingFieldDouble; + class MEDCouplingFieldTemplate; } namespace ParaMEDMEM @@ -44,6 +45,7 @@ namespace ParaMEDMEM MEDCOUPLINGREMAPPER_EXPORT MEDCouplingRemapper(); MEDCOUPLINGREMAPPER_EXPORT ~MEDCouplingRemapper(); MEDCOUPLINGREMAPPER_EXPORT int prepare(const MEDCouplingMesh *srcMesh, const MEDCouplingMesh *targetMesh, const char *method) throw(INTERP_KERNEL::Exception); + MEDCOUPLINGREMAPPER_EXPORT int prepareEx(const MEDCouplingFieldTemplate *src, const MEDCouplingFieldTemplate *target) throw(INTERP_KERNEL::Exception); MEDCOUPLINGREMAPPER_EXPORT void transfer(const MEDCouplingFieldDouble *srcField, MEDCouplingFieldDouble *targetField, double dftValue) throw(INTERP_KERNEL::Exception); MEDCOUPLINGREMAPPER_EXPORT void reverseTransfer(MEDCouplingFieldDouble *srcField, const MEDCouplingFieldDouble *targetField, double dftValue) throw(INTERP_KERNEL::Exception); MEDCOUPLINGREMAPPER_EXPORT MEDCouplingFieldDouble *transferField(const MEDCouplingFieldDouble *srcField, double dftValue) throw(INTERP_KERNEL::Exception); @@ -56,7 +58,7 @@ namespace ParaMEDMEM private: int prepareUU(const char *method) throw(INTERP_KERNEL::Exception); int prepareEE(const char *method) throw(INTERP_KERNEL::Exception); - void updateTime(); + void updateTime() const; void releaseData(bool matrixSuppression); void computeDeno(NatureOfField nat, const MEDCouplingFieldDouble *srcField, const MEDCouplingFieldDouble *trgField); void computeDenoFromScratch(NatureOfField nat, const MEDCouplingFieldDouble *srcField, const MEDCouplingFieldDouble *trgField) throw(INTERP_KERNEL::Exception); diff --git a/src/MEDCoupling/MEDCouplingTimeDiscretization.cxx b/src/MEDCoupling/MEDCouplingTimeDiscretization.cxx index a150a9cd4..c4b277a2c 100644 --- a/src/MEDCoupling/MEDCouplingTimeDiscretization.cxx +++ b/src/MEDCoupling/MEDCouplingTimeDiscretization.cxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "MEDCouplingTimeDiscretization.hxx" @@ -65,10 +65,12 @@ MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::New(TypeOfTimeDisc void MEDCouplingTimeDiscretization::copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other) { _time_tolerance=other._time_tolerance; + _time_unit=other._time_unit; } void MEDCouplingTimeDiscretization::copyTinyStringsFrom(const MEDCouplingTimeDiscretization& other) { + _time_unit=other._time_unit; if(_array && other._array) _array->copyStringInfoFrom(*other._array); } @@ -81,7 +83,7 @@ void MEDCouplingTimeDiscretization::checkCoherency() const throw(INTERP_KERNEL:: throw INTERP_KERNEL::Exception("time tolerance is expected to be greater than 0. !"); } -void MEDCouplingTimeDiscretization::updateTime() +void MEDCouplingTimeDiscretization::updateTime() const { if(_array) updateTimeWith(*_array); @@ -102,6 +104,8 @@ bool MEDCouplingTimeDiscretization::areCompatible(const MEDCouplingTimeDiscretiz bool MEDCouplingTimeDiscretization::areStrictlyCompatible(const MEDCouplingTimeDiscretization *other) const { + if(_time_unit!=other->_time_unit) + return false; if(std::fabs(_time_tolerance-other->_time_tolerance)>1.e-16) return false; if(_array==0 && other->_array==0) @@ -115,6 +119,19 @@ bool MEDCouplingTimeDiscretization::areStrictlyCompatible(const MEDCouplingTimeD return true; } +bool MEDCouplingTimeDiscretization::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const +{ + if(std::fabs(_time_tolerance-other->_time_tolerance)>1.e-16) + return false; + if(_array==0 && other->_array==0) + return true; + if(_array==0 || other->_array==0) + return false; + if(_array->getNumberOfTuples()!=other->_array->getNumberOfTuples()) + return false; + return true; +} + bool MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const { if(std::fabs(_time_tolerance-other->_time_tolerance)>1.e-16) @@ -131,6 +148,21 @@ bool MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(const MEDCouplin return true; } +bool MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const +{ + if(std::fabs(_time_tolerance-other->_time_tolerance)>1.e-16) + return false; + if(_array==0 && other->_array==0) + return true; + if(_array==0 || other->_array==0) + return false; + int nbC1=_array->getNumberOfComponents(); + int nbC2=other->_array->getNumberOfComponents(); + if(nbC1!=nbC2 && nbC2!=1) + return false; + return true; +} + bool MEDCouplingTimeDiscretization::isEqual(const MEDCouplingTimeDiscretization *other, double prec) const { if(!areStrictlyCompatible(other)) @@ -149,11 +181,11 @@ bool MEDCouplingTimeDiscretization::isEqualWithoutConsideringStr(const MEDCoupli return _array->isEqualWithoutConsideringStr(*other->_array,prec); } -MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::buildNewTimeReprFromThis(const MEDCouplingTimeDiscretization *other, - TypeOfTimeDiscretization type, bool deepCpy) const +MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::buildNewTimeReprFromThis(TypeOfTimeDiscretization type, bool deepCpy) const { MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(type); - DataArrayDouble *arrSrc=getArray(); + ret->setTimeUnit(getTimeUnit()); + const DataArrayDouble *arrSrc=getArray(); DataArrayDouble *arr=0; if(arrSrc) arr=arrSrc->performCpy(deepCpy); @@ -217,7 +249,7 @@ MEDCouplingTimeDiscretization::MEDCouplingTimeDiscretization():_time_tolerance(T { } -MEDCouplingTimeDiscretization::MEDCouplingTimeDiscretization(const MEDCouplingTimeDiscretization& other, bool deepCpy):_time_tolerance(other._time_tolerance) +MEDCouplingTimeDiscretization::MEDCouplingTimeDiscretization(const MEDCouplingTimeDiscretization& other, bool deepCpy):_time_unit(other._time_unit),_time_tolerance(other._time_tolerance) { if(other._array) _array=other._array->performCpy(deepCpy); @@ -245,7 +277,12 @@ void MEDCouplingTimeDiscretization::setArray(DataArrayDouble *array, TimeLabel * } } -DataArrayDouble *MEDCouplingTimeDiscretization::getEndArray() const +const DataArrayDouble *MEDCouplingTimeDiscretization::getEndArray() const +{ + throw INTERP_KERNEL::Exception("getEndArray not available for this type of time discretization !"); +} + +DataArrayDouble *MEDCouplingTimeDiscretization::getEndArray() { throw INTERP_KERNEL::Exception("getEndArray not available for this type of time discretization !"); } @@ -287,6 +324,7 @@ bool MEDCouplingTimeDiscretization::isStrictlyBefore(const MEDCouplingTimeDiscre MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::doublyContractedProduct() const throw(INTERP_KERNEL::Exception) { MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum()); + ret->setTimeUnit(getTimeUnit()); std::vector arrays; getArrays(arrays); std::vector< MEDCouplingAutoRefCountObjectPtr > arrays2(arrays.size()); @@ -320,6 +358,7 @@ MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::determinant() cons for(int j=0;j<(int)arrays.size();j++) arrays3[j]=arrays2[j]; MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum()); + ret->setTimeUnit(getTimeUnit()); ret->setArrays(arrays3,0); return ret; } @@ -340,6 +379,7 @@ MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::eigenValues() cons for(int j=0;j<(int)arrays.size();j++) arrays3[j]=arrays2[j]; MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum()); + ret->setTimeUnit(getTimeUnit()); ret->setArrays(arrays3,0); return ret; } @@ -360,6 +400,7 @@ MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::eigenVectors() con for(int j=0;j<(int)arrays.size();j++) arrays3[j]=arrays2[j]; MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum()); + ret->setTimeUnit(getTimeUnit()); ret->setArrays(arrays3,0); return ret; } @@ -380,6 +421,7 @@ MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::inverse() const th for(int j=0;j<(int)arrays.size();j++) arrays3[j]=arrays2[j]; MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum()); + ret->setTimeUnit(getTimeUnit()); ret->setArrays(arrays3,0); return ret; } @@ -400,6 +442,7 @@ MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::trace() const thro for(int j=0;j<(int)arrays.size();j++) arrays3[j]=arrays2[j]; MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum()); + ret->setTimeUnit(getTimeUnit()); ret->setArrays(arrays3,0); return ret; } @@ -420,6 +463,7 @@ MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::deviator() const t for(int j=0;j<(int)arrays.size();j++) arrays3[j]=arrays2[j]; MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum()); + ret->setTimeUnit(getTimeUnit()); ret->setArrays(arrays3,0); return ret; } @@ -440,6 +484,7 @@ MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::magnitude() const for(int j=0;j<(int)arrays.size();j++) arrays3[j]=arrays2[j]; MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum()); + ret->setTimeUnit(getTimeUnit()); ret->setArrays(arrays3,0); return ret; } @@ -460,6 +505,7 @@ MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::maxPerTuple() cons for(int j=0;j<(int)arrays.size();j++) arrays3[j]=arrays2[j]; MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum()); + ret->setTimeUnit(getTimeUnit()); ret->setArrays(arrays3,0); return ret; } @@ -480,6 +526,7 @@ MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::keepSelectedCompon for(int j=0;j<(int)arrays.size();j++) arrays3[j]=arrays2[j]; MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum()); + ret->setTimeUnit(getTimeUnit()); ret->setArrays(arrays3,0); return ret; } @@ -571,7 +618,7 @@ void MEDCouplingTimeDiscretization::applyFunc(int nbOfComp, FunctionToEvaluate f { std::vector arrays; getArrays(arrays); - std::vector arrays2(arrays.size()); + std::vector< MEDCouplingAutoRefCountObjectPtr > arrays2(arrays.size()); for(int j=0;j<(int)arrays.size();j++) { if(arrays[j]) @@ -579,17 +626,17 @@ void MEDCouplingTimeDiscretization::applyFunc(int nbOfComp, FunctionToEvaluate f else arrays2[j]=0; } - setArrays(arrays2,0); + std::vector arrays3(arrays.size()); for(int j=0;j<(int)arrays.size();j++) - if(arrays2[j]) - arrays2[j]->decrRef(); + arrays3[j]=arrays2[j]; + setArrays(arrays3,0); } void MEDCouplingTimeDiscretization::applyFunc(int nbOfComp, const char *func) { std::vector arrays; getArrays(arrays); - std::vector arrays2(arrays.size()); + std::vector< MEDCouplingAutoRefCountObjectPtr > arrays2(arrays.size()); for(int j=0;j<(int)arrays.size();j++) { if(arrays[j]) @@ -597,17 +644,53 @@ void MEDCouplingTimeDiscretization::applyFunc(int nbOfComp, const char *func) else arrays2[j]=0; } - setArrays(arrays2,0); + std::vector arrays3(arrays.size()); for(int j=0;j<(int)arrays.size();j++) - if(arrays2[j]) - arrays2[j]->decrRef(); + arrays3[j]=arrays2[j]; + setArrays(arrays3,0); +} + +void MEDCouplingTimeDiscretization::applyFunc2(int nbOfComp, const char *func) +{ + std::vector arrays; + getArrays(arrays); + std::vector< MEDCouplingAutoRefCountObjectPtr > arrays2(arrays.size()); + for(int j=0;j<(int)arrays.size();j++) + { + if(arrays[j]) + arrays2[j]=arrays[j]->applyFunc2(nbOfComp,func); + else + arrays2[j]=0; + } + std::vector arrays3(arrays.size()); + for(int j=0;j<(int)arrays.size();j++) + arrays3[j]=arrays2[j]; + setArrays(arrays3,0); +} + +void MEDCouplingTimeDiscretization::applyFunc3(int nbOfComp, const std::vector& varsOrder, const char *func) +{ + std::vector arrays; + getArrays(arrays); + std::vector< MEDCouplingAutoRefCountObjectPtr > arrays2(arrays.size()); + for(int j=0;j<(int)arrays.size();j++) + { + if(arrays[j]) + arrays2[j]=arrays[j]->applyFunc3(nbOfComp,varsOrder,func); + else + arrays2[j]=0; + } + std::vector arrays3(arrays.size()); + for(int j=0;j<(int)arrays.size();j++) + arrays3[j]=arrays2[j]; + setArrays(arrays3,0); } void MEDCouplingTimeDiscretization::applyFunc(const char *func) { std::vector arrays; getArrays(arrays); - std::vector arrays2(arrays.size()); + std::vector< MEDCouplingAutoRefCountObjectPtr > arrays2(arrays.size()); for(int j=0;j<(int)arrays.size();j++) { if(arrays[j]) @@ -615,10 +698,10 @@ void MEDCouplingTimeDiscretization::applyFunc(const char *func) else arrays2[j]=0; } - setArrays(arrays2,0); + std::vector arrays3(arrays.size()); for(int j=0;j<(int)arrays.size();j++) - if(arrays2[j]) - arrays2[j]->decrRef(); + arrays3[j]=arrays2[j]; + setArrays(arrays3,0); } void MEDCouplingTimeDiscretization::applyFuncFast32(const char *func) @@ -669,6 +752,32 @@ void MEDCouplingTimeDiscretization::fillFromAnalytic(const DataArrayDouble *loc, setArrays(arrays3,0); } +void MEDCouplingTimeDiscretization::fillFromAnalytic2(const DataArrayDouble *loc, int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception) +{ + std::vector arrays; + getArrays(arrays); + std::vector< MEDCouplingAutoRefCountObjectPtr > arrays2(arrays.size()); + for(int j=0;j<(int)arrays.size();j++) + arrays2[j]=loc->applyFunc2(nbOfComp,func); + std::vector arrays3(arrays.size()); + for(int j=0;j<(int)arrays.size();j++) + arrays3[j]=arrays2[j]; + setArrays(arrays3,0); +} + +void MEDCouplingTimeDiscretization::fillFromAnalytic3(const DataArrayDouble *loc, int nbOfComp, const std::vector& varsOrder, const char *func) throw(INTERP_KERNEL::Exception) +{ + std::vector arrays; + getArrays(arrays); + std::vector< MEDCouplingAutoRefCountObjectPtr > arrays2(arrays.size()); + for(int j=0;j<(int)arrays.size();j++) + arrays2[j]=loc->applyFunc3(nbOfComp,varsOrder,func); + std::vector arrays3(arrays.size()); + for(int j=0;j<(int)arrays.size();j++) + arrays3[j]=arrays2[j]; + setArrays(arrays3,0); +} + MEDCouplingNoTimeLabel::MEDCouplingNoTimeLabel() { } @@ -681,6 +790,7 @@ std::string MEDCouplingNoTimeLabel::getStringRepr() const { std::ostringstream stream; stream << REPR; + stream << "\nTime unit is : \"" << _time_unit << "\""; return stream.str(); } @@ -708,6 +818,22 @@ bool MEDCouplingNoTimeLabel::areStrictlyCompatibleForMul(const MEDCouplingTimeDi return otherC!=0; } +bool MEDCouplingNoTimeLabel::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const +{ + if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other)) + return false; + const MEDCouplingNoTimeLabel *otherC=dynamic_cast(other); + return otherC!=0; +} + +bool MEDCouplingNoTimeLabel::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const +{ + if(!MEDCouplingTimeDiscretization::areCompatibleForMeld(other)) + return false; + const MEDCouplingNoTimeLabel *otherC=dynamic_cast(other); + return otherC!=0; +} + bool MEDCouplingNoTimeLabel::isEqual(const MEDCouplingTimeDiscretization *other, double prec) const { const MEDCouplingNoTimeLabel *otherC=dynamic_cast(other); @@ -729,7 +855,37 @@ MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::aggregate(const MEDCoupli const MEDCouplingNoTimeLabel *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("NoTimeLabel::aggregation on mismatched time discretization !"); - DataArrayDouble *arr=DataArrayDouble::aggregate(getArray(),other->getArray()); + DataArrayDouble *arr=DataArrayDouble::Aggregate(getArray(),other->getArray()); + MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel; + ret->setArray(arr,0); + arr->decrRef(); + return ret; +} + +MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::aggregate(const std::vector& other) const +{ + std::vector a(other.size()); + int i=0; + for(std::vector::const_iterator it=other.begin();it!=other.end();it++,i++) + { + const MEDCouplingNoTimeLabel *itC=dynamic_cast(*it); + if(!itC) + throw INTERP_KERNEL::Exception("NoTimeLabel::aggregate on mismatched time discretization !"); + a[i]=itC->getArray(); + } + DataArrayDouble *arr=DataArrayDouble::Aggregate(a); + MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel; + ret->setArray(arr,0); + arr->decrRef(); + return ret; +} + +MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::meld(const MEDCouplingTimeDiscretization *other) const +{ + const MEDCouplingNoTimeLabel *otherC=dynamic_cast(other); + if(!otherC) + throw INTERP_KERNEL::Exception("NoTimeLabel::meld on mismatched time discretization !"); + DataArrayDouble *arr=DataArrayDouble::Meld(getArray(),other->getArray()); MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel; ret->setTimeTolerance(getTimeTolerance()); ret->setArray(arr,0); @@ -742,7 +898,7 @@ MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::dot(const MEDCouplingTime const MEDCouplingNoTimeLabel *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("NoTimeLabel::dot on mismatched time discretization !"); - DataArrayDouble *arr=DataArrayDouble::dot(getArray(),other->getArray()); + DataArrayDouble *arr=DataArrayDouble::Dot(getArray(),other->getArray()); MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel; ret->setArray(arr,0); arr->decrRef(); @@ -754,7 +910,7 @@ MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::crossProduct(const MEDCou const MEDCouplingNoTimeLabel *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("NoTimeLabel::crossProduct on mismatched time discretization !"); - DataArrayDouble *arr=DataArrayDouble::crossProduct(getArray(),other->getArray()); + DataArrayDouble *arr=DataArrayDouble::CrossProduct(getArray(),other->getArray()); MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel; ret->setArray(arr,0); arr->decrRef(); @@ -766,7 +922,7 @@ MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::max(const MEDCouplingTime const MEDCouplingNoTimeLabel *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("NoTimeLabel::max on mismatched time discretization !"); - DataArrayDouble *arr=DataArrayDouble::max(getArray(),other->getArray()); + DataArrayDouble *arr=DataArrayDouble::Max(getArray(),other->getArray()); MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel; ret->setArray(arr,0); arr->decrRef(); @@ -778,7 +934,7 @@ MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::min(const MEDCouplingTime const MEDCouplingNoTimeLabel *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("NoTimeLabel::max on mismatched time discretization !"); - DataArrayDouble *arr=DataArrayDouble::min(getArray(),other->getArray()); + DataArrayDouble *arr=DataArrayDouble::Min(getArray(),other->getArray()); MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel; ret->setArray(arr,0); arr->decrRef(); @@ -790,7 +946,7 @@ MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::add(const MEDCouplingTime const MEDCouplingNoTimeLabel *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("NoTimeLabel::add on mismatched time discretization !"); - DataArrayDouble *arr=DataArrayDouble::add(getArray(),other->getArray()); + DataArrayDouble *arr=DataArrayDouble::Add(getArray(),other->getArray()); MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel; ret->setArray(arr,0); arr->decrRef(); @@ -810,7 +966,7 @@ MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::substract(const MEDCoupli const MEDCouplingNoTimeLabel *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("NoTimeLabel::substract on mismatched time discretization !"); - DataArrayDouble *arr=DataArrayDouble::substract(getArray(),other->getArray()); + DataArrayDouble *arr=DataArrayDouble::Substract(getArray(),other->getArray()); MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel; ret->setArray(arr,0); arr->decrRef(); @@ -830,7 +986,7 @@ MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::multiply(const MEDCouplin const MEDCouplingNoTimeLabel *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("NoTimeLabel::multiply on mismatched time discretization !"); - DataArrayDouble *arr=DataArrayDouble::multiply(getArray(),other->getArray()); + DataArrayDouble *arr=DataArrayDouble::Multiply(getArray(),other->getArray()); MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel; ret->setArray(arr,0); arr->decrRef(); @@ -850,7 +1006,7 @@ MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::divide(const MEDCouplingT const MEDCouplingNoTimeLabel *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("divide on mismatched time discretization !"); - DataArrayDouble *arr=DataArrayDouble::divide(getArray(),other->getArray()); + DataArrayDouble *arr=DataArrayDouble::Divide(getArray(),other->getArray()); MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel; ret->setArray(arr,0); arr->decrRef(); @@ -905,6 +1061,36 @@ double MEDCouplingNoTimeLabel::getEndTime(int& iteration, int& order) const thro throw INTERP_KERNEL::Exception(EXCEPTION_MSG); } +void MEDCouplingNoTimeLabel::setStartIteration(int it) throw(INTERP_KERNEL::Exception) +{ + throw INTERP_KERNEL::Exception(EXCEPTION_MSG); +} + +void MEDCouplingNoTimeLabel::setEndIteration(int it) throw(INTERP_KERNEL::Exception) +{ + throw INTERP_KERNEL::Exception(EXCEPTION_MSG); +} + +void MEDCouplingNoTimeLabel::setStartOrder(int order) throw(INTERP_KERNEL::Exception) +{ + throw INTERP_KERNEL::Exception(EXCEPTION_MSG); +} + +void MEDCouplingNoTimeLabel::setEndOrder(int order) throw(INTERP_KERNEL::Exception) +{ + throw INTERP_KERNEL::Exception(EXCEPTION_MSG); +} + +void MEDCouplingNoTimeLabel::setStartTimeValue(double time) throw(INTERP_KERNEL::Exception) +{ + throw INTERP_KERNEL::Exception(EXCEPTION_MSG); +} + +void MEDCouplingNoTimeLabel::setEndTimeValue(double time) throw(INTERP_KERNEL::Exception) +{ + throw INTERP_KERNEL::Exception(EXCEPTION_MSG); +} + void MEDCouplingNoTimeLabel::setStartTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) { throw INTERP_KERNEL::Exception(EXCEPTION_MSG); @@ -925,6 +1111,31 @@ void MEDCouplingNoTimeLabel::getValueOnDiscTime(int eltId, int iteration, int or throw INTERP_KERNEL::Exception(EXCEPTION_MSG); } +/*! + * idem getTinySerializationIntInformation except that it is for multi field fetch + */ +void MEDCouplingNoTimeLabel::getTinySerializationIntInformation2(std::vector& tinyInfo) const +{ + tinyInfo.clear(); +} + +/*! + * idem getTinySerializationDbleInformation except that it is for multi field fetch + */ +void MEDCouplingNoTimeLabel::getTinySerializationDbleInformation2(std::vector& tinyInfo) const +{ + tinyInfo.resize(1); + tinyInfo[0]=_time_tolerance; +} + +/*! + * idem finishUnserialization except that it is for multi field fetch + */ +void MEDCouplingNoTimeLabel::finishUnserialization2(const std::vector& tinyInfoI, const std::vector& tinyInfoD) +{ + _time_tolerance=tinyInfoD[0]; +} + MEDCouplingWithTimeStep::MEDCouplingWithTimeStep(const MEDCouplingWithTimeStep& other, bool deepCpy):MEDCouplingTimeDiscretization(other,deepCpy), _time(other._time),_iteration(other._iteration),_order(other._order) { @@ -938,6 +1149,7 @@ std::string MEDCouplingWithTimeStep::getStringRepr() const { std::ostringstream stream; stream << REPR << " Time is defined by iteration=" << _iteration << " order=" << _order << " and time=" << _time << "."; + stream << "\nTime unit is : \"" << _time_unit << "\""; return stream.str(); } @@ -962,6 +1174,37 @@ void MEDCouplingWithTimeStep::finishUnserialization(const std::vector& tiny _order=tinyInfoI[3]; } +/*! + * idem getTinySerializationIntInformation except that it is for multi field fetch + */ +void MEDCouplingWithTimeStep::getTinySerializationIntInformation2(std::vector& tinyInfo) const +{ + tinyInfo.resize(2); + tinyInfo[0]=_iteration; + tinyInfo[1]=_order; +} + +/*! + * idem getTinySerializationDbleInformation except that it is for multi field fetch + */ +void MEDCouplingWithTimeStep::getTinySerializationDbleInformation2(std::vector& tinyInfo) const +{ + tinyInfo.resize(2); + tinyInfo[0]=_time_tolerance; + tinyInfo[1]=_time; +} + +/*! + * idem finishUnserialization except that it is for multi field fetch + */ +void MEDCouplingWithTimeStep::finishUnserialization2(const std::vector& tinyInfoI, const std::vector& tinyInfoD) +{ + _iteration=tinyInfoI[0]; + _order=tinyInfoI[1]; + _time_tolerance=tinyInfoD[0]; + _time=tinyInfoD[1]; +} + bool MEDCouplingWithTimeStep::areCompatible(const MEDCouplingTimeDiscretization *other) const { if(!MEDCouplingTimeDiscretization::areCompatible(other)) @@ -986,6 +1229,22 @@ bool MEDCouplingWithTimeStep::areStrictlyCompatibleForMul(const MEDCouplingTimeD return otherC!=0; } +bool MEDCouplingWithTimeStep::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const +{ + if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other)) + return false; + const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); + return otherC!=0; +} + +bool MEDCouplingWithTimeStep::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const +{ + if(!MEDCouplingTimeDiscretization::areCompatibleForMeld(other)) + return false; + const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); + return otherC!=0; +} + bool MEDCouplingWithTimeStep::isEqual(const MEDCouplingTimeDiscretization *other, double prec) const { const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); @@ -1028,14 +1287,40 @@ MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::aggregate(const MEDCoupl const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("WithTimeStep::aggregation on mismatched time discretization !"); - DataArrayDouble *arr=DataArrayDouble::aggregate(getArray(),other->getArray()); + DataArrayDouble *arr=DataArrayDouble::Aggregate(getArray(),other->getArray()); + MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep; + ret->setArray(arr,0); + arr->decrRef(); + return ret; +} + +MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::aggregate(const std::vector& other) const +{ + std::vector a(other.size()); + int i=0; + for(std::vector::const_iterator it=other.begin();it!=other.end();it++,i++) + { + const MEDCouplingWithTimeStep *itC=dynamic_cast(*it); + if(!itC) + throw INTERP_KERNEL::Exception("WithTimeStep::aggregate on mismatched time discretization !"); + a[i]=itC->getArray(); + } + DataArrayDouble *arr=DataArrayDouble::Aggregate(a); + MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep; + ret->setArray(arr,0); + arr->decrRef(); + return ret; +} + +MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::meld(const MEDCouplingTimeDiscretization *other) const +{ + const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); + if(!otherC) + throw INTERP_KERNEL::Exception("WithTimeStep::meld on mismatched time discretization !"); + DataArrayDouble *arr=DataArrayDouble::Meld(getArray(),other->getArray()); MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep; - ret->setTimeTolerance(getTimeTolerance()); ret->setArray(arr,0); arr->decrRef(); - int tmp1,tmp2; - double tmp3=getStartTime(tmp1,tmp2); - ret->setStartTime(tmp3,tmp1,tmp2); return ret; } @@ -1045,7 +1330,7 @@ MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::dot(const MEDCouplingTim if(!otherC) throw INTERP_KERNEL::Exception("WithTimeStep::dot on mismatched time discretization !"); MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep; - DataArrayDouble *arr=DataArrayDouble::dot(getArray(),other->getArray()); + DataArrayDouble *arr=DataArrayDouble::Dot(getArray(),other->getArray()); ret->setArray(arr,0); arr->decrRef(); return ret; @@ -1056,7 +1341,7 @@ MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::crossProduct(const MEDCo const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("WithTimeStep::crossProduct on mismatched time discretization !"); - DataArrayDouble *arr=DataArrayDouble::crossProduct(getArray(),other->getArray()); + DataArrayDouble *arr=DataArrayDouble::CrossProduct(getArray(),other->getArray()); MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep; ret->setArray(arr,0); arr->decrRef(); @@ -1068,7 +1353,7 @@ MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::max(const MEDCouplingTim const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("WithTimeStep::max on mismatched time discretization !"); - DataArrayDouble *arr=DataArrayDouble::max(getArray(),other->getArray()); + DataArrayDouble *arr=DataArrayDouble::Max(getArray(),other->getArray()); MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep; ret->setArray(arr,0); arr->decrRef(); @@ -1080,7 +1365,7 @@ MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::min(const MEDCouplingTim const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("WithTimeStep::min on mismatched time discretization !"); - DataArrayDouble *arr=DataArrayDouble::min(getArray(),other->getArray()); + DataArrayDouble *arr=DataArrayDouble::Min(getArray(),other->getArray()); MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep; ret->setArray(arr,0); arr->decrRef(); @@ -1092,7 +1377,7 @@ MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::add(const MEDCouplingTim const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("WithTimeStep::add on mismatched time discretization !"); - DataArrayDouble *arr=DataArrayDouble::add(getArray(),other->getArray()); + DataArrayDouble *arr=DataArrayDouble::Add(getArray(),other->getArray()); MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep; ret->setArray(arr,0); arr->decrRef(); @@ -1115,7 +1400,7 @@ MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::substract(const MEDCoupl const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("WithTimeStep::substract on mismatched time discretization !"); - DataArrayDouble *arr=DataArrayDouble::substract(getArray(),other->getArray()); + DataArrayDouble *arr=DataArrayDouble::Substract(getArray(),other->getArray()); MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep; ret->setArray(arr,0); arr->decrRef(); @@ -1138,7 +1423,7 @@ MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::multiply(const MEDCoupli const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("WithTimeStep::multiply on mismatched time discretization !"); - DataArrayDouble *arr=DataArrayDouble::multiply(getArray(),other->getArray()); + DataArrayDouble *arr=DataArrayDouble::Multiply(getArray(),other->getArray()); MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep; ret->setArray(arr,0); arr->decrRef(); @@ -1161,7 +1446,7 @@ MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::divide(const MEDCoupling const MEDCouplingWithTimeStep *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("WithTimeStep::divide on mismatched time discretization !"); - DataArrayDouble *arr=DataArrayDouble::divide(getArray(),other->getArray()); + DataArrayDouble *arr=DataArrayDouble::Divide(getArray(),other->getArray()); MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep; ret->setArray(arr,0); arr->decrRef(); @@ -1281,6 +1566,43 @@ void MEDCouplingConstOnTimeInterval::finishUnserialization(const std::vector& tinyInfo) const +{ + tinyInfo.resize(4); + tinyInfo[0]=_start_iteration; + tinyInfo[1]=_start_order; + tinyInfo[2]=_end_iteration; + tinyInfo[3]=_end_order; +} + +/*! + * idem getTinySerializationDbleInformation except that it is for multi field fetch + */ +void MEDCouplingConstOnTimeInterval::getTinySerializationDbleInformation2(std::vector& tinyInfo) const +{ + tinyInfo.resize(3); + tinyInfo[0]=_time_tolerance; + tinyInfo[1]=_start_time; + tinyInfo[2]=_end_time; +} + +/*! + * idem finishUnserialization except that it is for multi field fetch + */ +void MEDCouplingConstOnTimeInterval::finishUnserialization2(const std::vector& tinyInfoI, const std::vector& tinyInfoD) +{ + _start_iteration=tinyInfoI[0]; + _start_order=tinyInfoI[1]; + _end_iteration=tinyInfoI[2]; + _end_order=tinyInfoI[3]; + _time_tolerance=tinyInfoD[0]; + _start_time=tinyInfoD[1]; + _end_time=tinyInfoD[2]; +} + MEDCouplingConstOnTimeInterval::MEDCouplingConstOnTimeInterval(const MEDCouplingConstOnTimeInterval& other, bool deepCpy): MEDCouplingTimeDiscretization(other,deepCpy),_start_time(other._start_time),_end_time(other._end_time),_start_iteration(other._start_iteration), _end_iteration(other._end_iteration),_start_order(other._start_order),_end_order(other._end_order) @@ -1292,6 +1614,7 @@ std::string MEDCouplingConstOnTimeInterval::getStringRepr() const std::ostringstream stream; stream << REPR << " Time interval is defined by :\niteration_start=" << _start_iteration << " order_start=" << _start_order << " and time_start=" << _start_time << "\n"; stream << "iteration_end=" << _end_iteration << " order_end=" << _end_order << " and end_time=" << _end_time << "\n"; + stream << "\nTime unit is : \"" << _time_unit << "\""; return stream.str(); } @@ -1335,7 +1658,23 @@ bool MEDCouplingConstOnTimeInterval::areStrictlyCompatible(const MEDCouplingTime bool MEDCouplingConstOnTimeInterval::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const { - if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other)) + if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(other)) + return false; + const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); + return otherC!=0; +} + +bool MEDCouplingConstOnTimeInterval::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const +{ + if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other)) + return false; + const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); + return otherC!=0; +} + +bool MEDCouplingConstOnTimeInterval::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const +{ + if(!MEDCouplingTimeDiscretization::areCompatibleForMeld(other)) return false; const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); return otherC!=0; @@ -1421,19 +1760,44 @@ void MEDCouplingConstOnTimeInterval::checkTimePresence(double time) const throw( MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::aggregate(const MEDCouplingTimeDiscretization *other) const { - const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); + const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("ConstOnTimeInterval::aggregation on mismatched time discretization !"); - DataArrayDouble *arr=DataArrayDouble::aggregate(getArray(),other->getArray()); + DataArrayDouble *arr=DataArrayDouble::Aggregate(getArray(),other->getArray()); + MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval; + ret->setArray(arr,0); + arr->decrRef(); + return ret; +} + +MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::aggregate(const std::vector& other) const +{ + std::vector a(other.size()); + int i=0; + for(std::vector::const_iterator it=other.begin();it!=other.end();it++,i++) + { + const MEDCouplingConstOnTimeInterval *itC=dynamic_cast(*it); + if(!itC) + throw INTERP_KERNEL::Exception("ConstOnTimeInterval::aggregate on mismatched time discretization !"); + a[i]=itC->getArray(); + } + DataArrayDouble *arr=DataArrayDouble::Aggregate(a); + MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval; + ret->setArray(arr,0); + arr->decrRef(); + return ret; +} + +MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::meld(const MEDCouplingTimeDiscretization *other) const +{ + const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); + if(!otherC) + throw INTERP_KERNEL::Exception("ConstOnTimeInterval::meld on mismatched time discretization !"); + DataArrayDouble *arr=DataArrayDouble::Meld(getArray(),other->getArray()); MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval; ret->setTimeTolerance(getTimeTolerance()); ret->setArray(arr,0); arr->decrRef(); - int tmp1,tmp2; - double tmp3=getStartTime(tmp1,tmp2); - ret->setStartTime(tmp3,tmp1,tmp2); - tmp3=getEndTime(tmp1,tmp2); - ret->setEndTime(tmp3,tmp1,tmp2); return ret; } @@ -1442,7 +1806,7 @@ MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::dot(const MEDCoup const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("ConstOnTimeInterval::dot on mismatched time discretization !"); - DataArrayDouble *arr=DataArrayDouble::dot(getArray(),other->getArray()); + DataArrayDouble *arr=DataArrayDouble::Dot(getArray(),other->getArray()); MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval; ret->setArray(arr,0); arr->decrRef(); @@ -1454,7 +1818,7 @@ MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::crossProduct(cons const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("ConstOnTimeInterval::crossProduct on mismatched time discretization !"); - DataArrayDouble *arr=DataArrayDouble::crossProduct(getArray(),other->getArray()); + DataArrayDouble *arr=DataArrayDouble::CrossProduct(getArray(),other->getArray()); MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval; ret->setArray(arr,0); arr->decrRef(); @@ -1466,7 +1830,7 @@ MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::max(const MEDCoup const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("ConstOnTimeInterval::max on mismatched time discretization !"); - DataArrayDouble *arr=DataArrayDouble::max(getArray(),other->getArray()); + DataArrayDouble *arr=DataArrayDouble::Max(getArray(),other->getArray()); MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval; ret->setArray(arr,0); arr->decrRef(); @@ -1478,7 +1842,7 @@ MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::min(const MEDCoup const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("ConstOnTimeInterval::min on mismatched time discretization !"); - DataArrayDouble *arr=DataArrayDouble::min(getArray(),other->getArray()); + DataArrayDouble *arr=DataArrayDouble::Min(getArray(),other->getArray()); MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval; ret->setArray(arr,0); arr->decrRef(); @@ -1490,7 +1854,7 @@ MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::add(const MEDCoup const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("ConstOnTimeInterval::add on mismatched time discretization !"); - DataArrayDouble *arr=DataArrayDouble::add(getArray(),other->getArray()); + DataArrayDouble *arr=DataArrayDouble::Add(getArray(),other->getArray()); MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval; ret->setArray(arr,0); arr->decrRef(); @@ -1515,7 +1879,7 @@ MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::substract(const M const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("ConstOnTimeInterval::substract on mismatched time discretization !"); - DataArrayDouble *arr=DataArrayDouble::substract(getArray(),other->getArray()); + DataArrayDouble *arr=DataArrayDouble::Substract(getArray(),other->getArray()); MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval; ret->setArray(arr,0); arr->decrRef(); @@ -1540,7 +1904,7 @@ MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::multiply(const ME const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("multiply on mismatched time discretization !"); - DataArrayDouble *arr=DataArrayDouble::multiply(getArray(),other->getArray()); + DataArrayDouble *arr=DataArrayDouble::Multiply(getArray(),other->getArray()); MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval; ret->setArray(arr,0); arr->decrRef(); @@ -1565,7 +1929,7 @@ MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::divide(const MEDC const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("divide on mismatched time discretization !"); - DataArrayDouble *arr=DataArrayDouble::divide(getArray(),other->getArray()); + DataArrayDouble *arr=DataArrayDouble::Divide(getArray(),other->getArray()); MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval; ret->setArray(arr,0); arr->decrRef(); @@ -1596,7 +1960,7 @@ MEDCouplingTwoTimeSteps::MEDCouplingTwoTimeSteps(const MEDCouplingTwoTimeSteps& _end_array=0; } -void MEDCouplingTwoTimeSteps::updateTime() +void MEDCouplingTwoTimeSteps::updateTime() const { MEDCouplingTimeDiscretization::updateTime(); if(_end_array) @@ -1625,7 +1989,12 @@ void MEDCouplingTwoTimeSteps::copyTinyStringsFrom(const MEDCouplingTimeDiscretiz _end_array->copyStringInfoFrom(*otherC->_end_array); } -DataArrayDouble *MEDCouplingTwoTimeSteps::getEndArray() const +const DataArrayDouble *MEDCouplingTwoTimeSteps::getEndArray() const +{ + return _end_array; +} + +DataArrayDouble *MEDCouplingTwoTimeSteps::getEndArray() { return _end_array; } @@ -1805,6 +2174,43 @@ void MEDCouplingTwoTimeSteps::finishUnserialization(const std::vector& tiny _end_order=tinyInfoI[5]; } +/*! + * idem getTinySerializationIntInformation except that it is for multi field fetch + */ +void MEDCouplingTwoTimeSteps::getTinySerializationIntInformation2(std::vector& tinyInfo) const +{ + tinyInfo.resize(4); + tinyInfo[0]=_start_iteration; + tinyInfo[1]=_start_order; + tinyInfo[2]=_end_iteration; + tinyInfo[3]=_end_order; +} + +/*! + * idem getTinySerializationDbleInformation except that it is for multi field fetch + */ +void MEDCouplingTwoTimeSteps::getTinySerializationDbleInformation2(std::vector& tinyInfo) const +{ + tinyInfo.resize(3); + tinyInfo[0]=_time_tolerance; + tinyInfo[1]=_start_time; + tinyInfo[2]=_end_time; +} + +/*! + * idem finishUnserialization except that it is for multi field fetch + */ +void MEDCouplingTwoTimeSteps::finishUnserialization2(const std::vector& tinyInfoI, const std::vector& tinyInfoD) +{ + _start_iteration=tinyInfoI[0]; + _start_order=tinyInfoI[1]; + _end_iteration=tinyInfoI[2]; + _end_order=tinyInfoI[3]; + _time_tolerance=tinyInfoD[0]; + _start_time=tinyInfoD[1]; + _end_time=tinyInfoD[2]; +} + std::vector< const DataArrayDouble *> MEDCouplingTwoTimeSteps::getArraysForTime(double time) const throw(INTERP_KERNEL::Exception) { if(time>_start_time-_time_tolerance && time<_end_time+_time_tolerance) @@ -1839,6 +2245,7 @@ std::string MEDCouplingLinearTime::getStringRepr() const std::ostringstream stream; stream << REPR << " Time interval is defined by :\niteration_start=" << _start_iteration << " order_start=" << _start_order << " and time_start=" << _start_time << "\n"; stream << "iteration_end=" << _end_iteration << " order_end=" << _end_order << " and end_time=" << _end_time << "\n"; + stream << "Time unit is : \"" << _time_unit << "\""; return stream.str(); } @@ -1859,7 +2266,15 @@ bool MEDCouplingLinearTime::areCompatible(const MEDCouplingTimeDiscretization *o if(!MEDCouplingTimeDiscretization::areCompatible(other)) return false; const MEDCouplingLinearTime *otherC=dynamic_cast(other); - return otherC!=0; + if(otherC==0) + return false; + if(_end_array==0 && otherC->_end_array==0) + return true; + if(_end_array==0 || otherC->_end_array==0) + return false; + if(_end_array->getNumberOfComponents()!=otherC->_end_array->getNumberOfComponents()) + return false; + return true; } bool MEDCouplingLinearTime::areStrictlyCompatible(const MEDCouplingTimeDiscretization *other) const @@ -1878,6 +2293,32 @@ bool MEDCouplingLinearTime::areStrictlyCompatibleForMul(const MEDCouplingTimeDis return otherC!=0; } +bool MEDCouplingLinearTime::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const +{ + if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other)) + return false; + const MEDCouplingLinearTime *otherC=dynamic_cast(other); + if(otherC==0) + return false; + if(_end_array==0 && otherC->_end_array==0) + return true; + if(_end_array==0 || otherC->_end_array==0) + return false; + int nbC1=_end_array->getNumberOfComponents(); + int nbC2=otherC->_end_array->getNumberOfComponents(); + if(nbC1!=nbC2 && nbC2!=1) + return false; + return true; +} + +bool MEDCouplingLinearTime::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const +{ + if(!MEDCouplingTimeDiscretization::areCompatibleForMeld(other)) + return false; + const MEDCouplingLinearTime *otherC=dynamic_cast(other); + return otherC!=0; +} + /*! * vals is expected to be of size 2*_array->getNumberOfTuples()==_array->getNumberOfTuples()+_end_array->getNumberOfTuples() */ @@ -1935,8 +2376,46 @@ MEDCouplingTimeDiscretization *MEDCouplingLinearTime::aggregate(const MEDCouplin const MEDCouplingLinearTime *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("LinearTime::aggregation on mismatched time discretization !"); - DataArrayDouble *arr1=DataArrayDouble::aggregate(getArray(),other->getArray()); - DataArrayDouble *arr2=DataArrayDouble::aggregate(getEndArray(),other->getEndArray()); + DataArrayDouble *arr1=DataArrayDouble::Aggregate(getArray(),other->getArray()); + DataArrayDouble *arr2=DataArrayDouble::Aggregate(getEndArray(),other->getEndArray()); + MEDCouplingLinearTime *ret=new MEDCouplingLinearTime; + ret->setArray(arr1,0); + arr1->decrRef(); + ret->setEndArray(arr2,0); + arr2->decrRef(); + return ret; +} + +MEDCouplingTimeDiscretization *MEDCouplingLinearTime::aggregate(const std::vector& other) const +{ + 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++) + { + const MEDCouplingLinearTime *itC=dynamic_cast(*it); + if(!itC) + throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::aggregate on mismatched time discretization !"); + a[i]=itC->getArray(); + b[i]=itC->getEndArray(); + } + DataArrayDouble *arr=DataArrayDouble::Aggregate(a); + DataArrayDouble *arr2=DataArrayDouble::Aggregate(b); + MEDCouplingLinearTime *ret=new MEDCouplingLinearTime; + ret->setArray(arr,0); + arr->decrRef(); + ret->setEndArray(arr2,0); + arr2->decrRef(); + return ret; +} + +MEDCouplingTimeDiscretization *MEDCouplingLinearTime::meld(const MEDCouplingTimeDiscretization *other) const +{ + const MEDCouplingLinearTime *otherC=dynamic_cast(other); + if(!otherC) + throw INTERP_KERNEL::Exception("LinearTime::meld on mismatched time discretization !"); + DataArrayDouble *arr1=DataArrayDouble::Meld(getArray(),other->getArray()); + DataArrayDouble *arr2=DataArrayDouble::Meld(getEndArray(),other->getEndArray()); MEDCouplingLinearTime *ret=new MEDCouplingLinearTime; ret->setTimeTolerance(getTimeTolerance()); ret->setArray(arr1,0); @@ -1951,8 +2430,8 @@ MEDCouplingTimeDiscretization *MEDCouplingLinearTime::dot(const MEDCouplingTimeD const MEDCouplingLinearTime *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("LinearTime::dot on mismatched time discretization !"); - DataArrayDouble *arr1=DataArrayDouble::dot(getArray(),other->getArray()); - DataArrayDouble *arr2=DataArrayDouble::dot(getEndArray(),other->getEndArray()); + DataArrayDouble *arr1=DataArrayDouble::Dot(getArray(),other->getArray()); + DataArrayDouble *arr2=DataArrayDouble::Dot(getEndArray(),other->getEndArray()); MEDCouplingLinearTime *ret=new MEDCouplingLinearTime; ret->setArray(arr1,0); arr1->decrRef(); @@ -1966,8 +2445,8 @@ MEDCouplingTimeDiscretization *MEDCouplingLinearTime::crossProduct(const MEDCoup const MEDCouplingLinearTime *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("LinearTime::crossProduct on mismatched time discretization !"); - DataArrayDouble *arr1=DataArrayDouble::crossProduct(getArray(),other->getArray()); - DataArrayDouble *arr2=DataArrayDouble::crossProduct(getEndArray(),other->getEndArray()); + DataArrayDouble *arr1=DataArrayDouble::CrossProduct(getArray(),other->getArray()); + DataArrayDouble *arr2=DataArrayDouble::CrossProduct(getEndArray(),other->getEndArray()); MEDCouplingLinearTime *ret=new MEDCouplingLinearTime; ret->setArray(arr1,0); arr1->decrRef(); @@ -1982,10 +2461,10 @@ MEDCouplingTimeDiscretization *MEDCouplingLinearTime::max(const MEDCouplingTimeD if(!otherC) throw INTERP_KERNEL::Exception("LinearTime::max on mismatched time discretization !"); MEDCouplingLinearTime *ret=new MEDCouplingLinearTime; - DataArrayDouble *arr1=DataArrayDouble::max(getArray(),other->getArray()); + DataArrayDouble *arr1=DataArrayDouble::Max(getArray(),other->getArray()); ret->setArray(arr1,0); arr1->decrRef(); - DataArrayDouble *arr2=DataArrayDouble::max(getEndArray(),other->getEndArray()); + DataArrayDouble *arr2=DataArrayDouble::Max(getEndArray(),other->getEndArray()); ret->setEndArray(arr2,0); arr2->decrRef(); return ret; @@ -1996,8 +2475,8 @@ MEDCouplingTimeDiscretization *MEDCouplingLinearTime::min(const MEDCouplingTimeD const MEDCouplingLinearTime *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("LinearTime::min on mismatched time discretization !"); - DataArrayDouble *arr1=DataArrayDouble::min(getArray(),other->getArray()); - DataArrayDouble *arr2=DataArrayDouble::min(getEndArray(),other->getEndArray()); + DataArrayDouble *arr1=DataArrayDouble::Min(getArray(),other->getArray()); + DataArrayDouble *arr2=DataArrayDouble::Min(getEndArray(),other->getEndArray()); MEDCouplingLinearTime *ret=new MEDCouplingLinearTime; ret->setArray(arr1,0); arr1->decrRef(); @@ -2011,8 +2490,8 @@ MEDCouplingTimeDiscretization *MEDCouplingLinearTime::add(const MEDCouplingTimeD const MEDCouplingLinearTime *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("LinearTime::add on mismatched time discretization !"); - DataArrayDouble *arr1=DataArrayDouble::add(getArray(),other->getArray()); - DataArrayDouble *arr2=DataArrayDouble::add(getEndArray(),other->getEndArray()); + DataArrayDouble *arr1=DataArrayDouble::Add(getArray(),other->getArray()); + DataArrayDouble *arr2=DataArrayDouble::Add(getEndArray(),other->getEndArray()); MEDCouplingLinearTime *ret=new MEDCouplingLinearTime; ret->setArray(arr1,0); arr1->decrRef(); @@ -2035,8 +2514,8 @@ MEDCouplingTimeDiscretization *MEDCouplingLinearTime::substract(const MEDCouplin const MEDCouplingLinearTime *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("LinearTime::substract on mismatched time discretization !"); - DataArrayDouble *arr1=DataArrayDouble::substract(getArray(),other->getArray()); - DataArrayDouble *arr2=DataArrayDouble::substract(getEndArray(),other->getEndArray()); + DataArrayDouble *arr1=DataArrayDouble::Substract(getArray(),other->getArray()); + DataArrayDouble *arr2=DataArrayDouble::Substract(getEndArray(),other->getEndArray()); MEDCouplingLinearTime *ret=new MEDCouplingLinearTime; ret->setArray(arr1,0); arr1->decrRef(); @@ -2059,8 +2538,8 @@ MEDCouplingTimeDiscretization *MEDCouplingLinearTime::multiply(const MEDCoupling const MEDCouplingLinearTime *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("LinearTime::multiply on mismatched time discretization !"); - DataArrayDouble *arr1=DataArrayDouble::multiply(getArray(),other->getArray()); - DataArrayDouble *arr2=DataArrayDouble::multiply(getEndArray(),other->getEndArray()); + DataArrayDouble *arr1=DataArrayDouble::Multiply(getArray(),other->getArray()); + DataArrayDouble *arr2=DataArrayDouble::Multiply(getEndArray(),other->getEndArray()); MEDCouplingLinearTime *ret=new MEDCouplingLinearTime; ret->setArray(arr1,0); arr1->decrRef(); @@ -2083,8 +2562,8 @@ MEDCouplingTimeDiscretization *MEDCouplingLinearTime::divide(const MEDCouplingTi const MEDCouplingLinearTime *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("LinearTime::divide on mismatched time discretization !"); - DataArrayDouble *arr1=DataArrayDouble::divide(getArray(),other->getArray()); - DataArrayDouble *arr2=DataArrayDouble::divide(getEndArray(),other->getEndArray()); + DataArrayDouble *arr1=DataArrayDouble::Divide(getArray(),other->getArray()); + DataArrayDouble *arr2=DataArrayDouble::Divide(getEndArray(),other->getEndArray()); MEDCouplingLinearTime *ret=new MEDCouplingLinearTime; ret->setArray(arr1,0); arr1->decrRef(); diff --git a/src/MEDCoupling/MEDCouplingTimeDiscretization.hxx b/src/MEDCoupling/MEDCouplingTimeDiscretization.hxx index e826e12ce..79a5bf04a 100644 --- a/src/MEDCoupling/MEDCouplingTimeDiscretization.hxx +++ b/src/MEDCoupling/MEDCouplingTimeDiscretization.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __PARAMEDMEM_MEDCOUPLINGTIMEDISCRETIZATION_HXX__ @@ -38,21 +38,26 @@ namespace ParaMEDMEM MEDCouplingTimeDiscretization(); MEDCouplingTimeDiscretization(const MEDCouplingTimeDiscretization& other, bool deepCpy); public: - void updateTime(); + void updateTime() const; static MEDCouplingTimeDiscretization *New(TypeOfTimeDiscretization type); + void setTimeUnit(const char *unit) { _time_unit=unit; } + const char *getTimeUnit() const { return _time_unit.c_str(); } virtual void copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other); virtual void copyTinyStringsFrom(const MEDCouplingTimeDiscretization& other); virtual void checkCoherency() const throw(INTERP_KERNEL::Exception); virtual bool areCompatible(const MEDCouplingTimeDiscretization *other) const; virtual bool areStrictlyCompatible(const MEDCouplingTimeDiscretization *other) const; virtual bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const; + virtual bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const; + virtual bool areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const; virtual bool isEqual(const MEDCouplingTimeDiscretization *other, double prec) const; virtual bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const; - virtual MEDCouplingTimeDiscretization *buildNewTimeReprFromThis(const MEDCouplingTimeDiscretization *other, - TypeOfTimeDiscretization type, bool deepCpy) const; + virtual MEDCouplingTimeDiscretization *buildNewTimeReprFromThis(TypeOfTimeDiscretization type, bool deepCpy) const; virtual std::string getStringRepr() const = 0; virtual TypeOfTimeDiscretization getEnum() const = 0; virtual MEDCouplingTimeDiscretization *aggregate(const MEDCouplingTimeDiscretization *other) const = 0; + virtual MEDCouplingTimeDiscretization *aggregate(const std::vector& other) const = 0; + virtual MEDCouplingTimeDiscretization *meld(const MEDCouplingTimeDiscretization *other) const = 0; virtual MEDCouplingTimeDiscretization *dot(const MEDCouplingTimeDiscretization *other) const = 0; virtual MEDCouplingTimeDiscretization *crossProduct(const MEDCouplingTimeDiscretization *other) const = 0; virtual MEDCouplingTimeDiscretization *max(const MEDCouplingTimeDiscretization *other) const = 0; @@ -70,6 +75,9 @@ namespace ParaMEDMEM virtual void getTinySerializationStrInformation(std::vector& tinyInfo) const; virtual void resizeForUnserialization(const std::vector& tinyInfoI, std::vector& arrays); virtual void finishUnserialization(const std::vector& tinyInfoI, const std::vector& tinyInfoD, const std::vector& tinyInfoS); + virtual void getTinySerializationIntInformation2(std::vector& tinyInfo) const = 0; + virtual void getTinySerializationDbleInformation2(std::vector& tinyInfo) const = 0; + virtual void finishUnserialization2(const std::vector& tinyInfoI, const std::vector& tinyInfoD) = 0; virtual MEDCouplingTimeDiscretization *performCpy(bool deepCpy) const = 0; void setTimeTolerance(double val) { _time_tolerance=val; } double getTimeTolerance() const { return _time_tolerance; } @@ -78,8 +86,10 @@ namespace ParaMEDMEM virtual void setArray(DataArrayDouble *array, TimeLabel *owner); virtual void setEndArray(DataArrayDouble *array, TimeLabel *owner); virtual void setArrays(const std::vector& arrays, TimeLabel *owner) throw(INTERP_KERNEL::Exception); - DataArrayDouble *getArray() const { return _array; } - virtual DataArrayDouble *getEndArray() const; + DataArrayDouble *getArray() { return _array; } + const DataArrayDouble *getArray() const { return _array; } + virtual const DataArrayDouble *getEndArray() const; + virtual DataArrayDouble *getEndArray(); virtual std::vector< const DataArrayDouble *> getArraysForTime(double time) const throw(INTERP_KERNEL::Exception) = 0; virtual void getValueForTime(double time, const std::vector& vals, double *res) const = 0; virtual void getArrays(std::vector& arrays) const; @@ -89,6 +99,15 @@ namespace ParaMEDMEM virtual double getStartTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) = 0; virtual double getEndTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) = 0; void setTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) { setStartTime(time,iteration,order); } + void setIteration(int it) throw(INTERP_KERNEL::Exception) { setStartIteration(it); } + void setOrder(int order) throw(INTERP_KERNEL::Exception) { setStartOrder(order); } + void setTimeValue(double val) throw(INTERP_KERNEL::Exception) { setStartTimeValue(val); } + virtual void setStartIteration(int it) throw(INTERP_KERNEL::Exception) = 0; + virtual void setEndIteration(int it) throw(INTERP_KERNEL::Exception) = 0; + virtual void setStartOrder(int order) throw(INTERP_KERNEL::Exception) = 0; + virtual void setEndOrder(int order) throw(INTERP_KERNEL::Exception) = 0; + virtual void setStartTimeValue(double time) throw(INTERP_KERNEL::Exception) = 0; + virtual void setEndTimeValue(double time) throw(INTERP_KERNEL::Exception) = 0; virtual void setStartTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) = 0; virtual void setEndTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) = 0; virtual void getValueOnTime(int eltId, double time, double *value) const throw(INTERP_KERNEL::Exception) = 0; @@ -111,14 +130,19 @@ namespace ParaMEDMEM virtual void applyLin(double a, double b, int compoId); virtual void applyFunc(int nbOfComp, FunctionToEvaluate func); virtual void applyFunc(int nbOfComp, const char *func); + virtual void applyFunc2(int nbOfComp, const char *func); + virtual void applyFunc3(int nbOfComp, const std::vector& varsOrder, const char *func); virtual void applyFunc(const char *func); virtual void applyFuncFast32(const char *func); virtual void applyFuncFast64(const char *func); virtual void fillFromAnalytic(const DataArrayDouble *loc, int nbOfComp, FunctionToEvaluate func) throw(INTERP_KERNEL::Exception); virtual void fillFromAnalytic(const DataArrayDouble *loc, int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception); + virtual void fillFromAnalytic2(const DataArrayDouble *loc, int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception); + virtual void fillFromAnalytic3(const DataArrayDouble *loc, int nbOfComp, const std::vector& varsOrder, const char *func) throw(INTERP_KERNEL::Exception); // virtual ~MEDCouplingTimeDiscretization(); protected: + std::string _time_unit; double _time_tolerance; DataArrayDouble *_array; protected: @@ -133,6 +157,8 @@ namespace ParaMEDMEM std::string getStringRepr() const; TypeOfTimeDiscretization getEnum() const { return DISCRETIZATION; } MEDCouplingTimeDiscretization *aggregate(const MEDCouplingTimeDiscretization *other) const; + MEDCouplingTimeDiscretization *aggregate(const std::vector& other) const; + MEDCouplingTimeDiscretization *meld(const MEDCouplingTimeDiscretization *other) const; MEDCouplingTimeDiscretization *dot(const MEDCouplingTimeDiscretization *other) const; MEDCouplingTimeDiscretization *crossProduct(const MEDCouplingTimeDiscretization *other) const; MEDCouplingTimeDiscretization *max(const MEDCouplingTimeDiscretization *other) const; @@ -150,6 +176,8 @@ namespace ParaMEDMEM bool areCompatible(const MEDCouplingTimeDiscretization *other) const; bool areStrictlyCompatible(const MEDCouplingTimeDiscretization *other) const; bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const; + bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const; + bool areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const; MEDCouplingTimeDiscretization *performCpy(bool deepCpy) const; void checkNoTimePresence() const throw(INTERP_KERNEL::Exception) { } void checkTimePresence(double time) const throw(INTERP_KERNEL::Exception); @@ -159,10 +187,19 @@ namespace ParaMEDMEM bool isStrictlyBefore(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception); double getStartTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception); double getEndTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception); + void setStartIteration(int it) throw(INTERP_KERNEL::Exception); + void setEndIteration(int it) throw(INTERP_KERNEL::Exception); + void setStartOrder(int order) throw(INTERP_KERNEL::Exception); + void setEndOrder(int order) throw(INTERP_KERNEL::Exception); + void setStartTimeValue(double time) throw(INTERP_KERNEL::Exception); + void setEndTimeValue(double time) throw(INTERP_KERNEL::Exception); void setStartTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception); void setEndTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception); void getValueOnTime(int eltId, double time, double *value) const throw(INTERP_KERNEL::Exception); void getValueOnDiscTime(int eltId, int iteration, int order, double *value) const throw(INTERP_KERNEL::Exception); + void getTinySerializationIntInformation2(std::vector& tinyInfo) const; + void getTinySerializationDbleInformation2(std::vector& tinyInfo) const; + void finishUnserialization2(const std::vector& tinyInfoI, const std::vector& tinyInfoD); public: static const TypeOfTimeDiscretization DISCRETIZATION=NO_TIME; static const char REPR[]; @@ -180,6 +217,8 @@ namespace ParaMEDMEM void copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other); TypeOfTimeDiscretization getEnum() const { return DISCRETIZATION; } MEDCouplingTimeDiscretization *aggregate(const MEDCouplingTimeDiscretization *other) const; + MEDCouplingTimeDiscretization *aggregate(const std::vector& other) const; + MEDCouplingTimeDiscretization *meld(const MEDCouplingTimeDiscretization *other) const; MEDCouplingTimeDiscretization *dot(const MEDCouplingTimeDiscretization *other) const; MEDCouplingTimeDiscretization *crossProduct(const MEDCouplingTimeDiscretization *other) const; MEDCouplingTimeDiscretization *max(const MEDCouplingTimeDiscretization *other) const; @@ -197,9 +236,14 @@ namespace ParaMEDMEM bool areCompatible(const MEDCouplingTimeDiscretization *other) const; bool areStrictlyCompatible(const MEDCouplingTimeDiscretization *other) const; bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const; + bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const; + bool areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const; void getTinySerializationIntInformation(std::vector& tinyInfo) const; void getTinySerializationDbleInformation(std::vector& tinyInfo) const; void finishUnserialization(const std::vector& tinyInfoI, const std::vector& tinyInfoD, const std::vector& tinyInfoS); + void getTinySerializationIntInformation2(std::vector& tinyInfo) const; + void getTinySerializationDbleInformation2(std::vector& tinyInfo) const; + void finishUnserialization2(const std::vector& tinyInfoI, const std::vector& tinyInfoD); MEDCouplingTimeDiscretization *performCpy(bool deepCpy) const; void checkNoTimePresence() const throw(INTERP_KERNEL::Exception); void checkTimePresence(double time) const throw(INTERP_KERNEL::Exception); @@ -207,6 +251,12 @@ namespace ParaMEDMEM void setEndTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) { _time=time; _iteration=iteration; _order=order; } double getStartTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) { iteration=_iteration; order=_order; return _time; } double getEndTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) { iteration=_iteration; order=_order; return _time; } + void setStartIteration(int it) throw(INTERP_KERNEL::Exception) { _iteration=it; } + void setEndIteration(int it) throw(INTERP_KERNEL::Exception) { _iteration=it; } + void setStartOrder(int order) throw(INTERP_KERNEL::Exception) { _order=order; } + void setEndOrder(int order) throw(INTERP_KERNEL::Exception) { _order=order; } + void setStartTimeValue(double time) throw(INTERP_KERNEL::Exception) { _time=time; } + void setEndTimeValue(double time) throw(INTERP_KERNEL::Exception) { _time=time; } std::vector< const DataArrayDouble *> getArraysForTime(double time) const throw(INTERP_KERNEL::Exception); void getValueForTime(double time, const std::vector& vals, double *res) const; void getValueOnTime(int eltId, double time, double *value) const throw(INTERP_KERNEL::Exception); @@ -232,10 +282,15 @@ namespace ParaMEDMEM void getTinySerializationIntInformation(std::vector& tinyInfo) const; void getTinySerializationDbleInformation(std::vector& tinyInfo) const; void finishUnserialization(const std::vector& tinyInfoI, const std::vector& tinyInfoD, const std::vector& tinyInfoS); + void getTinySerializationIntInformation2(std::vector& tinyInfo) const; + void getTinySerializationDbleInformation2(std::vector& tinyInfo) const; + void finishUnserialization2(const std::vector& tinyInfoI, const std::vector& tinyInfoD); MEDCouplingTimeDiscretization *performCpy(bool deepCpy) const; bool areCompatible(const MEDCouplingTimeDiscretization *other) const; bool areStrictlyCompatible(const MEDCouplingTimeDiscretization *other) const; bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const; + bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const; + bool areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const; bool isEqual(const MEDCouplingTimeDiscretization *other, double prec) const; bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const; std::vector< const DataArrayDouble *> getArraysForTime(double time) const throw(INTERP_KERNEL::Exception); @@ -245,6 +300,8 @@ namespace ParaMEDMEM TypeOfTimeDiscretization getEnum() const { return DISCRETIZATION; } std::string getStringRepr() const; MEDCouplingTimeDiscretization *aggregate(const MEDCouplingTimeDiscretization *other) const; + MEDCouplingTimeDiscretization *aggregate(const std::vector& other) const; + MEDCouplingTimeDiscretization *meld(const MEDCouplingTimeDiscretization *other) const; MEDCouplingTimeDiscretization *dot(const MEDCouplingTimeDiscretization *other) const; MEDCouplingTimeDiscretization *crossProduct(const MEDCouplingTimeDiscretization *other) const; MEDCouplingTimeDiscretization *max(const MEDCouplingTimeDiscretization *other) const; @@ -261,6 +318,12 @@ namespace ParaMEDMEM void setEndTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) { _end_time=time; _end_iteration=iteration; _end_order=order; } double getStartTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) { iteration=_start_iteration; order=_start_order; return _start_time; } double getEndTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) { iteration=_end_iteration; order=_end_order; return _end_time; } + void setStartIteration(int it) throw(INTERP_KERNEL::Exception) { _start_iteration=it; } + void setEndIteration(int it) throw(INTERP_KERNEL::Exception) { _end_iteration=it; } + void setStartOrder(int order) throw(INTERP_KERNEL::Exception) { _start_order=order; } + void setEndOrder(int order) throw(INTERP_KERNEL::Exception) { _end_order=order; } + void setStartTimeValue(double time) throw(INTERP_KERNEL::Exception) { _start_time=time; } + void setEndTimeValue(double time) throw(INTERP_KERNEL::Exception) { _end_time=time; } void checkNoTimePresence() const throw(INTERP_KERNEL::Exception); void checkTimePresence(double time) const throw(INTERP_KERNEL::Exception); public: @@ -284,10 +347,11 @@ namespace ParaMEDMEM MEDCouplingTwoTimeSteps(); ~MEDCouplingTwoTimeSteps(); public: - void updateTime(); + void updateTime() const; void copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other); void copyTinyStringsFrom(const MEDCouplingTimeDiscretization& other); - DataArrayDouble *getEndArray() const; + const DataArrayDouble *getEndArray() const; + DataArrayDouble *getEndArray(); void checkCoherency() const throw(INTERP_KERNEL::Exception); bool isEqual(const MEDCouplingTimeDiscretization *other, double prec) const; bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const; @@ -299,11 +363,20 @@ namespace ParaMEDMEM void setEndTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) { _end_time=time; _end_iteration=iteration; _end_order=order; } double getStartTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) { iteration=_start_iteration; order=_start_order; return _start_time; } double getEndTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) { iteration=_end_iteration; order=_end_order; return _end_time; } + void setStartIteration(int it) throw(INTERP_KERNEL::Exception) { _start_iteration=it; } + void setEndIteration(int it) throw(INTERP_KERNEL::Exception) { _end_iteration=it; } + void setStartOrder(int order) throw(INTERP_KERNEL::Exception) { _start_order=order; } + void setEndOrder(int order) throw(INTERP_KERNEL::Exception) { _end_order=order; } + void setStartTimeValue(double time) throw(INTERP_KERNEL::Exception) { _start_time=time; } + void setEndTimeValue(double time) throw(INTERP_KERNEL::Exception) { _end_time=time; } void getTinySerializationIntInformation(std::vector& tinyInfo) const; void getTinySerializationDbleInformation(std::vector& tinyInfo) const; void getTinySerializationStrInformation(std::vector& tinyInfo) const; void resizeForUnserialization(const std::vector& tinyInfoI, std::vector& arrays); void finishUnserialization(const std::vector& tinyInfoI, const std::vector& tinyInfoD, const std::vector& tinyInfoS); + void getTinySerializationIntInformation2(std::vector& tinyInfo) const; + void getTinySerializationDbleInformation2(std::vector& tinyInfo) const; + void finishUnserialization2(const std::vector& tinyInfoI, const std::vector& tinyInfoD); std::vector< const DataArrayDouble *> getArraysForTime(double time) const throw(INTERP_KERNEL::Exception); void setArrays(const std::vector& arrays, TimeLabel *owner) throw(INTERP_KERNEL::Exception); protected: @@ -331,10 +404,14 @@ namespace ParaMEDMEM bool areCompatible(const MEDCouplingTimeDiscretization *other) const; bool areStrictlyCompatible(const MEDCouplingTimeDiscretization *other) const; bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const; + bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const; + bool areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const; void getValueForTime(double time, const std::vector& vals, double *res) const; void getValueOnTime(int eltId, double time, double *value) const throw(INTERP_KERNEL::Exception); void getValueOnDiscTime(int eltId, int iteration, int order, double *value) const throw(INTERP_KERNEL::Exception); MEDCouplingTimeDiscretization *aggregate(const MEDCouplingTimeDiscretization *other) const; + MEDCouplingTimeDiscretization *aggregate(const std::vector& other) const; + MEDCouplingTimeDiscretization *meld(const MEDCouplingTimeDiscretization *other) const; MEDCouplingTimeDiscretization *dot(const MEDCouplingTimeDiscretization *other) const; MEDCouplingTimeDiscretization *crossProduct(const MEDCouplingTimeDiscretization *other) const; MEDCouplingTimeDiscretization *max(const MEDCouplingTimeDiscretization *other) const; diff --git a/src/MEDCoupling/MEDCouplingTimeLabel.cxx b/src/MEDCoupling/MEDCouplingTimeLabel.cxx index dad0d5900..d6f8c151e 100644 --- a/src/MEDCoupling/MEDCouplingTimeLabel.cxx +++ b/src/MEDCoupling/MEDCouplingTimeLabel.cxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "MEDCouplingTimeLabel.hxx" @@ -31,18 +31,18 @@ TimeLabel::~TimeLabel() { } - TimeLabel& TimeLabel::operator=(const TimeLabel& other) +TimeLabel& TimeLabel::operator=(const TimeLabel& other) { _time=GLOBAL_TIME++; return *this; } -void TimeLabel::declareAsNew() +void TimeLabel::declareAsNew() const { _time=GLOBAL_TIME++; } -void TimeLabel::updateTimeWith(const TimeLabel& other) +void TimeLabel::updateTimeWith(const TimeLabel& other) const { if(_time #include @@ -63,7 +66,7 @@ MEDCouplingUMesh *MEDCouplingUMesh::clone(bool recDeepCpy) const return new MEDCouplingUMesh(*this,recDeepCpy); } -void MEDCouplingUMesh::updateTime() +void MEDCouplingUMesh::updateTime() const { MEDCouplingPointSet::updateTime(); if(_nodal_connec) @@ -93,7 +96,7 @@ void MEDCouplingUMesh::checkCoherency() const throw(INTERP_KERNEL::Exception) throw INTERP_KERNEL::Exception("No mesh dimension specified !"); for(std::set::const_iterator iter=_types.begin();iter!=_types.end();iter++) { - if((int)INTERP_KERNEL::CellModel::getCellModel(*iter).getDimension()!=_mesh_dim) + if((int)INTERP_KERNEL::CellModel::GetCellModel(*iter).getDimension()!=_mesh_dim) { std::ostringstream message; message << "Mesh invalid because dimension is " << _mesh_dim << " and there is presence of cell(s) with type " << (*iter); @@ -116,6 +119,72 @@ void MEDCouplingUMesh::checkCoherency() const throw(INTERP_KERNEL::Exception) } } +/*! + * This method performs deeper checking in 'this' than MEDCouplingUMesh::checkCoherency does. + * So this method is more time-consuming. This method checks that nodal connectivity points to valid node ids. + * No geometrical aspects are checked here. These aspects are done in MEDCouplingUMesh::checkCoherency2. + */ +void MEDCouplingUMesh::checkCoherency1(double eps) const throw(INTERP_KERNEL::Exception) +{ + checkCoherency(); + if(_mesh_dim==-1) + return ; + int meshDim=getMeshDimension(); + int nbOfNodes=getNumberOfNodes(); + int nbOfCells=getNumberOfCells(); + const int *ptr=_nodal_connec->getConstPointer(); + const int *ptrI=_nodal_connec_index->getConstPointer(); + for(int i=0;i=0) + { + if(nodeId>=nbOfNodes) + { + std::ostringstream oss; oss << "Cell #" << i << " is consituted of node #" << nodeId << " whereas there are only " << nbOfNodes << " nodes !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + } + else if(nodeId<-1) + { + std::ostringstream oss; oss << "Cell #" << i << " is consituted of node #" << nodeId << " in connectivity ! sounds bad !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + else + { + if((INTERP_KERNEL::NormalizedCellType)(ptr[ptrI[i]])!=INTERP_KERNEL::NORM_POLYHED) + { + std::ostringstream oss; oss << "Cell #" << i << " is consituted of node #-1 in connectivity ! sounds bad !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + } + } + } +} + +void MEDCouplingUMesh::checkCoherency2(double eps) const throw(INTERP_KERNEL::Exception) +{ + checkCoherency1(eps); +} + void MEDCouplingUMesh::setMeshDimension(int meshDim) { if(meshDim<-1) @@ -152,14 +221,30 @@ void MEDCouplingUMesh::allocateCells(int nbOfCells) * @param size number of nodes constituting this cell. * @param nodalConnOfCell the connectivity of the cell to add. */ -void MEDCouplingUMesh::insertNextCell(INTERP_KERNEL::NormalizedCellType type, int size, const int *nodalConnOfCell) +void MEDCouplingUMesh::insertNextCell(INTERP_KERNEL::NormalizedCellType type, int size, const int *nodalConnOfCell) throw(INTERP_KERNEL::Exception) { - int *pt=_nodal_connec_index->getPointer(); - int idx=pt[_iterator]; - - _nodal_connec->writeOnPlace(idx,type,nodalConnOfCell,size); - _types.insert(type); - pt[++_iterator]=idx+size+1; + const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(type); + if(_nodal_connec_index==0) + throw INTERP_KERNEL::Exception("MEDCouplingUMesh::insertNextCell : nodal connectivity not set ! invoke allocateCells before calling insertNextCell !"); + if((int)cm.getDimension()==_mesh_dim) + { + int nbOfElems=_nodal_connec_index->getNbOfElems()-1; + if(_iterator>=nbOfElems) + throw INTERP_KERNEL::Exception("MEDCouplingUMesh::insertNextCell : allocation of cells was wide enough ! Call insertNextCell with higher value or call finishInsertingCells !"); + int *pt=_nodal_connec_index->getPointer(); + int idx=pt[_iterator]; + + _nodal_connec->writeOnPlace(idx,type,nodalConnOfCell,size); + _types.insert(type); + pt[++_iterator]=idx+size+1; + } + else + { + std::ostringstream oss; oss << "MEDCouplingUMesh::insertNextCell : cell type " << cm.getRepr() << " has a dimension " << cm.getDimension(); + oss << " whereas Mesh Dimension of current UMesh instance is set to " << _mesh_dim << " ! Please invoke \"setMeshDimension\" method before or invoke "; + oss << "\"MEDCouplingUMesh::New\" static method with 2 parameters name and meshDimension !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } } /*! @@ -178,6 +263,11 @@ void MEDCouplingUMesh::finishInsertingCells() updateTime(); } +std::set MEDCouplingUMesh::getAllGeoTypes() const +{ + return _types; +} + /*! * This method is a method that compares 'this' and 'other'. * This method compares \b all attributes, even names and component names. @@ -252,7 +342,7 @@ void MEDCouplingUMesh::checkDeepEquivalWith(const MEDCouplingMesh *other, int ce MEDCouplingMesh::checkFastEquivalWith(other,prec); if(_types!=otherC->_types) throw INTERP_KERNEL::Exception("checkDeepEquivalWith : Types are not equal !"); - MEDCouplingAutoRefCountObjectPtr m=mergeUMeshes(this,otherC); + MEDCouplingAutoRefCountObjectPtr m=MergeUMeshes(this,otherC); bool areNodesMerged; int newNbOfNodes; int oldNbOfNodes=getNumberOfNodes(); @@ -295,6 +385,7 @@ void MEDCouplingUMesh::checkDeepEquivalWith(const MEDCouplingMesh *other, int ce * This method looks if 'this' and 'other' are geometrically equivalent that is to say if each cell in 'other' correspond to one cell and only one * in 'this' is found regarding 'prec' parameter and 'cellCompPol' parameter. The difference with MEDCouplingUMesh::checkDeepEquivalWith method is that * coordinates of 'this' and 'other' are expected to be the same. If not an exception will be thrown. + * This method is close to MEDCouplingUMesh::areCellsIncludedIn except that this method throws exception ! * * In case of success cellCor are informed both. * @param cellCompPol values are described in MEDCouplingUMesh::zipConnectivityTraducer method. @@ -311,10 +402,10 @@ void MEDCouplingUMesh::checkDeepEquivalOnSameNodesWith(const MEDCouplingMesh *ot throw INTERP_KERNEL::Exception("checkDeepEquivalOnSameNodesWith : Types are not equal !"); if(_coords!=otherC->_coords) throw INTERP_KERNEL::Exception("checkDeepEquivalOnSameNodesWith : meshes do not share the same coordinates ! Use tryToShareSameCoordinates or call checkDeepEquivalWith !"); - std::vector ms(2); - ms[0]=const_cast(this); - ms[1]=const_cast(otherC); - MEDCouplingAutoRefCountObjectPtr m=mergeUMeshesOnSameCoords(ms); + std::vector ms(2); + ms[0]=this; + ms[1]=otherC; + MEDCouplingAutoRefCountObjectPtr m=MergeUMeshesOnSameCoords(ms); MEDCouplingAutoRefCountObjectPtr da=m->zipConnectivityTraducer(cellCompPol); int maxId=*std::max_element(da->getConstPointer(),da->getConstPointer()+getNumberOfCells()); const int *pt=std::find_if(da->getConstPointer()+getNumberOfCells(),da->getConstPointer()+da->getNbOfElems(),std::bind2nd(std::greater(),maxId)); @@ -356,7 +447,7 @@ void MEDCouplingUMesh::checkFastEquivalWith(const MEDCouplingMesh *other, double * \b WARNING this method do the assumption that connectivity lies on the coordinates set. * For speed reasons no check of this will be done. */ -void MEDCouplingUMesh::getReverseNodalConnectivity(DataArrayInt *revNodal, DataArrayInt *revNodalIndx) const +void MEDCouplingUMesh::getReverseNodalConnectivity(DataArrayInt *revNodal, DataArrayInt *revNodalIndx) const throw(INTERP_KERNEL::Exception) { checkFullyDefined(); int nbOfNodes=getNumberOfNodes(); @@ -396,7 +487,7 @@ void MEDCouplingUMesh::getReverseNodalConnectivity(DataArrayInt *revNodal, DataA * \b WARNING this method do the assumption that connectivity lies on the coordinates set. * For speed reasons no check of this will be done. */ -MEDCouplingUMesh *MEDCouplingUMesh::buildDescendingConnectivity(DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *revDesc, DataArrayInt *revDescIndx) const +MEDCouplingUMesh *MEDCouplingUMesh::buildDescendingConnectivity(DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *revDesc, DataArrayInt *revDescIndx) const throw(INTERP_KERNEL::Exception) { checkFullyDefined(); int nbOfCells=getNumberOfCells(); @@ -413,14 +504,14 @@ MEDCouplingUMesh *MEDCouplingUMesh::buildDescendingConnectivity(DataArrayInt *de { int pos=connIndex[eltId]; int posP1=connIndex[eltId+1]; - const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::getCellModel((INTERP_KERNEL::NormalizedCellType)conn[pos]); + const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel((INTERP_KERNEL::NormalizedCellType)conn[pos]); unsigned nbOfSons=cm.getNumberOfSons2(conn+pos+1,posP1-pos-1); int *tmp=new int[posP1-pos]; for(unsigned i=0;i shareableCells(revNodalB[tmp[0]].begin(),revNodalB[tmp[0]].end()); for(unsigned j=1;j& cellIdsToConve int pos=connIndex[*iter]; int posP1=connIndex[(*iter)+1]; int lgthOld=posP1-pos-1; - const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::getCellModel((INTERP_KERNEL::NormalizedCellType)connNew[pos]); + const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel((INTERP_KERNEL::NormalizedCellType)connNew[pos]); connNew[pos]=INTERP_KERNEL::NORM_POLYHED; unsigned nbOfFaces=cm.getNumberOfSons2(&connNew[pos+1],lgthOld); int *tmp=new int[nbOfFaces*lgthOld]; @@ -564,12 +655,84 @@ void MEDCouplingUMesh::convertToPolyTypes(const std::vector& cellIdsToConve } /*! - * Array returned is the correspondance new to old. + * This method converts all cells into poly type if possible. + * This method is purely for userfriendliness. + * As this method can be costly in Memory, no optimization is done to avoid construction of useless vector. + */ +void MEDCouplingUMesh::convertAllToPoly() +{ + int nbOfCells=getNumberOfCells(); + std::vector cellIds(nbOfCells); + for(int i=0;igetPointer(); + int *index=_nodal_connec_index->getPointer(); + int posOfCurCell=0; + int newPos=0; + int lgthOfCurCell; + for(int i=0;i tmp=new int[lgthOfCurCell-1]; + std::copy(conn+posOfCurCell+1,conn+posOfCurCell+lgthOfCurCell,(int *)tmp); + newType=INTERP_KERNEL::CellSimplify::tryToUnPoly2D(tmp,lgthOfCurCell-1,conn+newPos+1,newLgth); + } + if(cm.getDimension()==3) + { + int nbOfFaces,lgthOfPolyhConn; + INTERP_KERNEL::AutoPtr zipFullReprOfPolyh=INTERP_KERNEL::CellSimplify::getFullPolyh3DCell(type,conn+posOfCurCell+1,lgthOfCurCell-1,nbOfFaces,lgthOfPolyhConn); + newType=INTERP_KERNEL::CellSimplify::tryToUnPoly3D(zipFullReprOfPolyh,nbOfFaces,lgthOfPolyhConn,conn+newPos+1,newLgth); + } + conn[newPos]=newType; + newPos+=newLgth+1; + posOfCurCell=index[i+1]; + index[i+1]=newPos; + } + else + { + std::copy(conn+posOfCurCell,conn+posOfCurCell+lgthOfCurCell,conn+newPos); + newPos+=lgthOfCurCell; + posOfCurCell+=lgthOfCurCell; + index[i+1]=newPos; + } + } + if(newPos!=initMeshLgth) + _nodal_connec->reAlloc(newPos); + computeTypes(); +} + +/*! + * Array returned is the correspondance old to new. * The maximum value stored in returned array is the number of nodes of 'this' minus 1 after call of this method. * The size of returned array is the number of nodes of the old (previous to the call of this method) number of nodes. * -1 values in returned array means that the corresponding old node is no more used. */ -DataArrayInt *MEDCouplingUMesh::zipCoordsTraducer() +DataArrayInt *MEDCouplingUMesh::zipCoordsTraducer() throw(INTERP_KERNEL::Exception) { int nbOfNodes=getNumberOfNodes(); DataArrayInt *ret=DataArrayInt::New(); @@ -772,7 +935,7 @@ void MEDCouplingUMesh::findCommonCellsBase(int compType, std::vector& res, * 2 : nodal. cell1 and cell2 are equal if and only if cell1 and cell2 have same type and have the same nodes constituting connectivity. This is the laziest policy. * @return the correspondance array old to new. */ -DataArrayInt *MEDCouplingUMesh::zipConnectivityTraducer(int compType) +DataArrayInt *MEDCouplingUMesh::zipConnectivityTraducer(int compType) throw(INTERP_KERNEL::Exception) { int spaceDim=getSpaceDimension(); int nbOfCells=getNumberOfCells(); @@ -840,6 +1003,30 @@ DataArrayInt *MEDCouplingUMesh::zipConnectivityTraducer(int compType) return ret; } +/*! + * This method makes the assumption that 'this' and 'other' share the same coords. If not an exception will be thrown ! + * This method tries to determine if 'other' is fully included in 'this'. To compute that, this method works with connectivity as MEDCouplingUMesh::zipConnectivityTraducer method does. + * This method is close to MEDCouplingUMesh::checkDeepEquivalOnSameNodesWith or MEDCouplingMesh::checkGeoEquivalWith with policy 20,21,or 22. + * The main difference is that this method is not expected to throw exception. + * This method has two outputs : + * + * @param compType is the comparison type. The possible values of this parameter are described in ParaMEDMEM::MEDCouplingUMesh::zipConnectivityTraducer method + * @param arr is an output parameter that returns a \b newly created instance. This array is of size 'other->getNumberOfCells()'. + * @return If 'other' is fully included in 'this 'true is returned. If not false is returned. + */ +bool MEDCouplingUMesh::areCellsIncludedIn(const MEDCouplingUMesh *other, int compType, DataArrayInt *& arr) const throw(INTERP_KERNEL::Exception) +{ + MEDCouplingAutoRefCountObjectPtr mesh=MergeUMeshesOnSameCoords(this,other); + MEDCouplingAutoRefCountObjectPtr o2n=mesh->zipConnectivityTraducer(compType); + int nbOfCells=getNumberOfCells(); + arr=o2n->substr(nbOfCells); + arr->setName(other->getName()); + int tmp; + if(other->getNumberOfCells()==0) + return true; + return arr->getMaxValue(tmp)getConstPointer(),newNbOfNodes); + return ret; +} + /*! * This method tries to use 'other' coords and use it for 'this'. If no exception was thrown after the call of this method : - * this->_coords==other->_coords. If not a exception is thrown this remains unchanged. + * this->_coords==other->_coords. If an exception is thrown 'this' remains unchanged. + * Contrary to MEDCouplingUMesh::tryToShareSameCoords method this method makes a deeper analyze of coordinates (and so more expensive) than simple equality. + * Two nodes one in 'this' and other in 'other' are considered equal if the distance between the two is lower than epsilon. */ void MEDCouplingUMesh::tryToShareSameCoordsPermute(const MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception) { - DataArrayDouble *coords=other.getCoords(); + const DataArrayDouble *coords=other.getCoords(); if(!coords) throw INTERP_KERNEL::Exception("tryToShareSameCoordsPermute : No coords specified in other !"); if(!_coords) throw INTERP_KERNEL::Exception("tryToShareSameCoordsPermute : No coords specified in this whereas there is any in other !"); int otherNbOfNodes=other.getNumberOfNodes(); - MEDCouplingAutoRefCountObjectPtr newCoords=mergeNodesArray(&other,this); + MEDCouplingAutoRefCountObjectPtr newCoords=MergeNodesArray(&other,this); _coords->incrRef(); MEDCouplingAutoRefCountObjectPtr oldCoords=_coords; setCoords(newCoords); @@ -892,7 +1092,7 @@ void MEDCouplingUMesh::tryToShareSameCoordsPermute(const MEDCouplingPointSet& ot * build a sub part of 'this'. This sub part is defined by the cell ids contained in the array in [begin,end). * @param begin begin of array containing the cell ids to keep. * @param end end of array of cell ids to keep. \b WARNING end param is \b not included ! Idem STL standard definitions. - * @param keepCoords that specifies if you want or not to keep coords as this or zip it (see zipCoords) + * @param keepCoords that specifies if you want or not to keep coords as this or zip it (see ParaMEDMEM::MEDCouplingUMesh::zipCoords). If true zipCoords is \b NOT called, if false, zipCoords is called. */ MEDCouplingPointSet *MEDCouplingUMesh::buildPartOfMySelf(const int *begin, const int *end, bool keepCoords) const { @@ -954,6 +1154,20 @@ void MEDCouplingUMesh::fillCellIdsToKeepFromNodeIds(const int *begin, const int } } +/*! + * This method is very close too MEDCouplingUMesh::buildPartOfMySelfNode. The difference is that it returns directly ids. + */ +DataArrayInt *MEDCouplingUMesh::getCellIdsLyingOnNodes(const int *begin, const int *end, bool fullyIn) const +{ + std::vector cellIdsKept; + fillCellIdsToKeepFromNodeIds(begin,end,fullyIn,cellIdsKept); + DataArrayInt *ret=DataArrayInt::New(); + ret->alloc(cellIdsKept.size(),1); + std::copy(cellIdsKept.begin(),cellIdsKept.end(),ret->getPointer()); + ret->setName(getName()); + return ret; +} + /*! * Keeps from 'this' only cells which constituing point id are in the ids specified by ['begin','end'). * The return newly allocated mesh will share the same coordinates as 'this'. @@ -987,7 +1201,7 @@ MEDCouplingPointSet *MEDCouplingUMesh::buildFacePartOfMySelfNode(const int *begi /*! * This method returns a mesh with meshDim=this->getMeshDimension()-1. * This returned mesh contains cells that are linked with one and only one cell of this. - * @param keepCoords specifies if zipCoords is called on returned mesh before being returned. + * @param keepCoords specifies if ParaMEDMEM::MEDCouplingUMesh::zipCoords is called on returned mesh before being returned. If true zipCoords is \b NOT called, if false, zipCoords is called. * @return mesh with ref counter equal to 1. */ MEDCouplingPointSet *MEDCouplingUMesh::buildBoundaryMesh(bool keepCoords) const @@ -1013,6 +1227,44 @@ MEDCouplingPointSet *MEDCouplingUMesh::buildBoundaryMesh(bool keepCoords) const return ret; } +/*! + * This method returns a newly created DataArrayInt instance containing ids of cells located in boundary. + * A cell is detected to be on boundary if it contains one or more than one face having only one father. + * This method makes the assumption that 'this' is fully defined (coords,connectivity). If not an exception will be thrown. + */ +DataArrayInt *MEDCouplingUMesh::findCellsIdsOnBoundary() const throw(INTERP_KERNEL::Exception) +{ + checkFullyDefined(); + DataArrayInt *desc=DataArrayInt::New(); + DataArrayInt *descIndx=DataArrayInt::New(); + DataArrayInt *revDesc=DataArrayInt::New(); + DataArrayInt *revDescIndx=DataArrayInt::New(); + // + MEDCouplingUMesh *meshDM1=buildDescendingConnectivity(desc,descIndx,revDesc,revDescIndx); + meshDM1->decrRef(); + desc->decrRef(); + descIndx->decrRef(); + // + DataArrayInt *tmp=revDescIndx->deltaShiftIndex(); + DataArrayInt *faceIds=tmp->getIdsEqual(1); + tmp->decrRef(); + int nbOfFaces=faceIds->getNumberOfTuples(); + const int *faces=faceIds->getConstPointer(); + std::set ret; + for(const int *w=faces;w!=faces+nbOfFaces;w++) + ret.insert(revDesc->getIJ(revDescIndx->getIJ(*w,0),0)); + faceIds->decrRef(); + // + revDescIndx->decrRef(); + revDesc->decrRef(); + // + DataArrayInt *ret2=DataArrayInt::New(); + ret2->alloc(ret.size(),1); + std::copy(ret.begin(),ret.end(),ret2->getPointer()); + ret2->setName("BoundaryCells"); + return ret2; +} + /*! * This methods returns set of nodes lying on the boundary of this. */ @@ -1046,13 +1298,19 @@ void MEDCouplingUMesh::findBoundaryNodes(std::vector& nodes) const meshDM1->decrRef(); } +MEDCouplingUMesh *MEDCouplingUMesh::buildUnstructured() const throw(INTERP_KERNEL::Exception) +{ + incrRef(); + return const_cast(this); +} + /* * This method renumber 'this' using 'newNodeNumbers' array of size this->getNumberOfNodes. * newNbOfNodes specifies the *std::max_element(newNodeNumbers,newNodeNumbers+this->getNumberOfNodes()) * This value is asked because often known by the caller of this method. * This method, contrary to MEDCouplingMesh::renumberCells does NOT conserve the number of nodes before and after. * - * @param newNodeNumbers array specifying the new numbering. + * @param newNodeNumbers array specifying the new numbering in old2New convention. * @param newNbOfNodes the new number of nodes. */ void MEDCouplingUMesh::renumberNodes(const int *newNodeNumbers, int newNbOfNodes) @@ -1061,9 +1319,26 @@ void MEDCouplingUMesh::renumberNodes(const int *newNodeNumbers, int newNbOfNodes renumberNodesInConn(newNodeNumbers); } +/* + * This method renumber 'this' using 'newNodeNumbers' array of size this->getNumberOfNodes. + * newNbOfNodes specifies the *std::max_element(newNodeNumbers,newNodeNumbers+this->getNumberOfNodes()) + * This value is asked because often known by the caller of this method. + * This method, contrary to MEDCouplingMesh::renumberCells does NOT conserve the number of nodes before and after. + * The difference with ParaMEDMEM::MEDCouplingUMesh::renumberNodes method is in the fact that the barycenter of merged nodes is computed here. + * + * @param newNodeNumbers array specifying the new numbering. + * @param newNbOfNodes the new number of nodes. + */ +void MEDCouplingUMesh::renumberNodes2(const int *newNodeNumbers, int newNbOfNodes) +{ + MEDCouplingPointSet::renumberNodes2(newNodeNumbers,newNbOfNodes); + renumberNodesInConn(newNodeNumbers); +} + /*! * This method renumbers nodes in connectivity only without any reference with coords. * Use it with care ! + * @param 'newNodeNumbers' in old2New convention */ void MEDCouplingUMesh::renumberNodesInConn(const int *newNodeNumbers) { @@ -1099,10 +1374,11 @@ void MEDCouplingUMesh::renumberNodesInConn(const int *newNodeNumbers) */ void MEDCouplingUMesh::renumberCells(const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception) { + checkConnectivityFullyDefined(); int nbCells=getNumberOfCells(); const int *array=old2NewBg; if(check) - array=DataArrayInt::checkAndPreparePermutation(old2NewBg,old2NewBg+nbCells); + array=DataArrayInt::CheckAndPreparePermutation(old2NewBg,old2NewBg+nbCells); // const int *conn=_nodal_connec->getConstPointer(); const int *connI=_nodal_connec_index->getConstPointer(); @@ -1139,7 +1415,7 @@ void MEDCouplingUMesh::renumberCells(const int *old2NewBg, bool check) throw(INT * Warning 'elems' is incremented during the call so if elems is not empty before call returned elements will be * added in 'elems' parameter. */ -void MEDCouplingUMesh::giveElemsInBoundingBox(const double *bbox, double eps, std::vector& elems) +void MEDCouplingUMesh::getCellsInBoundingBox(const double *bbox, double eps, std::vector& elems) { if(getMeshDimension()==-1) { @@ -1187,11 +1463,11 @@ void MEDCouplingUMesh::giveElemsInBoundingBox(const double *bbox, double eps, st } /*! - * Given a boundary box 'bbox' returns elements 'elems' contained in this 'bbox'. + * Given a boundary box 'bbox' returns elements 'elems' contained in this 'bbox' or touching 'bbox' (within 'eps' distance). * Warning 'elems' is incremented during the call so if elems is not empty before call returned elements will be * added in 'elems' parameter. */ -void MEDCouplingUMesh::giveElemsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bbox, double eps, std::vector& elems) +void MEDCouplingUMesh::getCellsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bbox, double eps, std::vector& elems) { if(getMeshDimension()==-1) { @@ -1292,9 +1568,20 @@ std::string MEDCouplingUMesh::simpleRepr() const static const char msg0[]="No coordinates specified !"; std::ostringstream ret; ret << "Unstructured mesh with name : \"" << getName() << "\"\n"; + ret << "Description of mesh : \"" << getDescription() << "\"\n"; + int tmpp1,tmpp2; + double tt=getTime(tmpp1,tmpp2); + ret << "Time attached to the mesh [unit] : " << tt << " [" << getTimeUnit() << "]\n"; + ret << "Iteration : " << tmpp1 << " Order : " << tmpp2 << "\n"; ret << "Mesh dimension : " << _mesh_dim << "\nSpace dimension : "; if(_coords!=0) - ret << getSpaceDimension() << "\n"; + { + const int spaceDim=getSpaceDimension(); + ret << spaceDim << "\nInfo attached on space dimension : "; + for(int i=0;igetInfoOnComponent(i) << "\" "; + ret << "\n"; + } else ret << msg0 << "\n"; ret << "Number of nodes : "; @@ -1310,7 +1597,7 @@ std::string MEDCouplingUMesh::simpleRepr() const ret << "Cell types present : "; for(std::set::const_iterator iter=_types.begin();iter!=_types.end();iter++) { - const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::getCellModel(*iter); + const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*iter); ret << cm.getRepr() << " "; } ret << "\n"; @@ -1346,7 +1633,7 @@ void MEDCouplingUMesh::reprConnectivityOfThisLL(std::ostringstream& stream) cons const int *ci=_nodal_connec_index->getConstPointer(); for(int i=0;i(stream," ")); stream << "\n"; @@ -1366,14 +1653,29 @@ int MEDCouplingUMesh::getNumberOfNodesInCell(int cellId) const return std::count_if(pt+ptI[cellId]+1,pt+ptI[cellId+1],std::bind2nd(std::not_equal_to(),-1)); } +/*! + * This method is equivalent to MEDCouplingUMesh::getAllTypes excecpt that it returns only types of submesh which cell ids are in [begin,end). + * This method avoids to compute explicitely submesh to get its types. + */ +std::set MEDCouplingUMesh::getTypesOfPart(const int *begin, const int *end) const throw(INTERP_KERNEL::Exception) +{ + checkFullyDefined(); + std::set ret; + const int *conn=_nodal_connec->getConstPointer(); + const int *connIndex=_nodal_connec_index->getConstPointer(); + for(const int *w=begin;w!=end;w++) + ret.insert((INTERP_KERNEL::NormalizedCellType)conn[connIndex[*w]]); + return ret; +} + /*! * Method reserved for advanced users having prepared their connectivity before. * Arrays 'conn' and 'connIndex' will be aggregated without any copy and their counter will be incremented. */ void MEDCouplingUMesh::setConnectivity(DataArrayInt *conn, DataArrayInt *connIndex, bool isComputingTypes) { - DataArrayInt::setArrayIn(conn,_nodal_connec); - DataArrayInt::setArrayIn(connIndex,_nodal_connec_index); + DataArrayInt::SetArrayIn(conn,_nodal_connec); + DataArrayInt::SetArrayIn(connIndex,_nodal_connec_index); if(isComputingTypes) computeTypes(); declareAsNew(); @@ -1426,6 +1728,15 @@ void MEDCouplingUMesh::checkFullyDefined() const throw(INTERP_KERNEL::Exception) throw INTERP_KERNEL::Exception("Reverse nodal connectivity computation requires full connectivity and coordinates set in unstructured mesh."); } +/*! + * This method checks that all connectivity arrays are set. If yes nothing done if no an exception is thrown. + */ +void MEDCouplingUMesh::checkConnectivityFullyDefined() const throw(INTERP_KERNEL::Exception) +{ + if(!_nodal_connec_index || !_nodal_connec) + throw INTERP_KERNEL::Exception("Reverse nodal connectivity computation requires full connectivity set in unstructured mesh."); +} + int MEDCouplingUMesh::getNumberOfCells() const { if(_nodal_connec_index) @@ -1458,9 +1769,9 @@ int MEDCouplingUMesh::getMeshLength() const /*! * First step of serialization process. Used by ParaMEDMEM and MEDCouplingCorba to transfert data between process. */ -void MEDCouplingUMesh::getTinySerializationInformation(std::vector& tinyInfo, std::vector& littleStrings) const +void MEDCouplingUMesh::getTinySerializationInformation(std::vector& tinyInfoD, std::vector& tinyInfo, std::vector& littleStrings) const { - MEDCouplingPointSet::getTinySerializationInformation(tinyInfo,littleStrings); + MEDCouplingPointSet::getTinySerializationInformation(tinyInfoD,tinyInfo,littleStrings); tinyInfo.push_back(getMeshDimension()); tinyInfo.push_back(getNumberOfCells()); if(_nodal_connec) @@ -1474,7 +1785,7 @@ void MEDCouplingUMesh::getTinySerializationInformation(std::vector& tinyInf */ bool MEDCouplingUMesh::isEmptyMesh(const std::vector& tinyInfo) const { - return tinyInfo[4]<=0; + return tinyInfo[6]<=0; } /*! @@ -1485,7 +1796,7 @@ void MEDCouplingUMesh::resizeForUnserialization(const std::vector& tinyInfo { MEDCouplingPointSet::resizeForUnserialization(tinyInfo,a1,a2,littleStrings); if(tinyInfo[5]!=-1) - a1->alloc(tinyInfo[5]+tinyInfo[4]+1,1); + a1->alloc(tinyInfo[7]+tinyInfo[6]+1,1); } /*! @@ -1512,20 +1823,20 @@ void MEDCouplingUMesh::serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const * Second and final unserialization process. * @param tinyInfo must be equal to the result given by getTinySerializationInformation method. */ -void MEDCouplingUMesh::unserialization(const std::vector& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, const std::vector& littleStrings) +void MEDCouplingUMesh::unserialization(const std::vector& tinyInfoD, const std::vector& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, const std::vector& littleStrings) { - MEDCouplingPointSet::unserialization(tinyInfo,a1,a2,littleStrings); - setMeshDimension(tinyInfo[3]); - if(tinyInfo[5]!=-1) + MEDCouplingPointSet::unserialization(tinyInfoD,tinyInfo,a1,a2,littleStrings); + setMeshDimension(tinyInfo[5]); + if(tinyInfo[7]!=-1) { // Connectivity const int *recvBuffer=a1->getConstPointer(); DataArrayInt* myConnecIndex=DataArrayInt::New(); - myConnecIndex->alloc(tinyInfo[4]+1,1); - std::copy(recvBuffer,recvBuffer+tinyInfo[4]+1,myConnecIndex->getPointer()); + myConnecIndex->alloc(tinyInfo[6]+1,1); + std::copy(recvBuffer,recvBuffer+tinyInfo[6]+1,myConnecIndex->getPointer()); DataArrayInt* myConnec=DataArrayInt::New(); - myConnec->alloc(tinyInfo[5],1); - std::copy(recvBuffer+tinyInfo[4]+1,recvBuffer+tinyInfo[4]+1+tinyInfo[5],myConnec->getPointer()); + myConnec->alloc(tinyInfo[7],1); + std::copy(recvBuffer+tinyInfo[6]+1,recvBuffer+tinyInfo[6]+1+tinyInfo[7],myConnec->getPointer()); setConnectivity(myConnec, myConnecIndex) ; myConnec->decrRef(); myConnecIndex->decrRef(); @@ -1541,17 +1852,6 @@ MEDCouplingUMesh *MEDCouplingUMesh::buildPartOfMySelfKeepCoords(const int *begin { checkFullyDefined(); MEDCouplingUMesh *ret=MEDCouplingUMesh::New(); - std::string name(getName()); - int sz=strlen(PART_OF_NAME); - if((int)name.length()>=sz) - name=name.substr(0,sz); - if(name!=PART_OF_NAME) - { - std::ostringstream stream; stream << PART_OF_NAME << getName(); - ret->setName(stream.str().c_str()); - } - else - ret->setName(getName()); ret->_mesh_dim=_mesh_dim; ret->setCoords(_coords); int nbOfElemsRet=end-begin; @@ -1578,6 +1878,18 @@ MEDCouplingUMesh *MEDCouplingUMesh::buildPartOfMySelfKeepCoords(const int *begin ret->_types=types; connRetArr->decrRef(); connIndexRetArr->decrRef(); + ret->copyTinyInfoFrom(this); + std::string name(getName()); + int sz=strlen(PART_OF_NAME); + if((int)name.length()>=sz) + name=name.substr(0,sz); + if(name!=PART_OF_NAME) + { + std::ostringstream stream; stream << PART_OF_NAME << getName(); + ret->setName(stream.str().c_str()); + } + else + ret->setName(getName()); return ret; } @@ -1627,6 +1939,43 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::getMeasureField(bool isAbs) const return field; } +/*! + * This method is equivalent to MEDCouplingUMesh::getMeasureField except that only part defined by [begin,end) is returned ! + * This method avoids to build explicitely part of this to perform the work. + */ +DataArrayDouble *MEDCouplingUMesh::getPartMeasureField(bool isAbs, const int *begin, const int *end) const +{ + std::string name="PartMeasureOfMesh_"; + name+=getName(); + int nbelem=std::distance(begin,end); + DataArrayDouble* array=DataArrayDouble::New(); + array->setName(name.c_str()); + array->alloc(nbelem,1); + double *area_vol=array->getPointer(); + if(getMeshDimension()!=-1) + { + int ipt; + INTERP_KERNEL::NormalizedCellType type; + int dim_space=getSpaceDimension(); + const double *coords=getCoords()->getConstPointer(); + const int *connec=getNodalConnectivity()->getConstPointer(); + const int *connec_index=getNodalConnectivityIndex()->getConstPointer(); + for(const int *iel=begin;iel!=end;iel++) + { + ipt=connec_index[*iel]; + type=(INTERP_KERNEL::NormalizedCellType)connec[ipt]; + *area_vol++=INTERP_KERNEL::computeVolSurfOfCell2(type,connec+ipt+1,connec_index[*iel+1]-ipt-1,coords,dim_space); + } + if(isAbs) + std::transform(array->getPointer(),area_vol,array->getPointer(),std::ptr_fun(fabs)); + } + else + { + area_vol[0]=std::numeric_limits::max(); + } + return array; +} + /*! * This methods returns a field on nodes and no time. This method is usefull to check "P1*" conservative interpolators. * This field returns the getMeasureField of the dualMesh in P1 sens of 'this'. @@ -1667,35 +2016,109 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::getMeasureFieldOnNode(bool isAbs) cons */ MEDCouplingFieldDouble *MEDCouplingUMesh::buildOrthogonalField() const { - if(getMeshDimension()!=2) - throw INTERP_KERNEL::Exception("Expected a umesh with meshDim == 2 !"); + if((getMeshDimension()!=2) && (getMeshDimension()!=1 || getSpaceDimension()!=2)) + throw INTERP_KERNEL::Exception("Expected a umesh with ( meshDim == 2 spaceDim == 2 or 3 ) or ( meshDim == 1 spaceDim == 2 ) !"); MEDCouplingFieldDouble *ret=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME); DataArrayDouble *array=DataArrayDouble::New(); int nbOfCells=getNumberOfCells(); - array->alloc(nbOfCells,3); + int nbComp=getMeshDimension()+1; + array->alloc(nbOfCells,nbComp); double *vals=array->getPointer(); const int *connI=_nodal_connec_index->getConstPointer(); const int *conn=_nodal_connec->getConstPointer(); const double *coords=_coords->getConstPointer(); - DataArrayDouble *loc=getBarycenterAndOwner(); - const double *locPtr=loc->getConstPointer(); - if(getSpaceDimension()==3) + if(getMeshDimension()==2) { - for(int i=0;i(locPtr+3*i,coords+3*conn[offset+1],coords+3*conn[offset+2],vals); - double n=INTERP_KERNEL::norm<3>(vals); - std::transform(vals,vals+3,vals,std::bind2nd(std::multiplies(),1./n)); + DataArrayDouble *loc=getBarycenterAndOwner(); + const double *locPtr=loc->getConstPointer(); + for(int i=0;i(locPtr+3*i,coords+3*conn[offset+1],coords+3*conn[offset+2],vals); + double n=INTERP_KERNEL::norm<3>(vals); + std::transform(vals,vals+3,vals,std::bind2nd(std::multiplies(),1./n)); + } + loc->decrRef(); + } + else + { + for(int i=0;i()); + double n=INTERP_KERNEL::norm<2>(tmp); + std::transform(tmp,tmp+2,tmp,std::bind2nd(std::multiplies(),1./n)); + *vals++=-tmp[1]; + *vals++=tmp[0]; + } + } + ret->setArray(array); + array->decrRef(); + ret->setMesh(this); + return ret; +} + +/*! + * This method is equivalent to MEDCouplingUMesh::buildOrthogonalField except that only part defined by [begin,end) is returned ! + * This method avoids to build explicitely part of this to perform the work. + */ +MEDCouplingFieldDouble *MEDCouplingUMesh::buildPartOrthogonalField(const int *begin, const int *end) const +{ + if((getMeshDimension()!=2) && (getMeshDimension()!=1 || getSpaceDimension()!=2)) + throw INTERP_KERNEL::Exception("Expected a umesh with ( meshDim == 2 spaceDim == 2 or 3 ) or ( meshDim == 1 spaceDim == 2 ) !"); + MEDCouplingFieldDouble *ret=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME); + DataArrayDouble *array=DataArrayDouble::New(); + int nbelems=std::distance(begin,end); + int nbComp=getMeshDimension()+1; + array->alloc(nbelems,nbComp); + double *vals=array->getPointer(); + const int *connI=_nodal_connec_index->getConstPointer(); + const int *conn=_nodal_connec->getConstPointer(); + const double *coords=_coords->getConstPointer(); + if(getMeshDimension()==2) + { + if(getSpaceDimension()==3) + { + DataArrayDouble *loc=getPartBarycenterAndOwner(begin,end); + const double *locPtr=loc->getConstPointer(); + for(const int *i=begin;i!=end;i++,vals+=3,locPtr+=3) + { + int 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); + std::transform(vals,vals+3,vals,std::bind2nd(std::multiplies(),1./n)); + } + loc->decrRef(); + } + else + { + for(int i=0;i()); + double n=INTERP_KERNEL::norm<2>(tmp); + std::transform(tmp,tmp+2,tmp,std::bind2nd(std::multiplies(),1./n)); + *vals++=-tmp[1]; + *vals++=tmp[0]; + } } ret->setArray(array); - loc->decrRef(); array->decrRef(); ret->setMesh(this); return ret; @@ -1733,18 +2156,44 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::buildDirectionVectorField() const } /*! - * This method is only callable on mesh with meshdim == 1 containing only SEG2 and spaceDim==3. - * This method projects this on the 3D line defined by (pt,v). This methods first checks that all SEG2 are along v vector. - * @param pt reference point of the line - * @param v normalized director vector of the line - * @param eps max precision before throwing an exception - * @param res output of size this->getNumberOfCells + * This method checks that 'this' is a contiguous mesh. The user is expected to call this method on a mesh with meshdim==1. + * If not an exception will thrown. If this is an empty mesh with no cell an exception will be thrown too. + * No consideration of coordinate is done by this method. + * A 1D mesh is said contiguous if : a cell i with nodal connectivity (k,p) the cell i+1 the nodal connectivity should be (p,m) + * If not false is returned. In case that false is returned a call to ParaMEDMEM::MEDCouplingUMesh::mergeNodes could be usefull. */ -void MEDCouplingUMesh::project1D(const double *pt, const double *v, double eps, double *res) const +bool MEDCouplingUMesh::isContiguous1D() const throw(INTERP_KERNEL::Exception) { if(getMeshDimension()!=1) - throw INTERP_KERNEL::Exception("Expected a umesh with meshDim == 1 for project1D !"); - if(_types.size()!=1 || *(_types.begin())!=INTERP_KERNEL::NORM_SEG2) + throw INTERP_KERNEL::Exception("MEDCouplingUMesh::isContiguous1D : this method has a sense only for 1D mesh !"); + int nbCells=getNumberOfCells(); + if(nbCells<1) + throw INTERP_KERNEL::Exception("MEDCouplingUMesh::isContiguous1D : this method has a sense for non empty mesh !"); + const int *connI=_nodal_connec_index->getConstPointer(); + const int *conn=_nodal_connec->getConstPointer(); + int ref=conn[connI[0]+2]; + for(int i=1;igetNumberOfCells + */ +void MEDCouplingUMesh::project1D(const double *pt, const double *v, double eps, double *res) const +{ + if(getMeshDimension()!=1) + throw INTERP_KERNEL::Exception("Expected a umesh with meshDim == 1 for project1D !"); + if(_types.size()!=1 || *(_types.begin())!=INTERP_KERNEL::NORM_SEG2) throw INTERP_KERNEL::Exception("Expected a umesh with only NORM_SEG2 type of elements for project1D !"); if(getSpaceDimension()!=3) throw INTERP_KERNEL::Exception("Expected a umesh with spaceDim==3 for project1D !"); @@ -1778,6 +2227,8 @@ void MEDCouplingUMesh::project1D(const double *pt, const double *v, double eps, /*! * Returns a cell if any that contains the point located on 'pos' with precison eps. * If 'pos' is outside 'this' -1 is returned. If several cells contain this point the cell with the smallest id is returned. + * \b Warning this method is good if the caller intends to evaluate only one point. But if more than one point is requested on 'this' + * it is better to use MEDCouplingUMesh::getCellsContainingPoints method because in this case, the acceleration structure will be computed only once. */ int MEDCouplingUMesh::getCellContainingPoint(const double *pos, double eps) const { @@ -1790,6 +2241,8 @@ int MEDCouplingUMesh::getCellContainingPoint(const double *pos, double eps) cons /*! * Returns all cellIds in 'elts' of point 'pos' with eps accuracy. + * \b Warning this method is good if the caller intends to evaluate only one point. But if more than one point is requested on 'this' + * it is better to use MEDCouplingUMesh::getCellsContainingPoints method because in this case, the acceleration structure will be computed only once. */ void MEDCouplingUMesh::getCellsContainingPoint(const double *pos, double eps, std::vector& elts) const { @@ -1830,16 +2283,14 @@ void MEDCouplingUMesh::getCellsContainingPointsAlg(const double *coords, const d const int *conn=_nodal_connec->getConstPointer(); const int *connI=_nodal_connec_index->getConstPointer(); double bb[2*SPACEDIM]; - for(int j=0;j::max(); bb[2*j+1]=-std::numeric_limits::max(); } BBTree myTree(&bbox[0],0,0,nbOfCells,-eps); for(int i=0;i candidates; myTree.getIntersectingElems(bb,candidates); @@ -1857,6 +2308,15 @@ void MEDCouplingUMesh::getCellsContainingPointsAlg(const double *coords, const d } } +/*! + * This method is an extension of MEDCouplingUMesh::getCellContainingPoint and MEDCouplingUMesh::getCellsContainingPoint. + * This method performs 'nbOfPoints' time the getCellsContainingPoint request. This method is recommended rather than the 2 others + * in case of multi points searching. + * This method returns 2 arrays 'elts' and 'eltsIndex'. 'eltsIndex' is of size 'nbOfPoints+1' and 'elts' is of size 'eltsIndex[nbOfPoints-1]'. + * For point j in [0,nbOfPoints), (eltsIndex[j+1]-eltsIndex[j]) cells contain this point. These cells are : [elts.begin()+eltsIndex[j],elts.begin():eltsIndex[j+1]). + * + * \param pos input parameter that points to an array of size 'getSpaceDim()*nbOfPoints' points stored in full interlace mode : X0,Y0,Z0,X1,Y1,Z1... + */ void MEDCouplingUMesh::getCellsContainingPoints(const double *pos, int nbOfPoints, double eps, std::vector& elts, std::vector& eltsIndex) const { @@ -1886,9 +2346,6 @@ void MEDCouplingUMesh::getCellsContainingPoints(const double *pos, int nbOfPoint else throw INTERP_KERNEL::Exception("For spaceDim==2 only meshDim==2 implemented for getelementscontainingpoints !"); } - - - } /*! @@ -1915,7 +2372,7 @@ void MEDCouplingUMesh::checkButterflyCells(std::vector& cells) const int nbOfNodesForCell=connI[i+1]-offset-1; if(nbOfNodesForCell<=3) continue; - bool isQuad=INTERP_KERNEL::CellModel::getCellModel((INTERP_KERNEL::NormalizedCellType)conn[offset]).isQuadratic(); + bool isQuad=INTERP_KERNEL::CellModel::GetCellModel((INTERP_KERNEL::NormalizedCellType)conn[offset]).isQuadratic(); project2DCellOnXY(conn+offset+1,conn+connI[i+1],cell2DinS2); if(isButterfly2DCell(cell2DinS2,isQuad)) cells.push_back(i); @@ -1931,14 +2388,18 @@ void MEDCouplingUMesh::checkButterflyCells(std::vector& cells) const * \b 1 for translation and rotation around point of 'mesh1D'. * @return an unstructured mesh with meshDim==3 and spaceDim==3. The returned mesh has the same coords than 'this'. */ -MEDCouplingUMesh *MEDCouplingUMesh::buildExtrudedMeshFromThis(const MEDCouplingUMesh *mesh1D, int policy) +MEDCouplingUMesh *MEDCouplingUMesh::buildExtrudedMesh(const MEDCouplingUMesh *mesh1D, int policy) { checkFullyDefined(); mesh1D->checkFullyDefined(); - if(getMeshDimension()!=2 || getSpaceDimension()!=3) - throw INTERP_KERNEL::Exception("Invalid 'this' for buildExtrudedMeshFromThis method : must be meshDim==2 and spaceDim ==3 !"); - if(mesh1D->getMeshDimension()!=1 || mesh1D->getSpaceDimension()!=3) - throw INTERP_KERNEL::Exception("Invalid 'mesh1D' for buildExtrudedMeshFromThis method : must be meshDim==1 and spaceDim ==3 !"); + if(!mesh1D->isContiguous1D()) + throw INTERP_KERNEL::Exception("buildExtrudedMesh : 1D mesh passed in parameter is not contiguous !"); + if(getSpaceDimension()!=mesh1D->getSpaceDimension()) + throw INTERP_KERNEL::Exception("Invalid call to buildExtrudedMesh this and mesh1D must have same dimension !"); + if((getMeshDimension()!=2 || getSpaceDimension()!=3) && (getMeshDimension()!=1 || getSpaceDimension()!=2)) + throw INTERP_KERNEL::Exception("Invalid 'this' for buildExtrudedMesh method : must be (meshDim==2 and spaceDim==3) or (meshDim==1 and spaceDim==2) !"); + if(mesh1D->getMeshDimension()!=1) + throw INTERP_KERNEL::Exception("Invalid 'mesh1D' for buildExtrudedMesh method : must be meshDim==1 !"); bool isQuad=false; if(isPresenceOfQuadratic()) { @@ -1957,6 +2418,11 @@ MEDCouplingUMesh *MEDCouplingUMesh::buildExtrudedMeshFromThis(const MEDCouplingU newCoords=fillExtCoordsUsingTranslation(mesh1D,isQuad); break; } + case 1: + { + newCoords=fillExtCoordsUsingTranslAndAutoRotation(mesh1D,isQuad); + break; + } default: throw INTERP_KERNEL::Exception("Not implemented extrusion policy : must be in (0) !"); } @@ -1968,7 +2434,7 @@ MEDCouplingUMesh *MEDCouplingUMesh::buildExtrudedMeshFromThis(const MEDCouplingU } /*! - * This method incarnates the policy 0 for MEDCouplingUMesh::buildExtrudedMeshFromThis method. + * This method incarnates the policy 0 for MEDCouplingUMesh::buildExtrudedMesh method. * @param mesh1D is the input 1D mesh used for translation computation. * @return newCoords new coords filled by this method. */ @@ -1976,13 +2442,14 @@ DataArrayDouble *MEDCouplingUMesh::fillExtCoordsUsingTranslation(const MEDCoupli { int oldNbOfNodes=getNumberOfNodes(); int nbOf1DCells=mesh1D->getNumberOfCells(); + int spaceDim=getSpaceDimension(); DataArrayDouble *ret=DataArrayDouble::New(); std::vector isQuads; int nbOfLevsInVec=isQuad?2*nbOf1DCells+1:nbOf1DCells+1; - ret->alloc(oldNbOfNodes*nbOfLevsInVec,3); + ret->alloc(oldNbOfNodes*nbOfLevsInVec,spaceDim); double *retPtr=ret->getPointer(); const double *coords=getCoords()->getConstPointer(); - double *work=std::copy(coords,coords+3*oldNbOfNodes,retPtr); + double *work=std::copy(coords,coords+spaceDim*oldNbOfNodes,retPtr); std::vector v; std::vector c; double vec[3]; @@ -1995,26 +2462,155 @@ DataArrayDouble *MEDCouplingUMesh::fillExtCoordsUsingTranslation(const MEDCoupli c.resize(0); mesh1D->getCoordinatesOfNode(v[isQuad?2:1],c); mesh1D->getCoordinatesOfNode(v[0],c); - std::transform(c.begin(),c.begin()+3,c.begin()+3,vec,std::minus()); + std::transform(c.begin(),c.begin()+spaceDim,c.begin()+spaceDim,vec,std::minus()); for(int j=0;j()); + work=std::transform(vec,vec+spaceDim,retPtr+spaceDim*(i*oldNbOfNodes+j),work,std::plus()); if(isQuad) { c.resize(0); mesh1D->getCoordinatesOfNode(v[1],c); mesh1D->getCoordinatesOfNode(v[0],c); - std::transform(c.begin(),c.begin()+3,c.begin()+3,vec,std::minus()); + std::transform(c.begin(),c.begin()+spaceDim,c.begin()+spaceDim,vec,std::minus()); for(int j=0;j()); + work=std::transform(vec,vec+spaceDim,retPtr+spaceDim*(i*oldNbOfNodes+j),work,std::plus()); } } ret->copyStringInfoFrom(*getCoords()); return ret; } +/*! + * This method incarnates the policy 1 for MEDCouplingUMesh::buildExtrudedMesh method. + * @param mesh1D is the input 1D mesh used for translation and automatic rotation computation. + * @return newCoords new coords filled by this method. + */ +DataArrayDouble *MEDCouplingUMesh::fillExtCoordsUsingTranslAndAutoRotation(const MEDCouplingUMesh *mesh1D, bool isQuad) const throw(INTERP_KERNEL::Exception) +{ + if(mesh1D->getSpaceDimension()==2) + return fillExtCoordsUsingTranslAndAutoRotation2D(mesh1D,isQuad); + if(mesh1D->getSpaceDimension()==3) + return fillExtCoordsUsingTranslAndAutoRotation3D(mesh1D,isQuad); + throw INTERP_KERNEL::Exception("Not implemented rotation and translation alg. for spacedim other than 2 and 3 !"); +} + +/*! + * This method incarnates the policy 1 for MEDCouplingUMesh::buildExtrudedMesh method. + * @param mesh1D is the input 1D mesh used for translation and automatic rotation computation. + * @return newCoords new coords filled by this method. + */ +DataArrayDouble *MEDCouplingUMesh::fillExtCoordsUsingTranslAndAutoRotation2D(const MEDCouplingUMesh *mesh1D, bool isQuad) const throw(INTERP_KERNEL::Exception) +{ + if(isQuad) + throw INTERP_KERNEL::Exception("MEDCouplingUMesh::fillExtCoordsUsingTranslAndAutoRotation2D : not implemented for quadratic cells !"); + int oldNbOfNodes=getNumberOfNodes(); + int nbOf1DCells=mesh1D->getNumberOfCells(); + if(nbOf1DCells<2) + throw INTERP_KERNEL::Exception("MEDCouplingUMesh::fillExtCoordsUsingTranslAndAutoRotation2D : impossible to detect any angle of rotation ! Change extrusion policy 1->0 !"); + DataArrayDouble *ret=DataArrayDouble::New(); + int nbOfLevsInVec=nbOf1DCells+1; + ret->alloc(oldNbOfNodes*nbOfLevsInVec,2); + double *retPtr=ret->getPointer(); + retPtr=std::copy(getCoords()->getConstPointer(),getCoords()->getConstPointer()+getCoords()->getNbOfElems(),retPtr); + MEDCouplingUMesh *tmp=MEDCouplingUMesh::New(); + DataArrayDouble *tmp2=getCoords()->deepCpy(); + tmp->setCoords(tmp2); + tmp2->decrRef(); + const double *coo1D=mesh1D->getCoords()->getConstPointer(); + const int *conn1D=mesh1D->getNodalConnectivity()->getConstPointer(); + const int *connI1D=mesh1D->getNodalConnectivityIndex()->getConstPointer(); + for(int i=1;itranslate(vec); + double tmp3[2],radius,alpha,alpha0; + const double *p0=i+1rotate(end,0,angle); + retPtr=std::copy(tmp2->getConstPointer(),tmp2->getConstPointer()+tmp2->getNbOfElems(),retPtr); + } + tmp->decrRef(); + return ret; +} + +/*! + * This method incarnates the policy 1 for MEDCouplingUMesh::buildExtrudedMesh method. + * @param mesh1D is the input 1D mesh used for translation and automatic rotation computation. + * @return newCoords new coords filled by this method. + */ +DataArrayDouble *MEDCouplingUMesh::fillExtCoordsUsingTranslAndAutoRotation3D(const MEDCouplingUMesh *mesh1D, bool isQuad) const throw(INTERP_KERNEL::Exception) +{ + if(isQuad) + throw INTERP_KERNEL::Exception("MEDCouplingUMesh::fillExtCoordsUsingTranslAndAutoRotation3D : not implemented for quadratic cells !"); + int oldNbOfNodes=getNumberOfNodes(); + int nbOf1DCells=mesh1D->getNumberOfCells(); + if(nbOf1DCells<2) + throw INTERP_KERNEL::Exception("MEDCouplingUMesh::fillExtCoordsUsingTranslAndAutoRotation3D : impossible to detect any angle of rotation ! Change extrusion policy 1->0 !"); + DataArrayDouble *ret=DataArrayDouble::New(); + int nbOfLevsInVec=nbOf1DCells+1; + ret->alloc(oldNbOfNodes*nbOfLevsInVec,3); + double *retPtr=ret->getPointer(); + retPtr=std::copy(getCoords()->getConstPointer(),getCoords()->getConstPointer()+getCoords()->getNbOfElems(),retPtr); + MEDCouplingUMesh *tmp=MEDCouplingUMesh::New(); + DataArrayDouble *tmp2=getCoords()->deepCpy(); + tmp->setCoords(tmp2); + tmp2->decrRef(); + const double *coo1D=mesh1D->getCoords()->getConstPointer(); + const int *conn1D=mesh1D->getNodalConnectivity()->getConstPointer(); + const int *connI1D=mesh1D->getNodalConnectivityIndex()->getConstPointer(); + for(int i=1;itranslate(vec); + double tmp3[2],radius,alpha,alpha0; + const double *p0=i+11.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 c2=cos(asin(s2)); + double 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} + }; + double p0r[3]={m[0][0]*p0[0]+m[0][1]*p0[1]+m[0][2]*p0[2], m[1][0]*p0[0]+m[1][1]*p0[1]+m[1][2]*p0[2], m[2][0]*p0[0]+m[2][1]*p0[1]+m[2][2]*p0[2]}; + 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); + } + tmp->decrRef(); + return ret; +} + /*! * This method is private because not easy to use for end user. This method is const contrary to - * MEDCouplingUMesh::buildExtrudedMeshFromThis method because this->_coords are expected to contain + * MEDCouplingUMesh::buildExtrudedMesh method because this->_coords are expected to contain * the coords sorted slice by slice. * @param isQuad specifies presence of quadratic cells. */ @@ -2023,7 +2619,7 @@ MEDCouplingUMesh *MEDCouplingUMesh::buildExtrudedMeshFromThisLowLev(int nbOfNode int nbOf1DCells=getNumberOfNodes()/nbOfNodesOf1Lev-1; int nbOf2DCells=getNumberOfCells(); int nbOf3DCells=nbOf2DCells*nbOf1DCells; - MEDCouplingUMesh *ret=MEDCouplingUMesh::New("Extruded",3); + MEDCouplingUMesh *ret=MEDCouplingUMesh::New("Extruded",getMeshDimension()+1); const int *conn=_nodal_connec->getConstPointer(); const int *connI=_nodal_connec_index->getConstPointer(); DataArrayInt *newConn=DataArrayInt::New(); @@ -2077,7 +2673,7 @@ bool MEDCouplingUMesh::isFullyQuadratic() const for(int i=0;i= 1 !"); + int nbCells=getNumberOfCells(); + const int *conn=_nodal_connec->getConstPointer(); + const int *connI=_nodal_connec_index->getConstPointer(); + for(int i=0;ialloc(nbOfCells+nbOfCutCells,1); + if(nbOfCutCells==0) + { + ret->iota(0); + return ret; + } + int *retPt=ret->getPointer(); + DataArrayInt *newConn=DataArrayInt::New(); + DataArrayInt *newConnI=DataArrayInt::New(); + newConnI->alloc(nbOfCells+nbOfCutCells+1,1); + newConn->alloc(getMeshLength()+3*nbOfCutCells,1); + int *pt=newConn->getPointer(); + int *ptI=newConnI->getPointer(); + ptI[0]=0; + const int *oldc=_nodal_connec->getConstPointer(); + const int *ci=_nodal_connec_index->getConstPointer(); + for(int i=0;idecrRef(); + _nodal_connec=newConn; + _nodal_connec_index->decrRef(); + _nodal_connec_index=newConnI; + computeTypes(); + updateTime(); + return ret; +} + +/*! + * This method implements policy 1 of virtual method ParaMEDMEM::MEDCouplingUMesh::simplexize. + */ +DataArrayInt *MEDCouplingUMesh::simplexizePol1() throw(INTERP_KERNEL::Exception) +{ + if(getMeshDimension()!=2) + throw INTERP_KERNEL::Exception("MEDCouplingUMesh::simplexizePol0 : this policy is only available for mesh with meshdim == 2 !"); + int nbOfCells=getNumberOfCells(); + DataArrayInt *ret=DataArrayInt::New(); + int nbOfCutCells=getNumberOfCellsWithType(INTERP_KERNEL::NORM_QUAD4); + ret->alloc(nbOfCells+nbOfCutCells,1); + if(nbOfCutCells==0) + { + ret->iota(0); + return ret; + } + int *retPt=ret->getPointer(); + DataArrayInt *newConn=DataArrayInt::New(); + DataArrayInt *newConnI=DataArrayInt::New(); + newConnI->alloc(nbOfCells+nbOfCutCells+1,1); + newConn->alloc(getMeshLength()+3*nbOfCutCells,1); + int *pt=newConn->getPointer(); + int *ptI=newConnI->getPointer(); + ptI[0]=0; + const int *oldc=_nodal_connec->getConstPointer(); + const int *ci=_nodal_connec_index->getConstPointer(); + for(int i=0;idecrRef(); + _nodal_connec=newConn; + _nodal_connec_index->decrRef(); + _nodal_connec_index=newConnI; + computeTypes(); + updateTime(); + return ret; +} + + +/*! + * This method converts all degenerated cells to simpler cells. For example a NORM_QUAD4 cell consituted from 2 same node id in its + * nodal connectivity will be transform to a NORM_TRI3 cell. + * This method works \b only \b on \b linear cells. + * This method works on nodes ids, that is to say a call to ParaMEDMEM::MEDCouplingUMesh::mergeNodes + * method could be usefull before calling this method in case of presence of several pair of nodes located on same position. + * This method throws an exception if 'this' is not fully defined (connectivity). + * This method throws an exception too if a "too" degenerated cell is detected. For example a NORM_TRI3 with 3 times the same node id. + */ +void MEDCouplingUMesh::convertDegeneratedCells() throw(INTERP_KERNEL::Exception) +{ + checkFullyDefined(); + if(getMeshDimension()<=1) + throw INTERP_KERNEL::Exception("MEDCouplingUMesh::convertDegeneratedCells works on umeshes with meshdim equals to 2 or 3 !"); + int nbOfCells=getNumberOfCells(); + if(nbOfCells<1) + return ; + int initMeshLgth=getMeshLength(); + int *conn=_nodal_connec->getPointer(); + int *index=_nodal_connec_index->getPointer(); + int posOfCurCell=0; + int newPos=0; + int lgthOfCurCell; + for(int i=0;ireAlloc(newPos); + computeTypes(); +} + /*! * This method checks that all or only polygons (depending 'polyOnly' parameter) 2D cells are correctly oriented relative to 'vec' vector. * The 'vec' vector has to have a non nul norm. @@ -2175,7 +2963,7 @@ void MEDCouplingUMesh::are2DCellsNotCorrectlyOriented(const double *vec, bool po INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)conn[connI[i]]; if(!polyOnly || type==INTERP_KERNEL::NORM_POLYGON) { - if(!isPolygonWellOriented(vec,conn+connI[i]+1,conn+connI[i+1],coordsPtr)) + if(!IsPolygonWellOriented(vec,conn+connI[i]+1,conn+connI[i+1],coordsPtr)) cells.push_back(i); } } @@ -2199,7 +2987,7 @@ void MEDCouplingUMesh::orientCorrectly2DCells(const double *vec, bool polyOnly) { INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)conn[connI[i]]; if(!polyOnly || type==INTERP_KERNEL::NORM_POLYGON) - if(!isPolygonWellOriented(vec,conn+connI[i]+1,conn+connI[i+1],coordsPtr)) + if(!IsPolygonWellOriented(vec,conn+connI[i]+1,conn+connI[i+1],coordsPtr)) { isModified=true; std::vector tmp(connI[i+1]-connI[i]-2); @@ -2230,7 +3018,7 @@ void MEDCouplingUMesh::arePolyhedronsNotCorrectlyOriented(std::vector& cell INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)conn[connI[i]]; if(type==INTERP_KERNEL::NORM_POLYHED) { - if(!isPolyhedronWellOriented(conn+connI[i]+1,conn+connI[i+1],coordsPtr)) + if(!IsPolyhedronWellOriented(conn+connI[i]+1,conn+connI[i+1],coordsPtr)) cells.push_back(i); } } @@ -2253,9 +3041,9 @@ void MEDCouplingUMesh::orientCorrectlyPolyhedrons() throw(INTERP_KERNEL::Excepti { INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)conn[connI[i]]; if(type==INTERP_KERNEL::NORM_POLYHED) - if(!isPolyhedronWellOriented(conn+connI[i]+1,conn+connI[i+1],coordsPtr)) + if(!IsPolyhedronWellOriented(conn+connI[i]+1,conn+connI[i+1],coordsPtr)) { - tryToCorrectPolyhedronOrientation(conn+connI[i]+1,conn+connI[i+1],coordsPtr); + TryToCorrectPolyhedronOrientation(conn+connI[i]+1,conn+connI[i+1],coordsPtr); isModified=true; } } @@ -2543,6 +3331,148 @@ namespace ParaMEDMEMImpl const int *_conn; int _val; }; + + class ConnReader2 + { + public: + ConnReader2(const int *c, int val):_conn(c),_val(val) { } + bool operator() (const int& pos) { return _conn[pos]==_val; } + private: + const int *_conn; + int _val; + }; +} + +/*! + * This method is used to check that this has contiguous cell type in same order than described in 'code'. + * Format of 'code' is the following. 'code' should be of size 3*n and non empty. If not an exception is thrown. + * foreach k in [0,n) on 3*k pos represent the geometric type and 3*k+1 number of elements of type 3*k. + * 3*k+2 refers if different from -1 the pos in 'idsPerType' to get the corresponding array. + * If 2 or more same geometric type is in 'code' and exception is thrown too. + * + * This method fistly checks + * If it exists k so that 3*k geometric type is not in geometric types of this an exception will be thrown. + * If it exists k so that 3*k geometric type exists but the number of consecutive cell types does not match, + * an exception is thrown too. + * + * If all geometric types in 'code' are exactly those in 'this' null pointer is returned. + * If it exists a geometric type in 'this' \b not in 'code' \b no exception is thrown and a DataArrayInt instance is returned that the user has the responsability + * to deallocate. + */ +DataArrayInt *MEDCouplingUMesh::checkTypeConsistencyAndContig(const std::vector& code, const std::vector& idsPerType) const throw(INTERP_KERNEL::Exception) +{ + if(code.empty()) + throw INTERP_KERNEL::Exception("MEDCouplingUMesh::checkTypeConsistencyAndContig : code is empty, should not !"); + int sz=code.size(); + std::size_t n=sz/3; + if(sz%3!=0) + throw INTERP_KERNEL::Exception("MEDCouplingUMesh::checkTypeConsistencyAndContig : code size is NOT %3 !"); + std::vector types; + int nb=0; + for(std::size_t i=0;ialloc(nb,1); + int *retPtr=ret->getPointer(); + const int *connI=_nodal_connec_index->getConstPointer(); + const int *conn=_nodal_connec->getConstPointer(); + int nbOfCells=getNumberOfCells(); + const int *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,ParaMEDMEMImpl::ConnReader2(conn,(int)(*it))); + int offset=std::distance(connI,i); + if(code[3*kk+2]==-1) + { + const int *j=std::find_if(i+1,connI+nbOfCells,ParaMEDMEMImpl::ConnReader(conn,(int)(*it))); + int pos2=std::distance(i,j); + for(int k=0;kgetConstPointer(),idsPerType[code[3*kk+2]]->getConstPointer()+idsPerType[code[3*kk+2]]->getNbOfElems(), + retPtr,std::bind2nd(std::plus(),offset)); + } + } + return ret; +} + +/*! + * This method is here too emulate the MEDMEM behaviour on BDC (buildDescendingConnectivity). Hoping this method becomes deprecated very soon. + * This method make the assumption that 'this' and 'nM1LevMesh' mesh lyies on same coords (same pointer) as MED and MEDMEM does. + * The following equality should be verified 'nM1LevMesh->getMeshDimension()==this->getMeshDimension()-1' + * This method returns 5+2 elements. 'desc', 'descIndx', 'revDesc', 'revDescIndx' and 'meshnM1' behaves exactly as ParaMEDMEM::MEDCouplingUMesh::buildDescendingConnectivity except the content as described after. The returned array specifies the n-1 mesh reordered by type as MEDMEM does. 'nM1LevMeshIds' contains the ids in returned 'meshnM1'. Finally 'meshnM1Old2New' contains numbering old2new that is to say the cell #k in coarse 'nM1LevMesh' will have the number ret[k] in returned mesh 'nM1LevMesh' MEDMEM reordered. + */ +MEDCouplingUMesh *MEDCouplingUMesh::emulateMEDMEMBDC(const MEDCouplingUMesh *nM1LevMesh, DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *&revDesc, DataArrayInt *&revDescIndx, DataArrayInt *& nM1LevMeshIds, DataArrayInt *&meshnM1Old2New) const throw(INTERP_KERNEL::Exception) +{ + checkFullyDefined(); + nM1LevMesh->checkFullyDefined(); + if(getMeshDimension()-1!=nM1LevMesh->getMeshDimension()) + throw INTERP_KERNEL::Exception("MEDCouplingUMesh::emulateMEDMEMBDC : The mesh passed as first argument should have a meshDim equal to this->getMeshDimension()-1 !" ); + if(_coords!=nM1LevMesh->getCoords()) + throw INTERP_KERNEL::Exception("MEDCouplingUMesh::emulateMEDMEMBDC : 'this' and mesh in first argument should share the same coords : Use tryToShareSameCoords method !"); + MEDCouplingAutoRefCountObjectPtr tmp0=DataArrayInt::New(); + MEDCouplingAutoRefCountObjectPtr tmp1=DataArrayInt::New(); + MEDCouplingAutoRefCountObjectPtr ret1=buildDescendingConnectivity(desc,descIndx,tmp0,tmp1); + MEDCouplingAutoRefCountObjectPtr ret0=ret1->sortCellsInMEDFileFrmt(); + desc->transformWithIndArr(ret0->getConstPointer(),ret0->getConstPointer()+ret0->getNbOfElems()); + MEDCouplingAutoRefCountObjectPtr tmp=MEDCouplingUMesh::New(); + tmp->setConnectivity(tmp0,tmp1); + tmp->renumberCells(ret0->getConstPointer(),false); + revDesc=tmp->getNodalConnectivity(); + revDescIndx=tmp->getNodalConnectivityIndex(); + DataArrayInt *ret=0; + if(!ret1->areCellsIncludedIn(nM1LevMesh,2,ret)) + { + int tmp; + ret->getMaxValue(tmp); + ret->decrRef(); + std::ostringstream oss; oss << "MEDCouplingUMesh::emulateMEDMEMBDC : input N-1 mesh present a cell not in descending mesh ... Id of cell is " << tmp << " !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + nM1LevMeshIds=ret; + // + revDesc->incrRef(); + revDescIndx->incrRef(); + ret1->incrRef(); + ret0->incrRef(); + meshnM1Old2New=ret0; + return ret1; +} + +/*! + * This method sorts cell in this so that cells are sorted by cell type specified by MEDMEM and so for MED file. + * It avoids to deal with renum in MEDLoader so it is usefull for MED file R/W with multi types. + * This method returns a newly allocated array old2New. + * This method expects that connectivity of this is set. If not an exception will be thrown. Coordinates are not taken into account. + */ +DataArrayInt *MEDCouplingUMesh::sortCellsInMEDFileFrmt() throw(INTERP_KERNEL::Exception) +{ + static const int N=18; + static const INTERP_KERNEL::NormalizedCellType MEDMEM_ORDER[N] = { INTERP_KERNEL::NORM_POINT1, INTERP_KERNEL::NORM_SEG2, INTERP_KERNEL::NORM_SEG3, INTERP_KERNEL::NORM_TRI3, INTERP_KERNEL::NORM_QUAD4, INTERP_KERNEL::NORM_TRI6, INTERP_KERNEL::NORM_QUAD8, INTERP_KERNEL::NORM_TETRA4, INTERP_KERNEL::NORM_PYRA5, INTERP_KERNEL::NORM_PENTA6, INTERP_KERNEL::NORM_HEXA8, INTERP_KERNEL::NORM_HEXGP12, INTERP_KERNEL::NORM_TETRA10, INTERP_KERNEL::NORM_PYRA13, INTERP_KERNEL::NORM_PENTA15, INTERP_KERNEL::NORM_HEXA20, INTERP_KERNEL::NORM_POLYGON, INTERP_KERNEL::NORM_POLYHED }; + checkConnectivityFullyDefined(); + MEDCouplingAutoRefCountObjectPtr ret=getRenumArrForConsecutiveCellTypesSpec(MEDMEM_ORDER,MEDMEM_ORDER+N); + renumberCells(ret->getConstPointer(),false); + ret->incrRef(); + return ret; } /*! @@ -2591,46 +3521,58 @@ bool MEDCouplingUMesh::checkConsecutiveCellTypesAndOrder(const INTERP_KERNEL::No } /*! - * This method is similar to method MEDCouplingUMesh::rearrange2ConsecutiveCellTypes except that the type order is specfied by [orderBg,orderEnd) (as MEDCouplingUMesh::checkConsecutiveCellTypesAndOrder method) and that this method is \b const and performs \b NO permutation is 'this'. - * This method returns an array of size getNumberOfCells() that gives a renumber array old2New that can be used as input of MEDCouplingMesh::renumberCells. - * The mesh after this call will pass the test of MEDCouplingUMesh::checkConsecutiveCellTypesAndOrder with the same inputs. - * The returned array minimizes the permutations that is to say the order of cells inside same geometric type remains the same. + * This method returns 2 newly allocated DataArrayInt instances. The first is an array of size 'this->getNumberOfCells()' with one component, + * that tells for each cell the pos of its type in the array on type given in input parameter. The 2nd output parameter is an array with the same + * number of tuples than input type array and with one component. This 2nd output array gives type by type the number of occurence of type in 'this'. */ -DataArrayInt *MEDCouplingUMesh::getRenumArrForConsecutiveCellTypesSpec(const INTERP_KERNEL::NormalizedCellType *orderBg, const INTERP_KERNEL::NormalizedCellType *orderEnd) const +DataArrayInt *MEDCouplingUMesh::getLevArrPerCellTypes(const INTERP_KERNEL::NormalizedCellType *orderBg, const INTERP_KERNEL::NormalizedCellType *orderEnd, DataArrayInt *&nbPerType) const throw(INTERP_KERNEL::Exception) { - checkFullyDefined(); + checkConnectivityFullyDefined(); int nbOfCells=getNumberOfCells(); const int *conn=_nodal_connec->getConstPointer(); const int *connI=_nodal_connec_index->getConstPointer(); - int *tmp=new int[nbOfCells]; - int minPos=std::numeric_limits::max(); + MEDCouplingAutoRefCountObjectPtr tmpa=DataArrayInt::New(); + MEDCouplingAutoRefCountObjectPtr tmpb=DataArrayInt::New(); + tmpa->alloc(nbOfCells,1); + tmpb->alloc(std::distance(orderBg,orderEnd),1); + tmpb->fillWithZero(); + int *tmp=tmpa->getPointer(); + int *tmp2=tmpb->getPointer(); for(const int *i=connI;i!=connI+nbOfCells;i++) { - int pos=std::distance(orderBg,std::find(orderBg,orderEnd,(INTERP_KERNEL::NormalizedCellType)conn[*i])); - tmp[std::distance(connI,i)]=pos; - minPos=std::min(minPos,pos); - } - DataArrayInt *ret=DataArrayInt::New(); - ret->alloc(nbOfCells,1); - int *optr=ret->getPointer(); - int k=0; - while(minPos!=std::numeric_limits::max()) - { - int nextMinPos=std::numeric_limits::max(); - for(int j=0;j::max(); - } - else - nextMinPos=std::min(nextMinPos,tmp[j]); + int pos=std::distance(orderBg,where); + tmp2[pos]++; + tmp[std::distance(connI,i)]=pos; + } + else + { + const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel((INTERP_KERNEL::NormalizedCellType)conn[*i]); + std::ostringstream oss; oss << "MEDCouplingUMesh::getLevArrPerCellTypes : Cell #" << std::distance(connI,i); + oss << " has a type " << cm.getRepr() << " not in input array of type !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); } - minPos=nextMinPos; } - delete [] tmp; - return ret; + nbPerType=tmpb; + tmpa->incrRef(); + tmpb->incrRef(); + return tmpa; +} + +/*! + * This method is similar to method MEDCouplingUMesh::rearrange2ConsecutiveCellTypes except that the type order is specfied by [orderBg,orderEnd) (as MEDCouplingUMesh::checkConsecutiveCellTypesAndOrder method) and that this method is \b const and performs \b NO permutation in 'this'. + * This method returns an array of size getNumberOfCells() that gives a renumber array old2New that can be used as input of MEDCouplingMesh::renumberCells. + * The mesh after this call to MEDCouplingMesh::renumberCells will pass the test of MEDCouplingUMesh::checkConsecutiveCellTypesAndOrder with the same inputs. + * The returned array minimizes the permutations that is to say the order of cells inside same geometric type remains the same. + */ +DataArrayInt *MEDCouplingUMesh::getRenumArrForConsecutiveCellTypesSpec(const INTERP_KERNEL::NormalizedCellType *orderBg, const INTERP_KERNEL::NormalizedCellType *orderEnd) const throw(INTERP_KERNEL::Exception) +{ + DataArrayInt *nbPerType=0; + MEDCouplingAutoRefCountObjectPtr tmpa=getLevArrPerCellTypes(orderBg,orderEnd,nbPerType); + nbPerType->decrRef(); + return tmpa->buildPermArrPerLevel(); } /*! @@ -2670,7 +3612,7 @@ DataArrayInt *MEDCouplingUMesh::rearrange2ConsecutiveCellTypes() } /*! - * This methods split this into as mush as untructured meshes that consecutive set of same type cells. + * This method splits 'this' into as mush as untructured meshes that consecutive set of same type cells. * So this method has typically a sense if MEDCouplingUMesh::checkConsecutiveCellTypes has a sense. * This method makes asumption that connectivity is correctly set before calling. */ @@ -2698,6 +3640,25 @@ std::vector MEDCouplingUMesh::splitByType() const return ret; } +/*! + * This method returns a newly created DataArrayInt instance. + * This method retrieves cell ids in [begin,end) that have the type 'type'. + */ +DataArrayInt *MEDCouplingUMesh::keepCellIdsByType(INTERP_KERNEL::NormalizedCellType type, const int *begin, const int *end) const throw(INTERP_KERNEL::Exception) +{ + checkFullyDefined(); + std::vector r; + const int *conn=_nodal_connec->getConstPointer(); + const int *connIndex=_nodal_connec_index->getConstPointer(); + for(const int *w=begin;w!=end;w++) + if((INTERP_KERNEL::NormalizedCellType)conn[connIndex[*w]]==type) + r.push_back(*w); + DataArrayInt *ret=DataArrayInt::New(); + ret->alloc(r.size(),1); + std::copy(r.begin(),r.end(),ret->getPointer()); + return ret; +} + /*! * This method makes the assumption that da->getNumberOfTuples()getNumberOfCells(). This method makes the assumption that ids contained in 'da' * are in [0:getNumberOfCells()) @@ -2734,7 +3695,7 @@ DataArrayInt *MEDCouplingUMesh::convertCellArrayPerGeoType(const DataArrayInt *d * cells whose ids is in 'idsPerGeoType' array. * This method conserves coords and name of mesh. */ -MEDCouplingUMesh *MEDCouplingUMesh::keepSpecifiedCells(INTERP_KERNEL::NormalizedCellType type, const std::vector& idsPerGeoType) const +MEDCouplingUMesh *MEDCouplingUMesh::keepSpecifiedCells(INTERP_KERNEL::NormalizedCellType type, const int *idsPerGeoTypeBg, const int *idsPerGeoTypeEnd) const { std::vector idsTokeep; int nbOfCells=getNumberOfCells(); @@ -2744,7 +3705,7 @@ MEDCouplingUMesh *MEDCouplingUMesh::keepSpecifiedCells(INTERP_KERNEL::Normalized idsTokeep.push_back(i); else { - if(std::find(idsPerGeoType.begin(),idsPerGeoType.end(),j)!=idsPerGeoType.end()) + if(std::find(idsPerGeoTypeBg,idsPerGeoTypeEnd,j)!=idsPerGeoTypeEnd) idsTokeep.push_back(i); j++; } @@ -2755,7 +3716,7 @@ MEDCouplingUMesh *MEDCouplingUMesh::keepSpecifiedCells(INTERP_KERNEL::Normalized ret->decrRef(); return 0; } - ret2->setName(getName()); + ret2->copyTinyInfoFrom(this); return ret2; } @@ -2767,7 +3728,7 @@ MEDCouplingMesh *MEDCouplingUMesh::mergeMyselfWith(const MEDCouplingMesh *other) if(other->getType()!=UNSTRUCTURED) throw INTERP_KERNEL::Exception("Merge of umesh only available with umesh each other !"); const MEDCouplingUMesh *otherC=static_cast(other); - return mergeUMeshes(this,otherC); + return MergeUMeshes(this,otherC); } /*! @@ -2781,6 +3742,7 @@ DataArrayDouble *MEDCouplingUMesh::getBarycenterAndOwner() const int spaceDim=getSpaceDimension(); int nbOfCells=getNumberOfCells(); ret->alloc(nbOfCells,spaceDim); + ret->copyStringInfoFrom(*getCoords()); double *ptToFill=ret->getPointer(); double *tmp=new double[spaceDim]; const int *nodal=_nodal_connec->getConstPointer(); @@ -2796,59 +3758,154 @@ DataArrayDouble *MEDCouplingUMesh::getBarycenterAndOwner() const return ret; } +/*! + * This method is similar to MEDCouplingUMesh::getBarycenterAndOwner except that it works on subPart of 'this' without + * building explicitely it. The input part is defined by an array [begin,end). All ids contained in this array should be less than this->getNumberOfCells(). + * No check of that will be done ! + */ +DataArrayDouble *MEDCouplingUMesh::getPartBarycenterAndOwner(const int *begin, const int *end) const +{ + DataArrayDouble *ret=DataArrayDouble::New(); + int spaceDim=getSpaceDimension(); + int nbOfTuple=std::distance(begin,end); + ret->alloc(nbOfTuple,spaceDim); + double *ptToFill=ret->getPointer(); + double *tmp=new double[spaceDim]; + const int *nodal=_nodal_connec->getConstPointer(); + const int *nodalI=_nodal_connec_index->getConstPointer(); + const double *coor=_coords->getConstPointer(); + for(const int *w=begin;w!=end;w++) + { + INTERP_KERNEL::NormalizedCellType 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; + } + delete [] tmp; + return ret; +} + +/*! + * This method expects as input a DataArrayDouble non nul instance 'da' that should be allocated. If not an exception is thrown. + * + */ +MEDCouplingUMesh *MEDCouplingUMesh::Build0DMeshFromCoords(DataArrayDouble *da) throw(INTERP_KERNEL::Exception) +{ + if(!da) + throw INTERP_KERNEL::Exception("MEDCouplingUMesh::Build0DMeshFromCoords : instance of DataArrayDouble must be not null !"); + da->checkAllocated(); + MEDCouplingAutoRefCountObjectPtr ret=MEDCouplingUMesh::New(da->getName().c_str(),0); + ret->setCoords(da); + int nbOfTuples=da->getNumberOfTuples(); + MEDCouplingAutoRefCountObjectPtr c=DataArrayInt::New(); + MEDCouplingAutoRefCountObjectPtr cI=DataArrayInt::New(); + c->alloc(2*nbOfTuples,1); + cI->alloc(nbOfTuples+1,1); + int *cp=c->getPointer(); + int *cip=cI->getPointer(); + *cip++=0; + for(int i=0;isetConnectivity(c,cI,true); + ret->incrRef(); + return ret; +} + /*! * Returns a newly created mesh (with ref count ==1) that contains merge of 'mesh1' and 'other'. * The coords of 'mesh2' are added at the end of coords of 'mesh1'. */ -MEDCouplingUMesh *MEDCouplingUMesh::mergeUMeshes(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2) +MEDCouplingUMesh *MEDCouplingUMesh::MergeUMeshes(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2) throw(INTERP_KERNEL::Exception) { - MEDCouplingUMesh *ret=MEDCouplingUMesh::New(); - ret->setName("merge"); - DataArrayDouble *pts=mergeNodesArray(mesh1,mesh2); + std::vector tmp(2); + tmp[0]=const_cast(mesh1); tmp[1]=const_cast(mesh2); + return MergeUMeshes(tmp); +} + +MEDCouplingUMesh *MEDCouplingUMesh::MergeUMeshes(std::vector& a) throw(INTERP_KERNEL::Exception) +{ + if(a.empty()) + throw INTERP_KERNEL::Exception("MEDCouplingUMesh::MergeUMeshes : input array must be NON EMPTY !"); + std::vector::const_iterator it=a.begin(); + int meshDim=(*it)->getMeshDimension(); + int nbOfCells=(*it)->getNumberOfCells(); + int meshLgth=(*it++)->getMeshLength(); + for(;it!=a.end();it++) + { + if(meshDim!=(*it)->getMeshDimension()) + throw INTERP_KERNEL::Exception("Mesh dimensions mismatches, MergeUMeshes impossible !"); + nbOfCells+=(*it)->getNumberOfCells(); + meshLgth+=(*it)->getMeshLength(); + } + std::vector aps(a.size()); + std::copy(a.begin(),a.end(),aps.begin()); + DataArrayDouble *pts=MergeNodesArray(aps); + MEDCouplingAutoRefCountObjectPtr ret=MEDCouplingUMesh::New("merge",meshDim); ret->setCoords(pts); pts->decrRef(); - int meshDim=mesh1->getMeshDimension(); - if(meshDim!=mesh2->getMeshDimension()) - throw INTERP_KERNEL::Exception("Mesh dimensions mismatches, mergeMeshes impossible !"); - ret->setMeshDimension(meshDim); - int delta=mesh1->getMeshLength(); - int pos=mesh1->getNumberOfCells(); - int nbOfCells2=mesh2->getNumberOfCells(); - int end=mesh1->getNumberOfCells()+nbOfCells2+1; - DataArrayInt *nodalIndex=DataArrayInt::aggregate(mesh1->getNodalConnectivityIndex(), - mesh2->getNodalConnectivityIndex(),1); - std::transform(nodalIndex->getConstPointer()+pos+1,nodalIndex->getConstPointer()+end, - nodalIndex->getPointer()+pos+1,std::bind2nd(std::plus(),delta)); - DataArrayInt *newNodal2=mesh2->getNodalConnectivity()->deepCopy(); - delta=mesh1->getNumberOfNodes(); - const int *nI2=mesh2->getNodalConnectivityIndex()->getConstPointer(); - int *pt=newNodal2->getPointer(); - for(int i=0;igetNodalConnectivity(),newNodal2,0); - newNodal2->decrRef(); - ret->setConnectivity(nodal,nodalIndex,true); - nodalIndex->decrRef(); - nodal->decrRef(); + DataArrayInt *c=DataArrayInt::New(); + c->alloc(meshLgth,1); + int *cPtr=c->getPointer(); + DataArrayInt *cI=DataArrayInt::New(); + cI->alloc(nbOfCells+1,1); + int *cIPtr=cI->getPointer(); + *cIPtr++=0; + int offset=0; + int offset2=0; + for(it=a.begin();it!=a.end();it++) + { + int curNbOfCell=(*it)->getNumberOfCells(); + const int *curCI=(*it)->_nodal_connec_index->getConstPointer(); + const int *curC=(*it)->_nodal_connec->getConstPointer(); + cIPtr=std::transform(curCI+1,curCI+curNbOfCell+1,cIPtr,std::bind2nd(std::plus(),offset)); + for(int j=0;jgetNumberOfNodes(); + } + // + ret->setConnectivity(c,cI,true); + c->decrRef(); + cI->decrRef(); + ret->incrRef(); return ret; } /*! - * Idem mergeUMeshes except that 'meshes' are expected to lyie on the same coords and 'meshes' have the same meshdim. + * Idem MergeUMeshes except that 'meshes' are expected to lyie on the same coords and 'meshes' have the same meshdim. + * 'meshes' must be a non empty vector. + */ +MEDCouplingUMesh *MEDCouplingUMesh::MergeUMeshesOnSameCoords(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2) throw(INTERP_KERNEL::Exception) +{ + std::vector tmp(2); + tmp[0]=mesh1; tmp[1]=mesh2; + return MergeUMeshesOnSameCoords(tmp); +} + +/*! + * Idem MergeUMeshes except that 'meshes' are expected to lyie on the same coords and 'meshes' have the same meshdim. * 'meshes' must be a non empty vector. */ -MEDCouplingUMesh *MEDCouplingUMesh::mergeUMeshesOnSameCoords(const std::vector& meshes) +MEDCouplingUMesh *MEDCouplingUMesh::MergeUMeshesOnSameCoords(const std::vector& meshes) { if(meshes.empty()) throw INTERP_KERNEL::Exception("meshes input parameter is expected to be non empty."); - DataArrayDouble *coords=meshes.front()->getCoords(); + const DataArrayDouble *coords=meshes.front()->getCoords(); int meshDim=meshes.front()->getMeshDimension(); - std::vector::const_iterator iter=meshes.begin(); + std::vector::const_iterator iter=meshes.begin(); int meshLgth=0; int meshIndexLgth=0; for(;iter!=meshes.end();iter++) @@ -2856,7 +3913,7 @@ MEDCouplingUMesh *MEDCouplingUMesh::mergeUMeshesOnSameCoords(const std::vectorgetCoords()) throw INTERP_KERNEL::Exception("meshes does not share the same coords ! Try using tryToShareSameCoords method !"); if(meshDim!=(*iter)->getMeshDimension()) - throw INTERP_KERNEL::Exception("Mesh dimensions mismatches, fuseUMeshesOnSameCoords impossible !"); + throw INTERP_KERNEL::Exception("Mesh dimensions mismatches, FuseUMeshesOnSameCoords impossible !"); meshLgth+=(*iter)->getMeshLength(); meshIndexLgth+=(*iter)->getNumberOfCells(); } @@ -2902,10 +3959,10 @@ MEDCouplingUMesh *MEDCouplingUMesh::mergeUMeshesOnSameCoords(const std::vector& meshes, int compType, std::vector& corr) +MEDCouplingUMesh *MEDCouplingUMesh::FuseUMeshesOnSameCoords(const std::vector& meshes, int compType, std::vector& corr) { - //All checks are delegated to mergeUMeshesOnSameCoords - MEDCouplingUMesh *ret=mergeUMeshesOnSameCoords(meshes); + //All checks are delegated to MergeUMeshesOnSameCoords + MEDCouplingUMesh *ret=MergeUMeshesOnSameCoords(meshes); DataArrayInt *o2n=ret->zipConnectivityTraducer(compType); corr.resize(meshes.size()); int nbOfMeshes=meshes.size(); @@ -2918,6 +3975,7 @@ MEDCouplingUMesh *MEDCouplingUMesh::fuseUMeshesOnSameCoords(const std::vectoralloc(curNbOfCells,1); std::copy(o2nPtr+offset,o2nPtr+offset+curNbOfCells,tmp->getPointer()); offset+=curNbOfCells; + tmp->setName(meshes[i]->getName()); corr[i]=tmp; } o2n->decrRef(); @@ -2933,12 +3991,12 @@ MEDCouplingUMesh *MEDCouplingUMesh::fuseUMeshesOnSameCoords(const std::vector& ret) { INTERP_KERNEL::NormalizedCellType flatType=(INTERP_KERNEL::NormalizedCellType)connBg[0]; - const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::getCellModel(flatType); + const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(flatType); ret.push_back(cm.getExtrudedType()); int deltaz=isQuad?2*nbOfNodesPerLev:nbOfNodesPerLev; switch(flatType) { - case INTERP_KERNEL::NORM_POINT0: + case INTERP_KERNEL::NORM_POINT1: { ret.push_back(connBg[1]); ret.push_back(connBg[1]+nbOfNodesPerLev); @@ -3010,7 +4068,7 @@ void MEDCouplingUMesh::appendExtrudedCell(const int *connBg, const int *connEnd, /*! * This static operates only for coords in 3D. The polygon is specfied by its connectivity nodes in [begin,end). */ -bool MEDCouplingUMesh::isPolygonWellOriented(const double *vec, const int *begin, const int *end, const double *coords) +bool MEDCouplingUMesh::IsPolygonWellOriented(const double *vec, const int *begin, const int *end, const double *coords) { double v[3]={0.,0.,0.}; int sz=std::distance(begin,end); @@ -3026,7 +4084,7 @@ bool MEDCouplingUMesh::isPolygonWellOriented(const double *vec, const int *begin /*! * The polyhedron is specfied by its connectivity nodes in [begin,end). */ -bool MEDCouplingUMesh::isPolyhedronWellOriented(const int *begin, const int *end, const double *coords) +bool MEDCouplingUMesh::IsPolyhedronWellOriented(const int *begin, const int *end, const double *coords) { std::vector > edges; int nbOfFaces=std::count(begin,end,-1)+1; @@ -3051,7 +4109,7 @@ bool MEDCouplingUMesh::isPolyhedronWellOriented(const int *begin, const int *end * This method tries to obtain a well oriented polyhedron. * If the algorithm fails, an exception will be thrown. */ -void MEDCouplingUMesh::tryToCorrectPolyhedronOrientation(int *begin, int *end, const double *coords) throw(INTERP_KERNEL::Exception) +void MEDCouplingUMesh::TryToCorrectPolyhedronOrientation(int *begin, int *end, const double *coords) throw(INTERP_KERNEL::Exception) { std::vector > edges; int nbOfFaces=std::count(begin,end,-1)+1; diff --git a/src/MEDCoupling/MEDCouplingUMesh.hxx b/src/MEDCoupling/MEDCouplingUMesh.hxx index eb989c9a6..96fc0a6fd 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.hxx +++ b/src/MEDCoupling/MEDCouplingUMesh.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __PARAMEDMEM_MEDCOUPLINGUMESH_HXX__ @@ -35,7 +35,7 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT static MEDCouplingUMesh *New(const char *meshName, int meshDim); MEDCOUPLING_EXPORT MEDCouplingMesh *deepCpy() const; MEDCOUPLING_EXPORT MEDCouplingUMesh *clone(bool recDeepCpy) const; - MEDCOUPLING_EXPORT void updateTime(); + MEDCOUPLING_EXPORT void updateTime() const; MEDCOUPLING_EXPORT MEDCouplingMeshType getType() const { return UNSTRUCTURED; } MEDCOUPLING_EXPORT bool isEqual(const MEDCouplingMesh *other, double prec) const; MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const; @@ -45,14 +45,20 @@ namespace ParaMEDMEM DataArrayInt *&cellCor) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void checkFastEquivalWith(const MEDCouplingMesh *other, double prec) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void checkCoherency() const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT void checkCoherency1(double eps=1e-12) const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT void checkCoherency2(double eps=1e-12) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void setMeshDimension(int meshDim); MEDCOUPLING_EXPORT void allocateCells(int nbOfCells); - MEDCOUPLING_EXPORT void insertNextCell(INTERP_KERNEL::NormalizedCellType type, int size, const int *nodalConnOfCell); + MEDCOUPLING_EXPORT void insertNextCell(INTERP_KERNEL::NormalizedCellType type, int size, const int *nodalConnOfCell) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void finishInsertingCells(); MEDCOUPLING_EXPORT const std::set& getAllTypes() const { return _types; } + MEDCOUPLING_EXPORT std::set getAllGeoTypes() const; + MEDCOUPLING_EXPORT std::set getTypesOfPart(const int *begin, const int *end) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void setConnectivity(DataArrayInt *conn, DataArrayInt *connIndex, bool isComputingTypes=true); - MEDCOUPLING_EXPORT DataArrayInt *getNodalConnectivity() const { return _nodal_connec; } - MEDCOUPLING_EXPORT DataArrayInt *getNodalConnectivityIndex() const { return _nodal_connec_index; } + MEDCOUPLING_EXPORT const DataArrayInt *getNodalConnectivity() const { return _nodal_connec; } + MEDCOUPLING_EXPORT const DataArrayInt *getNodalConnectivityIndex() const { return _nodal_connec_index; } + MEDCOUPLING_EXPORT DataArrayInt *getNodalConnectivity() { return _nodal_connec; } + MEDCOUPLING_EXPORT DataArrayInt *getNodalConnectivityIndex() { return _nodal_connec_index; } MEDCOUPLING_EXPORT INTERP_KERNEL::NormalizedCellType getTypeOfCell(int cellId) const; MEDCOUPLING_EXPORT int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const; MEDCOUPLING_EXPORT void getNodeIdsOfCell(int cellId, std::vector& conn) const; @@ -67,11 +73,11 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT int getMeshLength() const; MEDCOUPLING_EXPORT void computeTypes(); //! size of returned tinyInfo must be always the same. - MEDCOUPLING_EXPORT void getTinySerializationInformation(std::vector& tinyInfo, std::vector& littleStrings) const; + 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, DataArrayInt *a1, DataArrayDouble *a2, std::vector& littleStrings) const; MEDCOUPLING_EXPORT void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const; - MEDCOUPLING_EXPORT void unserialization(const std::vector& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, const std::vector& littleStrings); + MEDCOUPLING_EXPORT void unserialization(const std::vector& tinyInfoD, const std::vector& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, const std::vector& littleStrings); //tools MEDCOUPLING_EXPORT bool areCellsEqual(int cell1, int cell2, int compType) const; MEDCOUPLING_EXPORT bool areCellsEqual0(int cell1, int cell2) const; @@ -79,35 +85,49 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT bool areCellsEqual2(int cell1, int cell2) const; MEDCOUPLING_EXPORT bool areCellsFrom2MeshEqual(const MEDCouplingUMesh *other, int cellId, double prec) const; MEDCOUPLING_EXPORT void convertToPolyTypes(const std::vector& cellIdsToConvert); - MEDCOUPLING_EXPORT DataArrayInt *zipCoordsTraducer(); - MEDCOUPLING_EXPORT DataArrayInt *zipConnectivityTraducer(int compType); - MEDCOUPLING_EXPORT void getReverseNodalConnectivity(DataArrayInt *revNodal, DataArrayInt *revNodalIndx) const; - MEDCOUPLING_EXPORT MEDCouplingUMesh *buildDescendingConnectivity(DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *revDesc, DataArrayInt *revDescIndx) const; + MEDCOUPLING_EXPORT void convertAllToPoly(); + MEDCOUPLING_EXPORT void unPolyze(); + MEDCOUPLING_EXPORT DataArrayInt *zipCoordsTraducer() throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT DataArrayInt *zipConnectivityTraducer(int compType) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT bool areCellsIncludedIn(const MEDCouplingUMesh *other, int compType, DataArrayInt *& arr) const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT void getReverseNodalConnectivity(DataArrayInt *revNodal, DataArrayInt *revNodalIndx) const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT MEDCouplingUMesh *buildDescendingConnectivity(DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *revDesc, DataArrayInt *revDescIndx) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT DataArrayInt *mergeNodes(double precision, bool& areNodesMerged, int& newNbOfNodes); + MEDCOUPLING_EXPORT DataArrayInt *mergeNodes2(double precision, bool& areNodesMerged, int& newNbOfNodes); MEDCOUPLING_EXPORT void tryToShareSameCoordsPermute(const MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT MEDCouplingPointSet *buildPartOfMySelf(const int *begin, const int *end, bool keepCoords) const; MEDCOUPLING_EXPORT MEDCouplingPointSet *buildPartOfMySelfNode(const int *begin, const int *end, bool fullyIn) const; + MEDCOUPLING_EXPORT DataArrayInt *getCellIdsLyingOnNodes(const int *begin, const int *end, bool fullyIn) const; MEDCOUPLING_EXPORT MEDCouplingPointSet *buildFacePartOfMySelfNode(const int *begin, const int *end, bool fullyIn) const; + MEDCOUPLING_EXPORT MEDCouplingUMesh *buildUnstructured() const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void findBoundaryNodes(std::vector& nodes) const; MEDCOUPLING_EXPORT MEDCouplingPointSet *buildBoundaryMesh(bool keepCoords) const; + MEDCOUPLING_EXPORT DataArrayInt *findCellsIdsOnBoundary() const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void renumberNodes(const int *newNodeNumbers, int newNbOfNodes); + MEDCOUPLING_EXPORT void renumberNodes2(const int *newNodeNumbers, int newNbOfNodes); MEDCOUPLING_EXPORT void renumberCells(const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT void giveElemsInBoundingBox(const double *bbox, double eps, std::vector& elems); - MEDCOUPLING_EXPORT void giveElemsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bbox, double eps, std::vector& elems); + MEDCOUPLING_EXPORT void getCellsInBoundingBox(const double *bbox, double eps, std::vector& elems); + MEDCOUPLING_EXPORT void getCellsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bbox, double eps, std::vector& elems); MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureField(bool isAbs) const; + MEDCOUPLING_EXPORT DataArrayDouble *getPartMeasureField(bool isAbs, const int *begin, const int *end) const; MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureFieldOnNode(bool isAbs) const; MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildOrthogonalField() const; + MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildPartOrthogonalField(const int *begin, const int *end) const; MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildDirectionVectorField() const; + MEDCOUPLING_EXPORT bool isContiguous1D() const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void project1D(const double *pt, const double *v, double eps, double *res) const; MEDCOUPLING_EXPORT int getCellContainingPoint(const double *pos, double eps) const; MEDCOUPLING_EXPORT void getCellsContainingPoint(const double *pos, double eps, std::vector& elts) const; MEDCOUPLING_EXPORT void getCellsContainingPoints(const double *pos, int nbOfPoints, double eps, std::vector& elts, std::vector& eltsIndex) const; MEDCOUPLING_EXPORT void checkButterflyCells(std::vector& cells) const; MEDCOUPLING_EXPORT void getBoundingBoxForBBTree(std::vector& bbox) const; - MEDCOUPLING_EXPORT MEDCouplingUMesh *buildExtrudedMeshFromThis(const MEDCouplingUMesh *mesh1D, int policy); + MEDCOUPLING_EXPORT MEDCouplingUMesh *buildExtrudedMesh(const MEDCouplingUMesh *mesh1D, int policy); MEDCOUPLING_EXPORT bool isFullyQuadratic() const; MEDCOUPLING_EXPORT bool isPresenceOfQuadratic() const; MEDCOUPLING_EXPORT void convertQuadraticCellsToLinear() throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT DataArrayInt *simplexize(int policy) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT bool areOnlySimplexCells() const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT void convertDegeneratedCells() throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void are2DCellsNotCorrectlyOriented(const double *vec, bool polyOnly, std::vector& cells) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void orientCorrectly2DCells(const double *vec, bool polyOnly) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void arePolyhedronsNotCorrectlyOriented(std::vector& cells) const throw(INTERP_KERNEL::Exception); @@ -119,33 +139,48 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getWarpField() const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getSkewField() const throw(INTERP_KERNEL::Exception); //utilities for MED File RW + MEDCOUPLING_EXPORT DataArrayInt *checkTypeConsistencyAndContig(const std::vector& code, const std::vector& idsPerType) const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT MEDCouplingUMesh *emulateMEDMEMBDC(const MEDCouplingUMesh *nM1LevMesh, DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *&revDesc, DataArrayInt *&revDescIndx, DataArrayInt *& nM1LevMeshIds, DataArrayInt *&meshnM1Old2New) const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT DataArrayInt *sortCellsInMEDFileFrmt() throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT bool checkConsecutiveCellTypes() const; MEDCOUPLING_EXPORT bool checkConsecutiveCellTypesAndOrder(const INTERP_KERNEL::NormalizedCellType *orderBg, const INTERP_KERNEL::NormalizedCellType *orderEnd) const; - MEDCOUPLING_EXPORT DataArrayInt *getRenumArrForConsecutiveCellTypesSpec(const INTERP_KERNEL::NormalizedCellType *orderBg, const INTERP_KERNEL::NormalizedCellType *orderEnd) const; + MEDCOUPLING_EXPORT DataArrayInt *getLevArrPerCellTypes(const INTERP_KERNEL::NormalizedCellType *orderBg, const INTERP_KERNEL::NormalizedCellType *orderEnd, DataArrayInt *&nbPerType) const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT DataArrayInt *getRenumArrForConsecutiveCellTypesSpec(const INTERP_KERNEL::NormalizedCellType *orderBg, const INTERP_KERNEL::NormalizedCellType *orderEnd) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT DataArrayInt *rearrange2ConsecutiveCellTypes(); MEDCOUPLING_EXPORT std::vector splitByType() const; + MEDCOUPLING_EXPORT DataArrayInt *keepCellIdsByType(INTERP_KERNEL::NormalizedCellType type, const int *begin, const int *end) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT DataArrayInt *convertCellArrayPerGeoType(const DataArrayInt *da) const throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT MEDCouplingUMesh *keepSpecifiedCells(INTERP_KERNEL::NormalizedCellType type, const std::vector& idsPerGeoType) const; + MEDCOUPLING_EXPORT MEDCouplingUMesh *keepSpecifiedCells(INTERP_KERNEL::NormalizedCellType type, const int *idsPerGeoTypeBg, const int *idsPerGeoTypeEnd) const; // MEDCOUPLING_EXPORT MEDCouplingMesh *mergeMyselfWith(const MEDCouplingMesh *other) const; MEDCOUPLING_EXPORT DataArrayDouble *getBarycenterAndOwner() const; - MEDCOUPLING_EXPORT static MEDCouplingUMesh *mergeUMeshes(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2); - MEDCOUPLING_EXPORT static MEDCouplingUMesh *mergeUMeshesOnSameCoords(const std::vector& meshes); - MEDCOUPLING_EXPORT static MEDCouplingUMesh *fuseUMeshesOnSameCoords(const std::vector& meshes, int compType, std::vector& corr); - MEDCOUPLING_EXPORT static bool isPolygonWellOriented(const double *vec, const int *begin, const int *end, const double *coords); - MEDCOUPLING_EXPORT static bool isPolyhedronWellOriented(const int *begin, const int *end, const double *coords); - MEDCOUPLING_EXPORT static void tryToCorrectPolyhedronOrientation(int *begin, int *end, const double *coords) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT DataArrayDouble *getPartBarycenterAndOwner(const int *begin, const int *end) const; + MEDCOUPLING_EXPORT static MEDCouplingUMesh *Build0DMeshFromCoords(DataArrayDouble *da) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT static MEDCouplingUMesh *MergeUMeshes(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT static MEDCouplingUMesh *MergeUMeshes(std::vector& a) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT static MEDCouplingUMesh *MergeUMeshesOnSameCoords(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT static MEDCouplingUMesh *MergeUMeshesOnSameCoords(const std::vector& meshes); + MEDCOUPLING_EXPORT static MEDCouplingUMesh *FuseUMeshesOnSameCoords(const std::vector& meshes, int compType, std::vector& corr); + MEDCOUPLING_EXPORT static bool IsPolygonWellOriented(const double *vec, const int *begin, const int *end, const double *coords); + MEDCOUPLING_EXPORT static bool IsPolyhedronWellOriented(const int *begin, const int *end, const double *coords); + MEDCOUPLING_EXPORT static void TryToCorrectPolyhedronOrientation(int *begin, int *end, const double *coords) throw(INTERP_KERNEL::Exception); private: MEDCouplingUMesh(); MEDCouplingUMesh(const MEDCouplingUMesh& other, bool deepCpy); ~MEDCouplingUMesh(); void checkFullyDefined() const throw(INTERP_KERNEL::Exception); + void checkConnectivityFullyDefined() const throw(INTERP_KERNEL::Exception); void reprConnectivityOfThisLL(std::ostringstream& stream) const; //tools + DataArrayInt *simplexizePol0() throw(INTERP_KERNEL::Exception); + DataArrayInt *simplexizePol1() throw(INTERP_KERNEL::Exception); void renumberNodesInConn(const int *newNodeNumbers); void fillCellIdsToKeepFromNodeIds(const int *begin, const int *end, bool fullyIn, std::vector& cellIdsKept) const; MEDCouplingUMesh *buildExtrudedMeshFromThisLowLev(int nbOfNodesOf1Lev, bool isQuad) const; DataArrayDouble *fillExtCoordsUsingTranslation(const MEDCouplingUMesh *mesh1D, bool isQuad) const; + DataArrayDouble *fillExtCoordsUsingTranslAndAutoRotation(const MEDCouplingUMesh *mesh1D, bool isQuad) const throw(INTERP_KERNEL::Exception); + DataArrayDouble *fillExtCoordsUsingTranslAndAutoRotation2D(const MEDCouplingUMesh *mesh1D, bool isQuad) const throw(INTERP_KERNEL::Exception); + DataArrayDouble *fillExtCoordsUsingTranslAndAutoRotation3D(const MEDCouplingUMesh *mesh1D, bool isQuad) const throw(INTERP_KERNEL::Exception); template void findCommonCellsBase(int compType, std::vector& res, std::vector& resI) const; bool areCellsEqualInPool(const std::vector& candidates, int compType, std::vector& result) const; diff --git a/src/MEDCoupling/MEDCouplingUMeshDesc.cxx b/src/MEDCoupling/MEDCouplingUMeshDesc.cxx index f45cd5eba..9406b0766 100644 --- a/src/MEDCoupling/MEDCouplingUMeshDesc.cxx +++ b/src/MEDCoupling/MEDCouplingUMeshDesc.cxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "MEDCouplingUMeshDesc.hxx" @@ -25,7 +25,7 @@ using namespace ParaMEDMEM; -MEDCouplingUMeshDesc::MEDCouplingUMeshDesc():_mesh_dim(-1),_desc_connec(0),_desc_connec_index(0), +MEDCouplingUMeshDesc::MEDCouplingUMeshDesc():_mesh_dim(-2),_desc_connec(0),_desc_connec_index(0), _nodal_connec_face(0),_nodal_connec_face_index(0) { } @@ -67,7 +67,7 @@ void MEDCouplingUMeshDesc::checkCoherency() const throw(INTERP_KERNEL::Exception { for(std::set::const_iterator iter=_types.begin();iter!=_types.end();iter++) { - if(INTERP_KERNEL::CellModel::getCellModel(*iter).getDimension()!=_mesh_dim) + if((int)INTERP_KERNEL::CellModel::GetCellModel(*iter).getDimension()!=_mesh_dim) { std::ostringstream message; message << "MeshDesc invalid because dimension is " << _mesh_dim << " and there is presence of cell(s) with type " << (*iter); @@ -76,6 +76,16 @@ void MEDCouplingUMeshDesc::checkCoherency() const throw(INTERP_KERNEL::Exception } } +void MEDCouplingUMeshDesc::checkCoherency1(double eps) const throw(INTERP_KERNEL::Exception) +{ + checkCoherency(); +} + +void MEDCouplingUMeshDesc::checkCoherency2(double eps) const throw(INTERP_KERNEL::Exception) +{ + checkCoherency1(eps); +} + void MEDCouplingUMeshDesc::checkDeepEquivalWith(const MEDCouplingMesh *other, int cellCompPol, double prec, DataArrayInt *&cellCor, DataArrayInt *&nodeCor) const throw(INTERP_KERNEL::Exception) { @@ -127,6 +137,11 @@ INTERP_KERNEL::NormalizedCellType MEDCouplingUMeshDesc::getTypeOfCell(int cellId return (INTERP_KERNEL::NormalizedCellType)desc_connec[desc_connec_index[cellId]+1]; } +std::set MEDCouplingUMeshDesc::getAllGeoTypes() const +{ + return _types; +} + int MEDCouplingUMeshDesc::getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const { const int *desc_connec=_desc_connec->getConstPointer(); @@ -167,16 +182,21 @@ std::string MEDCouplingUMeshDesc::advancedRepr() const void MEDCouplingUMeshDesc::setConnectivity(DataArrayInt *descConn, DataArrayInt *descConnIndex, DataArrayInt *nodalFaceConn, DataArrayInt *nodalFaceConnIndx) { - DataArrayInt::setArrayIn(descConn,_desc_connec); - DataArrayInt::setArrayIn(descConnIndex,_desc_connec_index); - DataArrayInt::setArrayIn(nodalFaceConn,_nodal_connec_face); - DataArrayInt::setArrayIn(nodalFaceConnIndx,_nodal_connec_face_index); + DataArrayInt::SetArrayIn(descConn,_desc_connec); + DataArrayInt::SetArrayIn(descConnIndex,_desc_connec_index); + DataArrayInt::SetArrayIn(nodalFaceConn,_nodal_connec_face); + DataArrayInt::SetArrayIn(nodalFaceConnIndx,_nodal_connec_face_index); computeTypes(); } -void MEDCouplingUMeshDesc::getTinySerializationInformation(std::vector& tinyInfo, std::vector& littleStrings) const +DataArrayInt *MEDCouplingUMeshDesc::checkTypeConsistencyAndContig(const std::vector& code, const std::vector& idsPerType) const throw(INTERP_KERNEL::Exception) +{ + throw INTERP_KERNEL::Exception("Not implemented yet !"); +} + +void MEDCouplingUMeshDesc::getTinySerializationInformation(std::vector& tinyInfoD, std::vector& tinyInfo, std::vector& littleStrings) const { - MEDCouplingPointSet::getTinySerializationInformation(tinyInfo,littleStrings); + MEDCouplingPointSet::getTinySerializationInformation(tinyInfoD,tinyInfo,littleStrings); tinyInfo.push_back(getMeshDimension()); tinyInfo.push_back(getNumberOfNodes()); tinyInfo.push_back(getNumberOfCells()); @@ -190,7 +210,7 @@ bool MEDCouplingUMeshDesc::isEmptyMesh(const std::vector& tinyInfo) const return tinyInfo[5]<=0; } -void MEDCouplingUMeshDesc::resizeForUnserialization(const std::vector& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector& littleStrings) +void MEDCouplingUMeshDesc::resizeForUnserialization(const std::vector& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector& littleStrings) const { std::vector tinyInfoTmp(tinyInfo.begin()+1,tinyInfo.end()); MEDCouplingPointSet::resizeForUnserialization(tinyInfoTmp,a1,a2,littleStrings); @@ -214,10 +234,10 @@ void MEDCouplingUMeshDesc::serialize(DataArrayInt *&a1, DataArrayDouble *&a2) co std::copy(faceConnIndex,faceConnIndex+getNumberOfFaces()+1,ptA1); } -void MEDCouplingUMeshDesc::unserialization(const std::vector& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, const std::vector& littleStrings) +void MEDCouplingUMeshDesc::unserialization(const std::vector& tinyInfoD, const std::vector& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, const std::vector& littleStrings) { std::vector tinyInfoTmp(tinyInfo.begin()+1,tinyInfo.end()); - MEDCouplingPointSet::unserialization(tinyInfoTmp,a1,a2,littleStrings); + MEDCouplingPointSet::unserialization(tinyInfoD,tinyInfoTmp,a1,a2,littleStrings); // const int *recvBuffer=a1->getConstPointer(); DataArrayInt *descConn=DataArrayInt::New(); @@ -241,7 +261,7 @@ void MEDCouplingUMeshDesc::unserialization(const std::vector& tinyInfo, Dat setMeshDimension(tinyInfo[2]); } -void MEDCouplingUMeshDesc::giveElemsInBoundingBox(const double *bbox, double eps, std::vector& elems) +void MEDCouplingUMeshDesc::getCellsInBoundingBox(const double *bbox, double eps, std::vector& elems) { int dim=getSpaceDimension(); double* elem_bb=new double[2*dim]; @@ -286,7 +306,7 @@ void MEDCouplingUMeshDesc::giveElemsInBoundingBox(const double *bbox, double eps delete [] elem_bb; } -void MEDCouplingUMeshDesc::giveElemsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox &bbox, double eps, std::vector& elems) +void MEDCouplingUMeshDesc::getCellsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox &bbox, double eps, std::vector& elems) { int dim=getSpaceDimension(); double* elem_bb=new double[2*dim]; @@ -338,6 +358,13 @@ DataArrayInt *MEDCouplingUMeshDesc::mergeNodes(double precision, bool& areNodesM return 0; } +DataArrayInt *MEDCouplingUMeshDesc::mergeNodes2(double precision, bool& areNodesMerged, int& newNbOfNodes) +{ + //not implemented yet. + areNodesMerged=false; + return 0; +} + void MEDCouplingUMeshDesc::tryToShareSameCoordsPermute(const MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception) { throw INTERP_KERNEL::Exception("Not implemented yet !"); @@ -361,6 +388,11 @@ MEDCouplingPointSet *MEDCouplingUMeshDesc::buildFacePartOfMySelfNode(const int * return 0; } +DataArrayInt *MEDCouplingUMeshDesc::simplexize(int policy) throw(INTERP_KERNEL::Exception) +{ + throw INTERP_KERNEL::Exception("MEDCouplingUMeshDesc::simplexize : Not implemented yet !"); +} + void MEDCouplingUMeshDesc::findBoundaryNodes(std::vector& nodes) const { //not implemented yet @@ -372,6 +404,11 @@ MEDCouplingPointSet *MEDCouplingUMeshDesc::buildBoundaryMesh(bool keepCoords) co return 0; } +MEDCouplingUMesh *MEDCouplingUMeshDesc::buildUnstructured() const throw(INTERP_KERNEL::Exception) +{ + throw INTERP_KERNEL::Exception("MEDCouplingUMeshDesc::buildUnstructured : not implemented yet !"); +} + void MEDCouplingUMeshDesc::renumberCells(const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception) { throw INTERP_KERNEL::Exception("Available for UMesh desc but not implemented yet !"); @@ -442,6 +479,5 @@ DataArrayDouble *MEDCouplingUMeshDesc::getBarycenterAndOwner() const int MEDCouplingUMeshDesc::getCellContainingPoint(const double *pos, double eps) const { - //not implemented yet. - return -1; + throw INTERP_KERNEL::Exception("MEDCouplingUMeshDesc::getCellContainingPoint : not implemented yet !"); } diff --git a/src/MEDCoupling/MEDCouplingUMeshDesc.hxx b/src/MEDCoupling/MEDCouplingUMeshDesc.hxx index 7c965a31c..98867717b 100644 --- a/src/MEDCoupling/MEDCouplingUMeshDesc.hxx +++ b/src/MEDCoupling/MEDCouplingUMeshDesc.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __PARAMEDMEM_MEDCOUPLINGUMESHDESC_HXX__ @@ -35,6 +35,8 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT static MEDCouplingUMeshDesc *New(const char *meshName, int meshDim); MEDCOUPLING_EXPORT MEDCouplingMesh *deepCpy() const; MEDCOUPLING_EXPORT void checkCoherency() const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT void checkCoherency1(double eps=1e-12) const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT void checkCoherency2(double eps=1e-12) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void checkDeepEquivalWith(const MEDCouplingMesh *other, int cellCompPol, double prec, DataArrayInt *&cellCor, DataArrayInt *&nodeCor) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void checkDeepEquivalOnSameNodesWith(const MEDCouplingMesh *other, int cellCompPol, double prec, @@ -46,6 +48,7 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT int getFaceMeshLength() const; MEDCOUPLING_EXPORT int getMeshDimension() const { return _mesh_dim; } MEDCOUPLING_EXPORT INTERP_KERNEL::NormalizedCellType getTypeOfCell(int cellId) const; + MEDCOUPLING_EXPORT std::set getAllGeoTypes() const; MEDCOUPLING_EXPORT int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const; MEDCOUPLING_EXPORT void getNodeIdsOfCell(int cellId, std::vector& conn) const; MEDCOUPLING_EXPORT void getCoordinatesOfNode(int nodeId, std::vector& coo) const; @@ -54,20 +57,24 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT MEDCouplingMeshType getType() const { return UNSTRUCTURED_DESC; } MEDCOUPLING_EXPORT void setConnectivity(DataArrayInt *descConn, DataArrayInt *descConnIndex, DataArrayInt *nodalFaceConn, DataArrayInt *nodalFaceConnIndx); //tools to overload - MEDCOUPLING_EXPORT void getTinySerializationInformation(std::vector& tinyInfo, std::vector& littleStrings) const; + MEDCOUPLING_EXPORT DataArrayInt *checkTypeConsistencyAndContig(const std::vector& code, const std::vector& idsPerType) const throw(INTERP_KERNEL::Exception); + 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, DataArrayInt *a1, DataArrayDouble *a2, std::vector& littleStrings); + MEDCOUPLING_EXPORT void resizeForUnserialization(const std::vector& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector& littleStrings) const; MEDCOUPLING_EXPORT void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const; - MEDCOUPLING_EXPORT void unserialization(const std::vector& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, const std::vector& littleStrings); - MEDCOUPLING_EXPORT void giveElemsInBoundingBox(const double *bbox, double eps, std::vector& elems); - MEDCOUPLING_EXPORT void giveElemsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox &bbox, double eps, std::vector& elems); + MEDCOUPLING_EXPORT void unserialization(const std::vector& tinyInfoD, const std::vector& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, const std::vector& littleStrings); + MEDCOUPLING_EXPORT void getCellsInBoundingBox(const double *bbox, double eps, std::vector& elems); + MEDCOUPLING_EXPORT void getCellsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox &bbox, double eps, std::vector& elems); MEDCOUPLING_EXPORT DataArrayInt *mergeNodes(double precision, bool& areNodesMerged, int& newNbOfNodes); + MEDCOUPLING_EXPORT DataArrayInt *mergeNodes2(double precision, bool& areNodesMerged, int& newNbOfNodes); MEDCOUPLING_EXPORT void tryToShareSameCoordsPermute(const MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT MEDCouplingPointSet *buildPartOfMySelf(const int *start, const int *end, bool keepCoords) const; MEDCOUPLING_EXPORT MEDCouplingPointSet *buildPartOfMySelfNode(const int *start, const int *end, bool fullyIn) const; MEDCOUPLING_EXPORT MEDCouplingPointSet *buildFacePartOfMySelfNode(const int *start, const int *end, bool fullyIn) const; + MEDCOUPLING_EXPORT DataArrayInt *simplexize(int policy) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void findBoundaryNodes(std::vector& nodes) const; MEDCOUPLING_EXPORT MEDCouplingPointSet *buildBoundaryMesh(bool keepCoords) const; + MEDCOUPLING_EXPORT MEDCouplingUMesh *buildUnstructured() const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void renumberCells(const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void renumberNodes(const int *newNodeNumbers, int newNbOfNodes); MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureField(bool isAbs) const; @@ -83,7 +90,7 @@ namespace ParaMEDMEM void computeTypes(); void checkFullyDefined() const throw(INTERP_KERNEL::Exception); private: - unsigned _mesh_dim; + int _mesh_dim; DataArrayInt *_desc_connec; DataArrayInt *_desc_connec_index; DataArrayInt *_nodal_connec_face; diff --git a/src/MEDCoupling/Makefile.am b/src/MEDCoupling/Makefile.am index 28553f288..5dcc884fb 100644 --- a/src/MEDCoupling/Makefile.am +++ b/src/MEDCoupling/Makefile.am @@ -1,20 +1,20 @@ -# Copyright (C) 2007-2010 CEA/DEN, EDF R&D +# Copyright (C) 2007-2011 CEA/DEN, EDF R&D # -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. # -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. # -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # include $(top_srcdir)/adm_local/unix/make_common_starter.am @@ -34,10 +34,11 @@ MEDCouplingField.hxx MEDCouplingNormalizedUnstructuredMesh.hxx MEDCouplingMemArr MEDCouplingNormalizedUnstructuredMesh.txx MEDCouplingMemArray.txx MEDCouplingRefCountObject.hxx \ MEDCouplingCMesh.hxx MEDCouplingTimeDiscretization.hxx \ MEDCouplingFieldDiscretization.hxx MEDCouplingPointSet.hxx MEDCouplingPointSet.txx \ -MEDCouplingUMeshDesc.hxx MEDCouplingNatureOfField.hxx \ +MEDCouplingUMeshDesc.hxx MEDCouplingNatureOfField.hxx MEDCouplingFieldTemplate.hxx \ MEDCouplingNormalizedCartesianMesh.hxx MEDCouplingNormalizedCartesianMesh.txx \ MEDCouplingRemapper.hxx MEDCouplingExtrudedMesh.hxx MEDCouplingGaussLocalization.hxx \ -MEDCouplingAutoRefCountObjectPtr.hxx +MEDCouplingAutoRefCountObjectPtr.hxx MEDCouplingMultiFields.hxx MEDCouplingDefinitionTime.hxx \ +MEDCouplingFieldOverTime.hxx # Libraries targets @@ -46,16 +47,17 @@ dist_libmedcoupling_la_SOURCES = \ MEDCouplingUMesh.cxx MEDCouplingMemArray.cxx MEDCouplingTimeLabel.cxx \ MEDCouplingCMesh.cxx MEDCouplingTimeDiscretization.cxx \ MEDCouplingFieldDiscretization.cxx MEDCouplingRefCountObject.cxx \ - MEDCouplingPointSet.cxx MEDCouplingUMeshDesc.cxx \ + MEDCouplingPointSet.cxx MEDCouplingUMeshDesc.cxx MEDCouplingFieldTemplate.cxx \ MEDCouplingExtrudedMesh.cxx MEDCouplingMesh.cxx MEDCouplingGaussLocalization.cxx \ - MEDCouplingNatureOfField.cxx + MEDCouplingNatureOfField.cxx MEDCouplingMultiFields.cxx \ + MEDCouplingDefinitionTime.cxx MEDCouplingFieldOverTime.cxx libmedcoupling_la_LDFLAGS= libmedcoupling_la_CPPFLAGS= @CXXTMPDPTHFLAGS@ \ -I$(srcdir) -I$(srcdir)/../INTERP_KERNEL/Bases \ -I$(srcdir)/../INTERP_KERNEL -I$(srcdir)/../INTERP_KERNEL/Geometric2D \ - -I$(srcdir)/../INTERP_KERNEL/ExprEval + -I$(srcdir)/../INTERP_KERNEL/ExprEval -I$(srcdir)/../INTERP_KERNEL/GaussPoints # the geom2D library is included in the interpkernel one libmedcoupling_la_LIBADD= ../INTERP_KERNEL/libinterpkernel.la @@ -93,4 +95,8 @@ EXTRA_DIST += \ MEDCouplingNatureOfField.hxx \ MEDCouplingRemapper.hxx \ MEDCouplingExtrudedMesh.hxx \ - MEDCouplingGaussLocalization.hxx + MEDCouplingGaussLocalization.hxx \ + MEDCouplingMultiFields.hxx \ + MEDCouplingFieldTemplate.hxx \ + MEDCouplingDefinitionTime.hxx \ + MEDCouplingFieldOverTime.hxx diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest.hxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest.hxx index 569560584..6fbe69a54 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest.hxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __MEDCOUPLINGBASICSTEST_HXX__ @@ -27,7 +27,10 @@ namespace ParaMEDMEM { + class DataArrayDouble; class MEDCouplingUMesh; + class MEDCouplingFieldDouble; + class MEDCouplingMultiFields; class MEDCouplingBasicsTest : public CppUnit::TestFixture { @@ -128,6 +131,7 @@ namespace ParaMEDMEM CPPUNIT_TEST( testFillFromAnalytic3 ); CPPUNIT_TEST( testFieldDoubleOpEqual1 ); CPPUNIT_TEST( testAreaBary3D2 ); + //MEDCouplingBasicsTest3.cxx CPPUNIT_TEST( testGetMeasureFieldCMesh1 ); CPPUNIT_TEST( testFieldDoubleZipCoords1 ); CPPUNIT_TEST( testFieldDoubleZipConnectivity1 ); @@ -143,6 +147,82 @@ namespace ParaMEDMEM CPPUNIT_TEST( testDataArrayIntInvertO2NNO21 ); CPPUNIT_TEST( testKeepSetSelectedComponent1 ); CPPUNIT_TEST( testKeepSetSelectedComponent2 ); + CPPUNIT_TEST( testDAIGetIdsEqual1 ); + CPPUNIT_TEST( testDAIGetIdsEqualList1 ); + CPPUNIT_TEST( testDAFromNoInterlace1 ); + CPPUNIT_TEST( testDAToNoInterlace1 ); + CPPUNIT_TEST( testDAIsUniform1 ); + CPPUNIT_TEST( testDADFromPolarToCart1 ); + CPPUNIT_TEST( testDADFromCylToCart1 ); + CPPUNIT_TEST( testDADFromSpherToCart1 ); + CPPUNIT_TEST( testUnPolyze1 ); + CPPUNIT_TEST( testConvertDegeneratedCells1 ); + CPPUNIT_TEST( testGetNodeIdsNearPoints1 ); + CPPUNIT_TEST( testFieldCopyTinyAttrFrom1 ); + CPPUNIT_TEST( testExtrudedMesh5 ); + CPPUNIT_TEST( testExtrudedMesh6 ); + CPPUNIT_TEST( testExtrudedMesh7 ); + CPPUNIT_TEST( testSimplexize1 ); + CPPUNIT_TEST( testSimplexize2 ); + CPPUNIT_TEST( testDAMeld1 ); + CPPUNIT_TEST( testFieldMeld1 ); + CPPUNIT_TEST( testMergeNodes2 ); + CPPUNIT_TEST( testMergeField2 ); + CPPUNIT_TEST( testDAIBuildComplement1 ); + CPPUNIT_TEST( testDAIBuildUnion1 ); + CPPUNIT_TEST( testDAIBuildIntersection1 ); + CPPUNIT_TEST( testDAIDeltaShiftIndex1 ); + CPPUNIT_TEST( testDaDoubleSelectByTupleIdSafe1 ); + CPPUNIT_TEST( testAreCellsIncludedIn1 ); + CPPUNIT_TEST( testDAIBuildSubstraction1 ); + CPPUNIT_TEST( testBuildOrthogonalField2 ); + CPPUNIT_TEST( testUMInsertNextCell1 ); + CPPUNIT_TEST( testFieldOperatorDivDiffComp1 ); + CPPUNIT_TEST( testDARearrange1 ); + CPPUNIT_TEST( testGetDifferentValues1 ); + CPPUNIT_TEST( testDAIBuildPermutationArr1 ); + CPPUNIT_TEST( testAreCellsIncludedIn2 ); + CPPUNIT_TEST( testUMeshGetPartBarycenterAndOwner1 ); + CPPUNIT_TEST( testUMeshGetPartMeasureField1 ); + CPPUNIT_TEST( testUMeshBuildPartOrthogonalField1 ); + CPPUNIT_TEST( testUMeshGetTypesOfPart1 ); + CPPUNIT_TEST( testUMeshKeepCellIdsByType1 ); + CPPUNIT_TEST( testDAIAggregateMulti1 ); + CPPUNIT_TEST( testMergeUMeshes2 ); + CPPUNIT_TEST( testBuild0DMeshFromCoords1 ); + //MEDCouplingBasicsTest4.cxx + CPPUNIT_TEST( testDescriptionInMeshTimeUnit1 ); + CPPUNIT_TEST( testMultiFields1 ); + CPPUNIT_TEST( testFieldOverTime1 ); + CPPUNIT_TEST( testDAICheckAndPreparePermutation1 ); + CPPUNIT_TEST( testDAIChangeSurjectiveFormat1 ); + CPPUNIT_TEST( testUMeshGetCellIdsLyingOnNodes1 ); + CPPUNIT_TEST( testUMeshFindCellsIdsOnBoundary1 ); + CPPUNIT_TEST( testMeshSetTime1 ); + CPPUNIT_TEST( testApplyFuncTwo1 ); + CPPUNIT_TEST( testApplyFuncThree1 ); + CPPUNIT_TEST( testFillFromAnalyticTwo1 ); + CPPUNIT_TEST( testFillFromAnalyticThree1 ); + CPPUNIT_TEST( testDAUnitVar1 ); + CPPUNIT_TEST( testGaussCoordinates1 ); + CPPUNIT_TEST( testP2Localization1 ); + CPPUNIT_TEST( testP2Localization2 ); + CPPUNIT_TEST( testGetValueOn2 ); + CPPUNIT_TEST( testDAIGetIdsNotEqual1 ); + CPPUNIT_TEST( testDAIComputeOffsets1 ); + CPPUNIT_TEST( testUMeshHexagonPrism1 ); + CPPUNIT_TEST( testDADCheckIsMonotonic ); + CPPUNIT_TEST( testCheckCoherencyDeeper1 ); + CPPUNIT_TEST( testUnPolyze2 ); + CPPUNIT_TEST( testDACpyFrom1 ); + CPPUNIT_TEST( testDAITransformWithIndArr1 ); + CPPUNIT_TEST( testDAIBuildPermArrPerLevel1 ); + CPPUNIT_TEST( testDAIOperations1 ); + CPPUNIT_TEST( testEmulateMEDMEMBDC1 ); + CPPUNIT_TEST( testGetLevArrPerCellTypes1 ); + CPPUNIT_TEST( testSortCellsInMEDFileFrmt1 ); + CPPUNIT_TEST( testBuildPartAndReduceNodes1 ); + CPPUNIT_TEST( testDAITransformWithIndArrR1 ); //MEDCouplingBasicsTestInterp.cxx CPPUNIT_TEST( test2DInterpP0P0_1 ); CPPUNIT_TEST( test2DInterpP0P0PL_1 ); @@ -299,6 +379,7 @@ namespace ParaMEDMEM void testFillFromAnalytic3(); void testFieldDoubleOpEqual1(); void testAreaBary3D2(); + //MEDCouplingBasicsTest3.cxx void testGetMeasureFieldCMesh1(); void testFieldDoubleZipCoords1(); void testFieldDoubleZipConnectivity1(); @@ -314,6 +395,83 @@ namespace ParaMEDMEM void testDataArrayIntInvertO2NNO21(); void testKeepSetSelectedComponent1(); void testKeepSetSelectedComponent2(); + void testDAIGetIdsEqual1(); + void testDAIGetIdsEqualList1(); + void testDAFromNoInterlace1(); + void testDAToNoInterlace1(); + void testDAIsUniform1(); + void testDADFromPolarToCart1(); + void testDADFromCylToCart1(); + void testDADFromSpherToCart1(); + void testUnPolyze1(); + void testConvertDegeneratedCells1(); + void testGetNodeIdsNearPoints1(); + void testFieldCopyTinyAttrFrom1(); + void testExtrudedMesh5(); + void testExtrudedMesh6(); + void testExtrudedMesh7(); + void testSimplexize1(); + void testSimplexize2(); + void testDAMeld1(); + void testFieldMeld1(); + void testMergeNodes2(); + void testMergeField2(); + void testDAIBuildComplement1(); + void testDAIBuildUnion1(); + void testDAIBuildIntersection1(); + void testDAIDeltaShiftIndex1(); + void testDaDoubleSelectByTupleIdSafe1(); + void testAreCellsIncludedIn1(); + void testDAIBuildSubstraction1(); + void testBuildOrthogonalField2(); + void testUMInsertNextCell1(); + void testFieldOperatorDivDiffComp1(); + void testDARearrange1(); + void testGetDifferentValues1(); + void testDAIBuildPermutationArr1(); + void testAreCellsIncludedIn2(); + void testUMeshGetPartBarycenterAndOwner1(); + void testUMeshGetPartMeasureField1(); + void testUMeshBuildPartOrthogonalField1(); + void testUMeshGetTypesOfPart1(); + void testUMeshKeepCellIdsByType1(); + void testDAIAggregateMulti1(); + void testMergeUMeshes2(); + void testBuild0DMeshFromCoords1(); + //MEDCouplingBasicsTest4.cxx + void testDescriptionInMeshTimeUnit1(); + void testMultiFields1(); + void testFieldOverTime1(); + void testDAICheckAndPreparePermutation1(); + void testDAIChangeSurjectiveFormat1(); + void testUMeshGetCellIdsLyingOnNodes1(); + void testUMeshFindCellsIdsOnBoundary1(); + void testMeshSetTime1(); + void testApplyFuncTwo1(); + void testApplyFuncThree1(); + void testFillFromAnalyticTwo1(); + void testFillFromAnalyticThree1(); + void testDAUnitVar1(); + void testGaussCoordinates1(); + void testQ1Localization1(); + void testP2Localization1(); + void testP2Localization2(); + void testGetValueOn2(); + void testDAIGetIdsNotEqual1(); + void testDAIComputeOffsets1(); + void testUMeshHexagonPrism1(); + void testDADCheckIsMonotonic(); + void testCheckCoherencyDeeper1(); + void testUnPolyze2(); + void testDACpyFrom1(); + void testDAITransformWithIndArr1(); + void testDAIBuildPermArrPerLevel1(); + void testDAIOperations1(); + void testEmulateMEDMEMBDC1(); + void testGetLevArrPerCellTypes1(); + void testSortCellsInMEDFileFrmt1(); + void testBuildPartAndReduceNodes1(); + void testDAITransformWithIndArrR1(); //MEDCouplingBasicsTestInterp.cxx void test2DInterpP0P0_1(); void test2DInterpP0P0PL_1(); @@ -407,6 +565,14 @@ namespace ParaMEDMEM static MEDCouplingUMesh *build2DTargetMesh_3(); static MEDCouplingUMesh *build3DTargetMesh_3(); static MEDCouplingUMesh *build2DTargetMesh_4(); + static MEDCouplingUMesh *build1DMultiTypes_1(); + static MEDCouplingUMesh *build2DMultiTypes_1(); + static MEDCouplingUMesh *build3DMultiTypes_1(); + static MEDCouplingUMesh *buildHexa8Mesh_1(); + static MEDCouplingUMesh *buildPointe_1(MEDCouplingUMesh *&m1); + static DataArrayDouble *buildCoordsForMultiTypes_1(); + static MEDCouplingMultiFields *buildMultiFields_1(); + static std::vector buildMultiFields_2(); static double sumAll(const std::vector< std::map >& matrix); }; } diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest0.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest0.cxx index 3f7adf58a..936adb68f 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest0.cxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest0.cxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "MEDCouplingBasicsTest.hxx" @@ -22,6 +22,7 @@ #include "MEDCouplingExtrudedMesh.hxx" #include "MEDCouplingFieldDouble.hxx" #include "MEDCouplingMemArray.hxx" +#include "MEDCouplingMultiFields.hxx" #include "MEDCouplingBasicsTestData1.hxx" @@ -443,13 +444,13 @@ MEDCouplingUMesh *MEDCouplingBasicsTest::build3DTargetMeshMergeNode_1() MEDCouplingUMesh *MEDCouplingBasicsTest::build3DExtrudedUMesh_1(MEDCouplingUMesh *&mesh2D) { double coords[180]={ - 0.,0.,0., 1.,1.,0., 1.,1.25,0., 0.,1.,0., 1.,1.5,0., 2.,0.,0., 2.,1.,0., 1.,2.,0., 0.,2.,0., 3.,1.,0., + 0.,0.,0., 1.,1.,0., 1.,1.25,0., 1.,0.,0., 1.,1.5,0., 2.,0.,0., 2.,1.,0., 1.,2.,0., 0.,2.,0., 3.,1.,0., 3.,2.,0., 0.,1.,0., 1.,3.,0., 2.,2.,0., 2.,3.,0., - 0.,0.,1., 1.,1.,1., 1.,1.25,1., 0.,1.,1., 1.,1.5,1., 2.,0.,1., 2.,1.,1., 1.,2.,1., 0.,2.,1., 3.,1.,1., + 0.,0.,1., 1.,1.,1., 1.,1.25,1., 1.,0.,1., 1.,1.5,1., 2.,0.,1., 2.,1.,1., 1.,2.,1., 0.,2.,1., 3.,1.,1., 3.,2.,1., 0.,1.,1., 1.,3.,1., 2.,2.,1., 2.,3.,1., - 0.,0.,2., 1.,1.,2., 1.,1.25,2., 0.,1.,2., 1.,1.5,2., 2.,0.,2., 2.,1.,2., 1.,2.,2., 0.,2.,2., 3.,1.,2., + 0.,0.,2., 1.,1.,2., 1.,1.25,2., 1.,0.,2., 1.,1.5,2., 2.,0.,2., 2.,1.,2., 1.,2.,2., 0.,2.,2., 3.,1.,2., 3.,2.,2., 0.,1.,2., 1.,3.,2., 2.,2.,2., 2.,3.,2., - 0.,0.,3., 1.,1.,3., 1.,1.25,3., 0.,1.,3., 1.,1.5,3., 2.,0.,3., 2.,1.,3., 1.,2.,3., 0.,2.,3., 3.,1.,3., + 0.,0.,3., 1.,1.,3., 1.,1.25,3., 1.,0.,3., 1.,1.5,3., 2.,0.,3., 2.,1.,3., 1.,2.,3., 0.,2.,3., 3.,1.,3., 3.,2.,3., 0.,1.,3., 1.,3.,3., 2.,2.,3., 2.,3.,3.}; int conn[354]={ @@ -842,6 +843,328 @@ MEDCouplingUMesh *MEDCouplingBasicsTest::build3DTargetMesh_3() return 0; } +MEDCouplingMultiFields *MEDCouplingBasicsTest::buildMultiFields_1() +{ + ParaMEDMEM::MEDCouplingUMesh *m1=build2DTargetMesh_1(); + m1->setName("m1"); + ParaMEDMEM::MEDCouplingUMesh *m2=build2DTargetMesh_1(); + m2->setName("m2"); + const double vals0[]={-0.7,-1.,-2.,-3.,-4.}; + const double vals1[]={0.,1.,2.,3.,4.,0.1,0.2,0.3,0.4}; + const double vals1_1[]={170.,171.,172.,173.,174.,170.1,170.2,170.3,170.4}; + const double vals2[]={5.,6.,7.,8.,9.}; + const double vals4[]={15.,16.,17.,18.,19.}; + // + ParaMEDMEM::DataArrayDouble *d0=ParaMEDMEM::DataArrayDouble::New(); d0->alloc(5,1); std::copy(vals0,vals0+5,d0->getPointer()); + ParaMEDMEM::DataArrayDouble *d1=ParaMEDMEM::DataArrayDouble::New(); d1->alloc(9,1); std::copy(vals1,vals1+9,d1->getPointer()); + ParaMEDMEM::DataArrayDouble *d1_1=ParaMEDMEM::DataArrayDouble::New(); d1_1->alloc(9,1); std::copy(vals1_1,vals1_1+9,d1_1->getPointer()); + ParaMEDMEM::DataArrayDouble *d2=ParaMEDMEM::DataArrayDouble::New(); d2->alloc(5,1); std::copy(vals2,vals2+5,d2->getPointer()); + ParaMEDMEM::DataArrayDouble *d4=ParaMEDMEM::DataArrayDouble::New(); d4->alloc(5,1); std::copy(vals4,vals4+5,d4->getPointer()); + // + d0->setName("d0"); d1->setName("d1"); d1_1->setName("d1_1"); d2->setName("d2"); d4->setName("d4"); + d0->setInfoOnComponent(0,"c1"); + d1->setInfoOnComponent(0,"c6"); + d1_1->setInfoOnComponent(0,"c9"); + d2->setInfoOnComponent(0,"c5"); + d4->setInfoOnComponent(0,"c7"); + // + ParaMEDMEM::MEDCouplingFieldDouble *f0=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME); + f0->setMesh(m1); + f0->setArray(d0); + f0->setTime(0.2,5,6); + f0->setName("f0"); + ParaMEDMEM::MEDCouplingFieldDouble *f1=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_NODES,ParaMEDMEM::LINEAR_TIME); + f1->setMesh(m1); + std::vector d1s(2); d1s[0]=d1; d1s[1]=d1_1; + f1->setArrays(d1s); + f1->setStartTime(0.7,7,8); + f1->setEndTime(1.2,9,10); + f1->setName("f1"); + ParaMEDMEM::MEDCouplingFieldDouble *f2=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::CONST_ON_TIME_INTERVAL); + f2->setMesh(m2); + f2->setArray(d2); + f2->setTime(1.2,11,12); + f2->setEndTime(1.5,13,14); + f2->setName("f2"); + ParaMEDMEM::MEDCouplingFieldDouble *f3=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME); + f3->setMesh(m1); + f3->setArray(d2); + f3->setTime(1.7,15,16); + f3->setName("f3"); + ParaMEDMEM::MEDCouplingFieldDouble *f4=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::NO_TIME); + f4->setMesh(m2); + f4->setArray(d4); + f4->setName("f4"); + // + std::vector fs(5); + fs[0]=f0; fs[1]=f1; fs[2]=f2; fs[3]=f3; fs[4]=f4; + ParaMEDMEM::MEDCouplingMultiFields *ret=ParaMEDMEM::MEDCouplingMultiFields::New(fs); + // + m1->decrRef(); + m2->decrRef(); + d0->decrRef(); + d1->decrRef(); + d1_1->decrRef(); + d2->decrRef(); + d4->decrRef(); + f0->decrRef(); + f1->decrRef(); + f2->decrRef(); + f3->decrRef(); + f4->decrRef(); + // + return ret; +} + +std::vector MEDCouplingBasicsTest::buildMultiFields_2() +{ + ParaMEDMEM::MEDCouplingUMesh *m1=build2DTargetMesh_1(); + m1->setName("m1"); + ParaMEDMEM::MEDCouplingUMesh *m2=build2DTargetMesh_1(); + m2->setName("m2"); + const double vals0[]={-0.7,-1.,-2.,-3.,-4.}; + const double vals1[]={0.,1.,2.,3.,4.}; + const double vals1_1[]={170.,171.,172.,173.,174.}; + const double vals2[]={5.,6.,7.,8.,9.}; + const double vals4[]={15.,16.,17.,18.,19.}; + // + ParaMEDMEM::DataArrayDouble *d0=ParaMEDMEM::DataArrayDouble::New(); d0->alloc(5,1); std::copy(vals0,vals0+5,d0->getPointer()); + ParaMEDMEM::DataArrayDouble *d1=ParaMEDMEM::DataArrayDouble::New(); d1->alloc(5,1); std::copy(vals1,vals1+5,d1->getPointer()); + ParaMEDMEM::DataArrayDouble *d1_1=ParaMEDMEM::DataArrayDouble::New(); d1_1->alloc(5,1); std::copy(vals1_1,vals1_1+5,d1_1->getPointer()); + ParaMEDMEM::DataArrayDouble *d2=ParaMEDMEM::DataArrayDouble::New(); d2->alloc(5,1); std::copy(vals2,vals2+5,d2->getPointer()); + ParaMEDMEM::DataArrayDouble *d4=ParaMEDMEM::DataArrayDouble::New(); d4->alloc(5,1); std::copy(vals4,vals4+5,d4->getPointer()); + // + d0->setName("d0"); d1->setName("d1"); d1_1->setName("d1_1"); d2->setName("d2"); d4->setName("d4"); + d0->setInfoOnComponent(0,"c1"); + d1->setInfoOnComponent(0,"c6"); + d1_1->setInfoOnComponent(0,"c9"); + d2->setInfoOnComponent(0,"c5"); + d4->setInfoOnComponent(0,"c7"); + // + ParaMEDMEM::MEDCouplingFieldDouble *f0=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME); + f0->setMesh(m1); + f0->setArray(d0); + f0->setTime(0.2,5,6); + f0->setName("f0"); + ParaMEDMEM::MEDCouplingFieldDouble *f1=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::LINEAR_TIME); + f1->setMesh(m1); + std::vector d1s(2); d1s[0]=d1; d1s[1]=d1_1; + f1->setArrays(d1s); + f1->setStartTime(0.7,7,8); + f1->setEndTime(1.2,9,10); + f1->setName("f1"); + ParaMEDMEM::MEDCouplingFieldDouble *f2=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::CONST_ON_TIME_INTERVAL); + f2->setMesh(m2); + f2->setArray(d2); + f2->setTime(1.2,11,12); + f2->setEndTime(1.5,13,14); + f2->setName("f2"); + ParaMEDMEM::MEDCouplingFieldDouble *f3=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME); + f3->setMesh(m1); + f3->setArray(d2); + f3->setTime(1.7,15,16); + f3->setName("f3"); + ParaMEDMEM::MEDCouplingFieldDouble *f4=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::NO_TIME); + f4->setMesh(m2); + f4->setArray(d4); + f4->setName("f4"); + // + std::vector fs(5); + fs[0]=f0; fs[1]=f1; fs[2]=f2; fs[3]=f3; fs[4]=f4; + m1->decrRef(); + m2->decrRef(); + d0->decrRef(); + d1->decrRef(); + d1_1->decrRef(); + d2->decrRef(); + d4->decrRef(); + // + return fs; +} + +MEDCouplingUMesh *MEDCouplingBasicsTest::build1DMultiTypes_1() +{ + MEDCouplingUMesh *mesh=MEDCouplingUMesh::New("Multi1DMesh",1); + DataArrayDouble *coo=buildCoordsForMultiTypes_1(); + const int conn[5]={0,2, 0,2,1}; + mesh->allocateCells(2); + mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn); + mesh->insertNextCell(INTERP_KERNEL::NORM_SEG3,3,conn+2); + mesh->finishInsertingCells(); + mesh->setCoords(coo); + coo->decrRef(); + return mesh; +} + +MEDCouplingUMesh *MEDCouplingBasicsTest::build2DMultiTypes_1() +{ + MEDCouplingUMesh *mesh=MEDCouplingUMesh::New("Multi2DMesh",2); + DataArrayDouble *coo=buildCoordsForMultiTypes_1(); + const int conn[21]={3,4,5, 3,4,5,6,7,8, 0,9,10,11, 0,9,10,11,12,13,14,15}; + mesh->allocateCells(4); + mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,conn); + mesh->insertNextCell(INTERP_KERNEL::NORM_TRI6,6,conn+3); + mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+9); + mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD8,8,conn+13); + mesh->finishInsertingCells(); + mesh->setCoords(coo); + coo->decrRef(); + return mesh; +} + +MEDCouplingUMesh *MEDCouplingBasicsTest::build3DMultiTypes_1() +{ + MEDCouplingUMesh *mesh=MEDCouplingUMesh::New("Multi3DMesh",3); + DataArrayDouble *coo=buildCoordsForMultiTypes_1(); + const int conn[81]={0,16,17,18, + 0,16,17,18,19,20,21,22,23,24, + 0,11,10,9,25, + 0,11,10,9,25,15,14,13,12,26,27,28,29, + 0,30,31,32,33,34, + 0,30,31,32,33,34,35,36,37,38,39,40,41,42,43, + 0,9,10,11,44,45,46,47, + 0,9,10,11,44,45,46,47,12,13,14,15,48,49,50,51,52,53,54,55 }; + mesh->allocateCells(8); + mesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,conn); + mesh->insertNextCell(INTERP_KERNEL::NORM_TETRA10,10,conn+4); + mesh->insertNextCell(INTERP_KERNEL::NORM_PYRA5,5,conn+14); + mesh->insertNextCell(INTERP_KERNEL::NORM_PYRA13,13,conn+19); + mesh->insertNextCell(INTERP_KERNEL::NORM_PENTA6,6,conn+32); + mesh->insertNextCell(INTERP_KERNEL::NORM_PENTA15,15,conn+38); + mesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+53); + mesh->insertNextCell(INTERP_KERNEL::NORM_HEXA20,20,conn+61); + mesh->finishInsertingCells(); + mesh->setCoords(coo); + coo->decrRef(); + return mesh; +} + +DataArrayDouble *MEDCouplingBasicsTest::buildCoordsForMultiTypes_1() +{ + DataArrayDouble *coords=DataArrayDouble::New(); + coords->alloc(56,3); + coords->setInfoOnComponent(0,"X (cm)"); + coords->setInfoOnComponent(1,"Y (cm)"); + coords->setInfoOnComponent(2,"Z (cm)"); + const double data[168]={ + 0.0, 0.0, 0.0, //#0 + 0.5, 0.5, 0.5, //#1 + 1.0, 1.0, 1.0, //#2 + 1.0, 1.0, 0.0, //#3 + 2.0, 2.5, 0.0, //#4 + 6.0, 1.5, 0.0, //#5 + 1.0, 2.0, 0.0, //#6 + 4.5, 2.5, 0.0, //#7 + 4.0, 0.5, 0.0, //#8 + 0.0, 4.0, 0.0, //#9 + 4.0, 4.0, 0.0, //#10 + 4.0, 0.0, 0.0, //#11 + 0.0, 2.0, 0.0, //#12 + 2.0, 4.0, 0.0, //#13 + 4.0, 2.0, 0.0, //#14 + 2.0, 0.0, 0.0, //#15 + 0.0, 6.0, 0.0, //#16 + 3.0, 3.0, 0.0, //#17 + 1.3, 3.0, 3.0, //#18 + 0.0, 3.0, 0.0, //#19 + 1.5, 4.5, 0.0, //#20 + 1.5, 1.5, 0.0, //#21 + 0.65, 1.5, 1.5, //#22 + 0.65, 4.5, 1.5, //#23 + 2.15, 3.0, 1.5, //#24 + 2.0, 2.0, 2.0, //#25 + 3.0, 1.0, 1.0, //#26 + 3.0, 3.0, 1.0, //#27 + 1.0, 3.0, 1.0, //#28 + 1.0, 1.0, 1.0, //#29 + 0.0, 3.0, 0.0, //#30 + 2.0, 0.0, 0.0, //#31 + 0.0, 0.0, 6.0, //#32 + 0.0, 3.0, 6.0, //#33 + 3.0, 0.0, 6.0, //#34 + 0.0, 1.5, 0.0, //#35 + 1.5, 1.5, 0.0, //#36 + 1.5, 0.0, 0.0, //#37 + 0.0, 1.5, 6.0, //#38 + 1.5, 1.5, 6.0, //#39 + 1.5, 0.0, 6.0, //#40 + 0.0, 0.0, 3.0, //#41 + 0.0, 3.0, 3.0, //#42 + 3.0, 0.0, 3.0, //#43 + 0.0, 0.0, 4.0, //#44 + 0.0, 4.0, 4.0, //#45 + 4.0, 4.0, 4.0, //#46 + 4.0, 0.0, 4.0, //#47 + 0.0, 2.0, 4.0, //#48 + 2.0, 4.0, 4.0, //#49 + 4.0, 2.0, 4.0, //#50 + 2.0, 0.0, 4.0, //#51 + 0.0, 0.0, 2.0, //#52 + 0.0, 4.0, 2.0, //#53 + 4.0, 4.0, 2.0, //#54 + 4.0, 0.0, 2.0 //#55 + }; + std::copy(data,data+168,coords->getPointer()); + return coords; +} + +MEDCouplingUMesh *MEDCouplingBasicsTest::buildHexa8Mesh_1() +{ + MEDCouplingUMesh *mesh=MEDCouplingUMesh::New("Hexa8Only",3); + DataArrayDouble *coo=DataArrayDouble::New(); + const double coords[81]={0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.5, 0.5, 0.0, 1.0, 0.5, 0.0, 0.0, 1.0, 0.0, 0.5, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.0, 0.5, 1.0, 0.0, 0.5, 0.0, 0.5, 0.5, 0.5, 0.5, 0.5, 1.0, 0.5, 0.5, 0.0, 1.0, 0.5, 0.5, 1.0, 0.5, 1.0, 1.0, 0.5, 0.0, 0.0, 1.0, 0.5, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.5, 1.0, 0.5, 0.5, 1.0, 1.0, 0.5, 1.0, 0.0, 1.0, 1.0, 0.5, 1.0, 1.0, 1.0, 1.0, 1.0}; + coo->alloc(27,3); + std::copy(coords,coords+81,coo->getPointer()); + const int conn[64]={3,12,13,4,0,9,10,1, + 4,13,14,5,1,10,11,2, + 6,15,16,7,3,12,13,4, + 7,16,17,8,4,13,14,5, + 12,21,22,13,9,18,19,10, + 13,22,23,14,10,19,20,11, + 15,24,25,16,12,21,22,13, + 16,25,26,17,13,22,23,14}; + mesh->allocateCells(8); + for(int i=0;i<8;i++) + mesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+8*i); + mesh->finishInsertingCells(); + mesh->setCoords(coo); + coo->decrRef(); + return mesh; +} + +MEDCouplingUMesh *MEDCouplingBasicsTest::buildPointe_1(MEDCouplingUMesh *& m1) +{ + MEDCouplingUMesh *mesh=MEDCouplingUMesh::New("Pointe.med",3); + MEDCouplingUMesh *mesh2=MEDCouplingUMesh::New("Pointe.med",2); + const double coords[57]={0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 2.0, 0.0, 1.0, 0.0, 2.0, 1.0, -2.0, 0.0, 1.0, 0.0, -2.0, 1.0, 1.0, 1.0, 2.0, -1.0, 1.0, 2.0, -1.0, -1.0, 2.0, 1.0, -1.0, 2.0, 1.0, 1.0, 3.0, -1.0, 1.0, 3.0, -1.0, -1.0, 3.0, 1.0, -1.0, 3.0, 1.0, 1.0, 4.0, -1.0, 1.0, 4.0, -1.0, -1.0, 4.0, 1.0, -1.0, 4.0, 0.0, 0.0, 5.0}; + const int conn[74]={0,1,2,5,0,1,3,2,0,1,4,3,0,1,5,4,1,6,3,2,1,7,4,3,1,8,5,4,1,9,2,5,1,6,2,9,1,7,3,6,1,8,4,7,1,9,5,8, 6,7,8,9,1,14,17,16,15,18, 10,11,12,13,6,7,8,9,14,15,16,17,10,11,12,13}; + DataArrayDouble *coo=DataArrayDouble::New(); + coo->alloc(19,3); + std::copy(coords,coords+57,coo->getPointer()); + mesh->setCoords(coo); + mesh2->setCoords(coo); + coo->decrRef(); + mesh->allocateCells(16); + for(int i=0;i<12;i++) + mesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,conn+4*i); + mesh->insertNextCell(INTERP_KERNEL::NORM_PYRA5,5,conn+48); + mesh->insertNextCell(INTERP_KERNEL::NORM_PYRA5,5,conn+53); + mesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+58); + mesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+66); + mesh->finishInsertingCells(); + //[1,34,29,23,41,32] + const int conn2[20]={0,5,1,14,18,17,8,7,4,9,5,2, 12,8,9,13,6,7,8,9}; + mesh2->allocateCells(6); + for(int i=0;i<4;i++) + mesh2->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,conn2+3*i); + mesh2->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn2+12); + mesh2->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn2+16); + mesh2->finishInsertingCells(); + m1=mesh2; + // + return mesh; +} + double MEDCouplingBasicsTest::sumAll(const std::vector< std::map >& matrix) { double ret=0.; diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest1.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest1.cxx index ffa8b6a75..a71b6220c 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest1.cxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest1.cxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "MEDCouplingBasicsTest.hxx" @@ -258,18 +258,18 @@ void MEDCouplingBasicsTest::testMesh() void MEDCouplingBasicsTest::testMeshPointsCloud() { double targetCoords[27]={-0.3,-0.3,0.5, 0.2,-0.3,1., 0.7,-0.3,1.5, -0.3,0.2,0.5, 0.2,0.2,1., 0.7,0.2,1.5, -0.3,0.7,0.5, 0.2,0.7,1., 0.7,0.7,1.5}; - int *targetConn=0; + const int targetConn[]={0,1,2,3,4,5,7,6}; MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New(); targetMesh->setMeshDimension(0); targetMesh->allocateCells(8); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT0,0,targetConn); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT0,0,targetConn); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT0,0,targetConn); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT0,0,targetConn); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT0,0,targetConn); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT0,0,targetConn); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT0,0,targetConn); - targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT0,0,targetConn); + targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn); + targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+1); + targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+2); + targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+3); + targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+4); + targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+5); + targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+6); + targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+7); targetMesh->finishInsertingCells(); DataArrayDouble *myCoords=DataArrayDouble::New(); myCoords->alloc(9,3); @@ -325,7 +325,7 @@ void MEDCouplingBasicsTest::testDeepCopy() std::fill(array->getPointer(),array->getPointer()+5*3,7.); CPPUNIT_ASSERT_DOUBLES_EQUAL(7.,array->getIJ(3,2),1e-14); double *tmp1=array->getPointer(); - DataArrayDouble *array2=array->deepCopy(); + DataArrayDouble *array2=array->deepCpy(); double *tmp2=array2->getPointer(); CPPUNIT_ASSERT(tmp1!=tmp2); array->decrRef(); @@ -337,7 +337,7 @@ void MEDCouplingBasicsTest::testDeepCopy() std::fill(array3->getPointer(),array3->getPointer()+5*3,17); CPPUNIT_ASSERT_EQUAL(17,array3->getIJ(3,2)); int *tmp3=array3->getPointer(); - DataArrayInt *array4=array3->deepCopy(); + DataArrayInt *array4=array3->deepCpy(); int *tmp4=array4->getPointer(); CPPUNIT_ASSERT(tmp3!=tmp4); array3->decrRef(); @@ -730,10 +730,10 @@ void MEDCouplingBasicsTest::testZipConnectivity() CPPUNIT_ASSERT(m3); m2->decrRef(); MEDCouplingUMesh *m4=build2DSourceMesh_1(); - MEDCouplingUMesh *m5=MEDCouplingUMesh::mergeUMeshes(m1,m3); + MEDCouplingUMesh *m5=MEDCouplingUMesh::MergeUMeshes(m1,m3); m1->decrRef(); m3->decrRef(); - MEDCouplingUMesh *m6=MEDCouplingUMesh::mergeUMeshes(m5,m4); + MEDCouplingUMesh *m6=MEDCouplingUMesh::MergeUMeshes(m5,m4); m4->decrRef(); m5->decrRef(); // @@ -873,7 +873,7 @@ void MEDCouplingBasicsTest::testEqualFieldDouble() CPPUNIT_ASSERT(fieldOnCells1->isEqual(fieldOnCells2,1e-12,1e-15)); CPPUNIT_ASSERT(fieldOnCells2->isEqual(fieldOnCells1,1e-12,1e-15)); // - DataArrayDouble *arr2=arr->deepCopy(); + DataArrayDouble *arr2=arr->deepCpy(); fieldOnCells2->setArray(arr2); arr2->decrRef(); CPPUNIT_ASSERT(fieldOnCells1->isEqual(fieldOnCells2,1e-12,1e-15)); @@ -930,7 +930,7 @@ void MEDCouplingBasicsTest::testBuildSubMeshData() DataArrayInt *di; MEDCouplingMesh *ret1=fieldCells->buildSubMeshData(elts,elts+3,di); CPPUNIT_ASSERT_EQUAL(3,ret1->getNumberOfCells()); - CPPUNIT_ASSERT_EQUAL(6,ret1->getNumberOfNodes()); + CPPUNIT_ASSERT_EQUAL(9,ret1->getNumberOfNodes()); CPPUNIT_ASSERT_EQUAL(3,di->getNumberOfTuples()); CPPUNIT_ASSERT_EQUAL(1,di->getNumberOfComponents()); const int *toCheck=di->getConstPointer(); @@ -1049,7 +1049,7 @@ void MEDCouplingBasicsTest::testExtrudedMesh2() } /*! - * This test check MEDCouplingUMesh::buildExtrudedMeshFromThis method. + * This test check MEDCouplingUMesh::buildExtrudedMesh method. */ void MEDCouplingBasicsTest::testExtrudedMesh3() { @@ -1060,7 +1060,7 @@ void MEDCouplingBasicsTest::testExtrudedMesh3() double center[3]={0.,0.,0.}; double vector[3]={0,1,0}; m2->rotate(center,vector,-M_PI/2.); - MEDCouplingUMesh *m3=m1->buildExtrudedMeshFromThis(m2,0); + MEDCouplingUMesh *m3=m1->buildExtrudedMesh(m2,0); // MEDCouplingExtrudedMesh *m4=MEDCouplingExtrudedMesh::New(m3,m1,0); CPPUNIT_ASSERT_EQUAL(15,m4->getNumberOfCells()); @@ -1085,7 +1085,7 @@ void MEDCouplingBasicsTest::testExtrudedMesh3() //play with polygons and polyedrons std::vector cells(2); cells[0]=2; cells[1]=3; m1->convertToPolyTypes(cells); - m3=m1->buildExtrudedMeshFromThis(m2,0); + m3=m1->buildExtrudedMesh(m2,0); CPPUNIT_ASSERT_EQUAL((int)INTERP_KERNEL::NORM_HEXA8,(int)m3->getTypeOfCell(0)); CPPUNIT_ASSERT_EQUAL((int)INTERP_KERNEL::NORM_PENTA6,(int)m3->getTypeOfCell(1)); CPPUNIT_ASSERT_EQUAL((int)INTERP_KERNEL::NORM_POLYHED,(int)m3->getTypeOfCell(2)); @@ -1107,7 +1107,7 @@ void MEDCouplingBasicsTest::testExtrudedMesh3() } /*! - * This test check MEDCouplingUMesh::buildExtrudedMeshFromThis method, but also, MEDCouplingExtrudedMesh following methods : + * This test check MEDCouplingUMesh::buildExtrudedMesh method, but also, MEDCouplingExtrudedMesh following methods : * getCellContainingPoint getMeasureField getNodeIdsOfCell getCoordinateOfNode getTypeOfCell build3DUnstructuredMesh. */ void MEDCouplingBasicsTest::testExtrudedMesh4() @@ -1121,7 +1121,7 @@ void MEDCouplingBasicsTest::testExtrudedMesh4() double center[3]={0.,0.,0.}; double vector[3]={0.,1.,0.}; m2->rotate(center,vector,-M_PI/2.); - MEDCouplingUMesh *m3=m1->buildExtrudedMeshFromThis(m2,0); + MEDCouplingUMesh *m3=m1->buildExtrudedMesh(m2,0); const int expected1[15]= {1,3,2,0,6,5,7,10,11,8,12,9,14,13,4}; const int rexpected1[15]={3, 0, 2, 1, 14, 5, 4, 6, 9, 11, 7, 8, 10, 13, 12}; m3->renumberCells(expected1,false); @@ -1319,9 +1319,9 @@ void MEDCouplingBasicsTest::testMergeMeshOnSameCoords1() m1->tryToShareSameCoords(*m2,1e-12); MEDCouplingUMesh *m3=build2DTargetMesh_1(); m3->tryToShareSameCoords(*m2,1e-12); - std::vector meshes; + std::vector meshes; meshes.push_back(m1); meshes.push_back(m2); meshes.push_back(m3); - MEDCouplingUMesh *m4=MEDCouplingUMesh::mergeUMeshesOnSameCoords(meshes); + MEDCouplingUMesh *m4=MEDCouplingUMesh::MergeUMeshesOnSameCoords(meshes); m4->checkCoherency(); CPPUNIT_ASSERT(m4->getCoords()==m1->getCoords()); CPPUNIT_ASSERT_EQUAL(15,m4->getNumberOfCells()); @@ -1353,7 +1353,7 @@ void MEDCouplingBasicsTest::testMergeField1() m2->translate(vec); MEDCouplingFieldDouble *f1=m1->getMeasureField(true); MEDCouplingFieldDouble *f2=m2->getMeasureField(true); - MEDCouplingFieldDouble *f3=MEDCouplingFieldDouble::mergeFields(f1,f2); + MEDCouplingFieldDouble *f3=MEDCouplingFieldDouble::MergeFields(f1,f2); f3->checkCoherency(); MEDCouplingUMesh *m4=build2DTargetMeshMerged_1(); CPPUNIT_ASSERT(f3->getMesh()->isEqual(m4,1.e-12)); @@ -1978,7 +1978,8 @@ void MEDCouplingBasicsTest::testSplitByType() MEDCouplingUMesh *m1=build3DSurfTargetMesh_1(); std::vector v=m1->splitByType(); CPPUNIT_ASSERT_EQUAL(3,(int)v.size()); - MEDCouplingUMesh *m2=MEDCouplingUMesh::mergeUMeshesOnSameCoords(v); + std::vector v2(v.begin(),v.end()); + MEDCouplingUMesh *m2=MEDCouplingUMesh::MergeUMeshesOnSameCoords(v2); m2->setName(m1->getName()); CPPUNIT_ASSERT(m1->isEqual(m2,1.e-12)); for(std::vector::const_iterator iter=v.begin();iter!=v.end();iter++) @@ -1989,7 +1990,7 @@ void MEDCouplingBasicsTest::testSplitByType() void MEDCouplingBasicsTest::testFuseUMeshesOnSameCoords() { - std::vector meshes; + std::vector meshes; MEDCouplingUMesh *m2=build2DTargetMesh_1(); int cells1[3]={2,3,4}; MEDCouplingPointSet *m3_1=m2->buildPartOfMySelf(cells1,cells1+3,true); @@ -2009,7 +2010,7 @@ void MEDCouplingBasicsTest::testFuseUMeshesOnSameCoords() m2->decrRef(); // std::vector corr; - MEDCouplingUMesh *m7=MEDCouplingUMesh::fuseUMeshesOnSameCoords(meshes,0,corr); + MEDCouplingUMesh *m7=MEDCouplingUMesh::FuseUMeshesOnSameCoords(meshes,0,corr); CPPUNIT_ASSERT_EQUAL(4,m7->getNumberOfCells()); CPPUNIT_ASSERT_EQUAL(3,(int)corr.size()); const int expectedVals1[3]={3,3,2}; @@ -2025,7 +2026,8 @@ void MEDCouplingBasicsTest::testFuseUMeshesOnSameCoords() CPPUNIT_ASSERT_EQUAL(expectedVals2[i][j],vals[j]); } std::vector< std::vector > fidsOfGroups; - DataArrayInt *arr2=DataArrayInt::makePartition(corr,m7->getNumberOfCells(),fidsOfGroups); + std::vector corr2(corr.begin(),corr.end()); + DataArrayInt *arr2=DataArrayInt::MakePartition(corr2,m7->getNumberOfCells(),fidsOfGroups); const int fidExp[4]={5,1,3,4}; const int fidsGrp[3][3]={{1,3,5},{3,4,5},{4,5,23344}}; CPPUNIT_ASSERT_EQUAL(3,(int)fidsOfGroups.size()); @@ -2057,13 +2059,13 @@ void MEDCouplingBasicsTest::testFuseUMeshesOnSameCoords2() MEDCouplingUMesh *m3=(MEDCouplingUMesh *)m1->buildPartOfMySelf(part1,part1+5,true); const int part2[4]={5,6,4,7}; MEDCouplingUMesh *m4=(MEDCouplingUMesh *)m1->buildPartOfMySelf(part2,part2+4,true); - std::vector meshes; + std::vector meshes; meshes.push_back(m1); meshes.push_back(m3); meshes.push_back(m3); meshes.push_back(m4); std::vector corr; - MEDCouplingUMesh *m5=MEDCouplingUMesh::fuseUMeshesOnSameCoords(meshes,0,corr); + MEDCouplingUMesh *m5=MEDCouplingUMesh::FuseUMeshesOnSameCoords(meshes,0,corr); CPPUNIT_ASSERT_EQUAL(18,m5->getNumberOfCells()); std::vector::iterator it=corr.begin(); const int exp1[4]={18,5,5,4}; @@ -2139,7 +2141,7 @@ void MEDCouplingBasicsTest::testGetCellsContainingPoint() CPPUNIT_ASSERT(std::equal(t2.begin(),t2.end(),expectedValues2)); //2D with no help of bounding box. double center[2]={0.2,0.2}; - MEDCouplingPointSet::rotate2DAlg(center,0.78539816339744830962,6,pos); + MEDCouplingPointSet::Rotate2DAlg(center,0.78539816339744830962,6,pos); targetMesh->rotate(center,0,0.78539816339744830962); t1.clear(); t2.clear(); targetMesh->getCellsContainingPoints(pos,6,1e-12,t1,t2); diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest2.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest2.cxx index 0c36bdbad..0b75ef8af 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest2.cxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest2.cxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "MEDCouplingBasicsTest.hxx" @@ -48,6 +48,7 @@ void MEDCouplingBasicsTest::testGaussPointField1() MEDCouplingUMesh *m=build2DTargetMesh_1(); MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_GAUSS_PT,NO_TIME); f->setMesh(m); + CPPUNIT_ASSERT_EQUAL(5,f->getNumberOfMeshPlacesExpected()); CPPUNIT_ASSERT_EQUAL(0,f->getNbOfGaussLocalization()); f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_TRI3,_refCoo1,_gsCoo1,_wg1); CPPUNIT_ASSERT_THROW(f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_QUAD4,_refCoo1,_gsCoo1,_wg1),INTERP_KERNEL::Exception); @@ -123,6 +124,7 @@ void MEDCouplingBasicsTest::testGaussPointNEField1() MEDCouplingUMesh *m=build2DTargetMesh_1(); MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_GAUSS_NE,NO_TIME); f->setMesh(m); + CPPUNIT_ASSERT_EQUAL(5,f->getNumberOfMeshPlacesExpected()); f->setName("MyFirstFieldOnNE"); f->setDescription("MyDescriptionNE"); DataArrayDouble *array=DataArrayDouble::New(); @@ -215,7 +217,7 @@ void MEDCouplingBasicsTest::testCellOrientation2() double center[3]={0.,0.,0.}; double vector[3]={0.,1.,0.}; m4->rotate(center,vector,-M_PI/2.); - MEDCouplingUMesh *m5=m3->buildExtrudedMeshFromThis(m4,0); + MEDCouplingUMesh *m5=m3->buildExtrudedMesh(m4,0); res1.clear(); m5->arePolyhedronsNotCorrectlyOriented(res1); CPPUNIT_ASSERT_EQUAL(15,(int)res1.size()); @@ -696,6 +698,7 @@ void MEDCouplingBasicsTest::testRenumberNodesForFields() MEDCouplingUMesh *m=build2DTargetMesh_1(); MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_NODES,NO_TIME); f->setMesh(m); + CPPUNIT_ASSERT_EQUAL(9,f->getNumberOfMeshPlacesExpected()); DataArrayDouble *arr=DataArrayDouble::New(); int nbOfNodes=m->getNumberOfNodes(); arr->alloc(nbOfNodes,3); @@ -895,6 +898,7 @@ void MEDCouplingBasicsTest::testCopyTinyStringsFromOnFields() int nbOfCells=m->getNumberOfCells(); MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_CELLS,LINEAR_TIME); f->setMesh(m); + CPPUNIT_ASSERT_EQUAL(5,f->getNumberOfMeshPlacesExpected()); f->setName("a"); f->setDescription("b"); DataArrayDouble *a1=DataArrayDouble::New(); @@ -902,7 +906,7 @@ void MEDCouplingBasicsTest::testCopyTinyStringsFromOnFields() a1->fillWithZero(); a1->setInfoOnComponent(0,"c"); a1->setInfoOnComponent(1,"d"); - DataArrayDouble *a2=a1->deepCopy(); + DataArrayDouble *a2=a1->deepCpy(); a2->setInfoOnComponent(0,"e"); a2->setInfoOnComponent(1,"f"); f->setArray(a1); @@ -1055,7 +1059,7 @@ void MEDCouplingBasicsTest::testChangeUnderlyingMesh1() CPPUNIT_ASSERT(f1->getMesh()==mesh1); f1->changeUnderlyingMesh(mesh2,10,1e-12); CPPUNIT_ASSERT(f1->getMesh()==mesh2); - const double expected2[22]={7.,107.,9.,109.,17.,117.,10.,110.,11.,111.,12.,112.,13.,113.,15.,115.,14.,114.,16.,116.,8.,108.}; + const double expected2[22]={7.,107.,17.,117.,8.,108.,10.,110.,11.,111.,12.,112.,13.,113.,15.,115.,14.,114.,16.,116.,9.,109.}; for(int i=0;i<22;i++) CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],f1->getArray()->getIJ(0,i),1e-12); f1->decrRef(); @@ -1117,14 +1121,14 @@ void MEDCouplingBasicsTest::testSubstractInPlaceDM1() CPPUNIT_ASSERT_EQUAL(2,f1->getNumberOfComponents()); CPPUNIT_ASSERT_EQUAL(20,f1->getNumberOfValues()); // - const int renum[]={0,2,1,3,4,5,6,8,7,9}; + const int renum[]={0,2,3,1,4,5,6,8,7,9}; mesh2->renumberCells(renum,false); // MEDCouplingFieldDouble *f2=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME); f2->setMesh(mesh2); array=DataArrayDouble::New(); array->alloc(mesh2->getNumberOfCells(),2); - const double arr2[20]={7.1,107.1,9.1,109.1,8.1,108.1,10.1,110.1,11.1,111.1,12.1,112.1,13.1,113.1,15.1,115.1,14.1,114.1,16.1,116.1}; + const double arr2[20]={7.1,107.1,10.1,110.1,8.1,108.1,9.1,109.1,11.1,111.1,12.1,112.1,13.1,113.1,15.1,115.1,14.1,114.1,16.1,116.1}; std::copy(arr2,arr2+20,array->getPointer()); f2->setArray(array); array->decrRef(); @@ -1298,6 +1302,7 @@ void MEDCouplingBasicsTest::testBuildSubPart1() // const int part1[3]={2,1,4}; MEDCouplingFieldDouble *f2=f1->buildSubPart(part1,part1+3); + f2->zipCoords(); CPPUNIT_ASSERT_EQUAL(3,f2->getNumberOfTuples()); CPPUNIT_ASSERT_EQUAL(2,f2->getNumberOfComponents()); const double expected1[6]={5.,105.,4.,104.,7.,107.}; @@ -2217,791 +2222,3 @@ void MEDCouplingBasicsTest::testAreaBary3D2() // mesh->decrRef(); } - -void MEDCouplingBasicsTest::testGetMeasureFieldCMesh1() -{ - MEDCouplingCMesh *m=MEDCouplingCMesh::New(); - DataArrayDouble *da=DataArrayDouble::New(); - const double discX[4]={2.3,3.4,5.8,10.2}; - const double discY[3]={12.3,23.4,45.8}; - const double discZ[5]={-0.7,1.2,1.25,2.13,2.67}; - da->alloc(4,1); - std::copy(discX,discX+4,da->getPointer()); - m->setCoordsAt(0,da); - da->decrRef(); - m->checkCoherency(); - CPPUNIT_ASSERT_EQUAL(4,m->getNumberOfNodes()); - CPPUNIT_ASSERT_EQUAL(3,m->getNumberOfCells()); - CPPUNIT_ASSERT_EQUAL(1,m->getSpaceDimension()); - MEDCouplingFieldDouble *f=m->getMeasureField(true); - CPPUNIT_ASSERT_EQUAL(3,f->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,f->getNumberOfComponents()); - const double expected1[3]={1.1,2.4,4.4}; - for(int i=0;i<3;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f->getIJ(i,0),1e-12); - f->decrRef(); - DataArrayDouble *coords=m->getCoordinatesAndOwner(); - CPPUNIT_ASSERT_EQUAL(4,coords->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,coords->getNumberOfComponents()); - for(int i=0;i<4;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(discX[i],coords->getIJ(i,0),1e-12); - coords->decrRef(); - coords=m->getBarycenterAndOwner(); - CPPUNIT_ASSERT_EQUAL(3,coords->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,coords->getNumberOfComponents()); - const double expected1_3[3]={2.85,4.6,8.}; - for(int i=0;i<3;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1_3[i],coords->getIJ(i,0),1e-12); - coords->decrRef(); - // - da=DataArrayDouble::New(); - da->alloc(3,1); - std::copy(discY,discY+3,da->getPointer()); - m->setCoordsAt(1,da); - da->decrRef(); - m->checkCoherency(); - CPPUNIT_ASSERT_EQUAL(12,m->getNumberOfNodes()); - CPPUNIT_ASSERT_EQUAL(6,m->getNumberOfCells()); - CPPUNIT_ASSERT_EQUAL(2,m->getSpaceDimension()); - f=m->getMeasureField(true); - CPPUNIT_ASSERT_EQUAL(6,f->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,f->getNumberOfComponents()); - const double expected2[6]={12.21,26.64,48.84,24.64,53.76,98.56}; - for(int i=0;i<6;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],f->getIJ(i,0),1e-12); - f->decrRef(); - coords=m->getCoordinatesAndOwner(); - CPPUNIT_ASSERT_EQUAL(12,coords->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(2,coords->getNumberOfComponents()); - const double expected2_2[24]={2.3,12.3,3.4,12.3,5.8,12.3,10.2,12.3, 2.3,23.4,3.4,23.4,5.8,23.4,10.2,23.4, 2.3,45.8,3.4,45.8,5.8,45.8,10.2,45.8}; - for(int i=0;i<24;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2_2[i],coords->getIJ(0,i),1e-12); - coords->decrRef(); - coords=m->getBarycenterAndOwner(); - CPPUNIT_ASSERT_EQUAL(6,coords->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(2,coords->getNumberOfComponents()); - const double expected2_3[12]={2.85,17.85,4.6,17.85,8.,17.85, 2.85,34.6,4.6,34.6,8.,34.6}; - for(int i=0;i<12;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2_3[i],coords->getIJ(0,i),1e-12); - coords->decrRef(); - // - da=DataArrayDouble::New(); - da->alloc(5,1); - std::copy(discZ,discZ+5,da->getPointer()); - m->setCoordsAt(2,da); - da->decrRef(); - m->checkCoherency(); - CPPUNIT_ASSERT_EQUAL(60,m->getNumberOfNodes()); - CPPUNIT_ASSERT_EQUAL(24,m->getNumberOfCells()); - CPPUNIT_ASSERT_EQUAL(3,m->getSpaceDimension()); - f=m->getMeasureField(true); - CPPUNIT_ASSERT_EQUAL(24,f->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,f->getNumberOfComponents()); - const double expected3[24]={23.199, 50.616, 92.796, 46.816, 102.144, 187.264, 0.6105, 1.332, 2.442, 1.232, 2.688, 4.928, 10.7448, 23.4432, 42.9792, 21.6832, 47.3088, 86.7328, 6.5934, 14.3856, 26.3736, 13.3056, 29.0304, 53.2224}; - for(int i=0;i<24;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected3[i],f->getIJ(i,0),1e-12); - f->decrRef(); - coords=m->getCoordinatesAndOwner(); - CPPUNIT_ASSERT_EQUAL(60,coords->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(3,coords->getNumberOfComponents()); - const double expected3_2[180]={ - 2.3,12.3,-0.7, 3.4,12.3,-0.7, 5.8,12.3,-0.7, 10.2,12.3,-0.7, 2.3,23.4,-0.7, 3.4,23.4,-0.7, 5.8,23.4,-0.7, 10.2,23.4,-0.7, 2.3,45.8,-0.7, 3.4,45.8,-0.7, 5.8,45.8,-0.7, 10.2,45.8,-0.7, - 2.3,12.3,1.2, 3.4,12.3,1.2, 5.8,12.3,1.2, 10.2,12.3,1.2, 2.3,23.4,1.2, 3.4,23.4,1.2, 5.8,23.4,1.2, 10.2,23.4,1.2, 2.3,45.8,1.2, 3.4,45.8,1.2, 5.8,45.8,1.2, 10.2,45.8,1.2, - 2.3,12.3,1.25, 3.4,12.3,1.25, 5.8,12.3,1.25, 10.2,12.3,1.25, 2.3,23.4,1.25, 3.4,23.4,1.25, 5.8,23.4,1.25, 10.2,23.4,1.25, 2.3,45.8,1.25, 3.4,45.8,1.25, 5.8,45.8,1.25, 10.2,45.8,1.25, - 2.3,12.3,2.13, 3.4,12.3,2.13, 5.8,12.3,2.13, 10.2,12.3,2.13, 2.3,23.4,2.13, 3.4,23.4,2.13, 5.8,23.4,2.13, 10.2,23.4,2.13, 2.3,45.8,2.13, 3.4,45.8,2.13, 5.8,45.8,2.13, 10.2,45.8,2.13, - 2.3,12.3,2.67, 3.4,12.3,2.67, 5.8,12.3,2.67, 10.2,12.3,2.67, 2.3,23.4,2.67, 3.4,23.4,2.67, 5.8,23.4,2.67, 10.2,23.4,2.67, 2.3,45.8,2.67, 3.4,45.8,2.67, 5.8,45.8,2.67, 10.2,45.8,2.67 - }; - for(int i=0;i<180;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected3_2[i],coords->getIJ(0,i),1e-12); - coords->decrRef(); - coords=m->getBarycenterAndOwner(); - CPPUNIT_ASSERT_EQUAL(24,coords->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(3,coords->getNumberOfComponents()); - const double expected3_3[72]={ - 2.85,17.85,0.25,4.6,17.85,0.25,8.,17.85,0.25, 2.85,34.6,0.25,4.6,34.6,0.25,8.,34.6,0.25, - 2.85,17.85,1.225,4.6,17.85,1.225,8.,17.85,1.225, 2.85,34.6,1.225,4.6,34.6,1.225,8.,34.6,1.225, - 2.85,17.85,1.69,4.6,17.85,1.69,8.,17.85,1.69, 2.85,34.6,1.69,4.6,34.6,1.69,8.,34.6,1.69, - 2.85,17.85,2.4,4.6,17.85,2.4,8.,17.85,2.4, 2.85,34.6,2.4,4.6,34.6,2.4,8.,34.6,2.4 - }; - for(int i=0;i<72;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected3_3[i],coords->getIJ(0,i),1e-12); - coords->decrRef(); - // - m->decrRef(); -} - -void MEDCouplingBasicsTest::testFieldDoubleZipCoords1() -{ - MEDCouplingUMesh *m=build2DTargetMeshMergeNode_1(); - MEDCouplingFieldDouble *f=m->fillFromAnalytic(ON_NODES,2,"x*2."); - f->getArray()->setInfoOnComponent(0,"titi"); - f->getArray()->setInfoOnComponent(1,"tutu"); - f->checkCoherency(); - CPPUNIT_ASSERT_EQUAL(18,f->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(2,f->getNumberOfComponents()); - const double expected1[36]={-0.6, -0.6, 0.4, 0.4, 1.4, 1.4, -0.6, -0.6, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 1.4, 1.4, -0.6, -0.6, 0.4, 0.4, 1.4, 1.4, -0.6, -0.6, 1.4, 1.4, -0.6, -0.6, 0.4, 0.4, 1.4, 1.4, 0.4, 0.4}; - for(int i=0;i<36;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f->getIJ(0,i),1e-12); - CPPUNIT_ASSERT(f->zipCoords()); - f->checkCoherency(); - const double expected2[30]={-0.6, -0.6, 1.4, 1.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 1.4, 1.4, -0.6, -0.6, 0.4, 0.4, 1.4, 1.4, 1.4, 1.4, -0.6, -0.6, 0.4, 0.4, 1.4, 1.4, 0.4, 0.4}; - for(int i=0;i<30;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],f->getIJ(0,i),1e-12); - CPPUNIT_ASSERT(!f->zipCoords()); - f->checkCoherency(); - for(int i=0;i<30;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],f->getIJ(0,i),1e-12); - CPPUNIT_ASSERT(std::string(f->getArray()->getInfoOnComponent(0))=="titi"); - CPPUNIT_ASSERT(std::string(f->getArray()->getInfoOnComponent(1))=="tutu"); - f->decrRef(); - m->decrRef(); -} - -void MEDCouplingBasicsTest::testFieldDoubleZipConnectivity1() -{ - MEDCouplingUMesh *m1=build2DTargetMesh_1(); - MEDCouplingUMesh *m2=build2DTargetMesh_1(); - const int cells1[3]={2,3,4}; - MEDCouplingPointSet *m3_1=m2->buildPartOfMySelf(cells1,cells1+3,true); - MEDCouplingUMesh *m3=dynamic_cast(m3_1); - CPPUNIT_ASSERT(m3); - m2->decrRef(); - MEDCouplingUMesh *m4=build2DSourceMesh_1(); - MEDCouplingUMesh *m5=MEDCouplingUMesh::mergeUMeshes(m1,m3); - m1->decrRef(); - m3->decrRef(); - MEDCouplingUMesh *m6=MEDCouplingUMesh::mergeUMeshes(m5,m4); - m4->decrRef(); - m5->decrRef(); - // - CPPUNIT_ASSERT_EQUAL(10,m6->getNumberOfCells()); - CPPUNIT_ASSERT_EQUAL(22,m6->getNumberOfNodes()); - bool areNodesMerged; - int newNbOfNodes; - DataArrayInt *arr=m6->mergeNodes(1e-13,areNodesMerged,newNbOfNodes); - CPPUNIT_ASSERT_EQUAL(9,m6->getNumberOfNodes()); - arr->decrRef(); - MEDCouplingFieldDouble *f=m6->fillFromAnalytic(ON_CELLS,2,"x"); - MEDCouplingFieldDouble *f2=m6->fillFromAnalytic(ON_NODES,2,"x"); - CPPUNIT_ASSERT_EQUAL(10,f->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(2,f->getNumberOfComponents()); - const double expected1[20]={-0.05, -0.05, 0.3666666666666667, 0.3666666666666667, 0.53333333333333321, 0.53333333333333321, - -0.05, -0.05, 0.45, 0.45, 0.53333333333333321, 0.53333333333333321, -0.05, -0.05, 0.45, 0.45, - 0.36666666666666659, 0.36666666666666659, 0.033333333333333326, 0.033333333333333326}; - for(int i=0;i<20;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f->getIJ(0,i),1e-12); - f->getArray()->setInfoOnComponent(0,"titi"); - f->getArray()->setInfoOnComponent(1,"tutu"); - f->checkCoherency(); - CPPUNIT_ASSERT(f->zipConnectivity(0)); - const double expected2[14]={-0.05, -0.05, 0.3666666666666667, 0.3666666666666667, 0.53333333333333321, 0.53333333333333321, - -0.05, -0.05, 0.45, 0.45, 0.36666666666666659, 0.36666666666666659, 0.033333333333333326, 0.033333333333333326}; - CPPUNIT_ASSERT_EQUAL(7,f->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(2,f->getNumberOfComponents()); - for(int i=0;i<14;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],f->getIJ(0,i),1e-12); - CPPUNIT_ASSERT(std::string(f->getArray()->getInfoOnComponent(0))=="titi"); - CPPUNIT_ASSERT(std::string(f->getArray()->getInfoOnComponent(1))=="tutu"); - CPPUNIT_ASSERT(!f->zipConnectivity(0)); - f->decrRef(); - // - const double expected3[18]={-0.3, -0.3, 0.2, 0.2, 0.7, 0.7, -0.3, -0.3, 0.2, 0.2, 0.7, 0.7, - -0.3, -0.3, 0.2, 0.2, 0.7, 0.7}; - CPPUNIT_ASSERT_EQUAL(9,f2->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(2,f2->getNumberOfComponents()); - for(int i=0;i<18;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected3[i],f2->getIJ(0,i),1e-12); - CPPUNIT_ASSERT(f2->zipConnectivity(0)); - CPPUNIT_ASSERT_EQUAL(9,f2->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(2,f2->getNumberOfComponents()); - for(int i=0;i<18;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected3[i],f2->getIJ(0,i),1e-12); - f2->decrRef(); - // - m6->decrRef(); -} - -void MEDCouplingBasicsTest::testDaDoubleRenumber1() -{ - DataArrayDouble *a=DataArrayDouble::New(); - a->alloc(7,2); - a->setInfoOnComponent(0,"toto"); - a->setInfoOnComponent(1,"tata"); - const double arr1[14]={1.1,11.1,2.1,12.1,3.1,13.1,4.1,14.1,5.1,15.1,6.1,16.1,7.1,17.1}; - std::copy(arr1,arr1+14,a->getPointer()); - // - const int arr2[7]={3,1,0,6,5,4,2}; - DataArrayDouble *b=a->renumber(arr2); - CPPUNIT_ASSERT_EQUAL(7,b->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(2,b->getNumberOfComponents()); - CPPUNIT_ASSERT(std::string(b->getInfoOnComponent(0))=="toto"); - CPPUNIT_ASSERT(std::string(b->getInfoOnComponent(1))=="tata"); - const double expected1[14]={3.1, 13.1, 2.1, 12.1, 7.1, 17.1, 1.1, 11.1, 6.1, 16.1, 5.1, 15.1, 4.1, 14.1}; - for(int i=0;i<14;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],b->getIJ(0,i),1e-14); - b->decrRef(); - a->decrRef(); - // - DataArrayInt *c=DataArrayInt::New(); - c->alloc(7,2); - c->setInfoOnComponent(0,"toto"); - c->setInfoOnComponent(1,"tata"); - const int arr3[14]={1,11,2,12,3,13,4,14,5,15,6,16,7,17}; - std::copy(arr3,arr3+14,c->getPointer()); - DataArrayInt *d=c->renumber(arr2); - CPPUNIT_ASSERT_EQUAL(7,d->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(2,d->getNumberOfComponents()); - CPPUNIT_ASSERT(std::string(d->getInfoOnComponent(0))=="toto"); - CPPUNIT_ASSERT(std::string(d->getInfoOnComponent(1))=="tata"); - const int expected2[14]={3, 13, 2, 12, 7, 17, 1, 11, 6, 16, 5, 15, 4, 14}; - for(int i=0;i<14;i++) - CPPUNIT_ASSERT_EQUAL(expected2[i],d->getIJ(0,i)); - c->decrRef(); - d->decrRef(); -} - -void MEDCouplingBasicsTest::testDaDoubleRenumberAndReduce1() -{ - DataArrayDouble *a=DataArrayDouble::New(); - a->alloc(7,2); - a->setInfoOnComponent(0,"toto"); - a->setInfoOnComponent(1,"tata"); - const double arr1[14]={1.1,11.1,2.1,12.1,3.1,13.1,4.1,14.1,5.1,15.1,6.1,16.1,7.1,17.1}; - std::copy(arr1,arr1+14,a->getPointer()); - // - const int arr2[7]={2,-1,1,-1,0,4,3}; - DataArrayDouble *b=a->renumberAndReduce(arr2,5); - CPPUNIT_ASSERT_EQUAL(5,b->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(2,b->getNumberOfComponents()); - CPPUNIT_ASSERT(std::string(b->getInfoOnComponent(0))=="toto"); - CPPUNIT_ASSERT(std::string(b->getInfoOnComponent(1))=="tata"); - const double expected1[10]={5.1,15.1,3.1,13.1,1.1,11.1,7.1,17.1,6.1,16.1}; - for(int i=0;i<10;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],b->getIJ(0,i),1e-14); - b->decrRef(); - a->decrRef(); - // - DataArrayInt *c=DataArrayInt::New(); - c->alloc(7,2); - c->setInfoOnComponent(0,"toto"); - c->setInfoOnComponent(1,"tata"); - const int arr3[14]={1,11,2,12,3,13,4,14,5,15,6,16,7,17}; - std::copy(arr3,arr3+14,c->getPointer()); - DataArrayInt *d=c->renumberAndReduce(arr2,5); - CPPUNIT_ASSERT_EQUAL(5,d->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(2,d->getNumberOfComponents()); - CPPUNIT_ASSERT(std::string(d->getInfoOnComponent(0))=="toto"); - CPPUNIT_ASSERT(std::string(d->getInfoOnComponent(1))=="tata"); - const int expected2[10]={5,15,3,13,1,11,7,17,6,16}; - for(int i=0;i<10;i++) - CPPUNIT_ASSERT_EQUAL(expected2[i],d->getIJ(0,i)); - c->decrRef(); - d->decrRef(); -} - -void MEDCouplingBasicsTest::testDaDoubleRenumberInPlace1() -{ - DataArrayDouble *a=DataArrayDouble::New(); - a->alloc(7,2); - const double arr1[14]={1.1,11.1,2.1,12.1,3.1,13.1,4.1,14.1,5.1,15.1,6.1,16.1,7.1,17.1}; - std::copy(arr1,arr1+14,a->getPointer()); - // - const int arr2[7]={3,1,0,6,5,4,2}; - a->renumberInPlace(arr2); - CPPUNIT_ASSERT_EQUAL(7,a->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(2,a->getNumberOfComponents()); - const double expected1[14]={3.1, 13.1, 2.1, 12.1, 7.1, 17.1, 1.1, 11.1, 6.1, 16.1, 5.1, 15.1, 4.1, 14.1}; - for(int i=0;i<14;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],a->getIJ(0,i),1e-14); - a->decrRef(); - // - DataArrayInt *c=DataArrayInt::New(); - c->alloc(7,2); - const int arr3[14]={1,11,2,12,3,13,4,14,5,15,6,16,7,17}; - std::copy(arr3,arr3+14,c->getPointer()); - c->renumberInPlace(arr2); - CPPUNIT_ASSERT_EQUAL(7,c->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(2,c->getNumberOfComponents()); - const int expected2[14]={3, 13, 2, 12, 7, 17, 1, 11, 6, 16, 5, 15, 4, 14}; - for(int i=0;i<14;i++) - CPPUNIT_ASSERT_EQUAL(expected2[i],c->getIJ(0,i)); - c->decrRef(); -} - -void MEDCouplingBasicsTest::testDaDoubleRenumberR1() -{ - DataArrayDouble *a=DataArrayDouble::New(); - a->alloc(7,2); - a->setInfoOnComponent(0,"toto"); - a->setInfoOnComponent(1,"tata"); - const double arr1[14]={1.1,11.1,2.1,12.1,3.1,13.1,4.1,14.1,5.1,15.1,6.1,16.1,7.1,17.1}; - std::copy(arr1,arr1+14,a->getPointer()); - // - const int arr2[7]={3,1,0,6,5,4,2}; - DataArrayDouble *b=a->renumberR(arr2); - CPPUNIT_ASSERT_EQUAL(7,b->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(2,b->getNumberOfComponents()); - CPPUNIT_ASSERT(std::string(b->getInfoOnComponent(0))=="toto"); - CPPUNIT_ASSERT(std::string(b->getInfoOnComponent(1))=="tata"); - const double expected1[14]={4.1, 14.1, 2.1, 12.1, 1.1, 11.1, 7.1, 17.1, 6.1, 16.1, 5.1, 15.1, 3.1, 13.1}; - for(int i=0;i<14;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],b->getIJ(0,i),1e-14); - b->decrRef(); - a->decrRef(); - // - DataArrayInt *c=DataArrayInt::New(); - c->alloc(7,2); - c->setInfoOnComponent(0,"toto"); - c->setInfoOnComponent(1,"tata"); - const int arr3[14]={1,11,2,12,3,13,4,14,5,15,6,16,7,17}; - std::copy(arr3,arr3+14,c->getPointer()); - DataArrayInt *d=c->renumberR(arr2); - CPPUNIT_ASSERT_EQUAL(7,d->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(2,d->getNumberOfComponents()); - CPPUNIT_ASSERT(std::string(d->getInfoOnComponent(0))=="toto"); - CPPUNIT_ASSERT(std::string(d->getInfoOnComponent(1))=="tata"); - const int expected2[14]={4, 14, 2, 12, 1, 11, 7, 17, 6, 16, 5, 15, 3, 13}; - for(int i=0;i<14;i++) - CPPUNIT_ASSERT_EQUAL(expected2[i],d->getIJ(0,i)); - c->decrRef(); - d->decrRef(); -} - -void MEDCouplingBasicsTest::testDaDoubleRenumberInPlaceR1() -{ - DataArrayDouble *a=DataArrayDouble::New(); - a->alloc(7,2); - const double arr1[14]={1.1,11.1,2.1,12.1,3.1,13.1,4.1,14.1,5.1,15.1,6.1,16.1,7.1,17.1}; - std::copy(arr1,arr1+14,a->getPointer()); - // - const int arr2[7]={3,1,0,6,5,4,2}; - a->renumberInPlaceR(arr2); - CPPUNIT_ASSERT_EQUAL(7,a->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(2,a->getNumberOfComponents()); - const double expected1[14]={4.1, 14.1, 2.1, 12.1, 1.1, 11.1, 7.1, 17.1, 6.1, 16.1, 5.1, 15.1, 3.1, 13.1}; - for(int i=0;i<14;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],a->getIJ(0,i),1e-14); - a->decrRef(); - // - DataArrayInt *c=DataArrayInt::New(); - c->alloc(7,2); - const int arr3[14]={1,11,2,12,3,13,4,14,5,15,6,16,7,17}; - std::copy(arr3,arr3+14,c->getPointer()); - c->renumberInPlaceR(arr2); - CPPUNIT_ASSERT_EQUAL(7,c->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(2,c->getNumberOfComponents()); - const int expected2[14]={4, 14, 2, 12, 1, 11, 7, 17, 6, 16, 5, 15, 3, 13}; - for(int i=0;i<14;i++) - CPPUNIT_ASSERT_EQUAL(expected2[i],c->getIJ(0,i)); - c->decrRef(); -} - -void MEDCouplingBasicsTest::testDaDoubleSelectByTupleId1() -{ - DataArrayDouble *a=DataArrayDouble::New(); - a->alloc(7,2); - a->setInfoOnComponent(0,"toto"); - a->setInfoOnComponent(1,"tata"); - const double arr1[14]={1.1,11.1,2.1,12.1,3.1,13.1,4.1,14.1,5.1,15.1,6.1,16.1,7.1,17.1}; - std::copy(arr1,arr1+14,a->getPointer()); - // - const int arr2[7]={4,2,0,6,5}; - DataArrayDouble *b=a->selectByTupleId(arr2,arr2+5); - CPPUNIT_ASSERT_EQUAL(5,b->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(2,b->getNumberOfComponents()); - CPPUNIT_ASSERT(std::string(b->getInfoOnComponent(0))=="toto"); - CPPUNIT_ASSERT(std::string(b->getInfoOnComponent(1))=="tata"); - const double expected1[10]={5.1,15.1,3.1,13.1,1.1,11.1,7.1,17.1,6.1,16.1}; - for(int i=0;i<10;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],b->getIJ(0,i),1e-14); - b->decrRef(); - a->decrRef(); - // - DataArrayInt *c=DataArrayInt::New(); - c->alloc(7,2); - c->setInfoOnComponent(0,"toto"); - c->setInfoOnComponent(1,"tata"); - const int arr3[14]={1,11,2,12,3,13,4,14,5,15,6,16,7,17}; - std::copy(arr3,arr3+14,c->getPointer()); - DataArrayInt *d=c->selectByTupleId(arr2,arr2+5); - CPPUNIT_ASSERT_EQUAL(5,d->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(2,d->getNumberOfComponents()); - CPPUNIT_ASSERT(std::string(d->getInfoOnComponent(0))=="toto"); - CPPUNIT_ASSERT(std::string(d->getInfoOnComponent(1))=="tata"); - const int expected2[10]={5,15,3,13,1,11,7,17,6,16}; - for(int i=0;i<10;i++) - CPPUNIT_ASSERT_EQUAL(expected2[i],d->getIJ(0,i)); - c->decrRef(); - d->decrRef(); -} - -void MEDCouplingBasicsTest::testDaDoubleGetMinMaxValues1() -{ - DataArrayDouble *a=DataArrayDouble::New(); - a->alloc(9,1); - const double arr1[9]={2.34,4.56,-6.77,4.55,4.56,2.24,2.34,1.02,4.56}; - std::copy(arr1,arr1+9,a->getPointer()); - int where; - double m=a->getMaxValue(where); - CPPUNIT_ASSERT_EQUAL(1,where); - CPPUNIT_ASSERT_DOUBLES_EQUAL(4.56,m,1e-12); - DataArrayInt *ws; - m=a->getMaxValue2(ws); - CPPUNIT_ASSERT_DOUBLES_EQUAL(4.56,m,1e-12); - CPPUNIT_ASSERT_EQUAL(3,ws->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,ws->getNumberOfComponents()); - const int expected1[3]={1,4,8}; - for(int i=0;i<3;i++) - CPPUNIT_ASSERT_EQUAL(expected1[i],ws->getIJ(i,0)); - ws->decrRef(); - a->decrRef(); - a=DataArrayDouble::New(); - const double arr2[9]={-2.34,-4.56,6.77,-4.55,-4.56,-2.24,-2.34,-1.02,-4.56}; - a->alloc(9,1); - std::copy(arr2,arr2+9,a->getPointer()); - where=-2; - m=a->getMinValue(where); - CPPUNIT_ASSERT_EQUAL(1,where); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-4.56,m,1e-12); - m=a->getMinValue2(ws); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-4.56,m,1e-12); - CPPUNIT_ASSERT_EQUAL(3,ws->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,ws->getNumberOfComponents()); - for(int i=0;i<3;i++) - CPPUNIT_ASSERT_EQUAL(expected1[i],ws->getIJ(i,0)); - ws->decrRef(); - a->decrRef(); -} - -void MEDCouplingBasicsTest::testFieldDoubleGetMinMaxValues2() -{ - MEDCouplingUMesh *m1=0; - MEDCouplingUMesh *m2=build3DExtrudedUMesh_1(m1); - m1->decrRef(); - CPPUNIT_ASSERT_EQUAL(18,m2->getNumberOfCells()); - const double arr1[18]={8.71,4.53,-12.41,8.71,-8.71,8.7099,4.55,8.71,5.55,6.77,-1e-200,4.55,8.7099,0.,1.23,0.,2.22,8.71}; - MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME); - DataArrayDouble *a=DataArrayDouble::New(); - a->alloc(18,1); - std::copy(arr1,arr1+18,a->getPointer()); - f->setArray(a); - a->decrRef(); - f->setMesh(m2); - // - f->checkCoherency(); - double m=f->getMaxValue(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(8.71,m,1e-12); - DataArrayInt *ws; - m=f->getMaxValue2(ws); - CPPUNIT_ASSERT_DOUBLES_EQUAL(8.71,m,1e-12); - CPPUNIT_ASSERT_EQUAL(4,ws->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,ws->getNumberOfComponents()); - const int expected1[4]={0,3,7,17}; - for(int i=0;i<4;i++) - CPPUNIT_ASSERT_EQUAL(expected1[i],ws->getIJ(i,0)); - ws->decrRef(); - // - const double arr2[18]={-8.71,-4.53,12.41,-8.71,8.71,-8.7099,-4.55,-8.71,-5.55,-6.77,1e-200,-4.55,-8.7099,0.,-1.23,0.,-2.22,-8.71}; - std::copy(arr2,arr2+18,a->getPointer()); - f->checkCoherency(); - m=f->getMinValue(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-8.71,m,1e-12); - m=f->getMinValue2(ws); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-8.71,m,1e-12); - CPPUNIT_ASSERT_EQUAL(4,ws->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,ws->getNumberOfComponents()); - for(int i=0;i<4;i++) - CPPUNIT_ASSERT_EQUAL(expected1[i],ws->getIJ(i,0)); - ws->decrRef(); - // - f->decrRef(); - m2->decrRef(); -} - -void MEDCouplingBasicsTest::testBuildUnstructuredCMesh1() -{ - MEDCouplingCMesh *m=MEDCouplingCMesh::New(); - DataArrayDouble *da=DataArrayDouble::New(); - const double discX[4]={2.3,3.4,5.8,10.2}; - const double discY[3]={12.3,23.4,45.8}; - const double discZ[5]={-0.7,1.2,1.25,2.13,2.67}; - da->alloc(4,1); - std::copy(discX,discX+4,da->getPointer()); - m->setCoordsAt(0,da); - da->decrRef(); - m->checkCoherency(); - double pos=2.4; - CPPUNIT_ASSERT_EQUAL(0,m->getCellContainingPoint(&pos,1e-12)); - pos=3.7; - CPPUNIT_ASSERT_EQUAL(1,m->getCellContainingPoint(&pos,1e-12)); - pos=5.9; - CPPUNIT_ASSERT_EQUAL(2,m->getCellContainingPoint(&pos,1e-12)); - pos=10.3; - CPPUNIT_ASSERT_EQUAL(-1,m->getCellContainingPoint(&pos,1e-12)); - pos=1.3; - CPPUNIT_ASSERT_EQUAL(-1,m->getCellContainingPoint(&pos,1e-12)); - // - MEDCouplingUMesh *m2=m->buildUnstructured(); - m2->checkCoherency(); - MEDCouplingFieldDouble *f1=m->getMeasureField(false); - MEDCouplingFieldDouble *f2=m2->getMeasureField(false); - CPPUNIT_ASSERT_EQUAL(f1->getNumberOfTuples(),3); - CPPUNIT_ASSERT_EQUAL(f2->getNumberOfTuples(),3); - CPPUNIT_ASSERT_EQUAL(1,m2->getMeshDimension()); - CPPUNIT_ASSERT_EQUAL(1,m2->getSpaceDimension()); - for(int i=0;i<3;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(f1->getIJ(i,0),f2->getIJ(i,0),1e-10); - da=DataArrayDouble::New(); - da->alloc(3,1); - std::copy(discY,discY+3,da->getPointer()); - m->setCoordsAt(1,da); - da->decrRef(); - m2->decrRef(); - f1->decrRef(); - f2->decrRef(); - // - m2=m->buildUnstructured(); - m2->checkCoherency(); - f1=m->getMeasureField(false); - f2=m2->getMeasureField(false); - CPPUNIT_ASSERT_EQUAL(f1->getNumberOfTuples(),6); - CPPUNIT_ASSERT_EQUAL(f2->getNumberOfTuples(),6); - CPPUNIT_ASSERT_EQUAL(2,m2->getMeshDimension()); - CPPUNIT_ASSERT_EQUAL(2,m2->getSpaceDimension()); - for(int i=0;i<6;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(f1->getIJ(i,0),f2->getIJ(i,0),1e-10); - f1->decrRef(); - f2->decrRef(); - m2->decrRef(); - // - da=DataArrayDouble::New(); - da->alloc(5,1); - std::copy(discZ,discZ+5,da->getPointer()); - m->setCoordsAt(2,da); - da->decrRef(); - m2=m->buildUnstructured(); - m2->checkCoherency(); - f1=m->getMeasureField(false); - f2=m2->getMeasureField(false); - CPPUNIT_ASSERT_EQUAL(f1->getNumberOfTuples(),24); - CPPUNIT_ASSERT_EQUAL(f2->getNumberOfTuples(),24); - CPPUNIT_ASSERT_EQUAL(3,m2->getMeshDimension()); - CPPUNIT_ASSERT_EQUAL(3,m2->getSpaceDimension()); - for(int i=0;i<24;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(f1->getIJ(i,0),f2->getIJ(i,0),1e-10); - f1->decrRef(); - f2->decrRef(); - // - double pos1[3]={5.,30.,2.}; - CPPUNIT_ASSERT_EQUAL(16,m->getCellContainingPoint(pos1,1e-12)); - // - const double pt[3]={2.4,12.7,-3.4}; - m->scale(pt,3.7); - MEDCouplingUMesh *m3=m->buildUnstructured(); - m2->scale(pt,3.7); - CPPUNIT_ASSERT(m3->isEqual(m2,1e-12)); - m2->decrRef(); - m3->decrRef(); - // - m->decrRef(); -} - -void MEDCouplingBasicsTest::testDataArrayIntInvertO2NNO21() -{ - const int arr1[6]={2,0,4,1,5,3}; - DataArrayInt *da=DataArrayInt::New(); - da->alloc(6,1); - std::copy(arr1,arr1+6,da->getPointer()); - DataArrayInt *da2=da->invertArrayO2N2N2O(6); - CPPUNIT_ASSERT_EQUAL(6,da2->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,da2->getNumberOfComponents()); - const int expected1[6]={1,3,0,5,2,4}; - for(int i=0;i<6;i++) - CPPUNIT_ASSERT_EQUAL(expected1[i],da2->getIJ(i,0)); - DataArrayInt *da3=da2->invertArrayN2O2O2N(6); - for(int i=0;i<6;i++) - CPPUNIT_ASSERT_EQUAL(arr1[i],da3->getIJ(i,0)); - da3->decrRef(); - da2->decrRef(); - da->decrRef(); - // - const int arr2[10]={3,-1,5,4,-1,0,-1,1,2,-1}; - da=DataArrayInt::New(); - da->alloc(10,1); - std::copy(arr2,arr2+10,da->getPointer()); - da2=da->invertArrayO2N2N2O(6); - CPPUNIT_ASSERT_EQUAL(6,da2->getNumberOfTuples()); - CPPUNIT_ASSERT_EQUAL(1,da2->getNumberOfComponents()); - const int expected2[10]={5,7,8,0,3,2}; - for(int i=0;i<6;i++) - CPPUNIT_ASSERT_EQUAL(expected2[i],da2->getIJ(i,0)); - da3=da2->invertArrayN2O2O2N(10); - for(int i=0;i<10;i++) - CPPUNIT_ASSERT_EQUAL(arr2[i],da3->getIJ(i,0)); - da3->decrRef(); - da2->decrRef(); - da->decrRef(); -} - -void MEDCouplingBasicsTest::testKeepSetSelectedComponent1() -{ - const double arr1[20]={1.,2.,3.,4., 11.,12.,13.,14., 21.,22.,23.,24., 31.,32.,33.,34., 41.,42.,43.,44.}; - DataArrayDouble *a1=DataArrayDouble::New(); - a1->alloc(5,4); - std::copy(arr1,arr1+20,a1->getPointer()); - a1->setInfoOnComponent(0,"aaaa"); - a1->setInfoOnComponent(1,"bbbb"); - a1->setInfoOnComponent(2,"cccc"); - a1->setInfoOnComponent(3,"dddd"); - const int arr2[6]={1,2,1,2,0,0}; - std::vector arr2V(arr2,arr2+6); - DataArrayDouble *a2=a1->keepSelectedComponents(arr2V); - CPPUNIT_ASSERT_EQUAL(6,a2->getNumberOfComponents()); - CPPUNIT_ASSERT_EQUAL(5,a2->getNumberOfTuples()); - CPPUNIT_ASSERT(std::string(a2->getInfoOnComponent(0))=="bbbb"); - CPPUNIT_ASSERT(std::string(a2->getInfoOnComponent(1))=="cccc"); - CPPUNIT_ASSERT(std::string(a2->getInfoOnComponent(2))=="bbbb"); - CPPUNIT_ASSERT(std::string(a2->getInfoOnComponent(3))=="cccc"); - CPPUNIT_ASSERT(std::string(a2->getInfoOnComponent(4))=="aaaa"); - CPPUNIT_ASSERT(std::string(a2->getInfoOnComponent(5))=="aaaa"); - const double expected1[30]={2.,3.,2.,3.,1.,1., 12.,13.,12.,13.,11.,11., 22.,23.,22.,23.,21.,21., 32.,33.,32.,33.,31.,31., 42.,43.,42.,43.,41.,41.}; - for(int i=0;i<30;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],a2->getIJ(0,i),1e-14); - DataArrayInt *a3=a1->convertToIntArr(); - DataArrayInt *a4=a3->keepSelectedComponents(arr2V); - CPPUNIT_ASSERT_EQUAL(6,a4->getNumberOfComponents()); - CPPUNIT_ASSERT_EQUAL(5,a4->getNumberOfTuples()); - CPPUNIT_ASSERT(std::string(a4->getInfoOnComponent(0))=="bbbb"); - CPPUNIT_ASSERT(std::string(a4->getInfoOnComponent(1))=="cccc"); - CPPUNIT_ASSERT(std::string(a4->getInfoOnComponent(2))=="bbbb"); - CPPUNIT_ASSERT(std::string(a4->getInfoOnComponent(3))=="cccc"); - CPPUNIT_ASSERT(std::string(a4->getInfoOnComponent(4))=="aaaa"); - CPPUNIT_ASSERT(std::string(a4->getInfoOnComponent(5))=="aaaa"); - for(int i=0;i<30;i++) - CPPUNIT_ASSERT_EQUAL(int(expected1[i]),a4->getIJ(0,i)); - // setSelectedComponents - const int arr3[2]={3,2}; - std::vector arr3V(arr3,arr3+2); - DataArrayDouble *a5=a1->keepSelectedComponents(arr3V); - a5->setInfoOnComponent(0,"eeee"); - a5->setInfoOnComponent(1,"ffff"); - const int arr4[2]={1,2}; - std::vector arr4V(arr4,arr4+2); - a2->setSelectedComponents(a5,arr4V); - CPPUNIT_ASSERT_EQUAL(6,a2->getNumberOfComponents()); - CPPUNIT_ASSERT_EQUAL(5,a2->getNumberOfTuples()); - CPPUNIT_ASSERT(std::string(a2->getInfoOnComponent(0))=="bbbb"); - CPPUNIT_ASSERT(std::string(a2->getInfoOnComponent(1))=="eeee"); - CPPUNIT_ASSERT(std::string(a2->getInfoOnComponent(2))=="ffff"); - CPPUNIT_ASSERT(std::string(a2->getInfoOnComponent(3))=="cccc"); - CPPUNIT_ASSERT(std::string(a2->getInfoOnComponent(4))=="aaaa"); - CPPUNIT_ASSERT(std::string(a2->getInfoOnComponent(5))=="aaaa"); - const double expected2[30]={2.,4.,3.,3.,1.,1., 12.,14.,13.,13.,11.,11., 22.,24.,23.,23.,21.,21., 32.,34.,33.,33.,31.,31., 42.,44.,43.,43.,41.,41.}; - for(int i=0;i<30;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],a2->getIJ(0,i),1e-14); - DataArrayInt *a6=a5->convertToIntArr(); - a6->setInfoOnComponent(0,"eeee"); - a6->setInfoOnComponent(1,"ffff"); - a4->setSelectedComponents(a6,arr4V); - CPPUNIT_ASSERT_EQUAL(6,a4->getNumberOfComponents()); - CPPUNIT_ASSERT_EQUAL(5,a4->getNumberOfTuples()); - CPPUNIT_ASSERT(std::string(a4->getInfoOnComponent(0))=="bbbb"); - CPPUNIT_ASSERT(std::string(a4->getInfoOnComponent(1))=="eeee"); - CPPUNIT_ASSERT(std::string(a4->getInfoOnComponent(2))=="ffff"); - CPPUNIT_ASSERT(std::string(a4->getInfoOnComponent(3))=="cccc"); - CPPUNIT_ASSERT(std::string(a4->getInfoOnComponent(4))=="aaaa"); - CPPUNIT_ASSERT(std::string(a4->getInfoOnComponent(5))=="aaaa"); - for(int i=0;i<30;i++) - CPPUNIT_ASSERT_EQUAL(int(expected2[i]),a4->getIJ(0,i)); - // test of throw - const int arr5[3]={2,3,6}; - const int arr6[3]={2,7,5}; - const int arr7[4]={2,1,4,6}; - std::vector arr5V(arr5,arr5+3); - std::vector 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); - CPPUNIT_ASSERT_THROW(a2->setSelectedComponents(a1,arr7V),INTERP_KERNEL::Exception); - arr7V.resize(3); - CPPUNIT_ASSERT_THROW(a2->setSelectedComponents(a1,arr7V),INTERP_KERNEL::Exception); - // - a6->decrRef(); - a5->decrRef(); - a4->decrRef(); - a3->decrRef(); - a2->decrRef(); - a1->decrRef(); -} - -void MEDCouplingBasicsTest::testKeepSetSelectedComponent2() -{ - MEDCouplingUMesh *m1=build2DTargetMesh_1(); - const double arr1[20]={1.,2.,3.,4., 11.,12.,13.,14., 21.,22.,23.,24., 31.,32.,33.,34., 41.,42.,43.,44.}; - DataArrayDouble *a1=DataArrayDouble::New(); - a1->alloc(5,4); - std::copy(arr1,arr1+20,a1->getPointer()); - a1->setInfoOnComponent(0,"aaaa"); - a1->setInfoOnComponent(1,"bbbb"); - a1->setInfoOnComponent(2,"cccc"); - a1->setInfoOnComponent(3,"dddd"); - MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME); - f1->setTime(2.3,4,5); - f1->setMesh(m1); - f1->setName("f1"); - f1->setArray(a1); - f1->checkCoherency(); - // - const int arr2[6]={1,2,1,2,0,0}; - std::vector arr2V(arr2,arr2+6); - MEDCouplingFieldDouble *f2=f1->keepSelectedComponents(arr2V); - CPPUNIT_ASSERT(f2->getMesh()==f1->getMesh()); - CPPUNIT_ASSERT(f2->getTimeDiscretization()==ONE_TIME); - int dt,it; - CPPUNIT_ASSERT_DOUBLES_EQUAL(2.3,f2->getTime(dt,it),1e-13); - CPPUNIT_ASSERT_EQUAL(4,dt); - CPPUNIT_ASSERT_EQUAL(5,it); - f2->checkCoherency(); - CPPUNIT_ASSERT_EQUAL(6,f2->getNumberOfComponents()); - CPPUNIT_ASSERT_EQUAL(5,f2->getNumberOfTuples()); - CPPUNIT_ASSERT(std::string(f2->getArray()->getInfoOnComponent(0))=="bbbb"); - CPPUNIT_ASSERT(std::string(f2->getArray()->getInfoOnComponent(1))=="cccc"); - CPPUNIT_ASSERT(std::string(f2->getArray()->getInfoOnComponent(2))=="bbbb"); - CPPUNIT_ASSERT(std::string(f2->getArray()->getInfoOnComponent(3))=="cccc"); - CPPUNIT_ASSERT(std::string(f2->getArray()->getInfoOnComponent(4))=="aaaa"); - CPPUNIT_ASSERT(std::string(f2->getArray()->getInfoOnComponent(5))=="aaaa"); - const double expected1[30]={2.,3.,2.,3.,1.,1., 12.,13.,12.,13.,11.,11., 22.,23.,22.,23.,21.,21., 32.,33.,32.,33.,31.,31., 42.,43.,42.,43.,41.,41.}; - for(int i=0;i<30;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f2->getIJ(0,i),1e-14); - //setSelectedComponents - const int arr3[2]={3,2}; - std::vector 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->checkCoherency(); - const int arr4[2]={1,2}; - std::vector arr4V(arr4,arr4+2); - f2->setSelectedComponents(f5,arr4V); - CPPUNIT_ASSERT_EQUAL(6,f2->getNumberOfComponents()); - CPPUNIT_ASSERT_EQUAL(5,f2->getNumberOfTuples()); - f2->checkCoherency(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(2.3,f2->getTime(dt,it),1e-13); - CPPUNIT_ASSERT_EQUAL(4,dt); - CPPUNIT_ASSERT_EQUAL(5,it); - CPPUNIT_ASSERT(std::string(f2->getArray()->getInfoOnComponent(0))=="bbbb"); - CPPUNIT_ASSERT(std::string(f2->getArray()->getInfoOnComponent(1))=="eeee"); - CPPUNIT_ASSERT(std::string(f2->getArray()->getInfoOnComponent(2))=="ffff"); - CPPUNIT_ASSERT(std::string(f2->getArray()->getInfoOnComponent(3))=="cccc"); - CPPUNIT_ASSERT(std::string(f2->getArray()->getInfoOnComponent(4))=="aaaa"); - CPPUNIT_ASSERT(std::string(f2->getArray()->getInfoOnComponent(5))=="aaaa"); - const double expected2[30]={2.,4.,3.,3.,1.,1., 12.,14.,13.,13.,11.,11., 22.,24.,23.,23.,21.,21., 32.,34.,33.,33.,31.,31., 42.,44.,43.,43.,41.,41.}; - for(int i=0;i<30;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],f2->getIJ(0,i),1e-14); - f5->decrRef(); - f1->decrRef(); - f2->decrRef(); - a1->decrRef(); - m1->decrRef(); -} diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest3.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest3.cxx new file mode 100644 index 000000000..589ce1895 --- /dev/null +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest3.cxx @@ -0,0 +1,2253 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "MEDCouplingBasicsTest.hxx" +#include "MEDCouplingUMesh.hxx" +#include "MEDCouplingCMesh.hxx" +#include "MEDCouplingExtrudedMesh.hxx" +#include "MEDCouplingFieldDouble.hxx" +#include "MEDCouplingMemArray.hxx" +#include "MEDCouplingGaussLocalization.hxx" + +#include +#include +#include + +using namespace ParaMEDMEM; + +void MEDCouplingBasicsTest::testGetMeasureFieldCMesh1() +{ + MEDCouplingCMesh *m=MEDCouplingCMesh::New(); + DataArrayDouble *da=DataArrayDouble::New(); + const double discX[4]={2.3,3.4,5.8,10.2}; + const double discY[3]={12.3,23.4,45.8}; + const double discZ[5]={-0.7,1.2,1.25,2.13,2.67}; + da->alloc(4,1); + std::copy(discX,discX+4,da->getPointer()); + m->setCoordsAt(0,da); + da->decrRef(); + m->checkCoherency(); + CPPUNIT_ASSERT_EQUAL(4,m->getNumberOfNodes()); + CPPUNIT_ASSERT_EQUAL(3,m->getNumberOfCells()); + CPPUNIT_ASSERT_EQUAL(1,m->getSpaceDimension()); + MEDCouplingFieldDouble *f=m->getMeasureField(true); + CPPUNIT_ASSERT_EQUAL(3,f->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,f->getNumberOfComponents()); + const double expected1[3]={1.1,2.4,4.4}; + for(int i=0;i<3;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f->getIJ(i,0),1e-12); + f->decrRef(); + DataArrayDouble *coords=m->getCoordinatesAndOwner(); + CPPUNIT_ASSERT_EQUAL(4,coords->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,coords->getNumberOfComponents()); + for(int i=0;i<4;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(discX[i],coords->getIJ(i,0),1e-12); + coords->decrRef(); + coords=m->getBarycenterAndOwner(); + CPPUNIT_ASSERT_EQUAL(3,coords->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,coords->getNumberOfComponents()); + const double expected1_3[3]={2.85,4.6,8.}; + for(int i=0;i<3;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1_3[i],coords->getIJ(i,0),1e-12); + coords->decrRef(); + // + da=DataArrayDouble::New(); + da->alloc(3,1); + std::copy(discY,discY+3,da->getPointer()); + m->setCoordsAt(1,da); + da->decrRef(); + m->checkCoherency(); + CPPUNIT_ASSERT_EQUAL(12,m->getNumberOfNodes()); + CPPUNIT_ASSERT_EQUAL(6,m->getNumberOfCells()); + CPPUNIT_ASSERT_EQUAL(2,m->getSpaceDimension()); + f=m->getMeasureField(true); + CPPUNIT_ASSERT_EQUAL(6,f->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,f->getNumberOfComponents()); + const double expected2[6]={12.21,26.64,48.84,24.64,53.76,98.56}; + for(int i=0;i<6;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],f->getIJ(i,0),1e-12); + f->decrRef(); + coords=m->getCoordinatesAndOwner(); + CPPUNIT_ASSERT_EQUAL(12,coords->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(2,coords->getNumberOfComponents()); + const double expected2_2[24]={2.3,12.3,3.4,12.3,5.8,12.3,10.2,12.3, 2.3,23.4,3.4,23.4,5.8,23.4,10.2,23.4, 2.3,45.8,3.4,45.8,5.8,45.8,10.2,45.8}; + for(int i=0;i<24;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2_2[i],coords->getIJ(0,i),1e-12); + coords->decrRef(); + coords=m->getBarycenterAndOwner(); + CPPUNIT_ASSERT_EQUAL(6,coords->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(2,coords->getNumberOfComponents()); + const double expected2_3[12]={2.85,17.85,4.6,17.85,8.,17.85, 2.85,34.6,4.6,34.6,8.,34.6}; + for(int i=0;i<12;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2_3[i],coords->getIJ(0,i),1e-12); + coords->decrRef(); + // + da=DataArrayDouble::New(); + da->alloc(5,1); + std::copy(discZ,discZ+5,da->getPointer()); + m->setCoordsAt(2,da); + da->decrRef(); + m->checkCoherency(); + CPPUNIT_ASSERT_EQUAL(60,m->getNumberOfNodes()); + CPPUNIT_ASSERT_EQUAL(24,m->getNumberOfCells()); + CPPUNIT_ASSERT_EQUAL(3,m->getSpaceDimension()); + f=m->getMeasureField(true); + CPPUNIT_ASSERT_EQUAL(24,f->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,f->getNumberOfComponents()); + const double expected3[24]={23.199, 50.616, 92.796, 46.816, 102.144, 187.264, 0.6105, 1.332, 2.442, 1.232, 2.688, 4.928, 10.7448, 23.4432, 42.9792, 21.6832, 47.3088, 86.7328, 6.5934, 14.3856, 26.3736, 13.3056, 29.0304, 53.2224}; + for(int i=0;i<24;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected3[i],f->getIJ(i,0),1e-12); + f->decrRef(); + coords=m->getCoordinatesAndOwner(); + CPPUNIT_ASSERT_EQUAL(60,coords->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(3,coords->getNumberOfComponents()); + const double expected3_2[180]={ + 2.3,12.3,-0.7, 3.4,12.3,-0.7, 5.8,12.3,-0.7, 10.2,12.3,-0.7, 2.3,23.4,-0.7, 3.4,23.4,-0.7, 5.8,23.4,-0.7, 10.2,23.4,-0.7, 2.3,45.8,-0.7, 3.4,45.8,-0.7, 5.8,45.8,-0.7, 10.2,45.8,-0.7, + 2.3,12.3,1.2, 3.4,12.3,1.2, 5.8,12.3,1.2, 10.2,12.3,1.2, 2.3,23.4,1.2, 3.4,23.4,1.2, 5.8,23.4,1.2, 10.2,23.4,1.2, 2.3,45.8,1.2, 3.4,45.8,1.2, 5.8,45.8,1.2, 10.2,45.8,1.2, + 2.3,12.3,1.25, 3.4,12.3,1.25, 5.8,12.3,1.25, 10.2,12.3,1.25, 2.3,23.4,1.25, 3.4,23.4,1.25, 5.8,23.4,1.25, 10.2,23.4,1.25, 2.3,45.8,1.25, 3.4,45.8,1.25, 5.8,45.8,1.25, 10.2,45.8,1.25, + 2.3,12.3,2.13, 3.4,12.3,2.13, 5.8,12.3,2.13, 10.2,12.3,2.13, 2.3,23.4,2.13, 3.4,23.4,2.13, 5.8,23.4,2.13, 10.2,23.4,2.13, 2.3,45.8,2.13, 3.4,45.8,2.13, 5.8,45.8,2.13, 10.2,45.8,2.13, + 2.3,12.3,2.67, 3.4,12.3,2.67, 5.8,12.3,2.67, 10.2,12.3,2.67, 2.3,23.4,2.67, 3.4,23.4,2.67, 5.8,23.4,2.67, 10.2,23.4,2.67, 2.3,45.8,2.67, 3.4,45.8,2.67, 5.8,45.8,2.67, 10.2,45.8,2.67 + }; + for(int i=0;i<180;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected3_2[i],coords->getIJ(0,i),1e-12); + coords->decrRef(); + coords=m->getBarycenterAndOwner(); + CPPUNIT_ASSERT_EQUAL(24,coords->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(3,coords->getNumberOfComponents()); + const double expected3_3[72]={ + 2.85,17.85,0.25,4.6,17.85,0.25,8.,17.85,0.25, 2.85,34.6,0.25,4.6,34.6,0.25,8.,34.6,0.25, + 2.85,17.85,1.225,4.6,17.85,1.225,8.,17.85,1.225, 2.85,34.6,1.225,4.6,34.6,1.225,8.,34.6,1.225, + 2.85,17.85,1.69,4.6,17.85,1.69,8.,17.85,1.69, 2.85,34.6,1.69,4.6,34.6,1.69,8.,34.6,1.69, + 2.85,17.85,2.4,4.6,17.85,2.4,8.,17.85,2.4, 2.85,34.6,2.4,4.6,34.6,2.4,8.,34.6,2.4 + }; + for(int i=0;i<72;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected3_3[i],coords->getIJ(0,i),1e-12); + coords->decrRef(); + // + m->decrRef(); +} + +void MEDCouplingBasicsTest::testFieldDoubleZipCoords1() +{ + MEDCouplingUMesh *m=build2DTargetMeshMergeNode_1(); + MEDCouplingFieldDouble *f=m->fillFromAnalytic(ON_NODES,2,"x*2."); + f->getArray()->setInfoOnComponent(0,"titi"); + f->getArray()->setInfoOnComponent(1,"tutu"); + f->checkCoherency(); + CPPUNIT_ASSERT_EQUAL(18,f->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(2,f->getNumberOfComponents()); + const double expected1[36]={-0.6, -0.6, 0.4, 0.4, 1.4, 1.4, -0.6, -0.6, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 1.4, 1.4, -0.6, -0.6, 0.4, 0.4, 1.4, 1.4, -0.6, -0.6, 1.4, 1.4, -0.6, -0.6, 0.4, 0.4, 1.4, 1.4, 0.4, 0.4}; + for(int i=0;i<36;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f->getIJ(0,i),1e-12); + CPPUNIT_ASSERT(f->zipCoords()); + f->checkCoherency(); + const double expected2[30]={-0.6, -0.6, 1.4, 1.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 1.4, 1.4, -0.6, -0.6, 0.4, 0.4, 1.4, 1.4, 1.4, 1.4, -0.6, -0.6, 0.4, 0.4, 1.4, 1.4, 0.4, 0.4}; + for(int i=0;i<30;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],f->getIJ(0,i),1e-12); + CPPUNIT_ASSERT(!f->zipCoords()); + f->checkCoherency(); + for(int i=0;i<30;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],f->getIJ(0,i),1e-12); + CPPUNIT_ASSERT(std::string(f->getArray()->getInfoOnComponent(0))=="titi"); + CPPUNIT_ASSERT(std::string(f->getArray()->getInfoOnComponent(1))=="tutu"); + f->decrRef(); + m->decrRef(); +} + +void MEDCouplingBasicsTest::testFieldDoubleZipConnectivity1() +{ + MEDCouplingUMesh *m1=build2DTargetMesh_1(); + MEDCouplingUMesh *m2=build2DTargetMesh_1(); + const int cells1[3]={2,3,4}; + MEDCouplingPointSet *m3_1=m2->buildPartOfMySelf(cells1,cells1+3,true); + MEDCouplingUMesh *m3=dynamic_cast(m3_1); + CPPUNIT_ASSERT(m3); + m2->decrRef(); + MEDCouplingUMesh *m4=build2DSourceMesh_1(); + MEDCouplingUMesh *m5=MEDCouplingUMesh::MergeUMeshes(m1,m3); + m1->decrRef(); + m3->decrRef(); + MEDCouplingUMesh *m6=MEDCouplingUMesh::MergeUMeshes(m5,m4); + m4->decrRef(); + m5->decrRef(); + // + CPPUNIT_ASSERT_EQUAL(10,m6->getNumberOfCells()); + CPPUNIT_ASSERT_EQUAL(22,m6->getNumberOfNodes()); + bool areNodesMerged; + int newNbOfNodes; + DataArrayInt *arr=m6->mergeNodes(1e-13,areNodesMerged,newNbOfNodes); + CPPUNIT_ASSERT_EQUAL(9,m6->getNumberOfNodes()); + arr->decrRef(); + MEDCouplingFieldDouble *f=m6->fillFromAnalytic(ON_CELLS,2,"x"); + MEDCouplingFieldDouble *f2=m6->fillFromAnalytic(ON_NODES,2,"x"); + CPPUNIT_ASSERT_EQUAL(10,f->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(2,f->getNumberOfComponents()); + const double expected1[20]={-0.05, -0.05, 0.3666666666666667, 0.3666666666666667, 0.53333333333333321, 0.53333333333333321, + -0.05, -0.05, 0.45, 0.45, 0.53333333333333321, 0.53333333333333321, -0.05, -0.05, 0.45, 0.45, + 0.36666666666666659, 0.36666666666666659, 0.033333333333333326, 0.033333333333333326}; + for(int i=0;i<20;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f->getIJ(0,i),1e-12); + f->getArray()->setInfoOnComponent(0,"titi"); + f->getArray()->setInfoOnComponent(1,"tutu"); + f->checkCoherency(); + CPPUNIT_ASSERT(f->zipConnectivity(0)); + const double expected2[14]={-0.05, -0.05, 0.3666666666666667, 0.3666666666666667, 0.53333333333333321, 0.53333333333333321, + -0.05, -0.05, 0.45, 0.45, 0.36666666666666659, 0.36666666666666659, 0.033333333333333326, 0.033333333333333326}; + CPPUNIT_ASSERT_EQUAL(7,f->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(2,f->getNumberOfComponents()); + for(int i=0;i<14;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],f->getIJ(0,i),1e-12); + CPPUNIT_ASSERT(std::string(f->getArray()->getInfoOnComponent(0))=="titi"); + CPPUNIT_ASSERT(std::string(f->getArray()->getInfoOnComponent(1))=="tutu"); + CPPUNIT_ASSERT(!f->zipConnectivity(0)); + f->decrRef(); + // + const double expected3[18]={-0.3, -0.3, 0.2, 0.2, 0.7, 0.7, -0.3, -0.3, 0.2, 0.2, 0.7, 0.7, + -0.3, -0.3, 0.2, 0.2, 0.7, 0.7}; + CPPUNIT_ASSERT_EQUAL(9,f2->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(2,f2->getNumberOfComponents()); + for(int i=0;i<18;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected3[i],f2->getIJ(0,i),1e-12); + CPPUNIT_ASSERT(f2->zipConnectivity(0)); + CPPUNIT_ASSERT_EQUAL(9,f2->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(2,f2->getNumberOfComponents()); + for(int i=0;i<18;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected3[i],f2->getIJ(0,i),1e-12); + f2->decrRef(); + // + m6->decrRef(); +} + +void MEDCouplingBasicsTest::testDaDoubleRenumber1() +{ + DataArrayDouble *a=DataArrayDouble::New(); + a->alloc(7,2); + a->setInfoOnComponent(0,"toto"); + a->setInfoOnComponent(1,"tata"); + const double arr1[14]={1.1,11.1,2.1,12.1,3.1,13.1,4.1,14.1,5.1,15.1,6.1,16.1,7.1,17.1}; + std::copy(arr1,arr1+14,a->getPointer()); + // + const int arr2[7]={3,1,0,6,5,4,2}; + DataArrayDouble *b=a->renumber(arr2); + CPPUNIT_ASSERT_EQUAL(7,b->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(2,b->getNumberOfComponents()); + CPPUNIT_ASSERT(std::string(b->getInfoOnComponent(0))=="toto"); + CPPUNIT_ASSERT(std::string(b->getInfoOnComponent(1))=="tata"); + const double expected1[14]={3.1, 13.1, 2.1, 12.1, 7.1, 17.1, 1.1, 11.1, 6.1, 16.1, 5.1, 15.1, 4.1, 14.1}; + for(int i=0;i<14;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],b->getIJ(0,i),1e-14); + b->decrRef(); + a->decrRef(); + // + DataArrayInt *c=DataArrayInt::New(); + c->alloc(7,2); + c->setInfoOnComponent(0,"toto"); + c->setInfoOnComponent(1,"tata"); + const int arr3[14]={1,11,2,12,3,13,4,14,5,15,6,16,7,17}; + std::copy(arr3,arr3+14,c->getPointer()); + DataArrayInt *d=c->renumber(arr2); + CPPUNIT_ASSERT_EQUAL(7,d->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(2,d->getNumberOfComponents()); + CPPUNIT_ASSERT(std::string(d->getInfoOnComponent(0))=="toto"); + CPPUNIT_ASSERT(std::string(d->getInfoOnComponent(1))=="tata"); + const int expected2[14]={3, 13, 2, 12, 7, 17, 1, 11, 6, 16, 5, 15, 4, 14}; + for(int i=0;i<14;i++) + CPPUNIT_ASSERT_EQUAL(expected2[i],d->getIJ(0,i)); + c->decrRef(); + d->decrRef(); +} + +void MEDCouplingBasicsTest::testDaDoubleRenumberAndReduce1() +{ + DataArrayDouble *a=DataArrayDouble::New(); + a->alloc(7,2); + a->setInfoOnComponent(0,"toto"); + a->setInfoOnComponent(1,"tata"); + const double arr1[14]={1.1,11.1,2.1,12.1,3.1,13.1,4.1,14.1,5.1,15.1,6.1,16.1,7.1,17.1}; + std::copy(arr1,arr1+14,a->getPointer()); + // + const int arr2[7]={2,-1,1,-1,0,4,3}; + DataArrayDouble *b=a->renumberAndReduce(arr2,5); + CPPUNIT_ASSERT_EQUAL(5,b->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(2,b->getNumberOfComponents()); + CPPUNIT_ASSERT(std::string(b->getInfoOnComponent(0))=="toto"); + CPPUNIT_ASSERT(std::string(b->getInfoOnComponent(1))=="tata"); + const double expected1[10]={5.1,15.1,3.1,13.1,1.1,11.1,7.1,17.1,6.1,16.1}; + for(int i=0;i<10;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],b->getIJ(0,i),1e-14); + b->decrRef(); + a->decrRef(); + // + DataArrayInt *c=DataArrayInt::New(); + c->alloc(7,2); + c->setInfoOnComponent(0,"toto"); + c->setInfoOnComponent(1,"tata"); + const int arr3[14]={1,11,2,12,3,13,4,14,5,15,6,16,7,17}; + std::copy(arr3,arr3+14,c->getPointer()); + DataArrayInt *d=c->renumberAndReduce(arr2,5); + CPPUNIT_ASSERT_EQUAL(5,d->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(2,d->getNumberOfComponents()); + CPPUNIT_ASSERT(std::string(d->getInfoOnComponent(0))=="toto"); + CPPUNIT_ASSERT(std::string(d->getInfoOnComponent(1))=="tata"); + const int expected2[10]={5,15,3,13,1,11,7,17,6,16}; + for(int i=0;i<10;i++) + CPPUNIT_ASSERT_EQUAL(expected2[i],d->getIJ(0,i)); + c->decrRef(); + d->decrRef(); +} + +void MEDCouplingBasicsTest::testDaDoubleRenumberInPlace1() +{ + DataArrayDouble *a=DataArrayDouble::New(); + a->alloc(7,2); + const double arr1[14]={1.1,11.1,2.1,12.1,3.1,13.1,4.1,14.1,5.1,15.1,6.1,16.1,7.1,17.1}; + std::copy(arr1,arr1+14,a->getPointer()); + // + const int arr2[7]={3,1,0,6,5,4,2}; + a->renumberInPlace(arr2); + CPPUNIT_ASSERT_EQUAL(7,a->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(2,a->getNumberOfComponents()); + const double expected1[14]={3.1, 13.1, 2.1, 12.1, 7.1, 17.1, 1.1, 11.1, 6.1, 16.1, 5.1, 15.1, 4.1, 14.1}; + for(int i=0;i<14;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],a->getIJ(0,i),1e-14); + a->decrRef(); + // + DataArrayInt *c=DataArrayInt::New(); + c->alloc(7,2); + const int arr3[14]={1,11,2,12,3,13,4,14,5,15,6,16,7,17}; + std::copy(arr3,arr3+14,c->getPointer()); + c->renumberInPlace(arr2); + CPPUNIT_ASSERT_EQUAL(7,c->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(2,c->getNumberOfComponents()); + const int expected2[14]={3, 13, 2, 12, 7, 17, 1, 11, 6, 16, 5, 15, 4, 14}; + for(int i=0;i<14;i++) + CPPUNIT_ASSERT_EQUAL(expected2[i],c->getIJ(0,i)); + c->decrRef(); +} + +void MEDCouplingBasicsTest::testDaDoubleRenumberR1() +{ + DataArrayDouble *a=DataArrayDouble::New(); + a->alloc(7,2); + a->setInfoOnComponent(0,"toto"); + a->setInfoOnComponent(1,"tata"); + const double arr1[14]={1.1,11.1,2.1,12.1,3.1,13.1,4.1,14.1,5.1,15.1,6.1,16.1,7.1,17.1}; + std::copy(arr1,arr1+14,a->getPointer()); + // + const int arr2[7]={3,1,0,6,5,4,2}; + DataArrayDouble *b=a->renumberR(arr2); + CPPUNIT_ASSERT_EQUAL(7,b->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(2,b->getNumberOfComponents()); + CPPUNIT_ASSERT(std::string(b->getInfoOnComponent(0))=="toto"); + CPPUNIT_ASSERT(std::string(b->getInfoOnComponent(1))=="tata"); + const double expected1[14]={4.1, 14.1, 2.1, 12.1, 1.1, 11.1, 7.1, 17.1, 6.1, 16.1, 5.1, 15.1, 3.1, 13.1}; + for(int i=0;i<14;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],b->getIJ(0,i),1e-14); + b->decrRef(); + a->decrRef(); + // + DataArrayInt *c=DataArrayInt::New(); + c->alloc(7,2); + c->setInfoOnComponent(0,"toto"); + c->setInfoOnComponent(1,"tata"); + const int arr3[14]={1,11,2,12,3,13,4,14,5,15,6,16,7,17}; + std::copy(arr3,arr3+14,c->getPointer()); + DataArrayInt *d=c->renumberR(arr2); + CPPUNIT_ASSERT_EQUAL(7,d->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(2,d->getNumberOfComponents()); + CPPUNIT_ASSERT(std::string(d->getInfoOnComponent(0))=="toto"); + CPPUNIT_ASSERT(std::string(d->getInfoOnComponent(1))=="tata"); + const int expected2[14]={4, 14, 2, 12, 1, 11, 7, 17, 6, 16, 5, 15, 3, 13}; + for(int i=0;i<14;i++) + CPPUNIT_ASSERT_EQUAL(expected2[i],d->getIJ(0,i)); + c->decrRef(); + d->decrRef(); +} + +void MEDCouplingBasicsTest::testDaDoubleRenumberInPlaceR1() +{ + DataArrayDouble *a=DataArrayDouble::New(); + a->alloc(7,2); + const double arr1[14]={1.1,11.1,2.1,12.1,3.1,13.1,4.1,14.1,5.1,15.1,6.1,16.1,7.1,17.1}; + std::copy(arr1,arr1+14,a->getPointer()); + // + const int arr2[7]={3,1,0,6,5,4,2}; + a->renumberInPlaceR(arr2); + CPPUNIT_ASSERT_EQUAL(7,a->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(2,a->getNumberOfComponents()); + const double expected1[14]={4.1, 14.1, 2.1, 12.1, 1.1, 11.1, 7.1, 17.1, 6.1, 16.1, 5.1, 15.1, 3.1, 13.1}; + for(int i=0;i<14;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],a->getIJ(0,i),1e-14); + a->decrRef(); + // + DataArrayInt *c=DataArrayInt::New(); + c->alloc(7,2); + const int arr3[14]={1,11,2,12,3,13,4,14,5,15,6,16,7,17}; + std::copy(arr3,arr3+14,c->getPointer()); + c->renumberInPlaceR(arr2); + CPPUNIT_ASSERT_EQUAL(7,c->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(2,c->getNumberOfComponents()); + const int expected2[14]={4, 14, 2, 12, 1, 11, 7, 17, 6, 16, 5, 15, 3, 13}; + for(int i=0;i<14;i++) + CPPUNIT_ASSERT_EQUAL(expected2[i],c->getIJ(0,i)); + c->decrRef(); +} + +void MEDCouplingBasicsTest::testDaDoubleSelectByTupleId1() +{ + DataArrayDouble *a=DataArrayDouble::New(); + a->alloc(7,2); + a->setInfoOnComponent(0,"toto"); + a->setInfoOnComponent(1,"tata"); + const double arr1[14]={1.1,11.1,2.1,12.1,3.1,13.1,4.1,14.1,5.1,15.1,6.1,16.1,7.1,17.1}; + std::copy(arr1,arr1+14,a->getPointer()); + // + const int arr2[7]={4,2,0,6,5}; + DataArrayDouble *b=a->selectByTupleId(arr2,arr2+5); + CPPUNIT_ASSERT_EQUAL(5,b->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(2,b->getNumberOfComponents()); + CPPUNIT_ASSERT(std::string(b->getInfoOnComponent(0))=="toto"); + CPPUNIT_ASSERT(std::string(b->getInfoOnComponent(1))=="tata"); + const double expected1[10]={5.1,15.1,3.1,13.1,1.1,11.1,7.1,17.1,6.1,16.1}; + for(int i=0;i<10;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],b->getIJ(0,i),1e-14); + b->decrRef(); + a->decrRef(); + // + DataArrayInt *c=DataArrayInt::New(); + c->alloc(7,2); + c->setInfoOnComponent(0,"toto"); + c->setInfoOnComponent(1,"tata"); + const int arr3[14]={1,11,2,12,3,13,4,14,5,15,6,16,7,17}; + std::copy(arr3,arr3+14,c->getPointer()); + DataArrayInt *d=c->selectByTupleId(arr2,arr2+5); + CPPUNIT_ASSERT_EQUAL(5,d->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(2,d->getNumberOfComponents()); + CPPUNIT_ASSERT(std::string(d->getInfoOnComponent(0))=="toto"); + CPPUNIT_ASSERT(std::string(d->getInfoOnComponent(1))=="tata"); + const int expected2[10]={5,15,3,13,1,11,7,17,6,16}; + for(int i=0;i<10;i++) + CPPUNIT_ASSERT_EQUAL(expected2[i],d->getIJ(0,i)); + c->decrRef(); + d->decrRef(); +} + +void MEDCouplingBasicsTest::testDaDoubleGetMinMaxValues1() +{ + DataArrayDouble *a=DataArrayDouble::New(); + a->alloc(9,1); + const double arr1[9]={2.34,4.56,-6.77,4.55,4.56,2.24,2.34,1.02,4.56}; + std::copy(arr1,arr1+9,a->getPointer()); + int where; + double m=a->getMaxValue(where); + CPPUNIT_ASSERT_EQUAL(1,where); + CPPUNIT_ASSERT_DOUBLES_EQUAL(4.56,m,1e-12); + DataArrayInt *ws; + m=a->getMaxValue2(ws); + CPPUNIT_ASSERT_DOUBLES_EQUAL(4.56,m,1e-12); + CPPUNIT_ASSERT_EQUAL(3,ws->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,ws->getNumberOfComponents()); + const int expected1[3]={1,4,8}; + for(int i=0;i<3;i++) + CPPUNIT_ASSERT_EQUAL(expected1[i],ws->getIJ(i,0)); + ws->decrRef(); + a->decrRef(); + a=DataArrayDouble::New(); + const double arr2[9]={-2.34,-4.56,6.77,-4.55,-4.56,-2.24,-2.34,-1.02,-4.56}; + a->alloc(9,1); + std::copy(arr2,arr2+9,a->getPointer()); + where=-2; + m=a->getMinValue(where); + CPPUNIT_ASSERT_EQUAL(1,where); + CPPUNIT_ASSERT_DOUBLES_EQUAL(-4.56,m,1e-12); + m=a->getMinValue2(ws); + CPPUNIT_ASSERT_DOUBLES_EQUAL(-4.56,m,1e-12); + CPPUNIT_ASSERT_EQUAL(3,ws->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,ws->getNumberOfComponents()); + for(int i=0;i<3;i++) + CPPUNIT_ASSERT_EQUAL(expected1[i],ws->getIJ(i,0)); + ws->decrRef(); + a->decrRef(); +} + +void MEDCouplingBasicsTest::testFieldDoubleGetMinMaxValues2() +{ + MEDCouplingUMesh *m1=0; + MEDCouplingUMesh *m2=build3DExtrudedUMesh_1(m1); + m1->decrRef(); + CPPUNIT_ASSERT_EQUAL(18,m2->getNumberOfCells()); + const double arr1[18]={8.71,4.53,-12.41,8.71,-8.71,8.7099,4.55,8.71,5.55,6.77,-1e-200,4.55,8.7099,0.,1.23,0.,2.22,8.71}; + MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME); + DataArrayDouble *a=DataArrayDouble::New(); + a->alloc(18,1); + std::copy(arr1,arr1+18,a->getPointer()); + f->setArray(a); + a->decrRef(); + f->setMesh(m2); + // + f->checkCoherency(); + double m=f->getMaxValue(); + CPPUNIT_ASSERT_DOUBLES_EQUAL(8.71,m,1e-12); + DataArrayInt *ws; + m=f->getMaxValue2(ws); + CPPUNIT_ASSERT_DOUBLES_EQUAL(8.71,m,1e-12); + CPPUNIT_ASSERT_EQUAL(4,ws->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,ws->getNumberOfComponents()); + const int expected1[4]={0,3,7,17}; + for(int i=0;i<4;i++) + CPPUNIT_ASSERT_EQUAL(expected1[i],ws->getIJ(i,0)); + ws->decrRef(); + // + const double arr2[18]={-8.71,-4.53,12.41,-8.71,8.71,-8.7099,-4.55,-8.71,-5.55,-6.77,1e-200,-4.55,-8.7099,0.,-1.23,0.,-2.22,-8.71}; + std::copy(arr2,arr2+18,a->getPointer()); + f->checkCoherency(); + m=f->getMinValue(); + CPPUNIT_ASSERT_DOUBLES_EQUAL(-8.71,m,1e-12); + m=f->getMinValue2(ws); + CPPUNIT_ASSERT_DOUBLES_EQUAL(-8.71,m,1e-12); + CPPUNIT_ASSERT_EQUAL(4,ws->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,ws->getNumberOfComponents()); + for(int i=0;i<4;i++) + CPPUNIT_ASSERT_EQUAL(expected1[i],ws->getIJ(i,0)); + ws->decrRef(); + // + f->decrRef(); + m2->decrRef(); +} + +void MEDCouplingBasicsTest::testBuildUnstructuredCMesh1() +{ + MEDCouplingCMesh *m=MEDCouplingCMesh::New(); + DataArrayDouble *da=DataArrayDouble::New(); + const double discX[4]={2.3,3.4,5.8,10.2}; + const double discY[3]={12.3,23.4,45.8}; + const double discZ[5]={-0.7,1.2,1.25,2.13,2.67}; + da->alloc(4,1); + std::copy(discX,discX+4,da->getPointer()); + m->setCoordsAt(0,da); + da->decrRef(); + m->checkCoherency(); + double pos=2.4; + CPPUNIT_ASSERT_EQUAL(0,m->getCellContainingPoint(&pos,1e-12)); + pos=3.7; + CPPUNIT_ASSERT_EQUAL(1,m->getCellContainingPoint(&pos,1e-12)); + pos=5.9; + CPPUNIT_ASSERT_EQUAL(2,m->getCellContainingPoint(&pos,1e-12)); + pos=10.3; + CPPUNIT_ASSERT_EQUAL(-1,m->getCellContainingPoint(&pos,1e-12)); + pos=1.3; + CPPUNIT_ASSERT_EQUAL(-1,m->getCellContainingPoint(&pos,1e-12)); + // + MEDCouplingUMesh *m2=m->buildUnstructured(); + m2->checkCoherency(); + MEDCouplingFieldDouble *f1=m->getMeasureField(false); + MEDCouplingFieldDouble *f2=m2->getMeasureField(false); + CPPUNIT_ASSERT_EQUAL(f1->getNumberOfTuples(),3); + CPPUNIT_ASSERT_EQUAL(f2->getNumberOfTuples(),3); + CPPUNIT_ASSERT_EQUAL(1,m2->getMeshDimension()); + CPPUNIT_ASSERT_EQUAL(1,m2->getSpaceDimension()); + for(int i=0;i<3;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(f1->getIJ(i,0),f2->getIJ(i,0),1e-10); + da=DataArrayDouble::New(); + da->alloc(3,1); + std::copy(discY,discY+3,da->getPointer()); + m->setCoordsAt(1,da); + da->decrRef(); + m2->decrRef(); + f1->decrRef(); + f2->decrRef(); + // + m2=m->buildUnstructured(); + m2->checkCoherency(); + f1=m->getMeasureField(false); + f2=m2->getMeasureField(false); + CPPUNIT_ASSERT_EQUAL(f1->getNumberOfTuples(),6); + CPPUNIT_ASSERT_EQUAL(f2->getNumberOfTuples(),6); + CPPUNIT_ASSERT_EQUAL(2,m2->getMeshDimension()); + CPPUNIT_ASSERT_EQUAL(2,m2->getSpaceDimension()); + for(int i=0;i<6;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(f1->getIJ(i,0),f2->getIJ(i,0),1e-10); + f1->decrRef(); + f2->decrRef(); + m2->decrRef(); + // + da=DataArrayDouble::New(); + da->alloc(5,1); + std::copy(discZ,discZ+5,da->getPointer()); + m->setCoordsAt(2,da); + da->decrRef(); + m2=m->buildUnstructured(); + m2->checkCoherency(); + f1=m->getMeasureField(false); + f2=m2->getMeasureField(false); + CPPUNIT_ASSERT_EQUAL(f1->getNumberOfTuples(),24); + CPPUNIT_ASSERT_EQUAL(f2->getNumberOfTuples(),24); + CPPUNIT_ASSERT_EQUAL(3,m2->getMeshDimension()); + CPPUNIT_ASSERT_EQUAL(3,m2->getSpaceDimension()); + for(int i=0;i<24;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(f1->getIJ(i,0),f2->getIJ(i,0),1e-10); + f1->decrRef(); + f2->decrRef(); + // + double pos1[3]={5.,30.,2.}; + CPPUNIT_ASSERT_EQUAL(16,m->getCellContainingPoint(pos1,1e-12)); + // + const double pt[3]={2.4,12.7,-3.4}; + m->scale(pt,3.7); + MEDCouplingUMesh *m3=m->buildUnstructured(); + m2->scale(pt,3.7); + CPPUNIT_ASSERT(m3->isEqual(m2,1e-12)); + m2->decrRef(); + m3->decrRef(); + // + m->decrRef(); +} + +void MEDCouplingBasicsTest::testDataArrayIntInvertO2NNO21() +{ + const int arr1[6]={2,0,4,1,5,3}; + DataArrayInt *da=DataArrayInt::New(); + da->alloc(6,1); + std::copy(arr1,arr1+6,da->getPointer()); + DataArrayInt *da2=da->invertArrayO2N2N2O(6); + CPPUNIT_ASSERT_EQUAL(6,da2->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,da2->getNumberOfComponents()); + const int expected1[6]={1,3,0,5,2,4}; + for(int i=0;i<6;i++) + CPPUNIT_ASSERT_EQUAL(expected1[i],da2->getIJ(i,0)); + DataArrayInt *da3=da2->invertArrayN2O2O2N(6); + for(int i=0;i<6;i++) + CPPUNIT_ASSERT_EQUAL(arr1[i],da3->getIJ(i,0)); + da3->decrRef(); + da2->decrRef(); + da->decrRef(); + // + const int arr2[10]={3,-1,5,4,-1,0,-1,1,2,-1}; + da=DataArrayInt::New(); + da->alloc(10,1); + std::copy(arr2,arr2+10,da->getPointer()); + da2=da->invertArrayO2N2N2O(6); + CPPUNIT_ASSERT_EQUAL(6,da2->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,da2->getNumberOfComponents()); + const int expected2[10]={5,7,8,0,3,2}; + for(int i=0;i<6;i++) + CPPUNIT_ASSERT_EQUAL(expected2[i],da2->getIJ(i,0)); + da3=da2->invertArrayN2O2O2N(10); + for(int i=0;i<10;i++) + CPPUNIT_ASSERT_EQUAL(arr2[i],da3->getIJ(i,0)); + da3->decrRef(); + da2->decrRef(); + da->decrRef(); +} + +void MEDCouplingBasicsTest::testKeepSetSelectedComponent1() +{ + const double arr1[20]={1.,2.,3.,4., 11.,12.,13.,14., 21.,22.,23.,24., 31.,32.,33.,34., 41.,42.,43.,44.}; + DataArrayDouble *a1=DataArrayDouble::New(); + a1->alloc(5,4); + std::copy(arr1,arr1+20,a1->getPointer()); + a1->setInfoOnComponent(0,"aaaa"); + a1->setInfoOnComponent(1,"bbbb"); + a1->setInfoOnComponent(2,"cccc"); + a1->setInfoOnComponent(3,"dddd"); + const int arr2[6]={1,2,1,2,0,0}; + std::vector arr2V(arr2,arr2+6); + DataArrayDouble *a2=a1->keepSelectedComponents(arr2V); + CPPUNIT_ASSERT_EQUAL(6,a2->getNumberOfComponents()); + CPPUNIT_ASSERT_EQUAL(5,a2->getNumberOfTuples()); + CPPUNIT_ASSERT(std::string(a2->getInfoOnComponent(0))=="bbbb"); + CPPUNIT_ASSERT(std::string(a2->getInfoOnComponent(1))=="cccc"); + CPPUNIT_ASSERT(std::string(a2->getInfoOnComponent(2))=="bbbb"); + CPPUNIT_ASSERT(std::string(a2->getInfoOnComponent(3))=="cccc"); + CPPUNIT_ASSERT(std::string(a2->getInfoOnComponent(4))=="aaaa"); + CPPUNIT_ASSERT(std::string(a2->getInfoOnComponent(5))=="aaaa"); + const double expected1[30]={2.,3.,2.,3.,1.,1., 12.,13.,12.,13.,11.,11., 22.,23.,22.,23.,21.,21., 32.,33.,32.,33.,31.,31., 42.,43.,42.,43.,41.,41.}; + for(int i=0;i<30;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],a2->getIJ(0,i),1e-14); + DataArrayInt *a3=a1->convertToIntArr(); + DataArrayInt *a4=a3->keepSelectedComponents(arr2V); + CPPUNIT_ASSERT_EQUAL(6,a4->getNumberOfComponents()); + CPPUNIT_ASSERT_EQUAL(5,a4->getNumberOfTuples()); + CPPUNIT_ASSERT(std::string(a4->getInfoOnComponent(0))=="bbbb"); + CPPUNIT_ASSERT(std::string(a4->getInfoOnComponent(1))=="cccc"); + CPPUNIT_ASSERT(std::string(a4->getInfoOnComponent(2))=="bbbb"); + CPPUNIT_ASSERT(std::string(a4->getInfoOnComponent(3))=="cccc"); + CPPUNIT_ASSERT(std::string(a4->getInfoOnComponent(4))=="aaaa"); + CPPUNIT_ASSERT(std::string(a4->getInfoOnComponent(5))=="aaaa"); + for(int i=0;i<30;i++) + CPPUNIT_ASSERT_EQUAL(int(expected1[i]),a4->getIJ(0,i)); + // setSelectedComponents + const int arr3[2]={3,2}; + std::vector arr3V(arr3,arr3+2); + DataArrayDouble *a5=a1->keepSelectedComponents(arr3V); + a5->setInfoOnComponent(0,"eeee"); + a5->setInfoOnComponent(1,"ffff"); + const int arr4[2]={1,2}; + std::vector arr4V(arr4,arr4+2); + a2->setSelectedComponents(a5,arr4V); + CPPUNIT_ASSERT_EQUAL(6,a2->getNumberOfComponents()); + CPPUNIT_ASSERT_EQUAL(5,a2->getNumberOfTuples()); + CPPUNIT_ASSERT(std::string(a2->getInfoOnComponent(0))=="bbbb"); + CPPUNIT_ASSERT(std::string(a2->getInfoOnComponent(1))=="eeee"); + CPPUNIT_ASSERT(std::string(a2->getInfoOnComponent(2))=="ffff"); + CPPUNIT_ASSERT(std::string(a2->getInfoOnComponent(3))=="cccc"); + CPPUNIT_ASSERT(std::string(a2->getInfoOnComponent(4))=="aaaa"); + CPPUNIT_ASSERT(std::string(a2->getInfoOnComponent(5))=="aaaa"); + const double expected2[30]={2.,4.,3.,3.,1.,1., 12.,14.,13.,13.,11.,11., 22.,24.,23.,23.,21.,21., 32.,34.,33.,33.,31.,31., 42.,44.,43.,43.,41.,41.}; + for(int i=0;i<30;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],a2->getIJ(0,i),1e-14); + DataArrayInt *a6=a5->convertToIntArr(); + a6->setInfoOnComponent(0,"eeee"); + a6->setInfoOnComponent(1,"ffff"); + a4->setSelectedComponents(a6,arr4V); + CPPUNIT_ASSERT_EQUAL(6,a4->getNumberOfComponents()); + CPPUNIT_ASSERT_EQUAL(5,a4->getNumberOfTuples()); + CPPUNIT_ASSERT(std::string(a4->getInfoOnComponent(0))=="bbbb"); + CPPUNIT_ASSERT(std::string(a4->getInfoOnComponent(1))=="eeee"); + CPPUNIT_ASSERT(std::string(a4->getInfoOnComponent(2))=="ffff"); + CPPUNIT_ASSERT(std::string(a4->getInfoOnComponent(3))=="cccc"); + CPPUNIT_ASSERT(std::string(a4->getInfoOnComponent(4))=="aaaa"); + CPPUNIT_ASSERT(std::string(a4->getInfoOnComponent(5))=="aaaa"); + for(int i=0;i<30;i++) + CPPUNIT_ASSERT_EQUAL(int(expected2[i]),a4->getIJ(0,i)); + // test of throw + const int arr5[3]={2,3,6}; + const int arr6[3]={2,7,5}; + const int arr7[4]={2,1,4,6}; + std::vector arr5V(arr5,arr5+3); + std::vector 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); + CPPUNIT_ASSERT_THROW(a2->setSelectedComponents(a1,arr7V),INTERP_KERNEL::Exception); + arr7V.resize(3); + CPPUNIT_ASSERT_THROW(a2->setSelectedComponents(a1,arr7V),INTERP_KERNEL::Exception); + // + a6->decrRef(); + a5->decrRef(); + a4->decrRef(); + a3->decrRef(); + a2->decrRef(); + a1->decrRef(); +} + +void MEDCouplingBasicsTest::testKeepSetSelectedComponent2() +{ + MEDCouplingUMesh *m1=build2DTargetMesh_1(); + const double arr1[20]={1.,2.,3.,4., 11.,12.,13.,14., 21.,22.,23.,24., 31.,32.,33.,34., 41.,42.,43.,44.}; + DataArrayDouble *a1=DataArrayDouble::New(); + a1->alloc(5,4); + std::copy(arr1,arr1+20,a1->getPointer()); + a1->setInfoOnComponent(0,"aaaa"); + a1->setInfoOnComponent(1,"bbbb"); + a1->setInfoOnComponent(2,"cccc"); + a1->setInfoOnComponent(3,"dddd"); + MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME); + f1->setTime(2.3,4,5); + f1->setMesh(m1); + f1->setName("f1"); + f1->setArray(a1); + f1->checkCoherency(); + // + const int arr2[6]={1,2,1,2,0,0}; + std::vector arr2V(arr2,arr2+6); + MEDCouplingFieldDouble *f2=f1->keepSelectedComponents(arr2V); + CPPUNIT_ASSERT(f2->getMesh()==f1->getMesh()); + CPPUNIT_ASSERT(f2->getTimeDiscretization()==ONE_TIME); + int dt,it; + CPPUNIT_ASSERT_DOUBLES_EQUAL(2.3,f2->getTime(dt,it),1e-13); + CPPUNIT_ASSERT_EQUAL(4,dt); + CPPUNIT_ASSERT_EQUAL(5,it); + f2->checkCoherency(); + CPPUNIT_ASSERT_EQUAL(6,f2->getNumberOfComponents()); + CPPUNIT_ASSERT_EQUAL(5,f2->getNumberOfTuples()); + CPPUNIT_ASSERT(std::string(f2->getArray()->getInfoOnComponent(0))=="bbbb"); + CPPUNIT_ASSERT(std::string(f2->getArray()->getInfoOnComponent(1))=="cccc"); + CPPUNIT_ASSERT(std::string(f2->getArray()->getInfoOnComponent(2))=="bbbb"); + CPPUNIT_ASSERT(std::string(f2->getArray()->getInfoOnComponent(3))=="cccc"); + CPPUNIT_ASSERT(std::string(f2->getArray()->getInfoOnComponent(4))=="aaaa"); + CPPUNIT_ASSERT(std::string(f2->getArray()->getInfoOnComponent(5))=="aaaa"); + const double expected1[30]={2.,3.,2.,3.,1.,1., 12.,13.,12.,13.,11.,11., 22.,23.,22.,23.,21.,21., 32.,33.,32.,33.,31.,31., 42.,43.,42.,43.,41.,41.}; + for(int i=0;i<30;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f2->getIJ(0,i),1e-14); + //setSelectedComponents + const int arr3[2]={3,2}; + std::vector 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->checkCoherency(); + const int arr4[2]={1,2}; + std::vector arr4V(arr4,arr4+2); + f2->setSelectedComponents(f5,arr4V); + CPPUNIT_ASSERT_EQUAL(6,f2->getNumberOfComponents()); + CPPUNIT_ASSERT_EQUAL(5,f2->getNumberOfTuples()); + f2->checkCoherency(); + CPPUNIT_ASSERT_DOUBLES_EQUAL(2.3,f2->getTime(dt,it),1e-13); + CPPUNIT_ASSERT_EQUAL(4,dt); + CPPUNIT_ASSERT_EQUAL(5,it); + CPPUNIT_ASSERT(std::string(f2->getArray()->getInfoOnComponent(0))=="bbbb"); + CPPUNIT_ASSERT(std::string(f2->getArray()->getInfoOnComponent(1))=="eeee"); + CPPUNIT_ASSERT(std::string(f2->getArray()->getInfoOnComponent(2))=="ffff"); + CPPUNIT_ASSERT(std::string(f2->getArray()->getInfoOnComponent(3))=="cccc"); + CPPUNIT_ASSERT(std::string(f2->getArray()->getInfoOnComponent(4))=="aaaa"); + CPPUNIT_ASSERT(std::string(f2->getArray()->getInfoOnComponent(5))=="aaaa"); + const double expected2[30]={2.,4.,3.,3.,1.,1., 12.,14.,13.,13.,11.,11., 22.,24.,23.,23.,21.,21., 32.,34.,33.,33.,31.,31., 42.,44.,43.,43.,41.,41.}; + for(int i=0;i<30;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],f2->getIJ(0,i),1e-14); + f5->decrRef(); + f1->decrRef(); + f2->decrRef(); + a1->decrRef(); + m1->decrRef(); +} + +void MEDCouplingBasicsTest::testDAIGetIdsEqual1() +{ + const int tab1[7]={5,-2,-4,-2,3,2,-2}; + DataArrayInt *da=DataArrayInt::New(); + da->alloc(7,1); + std::copy(tab1,tab1+7,da->getPointer()); + DataArrayInt *da2=da->getIdsEqual(-2); + CPPUNIT_ASSERT_EQUAL(3,da2->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,da2->getNumberOfComponents()); + const int expected1[3]={1,3,6}; + CPPUNIT_ASSERT(std::equal(expected1,expected1+3,da2->getConstPointer())); + da2->decrRef(); + da->decrRef(); +} + +void MEDCouplingBasicsTest::testDAIGetIdsEqualList1() +{ + const int tab1[7]={5,-2,-4,-2,3,2,-2}; + DataArrayInt *da=DataArrayInt::New(); + da->alloc(7,1); + std::copy(tab1,tab1+7,da->getPointer()); + const int tab2[3]={3,-2,0}; + std::vector tab2V(tab2,tab2+3); + DataArrayInt *da2=da->getIdsEqualList(tab2V); + CPPUNIT_ASSERT_EQUAL(4,da2->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,da2->getNumberOfComponents()); + const int expected1[4]={1,3,4,6}; + CPPUNIT_ASSERT(std::equal(expected1,expected1+4,da2->getConstPointer())); + da2->decrRef(); + da->decrRef(); +} + +void MEDCouplingBasicsTest::testDAFromNoInterlace1() +{ + const int tab1[15]={1,11,21,31,41,2,12,22,32,42,3,13,23,33,43}; + DataArrayInt *da=DataArrayInt::New(); + da->alloc(5,3); + std::copy(tab1,tab1+15,da->getPointer()); + DataArrayInt *da2=da->fromNoInterlace(); + const int expected1[15]={1,2,3,11,12,13,21,22,23,31,32,33,41,42,43}; + CPPUNIT_ASSERT_EQUAL(5,da2->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(3,da2->getNumberOfComponents());// it's not a bug. Avoid to have 1 million components ! + CPPUNIT_ASSERT(std::equal(expected1,expected1+15,da2->getConstPointer())); + DataArrayDouble *da3=da->convertToDblArr(); + DataArrayDouble *da4=da3->fromNoInterlace(); + CPPUNIT_ASSERT_EQUAL(5,da4->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(3,da4->getNumberOfComponents());// it's not a bug. Avoid to have 1 million components ! + for(int i=0;i<15;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL((double)expected1[i],da4->getIJ(0,i),1e-14); + da4->decrRef(); + da3->decrRef(); + da2->decrRef(); + da->decrRef(); +} + +void MEDCouplingBasicsTest::testDAToNoInterlace1() +{ + const int tab1[15]={1,2,3,11,12,13,21,22,23,31,32,33,41,42,43}; + DataArrayInt *da=DataArrayInt::New(); + da->alloc(5,3); + std::copy(tab1,tab1+15,da->getPointer()); + DataArrayInt *da2=da->toNoInterlace(); + const int expected1[15]={1,11,21,31,41,2,12,22,32,42,3,13,23,33,43}; + CPPUNIT_ASSERT_EQUAL(5,da2->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(3,da2->getNumberOfComponents());// it's not a bug. Avoid to have 1 million components ! + CPPUNIT_ASSERT(std::equal(expected1,expected1+15,da2->getConstPointer())); + DataArrayDouble *da3=da->convertToDblArr(); + DataArrayDouble *da4=da3->toNoInterlace(); + CPPUNIT_ASSERT_EQUAL(5,da4->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(3,da4->getNumberOfComponents());// it's not a bug. Avoid to have 1 million components ! + for(int i=0;i<15;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL((double)expected1[i],da4->getIJ(0,i),1e-14); + da4->decrRef(); + da3->decrRef(); + da2->decrRef(); + da->decrRef(); +} + +void MEDCouplingBasicsTest::testDAIsUniform1() +{ + const int tab1[5]={1,1,1,1,1}; + DataArrayInt *da=DataArrayInt::New(); + da->alloc(5,1); + std::copy(tab1,tab1+5,da->getPointer()); + CPPUNIT_ASSERT(da->isUniform(1)); + da->setIJ(2,0,2); + CPPUNIT_ASSERT(!da->isUniform(1)); + da->setIJ(2,0,1); + CPPUNIT_ASSERT(da->isUniform(1)); + DataArrayDouble *da2=da->convertToDblArr(); + CPPUNIT_ASSERT(da2->isUniform(1.,1e-12)); + da2->setIJ(1,0,1.+1.e-13); + CPPUNIT_ASSERT(da2->isUniform(1.,1e-12)); + da2->setIJ(1,0,1.+1.e-11); + CPPUNIT_ASSERT(!da2->isUniform(1.,1e-12)); + da2->decrRef(); + da->decrRef(); +} + +void MEDCouplingBasicsTest::testDADFromPolarToCart1() +{ + const double tab1[4]={2.,0.2,2.5,0.7}; + DataArrayDouble *da=DataArrayDouble::New(); + da->alloc(2,2); + std::copy(tab1,tab1+4,da->getPointer()); + DataArrayDouble *da2=da->fromPolarToCart(); + const double expected1[4]={1.9601331556824833,0.39733866159012243, 1.9121054682112213,1.6105442180942275}; + for(int i=0;i<4;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],da2->getIJ(0,i),1e-13); + da2->decrRef(); + da->decrRef(); +} + +void MEDCouplingBasicsTest::testDADFromCylToCart1() +{ + const double tab1[6]={2.,0.2,4.,2.5,0.7,9.}; + DataArrayDouble *da=DataArrayDouble::New(); + da->alloc(2,3); + std::copy(tab1,tab1+6,da->getPointer()); + DataArrayDouble *da2=da->fromCylToCart(); + const double expected1[6]={1.9601331556824833,0.39733866159012243,4., 1.9121054682112213,1.6105442180942275,9.}; + for(int i=0;i<6;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],da2->getIJ(0,i),1e-13); + da2->decrRef(); + da->decrRef(); +} + +void MEDCouplingBasicsTest::testDADFromSpherToCart1() +{ + const double tab1[6]={2.,0.2,0.3,2.5,0.7,0.8}; + DataArrayDouble *da=DataArrayDouble::New(); + da->alloc(2,3); + std::copy(tab1,tab1+6,da->getPointer()); + DataArrayDouble *da2=da->fromSpherToCart(); + const double expected1[6]={0.37959212195737485,0.11742160338765303,1.9601331556824833, 1.1220769624465328,1.1553337045129035,1.9121054682112213}; + for(int i=0;i<6;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],da2->getIJ(0,i),1e-13); + da2->decrRef(); + da->decrRef(); +} + +void MEDCouplingBasicsTest::testUnPolyze1() +{ + const int elts[8]={0,1,2,3,4,5,6,7}; + std::vector eltsV(elts,elts+8); + MEDCouplingUMesh *mesh=build3DTargetMesh_1(); + mesh->convertToPolyTypes(eltsV); + mesh->unPolyze(); + MEDCouplingUMesh *mesh2=build3DTargetMesh_1(); + mesh->checkCoherency(); + CPPUNIT_ASSERT(mesh->isEqual(mesh2,1e-12)); + mesh->convertToPolyTypes(eltsV); + CPPUNIT_ASSERT(!mesh->isEqual(mesh2,1e-12)); + mesh->getNodalConnectivity()->setIJ(0,6,10); + mesh->getNodalConnectivity()->setIJ(0,7,9); + mesh->getNodalConnectivity()->setIJ(0,8,12); + mesh->getNodalConnectivity()->setIJ(0,9,13); + mesh->unPolyze(); + CPPUNIT_ASSERT(mesh->isEqual(mesh2,1e-12)); + mesh->convertToPolyTypes(eltsV); + mesh->getNodalConnectivity()->setIJ(0,6,12); + mesh->getNodalConnectivity()->setIJ(0,7,13); + mesh->getNodalConnectivity()->setIJ(0,8,10); + mesh->getNodalConnectivity()->setIJ(0,9,9); + mesh->unPolyze(); + CPPUNIT_ASSERT(mesh->isEqual(mesh2,1e-12)); + mesh->convertToPolyTypes(eltsV); + mesh->getNodalConnectivity()->setIJ(0,6,12); + mesh->getNodalConnectivity()->setIJ(0,7,10); + mesh->getNodalConnectivity()->setIJ(0,8,13); + mesh->getNodalConnectivity()->setIJ(0,9,9); + mesh->unPolyze(); + CPPUNIT_ASSERT(!mesh->isEqual(mesh2,1e-12)); + mesh->decrRef(); + mesh2->decrRef(); + // Test for 2D mesh + mesh=build2DTargetMesh_1(); + mesh2=build2DTargetMesh_1(); + eltsV.resize(5); + mesh->convertToPolyTypes(eltsV); + CPPUNIT_ASSERT(!mesh->isEqual(mesh2,1e-12)); + mesh->unPolyze(); + CPPUNIT_ASSERT(mesh->isEqual(mesh2,1e-12)); + mesh->decrRef(); + mesh2->decrRef(); +} + +void MEDCouplingBasicsTest::testConvertDegeneratedCells1() +{ + MEDCouplingUMesh *mesh=build3DTargetMesh_1(); + int conn[32]={0,1,3,3,9,10,12,12, 0,1,3,4,9,9,9,9, 1,1,1,1,10,12,9,10, 10,11,12,9,1,1,1,1}; + mesh->allocateCells(4); + mesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn); + mesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+8); + mesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+16); + mesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+24); + mesh->finishInsertingCells(); + mesh->checkCoherency(); + CPPUNIT_ASSERT_EQUAL(4,mesh->getNumberOfCells()); + CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_HEXA8,mesh->getTypeOfCell(0)); + CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_HEXA8,mesh->getTypeOfCell(1)); + CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_HEXA8,mesh->getTypeOfCell(2)); + CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_HEXA8,mesh->getTypeOfCell(3)); + MEDCouplingFieldDouble *f1=mesh->getMeasureField(true); + mesh->convertDegeneratedCells(); + mesh->checkCoherency(); + MEDCouplingFieldDouble *f2=mesh->getMeasureField(true); + CPPUNIT_ASSERT_EQUAL(4,mesh->getNumberOfCells()); + CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_PENTA6,mesh->getTypeOfCell(0)); + CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_PYRA5,mesh->getTypeOfCell(1)); + CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TETRA4,mesh->getTypeOfCell(2)); + CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_PYRA5,mesh->getTypeOfCell(3)); + for(int i=0;i<4;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(f1->getArray()->getIJ(0,i),f2->getArray()->getIJ(0,i),1e-5); + f1->decrRef(); + f2->decrRef(); + mesh->decrRef(); +} + +void MEDCouplingBasicsTest::testGetNodeIdsNearPoints1() +{ + MEDCouplingUMesh *mesh=build2DTargetMesh_1(); + DataArrayDouble *coords=mesh->getCoords(); + DataArrayDouble *tmp=DataArrayDouble::New(); + tmp->alloc(3,2); + const double vals[6]={0.2,0.2,0.1,0.2,0.2,0.2}; + std::copy(vals,vals+6,tmp->getPointer()); + DataArrayDouble *tmp2=DataArrayDouble::Aggregate(coords,tmp); + tmp->decrRef(); + mesh->setCoords(tmp2); + tmp2->decrRef(); + const double pts[6]={0.2,0.2,0.1,0.3,-0.3,0.7}; + std::vector c=mesh->getNodeIdsNearPoint(pts,1e-7); + CPPUNIT_ASSERT_EQUAL(3,(int)c.size()); + CPPUNIT_ASSERT_EQUAL(4,c[0]); + CPPUNIT_ASSERT_EQUAL(9,c[1]); + CPPUNIT_ASSERT_EQUAL(11,c[2]); + c.clear(); + std::vector cI; + mesh->getNodeIdsNearPoints(pts,3,1e-7,c,cI); + CPPUNIT_ASSERT_EQUAL(4,(int)cI.size()); + CPPUNIT_ASSERT_EQUAL(4,(int)c.size()); + CPPUNIT_ASSERT_EQUAL(4,c[0]); + CPPUNIT_ASSERT_EQUAL(9,c[1]); + CPPUNIT_ASSERT_EQUAL(11,c[2]); + CPPUNIT_ASSERT_EQUAL(6,c[3]); + CPPUNIT_ASSERT_EQUAL(0,cI[0]); + CPPUNIT_ASSERT_EQUAL(3,cI[1]); + CPPUNIT_ASSERT_EQUAL(3,cI[2]); + CPPUNIT_ASSERT_EQUAL(4,cI[3]); + mesh->decrRef(); +} + +void MEDCouplingBasicsTest::testFieldCopyTinyAttrFrom1() +{ + MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME); + f1->setName("f1"); + f1->setTimeTolerance(1.e-5); + f1->setDescription("f1Desc"); + f1->setTime(1.23,4,5); + MEDCouplingFieldDouble *f2=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME); + f2->setName("f2"); + f2->setDescription("f2Desc"); + f2->setTime(6.78,9,10); + f2->setTimeTolerance(4.556e-12); + // + int dt,it; + f1->copyTinyAttrFrom(f2); + CPPUNIT_ASSERT_DOUBLES_EQUAL(4.556e-12,f1->getTimeTolerance(),1e-24); + CPPUNIT_ASSERT_DOUBLES_EQUAL(6.78,f1->getTime(dt,it),1e-12); + CPPUNIT_ASSERT_EQUAL(9,dt); + CPPUNIT_ASSERT_EQUAL(10,it); + CPPUNIT_ASSERT(std::string(f1->getName())=="f1");//name unchanged + CPPUNIT_ASSERT(std::string(f1->getDescription())=="f1Desc");//description unchanged + f1->decrRef(); + f2->decrRef(); + // + f1=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME); + f1->setName("f1"); + f1->setTimeTolerance(1.e-5); + f1->setDescription("f1Desc"); + f2=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME); + f2->setName("f2"); + f2->setDescription("f2Desc"); + f2->setTimeTolerance(4.556e-12); + // + f1->copyTinyAttrFrom(f2); + CPPUNIT_ASSERT_DOUBLES_EQUAL(4.556e-12,f1->getTimeTolerance(),1e-24); + CPPUNIT_ASSERT(std::string(f1->getName())=="f1");//name unchanged + CPPUNIT_ASSERT(std::string(f1->getDescription())=="f1Desc");//description unchanged + f1->decrRef(); + f2->decrRef(); + // + f1=MEDCouplingFieldDouble::New(ON_CELLS,CONST_ON_TIME_INTERVAL); + f1->setName("f1"); + f1->setTimeTolerance(1.e-5); + f1->setDescription("f1Desc"); + f1->setTime(1.23,4,5); + f1->setEndTime(5.43,2,1); + f2=MEDCouplingFieldDouble::New(ON_CELLS,CONST_ON_TIME_INTERVAL); + f2->setName("f2"); + f2->setDescription("f2Desc"); + f2->setTimeTolerance(4.556e-12); + f2->setTime(6.78,9,10); + f2->setEndTime(10.98,7,6); + // + f1->copyTinyAttrFrom(f2); + CPPUNIT_ASSERT_DOUBLES_EQUAL(4.556e-12,f1->getTimeTolerance(),1e-24); + CPPUNIT_ASSERT(std::string(f1->getName())=="f1");//name unchanged + CPPUNIT_ASSERT(std::string(f1->getDescription())=="f1Desc");//description unchanged + CPPUNIT_ASSERT_DOUBLES_EQUAL(6.78,f1->getTime(dt,it),1e-12); + CPPUNIT_ASSERT_EQUAL(9,dt); + CPPUNIT_ASSERT_EQUAL(10,it); + CPPUNIT_ASSERT_DOUBLES_EQUAL(10.98,f1->getEndTime(dt,it),1e-12); + CPPUNIT_ASSERT_EQUAL(7,dt); + CPPUNIT_ASSERT_EQUAL(6,it); + f1->decrRef(); + f2->decrRef(); + // + f1=MEDCouplingFieldDouble::New(ON_CELLS,LINEAR_TIME); + f1->setName("f1"); + f1->setTimeTolerance(1.e-5); + f1->setDescription("f1Desc"); + f1->setTime(1.23,4,5); + f1->setEndTime(5.43,2,1); + f2=MEDCouplingFieldDouble::New(ON_CELLS,LINEAR_TIME); + f2->setName("f2"); + f2->setDescription("f2Desc"); + f2->setTimeTolerance(4.556e-12); + f2->setTime(6.78,9,10); + f2->setEndTime(10.98,7,6); + // + f1->copyTinyAttrFrom(f2); + CPPUNIT_ASSERT_DOUBLES_EQUAL(4.556e-12,f1->getTimeTolerance(),1e-24); + CPPUNIT_ASSERT(std::string(f1->getName())=="f1");//name unchanged + CPPUNIT_ASSERT(std::string(f1->getDescription())=="f1Desc");//description unchanged + CPPUNIT_ASSERT_DOUBLES_EQUAL(6.78,f1->getTime(dt,it),1e-12); + CPPUNIT_ASSERT_EQUAL(9,dt); + CPPUNIT_ASSERT_EQUAL(10,it); + CPPUNIT_ASSERT_DOUBLES_EQUAL(10.98,f1->getEndTime(dt,it),1e-12); + CPPUNIT_ASSERT_EQUAL(7,dt); + CPPUNIT_ASSERT_EQUAL(6,it); + f1->decrRef(); + f2->decrRef(); +} + +/*! + * 1D -> 2D extrusion with rotation + */ +void MEDCouplingBasicsTest::testExtrudedMesh5() +{ + const double coo1[4]={0.,1.,2.,3.5}; + DataArrayDouble *a=DataArrayDouble::New(); + a->alloc(4,1); + std::copy(coo1,coo1+4,a->getPointer()); + MEDCouplingCMesh *b=MEDCouplingCMesh::New(); + b->setCoordsAt(0,a); + MEDCouplingUMesh *c=b->buildUnstructured(); + CPPUNIT_ASSERT_EQUAL(1,c->getSpaceDimension()); + c->changeSpaceDimension(2); + // + DataArrayDouble *d=DataArrayDouble::New(); + d->alloc(13,1); + d->iota(); + MEDCouplingCMesh *e=MEDCouplingCMesh::New(); + e->setCoordsAt(0,d); + MEDCouplingUMesh *f=e->buildUnstructured(); + DataArrayDouble *g=f->getCoords()->applyFunc(2,"3.5*IVec+x/6*3.14159265359*JVec"); + DataArrayDouble *h=g->fromPolarToCart(); + f->setCoords(h); + MEDCouplingUMesh *i=c->buildExtrudedMesh(f,1); + CPPUNIT_ASSERT_EQUAL(52,i->getNumberOfNodes()); + bool tmp2; + int tmp3; + DataArrayInt *tmp=i->mergeNodes(1e-9,tmp2,tmp3); + CPPUNIT_ASSERT(tmp2); + CPPUNIT_ASSERT_EQUAL(37,tmp3); + tmp->decrRef(); + i->convertDegeneratedCells(); + i->checkCoherency(); + CPPUNIT_ASSERT_EQUAL(36,i->getNumberOfCells()); + CPPUNIT_ASSERT_EQUAL(37,i->getNumberOfNodes()); + CPPUNIT_ASSERT_EQUAL(12,i->getNumberOfCellsWithType(INTERP_KERNEL::NORM_TRI3)); + CPPUNIT_ASSERT_EQUAL(24,i->getNumberOfCellsWithType(INTERP_KERNEL::NORM_QUAD4)); + const double expected1[3]={0.25,0.75,2.0625}; + MEDCouplingFieldDouble *j=i->getMeasureField(true); + for(int i=0;i<12;i++) + for(int k=0;k<3;k++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[k],j->getIJ(0,i*3+k),1e-10); + const double expected2[72]={0.62200846792814113, 0.16666666666681595, 1.4513530918323276, 0.38888888888923495, 2.6293994326053212, 0.7045454545460802, 0.45534180126145435, 0.45534180126150181, 1.0624642029433926, 1.0624642029435025, 1.9248539780597826, 1.9248539780599816, 0.16666666666661334, 0.62200846792815856, 0.38888888888876294, 1.4513530918323678, 0.70454545454522521, 2.629399432605394, -0.16666666666674007, 0.62200846792812436, -0.38888888888906142, 1.4513530918322881, -0.70454545454576778, 2.6293994326052488, -0.45534180126154766, 0.45534180126140844, -1.0624642029436118, 1.0624642029432834, -1.9248539780601803, 1.9248539780595841, -0.62200846792817499, 0.1666666666665495, -1.451353091832408, 0.388888888888613, -2.6293994326054668, 0.70454545454495332, -0.62200846792810593, -0.16666666666680507, -1.451353091832247, -0.38888888888921297, -2.6293994326051746, -0.70454545454604123, -0.45534180126135926, -0.45534180126159562, -1.0624642029431723, -1.0624642029437235, -1.9248539780593836, -1.9248539780603811, -0.1666666666664828, -0.62200846792819242, -0.38888888888846079, -1.4513530918324489, -0.70454545454467987, -2.6293994326055397, 0.16666666666687083, -0.62200846792808862, 0.38888888888936374, -1.4513530918322073, 0.70454545454631357, -2.6293994326051022, 0.45534180126164348, -0.45534180126131207, 1.0624642029438327, -1.0624642029430627, 1.9248539780605791, -1.9248539780591853, 0.62200846792821063, -0.16666666666641802, 1.4513530918324888, -0.38888888888831086, 2.6293994326056125, -0.70454545454440853}; + DataArrayDouble *m=i->getBarycenterAndOwner(); + for(int i=0;i<72;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],m->getIJ(0,i),1e-10); + // + m->decrRef(); + j->decrRef(); + i->decrRef(); + h->decrRef(); + g->decrRef(); + f->decrRef(); + e->decrRef(); + d->decrRef(); + c->decrRef(); + b->decrRef(); + a->decrRef(); +} + +/*! + * 1D -> 2D extrusion without rotation + */ +void MEDCouplingBasicsTest::testExtrudedMesh6() +{ + const double coo1[4]={0.,1.,2.,3.5}; + DataArrayDouble *a=DataArrayDouble::New(); + a->alloc(4,1); + std::copy(coo1,coo1+4,a->getPointer()); + MEDCouplingCMesh *b=MEDCouplingCMesh::New(); + b->setCoordsAt(0,a); + MEDCouplingUMesh *c=b->buildUnstructured(); + CPPUNIT_ASSERT_EQUAL(1,c->getSpaceDimension()); + c->changeSpaceDimension(2); + // + DataArrayDouble *d=DataArrayDouble::New(); + d->alloc(5,1); + d->iota(); + MEDCouplingCMesh *e=MEDCouplingCMesh::New(); + e->setCoordsAt(0,d); + MEDCouplingUMesh *f=e->buildUnstructured(); + DataArrayDouble *d2=f->getCoords()->applyFunc("x*x/2"); + f->setCoords(d2); + f->changeSpaceDimension(2); + // + const double center[2]={0.,0.}; + f->rotate(center,0,M_PI/3); + MEDCouplingUMesh *g=c->buildExtrudedMesh(f,0); + g->checkCoherency(); + 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 }; + MEDCouplingFieldDouble *f1=g->getMeasureField(true); + for(int i=0;i<12;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f1->getIJ(0,i),1e-12); + + const double expected2[]={0.625, 0.21650635094610962, 1.625, 0.21650635094610959, 2.8750000000000004, 0.21650635094610965, 1.1250000000000002, 1.0825317547305482, 2.125, 1.0825317547305482, 3.3750000000000004, 1.0825317547305484, 2.125, 2.8145825622994254, 3.125, 2.8145825622994254, 4.375, 2.8145825622994254, 3.6250000000000009, 5.4126587736527414, 4.625, 5.4126587736527414, 5.875, 5.4126587736527414}; + DataArrayDouble *f2=g->getBarycenterAndOwner(); + for(int i=0;i<24;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],f2->getIJ(0,i),1e-12); + // + f1->decrRef(); + f2->decrRef(); + g->decrRef(); + f->decrRef(); + e->decrRef(); + d->decrRef(); + d2->decrRef(); + c->decrRef(); + b->decrRef(); + a->decrRef(); +} + +/*! + * 2D -> 3D extrusion with rotation + */ +void MEDCouplingBasicsTest::testExtrudedMesh7() +{ + const double coo1[4]={0.,1.,2.,3.5}; + DataArrayDouble *a=DataArrayDouble::New(); + a->alloc(4,1); + std::copy(coo1,coo1+4,a->getPointer()); + MEDCouplingCMesh *b=MEDCouplingCMesh::New(); + b->setCoordsAt(0,a); + MEDCouplingUMesh *c=b->buildUnstructured(); + CPPUNIT_ASSERT_EQUAL(1,c->getSpaceDimension()); + c->changeSpaceDimension(2); + // + DataArrayDouble *d=DataArrayDouble::New(); + d->alloc(13,1); + d->iota(); + MEDCouplingCMesh *e=MEDCouplingCMesh::New(); + e->setCoordsAt(0,d); + MEDCouplingUMesh *f=e->buildUnstructured(); + DataArrayDouble *g=f->getCoords()->applyFunc(2,"3.5*IVec+x/6*3.14159265359*JVec"); + DataArrayDouble *h=g->fromPolarToCart(); + f->setCoords(h); + MEDCouplingUMesh *i=c->buildExtrudedMesh(f,1); + CPPUNIT_ASSERT_EQUAL(52,i->getNumberOfNodes()); + bool tmp2; + int tmp3; + DataArrayInt *tmp=i->mergeNodes(1e-9,tmp2,tmp3); + CPPUNIT_ASSERT(tmp2); + CPPUNIT_ASSERT_EQUAL(37,tmp3); + tmp->decrRef(); + i->convertDegeneratedCells(); + const double vec1[3]={10.,0.,0.}; + i->translate(vec1); + DataArrayDouble *g2=h->applyFunc(3,"13.5/3.5*x*IVec+0*JVec+13.5/3.5*y*KVec"); + f->setCoords(g2); + i->changeSpaceDimension(3); + MEDCouplingUMesh *i3=i->buildExtrudedMesh(f,1); + MEDCouplingFieldDouble *f2=i3->getMeasureField(true); + tmp=i->mergeNodes(1e-9,tmp2,tmp3); + CPPUNIT_ASSERT(tmp2); + CPPUNIT_ASSERT_EQUAL(444,tmp3); + tmp->decrRef(); + const double expected1[36]={1.327751058489274, 4.2942574094314701, 13.024068164857139, 1.3069177251569044, 4.1484240761012954, 12.297505664866796, 1.270833333332571, 3.8958333333309674, 11.039062499993179, 1.2291666666659207, 3.6041666666644425, 9.585937499993932, 1.1930822748415895, 3.3515759238941376, 8.3274943351204556, 1.1722489415082769, 3.2057425905609289, 7.6009318351210622, 1.1722489415082862, 3.2057425905609884, 7.6009318351213713, 1.1930822748416161, 3.3515759238943001, 8.3274943351212727, 1.2291666666659564, 3.6041666666646734, 9.5859374999950777, 1.2708333333326081, 3.8958333333311868, 11.039062499994293, 1.3069177251569224, 4.1484240761014384, 12.297505664867627, 1.3277510584902354, 4.2942574094346071, 13.024068164866796}; + int kk=0; + for(int ii=0;ii<12;ii++) + for(int jj=0;jj<36;jj++,kk++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[jj],f2->getIJ(0,kk),1e-9); + // + f2->decrRef(); + i3->decrRef(); + g2->decrRef(); + i->decrRef(); + h->decrRef(); + g->decrRef(); + f->decrRef(); + e->decrRef(); + d->decrRef(); + c->decrRef(); + b->decrRef(); + a->decrRef(); +} + +void MEDCouplingBasicsTest::testSimplexize1() +{ + MEDCouplingUMesh *m=build3DSurfTargetMesh_1(); + std::vector v(1); + v[0]=3; + m->convertToPolyTypes(v); + DataArrayInt *da=m->simplexize(0); + CPPUNIT_ASSERT_EQUAL(7,da->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,da->getNumberOfComponents()); + const int expected2[7]={0,0,1,2,3,4,4}; + for(int i=0;i<7;i++) + CPPUNIT_ASSERT_EQUAL(expected2[i],da->getIJ(i,0)); + m->checkCoherency(); + CPPUNIT_ASSERT_EQUAL(7,m->getNumberOfCells()); + CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,m->getTypeOfCell(0)); + CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,m->getTypeOfCell(1)); + CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,m->getTypeOfCell(2)); + CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,m->getTypeOfCell(3)); + CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_POLYGON,m->getTypeOfCell(4)); + CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,m->getTypeOfCell(5)); + CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,m->getTypeOfCell(6)); + const double expected1[7]={0.125,0.125,0.125,0.125,0.25,0.125,0.125}; + MEDCouplingFieldDouble *f=m->getMeasureField(false); + for(int i=0;i<7;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i]*sqrt(2.),f->getIJ(i,0),1e-10); + std::set types=m->getAllTypes(); + CPPUNIT_ASSERT_EQUAL(2,(int)types.size()); + CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,*(types.begin())); + CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_POLYGON,*(++(types.begin()))); + f->decrRef(); + da->decrRef(); + m->decrRef(); + // + m=build3DSurfTargetMesh_1(); + v[0]=3; + m->convertToPolyTypes(v); + da=m->simplexize(1); + CPPUNIT_ASSERT_EQUAL(7,da->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,da->getNumberOfComponents()); + for(int i=0;i<7;i++) + CPPUNIT_ASSERT_EQUAL(expected2[i],da->getIJ(i,0)); + m->checkCoherency(); + types=m->getAllTypes(); + CPPUNIT_ASSERT_EQUAL(2,(int)types.size()); + CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,*(types.begin())); + CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_POLYGON,*(++(types.begin()))); + CPPUNIT_ASSERT_EQUAL(7,m->getNumberOfCells()); + CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,m->getTypeOfCell(0)); + CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,m->getTypeOfCell(1)); + CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,m->getTypeOfCell(2)); + CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,m->getTypeOfCell(3)); + CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_POLYGON,m->getTypeOfCell(4)); + CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,m->getTypeOfCell(5)); + CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,m->getTypeOfCell(6)); + f=m->getMeasureField(false); + for(int i=0;i<7;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i]*sqrt(2.),f->getIJ(i,0),1e-10); + f->decrRef(); + da->decrRef(); + m->decrRef(); +} + +void MEDCouplingBasicsTest::testSimplexize2() +{ + MEDCouplingUMesh *m=build3DSurfTargetMesh_1(); + std::vector v(1); + v[0]=3; + m->convertToPolyTypes(v); + MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME); + f1->setMesh(m); + DataArrayDouble *arr=DataArrayDouble::New(); + const double arr1[10]={10.,110.,20.,120.,30.,130.,40.,140.,50.,150.}; + arr->alloc(5,2); + std::copy(arr1,arr1+10,arr->getPointer()); + f1->setArray(arr); + arr->decrRef(); + // + f1->checkCoherency(); + CPPUNIT_ASSERT(f1->simplexize(0)); + f1->checkCoherency(); + const double expected1[14]={10.,110.,10.,110.,20.,120.,30.,130.,40.,140.,50.,150.,50.,150.}; + for(int i=0;i<14;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f1->getIJ(0,i),1e-10); + CPPUNIT_ASSERT(!f1->simplexize(0)); + for(int i=0;i<14;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f1->getIJ(0,i),1e-10); + // + f1->decrRef(); + m->decrRef(); +} + +void MEDCouplingBasicsTest::testDAMeld1() +{ + DataArrayDouble *da1=DataArrayDouble::New(); + da1->alloc(7,2); + DataArrayDouble *da2=DataArrayDouble::New(); + da2->alloc(7,1); + // + da1->fillWithValue(7.); + da2->iota(0.); + DataArrayDouble *da3=da2->applyFunc(3,"10*x*IVec+100*x*JVec+1000*x*KVec"); + // + da1->setInfoOnComponent(0,"c0da1"); + da1->setInfoOnComponent(1,"c1da1"); + da3->setInfoOnComponent(0,"c0da3"); + da3->setInfoOnComponent(1,"c1da3"); + da3->setInfoOnComponent(2,"c2da3"); + // + DataArrayDouble *da1C=da1->deepCpy(); + da1->meldWith(da3); + CPPUNIT_ASSERT_EQUAL(5,da1->getNumberOfComponents()); + CPPUNIT_ASSERT_EQUAL(7,da1->getNumberOfTuples()); + CPPUNIT_ASSERT(da1->getInfoOnComponent(0)=="c0da1"); + CPPUNIT_ASSERT(da1->getInfoOnComponent(1)=="c1da1"); + CPPUNIT_ASSERT(da1->getInfoOnComponent(2)=="c0da3"); + CPPUNIT_ASSERT(da1->getInfoOnComponent(3)=="c1da3"); + CPPUNIT_ASSERT(da1->getInfoOnComponent(4)=="c2da3"); + // + const double expected1[35]={7.,7.,0.,0.,0., 7.,7.,10.,100.,1000., 7.,7.,20.,200.,2000., 7.,7.,30.,300.,3000., 7.,7.,40.,400.,4000.,7.,7.,50.,500.,5000.,7.,7.,60.,600.,6000.}; + for(int i=0;i<35;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],da1->getIJ(0,i),1e-10); + // + DataArrayInt *dai1=da1C->convertToIntArr(); + DataArrayInt *dai3=da3->convertToIntArr(); + dai1->meldWith(dai3); + CPPUNIT_ASSERT_EQUAL(5,dai1->getNumberOfComponents()); + CPPUNIT_ASSERT_EQUAL(7,dai1->getNumberOfTuples()); + CPPUNIT_ASSERT(dai1->getInfoOnComponent(0)=="c0da1"); + CPPUNIT_ASSERT(dai1->getInfoOnComponent(1)=="c1da1"); + CPPUNIT_ASSERT(dai1->getInfoOnComponent(2)=="c0da3"); + CPPUNIT_ASSERT(dai1->getInfoOnComponent(3)=="c1da3"); + CPPUNIT_ASSERT(dai1->getInfoOnComponent(4)=="c2da3"); + for(int i=0;i<35;i++) + CPPUNIT_ASSERT_EQUAL((int)expected1[i],dai1->getIJ(0,i)); + // test of static method DataArrayDouble::meld + DataArrayDouble *da4=DataArrayDouble::Meld(da1C,da3); + CPPUNIT_ASSERT_EQUAL(5,da4->getNumberOfComponents()); + CPPUNIT_ASSERT_EQUAL(7,da4->getNumberOfTuples()); + CPPUNIT_ASSERT(da4->getInfoOnComponent(0)=="c0da1"); + CPPUNIT_ASSERT(da4->getInfoOnComponent(1)=="c1da1"); + CPPUNIT_ASSERT(da4->getInfoOnComponent(2)=="c0da3"); + CPPUNIT_ASSERT(da4->getInfoOnComponent(3)=="c1da3"); + CPPUNIT_ASSERT(da4->getInfoOnComponent(4)=="c2da3"); + for(int i=0;i<35;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],da4->getIJ(0,i),1e-10); + // test of static method DataArrayInt::meld + dai1->decrRef(); + dai1=da1C->convertToIntArr(); + DataArrayInt *dai4=DataArrayInt::Meld(dai1,dai3); + CPPUNIT_ASSERT_EQUAL(5,dai4->getNumberOfComponents()); + CPPUNIT_ASSERT_EQUAL(7,dai4->getNumberOfTuples()); + CPPUNIT_ASSERT(dai4->getInfoOnComponent(0)=="c0da1"); + CPPUNIT_ASSERT(dai4->getInfoOnComponent(1)=="c1da1"); + CPPUNIT_ASSERT(dai4->getInfoOnComponent(2)=="c0da3"); + CPPUNIT_ASSERT(dai4->getInfoOnComponent(3)=="c1da3"); + CPPUNIT_ASSERT(dai4->getInfoOnComponent(4)=="c2da3"); + for(int i=0;i<35;i++) + CPPUNIT_ASSERT_EQUAL((int)expected1[i],dai4->getIJ(0,i)); + // + dai4->decrRef(); + da4->decrRef(); + dai3->decrRef(); + dai1->decrRef(); + da1C->decrRef(); + da1->decrRef(); + da2->decrRef(); + da3->decrRef(); +} + +void MEDCouplingBasicsTest::testFieldMeld1() +{ + MEDCouplingUMesh *m=build3DSurfTargetMesh_1(); + MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME); + f1->setMesh(m); + DataArrayDouble *da1=DataArrayDouble::New(); + const double arr1[5]={12.,23.,34.,45.,56.}; + da1->alloc(5,1); + std::copy(arr1,arr1+5,da1->getPointer()); + da1->setInfoOnComponent(0,"aaa"); + f1->setArray(da1); + f1->setTime(3.4,2,1); + f1->checkCoherency(); + // + MEDCouplingFieldDouble *f2=f1->deepCpy(); + f2->setMesh(f1->getMesh()); + f2->checkCoherency(); + f2->changeNbOfComponents(2,5.); + (*f2)=5.; + f2->getArray()->setInfoOnComponent(0,"bbb"); + f2->getArray()->setInfoOnComponent(1,"ccc"); + f2->checkCoherency(); + // + MEDCouplingFieldDouble *f3=MEDCouplingFieldDouble::MeldFields(f2,f1); + f3->checkCoherency(); + CPPUNIT_ASSERT_EQUAL(5,f3->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(3,f3->getNumberOfComponents()); + CPPUNIT_ASSERT(f3->getArray()->getInfoOnComponent(0)=="bbb"); + CPPUNIT_ASSERT(f3->getArray()->getInfoOnComponent(1)=="ccc"); + CPPUNIT_ASSERT(f3->getArray()->getInfoOnComponent(2)=="aaa"); + const double expected1[15]={5.,5.,12.,5.,5.,23.,5.,5.,34.,5.,5.,45.,5.,5.,56.}; + 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); + CPPUNIT_ASSERT_DOUBLES_EQUAL(3.4,time,1e-14); + CPPUNIT_ASSERT_EQUAL(2,dt); + CPPUNIT_ASSERT_EQUAL(1,it); + // + MEDCouplingFieldDouble *f4=f2->buildNewTimeReprFromThis(NO_TIME,false); + MEDCouplingFieldDouble *f5=f1->buildNewTimeReprFromThis(NO_TIME,false); + MEDCouplingFieldDouble *f6=MEDCouplingFieldDouble::MeldFields(f4,f5); + f6->checkCoherency(); + CPPUNIT_ASSERT_EQUAL(5,f6->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(3,f6->getNumberOfComponents()); + CPPUNIT_ASSERT(f6->getArray()->getInfoOnComponent(0)=="bbb"); + CPPUNIT_ASSERT(f6->getArray()->getInfoOnComponent(1)=="ccc"); + CPPUNIT_ASSERT(f6->getArray()->getInfoOnComponent(2)=="aaa"); + for(int i=0;i<15;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f6->getIJ(0,i),1e-12); + // + f6->decrRef(); + f4->decrRef(); + f5->decrRef(); + f3->decrRef(); + da1->decrRef(); + f2->decrRef(); + f1->decrRef(); + m->decrRef(); +} + +void MEDCouplingBasicsTest::testMergeNodes2() +{ + MEDCouplingUMesh *m1=build2DTargetMesh_1(); + MEDCouplingUMesh *m2=build2DTargetMesh_1(); + const double vec[2]={0.002,0.}; + m2->translate(vec); + // + std::vector tmp(2); + tmp[0]=m1; + tmp[1]=m2; + MEDCouplingUMesh *m3=MEDCouplingUMesh::MergeUMeshes(tmp); + bool b; + int newNbOfNodes; + DataArrayInt *da=m3->mergeNodes2(0.01,b,newNbOfNodes); + CPPUNIT_ASSERT_EQUAL(9,m3->getNumberOfNodes()); + const double expected1[18]={-0.299,-0.3, 0.201,-0.3, 0.701,-0.3, -0.299,0.2, 0.201,0.2, 0.701,0.2, -0.299,0.7, 0.201,0.7, 0.701,0.7}; + for(int i=0;i<18;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],m3->getCoords()->getIJ(0,i),1e-13); + // + da->decrRef(); + m3->decrRef(); + m1->decrRef(); + m2->decrRef(); +} + +void MEDCouplingBasicsTest::testMergeField2() +{ + MEDCouplingUMesh *m=build2DTargetMesh_1(); + MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME); + f1->setMesh(m); + DataArrayDouble *arr=DataArrayDouble::New(); + arr->alloc(5,2); + arr->fillWithValue(2.); + f1->setArray(arr); + arr->decrRef(); + MEDCouplingFieldDouble *f2=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME); + f2->setMesh(m); + arr=DataArrayDouble::New(); + arr->alloc(5,2); + arr->fillWithValue(5.); + f2->setArray(arr); + arr->decrRef(); + MEDCouplingFieldDouble *f3=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME); + f3->setMesh(m); + arr=DataArrayDouble::New(); + arr->alloc(5,2); + arr->fillWithValue(7.); + f3->setArray(arr); + arr->decrRef(); + // + std::vector tmp(3); + tmp[0]=f1; tmp[1]=f2; tmp[2]=f3; + MEDCouplingFieldDouble *f4=MEDCouplingFieldDouble::MergeFields(tmp); + CPPUNIT_ASSERT_EQUAL(15,f4->getMesh()->getNumberOfCells()); + const double expected1[30]={2.,2.,2.,2.,2.,2.,2.,2.,2.,2., 5.,5.,5.,5.,5.,5.,5.,5.,5.,5., 7.,7.,7.,7.,7.,7.,7.,7.,7.,7.}; + for(int i=0;i<30;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f4->getIJ(0,i),1.e-13); + // + f4->decrRef(); + f1->decrRef(); + f2->decrRef(); + f3->decrRef(); + m->decrRef(); +} + +void MEDCouplingBasicsTest::testDAIBuildComplement1() +{ + DataArrayInt *a=DataArrayInt::New(); + const int tab[4]={3,1,7,8}; + a->alloc(4,1); + std::copy(tab,tab+4,a->getPointer()); + DataArrayInt *b=a->buildComplement(12); + CPPUNIT_ASSERT_EQUAL(8,b->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,b->getNumberOfComponents()); + const int expected1[8]={0,2,4,5,6,9,10,11}; + for(int i=0;i<8;i++) + CPPUNIT_ASSERT_EQUAL(expected1[i],b->getIJ(0,i)); + b->decrRef(); + a->decrRef(); +} + +void MEDCouplingBasicsTest::testDAIBuildUnion1() +{ + DataArrayInt *a=DataArrayInt::New(); + const int tab1[4]={3,1,7,8}; + a->alloc(4,1); + std::copy(tab1,tab1+4,a->getPointer()); + DataArrayInt *c=DataArrayInt::New(); + const int tab2[5]={5,3,0,18,8}; + c->alloc(5,1); + std::copy(tab2,tab2+5,c->getPointer()); + DataArrayInt *b=a->buildUnion(c); + CPPUNIT_ASSERT_EQUAL(7,b->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,b->getNumberOfComponents()); + const int expected1[7]={0,1,3,5,7,8,18}; + for(int i=0;i<7;i++) + CPPUNIT_ASSERT_EQUAL(expected1[i],b->getIJ(0,i)); + c->decrRef(); + b->decrRef(); + a->decrRef(); +} + +void MEDCouplingBasicsTest::testDAIBuildIntersection1() +{ + DataArrayInt *a=DataArrayInt::New(); + const int tab1[4]={3,1,7,8}; + a->alloc(4,1); + std::copy(tab1,tab1+4,a->getPointer()); + DataArrayInt *c=DataArrayInt::New(); + const int tab2[5]={5,3,0,18,8}; + c->alloc(5,1); + std::copy(tab2,tab2+5,c->getPointer()); + DataArrayInt *b=a->buildIntersection(c); + CPPUNIT_ASSERT_EQUAL(2,b->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,b->getNumberOfComponents()); + const int expected1[2]={3,8}; + for(int i=0;i<2;i++) + CPPUNIT_ASSERT_EQUAL(expected1[i],b->getIJ(0,i)); + c->decrRef(); + b->decrRef(); + a->decrRef(); +} + +void MEDCouplingBasicsTest::testDAIDeltaShiftIndex1() +{ + DataArrayInt *a=DataArrayInt::New(); + const int tab[7]={1,3,6,7,7,9,15}; + a->alloc(7,1); + std::copy(tab,tab+7,a->getPointer()); + DataArrayInt *b=a->deltaShiftIndex(); + CPPUNIT_ASSERT_EQUAL(6,b->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,b->getNumberOfComponents()); + const int expected1[6]={2,3,1,0,2,6}; + for(int i=0;i<6;i++) + CPPUNIT_ASSERT_EQUAL(expected1[i],b->getIJ(0,i)); + b->decrRef(); + a->decrRef(); +} + +void MEDCouplingBasicsTest::testDaDoubleSelectByTupleIdSafe1() +{ + DataArrayDouble *a=DataArrayDouble::New(); + a->alloc(7,2); + a->setInfoOnComponent(0,"toto"); + a->setInfoOnComponent(1,"tata"); + const double arr1[14]={1.1,11.1,2.1,12.1,3.1,13.1,4.1,14.1,5.1,15.1,6.1,16.1,7.1,17.1}; + std::copy(arr1,arr1+14,a->getPointer()); + // + const int arr2[7]={4,2,0,6,5}; + DataArrayDouble *b=a->selectByTupleIdSafe(arr2,arr2+5); + CPPUNIT_ASSERT_EQUAL(5,b->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(2,b->getNumberOfComponents()); + CPPUNIT_ASSERT(std::string(b->getInfoOnComponent(0))=="toto"); + CPPUNIT_ASSERT(std::string(b->getInfoOnComponent(1))=="tata"); + const double expected1[10]={5.1,15.1,3.1,13.1,1.1,11.1,7.1,17.1,6.1,16.1}; + for(int i=0;i<10;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],b->getIJ(0,i),1e-14); + const int arr4[5]={4,-1,0,6,5}; + CPPUNIT_ASSERT_THROW(a->selectByTupleIdSafe(arr4,arr4+5),INTERP_KERNEL::Exception); + const int arr5[5]={4,2,0,6,7}; + CPPUNIT_ASSERT_THROW(a->selectByTupleIdSafe(arr5,arr5+5),INTERP_KERNEL::Exception); + b->decrRef(); + a->decrRef(); + // + DataArrayInt *c=DataArrayInt::New(); + c->alloc(7,2); + c->setInfoOnComponent(0,"toto"); + c->setInfoOnComponent(1,"tata"); + const int arr3[14]={1,11,2,12,3,13,4,14,5,15,6,16,7,17}; + std::copy(arr3,arr3+14,c->getPointer()); + DataArrayInt *d=c->selectByTupleIdSafe(arr2,arr2+5); + CPPUNIT_ASSERT_EQUAL(5,d->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(2,d->getNumberOfComponents()); + CPPUNIT_ASSERT(std::string(d->getInfoOnComponent(0))=="toto"); + CPPUNIT_ASSERT(std::string(d->getInfoOnComponent(1))=="tata"); + const int expected2[10]={5,15,3,13,1,11,7,17,6,16}; + for(int i=0;i<10;i++) + CPPUNIT_ASSERT_EQUAL(expected2[i],d->getIJ(0,i)); + CPPUNIT_ASSERT_THROW(c->selectByTupleIdSafe(arr4,arr4+5),INTERP_KERNEL::Exception); + CPPUNIT_ASSERT_THROW(c->selectByTupleIdSafe(arr5,arr5+5),INTERP_KERNEL::Exception); + c->decrRef(); + d->decrRef(); +} + +void MEDCouplingBasicsTest::testAreCellsIncludedIn1() +{ + MEDCouplingUMesh *m=build3DSurfTargetMesh_1(); + const int pt[2]={1,3}; + MEDCouplingUMesh *m2=(MEDCouplingUMesh *)m->buildPartOfMySelf(pt,pt+2,true); + DataArrayInt *tmp; + CPPUNIT_ASSERT(m->areCellsIncludedIn(m2,0,tmp)); + CPPUNIT_ASSERT_EQUAL(2,tmp->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,tmp->getNumberOfComponents()); + CPPUNIT_ASSERT_EQUAL(pt[0],tmp->getIJ(0,0)); + CPPUNIT_ASSERT_EQUAL(pt[1],tmp->getIJ(0,1)); + tmp->decrRef(); + CPPUNIT_ASSERT(!m2->areCellsIncludedIn(m,0,tmp)); + tmp->decrRef(); + m2->decrRef(); + m->decrRef(); +} + +void MEDCouplingBasicsTest::testDAIBuildSubstraction1() +{ + DataArrayInt *a=DataArrayInt::New(); + const int aa[]={2,3,6,8,9}; + a->alloc(5,1); + std::copy(aa,aa+5,a->getPointer()); + DataArrayInt *b=DataArrayInt::New(); + const int bb[]={1,3,5,9,11}; + b->alloc(5,1); + std::copy(bb,bb+5,b->getPointer()); + // + DataArrayInt *c=a->buildSubstraction(b); + CPPUNIT_ASSERT_EQUAL(3,c->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,c->getNumberOfComponents()); + const int expected1[3]={2,6,8}; + CPPUNIT_ASSERT(std::equal(expected1,expected1+3,c->getConstPointer())); + // + c->decrRef(); + b->decrRef(); + a->decrRef(); +} + +void MEDCouplingBasicsTest::testBuildOrthogonalField2() +{ + MEDCouplingUMesh *m=build2DTargetMesh_1(); + DataArrayInt *d1=DataArrayInt::New(); + DataArrayInt *d2=DataArrayInt::New(); + DataArrayInt *d3=DataArrayInt::New(); + DataArrayInt *d4=DataArrayInt::New(); + MEDCouplingUMesh *m1=m->buildDescendingConnectivity(d1,d2,d3,d4); + // + MEDCouplingFieldDouble *f1=m1->buildOrthogonalField(); + DataArrayDouble *da1=f1->getArray(); + CPPUNIT_ASSERT_EQUAL(2,da1->getNumberOfComponents()); + CPPUNIT_ASSERT_EQUAL(13,da1->getNumberOfTuples()); + // + const double expected1[26]={-1.,0.,0.,1.,1.,0.,0.,-1.,0.707106781186548,0.707106781186548,0.,-1.,0.,1.,1.,0.,0.,1.,1.,0.,-1.,0.,0.,1.,1.,0.}; + for(int i=0;i<26;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],da1->getIJ(0,i),1e-14); + // + f1->decrRef(); + m1->decrRef(); + d1->decrRef(); + d2->decrRef(); + d3->decrRef(); + d4->decrRef(); + m->decrRef(); +} + +void MEDCouplingBasicsTest::testUMInsertNextCell1() +{ + double targetCoords[18]={-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 }; + int targetConn[18]={0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4}; + MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New(); + targetMesh->allocateCells(5); + CPPUNIT_ASSERT_THROW(targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn),INTERP_KERNEL::Exception); + targetMesh->setMeshDimension(2); + targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn); + CPPUNIT_ASSERT_THROW(targetMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,targetConn),INTERP_KERNEL::Exception); + CPPUNIT_ASSERT_THROW(targetMesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,targetConn),INTERP_KERNEL::Exception); + CPPUNIT_ASSERT_THROW(targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn),INTERP_KERNEL::Exception); + targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+4); + targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+7); + targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+10); + targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+14); + targetMesh->finishInsertingCells(); + DataArrayDouble *myCoords=DataArrayDouble::New(); + myCoords->alloc(9,2); + std::copy(targetCoords,targetCoords+18,myCoords->getPointer()); + targetMesh->setCoords(myCoords); + myCoords->decrRef(); + targetMesh->checkCoherency(); + targetMesh->decrRef(); +} + +void MEDCouplingBasicsTest::testFieldOperatorDivDiffComp1() +{ + MEDCouplingUMesh *m=build2DTargetMesh_1(); + DataArrayInt *d1=DataArrayInt::New(); + DataArrayInt *d2=DataArrayInt::New(); + DataArrayInt *d3=DataArrayInt::New(); + DataArrayInt *d4=DataArrayInt::New(); + MEDCouplingUMesh *m1=m->buildDescendingConnectivity(d1,d2,d3,d4); + // + MEDCouplingFieldDouble *f1=m1->buildOrthogonalField(); + const double arr1[13]={2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.}; + DataArrayDouble *arr=DataArrayDouble::New(); + arr->alloc(13,1); + std::copy(arr1,arr1+13,arr->getPointer()); + MEDCouplingFieldDouble *f2=MEDCouplingFieldDouble::New(ON_CELLS); + f2->setArray(arr); + f2->setMesh(m1); + f2->checkCoherency(); + // + MEDCouplingFieldDouble *f3=(*f1)/(*f2); + CPPUNIT_ASSERT_THROW((*f2)/(*f1),INTERP_KERNEL::Exception); + f3->checkCoherency(); + (*f1)/=(*f2); + CPPUNIT_ASSERT(f1->isEqual(f3,1e-10,1e-10)); + CPPUNIT_ASSERT_THROW((*f2)/=(*f1),INTERP_KERNEL::Exception); + const double expected1[26]={-0.5, 0.0, 0.0, 0.33333333333333331, 0.25, 0.0, 0.0, -0.20000000000000001, 0.117851130197758, 0.117851130197758, 0.0, -0.14285714285714285, 0.0, 0.125, 0.1111111111111111, 0.0, 0.0, 0.10000000000000001, 0.090909090909090912, 0.0, -0.083333333333333329, 0.0, 0.0, 0.076923076923076927, 0.071428571428571425, 0.0}; + for(int i=0;i<26;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f3->getIJ(0,i),1e-10); + // + f3->decrRef(); + f2->decrRef(); + arr->decrRef(); + f1->decrRef(); + m1->decrRef(); + d1->decrRef(); + d2->decrRef(); + d3->decrRef(); + d4->decrRef(); + m->decrRef(); +} + +void MEDCouplingBasicsTest::testDARearrange1() +{ + DataArrayInt *da1=DataArrayInt::New(); + da1->alloc(12,1); + da1->iota(0); + const int *ptr=da1->getConstPointer(); + // + CPPUNIT_ASSERT_EQUAL(12,da1->getNbOfElems()); + CPPUNIT_ASSERT_EQUAL(1,da1->getNumberOfComponents()); + CPPUNIT_ASSERT_EQUAL(12,da1->getNumberOfTuples()); + da1->rearrange(4); + CPPUNIT_ASSERT(ptr==da1->getConstPointer()); + CPPUNIT_ASSERT_EQUAL(12,da1->getNbOfElems()); + CPPUNIT_ASSERT_EQUAL(4,da1->getNumberOfComponents()); + CPPUNIT_ASSERT_EQUAL(3,da1->getNumberOfTuples()); + for(int i=0;i<12;i++) + CPPUNIT_ASSERT_EQUAL(i,da1->getIJ(0,i)); + // + da1->rearrange(6); + CPPUNIT_ASSERT(ptr==da1->getConstPointer()); + CPPUNIT_ASSERT_EQUAL(12,da1->getNbOfElems()); + CPPUNIT_ASSERT_EQUAL(6,da1->getNumberOfComponents()); + CPPUNIT_ASSERT_EQUAL(2,da1->getNumberOfTuples()); + for(int i=0;i<12;i++) + CPPUNIT_ASSERT_EQUAL(i,da1->getIJ(0,i)); + // + CPPUNIT_ASSERT_THROW(da1->rearrange(7),INTERP_KERNEL::Exception); + // + da1->rearrange(12); + CPPUNIT_ASSERT(ptr==da1->getConstPointer()); + CPPUNIT_ASSERT_EQUAL(12,da1->getNbOfElems()); + CPPUNIT_ASSERT_EQUAL(12,da1->getNumberOfComponents()); + CPPUNIT_ASSERT_EQUAL(1,da1->getNumberOfTuples()); + for(int i=0;i<12;i++) + CPPUNIT_ASSERT_EQUAL(i,da1->getIJ(0,i)); + // + da1->rearrange(3); + CPPUNIT_ASSERT(ptr==da1->getConstPointer()); + CPPUNIT_ASSERT_EQUAL(12,da1->getNbOfElems()); + CPPUNIT_ASSERT_EQUAL(3,da1->getNumberOfComponents()); + CPPUNIT_ASSERT_EQUAL(4,da1->getNumberOfTuples()); + for(int i=0;i<12;i++) + CPPUNIT_ASSERT_EQUAL(i,da1->getIJ(0,i)); + //double + DataArrayDouble *da2=da1->convertToDblArr(); + da1->decrRef(); + const double *ptr2=da2->getConstPointer(); + // + CPPUNIT_ASSERT_EQUAL(12,da2->getNbOfElems()); + CPPUNIT_ASSERT_EQUAL(3,da2->getNumberOfComponents()); + CPPUNIT_ASSERT_EQUAL(4,da2->getNumberOfTuples()); + da2->rearrange(4); + CPPUNIT_ASSERT(ptr2==da2->getConstPointer()); + CPPUNIT_ASSERT_EQUAL(12,da2->getNbOfElems()); + CPPUNIT_ASSERT_EQUAL(4,da2->getNumberOfComponents()); + CPPUNIT_ASSERT_EQUAL(3,da2->getNumberOfTuples()); + for(int i=0;i<12;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL((double)i,da2->getIJ(0,i),1e-14); + // + da2->rearrange(6); + CPPUNIT_ASSERT(ptr2==da2->getConstPointer()); + CPPUNIT_ASSERT_EQUAL(12,da2->getNbOfElems()); + CPPUNIT_ASSERT_EQUAL(6,da2->getNumberOfComponents()); + CPPUNIT_ASSERT_EQUAL(2,da2->getNumberOfTuples()); + for(int i=0;i<12;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL((double)i,da2->getIJ(0,i),1e-14); + // + CPPUNIT_ASSERT_THROW(da2->rearrange(7),INTERP_KERNEL::Exception); + // + da2->rearrange(1); + CPPUNIT_ASSERT(ptr2==da2->getConstPointer()); + CPPUNIT_ASSERT_EQUAL(12,da2->getNbOfElems()); + CPPUNIT_ASSERT_EQUAL(1,da2->getNumberOfComponents()); + CPPUNIT_ASSERT_EQUAL(12,da2->getNumberOfTuples()); + for(int i=0;i<12;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL((double)i,da2->getIJ(0,i),1e-14); + // + da2->rearrange(3); + CPPUNIT_ASSERT(ptr2==da2->getConstPointer()); + CPPUNIT_ASSERT_EQUAL(12,da2->getNbOfElems()); + CPPUNIT_ASSERT_EQUAL(3,da2->getNumberOfComponents()); + CPPUNIT_ASSERT_EQUAL(4,da2->getNumberOfTuples()); + for(int i=0;i<12;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL((double)i,da2->getIJ(0,i),1e-14); + da2->decrRef(); +} + +void MEDCouplingBasicsTest::testGetDifferentValues1() +{ + DataArrayInt *da1=DataArrayInt::New(); + const int arr[12]={1,2,3,2,2,3,5,1,5,5,2,2}; + da1->alloc(4,3); + std::copy(arr,arr+12,da1->getPointer()); + std::set s=da1->getDifferentValues(); + const int expected1[4]={1,2,3,5}; + CPPUNIT_ASSERT_EQUAL(4,(int)s.size()); + CPPUNIT_ASSERT(std::equal(expected1,expected1+4,s.begin())); + da1->decrRef(); +} + +void MEDCouplingBasicsTest::testDAIBuildPermutationArr1() +{ + DataArrayInt *a=DataArrayInt::New(); + const int vala[5]={4,5,6,7,8}; + a->alloc(5,1); + std::copy(vala,vala+5,a->getPointer()); + DataArrayInt *b=DataArrayInt::New(); + const int valb[5]={5,4,8,6,7}; + b->alloc(5,1); + std::copy(valb,valb+5,b->getPointer()); + DataArrayInt *c=a->buildPermutationArr(*b); + const int expect1[5]={1,0,4,2,3}; + CPPUNIT_ASSERT_EQUAL(5,c->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,c->getNumberOfComponents()); + CPPUNIT_ASSERT(std::equal(expect1,expect1+5,c->getConstPointer())); + CPPUNIT_ASSERT(a->isEqualWithoutConsideringStrAndOrder(*b)); + b->setIJ(0,0,9); + CPPUNIT_ASSERT(!a->isEqualWithoutConsideringStrAndOrder(*b)); + CPPUNIT_ASSERT_THROW(a->buildPermutationArr(*b),INTERP_KERNEL::Exception); + a->setIJ(3,0,4); + b->setIJ(0,0,5); + b->setIJ(4,0,4);//;a==[4,5,6,4,8] and b==[5,4,8,6,4] + CPPUNIT_ASSERT(a->isEqualWithoutConsideringStrAndOrder(*b)); + c->decrRef(); + c=a->buildPermutationArr(*b); + const int expect2[5]={1,3,4,2,3}; + CPPUNIT_ASSERT(std::equal(expect2,expect2+5,c->getConstPointer())); + DataArrayDouble *d=b->convertToDblArr(); + b->sort(); + const int expect3[5]={4,4,5,6,8}; + CPPUNIT_ASSERT(std::equal(expect3,expect3+5,b->getConstPointer())); + d->sort(); + CPPUNIT_ASSERT_EQUAL(5,d->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,d->getNumberOfComponents()); + for(int i=0;i<5;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(double(expect3[i]),d->getIJ(i,0),1e-14); + // + d->decrRef(); + c->decrRef(); + a->decrRef(); + b->decrRef(); +} + +void MEDCouplingBasicsTest::testAreCellsIncludedIn2() +{ + const char myName[]="Vitoo"; + MEDCouplingUMesh *m=build3DSurfTargetMesh_1(); + MEDCouplingUMesh *m2=(MEDCouplingUMesh *)m->buildPartOfMySelf(0,0,true); + CPPUNIT_ASSERT_EQUAL(0,m2->getNumberOfCells()); + CPPUNIT_ASSERT_EQUAL(3,m2->getSpaceDimension()); + CPPUNIT_ASSERT_EQUAL(2,m2->getMeshDimension()); + m2->setName(myName); + DataArrayInt *tmp; + CPPUNIT_ASSERT(m->areCellsIncludedIn(m2,0,tmp)); + CPPUNIT_ASSERT(std::string(myName)==tmp->getName()); + CPPUNIT_ASSERT_EQUAL(0,tmp->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,tmp->getNumberOfComponents()); + m->decrRef(); + m2->decrRef(); + tmp->decrRef(); +} + +void MEDCouplingBasicsTest::testUMeshGetPartBarycenterAndOwner1() +{ + MEDCouplingUMesh *m1=build2DTargetMesh_1(); + const int part[3]={1,0,4}; + DataArrayDouble *b=m1->getPartBarycenterAndOwner(part,part+3); + CPPUNIT_ASSERT_EQUAL(2,b->getNumberOfComponents()); + CPPUNIT_ASSERT_EQUAL(3,b->getNumberOfTuples()); + const double expected1[6]={0.36666666666666665,-0.13333333333333333,-0.05,-0.05,0.45,0.45}; + for(int i=0;i<6;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],b->getIJ(0,i),1e-14); + b->decrRef(); + m1->decrRef(); +} + +void MEDCouplingBasicsTest::testUMeshGetPartMeasureField1() +{ + MEDCouplingUMesh *m1=build2DTargetMesh_1(); + const int part[3]={1,0,4}; + DataArrayDouble *b=m1->getPartMeasureField(true,part,part+3); + CPPUNIT_ASSERT_EQUAL(1,b->getNumberOfComponents()); + CPPUNIT_ASSERT_EQUAL(3,b->getNumberOfTuples()); + const double expected1[3]={0.125,0.25,0.25}; + for(int i=0;i<3;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],b->getIJ(0,i),1e-14); + b->decrRef(); + m1->decrRef(); +} + +void MEDCouplingBasicsTest::testUMeshBuildPartOrthogonalField1() +{ + MEDCouplingUMesh *m1=build2DTargetMesh_1(); + m1->changeSpaceDimension(3); + const int part[3]={1,0,4}; + MEDCouplingFieldDouble *b=m1->buildPartOrthogonalField(part,part+3); + CPPUNIT_ASSERT_EQUAL(3,b->getArray()->getNumberOfComponents()); + CPPUNIT_ASSERT_EQUAL(3,b->getArray()->getNumberOfTuples()); + const double expected1[9]={0.,0.,-1.,0.,0.,-1.,0.,0.,-1.}; + for(int i=0;i<9;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],b->getArray()->getIJ(0,i),1e-14); + b->decrRef(); + m1->decrRef(); +} + +void MEDCouplingBasicsTest::testUMeshGetTypesOfPart1() +{ + MEDCouplingUMesh *m1=build2DTargetMesh_1(); + const int part1[]={0,3,4}; + std::set s; + s=m1->getTypesOfPart(part1,part1+3); + CPPUNIT_ASSERT(s.size()==1); + CPPUNIT_ASSERT(*s.begin()==INTERP_KERNEL::NORM_QUAD4); + const int part2[]={2,2,2,1}; + s=m1->getTypesOfPart(part2,part2+4); + CPPUNIT_ASSERT(s.size()==1); + CPPUNIT_ASSERT(*s.begin()==INTERP_KERNEL::NORM_TRI3); + const int part3[]={3,2,1}; + s=m1->getTypesOfPart(part3,part3+3); + CPPUNIT_ASSERT(s.size()==2); + CPPUNIT_ASSERT(*s.begin()==INTERP_KERNEL::NORM_TRI3); + CPPUNIT_ASSERT(*(++s.begin())==INTERP_KERNEL::NORM_QUAD4); + m1->decrRef(); +} + +void MEDCouplingBasicsTest::testUMeshKeepCellIdsByType1() +{ + MEDCouplingUMesh *m1=build2DTargetMesh_1(); + const int part1[3]={0,3,4}; + DataArrayInt *a=m1->keepCellIdsByType(INTERP_KERNEL::NORM_TRI3,part1,part1+3); + CPPUNIT_ASSERT_EQUAL(1,a->getNumberOfComponents()); + CPPUNIT_ASSERT_EQUAL(0,a->getNumberOfTuples()); + a->decrRef(); + // + const int part2[5]={3,2,0,2,4}; + a=m1->keepCellIdsByType(INTERP_KERNEL::NORM_TRI3,part2,part2+5); + CPPUNIT_ASSERT_EQUAL(1,a->getNumberOfComponents()); + CPPUNIT_ASSERT_EQUAL(2,a->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(2,a->getIJ(0,0)); + CPPUNIT_ASSERT_EQUAL(2,a->getIJ(1,0)); + a->decrRef(); + // + a=m1->keepCellIdsByType(INTERP_KERNEL::NORM_QUAD4,part2,part2+5); + CPPUNIT_ASSERT_EQUAL(1,a->getNumberOfComponents()); + CPPUNIT_ASSERT_EQUAL(3,a->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(3,a->getIJ(0,0)); + CPPUNIT_ASSERT_EQUAL(0,a->getIJ(1,0)); + CPPUNIT_ASSERT_EQUAL(4,a->getIJ(2,0)); + // + a->decrRef(); + m1->decrRef(); +} + +void MEDCouplingBasicsTest::testDAIAggregateMulti1() +{ + DataArrayInt *a=DataArrayInt::New(); + a->setName("aa"); + a->alloc(4,1); + a->iota(0); + a->rearrange(2); + DataArrayInt *b=DataArrayInt::New(); + b->setName("bb"); + b->alloc(6,1); + b->iota(0); + b->rearrange(2); + // + std::vector v(2); + v[0]=a; v[1]=b; + DataArrayInt *c=DataArrayInt::Aggregate(v); + CPPUNIT_ASSERT_EQUAL(5,c->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(2,c->getNumberOfComponents()); + CPPUNIT_ASSERT(c->getName()=="aa"); + const int expect1[10]={0,1,2,3,0,1,2,3,4,5}; + for(int i=0;i<10;i++) + CPPUNIT_ASSERT_EQUAL(expect1[i],c->getIJ(0,i)); + // + c->decrRef(); + a->decrRef(); + b->decrRef(); +} + +void MEDCouplingBasicsTest::testMergeUMeshes2() +{ + MEDCouplingUMesh *m1=build3DSurfTargetMesh_1(); + MEDCouplingUMesh *m2=build3DSurfTargetMesh_1(); + MEDCouplingUMesh *m3=build3DSurfTargetMesh_1(); + // + const int vec1[3]={0,2,3}; + MEDCouplingUMesh *m2_2=(MEDCouplingUMesh *)m2->buildPartOfMySelf(vec1,vec1+3,false); + const int vec2[2]={1,1}; + MEDCouplingUMesh *m3_2=(MEDCouplingUMesh *)m3->buildPartOfMySelf(vec2,vec2+2,false); + // + std::vector ms(3); + ms[0]=m1; ms[1]=m2_2; ms[2]=m3_2; + // + MEDCouplingUMesh *m4=MEDCouplingUMesh::MergeUMeshes(ms); + m4->checkCoherency(); + CPPUNIT_ASSERT_EQUAL(10,m4->getNumberOfCells()); + CPPUNIT_ASSERT_EQUAL(20,m4->getNumberOfNodes()); + CPPUNIT_ASSERT_EQUAL(45,m4->getMeshLength()); + // + const int vec3[5]={0,1,2,3,4}; + MEDCouplingUMesh *m4_1=(MEDCouplingUMesh *)m4->buildPartOfMySelf(vec3,vec3+5,false); + m4_1->setName(m1->getName()); + CPPUNIT_ASSERT(m4_1->isEqual(m1,1e-12)); + m4_1->decrRef(); + // + const int vec4[3]={5,6,7}; + MEDCouplingUMesh *m4_2=(MEDCouplingUMesh *)m4->buildPartOfMySelf(vec4,vec4+3,false); + DataArrayInt *cellCor=0; + DataArrayInt *nodeCor=0; + m4_2->checkGeoEquivalWith(m2_2,10,1e-12,cellCor,nodeCor); + CPPUNIT_ASSERT(cellCor==0); + CPPUNIT_ASSERT(nodeCor==0); + m4_2->decrRef(); + // + const int vec5[2]={8,9}; + MEDCouplingUMesh *m4_3=(MEDCouplingUMesh *)m4->buildPartOfMySelf(vec5,vec5+2,false); + CPPUNIT_ASSERT_EQUAL(2,m4_3->getNumberOfCells()); + CPPUNIT_ASSERT_EQUAL(3,m4_3->getNumberOfNodes()); + m3_2->zipCoords(); + m4_3->setName(m3_2->getName()); + CPPUNIT_ASSERT(m4_3->isEqual(m3_2,1e-12)); + m4_3->decrRef(); + // + m4->decrRef(); + m1->decrRef(); + m2->decrRef(); + m2_2->decrRef(); + m3->decrRef(); + m3_2->decrRef(); +} + +void MEDCouplingBasicsTest::testBuild0DMeshFromCoords1() +{ + const double sourceCoords[12]={-0.3,-0.3,0., 0.7,-0.3,0., -0.3,0.7,0., 0.7,0.7,0.}; + DataArrayDouble *coo=DataArrayDouble::New(); + coo->alloc(4,3); + coo->setName("My0D"); + std::copy(sourceCoords,sourceCoords+12,coo->getPointer()); + MEDCouplingUMesh *m=MEDCouplingUMesh::Build0DMeshFromCoords(coo); + m->checkCoherency(); + CPPUNIT_ASSERT_EQUAL(4,m->getNumberOfNodes()); + CPPUNIT_ASSERT_EQUAL(4,m->getNumberOfCells()); + CPPUNIT_ASSERT_EQUAL(3,m->getSpaceDimension()); + CPPUNIT_ASSERT_EQUAL(0,m->getMeshDimension()); + const std::set& types=m->getAllTypes(); + CPPUNIT_ASSERT_EQUAL(1,(int)types.size()); + CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_POINT1,*types.begin()); + for(int i=0;i<4;i++) + { + std::vector conn; + m->getNodeIdsOfCell(i,conn); + CPPUNIT_ASSERT_EQUAL(1,(int)conn.size()); + CPPUNIT_ASSERT_EQUAL(i,conn[0]); + CPPUNIT_ASSERT(INTERP_KERNEL::NORM_POINT1==m->getTypeOfCell(i)); + } + CPPUNIT_ASSERT(std::string(m->getName())=="My0D"); + m->decrRef(); + coo->decrRef(); +} + diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest4.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest4.cxx new file mode 100644 index 000000000..cdd00270e --- /dev/null +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest4.cxx @@ -0,0 +1,1272 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "MEDCouplingBasicsTest.hxx" +#include "MEDCouplingUMesh.hxx" +#include "MEDCouplingCMesh.hxx" +#include "MEDCouplingExtrudedMesh.hxx" +#include "MEDCouplingFieldDouble.hxx" +#include "MEDCouplingMemArray.hxx" +#include "MEDCouplingGaussLocalization.hxx" +#include "MEDCouplingMultiFields.hxx" +#include "MEDCouplingFieldOverTime.hxx" + +#include +#include +#include + +using namespace ParaMEDMEM; + +void MEDCouplingBasicsTest::testDescriptionInMeshTimeUnit1() +{ + static const char text1[]="totoTTEDD"; + MEDCouplingUMesh *m=build2DTargetMesh_1(); + m->setDescription(text1); + CPPUNIT_ASSERT(std::string(m->getDescription())==text1); + MEDCouplingUMesh *m2=(MEDCouplingUMesh *)m->deepCpy(); + CPPUNIT_ASSERT(m->isEqual(m2,1e-12)); + CPPUNIT_ASSERT(std::string(m2->getDescription())==text1); + m2->setDescription("ggg"); + CPPUNIT_ASSERT(!m->isEqual(m2,1e-12)); + m2->decrRef(); + // + MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME); + f->setTimeUnit(text1); + CPPUNIT_ASSERT(std::string(f->getTimeUnit())==text1); + MEDCouplingFieldDouble *f2=f->deepCpy(); + CPPUNIT_ASSERT(std::string(f2->getTimeUnit())==text1); + f2->decrRef(); + // + f->decrRef(); + m->decrRef(); +} + +void MEDCouplingBasicsTest::testMultiFields1() +{ + MEDCouplingMultiFields *mfs=buildMultiFields_1(); + std::vector ms=mfs->getMeshes(); + std::vector refs; + std::vector dms=mfs->getDifferentMeshes(refs); + std::vector das=mfs->getArrays(); + std::vector< std::vector > refs2; + std::vector das2=mfs->getDifferentArrays(refs2); + // + CPPUNIT_ASSERT_EQUAL(5,(int)ms.size()); + CPPUNIT_ASSERT_EQUAL(2,(int)dms.size()); + CPPUNIT_ASSERT_EQUAL(6,(int)das.size()); + CPPUNIT_ASSERT_EQUAL(5,(int)das2.size()); + // + MEDCouplingMultiFields *mfs2=mfs->deepCpy(); + CPPUNIT_ASSERT(mfs->isEqual(mfs2,1e-12,1e-12)); + mfs2->decrRef(); + // + mfs->decrRef(); +} + +void MEDCouplingBasicsTest::testFieldOverTime1() +{ + std::vector fs=buildMultiFields_2(); + CPPUNIT_ASSERT_THROW(MEDCouplingFieldOverTime::New(fs),INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *f4bis=fs[4]->buildNewTimeReprFromThis(ONE_TIME,false); + fs[4]->decrRef(); + fs[4]=f4bis; + CPPUNIT_ASSERT_THROW(MEDCouplingFieldOverTime::New(fs),INTERP_KERNEL::Exception); + f4bis->setTime(2.7,20,21); + MEDCouplingFieldOverTime *fot=MEDCouplingFieldOverTime::New(fs); + MEDCouplingDefinitionTime 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}; + for(int i=0;i<6;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],hs[i],1e-12); + int meshId,arrId,arrIdInField,fieldId; + dt.getIdsOnTimeRight(0.2,meshId,arrId,arrIdInField,fieldId); + CPPUNIT_ASSERT_EQUAL(0,meshId); + CPPUNIT_ASSERT_EQUAL(0,arrId); + CPPUNIT_ASSERT_EQUAL(0,arrIdInField); + CPPUNIT_ASSERT_EQUAL(0,fieldId); + // + dt.getIdsOnTimeRight(0.7,meshId,arrId,arrIdInField,fieldId); + CPPUNIT_ASSERT_EQUAL(0,meshId); + CPPUNIT_ASSERT_EQUAL(1,arrId); + CPPUNIT_ASSERT_EQUAL(0,arrIdInField); + CPPUNIT_ASSERT_EQUAL(1,fieldId); + // + dt.getIdsOnTimeLeft(1.2,meshId,arrId,arrIdInField,fieldId);//**** WARNING left here + CPPUNIT_ASSERT_EQUAL(0,meshId); + CPPUNIT_ASSERT_EQUAL(2,arrId); + CPPUNIT_ASSERT_EQUAL(1,arrIdInField); + CPPUNIT_ASSERT_EQUAL(1,fieldId); + // + dt.getIdsOnTimeRight(1.2,meshId,arrId,arrIdInField,fieldId);//**** WARNING right again here + CPPUNIT_ASSERT_EQUAL(1,meshId); + CPPUNIT_ASSERT_EQUAL(3,arrId); + CPPUNIT_ASSERT_EQUAL(0,arrIdInField); + CPPUNIT_ASSERT_EQUAL(2,fieldId); + // + dt.getIdsOnTimeRight(1.35,meshId,arrId,arrIdInField,fieldId); + CPPUNIT_ASSERT_EQUAL(1,meshId); + CPPUNIT_ASSERT_EQUAL(3,arrId); + CPPUNIT_ASSERT_EQUAL(0,arrIdInField); + CPPUNIT_ASSERT_EQUAL(2,fieldId); + // + dt.getIdsOnTimeRight(1.7,meshId,arrId,arrIdInField,fieldId); + CPPUNIT_ASSERT_EQUAL(0,meshId); + CPPUNIT_ASSERT_EQUAL(3,arrId); + CPPUNIT_ASSERT_EQUAL(0,arrIdInField); + CPPUNIT_ASSERT_EQUAL(3,fieldId); + // + dt.getIdsOnTimeRight(2.7,meshId,arrId,arrIdInField,fieldId); + CPPUNIT_ASSERT_EQUAL(1,meshId); + CPPUNIT_ASSERT_EQUAL(4,arrId); + CPPUNIT_ASSERT_EQUAL(0,arrIdInField); + CPPUNIT_ASSERT_EQUAL(4,fieldId); + // + MEDCouplingDefinitionTime dt2; + CPPUNIT_ASSERT(!dt2.isEqual(dt)); + dt2.assign(dt); + dt2.assign(dt);//to check memory management + CPPUNIT_ASSERT(dt2.isEqual(dt)); + // + MEDCouplingDefinitionTime dt3; + std::vector tmp1; + std::vector tmp2; + CPPUNIT_ASSERT(!dt2.isEqual(dt3)); + dt2.getTinySerializationInformation(tmp1,tmp2); + dt3.unserialize(tmp1,tmp2); + CPPUNIT_ASSERT(dt2.isEqual(dt3)); + // + for(std::vector::iterator it=fs.begin();it!=fs.end();it++) + (*it)->decrRef(); + fot->decrRef(); +} + +void MEDCouplingBasicsTest::testDAICheckAndPreparePermutation1() +{ + const int vals1[]={9,10,0,6,4,11,3,7}; + const int expect1[]={5,6,0,3,2,7,1,4}; + const int vals2[]={9,10,0,6,10,11,3,7}; + DataArrayInt *da=DataArrayInt::New(); + da->alloc(8,1); + std::copy(vals1,vals1+8,da->getPointer()); + DataArrayInt *da2=da->checkAndPreparePermutation(); + CPPUNIT_ASSERT_EQUAL(8,da2->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,da2->getNumberOfComponents()); + for(int i=0;i<8;i++) + CPPUNIT_ASSERT_EQUAL(expect1[i],da2->getIJ(i,0)); + da2->decrRef(); + da->decrRef(); + // + da=DataArrayInt::New(); + da->alloc(8,1); + da->iota(0); + da2=da->checkAndPreparePermutation(); + CPPUNIT_ASSERT_EQUAL(8,da2->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,da2->getNumberOfComponents()); + CPPUNIT_ASSERT(da2->isIdentity()); + da2->decrRef(); + da->decrRef(); + // + da=DataArrayInt::New(); + da->alloc(8,1); + std::copy(vals2,vals2+8,da->getPointer()); + CPPUNIT_ASSERT_THROW(da->checkAndPreparePermutation(),INTERP_KERNEL::Exception); + da->decrRef(); +} + +void MEDCouplingBasicsTest::testDAIChangeSurjectiveFormat1() +{ + const int vals1[8]={0,3,2,3,2,2,1,2}; + const int expected1[5]={0,1,2,6,8}; + const int expected2[8]={0, 6, 2,4,5,7, 1,3}; + DataArrayInt *da=DataArrayInt::New(); + da->alloc(8,1); + std::copy(vals1,vals1+8,da->getPointer()); + // + DataArrayInt *da2,*da2I; + da->changeSurjectiveFormat(4,da2,da2I); + CPPUNIT_ASSERT_EQUAL(5,da2I->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(8,da2->getNumberOfTuples()); + CPPUNIT_ASSERT(std::equal(expected1,expected1+5,da2I->getConstPointer())); + CPPUNIT_ASSERT(std::equal(expected2,expected2+8,da2->getConstPointer())); + da2->decrRef(); + da2I->decrRef(); + // + CPPUNIT_ASSERT_THROW(da->changeSurjectiveFormat(3,da2,da2I),INTERP_KERNEL::Exception); + // + da->decrRef(); +} + +void MEDCouplingBasicsTest::testUMeshGetCellIdsLyingOnNodes1() +{ + MEDCouplingUMesh *m=build3DSurfTargetMesh_1(); + const int nodeIds1[5]={1,2,3,4,6}; + const int nodeIds2[2]={6,7}; + DataArrayInt *da=m->getCellIdsLyingOnNodes(nodeIds1,nodeIds1+5,true); + CPPUNIT_ASSERT_EQUAL(1,da->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,da->getNumberOfComponents()); + CPPUNIT_ASSERT_EQUAL(1,da->getIJ(0,0)); + da->decrRef(); + da=m->getCellIdsLyingOnNodes(nodeIds2,nodeIds2+2,false); + CPPUNIT_ASSERT_EQUAL(2,da->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,da->getNumberOfComponents()); + CPPUNIT_ASSERT_EQUAL(3,da->getIJ(0,0)); + CPPUNIT_ASSERT_EQUAL(4,da->getIJ(1,0)); + da->decrRef(); + // + m->decrRef(); +} + +void MEDCouplingBasicsTest::testUMeshFindCellsIdsOnBoundary1() +{ + MEDCouplingUMesh *m=build3DSurfTargetMesh_1(); + DataArrayInt *da5=m->findCellsIdsOnBoundary(); + CPPUNIT_ASSERT_EQUAL(5,da5->getNumberOfTuples()); + CPPUNIT_ASSERT(da5->isIdentity()); + // + da5->decrRef(); + m->decrRef(); +} + +void MEDCouplingBasicsTest::testMeshSetTime1() +{ + MEDCouplingUMesh *m1=build3DSurfTargetMesh_1(); + MEDCouplingUMesh *m2=build3DSurfTargetMesh_1(); + // + CPPUNIT_ASSERT(m1->isEqual(m2,1e-12)); + m1->setTime(3.14,6,7); + int tmp1,tmp2; + double tmp3=m1->getTime(tmp1,tmp2); + CPPUNIT_ASSERT_EQUAL(6,tmp1); + CPPUNIT_ASSERT_EQUAL(7,tmp2); + CPPUNIT_ASSERT_DOUBLES_EQUAL(3.14,tmp3,1e-12); + CPPUNIT_ASSERT(!m1->isEqual(m2,1e-12)); + m2->setTime(3.14,6,7); + CPPUNIT_ASSERT(m1->isEqual(m2,1e-12)); + m1->setTimeUnit("ms"); + CPPUNIT_ASSERT(std::string(m1->getTimeUnit())=="ms"); + m1->setTimeUnit("us"); + CPPUNIT_ASSERT(std::string(m1->getTimeUnit())=="us"); + CPPUNIT_ASSERT(!m1->isEqual(m2,1e-12)); + m2->setTimeUnit("us"); + CPPUNIT_ASSERT(m1->isEqual(m2,1e-12)); + m2->setTime(3.14,6,8); + CPPUNIT_ASSERT(!m1->isEqual(m2,1e-12)); + m2->setTime(3.14,7,7); + CPPUNIT_ASSERT(!m1->isEqual(m2,1e-12)); + m2->setTime(3.15,6,7); + CPPUNIT_ASSERT(!m1->isEqual(m2,1e-12)); + // + m1->setTime(10.34,55,12); + MEDCouplingUMesh *m3=(MEDCouplingUMesh *)m1->deepCpy(); + CPPUNIT_ASSERT(m1->isEqual(m3,1e-12)); + tmp3=m3->getTime(tmp1,tmp2); + CPPUNIT_ASSERT_EQUAL(55,tmp1); + CPPUNIT_ASSERT_EQUAL(12,tmp2); + CPPUNIT_ASSERT_DOUBLES_EQUAL(10.34,tmp3,1e-12); + // + m3->decrRef(); + m1->decrRef(); + m2->decrRef(); + // testing CMesh + const double coo1[4]={0.,1.,2.,3.5}; + DataArrayDouble *a=DataArrayDouble::New(); + a->alloc(4,1); + std::copy(coo1,coo1+4,a->getPointer()); + MEDCouplingCMesh *b=MEDCouplingCMesh::New(); + b->setCoordsAt(0,a); + a->decrRef(); + // + b->setTime(5.67,8,100); + tmp3=b->getTime(tmp1,tmp2); + CPPUNIT_ASSERT_EQUAL(8,tmp1); + CPPUNIT_ASSERT_EQUAL(100,tmp2); + CPPUNIT_ASSERT_DOUBLES_EQUAL(5.67,tmp3,1e-12); + MEDCouplingCMesh *c=(MEDCouplingCMesh *)b->deepCpy(); + CPPUNIT_ASSERT(c->isEqual(b,1e-12)); + tmp3=c->getTime(tmp1,tmp2); + CPPUNIT_ASSERT_EQUAL(8,tmp1); + CPPUNIT_ASSERT_EQUAL(100,tmp2); + CPPUNIT_ASSERT_DOUBLES_EQUAL(5.67,tmp3,1e-12); + c->decrRef(); + b->decrRef(); +} + +void MEDCouplingBasicsTest::testApplyFuncTwo1() +{ + MEDCouplingUMesh *m1=build3DSurfTargetMesh_1(); + MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME); + f1->setMesh(m1); + // + const double vals[15]={1.,11.,21.,2.,12.,22.,3.,13.,23.,4.,14.,24.,5.,15.,25.}; + DataArrayDouble *da=DataArrayDouble::New(); + da->alloc(5,3); + std::copy(vals,vals+15,da->getPointer()); + f1->setArray(da); + // + CPPUNIT_ASSERT_THROW(da->applyFunc2(1,"y+z"),INTERP_KERNEL::Exception); + da->setInfoOnComponent(0,"x [m]"); + da->setInfoOnComponent(1,"y [mm]"); + da->setInfoOnComponent(2,"z [km]"); + DataArrayDouble *da2=da->applyFunc2(1,"y+z"); + CPPUNIT_ASSERT_EQUAL(1,da2->getNumberOfComponents()); + CPPUNIT_ASSERT_EQUAL(5,da2->getNumberOfTuples()); + const double expected1[5]={32.,34.,36.,38.,40.}; + for(int i=0;i<5;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],da2->getIJ(0,i),1e-12); + da2->decrRef(); + da2=da->applyFunc(1,"y+z"); + const double expected2[5]={12.,14.,16.,18.,20.}; + for(int i=0;i<5;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],da2->getIJ(0,i),1e-12); + da2->decrRef(); + // + CPPUNIT_ASSERT_EQUAL(3,f1->getNumberOfComponents()); + CPPUNIT_ASSERT_EQUAL(5,f1->getNumberOfTuples()); + f1->applyFunc2(1,"y+z"); + CPPUNIT_ASSERT_EQUAL(1,f1->getNumberOfComponents()); + CPPUNIT_ASSERT_EQUAL(5,f1->getNumberOfTuples()); + for(int i=0;i<5;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f1->getArray()->getIJ(0,i),1e-12); + // + da->decrRef(); + f1->decrRef(); + m1->decrRef(); +} + +void MEDCouplingBasicsTest::testApplyFuncThree1() +{ + MEDCouplingUMesh *m1=build3DSurfTargetMesh_1(); + MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME); + f1->setMesh(m1); + // + const double vals[15]={1.,11.,21.,2.,12.,22.,3.,13.,23.,4.,14.,24.,5.,15.,25.}; + DataArrayDouble *da=DataArrayDouble::New(); + da->alloc(5,3); + std::copy(vals,vals+15,da->getPointer()); + f1->setArray(da); + // + std::vector vs(3); + vs[0]="x"; vs[1]="Y"; vs[2]="z"; + CPPUNIT_ASSERT_THROW(da->applyFunc3(1,vs,"y+z"),INTERP_KERNEL::Exception); + vs[1]="y"; + DataArrayDouble *da2=da->applyFunc3(1,vs,"y+z"); + const double expected1[5]={32.,34.,36.,38.,40.}; + for(int i=0;i<5;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],da2->getIJ(0,i),1e-12); + da2->decrRef(); + f1->setArray(da); + CPPUNIT_ASSERT_EQUAL(3,f1->getNumberOfComponents()); + CPPUNIT_ASSERT_EQUAL(5,f1->getNumberOfTuples()); + f1->applyFunc3(1,vs,"y+z"); + CPPUNIT_ASSERT_EQUAL(1,f1->getNumberOfComponents()); + CPPUNIT_ASSERT_EQUAL(5,f1->getNumberOfTuples()); + for(int i=0;i<5;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f1->getArray()->getIJ(0,i),1e-12); + // + da->decrRef(); + f1->decrRef(); + m1->decrRef(); +} + +void MEDCouplingBasicsTest::testFillFromAnalyticTwo1() +{ + MEDCouplingUMesh *m1=build3DSurfTargetMesh_1(); + CPPUNIT_ASSERT_THROW(m1->fillFromAnalytic2(ON_NODES,1,"y+z"),INTERP_KERNEL::Exception); + m1->getCoords()->setInfoOnComponent(0,"x [m]"); + m1->getCoords()->setInfoOnComponent(1,"y"); + m1->getCoords()->setInfoOnComponent(2,"z"); + MEDCouplingFieldDouble *f1=m1->fillFromAnalytic2(ON_NODES,1,"y+z"); + CPPUNIT_ASSERT_EQUAL(1,f1->getNumberOfComponents()); + CPPUNIT_ASSERT_EQUAL(9,f1->getNumberOfTuples()); + const double expected1[9]={0.2, 0.7, 1.2, 0.7, 1.2, 1.7, 1.2, 1.7, 2.2}; + for(int i=0;i<9;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f1->getArray()->getIJ(0,i),1e-12); + f1->decrRef(); + m1->decrRef(); +} + +void MEDCouplingBasicsTest::testFillFromAnalyticThree1() +{ + MEDCouplingUMesh *m1=build3DSurfTargetMesh_1(); + std::vector vs(3); + vs[0]="x"; vs[1]="Y"; vs[2]="z"; + CPPUNIT_ASSERT_THROW(m1->fillFromAnalytic3(ON_NODES,1,vs,"y+z"),INTERP_KERNEL::Exception); + vs[1]="y"; + MEDCouplingFieldDouble *f1=m1->fillFromAnalytic3(ON_NODES,1,vs,"y+z"); + CPPUNIT_ASSERT_EQUAL(1,f1->getNumberOfComponents()); + CPPUNIT_ASSERT_EQUAL(9,f1->getNumberOfTuples()); + const double expected1[9]={0.2, 0.7, 1.2, 0.7, 1.2, 1.7, 1.2, 1.7, 2.2}; + for(int i=0;i<9;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f1->getArray()->getIJ(0,i),1e-12); + f1->decrRef(); + m1->decrRef(); +} + +void MEDCouplingBasicsTest::testDAUnitVar1() +{ + DataArrayDouble *da=DataArrayDouble::New(); + da->alloc(1,3); + da->setInfoOnComponent(0,"XPS [m]"); + std::string st1,st2; + st1=da->getVarOnComponent(0); + CPPUNIT_ASSERT(st1=="XPS"); + st2=da->getUnitOnComponent(0); + CPPUNIT_ASSERT(st2=="m"); + // + da->setInfoOnComponent(0,"XPS [m]"); + st1=da->getVarOnComponent(0); + CPPUNIT_ASSERT(st1=="XPS"); + st2=da->getUnitOnComponent(0); + CPPUNIT_ASSERT(st2=="m"); + // + da->setInfoOnComponent(0,"XPP [m]"); + st1=da->getVarOnComponent(0); + CPPUNIT_ASSERT(st1=="XPP"); + st2=da->getUnitOnComponent(0); + CPPUNIT_ASSERT(st2=="m"); + // + da->setInfoOnComponent(0,"XPP kdep kefer [ m ]"); + st1=da->getVarOnComponent(0); + CPPUNIT_ASSERT(st1=="XPP kdep kefer"); + st2=da->getUnitOnComponent(0); + CPPUNIT_ASSERT(st2==" m "); + // + da->setInfoOnComponent(0," XPP k[ dep k]efer [ m^ 2/s^3*kJ ]"); + st1=da->getVarOnComponent(0); + CPPUNIT_ASSERT(st1==" XPP k[ dep k]efer"); + st2=da->getUnitOnComponent(0); + CPPUNIT_ASSERT(st2==" m^ 2/s^3*kJ "); + // + da->setInfoOnComponent(0," XPP kefer "); + st1=da->getVarOnComponent(0); + CPPUNIT_ASSERT(st1==" XPP kefer "); + st2=da->getUnitOnComponent(0); + CPPUNIT_ASSERT(st2==""); + // + da->setInfoOnComponent(0,"temperature( bof)"); + st1=da->getVarOnComponent(0); + CPPUNIT_ASSERT(st1=="temperature( bof)"); + st2=da->getUnitOnComponent(0); + CPPUNIT_ASSERT(st2==""); + // + da->setInfoOnComponent(0,"kkk [m]"); + da->setInfoOnComponent(1,"ppp [m^2/kJ]"); + da->setInfoOnComponent(2,"abcde [MW/s]"); + // + std::vector vs; + vs=da->getVarsOnComponent(); + CPPUNIT_ASSERT_EQUAL(3,(int)vs.size()); + CPPUNIT_ASSERT(vs[0]=="kkk"); + CPPUNIT_ASSERT(vs[1]=="ppp"); + CPPUNIT_ASSERT(vs[2]=="abcde"); + vs=da->getUnitsOnComponent(); + CPPUNIT_ASSERT_EQUAL(3,(int)vs.size()); + CPPUNIT_ASSERT(vs[0]=="m"); + CPPUNIT_ASSERT(vs[1]=="m^2/kJ"); + CPPUNIT_ASSERT(vs[2]=="MW/s"); + // + da->decrRef(); +} + +void MEDCouplingBasicsTest::testGaussCoordinates1() +{ + //Testing 1D cell types + MEDCouplingUMesh *m1=build1DMultiTypes_1(); + MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_GAUSS_PT,ONE_TIME); + f->setMesh(m1); + std::vector wg1(1); wg1[0]=0.3; + 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 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); + // + DataArrayDouble *resToTest=f->getLocalizationOfDiscr(); + CPPUNIT_ASSERT_EQUAL(3,resToTest->getNumberOfComponents()); + CPPUNIT_ASSERT_EQUAL(2,resToTest->getNumberOfTuples()); + const double expected1[6]={0.6,0.6,0.6, 0.6,0.6,0.6}; + for(int i=0;i<6;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],resToTest->getIJ(0,i),1e-14); + resToTest->decrRef(); + // + m1->decrRef(); + f->decrRef(); + //Testing 2D cell types + MEDCouplingUMesh *m2=build2DMultiTypes_1(); + f=MEDCouplingFieldDouble::New(ON_GAUSS_PT,ONE_TIME); + 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); + const double tria3CooRef[6]={ 0.0, 0.0, 1.0 , 0.0, 0.0, 1.0 }; + std::vector 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); + 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); + 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); + 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); + 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); + 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); + f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_QUAD8,refCoo6,gsCoo6,wg6); + // + resToTest=f->getLocalizationOfDiscr(); + CPPUNIT_ASSERT_EQUAL(3,resToTest->getNumberOfComponents()); + CPPUNIT_ASSERT_EQUAL(13,resToTest->getNumberOfTuples());//2+3+4+4 gauss points for resp TRI3,TRI6,QUAD4,QUAD8 + const double expected2[39]={5.1,1.55,0.0, 4.7,1.65,0.0, //TRI3 + 2.32,1.52,0.0, 1.6,1.32,0.0, 3.52,1.26,0.0,//TRI6 + 2.6,1.6,0.0, 2.4,1.8,0.0, 2.4,1.2,0.0, 2.3,1.46,0.0,//QUAD4 + 2.32,2.68,0.0, 2.6,2.42,0.0, 2.8,2.46,0.0, 2.74,2.28,0.0 };//QUAD8 + for(int i=0;i<39;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],resToTest->getIJ(0,i),1e-14); + resToTest->decrRef(); + // + m2->decrRef(); + f->decrRef(); + //Testing 3D cell types + MEDCouplingUMesh *m3=build3DMultiTypes_1(); + f=MEDCouplingFieldDouble::New(ON_GAUSS_PT,ONE_TIME); + f->setMesh(m3); + // + std::vector wg7(1); wg7[0]=0.3; + const double tetra4CooGauss[3]={0.34, 0.16, 0.21}; + std::vector 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); + 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); + 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); + 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); + 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); + 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); + 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); + 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); + 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); + 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); + 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); + 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); + 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); + 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); + 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); + f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_HEXA20,refCoo14,gsCoo14,wg14); + // + resToTest=f->getLocalizationOfDiscr(); + CPPUNIT_ASSERT_EQUAL(3,resToTest->getNumberOfComponents()); + CPPUNIT_ASSERT_EQUAL(8,resToTest->getNumberOfTuples());//2+3+4+4 gauss points for resp TRI3,TRI6,QUAD4,QUAD8 + const double expected3[24]={1.312,3.15,1.02, 0.56,3.3,0.6, 2.18,1.1,0.2, 1.18,1.54,0.98, 1.56,0.3,3.6, 1.613,0.801,4.374, 2.6,2.4,2.3, 2.31232,2.3933985,1.553255}; + for(int i=0;i<24;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected3[i],resToTest->getIJ(0,i),1e-14); + resToTest->decrRef(); + // + m3->decrRef(); + f->decrRef(); +} + +/*! + * Not activated test ! To be implemented ! + */ +void MEDCouplingBasicsTest::testQ1Localization1() +{ + MEDCouplingUMesh *m=buildHexa8Mesh_1(); + MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_NODES,ONE_TIME); + DataArrayDouble *da=DataArrayDouble::New(); + const double vals1[27]={1.0,3.0,4.0,1.0,3.0,4.0,3.0,2.0,5.0,1.0,3.0,4.0,1.0,3.0,4.0,3.0,2.0,5.0,1.0,3.0,4.0,1.0,3.0,4.0,3.0,2.0,5.0}; + da->alloc(27,1); + std::copy(vals1,vals1+27,da->getPointer()); + f->setMesh(m); + f->setArray(da); + da->decrRef(); + // + const double point1[3]={0.25,0.75,0.25}; + //const double points1[6]={0.25,0.75,0.25,1.0,1.0,1.0}; + double res1[3]; + f->getValueOn(point1,res1); + // + f->decrRef(); + m->decrRef(); +} + +void MEDCouplingBasicsTest::testP2Localization1() +{ + MEDCouplingUMesh *m=MEDCouplingUMesh::New("testP2",2); + const double coords[12]={0.,2.,3.5,0.,4.5,1.5,1.2,0.32,3.4,1.,2.1,2.4}; + const int conn[6]={0,1,2,3,4,5}; + DataArrayDouble *coo=DataArrayDouble::New(); + coo->alloc(6,2); + std::copy(coords,coords+12,coo->getPointer()); + m->setCoords(coo); + coo->decrRef(); + m->allocateCells(1); + m->insertNextCell(INTERP_KERNEL::NORM_TRI6,6,conn); + m->finishInsertingCells(); + // + MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_NODES,ONE_TIME); + f->setMesh(m); + DataArrayDouble *da=DataArrayDouble::New(); + da->alloc(6,3); + const double vals1[18]={1.2,2.3,3.4, 2.2,3.3,4.4, 3.2,4.3,5.4, 4.2,5.3,6.4, 5.2,6.3,7.4, 6.2,7.3,8.4}; + std::copy(vals1,vals1+18,da->getPointer()); + f->setArray(da); + da->decrRef(); + // + const double loc[2]={2.27,1.3}; + DataArrayDouble *locs=f->getValueOnMulti(loc,1); + const double expected1[3]={6.0921164547752236, 7.1921164547752232, 8.2921164547752255}; + for(int i=0;i<3;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],locs->getIJ(0,i),1e-12); + locs->decrRef(); + // + m->decrRef(); + f->decrRef(); +} + +void MEDCouplingBasicsTest::testP2Localization2() +{ + MEDCouplingUMesh *m=MEDCouplingUMesh::New("testP2_2",3); + const double coords[30]={0.33312787792955395, -0.35155740179580952, -0.03567564825034563, 1.307146326477638, -0.57234557776250305, -0.08608044208272235, 0.5551834466499993, 0.62324964668794192, -0.014638951108536295, 0.37761817224442129, -0.38324019806913578, 0.96283164472856886, 0.79494856035658679, -0.40628057809270046, 0.0021004190225864614, 1.023740446371799, 0.07665912970471335, -0.072889657161871096, 0.54564584619517376, 0.11132872093429744, 0.039647326652013051, 0.27164784387819052, -0.42018012100866675, 0.46563376500745146, 0.89501965094896418, -0.56148455362735061, 0.43337469695473035, 0.49118025152924394, 0.093884938060727313, 0.47216346905220891}; + const int conn[10]={0,1,2,3,4,5,6,7,8,9}; + DataArrayDouble *coo=DataArrayDouble::New(); + coo->alloc(10,3); + std::copy(coords,coords+30,coo->getPointer()); + m->setCoords(coo); + coo->decrRef(); + m->allocateCells(1); + m->insertNextCell(INTERP_KERNEL::NORM_TETRA10,10,conn); + m->finishInsertingCells(); + // + MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_NODES,ONE_TIME); + f->setMesh(m); + DataArrayDouble *da=DataArrayDouble::New(); + da->alloc(10,1); + const double vals1[10]={1.1,2.1,3.1,4.1,5.2,6.2,7.2,8.2,9.2,10.2}; + std::copy(vals1,vals1+10,da->getPointer()); + f->setArray(da); + da->decrRef(); + // + const double loc[3]={0.64637931739890486, -0.16185896817550552, 0.22678966365273748}; + DataArrayDouble *locs=f->getValueOnMulti(loc,1); + const double expected1[1]={10.0844021968047}; + for(int i=0;i<1;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],locs->getIJ(0,i),1e-12); + locs->decrRef(); + // + m->decrRef(); + f->decrRef(); +} + +void MEDCouplingBasicsTest::testGetValueOn2() +{ + MEDCouplingUMesh *m=build2DTargetMesh_1(); + MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME); + f->setMesh(m); + DataArrayDouble *arr=DataArrayDouble::New(); + int nbOfCells=m->getNumberOfCells(); + arr->alloc(nbOfCells,3); + f->setArray(arr); + arr->decrRef(); + const double values1[15]={7.,107.,10007.,8.,108.,10008.,9.,109.,10009.,10.,110.,10010.,11.,111.,10011.}; + std::copy(values1,values1+15,arr->getPointer()); + const double loc[10]={-0.05,-0.05, 0.55,-0.25, 0.55,0.15, -0.05,0.45, 0.45,0.45}; + f->checkCoherency(); + DataArrayDouble *locs=f->getValueOnMulti(loc,5); + CPPUNIT_ASSERT_EQUAL(5,locs->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(3,locs->getNumberOfComponents()); + for(int j=0;j<15;j++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(values1[j],locs->getIJ(0,j),1e-12); + locs->decrRef(); + f->decrRef(); + // Testing ON_NODES + f=MEDCouplingFieldDouble::New(ON_NODES,NO_TIME); + f->setMesh(m); + arr=DataArrayDouble::New(); + int nbOfNodes=m->getNumberOfNodes(); + arr->alloc(nbOfNodes,3); + f->setArray(arr); + arr->decrRef(); + const double values2[27]={7.,107.,10007.,8.,108.,10008.,9.,109.,10009.,10.,110.,10010.,11.,111.,10011.,12.,112.,10012.,13.,113.,10013.,14.,114.,10014.,15.,115.,10015.}; + std::copy(values2,values2+27,arr->getPointer()); + const double loc2[8]={0.5432,-0.2432, 0.5478,0.1528, 0.5432,-0.2432, 0.5432,-0.2432}; + const double expected2[12]={9.0272, 109.0272, 10009.0272, 11.4124,111.4124,10011.4124, 9.0272, 109.0272, 10009.0272, 9.0272, 109.0272, 10009.0272}; + f->checkCoherency(); + locs=f->getValueOnMulti(loc2,4); + CPPUNIT_ASSERT_EQUAL(4,locs->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(3,locs->getNumberOfComponents()); + for(int i=0;i<12;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],locs->getIJ(0,i),1e-12); + f->decrRef(); + locs->decrRef(); + // + m->decrRef(); +} + +void MEDCouplingBasicsTest::testDAIGetIdsNotEqual1() +{ + DataArrayInt *d=DataArrayInt::New(); + const int vals1[10]={2,3,5,6,8,5,5,6,1,-5}; + d->alloc(10,1); + std::copy(vals1,vals1+10,d->getPointer()); + DataArrayInt *d2=d->getIdsNotEqual(5); + CPPUNIT_ASSERT_EQUAL(7,d2->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,d2->getNumberOfComponents()); + const int expected1[7]={0,1,3,4,7,8,9}; + for(int i=0;i<7;i++) + CPPUNIT_ASSERT_EQUAL(expected1[i],d2->getIJ(0,i)); + d->rearrange(2); + CPPUNIT_ASSERT_THROW(d->getIdsNotEqual(5),INTERP_KERNEL::Exception); + const int vals2[3]={-4,5,6}; + std::vector vals3(vals2,vals2+3); + d->rearrange(1); + DataArrayInt *d3=d->getIdsNotEqualList(vals3); + CPPUNIT_ASSERT_EQUAL(5,d3->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,d3->getNumberOfComponents()); + const int expected2[5]={0,1,4,8,9}; + for(int i=0;i<5;i++) + CPPUNIT_ASSERT_EQUAL(expected2[i],d3->getIJ(0,i)); + d3->decrRef(); + d->decrRef(); + d2->decrRef(); +} + +void MEDCouplingBasicsTest::testDAIComputeOffsets1() +{ + DataArrayInt *d=DataArrayInt::New(); + const int vals1[6]={3,5,1,2,0,8}; + const int expected1[6]={0,3,8,9,11,11}; + d->alloc(6,1); + std::copy(vals1,vals1+6,d->getPointer()); + d->computeOffsets(); + CPPUNIT_ASSERT_EQUAL(6,d->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,d->getNumberOfComponents()); + for(int i=0;i<6;i++) + CPPUNIT_ASSERT_EQUAL(expected1[i],d->getIJ(0,i)); + d->decrRef(); +} + +void MEDCouplingBasicsTest::testUMeshHexagonPrism1() +{ + const double coords[36]={ + 0.8660254037844386, 0.5, 0.0, 0.0, 1.0, 0.0, -0.8660254037844386, 0.5, 0.0, -0.8660254037844386, -0.5, 0.0, 0.0, -1.0, 0.0, 0.8660254037844386, -0.5, 0.0, + 0.8660254037844386, 0.5, 2.0, 0.0, 1.0, 2.0, -0.8660254037844386, 0.5, 2.0, -0.8660254037844386, -0.5, 2.0, 0.0, -1.0, 2.0, 0.8660254037844386, -0.5, 2.0 + }; + const int conn[12]={1,2,3,4,5,0,7,8,9,10,11,6}; + MEDCouplingUMesh *mesh=MEDCouplingUMesh::New("MyFirstHexagonalPrism",3); + DataArrayDouble *coo=DataArrayDouble::New(); + coo->alloc(12,3); + std::copy(coords,coords+36,coo->getPointer()); + mesh->setCoords(coo); + mesh->allocateCells(1); + mesh->insertNextCell(INTERP_KERNEL::NORM_HEXGP12,12,conn); + mesh->finishInsertingCells(); + coo->decrRef(); + // + mesh->checkCoherency(); + MEDCouplingFieldDouble *vols=mesh->getMeasureField(false); + CPPUNIT_ASSERT_EQUAL(1,vols->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,vols->getNumberOfComponents()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(-5.196152422706632,vols->getIJ(0,0),1e-12); + DataArrayDouble *bary=mesh->getBarycenterAndOwner(); + CPPUNIT_ASSERT_EQUAL(1,bary->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(3,bary->getNumberOfComponents()); + const double expected1[3]={0.,0.,1.}; + for(int i=0;i<3;i++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],bary->getIJ(0,i),1e-12); + DataArrayInt *d1=DataArrayInt::New(); + DataArrayInt *d2=DataArrayInt::New(); + DataArrayInt *d3=DataArrayInt::New(); + DataArrayInt *d4=DataArrayInt::New(); + MEDCouplingUMesh *m2=mesh->buildDescendingConnectivity(d1,d2,d3,d4); + CPPUNIT_ASSERT_EQUAL(8,m2->getNumberOfCells()); + const int expected4[8][6]={{1,2,3,4,5,0},{7,6,11,10,9,8},{1,7,8,2},{2,8,9,3},{3,9,10,4},{4,10,11,5},{5,11,6,0},{0,6,7,1}}; + const INTERP_KERNEL::NormalizedCellType expected2[8]={INTERP_KERNEL::NORM_POLYGON, INTERP_KERNEL::NORM_POLYGON, INTERP_KERNEL::NORM_QUAD4, INTERP_KERNEL::NORM_QUAD4, INTERP_KERNEL::NORM_QUAD4, INTERP_KERNEL::NORM_QUAD4, INTERP_KERNEL::NORM_QUAD4, INTERP_KERNEL::NORM_QUAD4}; + const int expected3[8]={6,6,4,4,4,4,4,4}; + for(int i=0;i<8;i++) + { + CPPUNIT_ASSERT(m2->getTypeOfCell(i)==expected2[i]); + std::vector v; + m2->getNodeIdsOfCell(i,v); + CPPUNIT_ASSERT((int)v.size()==expected3[i]); + CPPUNIT_ASSERT(std::equal(expected4[i],expected4[i]+expected3[i],v.begin())); + } + d1->decrRef(); + d2->decrRef(); + d3->decrRef(); + d4->decrRef(); + m2->decrRef(); + // + mesh->convertAllToPoly(); + CPPUNIT_ASSERT(INTERP_KERNEL::NORM_POLYHED==mesh->getTypeOfCell(0)); + mesh->unPolyze(); + CPPUNIT_ASSERT(INTERP_KERNEL::NORM_HEXGP12==mesh->getTypeOfCell(0)); + CPPUNIT_ASSERT_EQUAL(13,mesh->getMeshLength()); + // + vols->decrRef(); + bary->decrRef(); + mesh->decrRef(); +} + +void MEDCouplingBasicsTest::testDADCheckIsMonotonic() +{ + DataArrayDouble *da=DataArrayDouble::New(); + const double vals[4]={-1.,1.01,2.03,6.}; + da->alloc(2,2); + std::copy(vals,vals+4,da->getPointer()); + CPPUNIT_ASSERT_THROW(da->isMonotonic(1e-12),INTERP_KERNEL::Exception); + da->rearrange(1); + CPPUNIT_ASSERT(da->isMonotonic(1e-12)); + da->checkMonotonic(1e-12); + da->setIJ(2,0,6.1); + CPPUNIT_ASSERT(!da->isMonotonic(1e-12)); + CPPUNIT_ASSERT_THROW(da->checkMonotonic(1e-12),INTERP_KERNEL::Exception); + da->setIJ(2,0,5.99); + CPPUNIT_ASSERT(da->isMonotonic(1e-12)); + CPPUNIT_ASSERT(!da->isMonotonic(1e-1)); + da->decrRef(); +} + +void MEDCouplingBasicsTest::testCheckCoherencyDeeper1() +{ + MEDCouplingUMesh *m=build3DSourceMesh_1(); + m->checkCoherency(); + m->checkCoherency1(); + m->getNodalConnectivity()->setIJ(8,0,-1); + m->checkCoherency(); + CPPUNIT_ASSERT_THROW(m->checkCoherency1(),INTERP_KERNEL::Exception); + m->getNodalConnectivity()->setIJ(8,0,-6); + m->checkCoherency(); + CPPUNIT_ASSERT_THROW(m->checkCoherency1(),INTERP_KERNEL::Exception); + m->getNodalConnectivity()->setIJ(8,0,9);//9>=NbOfNodes + m->checkCoherency(); + CPPUNIT_ASSERT_THROW(m->checkCoherency1(),INTERP_KERNEL::Exception); + m->getNodalConnectivity()->setIJ(8,0,8);//OK + m->checkCoherency(); + m->checkCoherency1(); + const int elts[2]={1,5}; + std::vector eltsV(elts,elts+2); + m->convertToPolyTypes(eltsV); + m->checkCoherency(); + m->checkCoherency1(); + m->getNodalConnectivity()->setIJ(2,0,9);//9>=NbOfNodes + m->checkCoherency(); + CPPUNIT_ASSERT_THROW(m->checkCoherency1(),INTERP_KERNEL::Exception); + m->getNodalConnectivity()->setIJ(2,0,-3); + m->checkCoherency(); + CPPUNIT_ASSERT_THROW(m->checkCoherency1(),INTERP_KERNEL::Exception); + m->getNodalConnectivity()->setIJ(2,0,-1); + m->checkCoherency(); + CPPUNIT_ASSERT_THROW(m->checkCoherency1(),INTERP_KERNEL::Exception);//Throw because cell#0 is not a polyhedron + m->getNodalConnectivity()->setIJ(2,0,4); + m->checkCoherency(); + m->checkCoherency1(); + m->getNodalConnectivity()->setIJ(7,0,-1); + m->checkCoherency(); + m->checkCoherency1();//OK because we are in polyhedron connec + m->getNodalConnectivity()->setIJ(36,0,14); + m->checkCoherency(); + CPPUNIT_ASSERT_THROW(m->checkCoherency1(),INTERP_KERNEL::Exception);//Throw beacause now cell 5 is a TETRA4 (14) so mimatch of number index and static type. + m->decrRef(); +} + +void MEDCouplingBasicsTest::testUnPolyze2() +{ + MEDCouplingUMesh *m=MEDCouplingUMesh::New("jjj",3); + DataArrayDouble *coo=DataArrayDouble::New(); + coo->alloc(4,3); + coo->rearrange(1); + coo->iota(0); + coo->rearrange(3); + m->setCoords(coo); + coo->decrRef(); + m->allocateCells(2); + const int conn[4]={0,1,2,3}; + m->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,conn); + m->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,conn); + m->finishInsertingCells(); + std::vector ms(4,m); + MEDCouplingUMesh *m2=MEDCouplingUMesh::MergeUMeshesOnSameCoords(ms); + std::vector temp(1,2); + m2->convertToPolyTypes(temp); + m2->unPolyze(); + CPPUNIT_ASSERT(INTERP_KERNEL::NORM_TETRA4==m2->getTypeOfCell(2)); + CPPUNIT_ASSERT_EQUAL(40,m2->getMeshLength()); + std::vector temp2; + m2->getNodeIdsOfCell(2,temp2); + CPPUNIT_ASSERT(4==(int)temp2.size()); + CPPUNIT_ASSERT(std::equal(conn,conn+4,temp2.begin())); + m2->checkCoherency1(); + MEDCouplingMesh *m3=m2->deepCpy(); + m2->unPolyze(); + CPPUNIT_ASSERT(m3->isEqual(m2,1e-12)); + m3->decrRef(); + m->decrRef(); + m2->decrRef(); +} + +void MEDCouplingBasicsTest::testDACpyFrom1() +{ + DataArrayDouble *d=DataArrayDouble::New(); + d->alloc(12,1); + d->iota(14.); + d->rearrange(3); + d->setName("Toto"); + d->setInfoOnComponent(0,"X [m]"); + d->setInfoOnComponent(1,"Y [m]"); + d->setInfoOnComponent(2,"Z [m]"); + // + DataArrayDouble *d1=DataArrayDouble::New(); + CPPUNIT_ASSERT(!d->isEqual(*d1,1e-12)); + d1->cpyFrom(*d); + CPPUNIT_ASSERT(d->isEqual(*d1,1e-12)); + d1->cpyFrom(*d); + CPPUNIT_ASSERT(d->isEqual(*d1,1e-12)); + d1->rearrange(2); + CPPUNIT_ASSERT(!d->isEqual(*d1,1e-12)); + d1->cpyFrom(*d); + CPPUNIT_ASSERT(d->isEqual(*d1,1e-12)); + // + DataArrayInt *d2=d->convertToIntArr(); + DataArrayInt *d4=DataArrayInt::New(); + CPPUNIT_ASSERT(!d2->isEqual(*d4)); + d4->cpyFrom(*d2); + CPPUNIT_ASSERT(d2->isEqual(*d4)); + d4->cpyFrom(*d2); + CPPUNIT_ASSERT(d2->isEqual(*d4)); + d4->rearrange(2); + CPPUNIT_ASSERT(!d2->isEqual(*d4)); + d4->cpyFrom(*d2); + CPPUNIT_ASSERT(d2->isEqual(*d4)); + // + d->decrRef(); + d1->decrRef(); + d2->decrRef(); + d4->decrRef(); +} + +void MEDCouplingBasicsTest::testDAITransformWithIndArr1() +{ + const int tab1[4]={17,18,22,19}; + const int tab2[12]={0,1,1,3,3,0,1,3,2,2,3,0}; + const int expected[12]={17,18,18,19,19,17,18,19,22,22,19,17}; + DataArrayInt *d=DataArrayInt::New(); + d->alloc(4,1); + std::copy(tab1,tab1+4,d->getPointer()); + DataArrayInt *d1=DataArrayInt::New(); + d1->alloc(12,1); + std::copy(tab2,tab2+12,d1->getPointer()); + // + d1->transformWithIndArr(d->getConstPointer(),d->getConstPointer()+d->getNbOfElems()); + CPPUNIT_ASSERT_EQUAL(12,d1->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,d1->getNumberOfComponents()); + for(int i=0;i<12;i++) + CPPUNIT_ASSERT_EQUAL(expected[i],d1->getIJ(i,0)); + // + d->decrRef(); + d1->decrRef(); +} + +void MEDCouplingBasicsTest::testDAIBuildPermArrPerLevel1() +{ + const int arr[12]={2,0,1,1,0,1,2,0,1,1,0,0}; + const int expected1[12]={10,0,5,6,1,7,11,2,8,9,3,4}; + DataArrayInt *da=DataArrayInt::New(); + da->alloc(12,1); + std::copy(arr,arr+12,da->getPointer()); + DataArrayInt *da2=da->buildPermArrPerLevel(); + CPPUNIT_ASSERT_EQUAL(12,da2->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,da2->getNumberOfComponents()); + for(int i=0;i<12;i++) + CPPUNIT_ASSERT_EQUAL(expected1[i],da2->getIJ(i,0)); + da->decrRef(); + da2->decrRef(); +} + +void MEDCouplingBasicsTest::testDAIOperations1() +{ + const int arr1[12]={-1,-2,4,7,3,2,6,6,4,3,0,1}; + DataArrayInt *da=DataArrayInt::New(); + da->alloc(4,3); + std::copy(arr1,arr1+12,da->getPointer()); + DataArrayInt *da1=DataArrayInt::New(); + da1->alloc(12,1); + da1->iota(2); + CPPUNIT_ASSERT_THROW(DataArrayInt::Add(da,da1),INTERP_KERNEL::Exception);//not same number of tuples/Components + da1->rearrange(3); + DataArrayInt *da2=DataArrayInt::Add(da,da1); + CPPUNIT_ASSERT_EQUAL(4,da2->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(3,da2->getNumberOfComponents()); + const int expected1[12]={1,1,8,12,9,9,14,15,14,14,12,14}; + for(int i=0;i<12;i++) + CPPUNIT_ASSERT_EQUAL(expected1[i],da2->getIJ(0,i)); + da2->decrRef(); + da1->substractEqual(da); + const int expected2[12]={3,5,0,-2,3,5,2,3,6,8,12,12}; + for(int i=0;i<12;i++) + CPPUNIT_ASSERT_EQUAL(expected2[i],da1->getIJ(0,i)); + da1->rearrange(1); da1->iota(2); da1->rearrange(3); + da1->addEqual(da); + for(int i=0;i<12;i++) + CPPUNIT_ASSERT_EQUAL(expected1[i],da1->getIJ(0,i)); + da1->rearrange(1); da1->iota(2); da1->rearrange(3); + da2=DataArrayInt::Multiply(da,da1); + CPPUNIT_ASSERT_EQUAL(4,da2->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(3,da2->getNumberOfComponents()); + const int expected3[12]={-2,-6,16,35,18,14,48,54,40,33,0,13}; + for(int i=0;i<12;i++) + CPPUNIT_ASSERT_EQUAL(expected3[i],da2->getIJ(0,i)); + da2->decrRef(); + da->divideEqual(da1); + CPPUNIT_ASSERT_EQUAL(4,da->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(3,da->getNumberOfComponents()); + const int expected4[12]={0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0}; + for(int i=0;i<12;i++) + CPPUNIT_ASSERT_EQUAL(expected4[i],da->getIJ(0,i)); + std::copy(arr1,arr1+12,da->getPointer()); + da1->multiplyEqual(da); + CPPUNIT_ASSERT_EQUAL(4,da1->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(3,da1->getNumberOfComponents()); + for(int i=0;i<12;i++) + CPPUNIT_ASSERT_EQUAL(expected3[i],da1->getIJ(0,i)); + da1->rearrange(1); da1->iota(2); da1->rearrange(3); + da2=DataArrayInt::Divide(da,da1); + CPPUNIT_ASSERT_EQUAL(4,da2->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(3,da2->getNumberOfComponents()); + for(int i=0;i<12;i++) + CPPUNIT_ASSERT_EQUAL(expected4[i],da2->getIJ(0,i)); + da2->decrRef(); + da1->applyInv(321); + CPPUNIT_ASSERT_EQUAL(4,da1->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(3,da1->getNumberOfComponents()); + const int expected5[12]={160,107,80,64,53,45,40,35,32,29,26,24}; + for(int i=0;i<12;i++) + CPPUNIT_ASSERT_EQUAL(expected5[i],da1->getIJ(0,i)); + da1->applyDivideBy(2); + CPPUNIT_ASSERT_EQUAL(4,da1->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(3,da1->getNumberOfComponents()); + const int expected6[12]={80,53,40,32,26,22,20,17,16,14,13,12}; + for(int i=0;i<12;i++) + CPPUNIT_ASSERT_EQUAL(expected6[i],da1->getIJ(0,i)); + const int expected7[12]={3,4,5,4,5,1,6,3,2,0,6,5}; + da1->applyModulus(7); + for(int i=0;i<12;i++) + CPPUNIT_ASSERT_EQUAL(expected7[i],da1->getIJ(0,i)); + da1->applyLin(1,1); + const int expected8[12]={3,3,3,3,3,1,3,3,0,0,3,3}; + da1->applyRModulus(3); + for(int i=0;i<12;i++) + CPPUNIT_ASSERT_EQUAL(expected8[i],da1->getIJ(0,i)); + // + da1->decrRef(); + da->decrRef(); +} + +void MEDCouplingBasicsTest::testEmulateMEDMEMBDC1() +{ + MEDCouplingUMesh *m1=0; + MEDCouplingUMesh *m=buildPointe_1(m1); + DataArrayInt *da1=DataArrayInt::New(); + DataArrayInt *da2=DataArrayInt::New(); + DataArrayInt *da3=0; + DataArrayInt *da4=0; + DataArrayInt *da5=0; + DataArrayInt *da0=0; + MEDCouplingUMesh *m2=m->emulateMEDMEMBDC(m1,da1,da2,da3,da4,da5,da0); + const int 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 int expected1[6]={1,32,29,23,41,36}; + CPPUNIT_ASSERT_EQUAL(47,da0->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,da0->getNumberOfComponents()); + for(int i=0;i<47;i++) + CPPUNIT_ASSERT_EQUAL(expected0[i],da0->getIJ(0,i)); + CPPUNIT_ASSERT_EQUAL(6,da5->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,da5->getNumberOfComponents()); + for(int i=0;i<6;i++) + CPPUNIT_ASSERT_EQUAL(expected1[i],da5->getIJ(0,i)); + const int expected2[70]={0,1,2,3,4,0,5,6,7,4,8,9,1,7,10,11,12,13,14,5,15,16,17,8,18,19,20,10,21,22,23,2,13,24,25,21,16,26,27,12,19,28,29,15,22,30,31,18,36,26,28,30,24,37,32,33,34,35,38,36,39,40,41,42,37,38,43,44,45,46}; + CPPUNIT_ASSERT_EQUAL(70,da1->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,da1->getNumberOfComponents()); + for(int i=0;i<70;i++) + CPPUNIT_ASSERT_EQUAL(expected2[i],da1->getIJ(0,i)); + const int expected3[17]={0,4,8,12,16,20,24,28,32,36,40,44,48,53,58,64,70}; + CPPUNIT_ASSERT_EQUAL(17,da2->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,da2->getNumberOfComponents()); + for(int i=0;i<17;i++) + CPPUNIT_ASSERT_EQUAL(expected3[i],da2->getIJ(0,i)); + const int expected4[48]={0,2,4,6,7,9,11,12,14,16,17,19,20,22,24,25,27,29,30,32,34,35,37,39,40,42,43,45,46,48,49,51,52,53,54,55,56,58,60,62,63,64,65,66,67,68,69,70}; + //const int expected4[48]={0,2,4,6,7,9,11,12,14,16,17,19,20,22,24,25,27,29,30,32,34,35,37,39,40,42,43,45,46,48,49,51,52,54,56,57,58,59,60,62,63,64,65,66,67,68,69,70}; + CPPUNIT_ASSERT_EQUAL(48,da4->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,da4->getNumberOfComponents()); + for(int i=0;i<48;i++) + CPPUNIT_ASSERT_EQUAL(expected4[i],da4->getIJ(0,i)); + const int expected5[70]={0,1,0,3,0,7,0,1,2,1,4,1,2,3,2,5,2,3,6,3,4,9,4,8,4,5,10,5,9,5,6,11,6,10,6,7,8,7,11,7,8,12,8,9,12,9,10,12,10,11,12,11,13,13,13,13,12,14,13,15,14,15,14,14,14,14,15,15,15,15}; + CPPUNIT_ASSERT_EQUAL(70,da3->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,da3->getNumberOfComponents()); + for(int i=0;i<70;i++) + CPPUNIT_ASSERT_EQUAL(expected5[i],da3->getIJ(0,i)); + // + da0->decrRef(); + da1->decrRef(); + da2->decrRef(); + da3->decrRef(); + da4->decrRef(); + da5->decrRef(); + // + m2->decrRef(); + m1->decrRef(); + m->decrRef(); +} + +void MEDCouplingBasicsTest::testGetLevArrPerCellTypes1() +{ + MEDCouplingUMesh *m1=0; + MEDCouplingUMesh *m=buildPointe_1(m1); + m1->decrRef(); + DataArrayInt *d0=DataArrayInt::New(); + DataArrayInt *d1=DataArrayInt::New(); + DataArrayInt *d2=DataArrayInt::New(); + DataArrayInt *d3=DataArrayInt::New(); + 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}; + DataArrayInt *da1=0; + DataArrayInt *da0=m1->getLevArrPerCellTypes(order,order+2,da1); + const int 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 int 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}; + CPPUNIT_ASSERT_EQUAL(47,da0->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,da0->getNumberOfComponents()); + for(int i=0;i<47;i++) + CPPUNIT_ASSERT_EQUAL(expected0[i],da0->getIJ(0,i)); + CPPUNIT_ASSERT_EQUAL(2,da1->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,da1->getNumberOfComponents()); + CPPUNIT_ASSERT_EQUAL(36,da1->getIJ(0,0));//36 TRI3 + CPPUNIT_ASSERT_EQUAL(11,da1->getIJ(1,0));//11 QUAD4 + // + DataArrayInt *da2=da0->buildPermArrPerLevel(); + // + CPPUNIT_ASSERT_EQUAL(47,da2->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,da2->getNumberOfComponents()); + for(int i=0;i<47;i++) + CPPUNIT_ASSERT_EQUAL(expected1[i],da2->getIJ(0,i)); + da2->decrRef(); + da0->decrRef(); + da1->decrRef(); + // + m->decrRef(); + m1->decrRef(); +} + +void MEDCouplingBasicsTest::testSortCellsInMEDFileFrmt1() +{ + MEDCouplingUMesh *m1=0; + MEDCouplingUMesh *m=buildPointe_1(m1); + MEDCouplingUMesh *m2=(MEDCouplingUMesh *)m->deepCpy(); + m->setCoords(0); + const int vals[16]={0,1,2,14,3,12,4,5,15,6,7,8,9,10,11,13}; + DataArrayInt *da=DataArrayInt::New(); + da->alloc(16,1); + std::copy(vals,vals+16,da->getPointer()); + DataArrayInt *daa=da->invertArrayN2O2O2N(16); + m->renumberCells(daa->getConstPointer(),false); + daa->decrRef(); + DataArrayInt *da2=m->sortCellsInMEDFileFrmt(); + CPPUNIT_ASSERT(m2->isEqual(m2,1e-12)); + CPPUNIT_ASSERT(da->isEqual(*da2)); + m2->decrRef(); + da2->decrRef(); + da->decrRef(); + m1->decrRef(); + m->decrRef(); +} + +void MEDCouplingBasicsTest::testBuildPartAndReduceNodes1() +{ + MEDCouplingMesh *m=build2DTargetMesh_1(); + const int arr[2]={1,0}; + DataArrayInt *da; + MEDCouplingMesh *m2=m->buildPartAndReduceNodes(arr,arr+2,da); + CPPUNIT_ASSERT_EQUAL(5,m2->getNumberOfNodes()); + CPPUNIT_ASSERT_EQUAL(2,m2->getNumberOfCells()); + MEDCouplingFieldDouble *f=m2->getMeasureField(true); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,f->getArray()->getIJ(0,0),1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,f->getArray()->getIJ(1,0),1e-12); + f->decrRef(); + da->decrRef(); + m2->decrRef(); + m->decrRef(); +} + +void MEDCouplingBasicsTest::testDAITransformWithIndArrR1() +{ + const int tab1[6]={2,4,5,3,6,7}; + const int tab2[12]={-1,-1,0,1,2,3,4,5,-1,-1,-1,-1}; + const int expected[6]={0,3,1,2,4,5}; + DataArrayInt *d=DataArrayInt::New(); + d->alloc(6,1); + std::copy(tab1,tab1+6,d->getPointer()); + DataArrayInt *d1=DataArrayInt::New(); + d1->alloc(12,1); + std::copy(tab2,tab2+12,d1->getPointer()); + // + DataArrayInt *d3=d->transformWithIndArrR(d1->getConstPointer(),d1->getConstPointer()+d1->getNbOfElems()); + CPPUNIT_ASSERT_EQUAL(6,d3->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,d3->getNumberOfComponents()); + for(int i=0;i<6;i++) + CPPUNIT_ASSERT_EQUAL(expected[i],d3->getIJ(i,0)); + d3->decrRef(); + // + d->decrRef(); + d1->decrRef(); +} diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTestData1.hxx b/src/MEDCoupling/Test/MEDCouplingBasicsTestData1.hxx index 2f9cc17cf..ce11c4433 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTestData1.hxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTestData1.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // int 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, diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTestInterp.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTestInterp.cxx index b60b3e066..03984bc64 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTestInterp.cxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTestInterp.cxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "MEDCouplingBasicsTest.hxx" @@ -23,11 +23,11 @@ #include "MEDCouplingFieldDouble.hxx" #include "MEDCouplingMemArray.hxx" #include "Interpolation2D.txx" -#include "Interpolation3DSurf.txx" +#include "Interpolation3DSurf.hxx" #include "Interpolation3D.txx" #include "InterpolationCC.txx" #include "InterpolationCU.txx" -#include "Interpolation2DCurve.txx" +#include "Interpolation2DCurve.hxx" #include "Interpolation1D.txx" #include "MEDCouplingNormalizedUnstructuredMesh.txx" @@ -924,53 +924,59 @@ void MEDCouplingBasicsTest::test3DInterpP0P0_1() INTERP_KERNEL::Interpolation3D myInterpolator; std::vector > res; myInterpolator.setPrecision(1e-12); - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0"); - CPPUNIT_ASSERT_EQUAL(8,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(8.e6,sumAll(res),1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[0][0],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(41666.66666666667,res[0][6],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[0][7],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[0][8],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[0][10],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(41666.66666666667,res[1][2],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[1][7],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[1][8],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[2][0],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[2][5],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333333,res[2][6],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[2][9],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[2][11],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(395833.3333333333,res[3][0],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333333,res[3][2],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333331,res[3][3],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[3][5],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(395833.3333333333,res[3][8],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[4][1],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[4][4],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333333,res[4][6],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[4][9],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[4][10],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333333,res[5][2],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333331,res[5][3],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[5][4],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(395833.3333333333,res[5][7],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(395833.3333333333,res[5][10],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[6][1],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(250000,res[6][6],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(541666.6666666667,res[6][9],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[6][11],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(83333.33333333331,res[7][0],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(479166.6666666667,res[7][1],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(333333.3333333333,res[7][2],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(624999.9999999997,res[7][3],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(479166.6666666667,res[7][4],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(479166.6666666667,res[7][5],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(83333.33333333333,res[7][6],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(83333.33333333331,res[7][7],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(83333.33333333333,res[7][8],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(83333.33333333333,res[7][9],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(83333.33333333331,res[7][10],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(479166.6666666667,res[7][11],1e-7); + 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 ) + { + myInterpolator.setSplittingPolicy( sp[i] ); + res.clear(); + myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0"); + CPPUNIT_ASSERT_EQUAL(8,(int)res.size()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(8.e6,sumAll(res),1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[0][0],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(41666.66666666667,res[0][6],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[0][7],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[0][8],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[0][10],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(41666.66666666667,res[1][2],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[1][7],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[1][8],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[2][0],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[2][5],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333333,res[2][6],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[2][9],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[2][11],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(395833.3333333333,res[3][0],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333333,res[3][2],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333331,res[3][3],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[3][5],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(395833.3333333333,res[3][8],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[4][1],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[4][4],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333333,res[4][6],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[4][9],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[4][10],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333333,res[5][2],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333331,res[5][3],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[5][4],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(395833.3333333333,res[5][7],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(395833.3333333333,res[5][10],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[6][1],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(250000,res[6][6],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(541666.6666666667,res[6][9],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[6][11],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(83333.33333333331,res[7][0],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(479166.6666666667,res[7][1],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(333333.3333333333,res[7][2],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(624999.9999999997,res[7][3],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(479166.6666666667,res[7][4],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(479166.6666666667,res[7][5],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(83333.33333333333,res[7][6],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(83333.33333333331,res[7][7],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(83333.33333333333,res[7][8],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(83333.33333333333,res[7][9],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(83333.33333333331,res[7][10],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(479166.6666666667,res[7][11],1e-7); + } //clean up sourceMesh->decrRef(); targetMesh->decrRef(); @@ -987,30 +993,36 @@ void MEDCouplingBasicsTest::test3DInterpP0P0PL_1() std::vector > res; myInterpolator.setPrecision(1e-12); myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator); - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0"); - CPPUNIT_ASSERT_EQUAL(8,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][6],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][7],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][8],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][10],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][7],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][8],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][6],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][8],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][6],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][10],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][7],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][10],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][9],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][3],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][4],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][5],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][11],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(21.,sumAll(res),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 ) + { + myInterpolator.setSplittingPolicy( sp[i] ); + res.clear(); + myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0"); + CPPUNIT_ASSERT_EQUAL(8,(int)res.size()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][6],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][7],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][8],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][10],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][7],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][8],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][6],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][0],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][8],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][6],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][10],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][7],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][10],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][9],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][1],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][3],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][4],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][5],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][11],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(21.,sumAll(res),1e-12); + } //clean up sourceMesh->decrRef(); targetMesh->decrRef(); @@ -1031,30 +1043,36 @@ void MEDCouplingBasicsTest::test3DInterpP0P0PL_2() std::vector > res; myInterpolator.setPrecision(1e-12); myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator); - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0"); - CPPUNIT_ASSERT_EQUAL(8,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][6],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][7],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][8],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][10],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][7],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][8],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][6],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][8],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][6],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][10],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][7],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][10],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][9],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][3],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][4],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][5],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][11],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(21.,sumAll(res),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 ) + { + myInterpolator.setSplittingPolicy( sp[i] ); + res.clear(); + myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0"); + CPPUNIT_ASSERT_EQUAL(8,(int)res.size()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][6],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][7],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][8],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][10],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][7],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][8],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][6],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][0],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][8],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][6],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][10],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][7],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][10],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][9],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][1],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][3],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][4],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][5],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][11],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(21.,sumAll(res),1e-12); + } //clean up sourceMesh->decrRef(); targetMesh->decrRef(); @@ -1075,30 +1093,36 @@ void MEDCouplingBasicsTest::test3DInterpP0P0PL_3() std::vector > res; myInterpolator.setPrecision(1e-12); myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator); - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0"); - CPPUNIT_ASSERT_EQUAL(8,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][6],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][7],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][8],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][10],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][7],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][8],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][6],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][8],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][6],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][10],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][7],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][10],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][9],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][3],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][4],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][5],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][11],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(21.,sumAll(res),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 ) + { + myInterpolator.setSplittingPolicy( sp[i] ); + res.clear(); + myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0"); + CPPUNIT_ASSERT_EQUAL(8,(int)res.size()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][6],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][7],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][8],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][10],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][7],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][8],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][6],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][0],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][8],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][6],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][10],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][7],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][10],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][9],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][1],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][3],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][4],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][5],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][11],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(21.,sumAll(res),1e-12); + } //clean up sourceMesh->decrRef(); targetMesh->decrRef(); @@ -1123,30 +1147,36 @@ void MEDCouplingBasicsTest::test3DInterpP0P0PL_4() std::vector > res; myInterpolator.setPrecision(1e-12); myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator); - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0"); - CPPUNIT_ASSERT_EQUAL(8,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][6],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][7],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][8],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][10],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][7],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][8],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][6],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][8],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][6],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][10],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][7],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][10],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][9],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][3],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][4],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][5],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][11],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(21.,sumAll(res),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 ) + { + myInterpolator.setSplittingPolicy( sp[i] ); + res.clear(); + myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0"); + CPPUNIT_ASSERT_EQUAL(8,(int)res.size()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][6],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][7],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][8],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][10],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][7],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][8],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][6],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][0],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][8],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][6],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][10],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][7],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][10],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][9],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][1],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][3],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][4],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][5],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][11],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(21.,sumAll(res),1e-12); + } //clean up sourceMesh->decrRef(); targetMesh->decrRef(); @@ -1162,41 +1192,47 @@ void MEDCouplingBasicsTest::test3DInterpP0P1_1() INTERP_KERNEL::Interpolation3D myInterpolator; std::vector > res; myInterpolator.setPrecision(1e-12); - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P1"); - CPPUNIT_ASSERT_EQUAL(9,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(244444.4444444445,res[0][4],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333333,res[0][5],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(291666.6666666666,res[0][6],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[0][7],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(125000,res[1][0],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(140277.7777777778,res[1][1],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(119444.4444444444,res[1][2],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[1][3],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(119444.4444444444,res[1][4],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[1][5],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(26388.88888888889,res[1][6],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(348611.1111111111,res[2][6],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888888,res[2][7],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(244444.4444444444,res[3][2],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333334,res[3][3],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(291666.6666666666,res[3][6],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[3][7],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(536111.111111111,res[4][5],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(297222.2222222221,res[4][7],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(223611.1111111111,res[5][1],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(125000,res[5][3],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(125000,res[5][5],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(26388.88888888892,res[5][7],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[6][7],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(536111.1111111109,res[7][3],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(297222.2222222221,res[7][7],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(11111.1111111111,res[8][1],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(11111.11111111111,res[8][2],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666666,res[8][3],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(11111.11111111111,res[8][4],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[8][5],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[8][6],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1466666.666666668,res[8][7],1e-7); + 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 ) + { + myInterpolator.setSplittingPolicy( sp[i] ); + res.clear(); + myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P1"); + CPPUNIT_ASSERT_EQUAL(9,(int)res.size()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(244444.4444444445,res[0][4],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333333,res[0][5],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(291666.6666666666,res[0][6],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[0][7],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(125000,res[1][0],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(140277.7777777778,res[1][1],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(119444.4444444444,res[1][2],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[1][3],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(119444.4444444444,res[1][4],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[1][5],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(26388.88888888889,res[1][6],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(348611.1111111111,res[2][6],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888888,res[2][7],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(244444.4444444444,res[3][2],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333334,res[3][3],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(291666.6666666666,res[3][6],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[3][7],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(536111.111111111,res[4][5],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(297222.2222222221,res[4][7],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(223611.1111111111,res[5][1],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(125000,res[5][3],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(125000,res[5][5],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(26388.88888888892,res[5][7],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[6][7],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(536111.1111111109,res[7][3],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(297222.2222222221,res[7][7],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(11111.1111111111,res[8][1],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(11111.11111111111,res[8][2],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666666,res[8][3],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(11111.11111111111,res[8][4],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[8][5],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[8][6],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1466666.666666668,res[8][7],1e-7); + } //clean up sourceMesh->decrRef(); targetMesh->decrRef(); @@ -1213,18 +1249,24 @@ void MEDCouplingBasicsTest::test3DInterpP0P1PL_1() std::vector > res; myInterpolator.setPrecision(1e-12); myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator); - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P1"); - CPPUNIT_ASSERT_EQUAL(9,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][4],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][6],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][2],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][5],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][7],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][3],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[8][7],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(9.,sumAll(res),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 ) + { + myInterpolator.setSplittingPolicy( sp[i] ); + res.clear(); + myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P1"); + CPPUNIT_ASSERT_EQUAL(9,(int)res.size()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][4],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][0],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][6],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][2],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][5],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][1],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][7],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][3],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[8][7],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(9.,sumAll(res),1e-12); + } //clean up sourceMesh->decrRef(); targetMesh->decrRef(); @@ -1240,41 +1282,47 @@ void MEDCouplingBasicsTest::test3DInterpP1P0_1() INTERP_KERNEL::Interpolation3D myInterpolator; std::vector > res; myInterpolator.setPrecision(1e-12); - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0"); - CPPUNIT_ASSERT_EQUAL(8,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(125000,res[0][1],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(140277.7777777778,res[1][1],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(223611.1111111111,res[1][5],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(11111.1111111111,res[1][8],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(119444.4444444444,res[2][1],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(244444.4444444445,res[2][3],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(11111.11111111111,res[2][8],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[3][1],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333333,res[3][3],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(125000,res[3][5],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(536111.1111111109,res[3][7],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[3][8],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(244444.4444444445,res[4][0],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(119444.4444444445,res[4][1],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(11111.11111111111,res[4][8],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333333,res[5][0],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[5][1],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(536111.1111111109,res[5][4],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(125000,res[5][5],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666666,res[5][8],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(291666.6666666666,res[6][0],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(26388.88888888889,res[6][1],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(348611.1111111112,res[6][2],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(291666.6666666667,res[6][3],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666666,res[6][8],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[7][0],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[7][2],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[7][3],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(297222.2222222221,res[7][4],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(26388.88888888892,res[7][5],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[7][6],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(297222.2222222222,res[7][7],1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1466666.666666668,res[7][8],1e-7); + 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 ) + { + myInterpolator.setSplittingPolicy( sp[i] ); + res.clear(); + myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0"); + CPPUNIT_ASSERT_EQUAL(8,(int)res.size()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(125000,res[0][1],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(140277.7777777778,res[1][1],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(223611.1111111111,res[1][5],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(11111.1111111111,res[1][8],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(119444.4444444444,res[2][1],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(244444.4444444445,res[2][3],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(11111.11111111111,res[2][8],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[3][1],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333333,res[3][3],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(125000,res[3][5],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(536111.1111111109,res[3][7],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[3][8],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(244444.4444444445,res[4][0],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(119444.4444444445,res[4][1],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(11111.11111111111,res[4][8],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333333,res[5][0],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[5][1],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(536111.1111111109,res[5][4],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(125000,res[5][5],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666666,res[5][8],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(291666.6666666666,res[6][0],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(26388.88888888889,res[6][1],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(348611.1111111112,res[6][2],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(291666.6666666667,res[6][3],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666666,res[6][8],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[7][0],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[7][2],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[7][3],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(297222.2222222221,res[7][4],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(26388.88888888892,res[7][5],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[7][6],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(297222.2222222222,res[7][7],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1466666.666666668,res[7][8],1e-7); + } //clean up sourceMesh->decrRef(); targetMesh->decrRef(); @@ -1291,32 +1339,38 @@ void MEDCouplingBasicsTest::test3DInterpP1P0PL_1() std::vector > res; myInterpolator.setPrecision(1e-12); myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator); - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0"); - CPPUNIT_ASSERT_EQUAL(8,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(3.75,res[0][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.25,res[0][8],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[1][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][5],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[1][8],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[2][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][3],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[2][8],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[3][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][7],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[3][8],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[4][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[4][8],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[5][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][4],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[5][8],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[6][0],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[6][2],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[6][3],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[6][8],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.25,res[7][6],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(3.75,res[7][8],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(21.,sumAll(res),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 ) + { + myInterpolator.setSplittingPolicy( sp[i] ); + res.clear(); + myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0"); + CPPUNIT_ASSERT_EQUAL(8,(int)res.size()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(3.75,res[0][1],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.25,res[0][8],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[1][1],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][5],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[1][8],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[2][1],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][3],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[2][8],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[3][1],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][7],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[3][8],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][0],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[4][1],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[4][8],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[5][1],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][4],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[5][8],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[6][0],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[6][2],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[6][3],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[6][8],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1.25,res[7][6],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(3.75,res[7][8],1e-12); + CPPUNIT_ASSERT_DOUBLES_EQUAL(21.,sumAll(res),1e-12); + } //clean up sourceMesh->decrRef(); targetMesh->decrRef(); diff --git a/src/MEDCoupling/Test/MEDCouplingRemapperTest.cxx b/src/MEDCoupling/Test/MEDCouplingRemapperTest.cxx index 1050f75ce..930b561ea 100644 --- a/src/MEDCoupling/Test/MEDCouplingRemapperTest.cxx +++ b/src/MEDCoupling/Test/MEDCouplingRemapperTest.cxx @@ -1,26 +1,27 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "MEDCouplingRemapperTest.hxx" #include "MEDCouplingUMesh.hxx" #include "MEDCouplingExtrudedMesh.hxx" #include "MEDCouplingFieldDouble.hxx" +#include "MEDCouplingFieldTemplate.hxx" #include "MEDCouplingMemArray.hxx" #include "MEDCouplingRemapper.hxx" @@ -982,6 +983,44 @@ void MEDCouplingRemapperTest::testExtruded2() meshTF->decrRef(); } +void MEDCouplingRemapperTest::testPrepareEx1() +{ + MEDCouplingUMesh *sourceMesh=MEDCouplingBasicsTest::build2DSourceMesh_1(); + MEDCouplingUMesh *targetMesh=build2DTargetMesh_3(); + // + MEDCouplingRemapper remapper; + remapper.setPrecision(1e-12); + remapper.setIntersectionType(INTERP_KERNEL::Triangulation); + MEDCouplingFieldTemplate *srcFt=MEDCouplingFieldTemplate::New(ON_CELLS); + MEDCouplingFieldTemplate *trgFt=MEDCouplingFieldTemplate::New(ON_CELLS); + srcFt->setMesh(sourceMesh); + trgFt->setMesh(targetMesh); + CPPUNIT_ASSERT_EQUAL(1,remapper.prepareEx(srcFt,trgFt)); + srcFt->decrRef(); + trgFt->decrRef(); + MEDCouplingFieldDouble *srcField=MEDCouplingFieldDouble::New(ON_CELLS); + srcField->setNature(ConservativeVolumic); + srcField->setMesh(sourceMesh); + DataArrayDouble *array=DataArrayDouble::New(); + array->alloc(sourceMesh->getNumberOfCells(),1); + srcField->setArray(array); + double *ptr=array->getPointer(); + for(int i=0;igetNumberOfCells();i++) + ptr[i]=(double)(i+7); + array->decrRef(); + MEDCouplingFieldDouble *trgfield=remapper.transferField(srcField,4.220173); + const double *values=trgfield->getArray()->getConstPointer(); + const double valuesExpected[4]={7.75, 7.0625, 4.220173,8.0}; + CPPUNIT_ASSERT_EQUAL(4,trgfield->getArray()->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,trgfield->getArray()->getNumberOfComponents()); + for(int i0=0;i0<4;i0++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesExpected[i0],values[i0],1e-12); + trgfield->decrRef(); + srcField->decrRef(); + sourceMesh->decrRef(); + targetMesh->decrRef(); +} + MEDCouplingUMesh *MEDCouplingRemapperTest::build1DTargetMesh_2() { double targetCoords[20]={ diff --git a/src/MEDCoupling/Test/MEDCouplingRemapperTest.hxx b/src/MEDCoupling/Test/MEDCouplingRemapperTest.hxx index 2b45b4b06..5085cda9a 100644 --- a/src/MEDCoupling/Test/MEDCouplingRemapperTest.hxx +++ b/src/MEDCoupling/Test/MEDCouplingRemapperTest.hxx @@ -1,20 +1,20 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef __MEDCOUPLINGREMAPPERTEST_HXX__ @@ -40,6 +40,7 @@ namespace ParaMEDMEM CPPUNIT_TEST( testNatureOfField ); CPPUNIT_TEST( testExtruded ); CPPUNIT_TEST( testExtruded2 ); + CPPUNIT_TEST( testPrepareEx1 ); CPPUNIT_TEST_SUITE_END(); public: void test2DInterpP0P0_1(); @@ -50,6 +51,7 @@ namespace ParaMEDMEM void testNatureOfField(); void testExtruded(); void testExtruded2(); + void testPrepareEx1(); private: static MEDCouplingUMesh *build1DTargetMesh_2(); static MEDCouplingUMesh *build2DTargetMesh_3(); diff --git a/src/MEDCoupling/Test/Makefile.am b/src/MEDCoupling/Test/Makefile.am index bab460971..1297cde3a 100755 --- a/src/MEDCoupling/Test/Makefile.am +++ b/src/MEDCoupling/Test/Makefile.am @@ -1,20 +1,20 @@ -# Copyright (C) 2007-2010 CEA/DEN, EDF R&D +# Copyright (C) 2007-2011 CEA/DEN, EDF R&D # -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. # -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. # -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # include $(top_srcdir)/adm_local/unix/make_common_starter.am @@ -26,11 +26,12 @@ TestMEDCoupling_CPPFLAGS=@CPPUNIT_INCLUDES@ @PTHREAD_CFLAGS@ -I$(srcdir)/.. -I$( TestMEDCoupling_LDFLAGS = @CPPUNIT_LIBS@ ../libmedcoupling.la ../../INTERP_KERNEL/libinterpkernel.la dist_TestMEDCoupling_SOURCES = TestMEDCoupling.cxx MEDCouplingBasicsTest.hxx MEDCouplingBasicsTest0.cxx MEDCouplingBasicsTest1.cxx \ - MEDCouplingBasicsTest2.cxx MEDCouplingBasicsTestInterp.cxx MEDCouplingBasicsTestData1.hxx + MEDCouplingBasicsTest2.cxx MEDCouplingBasicsTest3.cxx MEDCouplingBasicsTestInterp.cxx MEDCouplingBasicsTestData1.hxx \ + MEDCouplingBasicsTest4.cxx TestMEDCouplingRemapper_CPPFLAGS=@CPPUNIT_INCLUDES@ @PTHREAD_CFLAGS@ -I$(srcdir)/.. -I$(srcdir)/../../INTERP_KERNEL/Bases -I$(srcdir)/../../INTERP_KERNELTest -I$(srcdir)/../../INTERP_KERNEL -I$(srcdir)/../../INTERP_KERNEL/Geometric2D -TestMEDCouplingRemapper_LDFLAGS = @CPPUNIT_LIBS@ ../libmedcouplingremapper.la ../../INTERP_KERNEL/libinterpkernel.la +TestMEDCouplingRemapper_LDFLAGS = @CPPUNIT_LIBS@ ../libmedcouplingremapper.la ../../INTERP_KERNEL/libinterpkernel.la ../libmedcoupling.la dist_TestMEDCouplingRemapper_SOURCES = TestMEDCouplingRemapper.cxx MEDCouplingRemapperTest.hxx MEDCouplingRemapperTest.cxx MEDCouplingBasicsTest0.cxx @@ -40,4 +41,3 @@ check : tests CLEANFILES = \ UnitTestsResult - \ No newline at end of file diff --git a/src/MEDCoupling/Test/TestMEDCoupling.cxx b/src/MEDCoupling/Test/TestMEDCoupling.cxx index 84813ca08..a2008a6a0 100644 --- a/src/MEDCoupling/Test/TestMEDCoupling.cxx +++ b/src/MEDCoupling/Test/TestMEDCoupling.cxx @@ -1,23 +1,22 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -#include "CppUnitTest.hxx" #include "MEDCouplingBasicsTest.hxx" CPPUNIT_TEST_SUITE_REGISTRATION( ParaMEDMEM::MEDCouplingBasicsTest ); diff --git a/src/MEDCoupling/Test/TestMEDCouplingRemapper.cxx b/src/MEDCoupling/Test/TestMEDCouplingRemapper.cxx index 80b233001..007041a5f 100644 --- a/src/MEDCoupling/Test/TestMEDCouplingRemapper.cxx +++ b/src/MEDCoupling/Test/TestMEDCouplingRemapper.cxx @@ -1,23 +1,22 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -#include "CppUnitTest.hxx" #include "MEDCouplingRemapperTest.hxx" CPPUNIT_TEST_SUITE_REGISTRATION( ParaMEDMEM::MEDCouplingRemapperTest ); diff --git a/src/MEDCoupling_Swig/MEDCoupling.i b/src/MEDCoupling_Swig/MEDCoupling.i new file mode 100644 index 000000000..eea5b04e0 --- /dev/null +++ b/src/MEDCoupling_Swig/MEDCoupling.i @@ -0,0 +1,4244 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +%module MEDCoupling + +#define MEDCOUPLING_EXPORT + +%include std_vector.i +%include std_string.i + +%{ +#include "MEDCouplingMemArray.hxx" +#include "MEDCouplingUMesh.hxx" +#include "MEDCouplingExtrudedMesh.hxx" +#include "MEDCouplingCMesh.hxx" +#include "MEDCouplingField.hxx" +#include "MEDCouplingFieldDouble.hxx" +#include "MEDCouplingFieldTemplate.hxx" +#include "MEDCouplingGaussLocalization.hxx" +#include "MEDCouplingAutoRefCountObjectPtr.hxx" +#include "MEDCouplingMultiFields.hxx" +#include "MEDCouplingFieldOverTime.hxx" +#include "MEDCouplingDefinitionTime.hxx" +#include "MEDCouplingTypemaps.i" + +#include "InterpKernelAutoPtr.hxx" + +using namespace ParaMEDMEM; +using namespace INTERP_KERNEL; +%} + +%template(ivec) std::vector; +%template(dvec) std::vector; +%template(svec) std::vector; + +%typemap(out) ParaMEDMEM::MEDCouplingMesh* +{ + $result=convertMesh($1,$owner); +} + +%typemap(out) ParaMEDMEM::MEDCouplingPointSet* +{ + $result=convertMesh($1,$owner); +} + +%typemap(out) ParaMEDMEM::MEDCouplingMultiFields* +{ + $result=convertMultiFields($1,$owner); +} + +#ifdef WITH_NUMPY2 +%init %{ import_array(); %} +#endif + +%feature("autodoc", "1"); +%feature("docstring"); + +%newobject ParaMEDMEM::MEDCouplingFieldDiscretization::getOffsetArr; +%newobject ParaMEDMEM::MEDCouplingField::buildMeasureField; +%newobject ParaMEDMEM::MEDCouplingField::getLocalizationOfDiscr; +%newobject ParaMEDMEM::MEDCouplingFieldDouble::New; +%newobject ParaMEDMEM::MEDCouplingFieldDouble::getArray; +%newobject ParaMEDMEM::MEDCouplingFieldDouble::getEndArray; +%newobject ParaMEDMEM::MEDCouplingFieldDouble::MergeFields; +%newobject ParaMEDMEM::MEDCouplingFieldDouble::MeldFields; +%newobject ParaMEDMEM::MEDCouplingFieldDouble::doublyContractedProduct; +%newobject ParaMEDMEM::MEDCouplingFieldDouble::determinant; +%newobject ParaMEDMEM::MEDCouplingFieldDouble::eigenValues; +%newobject ParaMEDMEM::MEDCouplingFieldDouble::eigenVectors; +%newobject ParaMEDMEM::MEDCouplingFieldDouble::inverse; +%newobject ParaMEDMEM::MEDCouplingFieldDouble::trace; +%newobject ParaMEDMEM::MEDCouplingFieldDouble::deviator; +%newobject ParaMEDMEM::MEDCouplingFieldDouble::magnitude; +%newobject ParaMEDMEM::MEDCouplingFieldDouble::maxPerTuple; +%newobject ParaMEDMEM::MEDCouplingFieldDouble::keepSelectedComponents; +%newobject ParaMEDMEM::MEDCouplingFieldDouble::DotFields; +%newobject ParaMEDMEM::MEDCouplingFieldDouble::dot; +%newobject ParaMEDMEM::MEDCouplingFieldDouble::CrossProductFields; +%newobject ParaMEDMEM::MEDCouplingFieldDouble::crossProduct; +%newobject ParaMEDMEM::MEDCouplingFieldDouble::MaxFields; +%newobject ParaMEDMEM::MEDCouplingFieldDouble::max; +%newobject ParaMEDMEM::MEDCouplingFieldDouble::MinFields; +%newobject ParaMEDMEM::MEDCouplingFieldDouble::AddFields; +%newobject ParaMEDMEM::MEDCouplingFieldDouble::SubstractFields; +%newobject ParaMEDMEM::MEDCouplingFieldDouble::MultiplyFields; +%newobject ParaMEDMEM::MEDCouplingFieldDouble::DivideFields; +%newobject ParaMEDMEM::MEDCouplingFieldDouble::min; +%newobject ParaMEDMEM::MEDCouplingFieldDouble::getIdsInRange; +%newobject ParaMEDMEM::MEDCouplingFieldDouble::buildSubPart; +%newobject ParaMEDMEM::MEDCouplingFieldDouble::operator+; +%newobject ParaMEDMEM::MEDCouplingFieldDouble::operator-; +%newobject ParaMEDMEM::MEDCouplingFieldDouble::operator*; +%newobject ParaMEDMEM::MEDCouplingFieldDouble::operator/; +%newobject ParaMEDMEM::MEDCouplingFieldDouble::clone; +%newobject ParaMEDMEM::MEDCouplingFieldDouble::cloneWithMesh; +%newobject ParaMEDMEM::MEDCouplingFieldDouble::deepCpy; +%newobject ParaMEDMEM::MEDCouplingFieldDouble::buildNewTimeReprFromThis; +%newobject ParaMEDMEM::MEDCouplingFieldDouble::getValueOnMulti; +%newobject ParaMEDMEM::MEDCouplingFieldTemplate::New; +%newobject ParaMEDMEM::DataArrayInt::New; +%newobject ParaMEDMEM::DataArrayInt::convertToDblArr; +%newobject ParaMEDMEM::DataArrayInt::deepCpy; +%newobject ParaMEDMEM::DataArrayInt::performCpy; +%newobject ParaMEDMEM::DataArrayInt::substr; +%newobject ParaMEDMEM::DataArrayInt::changeNbOfComponents; +%newobject ParaMEDMEM::DataArrayInt::keepSelectedComponents; +%newobject ParaMEDMEM::DataArrayInt::selectByTupleId; +%newobject ParaMEDMEM::DataArrayInt::selectByTupleIdSafe; +%newobject ParaMEDMEM::DataArrayInt::selectByTupleId2; +%newobject ParaMEDMEM::DataArrayInt::checkAndPreparePermutation; +%newobject ParaMEDMEM::DataArrayInt::transformWithIndArrR; +%newobject ParaMEDMEM::DataArrayInt::renumber; +%newobject ParaMEDMEM::DataArrayInt::renumberR; +%newobject ParaMEDMEM::DataArrayInt::renumberAndReduce; +%newobject ParaMEDMEM::DataArrayInt::invertArrayO2N2N2O; +%newobject ParaMEDMEM::DataArrayInt::invertArrayN2O2O2N; +%newobject ParaMEDMEM::DataArrayInt::getIdsEqual; +%newobject ParaMEDMEM::DataArrayInt::getIdsNotEqual; +%newobject ParaMEDMEM::DataArrayInt::getIdsEqualList; +%newobject ParaMEDMEM::DataArrayInt::getIdsNotEqualList; +%newobject ParaMEDMEM::DataArrayInt::Aggregate; +%newobject ParaMEDMEM::DataArrayInt::Meld; +%newobject ParaMEDMEM::DataArrayInt::Add; +%newobject ParaMEDMEM::DataArrayInt::Substract; +%newobject ParaMEDMEM::DataArrayInt::Multiply; +%newobject ParaMEDMEM::DataArrayInt::Divide; +%newobject ParaMEDMEM::DataArrayInt::BuildUnion; +%newobject ParaMEDMEM::DataArrayInt::BuildIntersection; +%newobject ParaMEDMEM::DataArrayInt::fromNoInterlace; +%newobject ParaMEDMEM::DataArrayInt::toNoInterlace; +%newobject ParaMEDMEM::DataArrayInt::buildComplement; +%newobject ParaMEDMEM::DataArrayInt::buildUnion; +%newobject ParaMEDMEM::DataArrayInt::buildSubstraction; +%newobject ParaMEDMEM::DataArrayInt::buildIntersection; +%newobject ParaMEDMEM::DataArrayInt::deltaShiftIndex; +%newobject ParaMEDMEM::DataArrayInt::buildPermutationArr; +%newobject ParaMEDMEM::DataArrayInt::buildPermArrPerLevel; +%newobject ParaMEDMEM::DataArrayInt::__getitem__; +%newobject ParaMEDMEM::DataArrayInt::__add__; +%newobject ParaMEDMEM::DataArrayInt::__radd__; +%newobject ParaMEDMEM::DataArrayInt::__sub__; +%newobject ParaMEDMEM::DataArrayInt::__rsub__; +%newobject ParaMEDMEM::DataArrayInt::__mul__; +%newobject ParaMEDMEM::DataArrayInt::__rmul__; +%newobject ParaMEDMEM::DataArrayInt::__div__; +%newobject ParaMEDMEM::DataArrayInt::__rdiv__; +%newobject ParaMEDMEM::DataArrayInt::__mod__; +%newobject ParaMEDMEM::DataArrayInt::__rmod__; +%newobject ParaMEDMEM::DataArrayDouble::New; +%newobject ParaMEDMEM::DataArrayDouble::convertToIntArr; +%newobject ParaMEDMEM::DataArrayDouble::deepCpy; +%newobject ParaMEDMEM::DataArrayDouble::performCpy; +%newobject ParaMEDMEM::DataArrayDouble::Aggregate; +%newobject ParaMEDMEM::DataArrayDouble::Meld; +%newobject ParaMEDMEM::DataArrayDouble::Dot; +%newobject ParaMEDMEM::DataArrayDouble::CrossProduct; +%newobject ParaMEDMEM::DataArrayDouble::Add; +%newobject ParaMEDMEM::DataArrayDouble::Substract; +%newobject ParaMEDMEM::DataArrayDouble::Multiply; +%newobject ParaMEDMEM::DataArrayDouble::Divide; +%newobject ParaMEDMEM::DataArrayDouble::substr; +%newobject ParaMEDMEM::DataArrayDouble::changeNbOfComponents; +%newobject ParaMEDMEM::DataArrayDouble::keepSelectedComponents; +%newobject ParaMEDMEM::DataArrayDouble::getIdsInRange; +%newobject ParaMEDMEM::DataArrayDouble::selectByTupleId; +%newobject ParaMEDMEM::DataArrayDouble::selectByTupleIdSafe; +%newobject ParaMEDMEM::DataArrayDouble::selectByTupleId2; +%newobject ParaMEDMEM::DataArrayDouble::applyFunc; +%newobject ParaMEDMEM::DataArrayDouble::applyFunc2; +%newobject ParaMEDMEM::DataArrayDouble::applyFunc3; +%newobject ParaMEDMEM::DataArrayDouble::doublyContractedProduct; +%newobject ParaMEDMEM::DataArrayDouble::determinant; +%newobject ParaMEDMEM::DataArrayDouble::eigenValues; +%newobject ParaMEDMEM::DataArrayDouble::eigenVectors; +%newobject ParaMEDMEM::DataArrayDouble::inverse; +%newobject ParaMEDMEM::DataArrayDouble::trace; +%newobject ParaMEDMEM::DataArrayDouble::deviator; +%newobject ParaMEDMEM::DataArrayDouble::magnitude; +%newobject ParaMEDMEM::DataArrayDouble::maxPerTuple; +%newobject ParaMEDMEM::DataArrayDouble::renumber; +%newobject ParaMEDMEM::DataArrayDouble::renumberR; +%newobject ParaMEDMEM::DataArrayDouble::renumberAndReduce; +%newobject ParaMEDMEM::DataArrayDouble::fromNoInterlace; +%newobject ParaMEDMEM::DataArrayDouble::toNoInterlace; +%newobject ParaMEDMEM::DataArrayDouble::fromPolarToCart; +%newobject ParaMEDMEM::DataArrayDouble::fromCylToCart; +%newobject ParaMEDMEM::DataArrayDouble::fromSpherToCart; +%newobject ParaMEDMEM::DataArrayDouble::__getitem__; +%newobject ParaMEDMEM::DataArrayDouble::__add__; +%newobject ParaMEDMEM::DataArrayDouble::__radd__; +%newobject ParaMEDMEM::DataArrayDouble::__sub__; +%newobject ParaMEDMEM::DataArrayDouble::__rsub__; +%newobject ParaMEDMEM::DataArrayDouble::__mul__; +%newobject ParaMEDMEM::DataArrayDouble::__rmul__; +%newobject ParaMEDMEM::DataArrayDouble::__div__; +%newobject ParaMEDMEM::DataArrayDouble::__rdiv__; +%newobject ParaMEDMEM::MEDCouplingMesh::deepCpy; +%newobject ParaMEDMEM::MEDCouplingMesh::checkTypeConsistencyAndContig; +%newobject ParaMEDMEM::MEDCouplingMesh::getCoordinatesAndOwner; +%newobject ParaMEDMEM::MEDCouplingMesh::getBarycenterAndOwner; +%newobject ParaMEDMEM::MEDCouplingMesh::buildOrthogonalField; +%newobject ParaMEDMEM::MEDCouplingMesh::getCellIdsFullyIncludedInNodeIds; +%newobject ParaMEDMEM::MEDCouplingMesh::mergeMyselfWith; +%newobject ParaMEDMEM::MEDCouplingMesh::fillFromAnalytic; +%newobject ParaMEDMEM::MEDCouplingMesh::fillFromAnalytic2; +%newobject ParaMEDMEM::MEDCouplingMesh::fillFromAnalytic3; +%newobject ParaMEDMEM::MEDCouplingMesh::getMeasureField; +%newobject ParaMEDMEM::MEDCouplingMesh::simplexize; +%newobject ParaMEDMEM::MEDCouplingMesh::buildUnstructured; +%newobject ParaMEDMEM::MEDCouplingMesh::MergeMeshes; +%newobject ParaMEDMEM::MEDCouplingPointSet::zipCoordsTraducer; +%newobject ParaMEDMEM::MEDCouplingPointSet::buildBoundaryMesh; +%newobject ParaMEDMEM::MEDCouplingPointSet::MergeNodesArray; +%newobject ParaMEDMEM::MEDCouplingPointSet::BuildInstanceFromMeshType; +%newobject ParaMEDMEM::MEDCouplingUMesh::New; +%newobject ParaMEDMEM::MEDCouplingUMesh::getNodalConnectivity; +%newobject ParaMEDMEM::MEDCouplingUMesh::getNodalConnectivityIndex; +%newobject ParaMEDMEM::MEDCouplingUMesh::clone; +%newobject ParaMEDMEM::MEDCouplingUMesh::zipConnectivityTraducer; +%newobject ParaMEDMEM::MEDCouplingUMesh::buildDescendingConnectivity; +%newobject ParaMEDMEM::MEDCouplingUMesh::buildExtrudedMesh; +%newobject ParaMEDMEM::MEDCouplingUMesh::MergeUMeshes; +%newobject ParaMEDMEM::MEDCouplingUMesh::MergeUMeshesOnSameCoords; +%newobject ParaMEDMEM::MEDCouplingUMesh::buildNewNumberingFromCommNodesFrmt; +%newobject ParaMEDMEM::MEDCouplingUMesh::rearrange2ConsecutiveCellTypes; +%newobject ParaMEDMEM::MEDCouplingUMesh::sortCellsInMEDFileFrmt; +%newobject ParaMEDMEM::MEDCouplingUMesh::convertCellArrayPerGeoType; +%newobject ParaMEDMEM::MEDCouplingUMesh::getRenumArrForConsecutiveCellTypesSpec; +%newobject ParaMEDMEM::MEDCouplingUMesh::buildDirectionVectorField; +%newobject ParaMEDMEM::MEDCouplingUMesh::getEdgeRatioField; +%newobject ParaMEDMEM::MEDCouplingUMesh::getAspectRatioField; +%newobject ParaMEDMEM::MEDCouplingUMesh::getWarpField; +%newobject ParaMEDMEM::MEDCouplingUMesh::getSkewField; +%newobject ParaMEDMEM::MEDCouplingUMesh::getPartBarycenterAndOwner; +%newobject ParaMEDMEM::MEDCouplingUMesh::getPartMeasureField; +%newobject ParaMEDMEM::MEDCouplingUMesh::buildPartOrthogonalField; +%newobject ParaMEDMEM::MEDCouplingUMesh::keepCellIdsByType; +%newobject ParaMEDMEM::MEDCouplingUMesh::Build0DMeshFromCoords; +%newobject ParaMEDMEM::MEDCouplingUMesh::findCellsIdsOnBoundary; +%newobject ParaMEDMEM::MEDCouplingUMesh::getCellIdsLyingOnNodes; +%newobject ParaMEDMEM::MEDCouplingExtrudedMesh::New; +%newobject ParaMEDMEM::MEDCouplingExtrudedMesh::build3DUnstructuredMesh; +%newobject ParaMEDMEM::MEDCouplingCMesh::New; +%newobject ParaMEDMEM::MEDCouplingCMesh::getCoordsAt; +%newobject ParaMEDMEM::MEDCouplingMultiFields::New; +%newobject ParaMEDMEM::MEDCouplingMultiFields::deepCpy; +%newobject ParaMEDMEM::MEDCouplingFieldOverTime::New; + +%feature("unref") DataArrayDouble "$this->decrRef();" +%feature("unref") MEDCouplingPointSet "$this->decrRef();" +%feature("unref") MEDCouplingMesh "$this->decrRef();" +%feature("unref") MEDCouplingUMesh "$this->decrRef();" +%feature("unref") MEDCouplingExtrudedMesh "$this->decrRef();" +%feature("unref") MEDCouplingCMesh "$this->decrRef();" +%feature("unref") DataArrayInt "$this->decrRef();" +%feature("unref") MEDCouplingField "$this->decrRef();" +%feature("unref") MEDCouplingFieldDouble "$this->decrRef();" +%feature("unref") MEDCouplingMultiFields "$this->decrRef();" + +%rename(assign) *::operator=; +%ignore ParaMEDMEM::MemArray::operator=; +%ignore ParaMEDMEM::MemArray::operator[]; +%ignore ParaMEDMEM::MEDCouplingGaussLocalization::pushTinySerializationIntInfo; +%ignore ParaMEDMEM::MEDCouplingGaussLocalization::pushTinySerializationDblInfo; +%ignore ParaMEDMEM::MEDCouplingGaussLocalization::fillWithValues; +%ignore ParaMEDMEM::MEDCouplingGaussLocalization::buildNewInstanceFromTinyInfo; + +%nodefaultctor; + +%rename (InterpKernelException) INTERP_KERNEL::Exception; + +namespace INTERP_KERNEL +{ + class Exception + { + public: + Exception(const char* what); + ~Exception() throw (); + const char *what() const throw (); + }; +} + +%include "MEDCouplingTimeLabel.hxx" +%include "MEDCouplingRefCountObject.hxx" + +namespace ParaMEDMEM +{ + typedef enum + { + UNSTRUCTURED = 5, + UNSTRUCTURED_DESC = 6, + CARTESIAN = 7, + EXTRUDED = 8 + } MEDCouplingMeshType; + + class DataArrayInt; + class DataArrayDouble; + class MEDCouplingUMesh; + class MEDCouplingFieldDouble; + + %extend RefCountObject + { + std::string getHiddenCppPointer() const + { + std::ostringstream oss; oss << "C++ Pointer address is : " << self; + return oss.str(); + } + } + + class MEDCouplingMesh : public RefCountObject, public TimeLabel + { + public: + void setName(const char *name); + const char *getName() const; + void setDescription(const char *descr); + const char *getDescription() const; + void setTime(double val, int iteration, int order); + void setTimeUnit(const char *unit); + const char *getTimeUnit() const; + virtual MEDCouplingMeshType getType() const throw(INTERP_KERNEL::Exception) = 0; + bool isStructured() const throw(INTERP_KERNEL::Exception); + virtual MEDCouplingMesh *deepCpy() const = 0; + virtual bool isEqual(const MEDCouplingMesh *other, double prec) const throw(INTERP_KERNEL::Exception); + virtual bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const throw(INTERP_KERNEL::Exception) = 0; + virtual void copyTinyStringsFrom(const MEDCouplingMesh *other) throw(INTERP_KERNEL::Exception); + virtual void copyTinyInfoFrom(const MEDCouplingMesh *other) throw(INTERP_KERNEL::Exception); + virtual void checkCoherency() const throw(INTERP_KERNEL::Exception) = 0; + virtual void checkCoherency1(double eps=1e-12) const throw(INTERP_KERNEL::Exception) = 0; + virtual void checkCoherency2(double eps=1e-12) const throw(INTERP_KERNEL::Exception) = 0; + virtual int getNumberOfCells() const throw(INTERP_KERNEL::Exception) = 0; + virtual int getNumberOfNodes() const throw(INTERP_KERNEL::Exception) = 0; + virtual int getSpaceDimension() const throw(INTERP_KERNEL::Exception) = 0; + virtual int getMeshDimension() const throw(INTERP_KERNEL::Exception) = 0; + virtual DataArrayDouble *getCoordinatesAndOwner() const throw(INTERP_KERNEL::Exception) = 0; + virtual DataArrayDouble *getBarycenterAndOwner() const throw(INTERP_KERNEL::Exception) = 0; + virtual int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception) = 0; + virtual INTERP_KERNEL::NormalizedCellType getTypeOfCell(int cellId) const throw(INTERP_KERNEL::Exception) = 0; + virtual std::string simpleRepr() const = 0; + virtual std::string advancedRepr() const = 0; + // tools + virtual MEDCouplingFieldDouble *getMeasureField(bool isAbs) const throw(INTERP_KERNEL::Exception) = 0; + virtual MEDCouplingFieldDouble *getMeasureFieldOnNode(bool isAbs) const throw(INTERP_KERNEL::Exception) = 0; + virtual MEDCouplingFieldDouble *fillFromAnalytic(TypeOfField t, int nbOfComp, const char *func) const throw(INTERP_KERNEL::Exception); + virtual MEDCouplingFieldDouble *fillFromAnalytic2(TypeOfField t, int nbOfComp, const char *func) const throw(INTERP_KERNEL::Exception); + virtual MEDCouplingFieldDouble *fillFromAnalytic3(TypeOfField t, int nbOfComp, const std::vector& varsOrder, const char *func) const throw(INTERP_KERNEL::Exception); + virtual MEDCouplingFieldDouble *buildOrthogonalField() const throw(INTERP_KERNEL::Exception) = 0; + virtual MEDCouplingUMesh *buildUnstructured() const throw(INTERP_KERNEL::Exception); + virtual MEDCouplingMesh *mergeMyselfWith(const MEDCouplingMesh *other) const throw(INTERP_KERNEL::Exception) = 0; + virtual bool areCompatibleForMerge(const MEDCouplingMesh *other) const throw(INTERP_KERNEL::Exception); + virtual DataArrayInt *simplexize(int policy) throw(INTERP_KERNEL::Exception); + static MEDCouplingMesh *MergeMeshes(const MEDCouplingMesh *mesh1, const MEDCouplingMesh *mesh2) throw(INTERP_KERNEL::Exception); + %extend + { + std::string __str__() const + { + return self->simpleRepr(); + } + + PyObject *getTime() throw(INTERP_KERNEL::Exception) + { + int tmp1,tmp2; + double tmp0=self->getTime(tmp1,tmp2); + PyObject *res = PyList_New(3); + PyList_SetItem(res,0,SWIG_From_double(tmp0)); + PyList_SetItem(res,1,SWIG_From_int(tmp1)); + PyList_SetItem(res,2,SWIG_From_int(tmp2)); + return res; + } + + int getCellContainingPoint(PyObject *p, double eps) const throw(INTERP_KERNEL::Exception) + { + int sz; + double *pos=convertPyToNewDblArr2(p,&sz); + int ret=self->getCellContainingPoint(pos,eps); + delete [] pos; + return ret; + } + + PyObject *getCellsContainingPoints(PyObject *p, int nbOfPoints, double eps) const throw(INTERP_KERNEL::Exception) + { + int sz; + INTERP_KERNEL::AutoPtr pos=convertPyToNewDblArr2(p,&sz); + std::vector elts,eltsIndex; + self->getCellsContainingPoints(pos,nbOfPoints,eps,elts,eltsIndex); + MEDCouplingAutoRefCountObjectPtr d0=DataArrayInt::New(); + MEDCouplingAutoRefCountObjectPtr d1=DataArrayInt::New(); + d0->alloc(elts.size(),1); + d1->alloc(eltsIndex.size(),1); + std::copy(elts.begin(),elts.end(),d0->getPointer()); + std::copy(eltsIndex.begin(),eltsIndex.end(),d1->getPointer()); + PyObject *ret=PyTuple_New(2); + PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(d0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(d1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + d0->incrRef(); + d1->incrRef(); + return ret; + } + + PyObject *getCellsContainingPoint(PyObject *p, double eps) const throw(INTERP_KERNEL::Exception) + { + int sz; + INTERP_KERNEL::AutoPtr pos=convertPyToNewDblArr2(p,&sz); + std::vector elts; + self->getCellsContainingPoint(pos,eps,elts); + return convertIntArrToPyList2(elts); + } + + void renumberCells(PyObject *li, bool check) throw(INTERP_KERNEL::Exception) + { + void *da=0; + int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 ); + if (!SWIG_IsOK(res1)) + { + int size; + INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); + self->renumberCells(tmp,check); + } + else + { + DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da); + if(!da2) + throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !"); + da2->checkAllocated(); + self->renumberCells(da2->getConstPointer(),check); + } + } + + PyObject *checkGeoEquivalWith(const MEDCouplingMesh *other, int levOfCheck, double prec) const throw(INTERP_KERNEL::Exception) + { + DataArrayInt *cellCor, *nodeCor; + self->checkGeoEquivalWith(other,levOfCheck,prec,cellCor,nodeCor); + PyObject *res = PyList_New(2); + PyList_SetItem(res,0,SWIG_NewPointerObj(SWIG_as_voidptr(cellCor),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, cellCor?SWIG_POINTER_OWN | 0:0 )); + PyList_SetItem(res,1,SWIG_NewPointerObj(SWIG_as_voidptr(nodeCor),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, nodeCor?SWIG_POINTER_OWN | 0:0 )); + return res; + } + DataArrayInt *getCellIdsFullyIncludedInNodeIds(PyObject *li) const throw(INTERP_KERNEL::Exception) + { + void *da=0; + int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 ); + if (!SWIG_IsOK(res1)) + { + int size; + INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); + return self->getCellIdsFullyIncludedInNodeIds(tmp,((const int *)tmp)+size); + } + else + { + DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da); + if(!da2) + throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !"); + da2->checkAllocated(); + return self->getCellIdsFullyIncludedInNodeIds(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems()); + } + } + PyObject *getNodeIdsOfCell(int cellId) const throw(INTERP_KERNEL::Exception) + { + std::vector conn; + self->getNodeIdsOfCell(cellId,conn); + return convertIntArrToPyList2(conn); + } + + PyObject *getCoordinatesOfNode(int nodeId) const throw(INTERP_KERNEL::Exception) + { + std::vector coo; + self->getCoordinatesOfNode(nodeId,coo); + return convertDblArrToPyList2(coo); + } + + void scale(PyObject *point, double factor) throw(INTERP_KERNEL::Exception) + { + int sz; + double *p=convertPyToNewDblArr2(point,&sz); + self->scale(p,factor); + delete [] p; + } + + PyObject *getBoundingBox() const throw(INTERP_KERNEL::Exception) + { + int spaceDim=self->getSpaceDimension(); + double *tmp=new double[2*spaceDim]; + self->getBoundingBox(tmp); + PyObject *ret=convertDblArrToPyListOfTuple(tmp,2,spaceDim); + delete [] tmp; + return ret; + } + + PyObject *buildPart(PyObject *li) const throw(INTERP_KERNEL::Exception) + { + void *da=0; + int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 ); + if (!SWIG_IsOK(res1)) + { + int size; + INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); + MEDCouplingMesh *ret=self->buildPart(tmp,((const int *)tmp)+size); + return convertMesh(ret, SWIG_POINTER_OWN | 0 ); + } + else + { + DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da); + if(!da2) + throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !"); + da2->checkAllocated(); + MEDCouplingMesh *ret=self->buildPart(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems()); + ret->setName(da2->getName().c_str()); + return convertMesh(ret, SWIG_POINTER_OWN | 0 ); + } + } + + PyObject *buildPartAndReduceNodes(PyObject *li) const throw(INTERP_KERNEL::Exception) + { + void *da=0; + DataArrayInt *arr=0; + MEDCouplingMesh *ret=0; + int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 ); + if (!SWIG_IsOK(res1)) + { + int size; + INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); + ret=self->buildPartAndReduceNodes(tmp,((const int *)tmp)+size,arr); + } + else + { + DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da); + if(!da2) + throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !"); + da2->checkAllocated(); + ret=self->buildPartAndReduceNodes(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems(),arr); + ret->setName(da2->getName().c_str()); + } + PyObject *res = PyList_New(2); + PyObject *obj0=convertMesh(ret, SWIG_POINTER_OWN | 0 ); + PyObject *obj1=SWIG_NewPointerObj(SWIG_as_voidptr(arr),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ); + PyList_SetItem(res,0,obj0); + PyList_SetItem(res,1,obj1); + return res; + } + + DataArrayInt *checkTypeConsistencyAndContig(PyObject *li, PyObject *li2) const throw(INTERP_KERNEL::Exception) + { + std::vector code; + std::vector idsPerType; + convertPyObjToVecDataArrayIntCst(li2,idsPerType); + convertPyToNewIntArr3(li,code); + return self->checkTypeConsistencyAndContig(code,idsPerType); + } + + void translate(PyObject *vector) throw(INTERP_KERNEL::Exception) + { + int sz; + INTERP_KERNEL::AutoPtr v=convertPyToNewDblArr2(vector,&sz); + self->translate(v); + } + + void rotate(PyObject *center, PyObject *vector, double alpha) throw(INTERP_KERNEL::Exception) + { + int sz; + INTERP_KERNEL::AutoPtr c=convertPyToNewDblArr2(center,&sz); + if(!c) + return ; + INTERP_KERNEL::AutoPtr v=convertPyToNewDblArr2(vector,&sz); + if(!v) + { return ; } + self->rotate(c,v,alpha); + } + + PyObject *getAllGeoTypes() const throw(INTERP_KERNEL::Exception) + { + std::set result=self->getAllGeoTypes(); + std::set::const_iterator iL=result.begin(); + PyObject *res=PyList_New(result.size()); + for(int i=0;iL!=result.end(); i++, iL++) + PyList_SetItem(res,i,PyInt_FromLong(*iL)); + return res; + } + } + }; +} + +%include "MEDCouplingMemArray.hxx" +%include "NormalizedUnstructuredMesh.hxx" +%include "MEDCouplingNatureOfField.hxx" +%include "MEDCouplingTimeDiscretization.hxx" +%include "MEDCouplingGaussLocalization.hxx" + +namespace ParaMEDMEM +{ + class MEDCouplingPointSet : public ParaMEDMEM::MEDCouplingMesh + { + public: + void updateTime() const; + void setCoords(const DataArrayDouble *coords) throw(INTERP_KERNEL::Exception); + DataArrayDouble *getCoordinatesAndOwner() const throw(INTERP_KERNEL::Exception); + bool areCoordsEqual(const MEDCouplingPointSet& other, double prec) const throw(INTERP_KERNEL::Exception); + void zipCoords() throw(INTERP_KERNEL::Exception); + double getCaracteristicDimension() const throw(INTERP_KERNEL::Exception); + void changeSpaceDimension(int newSpaceDim, double dftVal=0.) throw(INTERP_KERNEL::Exception); + void tryToShareSameCoords(const MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception); + virtual void tryToShareSameCoordsPermute(const MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception) = 0; + static DataArrayDouble *MergeNodesArray(const MEDCouplingPointSet *m1, const MEDCouplingPointSet *m2) throw(INTERP_KERNEL::Exception); + static MEDCouplingPointSet *BuildInstanceFromMeshType(MEDCouplingMeshType type) throw(INTERP_KERNEL::Exception); + virtual MEDCouplingPointSet *buildBoundaryMesh(bool keepCoords) const throw(INTERP_KERNEL::Exception) = 0; + virtual bool isEmptyMesh(const std::vector& tinyInfo) const throw(INTERP_KERNEL::Exception) = 0; + //! size of returned tinyInfo must be always the same. + void getTinySerializationInformation(std::vector& tinyInfoD, std::vector& tinyInfo, std::vector& littleStrings) const throw(INTERP_KERNEL::Exception); + void resizeForUnserialization(const std::vector& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector& littleStrings) const throw(INTERP_KERNEL::Exception); + void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const throw(INTERP_KERNEL::Exception); + void unserialization(const std::vector& tinyInfoD, const std::vector& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, + const std::vector& littleStrings) throw(INTERP_KERNEL::Exception); + virtual void getCellsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bbox, double eps, std::vector& elems) throw(INTERP_KERNEL::Exception) = 0; + virtual DataArrayInt *zipCoordsTraducer() throw(INTERP_KERNEL::Exception) = 0; + %extend + { + std::string __str__() const + { + return self->simpleRepr(); + } + + PyObject *buildNewNumberingFromCommonNodesFormat(const DataArrayInt *comm, const DataArrayInt *commIndex) const throw(INTERP_KERNEL::Exception) + { + int newNbOfNodes; + DataArrayInt *ret0=self->buildNewNumberingFromCommonNodesFormat(comm,commIndex,newNbOfNodes); + PyObject *res = PyList_New(2); + PyList_SetItem(res,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyList_SetItem(res,1,SWIG_From_int(newNbOfNodes)); + return res; + } + + PyObject *findCommonNodes(int limitNodeId, double prec) const throw(INTERP_KERNEL::Exception) + { + DataArrayInt *comm, *commIndex; + self->findCommonNodes(limitNodeId,prec,comm,commIndex); + PyObject *res = PyList_New(2); + PyList_SetItem(res,0,SWIG_NewPointerObj(SWIG_as_voidptr(comm),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyList_SetItem(res,1,SWIG_NewPointerObj(SWIG_as_voidptr(commIndex),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + return res; + } + + PyObject *getCoords() throw(INTERP_KERNEL::Exception) + { + DataArrayDouble *ret1=self->getCoords(); + ret1->incrRef(); + return SWIG_NewPointerObj((void*)ret1,SWIGTYPE_p_ParaMEDMEM__DataArrayDouble,SWIG_POINTER_OWN | 0); + } + PyObject *buildPartOfMySelf(PyObject *li, bool keepCoords) const throw(INTERP_KERNEL::Exception) + { + void *da=0; + int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 ); + if (!SWIG_IsOK(res1)) + { + int size; + INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); + MEDCouplingPointSet *ret=self->buildPartOfMySelf(tmp,((const int *)tmp)+size,keepCoords); + return convertMesh(ret, SWIG_POINTER_OWN | 0 ); + } + else + { + DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da); + if(!da2) + throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !"); + da2->checkAllocated(); + MEDCouplingPointSet *ret=self->buildPartOfMySelf(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems(),keepCoords); + ret->setName(da2->getName().c_str()); + return convertMesh(ret, SWIG_POINTER_OWN | 0 ); + } + } + PyObject *buildPartOfMySelfNode(PyObject *li, bool fullyIn) const throw(INTERP_KERNEL::Exception) + { + void *da=0; + int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 ); + if (!SWIG_IsOK(res1)) + { + int size; + INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); + MEDCouplingPointSet *ret=self->buildPartOfMySelfNode(tmp,((const int *)tmp)+size,fullyIn); + return convertMesh(ret, SWIG_POINTER_OWN | 0 ); + } + else + { + DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da); + if(!da2) + throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !"); + da2->checkAllocated(); + MEDCouplingPointSet *ret=self->buildPartOfMySelfNode(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems(),fullyIn); + ret->setName(da2->getName().c_str()); + return convertMesh(ret, SWIG_POINTER_OWN | 0 ); + } + } + PyObject *buildFacePartOfMySelfNode(PyObject *li, bool fullyIn) const throw(INTERP_KERNEL::Exception) + { + void *da=0; + int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 ); + if (!SWIG_IsOK(res1)) + { + int size; + INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); + MEDCouplingPointSet *ret=self->buildFacePartOfMySelfNode(tmp,((const int *)tmp)+size,fullyIn); + return convertMesh(ret, SWIG_POINTER_OWN | 0 ); + } + else + { + DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da); + if(!da2) + throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !"); + da2->checkAllocated(); + MEDCouplingPointSet *ret=self->buildFacePartOfMySelfNode(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems(),fullyIn); + ret->setName(da2->getName().c_str()); + return convertMesh(ret, SWIG_POINTER_OWN | 0 ); + } + } + PyObject *findBoundaryNodes() const throw(INTERP_KERNEL::Exception) + { + std::vector nodes; + self->findBoundaryNodes(nodes); + return convertIntArrToPyList2(nodes); + } + void renumberNodes(PyObject *li, int newNbOfNodes) throw(INTERP_KERNEL::Exception) + { + void *da=0; + int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 ); + if (!SWIG_IsOK(res1)) + { + int size; + INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); + self->renumberNodes(tmp,newNbOfNodes); + } + else + { + DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da); + if(!da2) + throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !"); + da2->checkAllocated(); + self->renumberNodes(da2->getConstPointer(),newNbOfNodes); + } + } + void renumberNodes2(PyObject *li, int newNbOfNodes) throw(INTERP_KERNEL::Exception) + { + void *da=0; + int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 ); + if (!SWIG_IsOK(res1)) + { + int size; + INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); + self->renumberNodes2(tmp,newNbOfNodes); + } + else + { + DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da); + if(!da2) + throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !"); + da2->checkAllocated(); + self->renumberNodes2(da2->getConstPointer(),newNbOfNodes); + } + } + PyObject *findNodesOnPlane(PyObject *pt, PyObject *vec, double eps) const throw(INTERP_KERNEL::Exception) + { + std::vector nodes; + int sz; + double *p=convertPyToNewDblArr2(pt,&sz); + double *v=convertPyToNewDblArr2(vec,&sz); + self->findNodesOnPlane(p,v,eps,nodes); + delete [] v; + delete [] p; + return convertIntArrToPyList2(nodes); + } + PyObject *getNodeIdsNearPoint(PyObject *pt, double eps) const throw(INTERP_KERNEL::Exception) + { + int size; + INTERP_KERNEL::AutoPtr pos=convertPyToNewDblArr2(pt,&size); + if(sizegetSpaceDimension()) + throw INTERP_KERNEL::Exception("getNodeIdsNearPoint : to tiny array ! must be at least of size SpaceDim !"); + std::vector tmp=self->getNodeIdsNearPoint(pos,eps); + return convertIntArrToPyList2(tmp); + } + + PyObject *getNodeIdsNearPoints(PyObject *pt, int nbOfNodes, double eps) const throw(INTERP_KERNEL::Exception) + { + std::vector c,cI; + int size; + INTERP_KERNEL::AutoPtr pos=convertPyToNewDblArr2(pt,&size); + if(sizegetSpaceDimension()*nbOfNodes) + throw INTERP_KERNEL::Exception("getNodeIdsNearPoints : to tiny array ! must be at least of size SpaceDim*nbOfNodes !"); + self->getNodeIdsNearPoints(pos,nbOfNodes,eps,c,cI); + PyObject *ret=PyTuple_New(2); + MEDCouplingAutoRefCountObjectPtr d0=DataArrayInt::New(); + MEDCouplingAutoRefCountObjectPtr d1=DataArrayInt::New(); + d0->alloc(c.size(),1); + d1->alloc(cI.size(),1); + std::copy(c.begin(),c.end(),d0->getPointer()); + std::copy(cI.begin(),cI.end(),d1->getPointer()); + PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(d0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(d1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + d0->incrRef(); + d1->incrRef(); + return ret; + } + + PyObject *getCellsInBoundingBox(PyObject *bbox, double eps) throw(INTERP_KERNEL::Exception) + { + std::vector elems; + int size; + double *tmp=convertPyToNewDblArr2(bbox,&size); + self->getCellsInBoundingBox(tmp,eps,elems); + delete [] tmp; + return convertIntArrToPyList2(elems); + } + + static void Rotate2DAlg(PyObject *center, double angle, int nbNodes, PyObject *coords) throw(INTERP_KERNEL::Exception) + { + int sz; + double *c=convertPyToNewDblArr2(center,&sz); + double *coo=convertPyToNewDblArr2(coords,&sz); + ParaMEDMEM::MEDCouplingPointSet::Rotate2DAlg(c,angle,nbNodes,coo); + for(int i=0;isimpleRepr(); + } + void insertNextCell(INTERP_KERNEL::NormalizedCellType type, int size, PyObject *li) throw(INTERP_KERNEL::Exception) + { + int sz; + INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&sz); + self->insertNextCell(type,size,tmp); + } + DataArrayInt *getNodalConnectivity() throw(INTERP_KERNEL::Exception) + { + DataArrayInt *ret=self->getNodalConnectivity(); + if(ret) + ret->incrRef(); + return ret; + } + DataArrayInt *getNodalConnectivityIndex() throw(INTERP_KERNEL::Exception) + { + DataArrayInt *ret=self->getNodalConnectivityIndex(); + if(ret) + ret->incrRef(); + return ret; + } + PyObject *getAllTypes() const throw(INTERP_KERNEL::Exception) + { + std::set result=self->getAllTypes(); + std::set::const_iterator iL=result.begin(); + PyObject *res = PyList_New(result.size()); + for (int i=0;iL!=result.end(); i++, iL++) + PyList_SetItem(res,i,PyInt_FromLong(*iL)); + return res; + } + PyObject *mergeNodes(double precision) throw(INTERP_KERNEL::Exception) + { + bool ret1; + int ret2; + DataArrayInt *ret0=self->mergeNodes(precision,ret1,ret2); + PyObject *res = PyList_New(3); + PyList_SetItem(res,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyList_SetItem(res,1,SWIG_From_bool(ret1)); + PyList_SetItem(res,2,SWIG_From_int(ret2)); + return res; + } + PyObject *mergeNodes2(double precision) throw(INTERP_KERNEL::Exception) + { + bool ret1; + int ret2; + DataArrayInt *ret0=self->mergeNodes2(precision,ret1,ret2); + PyObject *res = PyList_New(3); + PyList_SetItem(res,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyList_SetItem(res,1,SWIG_From_bool(ret1)); + PyList_SetItem(res,2,SWIG_From_int(ret2)); + return res; + } + PyObject *checkButterflyCells() throw(INTERP_KERNEL::Exception) + { + std::vector cells; + self->checkButterflyCells(cells); + return convertIntArrToPyList2(cells); + } + + PyObject *splitByType() const throw(INTERP_KERNEL::Exception) + { + std::vector ms=self->splitByType(); + int sz=ms.size(); + PyObject *ret = PyList_New(sz); + for(int i=0;i tmp=convertPyToNewIntArr2(ids,&size); + MEDCouplingUMesh *ret=self->keepSpecifiedCells(type,tmp,tmp+size); + return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh, SWIG_POINTER_OWN | 0 ); + } + + bool checkConsecutiveCellTypesAndOrder(PyObject *li) const throw(INTERP_KERNEL::Exception) + { + int sz; + INTERP_KERNEL::AutoPtr order=(INTERP_KERNEL::NormalizedCellType *)convertPyToNewIntArr2(li,&sz); + bool ret=self->checkConsecutiveCellTypesAndOrder(order,order+sz); + return ret; + } + + DataArrayInt *getRenumArrForConsecutiveCellTypesSpec(PyObject *li) const throw(INTERP_KERNEL::Exception) + { + int sz; + INTERP_KERNEL::AutoPtr order=(INTERP_KERNEL::NormalizedCellType *)convertPyToNewIntArr2(li,&sz); + DataArrayInt *ret=self->getRenumArrForConsecutiveCellTypesSpec(order,(INTERP_KERNEL::NormalizedCellType *)order+sz); + return ret; + } + + PyObject *getLevArrPerCellTypes(PyObject *li) const throw(INTERP_KERNEL::Exception) + { + int sz; + INTERP_KERNEL::AutoPtr order=(INTERP_KERNEL::NormalizedCellType *)convertPyToNewIntArr2(li,&sz); + DataArrayInt *tmp0,*tmp1=0; + tmp0=self->getLevArrPerCellTypes(order,(INTERP_KERNEL::NormalizedCellType *)order+sz,tmp1); + PyObject *ret=PyTuple_New(2); + PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(tmp0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(tmp1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + return ret; + } + + static PyObject *MergeUMeshesOnSameCoords(PyObject *ms) throw(INTERP_KERNEL::Exception) + { + std::vector meshes; + convertPyObjToVecUMeshesCst(ms,meshes); + MEDCouplingUMesh *ret=MEDCouplingUMesh::MergeUMeshesOnSameCoords(meshes); + return convertMesh(ret, SWIG_POINTER_OWN | 0 ); + } + + static PyObject *FuseUMeshesOnSameCoords(PyObject *ms, int compType) throw(INTERP_KERNEL::Exception) + { + int sz; + std::vector meshes; + convertPyObjToVecUMeshesCst(ms,meshes); + std::vector corr; + MEDCouplingUMesh *um=MEDCouplingUMesh::FuseUMeshesOnSameCoords(meshes,compType,corr); + sz=corr.size(); + PyObject *ret1=PyList_New(sz); + for(int i=0;i cells; + int sz; + double *v=convertPyToNewDblArr2(vec,&sz); + try + { + self->are2DCellsNotCorrectlyOriented(v,polyOnly,cells); + } + catch(INTERP_KERNEL::Exception& e) + { + delete [] v; + throw e; + } + delete [] v; + return convertIntArrToPyList2(cells); + } + + void orientCorrectly2DCells(PyObject *vec, bool polyOnly) throw(INTERP_KERNEL::Exception) + { + int sz; + double *v=convertPyToNewDblArr2(vec,&sz); + try + { + self->orientCorrectly2DCells(v,polyOnly); + } + catch(INTERP_KERNEL::Exception& e) + { + delete [] v; + throw e; + } + delete [] v; + } + + PyObject *arePolyhedronsNotCorrectlyOriented() const throw(INTERP_KERNEL::Exception) + { + std::vector cells; + self->arePolyhedronsNotCorrectlyOriented(cells); + return convertIntArrToPyList2(cells); + } + + PyObject *getFastAveragePlaneOfThis() const throw(INTERP_KERNEL::Exception) + { + double vec[3]; + double pos[3]; + self->getFastAveragePlaneOfThis(vec,pos); + double vals[6]; + std::copy(vec,vec+3,vals); + std::copy(pos,pos+3,vals+3); + return convertDblArrToPyListOfTuple(vals,3,2); + } + + static MEDCouplingUMesh *MergeUMeshes(PyObject *li) throw(INTERP_KERNEL::Exception) + { + std::vector tmp; + convertPyObjToVecUMeshesCst(li,tmp); + return MEDCouplingUMesh::MergeUMeshes(tmp); + } + + PyObject *areCellsIncludedIn(const MEDCouplingUMesh *other, int compType) const throw(INTERP_KERNEL::Exception) + { + DataArrayInt *ret1; + bool ret0=self->areCellsIncludedIn(other,compType,ret1); + PyObject *ret=PyTuple_New(2); + PyObject *ret0Py=ret0?Py_True:Py_False; + Py_XINCREF(ret0Py); + PyTuple_SetItem(ret,0,ret0Py); + PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + return ret; + } + + PyObject *buildDescendingConnectivity() const throw(INTERP_KERNEL::Exception) + { + MEDCouplingAutoRefCountObjectPtr d0=DataArrayInt::New(); + MEDCouplingAutoRefCountObjectPtr d1=DataArrayInt::New(); + MEDCouplingAutoRefCountObjectPtr d2=DataArrayInt::New(); + MEDCouplingAutoRefCountObjectPtr d3=DataArrayInt::New(); + MEDCouplingUMesh *m=self->buildDescendingConnectivity(d0,d1,d2,d3); + PyObject *ret=PyTuple_New(5); + PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(m),SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(d0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,2,SWIG_NewPointerObj(SWIG_as_voidptr(d1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,3,SWIG_NewPointerObj(SWIG_as_voidptr(d2),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,4,SWIG_NewPointerObj(SWIG_as_voidptr(d3),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + d0->incrRef(); + d1->incrRef(); + d2->incrRef(); + d3->incrRef(); + return ret; + } + + PyObject *emulateMEDMEMBDC(const MEDCouplingUMesh *nM1LevMesh) + { + MEDCouplingAutoRefCountObjectPtr d0=DataArrayInt::New(); + MEDCouplingAutoRefCountObjectPtr d1=DataArrayInt::New(); + DataArrayInt *d2,*d3,*d4,*dd5; + MEDCouplingUMesh *mOut=self->emulateMEDMEMBDC(nM1LevMesh,d0,d1,d2,d3,d4,dd5); + PyObject *ret=PyTuple_New(7); + PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(mOut),SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr((DataArrayInt *)d0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,2,SWIG_NewPointerObj(SWIG_as_voidptr((DataArrayInt *)d1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,3,SWIG_NewPointerObj(SWIG_as_voidptr(d2),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,4,SWIG_NewPointerObj(SWIG_as_voidptr(d3),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,5,SWIG_NewPointerObj(SWIG_as_voidptr(d4),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,6,SWIG_NewPointerObj(SWIG_as_voidptr(dd5),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + d0->incrRef(); + d1->incrRef(); + return ret; + } + + PyObject *getReverseNodalConnectivity() const throw(INTERP_KERNEL::Exception) + { + MEDCouplingAutoRefCountObjectPtr d0=DataArrayInt::New(); + MEDCouplingAutoRefCountObjectPtr d1=DataArrayInt::New(); + self->getReverseNodalConnectivity(d0,d1); + PyObject *ret=PyTuple_New(2); + PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(d0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(d1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + d0->incrRef(); + d1->incrRef(); + return ret; + } + + DataArrayDouble *getPartBarycenterAndOwner(DataArrayInt *da) const throw(INTERP_KERNEL::Exception) + { + if(!da) + throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !"); + da->checkAllocated(); + return self->getPartBarycenterAndOwner(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems()); + } + + DataArrayDouble *getPartMeasureField(bool isAbs, DataArrayInt *da) const throw(INTERP_KERNEL::Exception) + { + if(!da) + throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !"); + da->checkAllocated(); + return self->getPartMeasureField(isAbs,da->getConstPointer(),da->getConstPointer()+da->getNbOfElems()); + } + + MEDCouplingFieldDouble *buildPartOrthogonalField(DataArrayInt *da) const throw(INTERP_KERNEL::Exception) + { + if(!da) + throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !"); + da->checkAllocated(); + return self->buildPartOrthogonalField(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems()); + } + + PyObject *getTypesOfPart(DataArrayInt *da) const throw(INTERP_KERNEL::Exception) + { + if(!da) + throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !"); + da->checkAllocated(); + std::set result=self->getTypesOfPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems()); + std::set::const_iterator iL=result.begin(); + PyObject *res = PyList_New(result.size()); + for (int i=0;iL!=result.end(); i++, iL++) + PyList_SetItem(res,i,PyInt_FromLong(*iL)); + return res; + } + + DataArrayInt *keepCellIdsByType(INTERP_KERNEL::NormalizedCellType type, DataArrayInt *da) const throw(INTERP_KERNEL::Exception) + { + if(!da) + throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !"); + da->checkAllocated(); + DataArrayInt *ret=self->keepCellIdsByType(type,da->getConstPointer(),da->getConstPointer()+da->getNbOfElems()); + ret->setName(da->getName().c_str()); + return ret; + } + + DataArrayInt *getCellIdsLyingOnNodes(PyObject *li, bool fullyIn) const throw(INTERP_KERNEL::Exception) + { + void *da=0; + int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 ); + if (!SWIG_IsOK(res1)) + { + int size; + INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); + return self->getCellIdsLyingOnNodes(tmp,((const int *)tmp)+size,fullyIn); + } + else + { + DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da); + if(!da2) + throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !"); + da2->checkAllocated(); + return self->getCellIdsLyingOnNodes(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems(),fullyIn); + } + } + } + void convertToPolyTypes(const std::vector& cellIdsToConvert) throw(INTERP_KERNEL::Exception); + void convertAllToPoly(); + void unPolyze() throw(INTERP_KERNEL::Exception); + MEDCouplingUMesh *buildExtrudedMesh(const MEDCouplingUMesh *mesh1D, int policy) throw(INTERP_KERNEL::Exception); + }; + + class MEDCouplingExtrudedMesh : public ParaMEDMEM::MEDCouplingMesh + { + public: + static MEDCouplingExtrudedMesh *New(const MEDCouplingUMesh *mesh3D, MEDCouplingUMesh *mesh2D, int cell2DId) throw(INTERP_KERNEL::Exception); + MEDCouplingUMesh *build3DUnstructuredMesh() const throw(INTERP_KERNEL::Exception); + %extend { + std::string __str__() const + { + return self->simpleRepr(); + } + PyObject *getMesh2D() const throw(INTERP_KERNEL::Exception) + { + MEDCouplingUMesh *ret=self->getMesh2D(); + ret->incrRef(); + return convertMesh(ret, SWIG_POINTER_OWN | 0 ); + } + PyObject *getMesh1D() const throw(INTERP_KERNEL::Exception) + { + MEDCouplingUMesh *ret=self->getMesh1D(); + ret->incrRef(); + return convertMesh(ret, SWIG_POINTER_OWN | 0 ); + } + PyObject *getMesh3DIds() const throw(INTERP_KERNEL::Exception) + { + DataArrayInt *ret=self->getMesh3DIds(); + ret->incrRef(); + return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ); + } + } + }; + + class MEDCouplingCMesh : public ParaMEDMEM::MEDCouplingMesh + { + public: + static MEDCouplingCMesh *New(); + void setCoords(const DataArrayDouble *coordsX, + const DataArrayDouble *coordsY=0, + const DataArrayDouble *coordsZ=0) throw(INTERP_KERNEL::Exception); + void setCoordsAt(int i, const DataArrayDouble *arr) throw(INTERP_KERNEL::Exception); + %extend { + std::string __str__() const + { + return self->simpleRepr(); + } + DataArrayDouble *getCoordsAt(int i) throw(INTERP_KERNEL::Exception) + { + DataArrayDouble *ret=self->getCoordsAt(i); + if(ret) + ret->incrRef(); + return ret; + } + } + }; +} + +%extend ParaMEDMEM::DataArray +{ + void copyPartOfStringInfoFrom(const DataArray& other, PyObject *li) throw(INTERP_KERNEL::Exception) + { + std::vector tmp; + convertPyToNewIntArr3(li,tmp); + self->copyPartOfStringInfoFrom(other,tmp); + } + + void copyPartOfStringInfoFrom2(PyObject *li, const DataArray& other) throw(INTERP_KERNEL::Exception) + { + std::vector tmp; + convertPyToNewIntArr3(li,tmp); + self->copyPartOfStringInfoFrom2(tmp,other); + } +} + +%extend ParaMEDMEM::DataArrayDouble + { + std::string __str__() const + { + return self->repr(); + } + + void setValues(PyObject *li, int nbOfTuples, int nbOfElsPerTuple) throw(INTERP_KERNEL::Exception) + { + double *tmp=new double[nbOfTuples*nbOfElsPerTuple]; + try + { + fillArrayWithPyListDbl(li,tmp,nbOfTuples*nbOfElsPerTuple,0.); + } + catch(INTERP_KERNEL::Exception& e) + { + delete [] tmp; + throw e; + } + self->useArray(tmp,true,CPP_DEALLOC,nbOfTuples,nbOfElsPerTuple); + } + + PyObject *getValues() throw(INTERP_KERNEL::Exception) + { + const double *vals=self->getPointer(); + return convertDblArrToPyList(vals,self->getNbOfElems()); + } + + PyObject *getValuesAsTuple() throw(INTERP_KERNEL::Exception) + { + const double *vals=self->getPointer(); + int nbOfComp=self->getNumberOfComponents(); + int nbOfTuples=self->getNumberOfTuples(); + return convertDblArrToPyListOfTuple(vals,nbOfComp,nbOfTuples); + } + + DataArrayDouble *renumber(PyObject *li) throw(INTERP_KERNEL::Exception) + { + void *da=0; + int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 ); + if (!SWIG_IsOK(res1)) + { + int size; + INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); + if(size!=self->getNumberOfTuples()) + { + throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !"); + } + return self->renumber(tmp); + } + else + { + DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da); + if(!da2) + throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !"); + da2->checkAllocated(); + int size=self->getNumberOfTuples(); + if(size!=self->getNumberOfTuples()) + { + throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !"); + } + return self->renumber(da2->getConstPointer()); + } + } + + DataArrayDouble *renumberR(PyObject *li) throw(INTERP_KERNEL::Exception) + { + void *da=0; + int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 ); + if (!SWIG_IsOK(res1)) + { + int size; + INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); + if(size!=self->getNumberOfTuples()) + { + throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !"); + } + return self->renumberR(tmp); + } + else + { + DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da); + if(!da2) + throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !"); + da2->checkAllocated(); + int size=self->getNumberOfTuples(); + if(size!=self->getNumberOfTuples()) + { + throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !"); + } + return self->renumberR(da2->getConstPointer()); + } + } + + DataArrayDouble *renumberAndReduce(PyObject *li, int newNbOfTuple) throw(INTERP_KERNEL::Exception) + { + void *da=0; + int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 ); + if (!SWIG_IsOK(res1)) + { + int size; + INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); + if(size!=self->getNumberOfTuples()) + { + throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !"); + } + return self->renumberAndReduce(tmp,newNbOfTuple); + } + else + { + DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da); + if(!da2) + throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !"); + da2->checkAllocated(); + int size=self->getNumberOfTuples(); + if(size!=self->getNumberOfTuples()) + { + throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !"); + } + return self->renumberAndReduce(da2->getConstPointer(),newNbOfTuple); + } + } + + void renumberInPlace(PyObject *li) throw(INTERP_KERNEL::Exception) + { + void *da=0; + int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 ); + if (!SWIG_IsOK(res1)) + { + int size; + INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); + if(size!=self->getNumberOfTuples()) + { + throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !"); + } + self->renumberInPlace(tmp); + } + else + { + DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da); + if(!da2) + throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !"); + da2->checkAllocated(); + int size=self->getNumberOfTuples(); + if(size!=self->getNumberOfTuples()) + { + throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !"); + } + self->renumberInPlace(da2->getConstPointer()); + } + } + + void renumberInPlaceR(PyObject *li) throw(INTERP_KERNEL::Exception) + { + void *da=0; + int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 ); + if (!SWIG_IsOK(res1)) + { + int size; + INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); + if(size!=self->getNumberOfTuples()) + { + throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !"); + } + self->renumberInPlaceR(tmp); + } + else + { + DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da); + if(!da2) + throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !"); + da2->checkAllocated(); + int size=self->getNumberOfTuples(); + if(size!=self->getNumberOfTuples()) + { + throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !"); + } + self->renumberInPlaceR(da2->getConstPointer()); + } + } + + DataArrayDouble *selectByTupleId(PyObject *li) const throw(INTERP_KERNEL::Exception) + { + void *da=0; + int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 ); + if (!SWIG_IsOK(res1)) + { + int size; + INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); + return self->selectByTupleId(tmp,tmp+size); + } + else + { + DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da); + if(!da2) + throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !"); + da2->checkAllocated(); + return self->selectByTupleId(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems()); + } + } + + DataArrayDouble *selectByTupleIdSafe(PyObject *li) const throw(INTERP_KERNEL::Exception) + { + void *da=0; + int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 ); + if (!SWIG_IsOK(res1)) + { + int size; + INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); + return self->selectByTupleIdSafe(tmp,tmp+size); + } + else + { + DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da); + if(!da2) + throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !"); + da2->checkAllocated(); + return self->selectByTupleIdSafe(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems()); + } + } + + PyObject *getMaxValue() const throw(INTERP_KERNEL::Exception) + { + int tmp; + double r1=self->getMaxValue(tmp); + PyObject *ret=PyTuple_New(2); + PyTuple_SetItem(ret,0,PyFloat_FromDouble(r1)); + PyTuple_SetItem(ret,1,PyInt_FromLong(tmp)); + return ret; + } + + PyObject *getMaxValue2() const throw(INTERP_KERNEL::Exception) + { + DataArrayInt *tmp; + double r1=self->getMaxValue2(tmp); + PyObject *ret=PyTuple_New(2); + PyTuple_SetItem(ret,0,PyFloat_FromDouble(r1)); + PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(tmp),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + return ret; + } + + PyObject *getMinValue() const throw(INTERP_KERNEL::Exception) + { + int tmp; + double r1=self->getMinValue(tmp); + PyObject *ret=PyTuple_New(2); + PyTuple_SetItem(ret,0,PyFloat_FromDouble(r1)); + PyTuple_SetItem(ret,1,PyInt_FromLong(tmp)); + return ret; + } + + PyObject *getMinValue2() const throw(INTERP_KERNEL::Exception) + { + DataArrayInt *tmp; + double r1=self->getMinValue2(tmp); + PyObject *ret=PyTuple_New(2); + PyTuple_SetItem(ret,0,PyFloat_FromDouble(r1)); + PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(tmp),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + return ret; + } + + PyObject *accumulate() const throw(INTERP_KERNEL::Exception) + { + int sz=self->getNumberOfComponents(); + double *tmp=new double[sz]; + try + { + self->accumulate(tmp); + } + catch(INTERP_KERNEL::Exception& e) + { + delete [] tmp; + throw e; + } + PyObject *ret=convertDblArrToPyList(tmp,sz); + delete [] tmp; + return ret; + } + + DataArrayDouble *keepSelectedComponents(PyObject *li) const throw(INTERP_KERNEL::Exception) + { + std::vector tmp; + convertPyToNewIntArr3(li,tmp); + return self->keepSelectedComponents(tmp); + } + + void setSelectedComponents(const DataArrayDouble *a, PyObject *li) throw(INTERP_KERNEL::Exception) + { + std::vector tmp; + convertPyToNewIntArr3(li,tmp); + self->setSelectedComponents(a,tmp); + } + + PyObject *getTuple(int tupleId) throw(INTERP_KERNEL::Exception) + { + int sz=self->getNumberOfComponents(); + INTERP_KERNEL::AutoPtr tmp=new double[sz]; + self->getTuple(tupleId,tmp); + return convertDblArrToPyList(tmp,sz); + } + + static DataArrayDouble *Aggregate(PyObject *li) throw(INTERP_KERNEL::Exception) + { + std::vector tmp; + convertPyObjToVecDataArrayDblCst(li,tmp); + return DataArrayDouble::Aggregate(tmp); + } + + static DataArrayDouble *Meld(PyObject *li) throw(INTERP_KERNEL::Exception) + { + std::vector tmp; + convertPyObjToVecDataArrayDblCst(li,tmp); + return DataArrayDouble::Meld(tmp); + } + + DataArrayDouble *__getitem__(PyObject *obj) throw(INTERP_KERNEL::Exception) + { + const char msg[]="Unexpected situation in __getitem__ !"; + self->checkAllocated(); + int nbOfTuples=self->getNumberOfTuples(); + int nbOfComponents=self->getNumberOfComponents(); + int it1,ic1; + std::vector vt1,vc1; + std::pair > pt1,pc1; + DataArrayInt *dt1=0,*dc1=0; + int sw; + convertObjToPossibleCpp3(obj,nbOfTuples,nbOfComponents,sw,it1,ic1,vt1,vc1,pt1,pc1,dt1,dc1); + MEDCouplingAutoRefCountObjectPtr ret; + switch(sw) + { + case 1: + return self->selectByTupleIdSafe(&it1,&it1+1); + case 2: + return self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size()); + case 3: + return self->selectByTupleId2(pt1.first,pt1.second.first,pt1.second.second); + case 4: + return self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems()); + case 5: + { + ret=self->selectByTupleIdSafe(&it1,&it1+1); + std::vector v2(1,ic1); + return ret->keepSelectedComponents(v2); + } + case 6: + { + ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size()); + std::vector v2(1,ic1); + return ret->keepSelectedComponents(v2); + } + case 7: + { + ret=self->selectByTupleId2(pt1.first,pt1.second.first,pt1.second.second); + std::vector v2(1,ic1); + return ret->keepSelectedComponents(v2); + } + case 8: + { + ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems()); + std::vector v2(1,ic1); + return ret->keepSelectedComponents(v2); + } + case 9: + { + ret=self->selectByTupleIdSafe(&it1,&it1+1); + return ret->keepSelectedComponents(vc1); + } + case 10: + { + ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size()); + return ret->keepSelectedComponents(vc1); + } + case 11: + { + ret=self->selectByTupleId2(pt1.first,pt1.second.first,pt1.second.second); + return ret->keepSelectedComponents(vc1); + } + case 12: + { + ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems()); + return ret->keepSelectedComponents(vc1); + } + case 13: + { + ret=self->selectByTupleIdSafe(&it1,&it1+1); + int nbOfComp=(pc1.second.first-1-pc1.first)/pc1.second.second+1; + std::vector v2(nbOfComp); + for(int i=0;ikeepSelectedComponents(v2); + } + case 14: + { + ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size()); + int nbOfComp=(pc1.second.first-1-pc1.first)/pc1.second.second+1; + std::vector v2(nbOfComp); + for(int i=0;ikeepSelectedComponents(v2); + } + case 15: + { + ret=self->selectByTupleId2(pt1.first,pt1.second.first,pt1.second.second); + int nbOfComp=(pc1.second.first-1-pc1.first)/pc1.second.second+1; + std::vector v2(nbOfComp); + for(int i=0;ikeepSelectedComponents(v2); + } + case 16: + { + ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems()); + int nbOfComp=(pc1.second.first-1-pc1.first)/pc1.second.second+1; + std::vector v2(nbOfComp); + for(int i=0;ikeepSelectedComponents(v2); + } + default: + throw INTERP_KERNEL::Exception(msg); + } + } + + DataArrayDouble *__setitem__(PyObject *obj, PyObject *value) throw(INTERP_KERNEL::Exception) + { + self->checkAllocated(); + const char msg[]="Unexpected situation in __setitem__ !"; + int nbOfTuples=self->getNumberOfTuples(); + int nbOfComponents=self->getNumberOfComponents(); + int sw1,sw2; + double i1; + std::vector v1; + DataArrayDouble *d1=0; + convertObjToPossibleCpp4(value,sw1,i1,v1,d1); + int it1,ic1; + std::vector vt1,vc1; + std::pair > pt1,pc1; + DataArrayInt *dt1=0,*dc1=0; + convertObjToPossibleCpp3(obj,nbOfTuples,nbOfComponents,sw2,it1,ic1,vt1,vc1,pt1,pc1,dt1,dc1); + MEDCouplingAutoRefCountObjectPtr tmp; + switch(sw2) + { + case 1: + { + switch(sw1) + { + case 1: + self->setPartOfValuesSimple1(i1,it1,it1+1,1,0,nbOfComponents,1); + return self; + case 2: + tmp=DataArrayDouble::New(); + tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1); + self->setPartOfValues1(tmp,it1,it1+1,1,0,nbOfComponents,1,false); + return self; + case 3: + self->setPartOfValues1(d1,it1,it1+1,1,0,nbOfComponents,1); + return self; + default: + throw INTERP_KERNEL::Exception(msg); + } + break; + } + case 2: + { + switch(sw1) + { + case 1: + self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1); + return self; + case 2: + tmp=DataArrayDouble::New(); + tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1); + self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1,false); + return self; + case 3: + self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1); + return self; + default: + throw INTERP_KERNEL::Exception(msg); + } + break; + } + case 3: + { + switch(sw1) + { + case 1: + self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1); + return self; + case 2: + tmp=DataArrayDouble::New(); + tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1); + self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1,false); + return self; + case 3: + self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1); + return self; + default: + throw INTERP_KERNEL::Exception(msg); + } + break; + } + case 4: + { + switch(sw1) + { + case 1: + self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1); + return self; + case 2: + tmp=DataArrayDouble::New(); + tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1); + self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1,false); + return self; + case 3: + self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1); + return self; + default: + throw INTERP_KERNEL::Exception(msg); + } + break; + } + case 5: + { + switch(sw1) + { + case 1: + self->setPartOfValuesSimple1(i1,it1,it1+1,1,ic1,ic1+1,1); + return self; + case 2: + tmp=DataArrayDouble::New(); + tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1); + self->setPartOfValues1(tmp,it1,it1+1,1,ic1,ic1+1,1,false); + return self; + case 3: + self->setPartOfValues1(d1,it1,it1+1,1,ic1,ic1+1,1); + return self; + default: + throw INTERP_KERNEL::Exception(msg); + } + break; + } + case 6: + { + switch(sw1) + { + case 1: + self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1); + return self; + case 2: + tmp=DataArrayDouble::New(); + tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1); + self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1,false); + return self; + case 3: + self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1); + return self; + default: + throw INTERP_KERNEL::Exception(msg); + } + break; + } + case 7: + { + switch(sw1) + { + case 1: + self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1); + return self; + case 2: + tmp=DataArrayDouble::New(); + tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1); + self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1,false); + return self; + case 3: + self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1); + return self; + default: + throw INTERP_KERNEL::Exception(msg); + } + break; + } + case 8: + { + switch(sw1) + { + case 1: + self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1); + return self; + case 2: + tmp=DataArrayDouble::New(); + tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1); + self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1,false); + return self; + case 3: + self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1); + return self; + default: + throw INTERP_KERNEL::Exception(msg); + } + break; + } + case 9: + { + switch(sw1) + { + case 1: + self->setPartOfValuesSimple2(i1,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size()); + return self; + case 2: + tmp=DataArrayDouble::New(); + tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1); + self->setPartOfValues2(tmp,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size(),false); + return self; + case 3: + self->setPartOfValues2(d1,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size()); + return self; + default: + throw INTERP_KERNEL::Exception(msg); + } + break; + } + case 10: + { + switch(sw1) + { + case 1: + self->setPartOfValuesSimple2(i1,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size()); + return self; + case 2: + tmp=DataArrayDouble::New(); + tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1); + self->setPartOfValues2(tmp,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size(),false); + return self; + case 3: + self->setPartOfValues2(d1,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size()); + return self; + default: + throw INTERP_KERNEL::Exception(msg); + } + break; + } + case 11: + { + int bb=pt1.first; + int ee=pt1.second.first; + int ss=pt1.second.second; + if(ee nv(nbOfE); + for(int jj=0;jjsetPartOfValuesSimple2(i1,&nv[0],&nv[0]+nv.size(),&vc1[0],&vc1[0]+vc1.size()); + return self; + case 2: + tmp=DataArrayDouble::New(); + tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1); + self->setPartOfValues2(tmp,&nv[0],&nv[0]+nv.size(),&vc1[0],&vc1[0]+vc1.size(),false); + return self; + case 3: + self->setPartOfValues2(d1,&nv[0],&nv[0]+nv.size(),&vc1[0],&vc1[0]+vc1.size()); + return self; + default: + throw INTERP_KERNEL::Exception(msg); + } + break; + } + case 12: + { + switch(sw1) + { + case 1: + self->setPartOfValuesSimple2(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size()); + return self; + case 2: + tmp=DataArrayDouble::New(); + tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1); + self->setPartOfValues2(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size(),false); + return self; + case 3: + self->setPartOfValues2(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size()); + return self; + default: + throw INTERP_KERNEL::Exception(msg); + } + break; + } + case 13: + { + switch(sw1) + { + case 1: + self->setPartOfValuesSimple1(i1,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second); + return self; + case 2: + tmp=DataArrayDouble::New(); + tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1); + self->setPartOfValues1(tmp,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second,false); + return self; + case 3: + self->setPartOfValues1(d1,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second); + return self; + default: + throw INTERP_KERNEL::Exception(msg); + } + break; + } + case 14: + { + switch(sw1) + { + case 1: + self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second); + return self; + case 2: + tmp=DataArrayDouble::New(); + tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1); + self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second,false); + return self; + case 3: + self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second); + return self; + default: + throw INTERP_KERNEL::Exception(msg); + } + break; + } + case 15: + { + switch(sw1) + { + case 1: + self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second); + return self; + case 2: + tmp=DataArrayDouble::New(); + tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1); + self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second,false); + return self; + case 3: + self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second); + return self; + default: + throw INTERP_KERNEL::Exception(msg); + } + break; + } + case 16: + { + switch(sw1) + { + case 1: + self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second); + return self; + case 2: + tmp=DataArrayDouble::New(); + tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1); + self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second,false); + return self; + case 3: + self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second); + return self; + default: + throw INTERP_KERNEL::Exception(msg); + } + break; + } + default: + throw INTERP_KERNEL::Exception(msg); + } + return self; + } + + DataArrayDouble *__add__(PyObject *obj) throw(INTERP_KERNEL::Exception) + { + const char msg[]="Unexpected situation in __add__ !"; + double val; + DataArrayDouble *a; + int sw; + convertObjToPossibleCpp5(obj,sw,val,a); + switch(sw) + { + case 1: + { + MEDCouplingAutoRefCountObjectPtr ret=self->deepCpy(); + ret->applyLin(1.,val); + ret->incrRef(); + return ret; + } + case 2: + { + return DataArrayDouble::Add(self,a); + } + default: + throw INTERP_KERNEL::Exception(msg); + } + } + + DataArrayDouble *__radd__(PyObject *obj) throw(INTERP_KERNEL::Exception) + { + const char msg[]="Unexpected situation in __radd__ !"; + double val; + DataArrayDouble *a; + int sw; + convertObjToPossibleCpp5(obj,sw,val,a); + switch(sw) + { + case 1: + { + MEDCouplingAutoRefCountObjectPtr ret=self->deepCpy(); + ret->applyLin(1.,val); + ret->incrRef(); + return ret; + } + default: + throw INTERP_KERNEL::Exception(msg); + } + } + + DataArrayDouble *operator+=(PyObject *obj) throw(INTERP_KERNEL::Exception) + { + const char msg[]="Unexpected situation in __iadd__ !"; + double val; + DataArrayDouble *a; + int sw; + convertObjToPossibleCpp5(obj,sw,val,a); + switch(sw) + { + case 1: + { + self->applyLin(1.,val); + return self; + } + case 2: + { + self->addEqual(a); + return self; + } + default: + throw INTERP_KERNEL::Exception(msg); + } + } + + DataArrayDouble *__sub__(PyObject *obj) throw(INTERP_KERNEL::Exception) + { + const char msg[]="Unexpected situation in __sub__ !"; + double val; + DataArrayDouble *a; + int sw; + convertObjToPossibleCpp5(obj,sw,val,a); + switch(sw) + { + case 1: + { + MEDCouplingAutoRefCountObjectPtr ret=self->deepCpy(); + ret->applyLin(1.,-val); + ret->incrRef(); + return ret; + } + case 2: + { + return DataArrayDouble::Substract(self,a); + } + default: + throw INTERP_KERNEL::Exception(msg); + } + } + + DataArrayDouble *__rsub__(PyObject *obj) throw(INTERP_KERNEL::Exception) + { + const char msg[]="Unexpected situation in __rsub__ !"; + double val; + DataArrayDouble *a; + int sw; + convertObjToPossibleCpp5(obj,sw,val,a); + switch(sw) + { + case 1: + { + MEDCouplingAutoRefCountObjectPtr ret=self->deepCpy(); + ret->applyLin(-1.,val); + ret->incrRef(); + return ret; + } + default: + throw INTERP_KERNEL::Exception(msg); + } + } + + DataArrayDouble *operator-=(PyObject *obj) throw(INTERP_KERNEL::Exception) + { + const char msg[]="Unexpected situation in __isub__ !"; + double val; + DataArrayDouble *a; + int sw; + convertObjToPossibleCpp5(obj,sw,val,a); + switch(sw) + { + case 1: + { + self->applyLin(1.,-val); + return self; + } + case 2: + { + self->substractEqual(a); + return self; + } + default: + throw INTERP_KERNEL::Exception(msg); + } + } + + DataArrayDouble *__mul__(PyObject *obj) throw(INTERP_KERNEL::Exception) + { + const char msg[]="Unexpected situation in __mul__ !"; + double val; + DataArrayDouble *a; + int sw; + convertObjToPossibleCpp5(obj,sw,val,a); + switch(sw) + { + case 1: + { + MEDCouplingAutoRefCountObjectPtr ret=self->deepCpy(); + ret->applyLin(val,0.); + ret->incrRef(); + return ret; + } + case 2: + { + return DataArrayDouble::Multiply(self,a); + } + default: + throw INTERP_KERNEL::Exception(msg); + } + } + + DataArrayDouble *__rmul__(PyObject *obj) throw(INTERP_KERNEL::Exception) + { + const char msg[]="Unexpected situation in __rmul__ !"; + double val; + DataArrayDouble *a; + int sw; + convertObjToPossibleCpp5(obj,sw,val,a); + switch(sw) + { + case 1: + { + MEDCouplingAutoRefCountObjectPtr ret=self->deepCpy(); + ret->applyLin(val,0.); + ret->incrRef(); + return ret; + } + default: + throw INTERP_KERNEL::Exception(msg); + } + } + + DataArrayDouble *operator*=(PyObject *obj) throw(INTERP_KERNEL::Exception) + { + const char msg[]="Unexpected situation in __imul__ !"; + double val; + DataArrayDouble *a; + int sw; + convertObjToPossibleCpp5(obj,sw,val,a); + switch(sw) + { + case 1: + { + self->applyLin(val,0.); + return self; + } + case 2: + { + self->multiplyEqual(a); + return self; + } + default: + throw INTERP_KERNEL::Exception(msg); + } + } + + DataArrayDouble *__div__(PyObject *obj) throw(INTERP_KERNEL::Exception) + { + const char msg[]="Unexpected situation in __div__ !"; + double val; + DataArrayDouble *a; + int sw; + convertObjToPossibleCpp5(obj,sw,val,a); + switch(sw) + { + case 1: + { + if(val==0.) + throw INTERP_KERNEL::Exception("DataArrayDouble::__div__ : trying to divide by zero !"); + MEDCouplingAutoRefCountObjectPtr ret=self->deepCpy(); + ret->applyLin(1/val,0.); + ret->incrRef(); + return ret; + } + case 2: + { + return DataArrayDouble::Divide(self,a); + } + default: + throw INTERP_KERNEL::Exception(msg); + } + } + + DataArrayDouble *__rdiv__(PyObject *obj) throw(INTERP_KERNEL::Exception) + { + const char msg[]="Unexpected situation in __rdiv__ !"; + double val; + DataArrayDouble *a; + int sw; + convertObjToPossibleCpp5(obj,sw,val,a); + switch(sw) + { + case 1: + { + MEDCouplingAutoRefCountObjectPtr ret=self->deepCpy(); + ret->applyInv(val); + ret->incrRef(); + return ret; + } + default: + throw INTERP_KERNEL::Exception(msg); + } + } + + DataArrayDouble *operator/=(PyObject *obj) throw(INTERP_KERNEL::Exception) + { + const char msg[]="Unexpected situation in __imul__ !"; + double val; + DataArrayDouble *a; + int sw; + convertObjToPossibleCpp5(obj,sw,val,a); + switch(sw) + { + case 1: + { + if(val==0.) + throw INTERP_KERNEL::Exception("DataArrayDouble::__div__ : trying to divide by zero !"); + self->applyLin(1./val,0.); + return self; + } + case 2: + { + self->divideEqual(a); + return self; + } + default: + throw INTERP_KERNEL::Exception(msg); + } + } + }; + +%extend ParaMEDMEM::DataArrayInt + { + std::string __str__() const + { + return self->repr(); + } + + PyObject *getDifferentValues(bool val) const throw(INTERP_KERNEL::Exception) + { + std::set ret=self->getDifferentValues(); + return convertIntArrToPyList3(ret); + } + + void setValues(PyObject *li, int nbOfTuples, int nbOfElsPerTuple) throw(INTERP_KERNEL::Exception) + { + int *tmp=new int[nbOfTuples*nbOfElsPerTuple]; + try + { + fillArrayWithPyListInt(li,tmp,nbOfTuples*nbOfElsPerTuple,0.); + } + catch(INTERP_KERNEL::Exception& e) + { + delete [] tmp; + throw e; + } + self->useArray(tmp,true,CPP_DEALLOC,nbOfTuples,nbOfElsPerTuple); + } + + PyObject *getValues() throw(INTERP_KERNEL::Exception) + { + const int *vals=self->getPointer(); + return convertIntArrToPyList(vals,self->getNbOfElems()); + } + + PyObject *getValuesAsTuple() throw(INTERP_KERNEL::Exception) + { + const int *vals=self->getPointer(); + int nbOfComp=self->getNumberOfComponents(); + int nbOfTuples=self->getNumberOfTuples(); + return convertIntArrToPyListOfTuple(vals,nbOfComp,nbOfTuples); + } + + static PyObject *MakePartition(PyObject *gps, int newNb) throw(INTERP_KERNEL::Exception) + { + std::vector groups; + std::vector< std::vector > fidsOfGroups; + convertPyObjToVecDataArrayIntCst(gps,groups); + ParaMEDMEM::DataArrayInt *ret0=ParaMEDMEM::DataArrayInt::MakePartition(groups,newNb,fidsOfGroups); + PyObject *ret = PyList_New(2); + PyList_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + int sz=fidsOfGroups.size(); + PyObject *ret1 = PyList_New(sz); + for(int i=0;i tmp=convertPyToNewIntArr2(li,&size); + self->transformWithIndArr(tmp,tmp+size); + } + else + { + DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da); + self->transformWithIndArr(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems()); + } + } + + DataArrayInt *transformWithIndArrR(PyObject *li) const + { + void *da=0; + int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 ); + if (!SWIG_IsOK(res1)) + { + int size; + INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); + return self->transformWithIndArrR(tmp,tmp+size); + } + else + { + DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da); + return self->transformWithIndArrR(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems()); + } + } + + void renumberInPlace(PyObject *li) throw(INTERP_KERNEL::Exception) + { + void *da=0; + int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 ); + if (!SWIG_IsOK(res1)) + { + int size; + INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); + if(size!=self->getNumberOfTuples()) + { + throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !"); + } + self->renumberInPlace(tmp); + } + else + { + DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da); + if(!da2) + throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !"); + da2->checkAllocated(); + int size=self->getNumberOfTuples(); + if(size!=self->getNumberOfTuples()) + { + throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !"); + } + self->renumberInPlace(da2->getConstPointer()); + } + } + + void renumberInPlaceR(PyObject *li) throw(INTERP_KERNEL::Exception) + { + void *da=0; + int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 ); + if (!SWIG_IsOK(res1)) + { + int size; + INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); + if(size!=self->getNumberOfTuples()) + { + throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !"); + } + self->renumberInPlaceR(tmp); + } + else + { + DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da); + if(!da2) + throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !"); + da2->checkAllocated(); + int size=self->getNumberOfTuples(); + if(size!=self->getNumberOfTuples()) + { + throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !"); + } + self->renumberInPlaceR(da2->getConstPointer()); + } + } + + DataArrayInt *renumberAndReduce(PyObject *li, int newNbOfTuple) throw(INTERP_KERNEL::Exception) + { + void *da=0; + int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 ); + if (!SWIG_IsOK(res1)) + { + int size; + INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); + if(size!=self->getNumberOfTuples()) + { + throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !"); + } + return self->renumberAndReduce(tmp,newNbOfTuple); + } + else + { + DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da); + if(!da2) + throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !"); + da2->checkAllocated(); + int size=self->getNumberOfTuples(); + if(size!=self->getNumberOfTuples()) + { + throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !"); + } + return self->renumberAndReduce(da2->getConstPointer(),newNbOfTuple); + } + } + + DataArrayInt *renumber(PyObject *li) throw(INTERP_KERNEL::Exception) + { + void *da=0; + int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 ); + if (!SWIG_IsOK(res1)) + { + int size; + INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); + if(size!=self->getNumberOfTuples()) + { + throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !"); + } + return self->renumber(tmp); + } + else + { + DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da); + if(!da2) + throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !"); + da2->checkAllocated(); + int size=self->getNumberOfTuples(); + if(size!=self->getNumberOfTuples()) + { + throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !"); + } + return self->renumber(da2->getConstPointer()); + } + } + + DataArrayInt *renumberR(PyObject *li) throw(INTERP_KERNEL::Exception) + { + void *da=0; + int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 ); + if (!SWIG_IsOK(res1)) + { + int size; + INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); + if(size!=self->getNumberOfTuples()) + { + throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !"); + } + return self->renumberR(tmp); + } + else + { + DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da); + if(!da2) + throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !"); + da2->checkAllocated(); + int size=self->getNumberOfTuples(); + if(size!=self->getNumberOfTuples()) + { + throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !"); + } + return self->renumberR(da2->getConstPointer()); + } + } + + DataArrayInt *selectByTupleId(PyObject *li) const throw(INTERP_KERNEL::Exception) + { + void *da=0; + int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 ); + if (!SWIG_IsOK(res1)) + { + int size; + INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); + return self->selectByTupleId(tmp,tmp+size); + } + else + { + DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da); + if(!da2) + throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !"); + da2->checkAllocated(); + return self->selectByTupleId(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems()); + } + } + + DataArrayInt *selectByTupleIdSafe(PyObject *li) const throw(INTERP_KERNEL::Exception) + { + void *da=0; + int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 ); + if (!SWIG_IsOK(res1)) + { + int size; + INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); + return self->selectByTupleIdSafe(tmp,tmp+size); + } + else + { + DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da); + if(!da2) + throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !"); + da2->checkAllocated(); + return self->selectByTupleIdSafe(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems()); + } + } + + DataArrayInt *keepSelectedComponents(PyObject *li) const throw(INTERP_KERNEL::Exception) + { + std::vector tmp; + convertPyToNewIntArr3(li,tmp); + return self->keepSelectedComponents(tmp); + } + + void setSelectedComponents(const DataArrayInt *a, PyObject *li) throw(INTERP_KERNEL::Exception) + { + std::vector tmp; + convertPyToNewIntArr3(li,tmp); + self->setSelectedComponents(a,tmp); + } + + PyObject *getTuple(int tupleId) throw(INTERP_KERNEL::Exception) + { + int sz=self->getNumberOfComponents(); + INTERP_KERNEL::AutoPtr tmp=new int[sz]; + self->getTuple(tupleId,tmp); + return convertIntArrToPyList(tmp,sz); + } + + PyObject *changeSurjectiveFormat(int targetNb) const throw(INTERP_KERNEL::Exception) + { + DataArrayInt *arr=0; + DataArrayInt *arrI=0; + self->changeSurjectiveFormat(targetNb,arr,arrI); + PyObject *res = PyList_New(2); + PyList_SetItem(res,0,SWIG_NewPointerObj((void*)arr,SWIGTYPE_p_ParaMEDMEM__DataArrayInt,SWIG_POINTER_OWN | 0)); + PyList_SetItem(res,1,SWIG_NewPointerObj((void*)arrI,SWIGTYPE_p_ParaMEDMEM__DataArrayInt,SWIG_POINTER_OWN | 0)); + return res; + } + + static DataArrayInt *Meld(PyObject *li) throw(INTERP_KERNEL::Exception) + { + std::vector tmp; + convertPyObjToVecDataArrayIntCst(li,tmp); + return DataArrayInt::Meld(tmp); + } + + static DataArrayInt *Aggregate(PyObject *li) throw(INTERP_KERNEL::Exception) + { + std::vector tmp; + convertPyObjToVecDataArrayIntCst(li,tmp); + return DataArrayInt::Aggregate(tmp); + } + + static DataArrayInt *BuildUnion(PyObject *li) throw(INTERP_KERNEL::Exception) + { + std::vector tmp; + convertPyObjToVecDataArrayIntCst(li,tmp); + return DataArrayInt::BuildUnion(tmp); + } + + static DataArrayInt *BuildIntersection(PyObject *li) throw(INTERP_KERNEL::Exception) + { + std::vector tmp; + convertPyObjToVecDataArrayIntCst(li,tmp); + return DataArrayInt::BuildIntersection(tmp); + } + + PyObject *getMaxValue() const throw(INTERP_KERNEL::Exception) + { + int tmp; + int r1=self->getMaxValue(tmp); + PyObject *ret=PyTuple_New(2); + PyTuple_SetItem(ret,0,PyInt_FromLong(r1)); + PyTuple_SetItem(ret,1,PyInt_FromLong(tmp)); + return ret; + } + + PyObject *getMinValue() const throw(INTERP_KERNEL::Exception) + { + int tmp; + int r1=self->getMinValue(tmp); + PyObject *ret=PyTuple_New(2); + PyTuple_SetItem(ret,0,PyInt_FromLong(r1)); + PyTuple_SetItem(ret,1,PyInt_FromLong(tmp)); + return ret; + } + + DataArrayInt *__getitem__(PyObject *obj) throw(INTERP_KERNEL::Exception) + { + const char msg[]="Unexpected situation in __getitem__ !"; + self->checkAllocated(); + int nbOfTuples=self->getNumberOfTuples(); + int nbOfComponents=self->getNumberOfComponents(); + int it1,ic1; + std::vector vt1,vc1; + std::pair > pt1,pc1; + DataArrayInt *dt1=0,*dc1=0; + int sw; + convertObjToPossibleCpp3(obj,nbOfTuples,nbOfComponents,sw,it1,ic1,vt1,vc1,pt1,pc1,dt1,dc1); + MEDCouplingAutoRefCountObjectPtr ret; + switch(sw) + { + case 1: + return self->selectByTupleIdSafe(&it1,&it1+1); + case 2: + return self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size()); + case 3: + return self->selectByTupleId2(pt1.first,pt1.second.first,pt1.second.second); + case 4: + return self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems()); + case 5: + { + ret=self->selectByTupleIdSafe(&it1,&it1+1); + std::vector v2(1,ic1); + return ret->keepSelectedComponents(v2); + } + case 6: + { + ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size()); + std::vector v2(1,ic1); + return ret->keepSelectedComponents(v2); + } + case 7: + { + ret=self->selectByTupleId2(pt1.first,pt1.second.first,pt1.second.second); + std::vector v2(1,ic1); + return ret->keepSelectedComponents(v2); + } + case 8: + { + ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems()); + std::vector v2(1,ic1); + return ret->keepSelectedComponents(v2); + } + case 9: + { + ret=self->selectByTupleIdSafe(&it1,&it1+1); + return ret->keepSelectedComponents(vc1); + } + case 10: + { + ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size()); + return ret->keepSelectedComponents(vc1); + } + case 11: + { + ret=self->selectByTupleId2(pt1.first,pt1.second.first,pt1.second.second); + return ret->keepSelectedComponents(vc1); + } + case 12: + { + ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems()); + return ret->keepSelectedComponents(vc1); + } + case 13: + { + ret=self->selectByTupleIdSafe(&it1,&it1+1); + int nbOfComp=(pc1.second.first-1-pc1.first)/pc1.second.second+1; + std::vector v2(nbOfComp); + for(int i=0;ikeepSelectedComponents(v2); + } + case 14: + { + ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size()); + int nbOfComp=(pc1.second.first-1-pc1.first)/pc1.second.second+1; + std::vector v2(nbOfComp); + for(int i=0;ikeepSelectedComponents(v2); + } + case 15: + { + ret=self->selectByTupleId2(pt1.first,pt1.second.first,pt1.second.second); + int nbOfComp=(pc1.second.first-1-pc1.first)/pc1.second.second+1; + std::vector v2(nbOfComp); + for(int i=0;ikeepSelectedComponents(v2); + } + case 16: + { + ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems()); + int nbOfComp=(pc1.second.first-1-pc1.first)/pc1.second.second+1; + std::vector v2(nbOfComp); + for(int i=0;ikeepSelectedComponents(v2); + } + default: + throw INTERP_KERNEL::Exception(msg); + } + } + + DataArrayInt *__setitem__(PyObject *obj, PyObject *value) throw(INTERP_KERNEL::Exception) + { + self->checkAllocated(); + const char msg[]="Unexpected situation in __setitem__ !"; + int nbOfTuples=self->getNumberOfTuples(); + int nbOfComponents=self->getNumberOfComponents(); + int sw1,sw2; + int i1; + std::vector v1; + DataArrayInt *d1=0; + convertObjToPossibleCpp1(value,sw1,i1,v1,d1); + int it1,ic1; + std::vector vt1,vc1; + std::pair > pt1,pc1; + DataArrayInt *dt1=0,*dc1=0; + convertObjToPossibleCpp3(obj,nbOfTuples,nbOfComponents,sw2,it1,ic1,vt1,vc1,pt1,pc1,dt1,dc1); + MEDCouplingAutoRefCountObjectPtr tmp; + switch(sw2) + { + case 1: + { + switch(sw1) + { + case 1: + self->setPartOfValuesSimple1(i1,it1,it1+1,1,0,nbOfComponents,1); + return self; + case 2: + tmp=DataArrayInt::New(); + tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1); + self->setPartOfValues1(tmp,it1,it1+1,1,0,nbOfComponents,1,false); + return self; + case 3: + self->setPartOfValues1(d1,it1,it1+1,1,0,nbOfComponents,1); + return self; + default: + throw INTERP_KERNEL::Exception(msg); + } + break; + } + case 2: + { + switch(sw1) + { + case 1: + self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1); + return self; + case 2: + tmp=DataArrayInt::New(); + tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1); + self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1,false); + return self; + case 3: + self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1); + return self; + default: + throw INTERP_KERNEL::Exception(msg); + } + break; + } + case 3: + { + switch(sw1) + { + case 1: + self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1); + return self; + case 2: + tmp=DataArrayInt::New(); + tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1); + self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1,false); + return self; + case 3: + self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1); + return self; + default: + throw INTERP_KERNEL::Exception(msg); + } + break; + } + case 4: + { + switch(sw1) + { + case 1: + self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1); + return self; + case 2: + tmp=DataArrayInt::New(); + tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1); + self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1,false); + return self; + case 3: + self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1); + return self; + default: + throw INTERP_KERNEL::Exception(msg); + } + break; + } + case 5: + { + switch(sw1) + { + case 1: + self->setPartOfValuesSimple1(i1,it1,it1+1,1,ic1,ic1+1,1); + return self; + case 2: + tmp=DataArrayInt::New(); + tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1); + self->setPartOfValues1(tmp,it1,it1+1,1,ic1,ic1+1,1,false); + return self; + case 3: + self->setPartOfValues1(d1,it1,it1+1,1,ic1,ic1+1,1); + return self; + default: + throw INTERP_KERNEL::Exception(msg); + } + break; + } + case 6: + { + switch(sw1) + { + case 1: + self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1); + return self; + case 2: + tmp=DataArrayInt::New(); + tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1); + self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1,false); + return self; + case 3: + self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1); + return self; + default: + throw INTERP_KERNEL::Exception(msg); + } + break; + } + case 7: + { + switch(sw1) + { + case 1: + self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1); + return self; + case 2: + tmp=DataArrayInt::New(); + tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1); + self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1,false); + return self; + case 3: + self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1); + return self; + default: + throw INTERP_KERNEL::Exception(msg); + } + break; + } + case 8: + { + switch(sw1) + { + case 1: + self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1); + return self; + case 2: + tmp=DataArrayInt::New(); + tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1); + self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1,false); + return self; + case 3: + self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1); + return self; + default: + throw INTERP_KERNEL::Exception(msg); + } + break; + } + case 9: + { + switch(sw1) + { + case 1: + self->setPartOfValuesSimple2(i1,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size()); + return self; + case 2: + tmp=DataArrayInt::New(); + tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1); + self->setPartOfValues2(tmp,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size(),false); + return self; + case 3: + self->setPartOfValues2(d1,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size()); + return self; + default: + throw INTERP_KERNEL::Exception(msg); + } + break; + } + case 10: + { + switch(sw1) + { + case 1: + self->setPartOfValuesSimple2(i1,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size()); + return self; + case 2: + tmp=DataArrayInt::New(); + tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1); + self->setPartOfValues2(tmp,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size(),false); + return self; + case 3: + self->setPartOfValues2(d1,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size()); + return self; + default: + throw INTERP_KERNEL::Exception(msg); + } + break; + } + case 11: + { + int bb=pt1.first; + int ee=pt1.second.first; + int ss=pt1.second.second; + if(ee nv(nbOfE); + for(int jj=0;jjsetPartOfValuesSimple2(i1,&nv[0],&nv[0]+nv.size(),&vc1[0],&vc1[0]+vc1.size()); + return self; + case 2: + tmp=DataArrayInt::New(); + tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1); + self->setPartOfValues2(tmp,&nv[0],&nv[0]+nv.size(),&vc1[0],&vc1[0]+vc1.size(),false); + return self; + case 3: + self->setPartOfValues2(d1,&nv[0],&nv[0]+nv.size(),&vc1[0],&vc1[0]+vc1.size()); + return self; + default: + throw INTERP_KERNEL::Exception(msg); + } + break; + } + case 12: + { + switch(sw1) + { + case 1: + self->setPartOfValuesSimple2(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size()); + return self; + case 2: + tmp=DataArrayInt::New(); + tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1); + self->setPartOfValues2(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size(),false); + return self; + case 3: + self->setPartOfValues2(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size()); + return self; + default: + throw INTERP_KERNEL::Exception(msg); + } + break; + } + case 13: + { + switch(sw1) + { + case 1: + self->setPartOfValuesSimple1(i1,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second); + return self; + case 2: + tmp=DataArrayInt::New(); + tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1); + self->setPartOfValues1(tmp,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second,false); + return self; + case 3: + self->setPartOfValues1(d1,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second); + return self; + default: + throw INTERP_KERNEL::Exception(msg); + } + break; + } + case 14: + { + switch(sw1) + { + case 1: + self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second); + return self; + case 2: + tmp=DataArrayInt::New(); + tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1); + self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second,false); + return self; + case 3: + self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second); + return self; + default: + throw INTERP_KERNEL::Exception(msg); + } + break; + } + case 15: + { + switch(sw1) + { + case 1: + self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second); + return self; + case 2: + tmp=DataArrayInt::New(); + tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1); + self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second,false); + return self; + case 3: + self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second); + return self; + default: + throw INTERP_KERNEL::Exception(msg); + } + break; + } + case 16: + { + switch(sw1) + { + case 1: + self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second); + return self; + case 2: + tmp=DataArrayInt::New(); + tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1); + self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second,false); + return self; + case 3: + self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second); + return self; + default: + throw INTERP_KERNEL::Exception(msg); + } + break; + } + default: + throw INTERP_KERNEL::Exception(msg); + } + return self; + } + + DataArrayInt *__add__(PyObject *obj) throw(INTERP_KERNEL::Exception) + { + const char msg[]="Unexpected situation in __add__ !"; + int val; + DataArrayInt *a; + std::vector aa; + int sw; + convertObjToPossibleCpp1(obj,sw,val,aa,a); + switch(sw) + { + case 1: + { + MEDCouplingAutoRefCountObjectPtr ret=self->deepCpy(); + ret->applyLin(1,val); + ret->incrRef(); + return ret; + } + case 3: + { + return DataArrayInt::Add(self,a); + } + default: + throw INTERP_KERNEL::Exception(msg); + } + } + + DataArrayInt *__radd__(PyObject *obj) throw(INTERP_KERNEL::Exception) + { + const char msg[]="Unexpected situation in __radd__ !"; + int val; + DataArrayInt *a; + std::vector aa; + int sw; + convertObjToPossibleCpp1(obj,sw,val,aa,a); + switch(sw) + { + case 1: + { + MEDCouplingAutoRefCountObjectPtr ret=self->deepCpy(); + ret->applyLin(1,val); + ret->incrRef(); + return ret; + } + default: + throw INTERP_KERNEL::Exception(msg); + } + } + + DataArrayInt *operator+=(PyObject *obj) throw(INTERP_KERNEL::Exception) + { + const char msg[]="Unexpected situation in __iadd__ !"; + int val; + DataArrayInt *a; + std::vector aa; + int sw; + convertObjToPossibleCpp1(obj,sw,val,aa,a); + switch(sw) + { + case 1: + { + self->applyLin(1,val); + return self; + } + case 3: + { + self->addEqual(a); + return self; + } + default: + throw INTERP_KERNEL::Exception(msg); + } + } + + DataArrayInt *__sub__(PyObject *obj) throw(INTERP_KERNEL::Exception) + { + const char msg[]="Unexpected situation in __sub__ !"; + int val; + DataArrayInt *a; + std::vector aa; + int sw; + convertObjToPossibleCpp1(obj,sw,val,aa,a); + switch(sw) + { + case 1: + { + MEDCouplingAutoRefCountObjectPtr ret=self->deepCpy(); + ret->applyLin(1,-val); + ret->incrRef(); + return ret; + } + case 3: + { + return DataArrayInt::Substract(self,a); + } + default: + throw INTERP_KERNEL::Exception(msg); + } + } + + DataArrayInt *__rsub__(PyObject *obj) throw(INTERP_KERNEL::Exception) + { + const char msg[]="Unexpected situation in __rsub__ !"; + int val; + DataArrayInt *a; + std::vector aa; + int sw; + convertObjToPossibleCpp1(obj,sw,val,aa,a); + switch(sw) + { + case 1: + { + MEDCouplingAutoRefCountObjectPtr ret=self->deepCpy(); + ret->applyLin(-1,val); + ret->incrRef(); + return ret; + } + default: + throw INTERP_KERNEL::Exception(msg); + } + } + + DataArrayInt *operator-=(PyObject *obj) throw(INTERP_KERNEL::Exception) + { + const char msg[]="Unexpected situation in __isub__ !"; + int val; + DataArrayInt *a; + std::vector aa; + int sw; + convertObjToPossibleCpp1(obj,sw,val,aa,a); + switch(sw) + { + case 1: + { + self->applyLin(1.,-val); + return self; + } + case 3: + { + self->substractEqual(a); + return self; + } + default: + throw INTERP_KERNEL::Exception(msg); + } + } + + DataArrayInt *__mul__(PyObject *obj) throw(INTERP_KERNEL::Exception) + { + const char msg[]="Unexpected situation in __mul__ !"; + int val; + DataArrayInt *a; + std::vector aa; + int sw; + convertObjToPossibleCpp1(obj,sw,val,aa,a); + switch(sw) + { + case 1: + { + MEDCouplingAutoRefCountObjectPtr ret=self->deepCpy(); + ret->applyLin(val,0); + ret->incrRef(); + return ret; + } + case 3: + { + return DataArrayInt::Multiply(self,a); + } + default: + throw INTERP_KERNEL::Exception(msg); + } + } + + DataArrayInt *__rmul__(PyObject *obj) throw(INTERP_KERNEL::Exception) + { + const char msg[]="Unexpected situation in __rmul__ !"; + int val; + DataArrayInt *a; + std::vector aa; + int sw; + convertObjToPossibleCpp1(obj,sw,val,aa,a); + switch(sw) + { + case 1: + { + MEDCouplingAutoRefCountObjectPtr ret=self->deepCpy(); + ret->applyLin(val,0); + ret->incrRef(); + return ret; + } + default: + throw INTERP_KERNEL::Exception(msg); + } + } + + DataArrayInt *operator*=(PyObject *obj) throw(INTERP_KERNEL::Exception) + { + const char msg[]="Unexpected situation in __imul__ !"; + int val; + DataArrayInt *a; + std::vector aa; + int sw; + convertObjToPossibleCpp1(obj,sw,val,aa,a); + switch(sw) + { + case 1: + { + self->applyLin(val,0); + return self; + } + case 3: + { + self->multiplyEqual(a); + return self; + } + default: + throw INTERP_KERNEL::Exception(msg); + } + } + + DataArrayInt *__div__(PyObject *obj) throw(INTERP_KERNEL::Exception) + { + const char msg[]="Unexpected situation in __div__ !"; + int val; + DataArrayInt *a; + std::vector aa; + int sw; + convertObjToPossibleCpp1(obj,sw,val,aa,a); + switch(sw) + { + case 1: + { + MEDCouplingAutoRefCountObjectPtr ret=self->deepCpy(); + ret->applyDivideBy(val); + ret->incrRef(); + return ret; + } + case 3: + { + return DataArrayInt::Divide(self,a); + } + default: + throw INTERP_KERNEL::Exception(msg); + } + } + + DataArrayInt *__rdiv__(PyObject *obj) throw(INTERP_KERNEL::Exception) + { + const char msg[]="Unexpected situation in __rdiv__ !"; + int val; + DataArrayInt *a; + std::vector aa; + int sw; + convertObjToPossibleCpp1(obj,sw,val,aa,a); + switch(sw) + { + case 1: + { + MEDCouplingAutoRefCountObjectPtr ret=self->deepCpy(); + ret->applyInv(val); + ret->incrRef(); + return ret; + } + default: + throw INTERP_KERNEL::Exception(msg); + } + } + + DataArrayInt *operator/=(PyObject *obj) throw(INTERP_KERNEL::Exception) + { + const char msg[]="Unexpected situation in __imul__ !"; + int val; + DataArrayInt *a; + std::vector aa; + int sw; + convertObjToPossibleCpp1(obj,sw,val,aa,a); + switch(sw) + { + case 1: + { + self->applyDivideBy(val); + return self; + } + case 3: + { + self->divideEqual(a); + return self; + } + default: + throw INTERP_KERNEL::Exception(msg); + } + } + + DataArrayInt *__mod__(PyObject *obj) throw(INTERP_KERNEL::Exception) + { + const char msg[]="Unexpected situation in __mod__ !"; + int val; + DataArrayInt *a; + std::vector aa; + int sw; + convertObjToPossibleCpp1(obj,sw,val,aa,a); + switch(sw) + { + case 1: + { + MEDCouplingAutoRefCountObjectPtr ret=self->deepCpy(); + ret->applyModulus(val); + ret->incrRef(); + return ret; + } + case 3: + { + return DataArrayInt::Modulus(self,a); + } + default: + throw INTERP_KERNEL::Exception(msg); + } + } + + DataArrayInt *__rmod__(PyObject *obj) throw(INTERP_KERNEL::Exception) + { + const char msg[]="Unexpected situation in __rmod__ !"; + int val; + DataArrayInt *a; + std::vector aa; + int sw; + convertObjToPossibleCpp1(obj,sw,val,aa,a); + switch(sw) + { + case 1: + { + MEDCouplingAutoRefCountObjectPtr ret=self->deepCpy(); + ret->applyRModulus(val); + ret->incrRef(); + return ret; + } + case 3: + { + return DataArrayInt::Modulus(self,a); + } + default: + throw INTERP_KERNEL::Exception(msg); + } + } + + DataArrayInt *operator%=(PyObject *obj) throw(INTERP_KERNEL::Exception) + { + const char msg[]="Unexpected situation in __imod__ !"; + int val; + DataArrayInt *a; + std::vector aa; + int sw; + convertObjToPossibleCpp1(obj,sw,val,aa,a); + switch(sw) + { + case 1: + { + self->applyModulus(val); + return self; + } + case 3: + { + self->modulusEqual(a); + return self; + } + default: + throw INTERP_KERNEL::Exception(msg); + } + } + }; + +namespace ParaMEDMEM +{ + class MEDCouplingField : public ParaMEDMEM::RefCountObject, public ParaMEDMEM::TimeLabel + { + public: + virtual void checkCoherency() const throw(INTERP_KERNEL::Exception); + virtual bool areCompatibleForMerge(const MEDCouplingField *other) const throw(INTERP_KERNEL::Exception); + virtual bool isEqual(const MEDCouplingField *other, double meshPrec, double valsPrec) const throw(INTERP_KERNEL::Exception); + virtual bool isEqualWithoutConsideringStr(const MEDCouplingField *other, double meshPrec, double valsPrec) const throw(INTERP_KERNEL::Exception); + void setMesh(const ParaMEDMEM::MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception); + void setName(const char *name) throw(INTERP_KERNEL::Exception); + const char *getDescription() const throw(INTERP_KERNEL::Exception); + void setDescription(const char *desc) throw(INTERP_KERNEL::Exception); + const char *getName() const throw(INTERP_KERNEL::Exception); + TypeOfField getTypeOfField() const throw(INTERP_KERNEL::Exception); + NatureOfField getNature() const throw(INTERP_KERNEL::Exception); + virtual void setNature(NatureOfField nat) throw(INTERP_KERNEL::Exception); + DataArrayDouble *getLocalizationOfDiscr() const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *buildMeasureField(bool isAbs) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDiscretization *getDiscretization() const throw(INTERP_KERNEL::Exception); + int getNumberOfTuplesExpected() const throw(INTERP_KERNEL::Exception); + int getNumberOfMeshPlacesExpected() const throw(INTERP_KERNEL::Exception); + void setGaussLocalizationOnType(INTERP_KERNEL::NormalizedCellType type, const std::vector& refCoo, + const std::vector& gsCoo, const std::vector& wg) throw(INTERP_KERNEL::Exception); + void clearGaussLocalizations() throw(INTERP_KERNEL::Exception); + MEDCouplingGaussLocalization& getGaussLocalization(int locId) throw(INTERP_KERNEL::Exception); + int getNbOfGaussLocalization() const throw(INTERP_KERNEL::Exception); + int getGaussLocalizationIdOfOneCell(int cellId) const throw(INTERP_KERNEL::Exception); + const MEDCouplingGaussLocalization& getGaussLocalization(int locId) const throw(INTERP_KERNEL::Exception); + %extend { + PyObject *getMesh() const throw(INTERP_KERNEL::Exception) + { + MEDCouplingMesh *ret1=(MEDCouplingMesh *)self->getMesh(); + if(ret1) + ret1->incrRef(); + return convertMesh(ret1, SWIG_POINTER_OWN | 0 ); + } + + PyObject *buildSubMeshData(PyObject *li) const throw(INTERP_KERNEL::Exception) + { + DataArrayInt *ret1=0; + MEDCouplingMesh *ret0=0; + void *da=0; + int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 ); + if (!SWIG_IsOK(res1)) + { + int size; + INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); + ret0=self->buildSubMeshData(tmp,tmp+size,ret1); + } + else + { + DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da); + if(!da2) + throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !"); + da2->checkAllocated(); + ret0=self->buildSubMeshData(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems(),ret1); + } + PyObject *res = PyList_New(2); + PyList_SetItem(res,0,convertMesh(ret0, SWIG_POINTER_OWN | 0 )); + PyList_SetItem(res,1,SWIG_NewPointerObj((void*)ret1,SWIGTYPE_p_ParaMEDMEM__DataArrayInt,SWIG_POINTER_OWN | 0)); + return res; + } + + void setGaussLocalizationOnCells(PyObject *li, const std::vector& refCoo, + const std::vector& gsCoo, const std::vector& wg) throw(INTERP_KERNEL::Exception) + { + void *da=0; + int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 ); + if (!SWIG_IsOK(res1)) + { + int size; + INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); + self->setGaussLocalizationOnCells(tmp,((int *)tmp)+size,refCoo,gsCoo,wg); + } + else + { + DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da); + if(!da2) + throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !"); + da2->checkAllocated(); + self->setGaussLocalizationOnCells(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems(),refCoo,gsCoo,wg); + } + } + + PyObject *getCellIdsHavingGaussLocalization(int locId) const throw(INTERP_KERNEL::Exception) + { + std::vector tmp; + self->getCellIdsHavingGaussLocalization(locId,tmp); + return convertIntArrToPyList2(tmp); + } + } + }; + + class MEDCouplingFieldDouble : public ParaMEDMEM::MEDCouplingField + { + public: + static MEDCouplingFieldDouble *New(TypeOfField type, TypeOfTimeDiscretization td=NO_TIME); + static MEDCouplingFieldDouble *New(const MEDCouplingFieldTemplate *ft, TypeOfTimeDiscretization td=NO_TIME); + void setTimeUnit(const char *unit); + const char *getTimeUnit() const; + void copyTinyStringsFrom(const MEDCouplingFieldDouble *other) throw(INTERP_KERNEL::Exception); + void copyTinyAttrFrom(const MEDCouplingFieldDouble *other) throw(INTERP_KERNEL::Exception); + std::string simpleRepr() const; + std::string advancedRepr() const; + MEDCouplingFieldDouble *clone(bool recDeepCpy) const; + MEDCouplingFieldDouble *cloneWithMesh(bool recDeepCpy) const; + MEDCouplingFieldDouble *deepCpy() const; + MEDCouplingFieldDouble *buildNewTimeReprFromThis(TypeOfTimeDiscretization td, bool deepCpy) const throw(INTERP_KERNEL::Exception); + TypeOfTimeDiscretization getTimeDiscretization() const throw(INTERP_KERNEL::Exception); + double getIJ(int tupleId, int compoId) const throw(INTERP_KERNEL::Exception); + double getIJK(int cellId, int nodeIdInCell, int compoId) const throw(INTERP_KERNEL::Exception); + void setArray(DataArrayDouble *array) throw(INTERP_KERNEL::Exception); + void setEndArray(DataArrayDouble *array) throw(INTERP_KERNEL::Exception); + void setTime(double val, int iteration, int order) throw(INTERP_KERNEL::Exception); + void setStartTime(double val, int iteration, int order) throw(INTERP_KERNEL::Exception); + void setEndTime(double val, int iteration, int order) throw(INTERP_KERNEL::Exception); + void applyLin(double a, double b, int compoId) throw(INTERP_KERNEL::Exception); + int getNumberOfComponents() const throw(INTERP_KERNEL::Exception); + int getNumberOfTuples() const throw(INTERP_KERNEL::Exception); + int getNumberOfValues() const throw(INTERP_KERNEL::Exception); + void setTimeTolerance(double val) throw(INTERP_KERNEL::Exception); + double getTimeTolerance() const throw(INTERP_KERNEL::Exception); + void setIteration(int it) throw(INTERP_KERNEL::Exception); + void setEndIteration(int it) throw(INTERP_KERNEL::Exception); + void setOrder(int order) throw(INTERP_KERNEL::Exception); + void setEndOrder(int order) throw(INTERP_KERNEL::Exception); + void setTimeValue(double val) throw(INTERP_KERNEL::Exception); + void setEndTimeValue(double val) throw(INTERP_KERNEL::Exception); + void updateTime() const throw(INTERP_KERNEL::Exception); + void changeUnderlyingMesh(const MEDCouplingMesh *other, int levOfCheck, double prec) throw(INTERP_KERNEL::Exception); + void substractInPlaceDM(const MEDCouplingFieldDouble *f, int levOfCheck, double prec) throw(INTERP_KERNEL::Exception); + bool mergeNodes(double eps, double epsOnVals=1e-15) throw(INTERP_KERNEL::Exception); + bool mergeNodes2(double eps, double epsOnVals=1e-15) throw(INTERP_KERNEL::Exception); + bool zipCoords(double epsOnVals=1e-15) throw(INTERP_KERNEL::Exception); + bool zipConnectivity(int compType,double epsOnVals=1e-15) throw(INTERP_KERNEL::Exception); + bool simplexize(int policy) throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *doublyContractedProduct() const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *determinant() const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *eigenValues() const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *eigenVectors() const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *inverse() const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *trace() const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *deviator() const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *magnitude() const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *maxPerTuple() const throw(INTERP_KERNEL::Exception); + void changeNbOfComponents(int newNbOfComp, double dftValue=0.) throw(INTERP_KERNEL::Exception); + void sortPerTuple(bool asc) throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble &operator=(double value) throw(INTERP_KERNEL::Exception); + void fillFromAnalytic(int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception); + void applyFunc(int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception); + void applyFunc2(int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception); + void applyFunc3(int nbOfComp, const std::vector& varsOrder, const char *func) throw(INTERP_KERNEL::Exception); + void applyFunc(int nbOfComp, double val) throw(INTERP_KERNEL::Exception); + void applyFunc(const char *func) throw(INTERP_KERNEL::Exception); + void applyFuncFast32(const char *func) throw(INTERP_KERNEL::Exception); + void applyFuncFast64(const char *func) throw(INTERP_KERNEL::Exception); + double accumulate(int compId) const throw(INTERP_KERNEL::Exception); + double getMaxValue() const throw(INTERP_KERNEL::Exception); + double getMinValue() const throw(INTERP_KERNEL::Exception); + double getAverageValue() const throw(INTERP_KERNEL::Exception); + double getWeightedAverageValue() const throw(INTERP_KERNEL::Exception); + double integral(int compId, bool isWAbs) const throw(INTERP_KERNEL::Exception); + double normL1(int compId) const throw(INTERP_KERNEL::Exception); + double normL2(int compId) const throw(INTERP_KERNEL::Exception); + DataArrayInt *getIdsInRange(double vmin, double vmax) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *buildSubPart(const DataArrayInt *part) const throw(INTERP_KERNEL::Exception); + static MEDCouplingFieldDouble *MergeFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception); + static MEDCouplingFieldDouble *MeldFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception); + static MEDCouplingFieldDouble *DotFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *dot(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception); + static MEDCouplingFieldDouble *CrossProductFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *crossProduct(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception); + static MEDCouplingFieldDouble *MaxFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *max(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception); + static MEDCouplingFieldDouble *MinFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception); + static MEDCouplingFieldDouble *AddFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception); + static MEDCouplingFieldDouble *SubstractFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception); + static MEDCouplingFieldDouble *MultiplyFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception); + static MEDCouplingFieldDouble *DivideFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *min(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *operator+(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception); + const MEDCouplingFieldDouble &operator+=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *operator-(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception); + const MEDCouplingFieldDouble &operator-=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *operator*(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception); + const MEDCouplingFieldDouble &operator*=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *operator/(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception); + const MEDCouplingFieldDouble &operator/=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception); + %extend { + std::string __str__() const + { + return self->simpleRepr(); + } + + DataArrayDouble *getArray() throw(INTERP_KERNEL::Exception) + { + DataArrayDouble *ret=self->getArray(); + if(ret) + ret->incrRef(); + return ret; + } + + PyObject *getArrays() const throw(INTERP_KERNEL::Exception) + { + std::vector arrs=self->getArrays(); + for(std::vector::iterator it=arrs.begin();it!=arrs.end();it++) + if(*it) + (*it)->incrRef(); + int sz=arrs.size(); + PyObject *ret=PyTuple_New(sz); + for(int i=0;i tmp; + convertPyObjToVecDataArrayDblCst(ls,tmp); + int sz=tmp.size(); + std::vector arrs(sz); + for(int i=0;i(tmp[i]); + self->setArrays(arrs); + } + + DataArrayDouble *getEndArray() throw(INTERP_KERNEL::Exception) + { + DataArrayDouble *ret=self->getEndArray(); + if(ret) + ret->incrRef(); + return ret; + } + + PyObject *getValueOn(PyObject *sl) const throw(INTERP_KERNEL::Exception) + { + int sz; + INTERP_KERNEL::AutoPtr spaceLoc=convertPyToNewDblArr2(sl,&sz); + sz=self->getNumberOfComponents(); + INTERP_KERNEL::AutoPtr res=new double[sz]; + self->getValueOn(spaceLoc,res); + return convertDblArrToPyList(res,sz); + } + + DataArrayDouble *getValueOnMulti(PyObject *li) const throw(INTERP_KERNEL::Exception) + { + void *da=0; + int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, 0 | 0 ); + if (!SWIG_IsOK(res1)) + { + int size; + INTERP_KERNEL::AutoPtr tmp=convertPyToNewDblArr2(li,&size); + int spaceDim=self->getMesh()->getSpaceDimension(); + int nbOfPoints=size/spaceDim; + if(size%spaceDim!=0) + { + throw INTERP_KERNEL::Exception("Invalid list length ! Must be a multiple of self.getMesh().getSpaceDimension() !"); + } + return self->getValueOnMulti(tmp,nbOfPoints); + } + else + { + DataArrayDouble *da2=reinterpret_cast< DataArrayDouble * >(da); + if(!da2) + throw INTERP_KERNEL::Exception("Not null DataArrayDouble instance expected !"); + da2->checkAllocated(); + int size=da2->getNumberOfTuples(); + int nbOfCompo=da2->getNumberOfComponents(); + if(nbOfCompo!=self->getMesh()->getSpaceDimension()) + { + throw INTERP_KERNEL::Exception("Invalid DataArrayDouble nb of components ! Expected same as self.getMesh().getSpaceDimension() !"); + } + return self->getValueOnMulti(da2->getConstPointer(),size); + } + } + + PyObject *getValueOn(PyObject *sl, double time) const throw(INTERP_KERNEL::Exception) + { + int sz; + INTERP_KERNEL::AutoPtr spaceLoc=convertPyToNewDblArr2(sl,&sz); + sz=self->getNumberOfComponents(); + INTERP_KERNEL::AutoPtr res=new double[sz]; + self->getValueOn(spaceLoc,time,res); + return convertDblArrToPyList(res,sz); + } + void setValues(PyObject *li) throw(INTERP_KERNEL::Exception) + { + if(self->getArray()!=0) + { + int sz; + double *tmp=convertPyToNewDblArr2(li,&sz); + int nbTuples=self->getArray()->getNumberOfTuples(); + int nbOfCompo=self->getArray()->getNumberOfComponents(); + self->getArray()->useArray(tmp,true,CPP_DEALLOC,nbTuples,nbOfCompo); + } + else + PyErr_SetString(PyExc_TypeError,"setValuesCpy : field must contain an array behind"); + } + PyObject *getTime() throw(INTERP_KERNEL::Exception) + { + int tmp1,tmp2; + double tmp0=self->getTime(tmp1,tmp2); + PyObject *res = PyList_New(3); + PyList_SetItem(res,0,SWIG_From_double(tmp0)); + PyList_SetItem(res,1,SWIG_From_int(tmp1)); + PyList_SetItem(res,2,SWIG_From_int(tmp2)); + return res; + } + + PyObject *getStartTime() throw(INTERP_KERNEL::Exception) + { + int tmp1,tmp2; + double tmp0=self->getStartTime(tmp1,tmp2); + PyObject *res = PyList_New(3); + PyList_SetItem(res,0,SWIG_From_double(tmp0)); + PyList_SetItem(res,1,SWIG_From_int(tmp1)); + PyList_SetItem(res,2,SWIG_From_int(tmp2)); + return res; + } + + PyObject *getEndTime() throw(INTERP_KERNEL::Exception) + { + int tmp1,tmp2; + double tmp0=self->getEndTime(tmp1,tmp2); + PyObject *res = PyList_New(3); + PyList_SetItem(res,0,SWIG_From_double(tmp0)); + PyList_SetItem(res,1,SWIG_From_int(tmp1)); + PyList_SetItem(res,2,SWIG_From_int(tmp2)); + return res; + } + PyObject *accumulate() const throw(INTERP_KERNEL::Exception) + { + int sz=self->getNumberOfComponents(); + INTERP_KERNEL::AutoPtr tmp=new double[sz]; + self->accumulate(tmp); + PyObject *ret=convertDblArrToPyList(tmp,sz); + return ret; + } + PyObject *integral(bool isWAbs) const throw(INTERP_KERNEL::Exception) + { + int sz=self->getNumberOfComponents(); + INTERP_KERNEL::AutoPtr tmp=new double[sz]; + self->integral(isWAbs,tmp); + PyObject *ret=convertDblArrToPyList(tmp,sz); + return ret; + } + PyObject *normL1() const throw(INTERP_KERNEL::Exception) + { + int sz=self->getNumberOfComponents(); + INTERP_KERNEL::AutoPtr tmp=new double[sz]; + self->normL1(tmp); + PyObject *ret=convertDblArrToPyList(tmp,sz); + return ret; + } + PyObject *normL2() const throw(INTERP_KERNEL::Exception) + { + int sz=self->getNumberOfComponents(); + INTERP_KERNEL::AutoPtr tmp=new double[sz]; + self->normL2(tmp); + PyObject *ret=convertDblArrToPyList(tmp,sz); + return ret; + } + void renumberCells(PyObject *li, bool check) throw(INTERP_KERNEL::Exception) + { + void *da=0; + int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 ); + if (!SWIG_IsOK(res1)) + { + int size; + INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); + self->renumberCells(tmp,check); + } + else + { + DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da); + if(!da2) + throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !"); + da2->checkAllocated(); + self->renumberCells(da2->getConstPointer(),check); + } + } + void renumberNodes(PyObject *li) throw(INTERP_KERNEL::Exception) + { + void *da=0; + int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 ); + if (!SWIG_IsOK(res1)) + { + int size; + INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); + self->renumberNodes(tmp); + } + else + { + DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da); + if(!da2) + throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !"); + da2->checkAllocated(); + self->renumberNodes(da2->getConstPointer()); + } + } + + MEDCouplingFieldDouble *buildSubPart(PyObject *li) const throw(INTERP_KERNEL::Exception) + { + void *da=0; + int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 ); + if (!SWIG_IsOK(res1)) + { + int size; + INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); + return self->buildSubPart(tmp,((const int *)tmp)+size); + } + else + { + DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da); + if(!da2) + throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !"); + da2->checkAllocated(); + return self->buildSubPart(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems()); + } + } + + PyObject *getMaxValue2() const throw(INTERP_KERNEL::Exception) + { + DataArrayInt *tmp; + double r1=self->getMaxValue2(tmp); + PyObject *ret=PyTuple_New(2); + PyTuple_SetItem(ret,0,PyFloat_FromDouble(r1)); + PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(tmp),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + return ret; + } + + PyObject *getMinValue2() const throw(INTERP_KERNEL::Exception) + { + DataArrayInt *tmp; + double r1=self->getMinValue2(tmp); + PyObject *ret=PyTuple_New(2); + PyTuple_SetItem(ret,0,PyFloat_FromDouble(r1)); + PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(tmp),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + return ret; + } + + MEDCouplingFieldDouble *keepSelectedComponents(PyObject *li) const throw(INTERP_KERNEL::Exception) + { + std::vector tmp; + convertPyToNewIntArr3(li,tmp); + return self->keepSelectedComponents(tmp); + } + + void setSelectedComponents(const MEDCouplingFieldDouble *f, PyObject *li) throw(INTERP_KERNEL::Exception) + { + std::vector tmp; + convertPyToNewIntArr3(li,tmp); + self->setSelectedComponents(f,tmp); + } + + static MEDCouplingFieldDouble *MergeFields(PyObject *li) throw(INTERP_KERNEL::Exception) + { + std::vector tmp; + convertPyObjToVecFieldDblCst(li,tmp); + return MEDCouplingFieldDouble::MergeFields(tmp); + } + } + }; + + class MEDCouplingFieldTemplate : public ParaMEDMEM::MEDCouplingField + { + public: + static MEDCouplingFieldTemplate *New(const MEDCouplingFieldDouble *f) throw(INTERP_KERNEL::Exception); + static MEDCouplingFieldTemplate *New(TypeOfField type); + std::string simpleRepr() const; + std::string advancedRepr() const; + %extend + { + std::string __str__() const + { + return self->simpleRepr(); + } + } + }; + + class MEDCouplingMultiFields : public RefCountObject, public TimeLabel + { + public: + int getNumberOfFields() const; + MEDCouplingMultiFields *deepCpy() const; + virtual std::string simpleRepr() const; + virtual std::string advancedRepr() const; + virtual bool isEqual(const MEDCouplingMultiFields *other, double meshPrec, double valsPrec) const; + virtual bool isEqualWithoutConsideringStr(const MEDCouplingMultiFields *other, double meshPrec, double valsPrec) const; + virtual void checkCoherency() const throw(INTERP_KERNEL::Exception); + %extend + { + std::string __str__() const + { + return self->simpleRepr(); + } + static MEDCouplingMultiFields *New(PyObject *li) throw(INTERP_KERNEL::Exception) + { + std::vector tmp; + convertPyObjToVecFieldDblCst(li,tmp); + int sz=tmp.size(); + std::vector fs(sz); + for(int i=0;i(tmp[i]); + return MEDCouplingMultiFields::New(fs); + } + PyObject *getFields() const + { + std::vector fields=self->getFields(); + int sz=fields.size(); + PyObject *res = PyList_New(sz); + for(int i=0;iincrRef(); + PyList_SetItem(res,i,SWIG_NewPointerObj(SWIG_as_voidptr(fields[i]),SWIGTYPE_p_ParaMEDMEM__MEDCouplingFieldDouble, SWIG_POINTER_OWN | 0 )); + } + else + { + PyList_SetItem(res,i,SWIG_NewPointerObj(SWIG_as_voidptr(0),SWIGTYPE_p_ParaMEDMEM__MEDCouplingFieldDouble, 0 )); + } + } + return res; + } + PyObject *getFieldAtPos(int id) const throw(INTERP_KERNEL::Exception) + { + const MEDCouplingFieldDouble *ret=self->getFieldAtPos(id); + if(ret) + { + ret->incrRef(); + return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_ParaMEDMEM__MEDCouplingFieldDouble, SWIG_POINTER_OWN | 0 ); + } + else + return SWIG_NewPointerObj(SWIG_as_voidptr(0),SWIGTYPE_p_ParaMEDMEM__MEDCouplingFieldDouble, 0 ); + } + PyObject *getMeshes() const throw(INTERP_KERNEL::Exception) + { + std::vector ms=self->getMeshes(); + int sz=ms.size(); + PyObject *res = PyList_New(sz); + for(int i=0;iincrRef(); + PyList_SetItem(res,i,convertMesh(ms[i], SWIG_POINTER_OWN | 0 )); + } + else + { + PyList_SetItem(res,i,SWIG_NewPointerObj(SWIG_as_voidptr(0),SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh, 0 )); + } + } + return res; + } + PyObject *getDifferentMeshes() const throw(INTERP_KERNEL::Exception) + { + std::vector refs; + std::vector ms=self->getDifferentMeshes(refs); + int sz=ms.size(); + PyObject *res = PyList_New(sz); + for(int i=0;iincrRef(); + PyList_SetItem(res,i,convertMesh(ms[i], SWIG_POINTER_OWN | 0 )); + } + else + { + PyList_SetItem(res,i,SWIG_NewPointerObj(SWIG_as_voidptr(0),SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh, 0 )); + } + } + // + PyObject *ret=PyTuple_New(2); + PyTuple_SetItem(ret,0,res); + PyTuple_SetItem(ret,1,convertIntArrToPyList2(refs)); + return ret; + } + PyObject *getArrays() const throw(INTERP_KERNEL::Exception) + { + std::vector ms=self->getArrays(); + int sz=ms.size(); + PyObject *res = PyList_New(sz); + for(int i=0;iincrRef(); + PyList_SetItem(res,i,SWIG_NewPointerObj(SWIG_as_voidptr(ms[i]),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, SWIG_POINTER_OWN | 0 )); + } + else + { + PyList_SetItem(res,i,SWIG_NewPointerObj(SWIG_as_voidptr(0),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, 0 )); + } + } + return res; + } + PyObject *getDifferentArrays() const throw(INTERP_KERNEL::Exception) + { + std::vector< std::vector > refs; + std::vector ms=self->getDifferentArrays(refs); + int sz=ms.size(); + PyObject *res = PyList_New(sz); + PyObject *res2 = PyList_New(sz); + for(int i=0;iincrRef(); + PyList_SetItem(res,i,SWIG_NewPointerObj(SWIG_as_voidptr(ms[i]),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, SWIG_POINTER_OWN | 0 )); + } + else + { + PyList_SetItem(res,i,SWIG_NewPointerObj(SWIG_as_voidptr(0),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, 0 )); + } + PyList_SetItem(res2,i,convertIntArrToPyList2(refs[i])); + } + // + PyObject *ret=PyTuple_New(2); + PyTuple_SetItem(ret,0,res); + PyTuple_SetItem(ret,1,res2); + return ret; + } + } + }; + + class MEDCouplingDefinitionTime + { + public: + MEDCouplingDefinitionTime(); + void assign(const MEDCouplingDefinitionTime& other); + bool isEqual(const MEDCouplingDefinitionTime& other) const; + double getTimeResolution() const; + std::vector getHotSpotsTime() const; + %extend + { + std::string __str__() const + { + std::ostringstream oss; + self->appendRepr(oss); + return oss.str(); + } + + PyObject *getIdsOnTimeRight(double tm) const throw(INTERP_KERNEL::Exception) + { + int meshId,arrId,arrIdInField,fieldId; + self->getIdsOnTimeRight(tm,meshId,arrId,arrIdInField,fieldId); + PyObject *res=PyList_New(4); + PyList_SetItem(res,0,PyInt_FromLong(meshId)); + PyList_SetItem(res,1,PyInt_FromLong(arrId)); + PyList_SetItem(res,2,PyInt_FromLong(arrIdInField)); + PyList_SetItem(res,3,PyInt_FromLong(fieldId)); + return res; + } + + PyObject *getIdsOnTimeLeft(double tm) const throw(INTERP_KERNEL::Exception) + { + int meshId,arrId,arrIdInField,fieldId; + self->getIdsOnTimeLeft(tm,meshId,arrId,arrIdInField,fieldId); + PyObject *res=PyList_New(4); + PyList_SetItem(res,0,PyInt_FromLong(meshId)); + PyList_SetItem(res,1,PyInt_FromLong(arrId)); + PyList_SetItem(res,2,PyInt_FromLong(arrIdInField)); + PyList_SetItem(res,3,PyInt_FromLong(fieldId)); + return res; + } + } + }; + + class MEDCouplingFieldOverTime : public MEDCouplingMultiFields + { + public: + double getTimeTolerance() const throw(INTERP_KERNEL::Exception); + MEDCouplingDefinitionTime getDefinitionTimeZone() const; + + %extend + { + std::string __str__() const + { + return self->simpleRepr(); + } + static MEDCouplingFieldOverTime *New(PyObject *li) throw(INTERP_KERNEL::Exception) + { + std::vector tmp; + convertPyObjToVecFieldDblCst(li,tmp); + int sz=tmp.size(); + std::vector fs(sz); + for(int i=0;i(tmp[i]); + return MEDCouplingFieldOverTime::New(fs); + } + } + }; +} diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py index 281f525bf..391a5036d 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py @@ -1,24 +1,24 @@ # -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2010 CEA/DEN, EDF R&D +# Copyright (C) 2007-2011 CEA/DEN, EDF R&D # -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. # -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. # -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -from libMEDCoupling_Swig import * +from MEDCoupling import * import unittest from math import pi,e,sqrt from MEDCouplingDataForTest import MEDCouplingDataForTest @@ -139,14 +139,14 @@ class MEDCouplingBasicsTest(unittest.TestCase): targetMesh=MEDCouplingUMesh.New(); targetMesh.setMeshDimension(0); targetMesh.allocateCells(8); - targetMesh.insertNextCell(NORM_POINT0,0,[]); - targetMesh.insertNextCell(NORM_POINT0,0,[]); - targetMesh.insertNextCell(NORM_POINT0,0,[]); - targetMesh.insertNextCell(NORM_POINT0,0,[]); - targetMesh.insertNextCell(NORM_POINT0,0,[]); - targetMesh.insertNextCell(NORM_POINT0,0,[]); - targetMesh.insertNextCell(NORM_POINT0,0,[]); - targetMesh.insertNextCell(NORM_POINT0,0,[]); + targetMesh.insertNextCell(NORM_POINT1,1,[0]); + targetMesh.insertNextCell(NORM_POINT1,1,[1]); + targetMesh.insertNextCell(NORM_POINT1,1,[2]); + targetMesh.insertNextCell(NORM_POINT1,1,[3]); + targetMesh.insertNextCell(NORM_POINT1,1,[4]); + targetMesh.insertNextCell(NORM_POINT1,1,[5]); + targetMesh.insertNextCell(NORM_POINT1,1,[7]); + targetMesh.insertNextCell(NORM_POINT1,1,[6]); targetMesh.finishInsertingCells(); myCoords=DataArrayDouble.New(); myCoords.setValues(targetCoords,9,3); @@ -158,17 +158,17 @@ class MEDCouplingBasicsTest(unittest.TestCase): pass def testMeshM1D(self): meshM1D=MEDCouplingUMesh.New(); - self.assertRaises(Exception,meshM1D.getMeshDimension); - self.assertRaises(Exception,meshM1D.getNumberOfNodes); - self.assertRaises(Exception,meshM1D.getNumberOfCells); - self.assertRaises(Exception,meshM1D.setMeshDimension,-2) - self.assertRaises(Exception,meshM1D.setMeshDimension,-10) + self.assertRaises(InterpKernelException,meshM1D.getMeshDimension); + self.assertRaises(InterpKernelException,meshM1D.getNumberOfNodes); + self.assertRaises(InterpKernelException,meshM1D.getNumberOfCells); + self.assertRaises(InterpKernelException,meshM1D.setMeshDimension,-2) + self.assertRaises(InterpKernelException,meshM1D.setMeshDimension,-10) meshM1D.setMeshDimension(-1); meshM1D.checkCoherency(); self.assertEqual(meshM1D.getMeshDimension(),-1); self.assertEqual(meshM1D.getNumberOfCells(),1); - self.assertRaises(Exception,meshM1D.getNumberOfNodes); - self.assertRaises(Exception,meshM1D.getSpaceDimension); + self.assertRaises(InterpKernelException,meshM1D.getNumberOfNodes); + self.assertRaises(InterpKernelException,meshM1D.getSpaceDimension); cpy=meshM1D.clone(True); self.assertTrue(cpy.isEqual(meshM1D,1e-12)); fieldOnCells=MEDCouplingFieldDouble.New(ON_CELLS); @@ -182,20 +182,18 @@ class MEDCouplingBasicsTest(unittest.TestCase): array=DataArrayDouble.New(); array.setValues(5*3*[7.],5,3); self.assertEqual(array.getIJ(3,2),7.); - array2=array.deepCopy(); + array2=array.deepCpy(); self.assertEqual(array2.getIJ(3,2),7.) # array3=DataArrayInt.New(); array3.setValues(5*3*[17],5,3); self.assertEqual(array3.getIJ(3,2),17); - array4=array3.deepCopy(); + array4=array3.deepCpy(); self.assertEqual(array4.getIJ(3,2),17); pass def testRevNodal(self): mesh=MEDCouplingDataForTest.build2DTargetMesh_1() - revNodal=DataArrayInt.New(); - revNodalIndx=DataArrayInt.New(); - mesh.getReverseNodalConnectivity(revNodal,revNodalIndx); + revNodal,revNodalIndx=mesh.getReverseNodalConnectivity(); revNodalExpected=[0,0,1,1,2,0,3,0,1,2,3,4,2,4,3,3,4,4]; revNodalIndexExpected=[0,1,3,5,7,12,14,15,17,18]; self.assertEqual(revNodal.getNbOfElems(),18) @@ -354,6 +352,8 @@ class MEDCouplingBasicsTest(unittest.TestCase): tab1=[0,4] tab2=[0,2,3] # + subMesh=mesh.buildPart(tab1) + self.assertTrue(isinstance(subMesh,MEDCouplingUMesh)) subMesh=mesh.buildPartOfMySelf(tab1,True); self.assertTrue(isinstance(subMesh,MEDCouplingUMesh)) name=subMesh.getName(); @@ -385,8 +385,12 @@ class MEDCouplingBasicsTest(unittest.TestCase): self.assertEqual(4,subMesh.getNodalConnectivityIndex().getNbOfElems()); self.assertEqual(subConn2[0:14],list(subMesh.getNodalConnectivity().getValues())); self.assertEqual(subConnIndex2[0:4],list(subMesh.getNodalConnectivityIndex().getValues())); - subMesh=subMesh.buildPartOfMySelf(range(3),True); - self.assertEqual("PartOf_Toto",subMesh.getName()); + dd=DataArrayInt.New() + dd.alloc(3,1) + dd.iota(0) + dd.setName("coucou") + subMesh=subMesh.buildPartOfMySelf(dd,True); + self.assertEqual("coucou",subMesh.getName()); pass def testBuildPartOfMySelfNode(self): mesh=MEDCouplingDataForTest.build2DTargetMesh_1(); @@ -403,7 +407,11 @@ class MEDCouplingBasicsTest(unittest.TestCase): self.assertEqual(subConn[0:5],list(subMesh.getNodalConnectivity().getValues())); self.assertEqual(subConnIndex[0:2],list(subMesh.getNodalConnectivityIndex().getValues())); # - subMesh=mesh.buildPartOfMySelfNode(tab1[0:2],False); + ddd=DataArrayInt.New() + ddd.setValues(tab1[0:2],2,1) + ddd.setName("ddd") + subMesh=mesh.buildPartOfMySelfNode(ddd,False); + self.assertEqual("ddd",subMesh.getName()) self.assertTrue(isinstance(subMesh,MEDCouplingUMesh)) self.assertEqual(2,len(subMesh.getAllTypes())); self.assertEqual(NORM_TRI3,subMesh.getAllTypes()[0]); @@ -475,8 +483,8 @@ class MEDCouplingBasicsTest(unittest.TestCase): m3=m2.buildPartOfMySelf(cells1,True); self.assertTrue(isinstance(m3,MEDCouplingUMesh)) m4=MEDCouplingDataForTest.build2DSourceMesh_1(); - m5=MEDCouplingUMesh.mergeUMeshes(m1,m3); - m6=MEDCouplingUMesh.mergeUMeshes(m5,m4); + m5=MEDCouplingUMesh.MergeUMeshes(m1,m3); + m6=MEDCouplingUMesh.MergeUMeshes(m5,m4); # self.assertEqual(10,m6.getNumberOfCells()); self.assertEqual(22,m6.getNumberOfNodes()); @@ -592,7 +600,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): self.assertTrue(fieldOnCells1.isEqual(fieldOnCells2,1e-12,1e-15)); self.assertTrue(fieldOnCells2.isEqual(fieldOnCells1,1e-12,1e-15)); # - arr2=arr.deepCopy(); + arr2=arr.deepCpy(); fieldOnCells2.setArray(arr2); self.assertTrue(fieldOnCells1.isEqual(fieldOnCells2,1e-12,1e-15)); self.assertTrue(fieldOnCells2.isEqual(fieldOnCells1,1e-12,1e-15)); @@ -625,8 +633,8 @@ class MEDCouplingBasicsTest(unittest.TestCase): field.setNature(IntegralGlobConstraint); field=MEDCouplingFieldDouble.New(ON_NODES,NO_TIME); field.setNature(ConservativeVolumic); - self.assertRaises(Exception,field.setNature,Integral); - self.assertRaises(Exception,field.setNature,IntegralGlobConstraint); + self.assertRaises(InterpKernelException,field.setNature,Integral); + self.assertRaises(InterpKernelException,field.setNature,IntegralGlobConstraint); pass def testBuildSubMeshData(self): @@ -638,7 +646,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): ret1,di=fieldCells.buildSubMeshData(elts); self.assertTrue(isinstance(ret1,MEDCouplingUMesh)) self.assertEqual(3,ret1.getNumberOfCells()); - self.assertEqual(6,ret1.getNumberOfNodes()); + self.assertEqual(9,ret1.getNumberOfNodes()); self.assertEqual(3,di.getNumberOfTuples()); self.assertEqual(1,di.getNumberOfComponents()); toCheck=di.getValues(); @@ -691,7 +699,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): center=[0.,0.,0.] vector=[0.,1.,0.] m2.rotate(center,vector,-pi/2.); - m3=m1.buildExtrudedMeshFromThis(m2,0); + m3=m1.buildExtrudedMesh(m2,0); # m4=MEDCouplingExtrudedMesh.New(m3,m1,0); self.assertEqual(15,m4.getNumberOfCells()); @@ -711,7 +719,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): #play with polygons and polyedrons cells=[2,3] m1.convertToPolyTypes(cells); - m3=m1.buildExtrudedMeshFromThis(m2,0); + m3=m1.buildExtrudedMesh(m2,0); self.assertEqual(NORM_HEXA8,m3.getTypeOfCell(0)); self.assertEqual(NORM_PENTA6,m3.getTypeOfCell(1)); self.assertEqual(NORM_POLYHED,m3.getTypeOfCell(2)); @@ -736,7 +744,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): center=[0.,0.,0.] vector=[0.,1.,0.] m2.rotate(center,vector,-pi/2.); - m3=m1.buildExtrudedMeshFromThis(m2,0); + m3=m1.buildExtrudedMesh(m2,0); expected1=[1,3,2,0,6,5,7,10,11,8,12,9,14,13,4] rexpected1=[3, 0, 2, 1, 14, 5, 4, 6, 9, 11, 7, 8, 10, 13, 12] m3.renumberCells(expected1,False); @@ -897,7 +905,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): m3=MEDCouplingDataForTest.build2DTargetMesh_1(); m3.tryToShareSameCoords(m2,1e-12); meshes=[m1,m2,m3] - m4=MEDCouplingUMesh.mergeUMeshesOnSameCoords(meshes); + m4=MEDCouplingUMesh.MergeUMeshesOnSameCoords(meshes); m4.checkCoherency(); self.assertEqual(15,m4.getNumberOfCells()); cells1=[0,1,2,3,4] @@ -921,7 +929,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): m2.translate(vec); f1=m1.getMeasureField(True); f2=m2.getMeasureField(True); - f3=MEDCouplingFieldDouble.mergeFields(f1,f2); + f3=MEDCouplingFieldDouble.MergeFields(f1,f2); f3.checkCoherency(); m4=MEDCouplingDataForTest.build2DTargetMeshMerged_1(); self.assertTrue(f3.getMesh().isEqual(m4,1.e-12)); @@ -988,7 +996,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): self.assertTrue(abs(0.5-values4[0])<1.e-12); self.assertTrue(abs(1.-values4[1])<1.e-12); # - self.assertRaises(Exception,m.fillFromAnalytic,ON_NODES,1,"1./(x-0.2)"); + self.assertRaises(InterpKernelException,m.fillFromAnalytic,ON_NODES,1,"1./(x-0.2)"); pass def testFillFromAnalytic2(self): @@ -1165,7 +1173,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): f4.checkCoherency(); self.assertEqual(f4.getTypeOfField(),ON_NODES); self.assertEqual(f4.getTimeDiscretization(),ONE_TIME); - self.assertRaises(Exception,f1.__add__,f4); + self.assertRaises(InterpKernelException,f1.__add__,f4); f5=f4.buildNewTimeReprFromThis(NO_TIME,False); self.assertEqual(f5.getTypeOfField(),ON_NODES); self.assertEqual(f5.getTimeDiscretization(),NO_TIME); @@ -1181,7 +1189,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): f4.checkCoherency(); self.assertEqual(f4.getTypeOfField(),ON_NODES); self.assertEqual(f4.getTimeDiscretization(),ONE_TIME); - self.assertRaises(Exception,f1.__add__,f4); + self.assertRaises(InterpKernelException,f1.__add__,f4); f5=f4.buildNewTimeReprFromThis(NO_TIME,True); self.assertEqual(f5.getTypeOfField(),ON_NODES); self.assertEqual(f5.getTimeDiscretization(),NO_TIME); @@ -1256,7 +1264,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): # f1=m.buildOrthogonalField(); # to avoid valgrind leaks - # self.assertRaises(Exception,f2.__imul__,f1); + # self.assertRaises(InterpKernelException,f2.__imul__,f1); pass def testOperationsOnFields4(self): @@ -1266,8 +1274,8 @@ class MEDCouplingBasicsTest(unittest.TestCase): f1.setMesh(m); array=DataArrayDouble.New(); f1.setArray(array); - self.assertRaises(Exception,f1.setEndArray,array); - self.assertRaises(Exception,f1.getEndArray); + self.assertRaises(InterpKernelException,f1.setEndArray,array); + self.assertRaises(InterpKernelException,f1.getEndArray); arr1=[0.,10.,20.,1.,11.,21.,2.,12.,22.,3.,13.,23.,4.,14.,24.] arr2=[5.,15.,25.,6.,16.,26.,7.,17.,27.,8.,18.,28.,9.,19.,29.] array.setValues(arr1,nbOfCells,3); @@ -1285,13 +1293,13 @@ class MEDCouplingBasicsTest(unittest.TestCase): self.assertTrue(abs(arr1[4]-res[1])<1.e-12); self.assertTrue(abs(arr1[5]-res[2])<1.e-12); res=None - self.assertRaises(Exception,f1.getValueOn,pos,3.2) + self.assertRaises(InterpKernelException,f1.getValueOn,pos,3.2) f2=MEDCouplingFieldDouble.New(ON_CELLS,LINEAR_TIME); f2.setMesh(m); f2.setArray(f1.getArray()); f2.setStartTime(2.,3,0); f2.setEndTime(4.,13,0); - self.assertRaises(Exception,f2.checkCoherency) + self.assertRaises(InterpKernelException,f2.checkCoherency) array2=DataArrayDouble.New(); array2.setValues(arr2,nbOfCells,3); f2.setEndArray(array2); @@ -1356,7 +1364,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): f1=targetMesh.fillFromAnalytic(ON_NODES,1,"x+y+z"); tmp=f1.getArray() tmp.setIJ(1,0,1000.); - self.assertRaises(Exception,f1.mergeNodes,1.e-10) + self.assertRaises(InterpKernelException,f1.mergeNodes,1.e-10) pass def testCheckConsecutiveCellTypes(self): @@ -1413,7 +1421,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): m1=MEDCouplingDataForTest.build3DSurfTargetMesh_1(); v=m1.splitByType(); self.assertEqual(3,len(v)); - m2=MEDCouplingUMesh.mergeUMeshesOnSameCoords(v); + m2=MEDCouplingUMesh.MergeUMeshesOnSameCoords(v); m2.setName(m1.getName()); self.assertTrue(m1.isEqual(m2,1.e-12)); pass @@ -1431,7 +1439,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): self.assertTrue(isinstance(m5,MEDCouplingUMesh)) meshes=[m3,m4,m5] # - m7,corr=MEDCouplingUMesh.fuseUMeshesOnSameCoords(meshes,0); + m7,corr=MEDCouplingUMesh.FuseUMeshesOnSameCoords(meshes,0); self.assertEqual(4,m7.getNumberOfCells()); self.assertEqual(3,len(corr)); expectedVals1=[3,3,2] @@ -1444,7 +1452,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): vals=arr.getValues(); self.assertEqual(expectedVals2[i],list(vals)); pass - arr2,fidsOfGroups=DataArrayInt.makePartition(corr,m7.getNumberOfCells()); + arr2,fidsOfGroups=DataArrayInt.MakePartition(corr,m7.getNumberOfCells()); fidExp=[5,1,3,4] fidsGrp=[[1,3,5],[3,4,5],[4,5]] self.assertEqual(3,len(fidsOfGroups)); @@ -1464,7 +1472,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): part2=[5,6,4,7] m4=m1.buildPartOfMySelf(part2,True); meshes=[m1,m3,m3,m4] - m5,corr=MEDCouplingUMesh.fuseUMeshesOnSameCoords(meshes,0); + m5,corr=MEDCouplingUMesh.FuseUMeshesOnSameCoords(meshes,0); self.assertEqual(18,m5.getNumberOfCells()); exp2=[ [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17], @@ -1512,23 +1520,25 @@ class MEDCouplingBasicsTest(unittest.TestCase): pos=[0.,0.,0.4,0.4,0.,0.4,0.1,0.1,0.25,0.,0.65,0.] #2D basic t1,t2=targetMesh.getCellsContainingPoints(pos,6,1e-12); - self.assertEqual(6,len(t1)); - self.assertEqual(7,len(t2)); + self.assertEqual(6,t1.getNumberOfTuples()); + self.assertEqual(1,t1.getNumberOfComponents()); + self.assertEqual(7,t2.getNumberOfTuples()); + self.assertEqual(1,t2.getNumberOfComponents()); expectedValues1=[0,4,3,0,1,2] expectedValues2=[0,1,2,3,4,5,6] - self.assertEqual(list(t1),expectedValues1); - self.assertEqual(list(t2),expectedValues2); + self.assertEqual(list(t1.getValues()),expectedValues1); + self.assertEqual(list(t2.getValues()),expectedValues2); #2D with no help of bounding box. center=[0.2,0.2] - MEDCouplingPointSet.rotate2DAlg(center,0.78539816339744830962,6,pos); + MEDCouplingPointSet.Rotate2DAlg(center,0.78539816339744830962,6,pos); targetMesh.rotate(center,[],0.78539816339744830962); t1=None t2=None t1,t2=targetMesh.getCellsContainingPoints(pos,6,1e-12); - self.assertEqual(6,len(t1)); - self.assertEqual(7,len(t2)); - self.assertEqual(list(t1),expectedValues1); - self.assertEqual(list(t2),expectedValues2); + self.assertEqual(6,t1.getNumberOfTuples()); + self.assertEqual(7,t2.getNumberOfTuples()); + self.assertEqual(list(t1.getValues()),expectedValues1); + self.assertEqual(list(t2.getValues()),expectedValues2); #2D outside pos1bis=[-0.3303300858899107,-0.11819805153394641] self.assertEqual(-1,targetMesh.getCellContainingPoint(pos1bis,1e-12)); @@ -1673,7 +1683,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): m1=MEDCouplingDataForTest.build2DTargetMesh_1(); m2=MEDCouplingDataForTest.build2DSourceMesh_1(); #self.assertEqual(m1.getCoords()!=m2.getCoords()); - self.assertRaises(Exception,m1.tryToShareSameCoords,m2,1e-12) + self.assertRaises(InterpKernelException,m1.tryToShareSameCoords,m2,1e-12) pass def testFindNodeOnPlane(self): @@ -1690,6 +1700,17 @@ class MEDCouplingBasicsTest(unittest.TestCase): expected=[0,1,2,3,4,5,6,7] val=da.getValues(); self.assertEqual(expected,list(val)); + # + ddd=DataArrayInt.New() + ddd.setValues(n,len(n),1) + m3dSurf=mesh.buildFacePartOfMySelfNode(ddd,True); + self.assertTrue(isinstance(m3dSurf,MEDCouplingUMesh)) + me=MEDCouplingExtrudedMesh.New(mesh,m3dSurf,0); + da=me.getMesh3DIds(); + self.assertEqual(8,me.getNumberOfCells()); + expected=[0,1,2,3,4,5,6,7] + val=da.getValues(); + self.assertEqual(expected,list(val)); pass def testRenumberCells(self): @@ -1743,9 +1764,10 @@ class MEDCouplingBasicsTest(unittest.TestCase): m=MEDCouplingDataForTest.build2DTargetMesh_1(); f=MEDCouplingFieldDouble.New(ON_GAUSS_PT,NO_TIME); f.setMesh(m); + self.assertEqual(5,f.getNumberOfMeshPlacesExpected()); self.assertEqual(0,f.getNbOfGaussLocalization()); f.setGaussLocalizationOnType(NORM_TRI3,_refCoo1,_gsCoo1,_wg1); - self.assertRaises(Exception,f.setGaussLocalizationOnType,NORM_QUAD4,_refCoo1,_gsCoo1,_wg1) + self.assertRaises(InterpKernelException,f.setGaussLocalizationOnType,NORM_QUAD4,_refCoo1,_gsCoo1,_wg1) self.assertEqual(1,f.getNbOfGaussLocalization()); refCoo2=[ 0.,0., 1.,0., 1.,1., 0.,1. ] _refCoo2=refCoo2 @@ -1767,22 +1789,22 @@ class MEDCouplingBasicsTest(unittest.TestCase): # f.clearGaussLocalizations(); self.assertEqual(0,f.getNbOfGaussLocalization()); - self.assertRaises(Exception,f.checkCoherency); + self.assertRaises(InterpKernelException,f.checkCoherency); ids1=[0,1,3,4] - self.assertRaises(Exception,f.setGaussLocalizationOnCells,ids1,_refCoo2,_gsCoo1,_wg1); + self.assertRaises(InterpKernelException,f.setGaussLocalizationOnCells,ids1,_refCoo2,_gsCoo1,_wg1); self.assertEqual(0,f.getNbOfGaussLocalization()); ids2=[0,4] f.setGaussLocalizationOnCells(ids2,_refCoo2,_gsCoo1,_wg1); self.assertEqual(1,f.getNbOfGaussLocalization()); self.assertEqual(0,f.getGaussLocalizationIdOfOneCell(0)); - self.assertRaises(Exception,f.getGaussLocalizationIdOfOneCell,1); + self.assertRaises(InterpKernelException,f.getGaussLocalizationIdOfOneCell,1); ids3=[1,2] f.setGaussLocalizationOnCells(ids3,_refCoo1,_gsCoo1,_wg1); self.assertEqual(2,f.getNbOfGaussLocalization()); self.assertEqual(0,f.getGaussLocalizationIdOfOneCell(0)); self.assertEqual(1,f.getGaussLocalizationIdOfOneCell(1)); self.assertEqual(1,f.getGaussLocalizationIdOfOneCell(2)); - self.assertRaises(Exception,f.checkCoherency);#<- cell 3 has no localization + self.assertRaises(InterpKernelException,f.checkCoherency);#<- cell 3 has no localization ids4=[3] _gsCoo2=_gsCoo1; _wg2=_wg1; @@ -1792,7 +1814,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): self.assertEqual(3,f.getNbOfGaussLocalization()); tmpIds=f.getCellIdsHavingGaussLocalization(0); self.assertEqual(ids2,list(tmpIds)); - self.assertRaises(Exception,f.checkCoherency);#<- it's always not ok because undelying array not with the good size. + self.assertRaises(InterpKernelException,f.checkCoherency);#<- it's always not ok because undelying array not with the good size. array2=f.getArray().substr(0,10); f.setArray(array2); f.checkCoherency();#<- here it is OK @@ -1812,6 +1834,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): m=MEDCouplingDataForTest.build2DTargetMesh_1(); f=MEDCouplingFieldDouble.New(ON_GAUSS_NE,NO_TIME); f.setMesh(m); + self.assertEqual(5,f.getNumberOfMeshPlacesExpected()); f.setName("MyFirstFieldOnNE"); f.setDescription("MyDescriptionNE"); array=DataArrayDouble.New(); @@ -1833,7 +1856,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): def testCellOrientation1(self): m=MEDCouplingDataForTest.build2DTargetMesh_1(); vec=[0.,0.,1.] - self.assertRaises(Exception,m.are2DCellsNotCorrectlyOriented,vec,False); + self.assertRaises(InterpKernelException,m.are2DCellsNotCorrectlyOriented,vec,False); m.changeSpaceDimension(3); res1=m.are2DCellsNotCorrectlyOriented(vec,False); self.assertTrue(len(res1)==0); @@ -1887,7 +1910,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): center=[0.,0.,0.] vector=[0.,1.,0.] m4.rotate(center,vector,-pi/2.); - m5=m3.buildExtrudedMeshFromThis(m4,0); + m5=m3.buildExtrudedMesh(m4,0); res1=m5.arePolyhedronsNotCorrectlyOriented(); self.assertEqual(15,len(res1)); m5.orientCorrectlyPolyhedrons(); @@ -2309,6 +2332,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): m=MEDCouplingDataForTest.build2DTargetMesh_1(); f=MEDCouplingFieldDouble.New(ON_NODES,NO_TIME); f.setMesh(m); + self.assertEqual(9,f.getNumberOfMeshPlacesExpected()); arr=DataArrayDouble.New(); nbOfNodes=m.getNumberOfNodes(); values1=[7.,107.,10007.,8.,108.,10008.,9.,109.,10009.,10.,110.,10010.,11.,111.,10011.,12.,112.,10012.,13.,113.,10013.,14.,114.,10014.,15.,115.,10015.] @@ -2397,7 +2421,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): #Third test : cell permutation by keeping the first the middle and the last as it is. renum=[0,2,1,3,4,5,6,8,7,9] mesh2.renumberCells(renum,False); - self.assertRaises(Exception,mesh1.checkGeoEquivalWith,mesh2,0,1e-12);#deepEqual fails + self.assertRaises(InterpKernelException,mesh1.checkGeoEquivalWith,mesh2,0,1e-12);#deepEqual fails self.assertTrue(cellCor==None); self.assertTrue(nodeCor==None); cellCor,nodeCor=mesh1.checkGeoEquivalWith(mesh2,1,1e-12);#fastEqual do not see anything @@ -2418,7 +2442,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): mesh2.renumberNodes(renum2,11); cellCor=None nodeCor=None - self.assertRaises(Exception,mesh1.checkGeoEquivalWith,mesh2,0,1e-12);#deepEqual fails + self.assertRaises(InterpKernelException,mesh1.checkGeoEquivalWith,mesh2,0,1e-12);#deepEqual fails self.assertTrue(cellCor==None); self.assertTrue(nodeCor==None); cellCor,nodeCor=mesh1.checkGeoEquivalWith(mesh2,1,1e-12);#fastEqual do not see anything @@ -2442,10 +2466,10 @@ class MEDCouplingBasicsTest(unittest.TestCase): mesh2.renumberNodes(renum2,11); cellCor=None nodeCor=None - self.assertRaises(Exception,mesh1.checkGeoEquivalWith,mesh2,0,1e-12) + self.assertRaises(InterpKernelException,mesh1.checkGeoEquivalWith,mesh2,0,1e-12) self.assertTrue(cellCor==None); self.assertTrue(nodeCor==None); - self.assertRaises(Exception,mesh1.checkGeoEquivalWith,mesh2,1,1e-12) + self.assertRaises(InterpKernelException,mesh1.checkGeoEquivalWith,mesh2,1,1e-12) self.assertTrue(cellCor==None); self.assertTrue(nodeCor==None); cellCor,nodeCor=mesh2.checkGeoEquivalWith(mesh1,10,1e-12);#deepEqual with geo permutations @@ -2476,6 +2500,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): nbOfCells=m.getNumberOfCells(); f=MEDCouplingFieldDouble.New(ON_CELLS,LINEAR_TIME); f.setMesh(m); + self.assertEqual(5,f.getNumberOfMeshPlacesExpected()); f.setName("a"); f.setDescription("b"); a1=DataArrayDouble.New(); @@ -2483,7 +2508,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): a1.fillWithZero(); a1.setInfoOnComponent(0,"c"); a1.setInfoOnComponent(1,"d"); - a2=a1.deepCopy(); + a2=a1.deepCpy(); a2.setInfoOnComponent(0,"e"); a2.setInfoOnComponent(1,"f"); f.setArray(a1); @@ -2533,7 +2558,9 @@ class MEDCouplingBasicsTest(unittest.TestCase): #self.assertTrue(m.getCoords()==m2.getCoords()); self.assertTrue(m2.isEqual(m,1e-12)); renum1=[1,2,0,5,8,7,4,3,6] - m.renumberNodes(renum1,9); + r1=DataArrayInt.New() + r1.setValues(renum1,len(renum1),1) + m.renumberNodes(r1,9); #self.assertTrue(m.getCoords()!=m2.getCoords()); self.assertTrue(not m2.isEqual(m,1e-12)); m.tryToShareSameCoordsPermute(m2,1e-12); @@ -2565,7 +2592,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): self.assertAlmostEqual(expected1[i],f1.getIJ(i,0),12); pass self.assertAlmostEqual(expected1[0],f2.getIJ(0,0),12); - self.assertRaises(Exception,m1.tryToShareSameCoordsPermute,m2,1e-12);# <- here in this order the sharing is impossible. + self.assertRaises(InterpKernelException,m1.tryToShareSameCoordsPermute,m2,1e-12);# <- here in this order the sharing is impossible. # Let's go for deeper test of tryToShareSameCoordsPermute m2.tryToShareSameCoordsPermute(m1,1e-12); f1=m1.getMeasureField(False); @@ -2612,7 +2639,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): #self.assertTrue(f1.getMesh()==mesh1); f1.changeUnderlyingMesh(mesh2,10,1e-12); #self.assertTrue(f1.getMesh()==mesh2); - expected2=[7.,107.,9.,109.,17.,117.,10.,110.,11.,111.,12.,112.,13.,113.,15.,115.,14.,114.,16.,116.,8.,108.] + expected2=[7.,107.,17.,117.,8.,108.,10.,110.,11.,111.,12.,112.,13.,113.,15.,115.,14.,114.,16.,116.,9.,109.] for i in xrange(22): self.assertAlmostEqual(expected2[i],f1.getArray().getIJ(0,i),12); pass @@ -2660,13 +2687,13 @@ class MEDCouplingBasicsTest(unittest.TestCase): self.assertEqual(2,f1.getNumberOfComponents()); self.assertEqual(20,f1.getNumberOfValues()); # - renum=[0,2,1,3,4,5,6,8,7,9] + renum=[0,2,3,1,4,5,6,8,7,9] mesh2.renumberCells(renum,False); # f2=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME); f2.setMesh(mesh2); array=DataArrayDouble.New(); - arr2=[7.1,107.1,9.1,109.1,8.1,108.1,10.1,110.1,11.1,111.1,12.1,112.1,13.1,113.1,15.1,115.1,14.1,114.1,16.1,116.1] + arr2=[7.1,107.1,10.1,110.1,8.1,108.1,9.1,109.1,11.1,111.1,12.1,112.1,13.1,113.1,15.1,115.1,14.1,114.1,16.1,116.1] array.setValues(arr2,mesh2.getNumberOfCells(),2); f2.setArray(array); # @@ -2803,6 +2830,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): # part1=[2,1,4] f2=f1.buildSubPart(part1); + f2.zipCoords() self.failUnlessEqual(3,f2.getNumberOfTuples()); self.failUnlessEqual(2,f2.getNumberOfComponents()); expected1=[5.,105.,4.,104.,7.,107.] @@ -2947,7 +2975,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7] array.setValues(arr2,mesh1.getNumberOfNodes(),6); f1.setArray(array); - self.assertRaises(Exception,f1.checkCoherency);#no end array specified ! + self.assertRaises(InterpKernelException,f1.checkCoherency);#no end array specified ! # f2=f1.determinant(); self.assertEqual(LINEAR_TIME,f2.getTimeDiscretization()); @@ -3314,7 +3342,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): self.assertTrue(not mesh1.isEqual(mesh2,1e-12)); self.assertTrue(mesh1.isEqualWithoutConsideringStr(mesh2,1e-12)); da1,da2=mesh1.checkGeoEquivalWith(mesh2,2,1e-12); - self.assertRaises(Exception,mesh1.checkGeoEquivalWith,mesh2,0,1e-12); + self.assertRaises(InterpKernelException,mesh1.checkGeoEquivalWith,mesh2,0,1e-12); mesh2.setName(""); self.assertTrue(mesh1.isEqual(mesh2,1e-12)); self.assertTrue(mesh1.isEqualWithoutConsideringStr(mesh2,1e-12)); @@ -3411,7 +3439,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): def testFillFromAnalytic3(self): m=MEDCouplingDataForTest.build2DTargetMesh_1() f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME) - self.assertRaises(Exception,f1.fillFromAnalytic,1,"y+x"); + self.assertRaises(InterpKernelException,f1.fillFromAnalytic,1,"y+x"); f1.setMesh(m) f1.setName("myField"); f1.fillFromAnalytic(1,"y+x"); @@ -3487,13 +3515,13 @@ class MEDCouplingBasicsTest(unittest.TestCase): # f1=MEDCouplingFieldDouble.New(ON_NODES,NO_TIME); f1.setMesh(m); - self.assertRaises(Exception,f1.fillFromAnalytic,1,"1./(x-0.2)"); + self.assertRaises(InterpKernelException,f1.fillFromAnalytic,1,"1./(x-0.2)"); pass def testFieldDoubleOpEqual1(self): m=MEDCouplingDataForTest.build2DTargetMesh_1(); f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME); - self.assertRaises(Exception,f1.assign,0.07); + self.assertRaises(InterpKernelException,f1.assign,0.07); f1.setMesh(m); f1.assign(0.07); f1.checkCoherency(); @@ -3725,8 +3753,8 @@ class MEDCouplingBasicsTest(unittest.TestCase): m3_1=m2.buildPartOfMySelf(cells1,True); m3=m3_1; m4=MEDCouplingDataForTest.build2DSourceMesh_1(); - m5=MEDCouplingUMesh.mergeUMeshes(m1,m3); - m6=MEDCouplingUMesh.mergeUMeshes(m5,m4); + m5=MEDCouplingUMesh.MergeUMeshes(m1,m3); + m6=MEDCouplingUMesh.MergeUMeshes(m5,m4); # self.assertEqual(10,m6.getNumberOfCells()); self.assertEqual(22,m6.getNumberOfNodes()); @@ -4087,6 +4115,9 @@ class MEDCouplingBasicsTest(unittest.TestCase): pos1=[5.,30.,2.] self.assertEqual(16,m.getCellContainingPoint(pos1,1e-12)); # + elems=m2.getCellsInBoundingBox([3.5,6.,12.2,25.,0.,1.5],1e-7) + self.assertEqual([1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17],elems) + # pt=[2.4,12.7,-3.4] m.scale(pt,3.7); m3=m.buildUnstructured(); @@ -4126,150 +4157,3250 @@ class MEDCouplingBasicsTest(unittest.TestCase): pass pass - def testKeepSetSelectedComponent1(self): - arr1=[1.,2.,3.,4., 11.,12.,13.,14., 21.,22.,23.,24., 31.,32.,33.,34., 41.,42.,43.,44.] - a1=DataArrayDouble.New(); - a1.setValues(arr1,5,4); - a1.setInfoOnComponent(0,"aaaa"); - a1.setInfoOnComponent(1,"bbbb"); - a1.setInfoOnComponent(2,"cccc"); - a1.setInfoOnComponent(3,"dddd"); - arr2V=[1,2,1,2,0,0] - a2=a1.keepSelectedComponents(arr2V); - self.assertEqual(6,a2.getNumberOfComponents()); - self.assertEqual(5,a2.getNumberOfTuples()); - self.assertTrue(a2.getInfoOnComponent(0)=="bbbb"); - self.assertTrue(a2.getInfoOnComponent(1)=="cccc"); - self.assertTrue(a2.getInfoOnComponent(2)=="bbbb"); - self.assertTrue(a2.getInfoOnComponent(3)=="cccc"); - self.assertTrue(a2.getInfoOnComponent(4)=="aaaa"); - self.assertTrue(a2.getInfoOnComponent(5)=="aaaa"); - expected1=[2.,3.,2.,3.,1.,1., 12.,13.,12.,13.,11.,11., 22.,23.,22.,23.,21.,21., 32.,33.,32.,33.,31.,31., 42.,43.,42.,43.,41.,41.] - for i in xrange(30): - self.assertAlmostEqual(expected1[i],a2.getIJ(0,i),14); + def testDoublyContractedProduct1(self): + mesh1=MEDCouplingDataForTest.build2DTargetMesh_1(); + f1=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME); + f1.setMesh(mesh1); + array=DataArrayDouble.New(); + arr1=[7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5] + array.setValues(arr1,mesh1.getNumberOfCells(),6); + f1.setArray(array); + f1.checkCoherency(); + # + f2=f1.doublyContractedProduct(); + f2.checkCoherency(); + self.assertEqual(1,f2.getNumberOfComponents()); + self.assertEqual(5,f2.getNumberOfTuples()); + for i in xrange(5): + self.assertAlmostEqual(3906.56,f2.getIJ(i,0),9); pass - a3=a1.convertToIntArr(); - a4=a3.keepSelectedComponents(arr2V); - self.assertEqual(6,a4.getNumberOfComponents()); - self.assertEqual(5,a4.getNumberOfTuples()); - self.assertTrue(a4.getInfoOnComponent(0)=="bbbb"); - self.assertTrue(a4.getInfoOnComponent(1)=="cccc"); - self.assertTrue(a4.getInfoOnComponent(2)=="bbbb"); - self.assertTrue(a4.getInfoOnComponent(3)=="cccc"); - self.assertTrue(a4.getInfoOnComponent(4)=="aaaa"); - self.assertTrue(a4.getInfoOnComponent(5)=="aaaa"); - for i in xrange(30): - self.assertEqual(int(expected1[i]),a4.getIJ(0,i)); + # + pass + + def testDeterminant1(self): + mesh1=MEDCouplingDataForTest.build2DTargetMesh_1(); + f1=MEDCouplingFieldDouble.New(ON_CELLS,CONST_ON_TIME_INTERVAL); + f1.setTime(2.3,5,6); + f1.setEndTime(3.8,7,3); + f1.setMesh(mesh1); + array=DataArrayDouble.New(); + arr1=[1.2,2.3,3.4,4.5, 1.2,2.3,3.4,4.5, 1.2,2.3,3.4,4.5, 1.2,2.3,3.4,4.5, 1.2,2.3,3.4,4.5] + array.setValues(arr1,mesh1.getNumberOfCells(),4); + f1.setArray(array); + #4 components + f1.checkCoherency(); + f2=f1.determinant(); + f2.checkCoherency(); + self.assertEqual(CONST_ON_TIME_INTERVAL,f2.getTimeDiscretization()); + self.assertEqual(1,f2.getNumberOfComponents()); + self.assertEqual(5,f2.getNumberOfValues()); + for i in xrange(5): + self.assertAlmostEqual(-2.42,f2.getIJ(i,0),13); pass - # setSelectedComponents - arr3V=[3,2] - a5=a1.keepSelectedComponents(arr3V); - a5.setInfoOnComponent(0,"eeee"); - a5.setInfoOnComponent(1,"ffff"); - arr4V=[1,2] - a2.setSelectedComponents(a5,arr4V); - self.assertEqual(6,a2.getNumberOfComponents()); - self.assertEqual(5,a2.getNumberOfTuples()); - self.assertTrue(a2.getInfoOnComponent(0)=="bbbb"); - self.assertTrue(a2.getInfoOnComponent(1)=="eeee"); - self.assertTrue(a2.getInfoOnComponent(2)=="ffff"); - self.assertTrue(a2.getInfoOnComponent(3)=="cccc"); - self.assertTrue(a2.getInfoOnComponent(4)=="aaaa"); - self.assertTrue(a2.getInfoOnComponent(5)=="aaaa"); - expected2=[2.,4.,3.,3.,1.,1., 12.,14.,13.,13.,11.,11., 22.,24.,23.,23.,21.,21., 32.,34.,33.,33.,31.,31., 42.,44.,43.,43.,41.,41.] - for i in xrange(30): - self.assertAlmostEqual(expected2[i],a2.getIJ(0,i),14); + #6 components multi arrays with end array not defined + f1=MEDCouplingFieldDouble.New(ON_NODES,LINEAR_TIME); + f1.setTime(2.3,5,6); + f1.setEndTime(3.8,7,3); + f1.setMesh(mesh1); + array=DataArrayDouble.New(); + arr2=[1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, + 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7] + array.setValues(arr2,mesh1.getNumberOfNodes(),6); + f1.setArray(array); + self.assertRaises(InterpKernelException,f1.checkCoherency);#no end array specified ! + # + f2=f1.determinant(); + self.assertEqual(LINEAR_TIME,f2.getTimeDiscretization()); + self.assertEqual(1,f2.getArray().getNumberOfComponents()); + self.assertEqual(9,f2.getNumberOfTuples()); + for i in xrange(9): + self.assertAlmostEqual(137.335,f2.getIJ(i,0),10); pass - a6=a5.convertToIntArr(); - a6.setInfoOnComponent(0,"eeee"); - a6.setInfoOnComponent(1,"ffff"); - a4.setSelectedComponents(a6,arr4V); - self.assertEqual(6,a4.getNumberOfComponents()); - self.assertEqual(5,a4.getNumberOfTuples()); - self.assertTrue(a4.getInfoOnComponent(0)=="bbbb"); - self.assertTrue(a4.getInfoOnComponent(1)=="eeee"); - self.assertTrue(a4.getInfoOnComponent(2)=="ffff"); - self.assertTrue(a4.getInfoOnComponent(3)=="cccc"); - self.assertTrue(a4.getInfoOnComponent(4)=="aaaa"); - self.assertTrue(a4.getInfoOnComponent(5)=="aaaa"); - for i in xrange(30): - self.assertEqual(int(expected2[i]),a4.getIJ(0,i)); + #6 components multi arrays with end array defined + array=DataArrayDouble.New(); + arr3=[7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, + 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5] + array.setValues(arr3,mesh1.getNumberOfNodes(),6); + f1.setEndArray(array); + f1.checkCoherency(); + f2=f1.determinant(); + f2.checkCoherency(); + self.assertEqual(LINEAR_TIME,f2.getTimeDiscretization()); + self.assertEqual(1,f2.getNumberOfComponents()); + self.assertEqual(9,f2.getNumberOfTuples()); + time2,it,order=f2.getTime() + self.assertAlmostEqual(2.3,time2,12); + self.assertEqual(5,it); + self.assertEqual(6,order); + time2,it,order=f2.getEndTime() + self.assertAlmostEqual(3.8,time2,12); + self.assertEqual(7,it); + self.assertEqual(3,order); + for i in xrange(9): + self.assertAlmostEqual(137.335,f2.getIJ(i,0),10); + self.assertAlmostEqual(1289.685,f2.getEndArray().getIJ(i,0),9); pass - # test of throw - arr5V=[2,3,6] - arr6V=[2,7,5] - arr7V=[2,1,4,6] - self.assertRaises(Exception,a2.keepSelectedComponents,arr5V); - self.assertRaises(Exception,a2.keepSelectedComponents,arr6V); - self.assertRaises(Exception,a2.setSelectedComponents,a1,arr7V); - arr7V=arr7V[0:3] - self.assertRaises(Exception,a2.setSelectedComponents,a1,arr7V); + #9 components + f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME); + f1.setTime(7.8,10,2); + f1.setMesh(mesh1); + array=DataArrayDouble.New(); + arr4=[1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1, 1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1, 1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1, 1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1, 1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1] + array.setValues(arr4,mesh1.getNumberOfCells(),9); + f1.setArray(array); # + f1.checkCoherency(); + f2=f1.determinant(); + f2.checkCoherency(); + self.assertEqual(ONE_TIME,f2.getTimeDiscretization()); + self.assertEqual(1,f2.getNumberOfComponents()); + self.assertEqual(5,f2.getNumberOfTuples()); + time2,it,order=f2.getTime() + self.assertAlmostEqual(7.8,time2,12); + self.assertEqual(10,it); + self.assertEqual(2,order); + for i in xrange(5): + self.assertAlmostEqual(3.267,f2.getIJ(i,0),13); + pass pass - def testKeepSetSelectedComponent2(self): - m1=MEDCouplingDataForTest.build2DTargetMesh_1(); - arr1=[1.,2.,3.,4., 11.,12.,13.,14., 21.,22.,23.,24., 31.,32.,33.,34., 41.,42.,43.,44.] - a1=DataArrayDouble.New(); - a1.setValues(arr1,5,4); - a1.setInfoOnComponent(0,"aaaa"); - a1.setInfoOnComponent(1,"bbbb"); - a1.setInfoOnComponent(2,"cccc"); - a1.setInfoOnComponent(3,"dddd"); - f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME); - f1.setTime(2.3,4,5); - f1.setMesh(m1); - f1.setName("f1"); - f1.setArray(a1); + def testEigenValues1(self): + mesh1=MEDCouplingDataForTest.build2DTargetMesh_1(); + f1=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME); + f1.setMesh(mesh1); + array=DataArrayDouble.New(); + arr1=[1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7] + array.setValues(arr1,mesh1.getNumberOfCells(),6); + f1.setArray(array); f1.checkCoherency(); # - arr2V=[1,2,1,2,0,0] - f2=f1.keepSelectedComponents(arr2V); - self.assertTrue(f2.getTimeDiscretization()==ONE_TIME); - t,dt,it=f2.getTime() - self.assertAlmostEqual(2.3,t,13); - self.assertEqual(4,dt); - self.assertEqual(5,it); + f2=f1.eigenValues(); f2.checkCoherency(); - self.assertEqual(6,f2.getNumberOfComponents()); + self.assertEqual(3,f2.getNumberOfComponents()); self.assertEqual(5,f2.getNumberOfTuples()); - self.assertTrue(f2.getArray().getInfoOnComponent(0)=="bbbb"); - self.assertTrue(f2.getArray().getInfoOnComponent(1)=="cccc"); - self.assertTrue(f2.getArray().getInfoOnComponent(2)=="bbbb"); - self.assertTrue(f2.getArray().getInfoOnComponent(3)=="cccc"); - self.assertTrue(f2.getArray().getInfoOnComponent(4)=="aaaa"); - self.assertTrue(f2.getArray().getInfoOnComponent(5)=="aaaa"); - expected1=[2.,3.,2.,3.,1.,1., 12.,13.,12.,13.,11.,11., 22.,23.,22.,23.,21.,21., 32.,33.,32.,33.,31.,31., 42.,43.,42.,43.,41.,41.] - for i in xrange(30): - self.assertAlmostEqual(expected1[i],f2.getIJ(0,i),14); + expected1=[13.638813677891717,-4.502313844635971,-2.2364998332557486] + for i in xrange(5): + self.assertAlmostEqual(expected1[0],f2.getIJ(i,0),13); + self.assertAlmostEqual(expected1[1],f2.getIJ(i,1),13); + self.assertAlmostEqual(expected1[2],f2.getIJ(i,2),13); pass - #setSelectedComponents - arr3V=[3,2] - f5=f1.keepSelectedComponents(arr3V); - f5.setTime(6.7,8,9); - f5.getArray().setInfoOnComponent(0,"eeee"); - f5.getArray().setInfoOnComponent(1,"ffff"); - f5.checkCoherency(); - arr4V=[1,2] - f2.setSelectedComponents(f5,arr4V); - self.assertEqual(6,f2.getNumberOfComponents()); - self.assertEqual(5,f2.getNumberOfTuples()); + pass + + def testEigenVectors1(self): + mesh1=MEDCouplingDataForTest.build2DTargetMesh_1(); + f1=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME); + f1.setMesh(mesh1); + array=DataArrayDouble.New(); + arr1=[1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7] + array.setValues(arr1,mesh1.getNumberOfCells(),6); + f1.setArray(array); + f1.checkCoherency(); + # + f2=f1.eigenVectors(); f2.checkCoherency(); - t,dt,it=f2.getTime() - self.assertAlmostEqual(2.3,t,13); - self.assertEqual(4,dt); - self.assertEqual(5,it); - self.assertTrue(f2.getArray().getInfoOnComponent(0)=="bbbb"); - self.assertTrue(f2.getArray().getInfoOnComponent(1)=="eeee"); + self.assertEqual(9,f2.getNumberOfComponents()); + self.assertEqual(5,f2.getNumberOfTuples()); + expected1=[0.5424262364180696, 0.5351201064614425, 0.6476266283176001,#eigenvect 0 + 0.7381111277307373, 0.06458838384003074, -0.6715804522117897,#eigenvect 1 + -0.4012053603397987, 0.8423032781211455, -0.3599436712889738#eigenvect 2 + ] + for i in xrange(5): + self.assertAlmostEqual(expected1[0],f2.getIJ(i,0),13); + self.assertAlmostEqual(expected1[1],f2.getIJ(i,1),13); + self.assertAlmostEqual(expected1[2],f2.getIJ(i,2),13); + self.assertAlmostEqual(expected1[3],f2.getIJ(i,3),13); + self.assertAlmostEqual(expected1[4],f2.getIJ(i,4),13); + self.assertAlmostEqual(expected1[5],f2.getIJ(i,5),13); + self.assertAlmostEqual(expected1[6],f2.getIJ(i,6),13); + self.assertAlmostEqual(expected1[7],f2.getIJ(i,7),13); + self.assertAlmostEqual(expected1[8],f2.getIJ(i,8),13); + pass + # + pass + + def testInverse1(self): + mesh1=MEDCouplingDataForTest.build2DTargetMesh_1(); + f1=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME); + f1.setMesh(mesh1); + array=DataArrayDouble.New(); + arr1=[1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1, 1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1, 1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1, 1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1, 1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1] + array.setValues(arr1,mesh1.getNumberOfCells(),9); + f1.setArray(array); + f1.checkCoherency(); + # + f2=f1.inverse(); + f2.checkCoherency(); + self.assertEqual(9,f2.getNumberOfComponents()); + self.assertEqual(5,f2.getNumberOfTuples()); + expected1=[-2.6538108356290113, 2.855831037649208, -1.1111111111111067, 3.461891643709813, -4.775022956841121, 2.2222222222222143, -1.1111111111111054, 2.222222222222214, -1.1111111111111072] + for i in xrange(5): + self.assertAlmostEqual(expected1[0],f2.getIJ(i,0),13); + self.assertAlmostEqual(expected1[1],f2.getIJ(i,1),13); + self.assertAlmostEqual(expected1[2],f2.getIJ(i,2),13); + self.assertAlmostEqual(expected1[3],f2.getIJ(i,3),13); + self.assertAlmostEqual(expected1[4],f2.getIJ(i,4),13); + self.assertAlmostEqual(expected1[5],f2.getIJ(i,5),13); + self.assertAlmostEqual(expected1[6],f2.getIJ(i,6),13); + self.assertAlmostEqual(expected1[7],f2.getIJ(i,7),13); + self.assertAlmostEqual(expected1[8],f2.getIJ(i,8),13); + pass + # + array=DataArrayDouble.New(); + arr3=[7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5] + array.setValues(arr3,mesh1.getNumberOfCells(),6); + f1.setArray(array); + f1.checkCoherency(); + # + f2=f1.inverse(); + f2.checkCoherency(); + self.assertEqual(6,f2.getNumberOfComponents()); + self.assertEqual(5,f2.getNumberOfTuples()); + expected3=[-0.3617705098531818, -0.8678630828458127, -0.026843764174972983, 0.5539957431465833, 0.13133439560823013, -0.05301294502145887] + for i in xrange(5): + self.assertAlmostEqual(expected3[0],f2.getIJ(i,0),13); + self.assertAlmostEqual(expected3[1],f2.getIJ(i,1),13); + self.assertAlmostEqual(expected3[2],f2.getIJ(i,2),13); + self.assertAlmostEqual(expected3[3],f2.getIJ(i,3),13); + self.assertAlmostEqual(expected3[4],f2.getIJ(i,4),13); + self.assertAlmostEqual(expected3[5],f2.getIJ(i,5),13); + pass + # + array=DataArrayDouble.New(); + arr2=[1.2,2.3,3.4,4.5, 1.2,2.3,3.4,4.5, 1.2,2.3,3.4,4.5, 1.2,2.3,3.4,4.5, 1.2,2.3,3.4,4.5] + array.setValues(arr2,mesh1.getNumberOfCells(),4); + f1.setArray(array); + f1.checkCoherency(); + # + f2=f1.inverse(); + f2.checkCoherency(); + self.assertEqual(4,f2.getNumberOfComponents()); + self.assertEqual(5,f2.getNumberOfTuples()); + expected2=[-1.8595041322314059, 0.9504132231404963, 1.404958677685951, -0.49586776859504156] + for i in xrange(5): + self.assertAlmostEqual(expected2[0],f2.getIJ(i,0),13); + self.assertAlmostEqual(expected2[1],f2.getIJ(i,1),13); + self.assertAlmostEqual(expected2[2],f2.getIJ(i,2),13); + self.assertAlmostEqual(expected2[3],f2.getIJ(i,3),13); + pass + # + pass + + def testTrace1(self): + mesh1=MEDCouplingDataForTest.build2DTargetMesh_1(); + f1=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME); + f1.setMesh(mesh1); + array=DataArrayDouble.New(); + arr1=[1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1, 1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1, 1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1, 1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1, 1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1] + array.setValues(arr1,mesh1.getNumberOfCells(),9); + f1.setArray(array); + f1.checkCoherency(); + # + f2=f1.trace(); + f2.checkCoherency(); + self.assertEqual(1,f2.getNumberOfComponents()); + self.assertEqual(5,f2.getNumberOfTuples()); + for i in xrange(5): + self.assertAlmostEqual(15.9,f2.getIJ(i,0),13); + pass + # + array=DataArrayDouble.New(); + arr3=[7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5] + array.setValues(arr3,mesh1.getNumberOfCells(),6); + f1.setArray(array); + f1.checkCoherency(); + # + f2=f1.trace(); + f2.checkCoherency(); + self.assertEqual(1,f2.getNumberOfComponents()); + self.assertEqual(5,f2.getNumberOfTuples()); + for i in xrange(5): + self.assertAlmostEqual(25.8,f2.getIJ(i,0),13); + pass + # + array=DataArrayDouble.New(); + arr2=[1.2,2.3,3.4,4.5, 1.2,2.3,3.4,4.5, 1.2,2.3,3.4,4.5, 1.2,2.3,3.4,4.5, 1.2,2.3,3.4,4.5] + array.setValues(arr2,mesh1.getNumberOfCells(),4); + f1.setArray(array); + f1.checkCoherency(); + # + f2=f1.trace(); + f2.checkCoherency(); + self.assertEqual(1,f2.getNumberOfComponents()); + self.assertEqual(5,f2.getNumberOfTuples()); + for i in xrange(5): + self.assertAlmostEqual(5.7,f2.getIJ(i,0),13); + pass + # + pass + + def testDeviator1(self): + mesh1=MEDCouplingDataForTest.build2DTargetMesh_1(); + f1=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME); + f1.setMesh(mesh1); + array=DataArrayDouble.New(); + arr1=[1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7] + array.setValues(arr1,mesh1.getNumberOfCells(),6); + f1.setArray(array); + f1.checkCoherency(); + # + f2=f1.deviator(); + f2.checkCoherency(); + self.assertEqual(6,f2.getNumberOfComponents()); + self.assertEqual(5,f2.getNumberOfTuples()); + expected1=[-1.1,0.,1.1,4.5,5.6,6.7] + for i in xrange(5): + self.assertAlmostEqual(expected1[0],f2.getIJ(i,0),13); + self.assertAlmostEqual(expected1[1],f2.getIJ(i,1),13); + self.assertAlmostEqual(expected1[2],f2.getIJ(i,2),13); + self.assertAlmostEqual(expected1[3],f2.getIJ(i,3),13); + self.assertAlmostEqual(expected1[4],f2.getIJ(i,4),13); + self.assertAlmostEqual(expected1[5],f2.getIJ(i,5),13); + pass + # + pass + + def testMagnitude1(self): + mesh1=MEDCouplingDataForTest.build2DTargetMesh_1(); + f1=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME); + f1.setMesh(mesh1); + array=DataArrayDouble.New(); + arr1=[1.2,2.3,3.4,4.5,5.6, 1.2,2.3,3.4,4.5,5.6, 1.2,2.3,3.4,4.5,5.6, 1.2,2.3,3.4,4.5,5.6, 1.2,2.3,3.4,4.5,5.6] + array.setValues(arr1,mesh1.getNumberOfCells(),5); + f1.setArray(array); + f1.checkCoherency(); + # + f2=f1.magnitude(); + f2.checkCoherency(); + self.assertEqual(1,f2.getNumberOfComponents()); + self.assertEqual(5,f2.getNumberOfTuples()); + for i in xrange(5): + self.assertAlmostEqual(8.3606219864313918,f2.getIJ(i,0),13); + pass + # + pass + + def testMaxPerTuple1(self): + mesh1=MEDCouplingDataForTest.build2DTargetMesh_1(); + f1=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME); + f1.setMesh(mesh1); + array=DataArrayDouble.New(); + arr1=[1.2,2.3,3.4,4.5,5.6, 1.2,3.4,4.5,5.6,2.3, 3.4,4.5,5.6,1.2,2.3, 5.6,1.2,2.3,3.4,4.5, 4.5,5.6,1.2,2.3,3.4] + array.setValues(arr1,mesh1.getNumberOfCells(),5); + f1.setArray(array); + f1.checkCoherency(); + # + f2=f1.maxPerTuple(); + f2.checkCoherency(); + self.assertEqual(1,f2.getNumberOfComponents()); + self.assertEqual(5,f2.getNumberOfTuples()); + for i in xrange(5): + self.assertAlmostEqual(5.6,f2.getIJ(i,0),13); + pass + # + pass + + def testChangeNbOfComponents(self): + mesh1=MEDCouplingDataForTest.build2DTargetMesh_1(); + f1=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME); + f1.setMesh(mesh1); + array=DataArrayDouble.New(); + arr1=[1.2,2.3,3.4,4.5,5.6, 1.2,3.4,4.5,5.6,2.3, 3.4,4.5,5.6,1.2,2.3, 5.6,1.2,2.3,3.4,4.5, 4.5,5.6,1.2,2.3,3.4] + array.setValues(arr1,mesh1.getNumberOfCells(),5); + f1.setArray(array); + f1.checkCoherency(); + # + f1.changeNbOfComponents(3,7.77); + f1.checkCoherency(); + self.assertEqual(3,f1.getNumberOfComponents()); + self.assertEqual(5,f1.getNumberOfTuples()); + expected1=[1.2,2.3,3.4, 1.2,3.4,4.5, 3.4,4.5,5.6, 5.6,1.2,2.3, 4.5,5.6,1.2] + for i in xrange(15): + self.assertAlmostEqual(expected1[i],f1.getIJ(0,i),13); + pass + f1.changeNbOfComponents(4,7.77); + f1.checkCoherency(); + self.assertEqual(4,f1.getNumberOfComponents()); + self.assertEqual(5,f1.getNumberOfTuples()); + expected2=[1.2,2.3,3.4,7.77, 1.2,3.4,4.5,7.77, 3.4,4.5,5.6,7.77, 5.6,1.2,2.3,7.77, 4.5,5.6,1.2,7.77] + for i in xrange(20): + self.assertAlmostEqual(expected2[i],f1.getIJ(0,i),13); + pass + # + pass + + def testSortPerTuple1(self): + mesh1=MEDCouplingDataForTest.build2DTargetMesh_1(); + f1=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME); + f1.setMesh(mesh1); + array=DataArrayDouble.New(); + arr1=[1.2,2.3,3.4,4.5,5.6, 1.2,3.4,4.5,5.6,2.3, 3.4,4.5,5.6,1.2,2.3, 5.6,1.2,2.3,3.4,4.5, 4.5,5.6,1.2,2.3,3.4] + array.setValues(arr1,mesh1.getNumberOfCells(),5); + f1.setArray(array); + f1.checkCoherency(); + # + f1.sortPerTuple(True); + f1.checkCoherency(); + self.assertEqual(5,f1.getNumberOfComponents()); + self.assertEqual(5,f1.getNumberOfTuples()); + for i in xrange(5): + self.assertAlmostEqual(arr1[0],f1.getIJ(i,0),13); + self.assertAlmostEqual(arr1[1],f1.getIJ(i,1),13); + self.assertAlmostEqual(arr1[2],f1.getIJ(i,2),13); + self.assertAlmostEqual(arr1[3],f1.getIJ(i,3),13); + self.assertAlmostEqual(arr1[4],f1.getIJ(i,4),13); + pass + # + f1.sortPerTuple(False); + f1.checkCoherency(); + self.assertEqual(5,f1.getNumberOfComponents()); + self.assertEqual(5,f1.getNumberOfTuples()); + for i in xrange(5): + self.assertAlmostEqual(arr1[4],f1.getIJ(i,0),13); + self.assertAlmostEqual(arr1[3],f1.getIJ(i,1),13); + self.assertAlmostEqual(arr1[2],f1.getIJ(i,2),13); + self.assertAlmostEqual(arr1[1],f1.getIJ(i,3),13); + self.assertAlmostEqual(arr1[0],f1.getIJ(i,4),13); + pass + # + pass + + def testKeepSetSelectedComponent1(self): + arr1=[1.,2.,3.,4., 11.,12.,13.,14., 21.,22.,23.,24., 31.,32.,33.,34., 41.,42.,43.,44.] + a1=DataArrayDouble.New(); + a1.setValues(arr1,5,4); + expp=[21.,22.,23.,24.] + self.assertEqual(4,len(a1.getTuple(2))); + for i in xrange(4): + self.assertAlmostEqual(expp[i],a1.getTuple(2)[i],12) + pass + a1.setInfoOnComponent(0,"aaaa"); + a1.setInfoOnComponent(1,"bbbb"); + a1.setInfoOnComponent(2,"cccc"); + a1.setInfoOnComponent(3,"dddd"); + arr2V=[1,2,1,2,0,0] + a2=a1.keepSelectedComponents(arr2V); + self.assertEqual(6,a2.getNumberOfComponents()); + self.assertEqual(5,a2.getNumberOfTuples()); + self.assertTrue(a2.getInfoOnComponent(0)=="bbbb"); + self.assertTrue(a2.getInfoOnComponent(1)=="cccc"); + self.assertTrue(a2.getInfoOnComponent(2)=="bbbb"); + self.assertTrue(a2.getInfoOnComponent(3)=="cccc"); + self.assertTrue(a2.getInfoOnComponent(4)=="aaaa"); + self.assertTrue(a2.getInfoOnComponent(5)=="aaaa"); + expected1=[2.,3.,2.,3.,1.,1., 12.,13.,12.,13.,11.,11., 22.,23.,22.,23.,21.,21., 32.,33.,32.,33.,31.,31., 42.,43.,42.,43.,41.,41.] + for i in xrange(30): + self.assertAlmostEqual(expected1[i],a2.getIJ(0,i),14); + pass + a3=a1.convertToIntArr(); + self.assertEqual([21,22,23,24],a3.getTuple(2)) + a4=a3.keepSelectedComponents(arr2V); + self.assertEqual(6,a4.getNumberOfComponents()); + self.assertEqual(5,a4.getNumberOfTuples()); + self.assertTrue(a4.getInfoOnComponent(0)=="bbbb"); + self.assertTrue(a4.getInfoOnComponent(1)=="cccc"); + self.assertTrue(a4.getInfoOnComponent(2)=="bbbb"); + self.assertTrue(a4.getInfoOnComponent(3)=="cccc"); + self.assertTrue(a4.getInfoOnComponent(4)=="aaaa"); + self.assertTrue(a4.getInfoOnComponent(5)=="aaaa"); + for i in xrange(30): + self.assertEqual(int(expected1[i]),a4.getIJ(0,i)); + pass + # setSelectedComponents + arr3V=[3,2] + a5=a1.keepSelectedComponents(arr3V); + a5.setInfoOnComponent(0,"eeee"); + a5.setInfoOnComponent(1,"ffff"); + arr4V=[1,2] + a2.setSelectedComponents(a5,arr4V); + self.assertEqual(6,a2.getNumberOfComponents()); + self.assertEqual(5,a2.getNumberOfTuples()); + self.assertTrue(a2.getInfoOnComponent(0)=="bbbb"); + self.assertTrue(a2.getInfoOnComponent(1)=="eeee"); + self.assertTrue(a2.getInfoOnComponent(2)=="ffff"); + self.assertTrue(a2.getInfoOnComponent(3)=="cccc"); + self.assertTrue(a2.getInfoOnComponent(4)=="aaaa"); + self.assertTrue(a2.getInfoOnComponent(5)=="aaaa"); + expected2=[2.,4.,3.,3.,1.,1., 12.,14.,13.,13.,11.,11., 22.,24.,23.,23.,21.,21., 32.,34.,33.,33.,31.,31., 42.,44.,43.,43.,41.,41.] + for i in xrange(30): + self.assertAlmostEqual(expected2[i],a2.getIJ(0,i),14); + pass + a6=a5.convertToIntArr(); + a6.setInfoOnComponent(0,"eeee"); + a6.setInfoOnComponent(1,"ffff"); + a4.setSelectedComponents(a6,arr4V); + self.assertEqual(6,a4.getNumberOfComponents()); + self.assertEqual(5,a4.getNumberOfTuples()); + self.assertTrue(a4.getInfoOnComponent(0)=="bbbb"); + self.assertTrue(a4.getInfoOnComponent(1)=="eeee"); + self.assertTrue(a4.getInfoOnComponent(2)=="ffff"); + self.assertTrue(a4.getInfoOnComponent(3)=="cccc"); + self.assertTrue(a4.getInfoOnComponent(4)=="aaaa"); + self.assertTrue(a4.getInfoOnComponent(5)=="aaaa"); + for i in xrange(30): + self.assertEqual(int(expected2[i]),a4.getIJ(0,i)); + pass + # test of throw + arr5V=[2,3,6] + arr6V=[2,7,5] + arr7V=[2,1,4,6] + self.assertRaises(InterpKernelException,a2.keepSelectedComponents,arr5V); + self.assertRaises(InterpKernelException,a2.keepSelectedComponents,arr6V); + self.assertRaises(InterpKernelException,a2.setSelectedComponents,a1,arr7V); + arr7V=arr7V[0:3] + self.assertRaises(InterpKernelException,a2.setSelectedComponents,a1,arr7V); + # + pass + + def testKeepSetSelectedComponent2(self): + m1=MEDCouplingDataForTest.build2DTargetMesh_1(); + arr1=[1.,2.,3.,4., 11.,12.,13.,14., 21.,22.,23.,24., 31.,32.,33.,34., 41.,42.,43.,44.] + a1=DataArrayDouble.New(); + a1.setValues(arr1,5,4); + a1.setInfoOnComponent(0,"aaaa"); + a1.setInfoOnComponent(1,"bbbb"); + a1.setInfoOnComponent(2,"cccc"); + a1.setInfoOnComponent(3,"dddd"); + f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME); + f1.setTime(2.3,4,5); + f1.setMesh(m1); + f1.setName("f1"); + f1.setArray(a1); + f1.checkCoherency(); + # + arr2V=[1,2,1,2,0,0] + f2=f1.keepSelectedComponents(arr2V); + self.assertTrue(f2.getTimeDiscretization()==ONE_TIME); + t,dt,it=f2.getTime() + self.assertAlmostEqual(2.3,t,13); + self.assertEqual(4,dt); + self.assertEqual(5,it); + f2.checkCoherency(); + self.assertEqual(6,f2.getNumberOfComponents()); + self.assertEqual(5,f2.getNumberOfTuples()); + self.assertTrue(f2.getArray().getInfoOnComponent(0)=="bbbb"); + self.assertTrue(f2.getArray().getInfoOnComponent(1)=="cccc"); + self.assertTrue(f2.getArray().getInfoOnComponent(2)=="bbbb"); + self.assertTrue(f2.getArray().getInfoOnComponent(3)=="cccc"); + self.assertTrue(f2.getArray().getInfoOnComponent(4)=="aaaa"); + self.assertTrue(f2.getArray().getInfoOnComponent(5)=="aaaa"); + expected1=[2.,3.,2.,3.,1.,1., 12.,13.,12.,13.,11.,11., 22.,23.,22.,23.,21.,21., 32.,33.,32.,33.,31.,31., 42.,43.,42.,43.,41.,41.] + for i in xrange(30): + self.assertAlmostEqual(expected1[i],f2.getIJ(0,i),14); + pass + #setSelectedComponents + arr3V=[3,2] + f5=f1.keepSelectedComponents(arr3V); + f5.setTime(6.7,8,9); + f5.getArray().setInfoOnComponent(0,"eeee"); + f5.getArray().setInfoOnComponent(1,"ffff"); + f5.checkCoherency(); + arr4V=[1,2] + f2.setSelectedComponents(f5,arr4V); + self.assertEqual(6,f2.getNumberOfComponents()); + self.assertEqual(5,f2.getNumberOfTuples()); + f2.checkCoherency(); + t,dt,it=f2.getTime() + self.assertAlmostEqual(2.3,t,13); + self.assertEqual(4,dt); + self.assertEqual(5,it); + self.assertTrue(f2.getArray().getInfoOnComponent(0)=="bbbb"); + self.assertTrue(f2.getArray().getInfoOnComponent(1)=="eeee"); self.assertTrue(f2.getArray().getInfoOnComponent(2)=="ffff"); self.assertTrue(f2.getArray().getInfoOnComponent(3)=="cccc"); self.assertTrue(f2.getArray().getInfoOnComponent(4)=="aaaa"); self.assertTrue(f2.getArray().getInfoOnComponent(5)=="aaaa"); expected2=[2.,4.,3.,3.,1.,1., 12.,14.,13.,13.,11.,11., 22.,24.,23.,23.,21.,21., 32.,34.,33.,33.,31.,31., 42.,44.,43.,43.,41.,41.] for i in xrange(30): - self.assertAlmostEqual(expected2[i],f2.getIJ(0,i),14); + self.assertAlmostEqual(expected2[i],f2.getIJ(0,i),14); + pass + # + pass + + def testDAIGetIdsEqual1(self): + tab1=[5,-2,-4,-2,3,2,-2]; + da=DataArrayInt.New(); + da.setValues(tab1,7,1); + da2=da.getIdsEqual(-2); + self.assertEqual(3,da2.getNumberOfTuples()); + self.assertEqual(1,da2.getNumberOfComponents()); + expected1=[1,3,6]; + self.assertEqual(expected1,da2.getValues()); + pass + + def testDAIGetIdsEqualList1(self): + tab1=[5,-2,-4,-2,3,2,-2]; + da=DataArrayInt.New(); + da.setValues(tab1,7,1); + da2=da.getIdsEqualList([3,-2,0]); + self.assertEqual(4,da2.getNumberOfTuples()); + self.assertEqual(1,da2.getNumberOfComponents()); + expected1=[1,3,4,6]; + self.assertEqual(expected1,da2.getValues()); + pass + + def testDAFromNoInterlace1(self): + tab1=[1,11,21,31,41,2,12,22,32,42,3,13,23,33,43] + da=DataArrayInt.New(); + da.setValues(tab1,5,3); + da2=da.fromNoInterlace(); + expected1=[1,2,3,11,12,13,21,22,23,31,32,33,41,42,43] + self.assertEqual(5,da2.getNumberOfTuples()); + self.assertEqual(3,da2.getNumberOfComponents());# it's not a bug. Avoid to have 1 million components ! + self.assertEqual(expected1,da2.getValues()); + da3=da.convertToDblArr(); + da4=da3.fromNoInterlace(); + self.assertEqual(5,da4.getNumberOfTuples()); + self.assertEqual(3,da4.getNumberOfComponents());# it's not a bug. Avoid to have 1 million components ! + for i in xrange(15): + self.assertAlmostEqual(expected1[i],da4.getIJ(0,i),14); + pass + pass + + def testDAToNoInterlace1(self): + tab1=[1,2,3,11,12,13,21,22,23,31,32,33,41,42,43] + da=DataArrayInt.New(); + da.setValues(tab1,5,3); + da2=da.toNoInterlace(); + expected1=[1,11,21,31,41,2,12,22,32,42,3,13,23,33,43] + self.assertEqual(5,da2.getNumberOfTuples()); + self.assertEqual(3,da2.getNumberOfComponents());# it's not a bug. Avoid to have 1 million components ! + self.assertEqual(expected1,da2.getValues()); + da3=da.convertToDblArr(); + da4=da3.toNoInterlace(); + self.assertEqual(5,da4.getNumberOfTuples()); + self.assertEqual(3,da4.getNumberOfComponents());# it's not a bug. Avoid to have 1 million components ! + for i in xrange(15): + self.assertAlmostEqual(expected1[i],da4.getIJ(0,i),14); + pass + pass + + def testDAIsUniform1(self): + tab1=[1,1,1,1,1] + da=DataArrayInt.New(); + da.setValues(tab1,5,1); + self.assertTrue(da.isUniform(1)); + da.setIJ(2,0,2); + self.assertTrue(not da.isUniform(1)); + da.setIJ(2,0,1); + self.assertTrue(da.isUniform(1)); + da2=da.convertToDblArr(); + self.assertTrue(da2.isUniform(1.,1.e-12)); + da2.setIJ(1,0,1.+1.e-13); + self.assertTrue(da2.isUniform(1.,1.e-12)); + da2.setIJ(1,0,1.+1.e-11); + self.assertTrue(not da2.isUniform(1.,1.e-12)); + pass + + def testDADFromPolarToCart1(self): + tab1=[2.,0.2,2.5,0.7] + da=DataArrayDouble.New(); + da.setValues(tab1,2,2); + da2=da.fromPolarToCart(); + expected1=[1.9601331556824833,0.39733866159012243, 1.9121054682112213,1.6105442180942275] + for i in xrange(4): + self.assertAlmostEqual(expected1[i],da2.getIJ(0,i),13); + pass + pass + + def testDADFromCylToCart1(self): + tab1=[2.,0.2,4.,2.5,0.7,9.] + da=DataArrayDouble.New(); + da.setValues(tab1,2,3); + da2=da.fromCylToCart(); + expected1=[1.9601331556824833,0.39733866159012243,4., 1.9121054682112213,1.6105442180942275,9.] + for i in xrange(6): + self.assertAlmostEqual(expected1[i],da2.getIJ(0,i),13); + pass + pass + + def testDADFromSpherToCart1(self): + tab1=[2.,0.2,0.3,2.5,0.7,0.8] + da=DataArrayDouble.New(); + da.setValues(tab1,2,3); + da2=da.fromSpherToCart(); + expected1=[0.37959212195737485,0.11742160338765303,1.9601331556824833, 1.1220769624465328,1.1553337045129035,1.9121054682112213] + for i in xrange(6): + self.assertAlmostEqual(expected1[i],da2.getIJ(0,i),13); + pass + pass + + def testUnPolyze1(self): + elts=[0,1,2,3,4,5,6,7] + eltsV=elts; + mesh=MEDCouplingDataForTest.build3DTargetMesh_1(); + mesh.convertToPolyTypes(eltsV); + mesh.unPolyze(); + mesh2=MEDCouplingDataForTest.build3DTargetMesh_1(); + mesh.checkCoherency(); + self.assertTrue(mesh.isEqual(mesh2,1e-12)); + mesh.convertToPolyTypes(eltsV); + self.assertTrue(not mesh.isEqual(mesh2,1e-12)); + mesh.getNodalConnectivity().setIJ(0,6,10); + mesh.getNodalConnectivity().setIJ(0,7,9); + mesh.getNodalConnectivity().setIJ(0,8,12); + mesh.getNodalConnectivity().setIJ(0,9,13); + mesh.unPolyze(); + self.assertTrue(mesh.isEqual(mesh2,1e-12)); + mesh.convertToPolyTypes(eltsV); + mesh.getNodalConnectivity().setIJ(0,6,12); + mesh.getNodalConnectivity().setIJ(0,7,13); + mesh.getNodalConnectivity().setIJ(0,8,10); + mesh.getNodalConnectivity().setIJ(0,9,9); + mesh.unPolyze(); + self.assertTrue(mesh.isEqual(mesh2,1e-12)); + mesh.convertToPolyTypes(eltsV); + mesh.getNodalConnectivity().setIJ(0,6,12); + mesh.getNodalConnectivity().setIJ(0,7,10); + mesh.getNodalConnectivity().setIJ(0,8,13); + mesh.getNodalConnectivity().setIJ(0,9,9); + mesh.unPolyze(); + self.assertTrue(not mesh.isEqual(mesh2,1e-12)); + # Test for 2D mesh + mesh=MEDCouplingDataForTest.build2DTargetMesh_1(); + mesh2=MEDCouplingDataForTest.build2DTargetMesh_1(); + eltsV=eltsV[:5]; + mesh.convertToPolyTypes(eltsV); + self.assertTrue(not mesh.isEqual(mesh2,1e-12)); + mesh.unPolyze(); + self.assertTrue(mesh.isEqual(mesh2,1e-12)); + pass + + def testConvertDegeneratedCells1(self): + mesh=MEDCouplingDataForTest.build3DTargetMesh_1(); + conn=[0,1,3,3,9,10,12,12, 0,1,3,4,9,9,9,9, 1,1,1,1,10,12,9,10, 10,11,12,9,1,1,1,1] + mesh.allocateCells(4); + mesh.insertNextCell(NORM_HEXA8,8,conn[0:8]) + mesh.insertNextCell(NORM_HEXA8,8,conn[8:16]) + mesh.insertNextCell(NORM_HEXA8,8,conn[16:24]) + mesh.insertNextCell(NORM_HEXA8,8,conn[24:32]) + mesh.finishInsertingCells(); + mesh.checkCoherency(); + self.assertEqual(4,mesh.getNumberOfCells()); + self.assertEqual(NORM_HEXA8,mesh.getTypeOfCell(0)); + self.assertEqual(NORM_HEXA8,mesh.getTypeOfCell(1)); + self.assertEqual(NORM_HEXA8,mesh.getTypeOfCell(2)); + self.assertEqual(NORM_HEXA8,mesh.getTypeOfCell(3)); + f1=mesh.getMeasureField(True); + mesh.convertDegeneratedCells(); + mesh.checkCoherency(); + f2=mesh.getMeasureField(True); + self.assertEqual(4,mesh.getNumberOfCells()); + self.assertEqual(NORM_PENTA6,mesh.getTypeOfCell(0)); + self.assertEqual(NORM_PYRA5,mesh.getTypeOfCell(1)); + self.assertEqual(NORM_TETRA4,mesh.getTypeOfCell(2)); + self.assertEqual(NORM_PYRA5,mesh.getTypeOfCell(3)); + for i in xrange(4): + self.assertAlmostEqual(f1.getArray().getIJ(0,i),f2.getArray().getIJ(0,i),5); + pass + pass + + def testGetNodeIdsNearPoints1(self): + mesh=MEDCouplingDataForTest.build2DTargetMesh_1(); + coords=mesh.getCoords(); + tmp=DataArrayDouble.New(); + vals=[0.2,0.2,0.1,0.2,0.2,0.2] + tmp.setValues(vals,3,2); + tmp2=DataArrayDouble.Aggregate(coords,tmp); + mesh.setCoords(tmp2); + pts=[0.2,0.2,0.1,0.3,-0.3,0.7] + c=mesh.getNodeIdsNearPoint(pts,1e-7); + self.assertEqual([4,9,11],c); + c,cI=mesh.getNodeIdsNearPoints(pts,3,1e-7); + self.assertEqual([0,3,3,4],cI.getValues()); + self.assertEqual([4,9,11,6],c.getValues()); + pass + + def testFieldCopyTinyAttrFrom1(self): + f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME); + f1.setName("f1"); + f1.setTimeTolerance(1.e-5); + f1.setDescription("f1Desc"); + f1.setTime(1.23,4,5); + f2=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME); + f2.setName("f2"); + f2.setDescription("f2Desc"); + f2.setTime(6.78,9,10); + f2.setTimeTolerance(4.556e-12); + # + f1.copyTinyAttrFrom(f2); + self.assertAlmostEqual(4.556e-12,f1.getTimeTolerance(),24); + t,dt,it=f1.getTime() + self.assertAlmostEqual(6.78,t,12); + self.assertEqual(9,dt); + self.assertEqual(10,it); + self.assertTrue(f1.getName()=="f1");#name unchanged + self.assertTrue(f1.getDescription()=="f1Desc");#description unchanged + # + f1=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME); + f1.setName("f1"); + f1.setTimeTolerance(1.e-5); + f1.setDescription("f1Desc"); + f2=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME); + f2.setName("f2"); + f2.setDescription("f2Desc"); + f2.setTimeTolerance(4.556e-12); + # + f1.copyTinyAttrFrom(f2); + self.assertAlmostEqual(4.556e-12,f1.getTimeTolerance(),24); + self.assertTrue(f1.getName()=="f1");#name unchanged + self.assertTrue(f1.getDescription()=="f1Desc");#description unchanged + # + f1=MEDCouplingFieldDouble.New(ON_CELLS,CONST_ON_TIME_INTERVAL); + f1.setName("f1"); + f1.setTimeTolerance(1.e-5); + f1.setDescription("f1Desc"); + f1.setTime(1.23,4,5); + f1.setEndTime(5.43,2,1); + f2=MEDCouplingFieldDouble.New(ON_CELLS,CONST_ON_TIME_INTERVAL); + f2.setName("f2"); + f2.setDescription("f2Desc"); + f2.setTimeTolerance(4.556e-12); + f2.setTime(6.78,9,10); + f2.setEndTime(10.98,7,6); + # + f1.copyTinyAttrFrom(f2); + self.assertAlmostEqual(4.556e-12,f1.getTimeTolerance(),24); + self.assertTrue(f1.getName()=="f1");#name unchanged + self.assertTrue(f1.getDescription()=="f1Desc");#description unchanged + t,dt,it=f1.getTime() + self.assertAlmostEqual(6.78,t,12); + self.assertEqual(9,dt); + self.assertEqual(10,it); + t,dt,it=f1.getEndTime() + self.assertAlmostEqual(10.98,t,12); + self.assertEqual(7,dt); + self.assertEqual(6,it); + # + f1=MEDCouplingFieldDouble.New(ON_CELLS,LINEAR_TIME); + f1.setName("f1"); + f1.setTimeTolerance(1.e-5); + f1.setDescription("f1Desc"); + f1.setTime(1.23,4,5); + f1.setEndTime(5.43,2,1); + f2=MEDCouplingFieldDouble.New(ON_CELLS,LINEAR_TIME); + f2.setName("f2"); + f2.setDescription("f2Desc"); + f2.setTimeTolerance(4.556e-12); + f2.setTime(6.78,9,10); + f2.setEndTime(10.98,7,6); + # + f1.copyTinyAttrFrom(f2); + self.assertAlmostEqual(4.556e-12,f1.getTimeTolerance(),24); + self.assertTrue(f1.getName()=="f1");#name unchanged + self.assertTrue(f1.getDescription()=="f1Desc");#description unchanged + t,dt,it=f1.getTime() + self.assertAlmostEqual(6.78,t,12); + self.assertEqual(9,dt); + self.assertEqual(10,it); + t,dt,it=f1.getEndTime() + self.assertAlmostEqual(10.98,t,12); + self.assertEqual(7,dt); + self.assertEqual(6,it); + pass + + def testExtrudedMesh5(self): + coo1=[0.,1.,2.,3.5] + a=DataArrayDouble.New(); + a.setValues(coo1,4,1); + b=MEDCouplingCMesh.New(); + b.setCoordsAt(0,a); + c=b.buildUnstructured(); + self.assertEqual(1,c.getSpaceDimension()); + c.changeSpaceDimension(2); + # + d=DataArrayDouble.New(); + d.alloc(13,1); + d.iota(); + e=MEDCouplingCMesh.New(); + e.setCoordsAt(0,d); + f=e.buildUnstructured(); + g=f.getCoords().applyFunc(2,"3.5*IVec+x/6*3.14159265359*JVec"); + h=g.fromPolarToCart(); + f.setCoords(h); + i=c.buildExtrudedMesh(f,1); + self.assertEqual(52,i.getNumberOfNodes()); + tmp,tmp2,tmp3=i.mergeNodes(1e-9); + self.assertTrue(tmp2); + self.assertEqual(37,tmp3); + i.convertDegeneratedCells(); + i.checkCoherency(); + self.assertEqual(36,i.getNumberOfCells()); + self.assertEqual(37,i.getNumberOfNodes()); + self.assertEqual(12,i.getNumberOfCellsWithType(NORM_TRI3)); + self.assertEqual(24,i.getNumberOfCellsWithType(NORM_QUAD4)); + expected1=[0.25,0.75,2.0625] + j=i.getMeasureField(True); + for ii in xrange(12): + for k in xrange(3): + self.assertAlmostEqual(expected1[k],j.getIJ(0,ii*3+k),10); + pass + pass + expected2=[0.62200846792814113, 0.16666666666681595, 1.4513530918323276, 0.38888888888923495, 2.6293994326053212, 0.7045454545460802, 0.45534180126145435, 0.45534180126150181, 1.0624642029433926, 1.0624642029435025, 1.9248539780597826, 1.9248539780599816, 0.16666666666661334, 0.62200846792815856, 0.38888888888876294, 1.4513530918323678, 0.70454545454522521, 2.629399432605394, -0.16666666666674007, 0.62200846792812436, -0.38888888888906142, 1.4513530918322881, -0.70454545454576778, 2.6293994326052488, -0.45534180126154766, 0.45534180126140844, -1.0624642029436118, 1.0624642029432834, -1.9248539780601803, 1.9248539780595841, -0.62200846792817499, 0.1666666666665495, -1.451353091832408, 0.388888888888613, -2.6293994326054668, 0.70454545454495332, -0.62200846792810593, -0.16666666666680507, -1.451353091832247, -0.38888888888921297, -2.6293994326051746, -0.70454545454604123, -0.45534180126135926, -0.45534180126159562, -1.0624642029431723, -1.0624642029437235, -1.9248539780593836, -1.9248539780603811, -0.1666666666664828, -0.62200846792819242, -0.38888888888846079, -1.4513530918324489, -0.70454545454467987, -2.6293994326055397, 0.16666666666687083, -0.62200846792808862, 0.38888888888936374, -1.4513530918322073, 0.70454545454631357, -2.6293994326051022, 0.45534180126164348, -0.45534180126131207, 1.0624642029438327, -1.0624642029430627, 1.9248539780605791, -1.9248539780591853, 0.62200846792821063, -0.16666666666641802, 1.4513530918324888, -0.38888888888831086, 2.6293994326056125, -0.70454545454440853] + m=i.getBarycenterAndOwner(); + for i in xrange(72): + self.assertAlmostEqual(expected2[i],m.getIJ(0,i),10); + pass + # + pass + + def testExtrudedMesh6(self): + coo1=[0.,1.,2.,3.5] + a=DataArrayDouble.New(); + a.setValues(coo1,4,1); + b=MEDCouplingCMesh.New(); + b.setCoordsAt(0,a); + c=b.buildUnstructured(); + self.assertEqual(1,c.getSpaceDimension()); + c.changeSpaceDimension(2); + # + d=DataArrayDouble.New(); + d.alloc(5,1); + d.iota(); + e=MEDCouplingCMesh.New(); + e.setCoordsAt(0,d); + f=e.buildUnstructured(); + d2=f.getCoords().applyFunc("x*x/2"); + f.setCoords(d2); + f.changeSpaceDimension(2); + # + center=[0.,0.] + f.rotate(center,[],pi/3); + g=c.buildExtrudedMesh(f,0); + g.checkCoherency(); + 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 ] + f1=g.getMeasureField(True); + for i in xrange(12): + self.assertAlmostEqual(expected1[i],f1.getIJ(0,i),12); + pass + expected2=[0.625, 0.21650635094610962, 1.625, 0.21650635094610959, 2.8750000000000004, 0.21650635094610965, 1.1250000000000002, 1.0825317547305482, 2.125, 1.0825317547305482, 3.3750000000000004, 1.0825317547305484, 2.125, 2.8145825622994254, 3.125, 2.8145825622994254, 4.375, 2.8145825622994254, 3.6250000000000009, 5.4126587736527414, 4.625, 5.4126587736527414, 5.875, 5.4126587736527414] + f2=g.getBarycenterAndOwner(); + for i in xrange(24): + self.assertAlmostEqual(expected2[i],f2.getIJ(0,i),12); + pass + pass + + def testExtrudedMesh7(self): + coo1=[0.,1.,2.,3.5] + a=DataArrayDouble.New(); + a.setValues(coo1,4,1); + b=MEDCouplingCMesh.New(); + b.setCoordsAt(0,a); + c=b.buildUnstructured(); + self.assertEqual(1,c.getSpaceDimension()); + c.changeSpaceDimension(2); + # + d=DataArrayDouble.New(); + d.alloc(13,1); + d.iota(); + e=MEDCouplingCMesh.New(); + e.setCoordsAt(0,d); + f=e.buildUnstructured(); + g=f.getCoords().applyFunc(2,"3.5*IVec+x/6*3.14159265359*JVec"); + h=g.fromPolarToCart(); + f.setCoords(h); + i=c.buildExtrudedMesh(f,1); + self.assertEqual(52,i.getNumberOfNodes()); + tmp,tmp2,tmp3=i.mergeNodes(1e-9); + self.assertTrue(tmp2); + self.assertEqual(37,tmp3); + i.convertDegeneratedCells(); + vec1=[10.,0.,0.] + i.translate(vec1); + g2=h.applyFunc(3,"13.5/3.5*x*IVec+0*JVec+13.5/3.5*y*KVec"); + f.setCoords(g2); + i.changeSpaceDimension(3); + i3=i.buildExtrudedMesh(f,1); + f2=i3.getMeasureField(True); + tmp,tmp2,tmp3=i.mergeNodes(1e-9); + self.assertTrue(tmp2); + self.assertEqual(444,tmp3); + expected1=[1.327751058489274, 4.2942574094314701, 13.024068164857139, 1.3069177251569044, 4.1484240761012954, 12.297505664866796, 1.270833333332571, 3.8958333333309674, 11.039062499993179, 1.2291666666659207, 3.6041666666644425, 9.585937499993932, 1.1930822748415895, 3.3515759238941376, 8.3274943351204556, 1.1722489415082769, 3.2057425905609289, 7.6009318351210622, 1.1722489415082862, 3.2057425905609884, 7.6009318351213713, 1.1930822748416161, 3.3515759238943001, 8.3274943351212727, 1.2291666666659564, 3.6041666666646734, 9.5859374999950777, 1.2708333333326081, 3.8958333333311868, 11.039062499994293, 1.3069177251569224, 4.1484240761014384, 12.297505664867627, 1.3277510584902354, 4.2942574094346071, 13.024068164866796] + for ii in xrange(12): + for jj in xrange(36): + self.assertAlmostEqual(expected1[jj],f2.getIJ(0,ii*36+jj),9); + pass + # + pass + + def testSimplexize1(self): + m=MEDCouplingDataForTest.build3DSurfTargetMesh_1(); + m.convertToPolyTypes([3]); + da=m.simplexize(0); + self.assertEqual(7,da.getNumberOfTuples()); + self.assertEqual(1,da.getNumberOfComponents()); + expected2=[0,0,1,2,3,4,4] + for i in xrange(7): + self.assertEqual(expected2[i],da.getIJ(i,0)); + pass + m.checkCoherency(); + self.assertEqual(7,m.getNumberOfCells()); + self.assertEqual(NORM_TRI3,m.getTypeOfCell(0)); + self.assertEqual(NORM_TRI3,m.getTypeOfCell(1)); + self.assertEqual(NORM_TRI3,m.getTypeOfCell(2)); + self.assertEqual(NORM_TRI3,m.getTypeOfCell(3)); + self.assertEqual(NORM_POLYGON,m.getTypeOfCell(4)); + self.assertEqual(NORM_TRI3,m.getTypeOfCell(5)); + self.assertEqual(NORM_TRI3,m.getTypeOfCell(6)); + expected1=[0.125,0.125,0.125,0.125,0.25,0.125,0.125] + f=m.getMeasureField(False); + for i in xrange(7): + self.assertAlmostEqual(expected1[i]*sqrt(2.),f.getIJ(i,0),10); + pass + types=m.getAllTypes(); + self.assertEqual([NORM_TRI3,NORM_POLYGON],types); + # + m=MEDCouplingDataForTest.build3DSurfTargetMesh_1(); + m.convertToPolyTypes([3]); + da=m.simplexize(1); + self.assertEqual(7,da.getNumberOfTuples()); + self.assertEqual(1,da.getNumberOfComponents()); + for i in xrange(7): + self.assertEqual(expected2[i],da.getIJ(i,0)); + pass + m.checkCoherency(); + types=m.getAllTypes(); + self.assertEqual([NORM_TRI3,NORM_POLYGON],types); + self.assertEqual(7,m.getNumberOfCells()); + self.assertEqual(NORM_TRI3,m.getTypeOfCell(0)); + self.assertEqual(NORM_TRI3,m.getTypeOfCell(1)); + self.assertEqual(NORM_TRI3,m.getTypeOfCell(2)); + self.assertEqual(NORM_TRI3,m.getTypeOfCell(3)); + self.assertEqual(NORM_POLYGON,m.getTypeOfCell(4)); + self.assertEqual(NORM_TRI3,m.getTypeOfCell(5)); + self.assertEqual(NORM_TRI3,m.getTypeOfCell(6)); + f=m.getMeasureField(False); + for i in xrange(7): + self.assertAlmostEqual(expected1[i]*sqrt(2.),f.getIJ(i,0),10); + pass + pass + + def testSimplexize2(self): + m=MEDCouplingDataForTest.build3DSurfTargetMesh_1(); + m.convertToPolyTypes([3]); + f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME); + f1.setMesh(m); + arr=DataArrayDouble.New(); + arr1=[10.,110.,20.,120.,30.,130.,40.,140.,50.,150.] + arr.setValues(arr1,5,2); + f1.setArray(arr); + # + f1.checkCoherency(); + self.assertTrue(f1.simplexize(0)); + f1.checkCoherency(); + expected1=[10.,110.,10.,110.,20.,120.,30.,130.,40.,140.,50.,150.,50.,150.] + for i in xrange(14): + self.assertAlmostEqual(expected1[i],f1.getIJ(0,i),10); + pass + self.assertTrue(not f1.simplexize(0)); + for i in xrange(14): + self.assertAlmostEqual(expected1[i],f1.getIJ(0,i),10); + pass + # + pass + + def testDAMeld1(self): + da1=DataArrayDouble.New(); + da1.alloc(7,2); + da2=DataArrayDouble.New(); + da2.alloc(7,1); + # + da1.fillWithValue(7.); + da2.iota(0.); + da3=da2.applyFunc(3,"10*x*IVec+100*x*JVec+1000*x*KVec"); + # + da1.setInfoOnComponent(0,"c0da1"); + da1.setInfoOnComponent(1,"c1da1"); + da3.setInfoOnComponent(0,"c0da3"); + da3.setInfoOnComponent(1,"c1da3"); + da3.setInfoOnComponent(2,"c2da3"); + # + da1C=da1.deepCpy(); + da1.meldWith(da3); + self.assertEqual(5,da1.getNumberOfComponents()); + self.assertEqual(7,da1.getNumberOfTuples()); + self.assertTrue(da1.getInfoOnComponent(0)=="c0da1"); + self.assertTrue(da1.getInfoOnComponent(1)=="c1da1"); + self.assertTrue(da1.getInfoOnComponent(2)=="c0da3"); + self.assertTrue(da1.getInfoOnComponent(3)=="c1da3"); + self.assertTrue(da1.getInfoOnComponent(4)=="c2da3"); + # + expected1=[7.,7.,0.,0.,0., 7.,7.,10.,100.,1000., 7.,7.,20.,200.,2000., 7.,7.,30.,300.,3000., 7.,7.,40.,400.,4000.,7.,7.,50.,500.,5000.,7.,7.,60.,600.,6000.] + for i in xrange(35): + self.assertAlmostEqual(expected1[i],da1.getIJ(0,i),10); + pass + # + dai1=da1C.convertToIntArr(); + dai3=da3.convertToIntArr(); + dai1.meldWith(dai3); + self.assertEqual(5,dai1.getNumberOfComponents()); + self.assertEqual(7,dai1.getNumberOfTuples()); + self.assertTrue(dai1.getInfoOnComponent(0)=="c0da1"); + self.assertTrue(dai1.getInfoOnComponent(1)=="c1da1"); + self.assertTrue(dai1.getInfoOnComponent(2)=="c0da3"); + self.assertTrue(dai1.getInfoOnComponent(3)=="c1da3"); + self.assertTrue(dai1.getInfoOnComponent(4)=="c2da3"); + for i in xrange(35): + self.assertEqual(int(expected1[i]),dai1.getIJ(0,i)); + pass + # test of static method DataArrayDouble::meld + da4=DataArrayDouble.Meld(da1C,da3); + tmp=DataArrayDouble.Meld([da1C,da3]); + self.assertTrue(da4.isEqual(tmp,1e-10)) + self.assertEqual(5,da4.getNumberOfComponents()); + self.assertEqual(7,da4.getNumberOfTuples()); + self.assertTrue(da4.getInfoOnComponent(0)=="c0da1"); + self.assertTrue(da4.getInfoOnComponent(1)=="c1da1"); + self.assertTrue(da4.getInfoOnComponent(2)=="c0da3"); + self.assertTrue(da4.getInfoOnComponent(3)=="c1da3"); + self.assertTrue(da4.getInfoOnComponent(4)=="c2da3"); + for i in xrange(35): + self.assertAlmostEqual(expected1[i],da4.getIJ(0,i),10); + pass + # test of static method DataArrayInt::meld + dai1=da1C.convertToIntArr(); + dai4=DataArrayInt.Meld(dai1,dai3); + tmp=DataArrayInt.Meld([dai1,dai3]); + self.assertTrue(dai4.isEqual(tmp)) + self.assertEqual(5,dai4.getNumberOfComponents()); + self.assertEqual(7,dai4.getNumberOfTuples()); + self.assertTrue(dai4.getInfoOnComponent(0)=="c0da1"); + self.assertTrue(dai4.getInfoOnComponent(1)=="c1da1"); + self.assertTrue(dai4.getInfoOnComponent(2)=="c0da3"); + self.assertTrue(dai4.getInfoOnComponent(3)=="c1da3"); + self.assertTrue(dai4.getInfoOnComponent(4)=="c2da3"); + for i in xrange(35): + self.assertEqual(int(expected1[i]),dai4.getIJ(0,i)); + pass + pass + + def testFieldMeld1(self): + m=MEDCouplingDataForTest.build3DSurfTargetMesh_1(); + f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME); + f1.setMesh(m); + da1=DataArrayDouble.New(); + arr1=[12.,23.,34.,45.,56.] + da1.setValues(arr1,5,1); + da1.setInfoOnComponent(0,"aaa"); + f1.setArray(da1); + f1.setTime(3.4,2,1); + f1.checkCoherency(); + # + f2=f1.deepCpy(); + f2.setMesh(f1.getMesh()); + f2.checkCoherency(); + f2.changeNbOfComponents(2,5.); + f2.assign(5.); + f2.getArray().setInfoOnComponent(0,"bbb"); + f2.getArray().setInfoOnComponent(1,"ccc"); + f2.checkCoherency(); + # + f3=MEDCouplingFieldDouble.MeldFields(f2,f1); + f3.checkCoherency(); + self.assertEqual(5,f3.getNumberOfTuples()); + self.assertEqual(3,f3.getNumberOfComponents()); + self.assertTrue(f3.getArray().getInfoOnComponent(0)=="bbb"); + self.assertTrue(f3.getArray().getInfoOnComponent(1)=="ccc"); + self.assertTrue(f3.getArray().getInfoOnComponent(2)=="aaa"); + expected1=[5.,5.,12.,5.,5.,23.,5.,5.,34.,5.,5.,45.,5.,5.,56.] + for i in xrange(15): + self.assertAlmostEqual(expected1[i],f3.getIJ(0,i),12); + pass + time,dt,it=f3.getTime(); + self.assertAlmostEqual(3.4,time,14); + self.assertEqual(2,dt); + self.assertEqual(1,it); + # + f4=f2.buildNewTimeReprFromThis(NO_TIME,False); + f5=f1.buildNewTimeReprFromThis(NO_TIME,False); + f6=MEDCouplingFieldDouble.MeldFields(f4,f5); + f6.checkCoherency(); + self.assertEqual(5,f6.getNumberOfTuples()); + self.assertEqual(3,f6.getNumberOfComponents()); + self.assertTrue(f6.getArray().getInfoOnComponent(0)=="bbb"); + self.assertTrue(f6.getArray().getInfoOnComponent(1)=="ccc"); + self.assertTrue(f6.getArray().getInfoOnComponent(2)=="aaa"); + for i in xrange(15): + self.assertAlmostEqual(expected1[i],f6.getIJ(0,i),12); + pass + # + pass + + def testMergeNodes2(self): + m1=MEDCouplingDataForTest.build2DTargetMesh_1(); + m2=MEDCouplingDataForTest.build2DTargetMesh_1(); + vec=[0.002,0.] + m2.translate(vec); + # + m3=MEDCouplingUMesh.MergeUMeshes([m1,m2]); + da,b,newNbOfNodes=m3.mergeNodes2(0.01); + self.assertEqual(9,m3.getNumberOfNodes()); + expected1=[-0.299,-0.3, 0.201,-0.3, 0.701,-0.3, -0.299,0.2, 0.201,0.2, 0.701,0.2, -0.299,0.7, 0.201,0.7, 0.701,0.7] + for i in xrange(18): + self.assertAlmostEqual(expected1[i],m3.getCoords().getIJ(0,i),13); + pass + # + pass + + def testMergeField2(self): + m=MEDCouplingDataForTest.build2DTargetMesh_1(); + f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME); + f1.setMesh(m); + arr=DataArrayDouble.New(); + arr.alloc(5,2); + arr.fillWithValue(2.); + f1.setArray(arr); + f2=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME); + f2.setMesh(m); + arr=DataArrayDouble.New(); + arr.alloc(5,2); + arr.fillWithValue(5.); + f2.setArray(arr); + f3=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME); + f3.setMesh(m); + arr=DataArrayDouble.New(); + arr.alloc(5,2); + arr.fillWithValue(7.); + f3.setArray(arr); + # + f4=MEDCouplingFieldDouble.MergeFields([f1,f2,f3]); + self.assertEqual(15,f4.getMesh().getNumberOfCells()); + expected1=[2.,2.,2.,2.,2.,2.,2.,2.,2.,2., 5.,5.,5.,5.,5.,5.,5.,5.,5.,5., 7.,7.,7.,7.,7.,7.,7.,7.,7.,7.] + for i in xrange(30): + self.assertAlmostEqual(expected1[i],f4.getIJ(0,i),13); + pass + # + pass + + def testDAIBuildComplement1(self): + a=DataArrayInt.New(); + tab=[3,1,7,8] + a.setValues(tab,4,1); + b=a.buildComplement(12); + self.assertEqual(8,b.getNumberOfTuples()); + self.assertEqual(1,b.getNumberOfComponents()); + expected1=[0,2,4,5,6,9,10,11] + for i in xrange(8): + self.assertEqual(expected1[i],b.getIJ(0,i)); + pass + pass + + def testDAIBuildUnion1(self): + a=DataArrayInt.New(); + tab1=[3,1,7,8] + a.setValues(tab1,4,1); + c=DataArrayInt.New(); + tab2=[5,3,0,18,8] + c.setValues(tab2,5,1); + b=a.buildUnion(c); + self.assertEqual(7,b.getNumberOfTuples()); + self.assertEqual(1,b.getNumberOfComponents()); + expected1=[0,1,3,5,7,8,18] + for i in xrange(7): + self.assertEqual(expected1[i],b.getIJ(0,i)); + pass + b=DataArrayInt.BuildUnion([a,c]); + self.assertEqual(7,b.getNumberOfTuples()); + self.assertEqual(1,b.getNumberOfComponents()); + expected1=[0,1,3,5,7,8,18] + for i in xrange(7): + self.assertEqual(expected1[i],b.getIJ(0,i)); + pass + pass + + def testDAIBuildIntersection1(self): + a=DataArrayInt.New(); + tab1=[3,1,7,8] + a.setValues(tab1,4,1); + c=DataArrayInt.New(); + tab2=[5,3,0,18,8] + c.setValues(tab2,5,1); + b=a.buildIntersection(c); + self.assertEqual(2,b.getNumberOfTuples()); + self.assertEqual(1,b.getNumberOfComponents()); + expected1=[3,8] + for i in xrange(2): + self.assertEqual(expected1[i],b.getIJ(0,i)); + pass + b=DataArrayInt.BuildIntersection([a,c]); + self.assertEqual(2,b.getNumberOfTuples()); + self.assertEqual(1,b.getNumberOfComponents()); + expected1=[3,8] + for i in xrange(2): + self.assertEqual(expected1[i],b.getIJ(0,i)); + pass + pass + + def testDAIDeltaShiftIndex1(self): + a=DataArrayInt.New(); + tab=[1,3,6,7,7,9,15] + a.setValues(tab,7,1); + b=a.deltaShiftIndex(); + self.assertEqual(6,b.getNumberOfTuples()); + self.assertEqual(1,b.getNumberOfComponents()); + expected1=[2,3,1,0,2,6] + for i in xrange(6): + self.assertEqual(expected1[i],b.getIJ(0,i)); + pass + pass + + def testDaDoubleSelectByTupleIdSafe1(self): + a=DataArrayDouble.New(); + arr1=[1.1,11.1,2.1,12.1,3.1,13.1,4.1,14.1,5.1,15.1,6.1,16.1,7.1,17.1] + a.setValues(arr1,7,2); + a.setInfoOnComponent(0,"toto"); + a.setInfoOnComponent(1,"tata"); + # + arr2=[4,2,0,6,5] + b=a.selectByTupleIdSafe(arr2); + self.assertEqual(5,b.getNumberOfTuples()); + self.assertEqual(2,b.getNumberOfComponents()); + self.assertTrue(b.getInfoOnComponent(0)=="toto"); + self.assertTrue(b.getInfoOnComponent(1)=="tata"); + expected1=[5.1,15.1,3.1,13.1,1.1,11.1,7.1,17.1,6.1,16.1] + for i in xrange(10): + self.assertAlmostEqual(expected1[i],b.getIJ(0,i),14); + pass + arr4=[4,-1,0,6,5] + self.assertRaises(InterpKernelException,a.selectByTupleIdSafe,arr4); + arr5=[4,2,0,6,7] + self.assertRaises(InterpKernelException,a.selectByTupleIdSafe,arr5); + # + c=DataArrayInt.New(); + arr3=[1,11,2,12,3,13,4,14,5,15,6,16,7,17] + c.setValues(arr3,7,2); + c.setInfoOnComponent(0,"toto"); + c.setInfoOnComponent(1,"tata"); + d=c.selectByTupleIdSafe(arr2); + self.assertEqual(5,d.getNumberOfTuples()); + self.assertEqual(2,d.getNumberOfComponents()); + self.assertTrue(d.getInfoOnComponent(0)=="toto"); + self.assertTrue(d.getInfoOnComponent(1)=="tata"); + expected2=[5,15,3,13,1,11,7,17,6,16] + for i in xrange(10): + self.assertEqual(expected2[i],d.getIJ(0,i)); + pass + self.assertRaises(InterpKernelException,c.selectByTupleIdSafe,arr4); + self.assertRaises(InterpKernelException,c.selectByTupleIdSafe,arr5); + pass + + def testAreCellsIncludedIn1(self): + m=MEDCouplingDataForTest.build3DSurfTargetMesh_1(); + pt=[1,3] + m2=m.buildPartOfMySelf(pt,True); + ret,tmp=m.areCellsIncludedIn(m2,0) + self.assertTrue(ret); + self.assertEqual(2,tmp.getNumberOfTuples()); + self.assertEqual(1,tmp.getNumberOfComponents()); + self.assertEqual(pt[0],tmp.getIJ(0,0)); + self.assertEqual(pt[1],tmp.getIJ(0,1)); + ret,tmp=m2.areCellsIncludedIn(m,0) + self.assertTrue(not ret); + pass + + def testSwigErrorProtection1(self): + m=MEDCouplingDataForTest.build3DTargetMesh_1(); + m.rotate([0.,0.,0.],[0.3,0.6,1.2],0.37) + m.rotate([0.,0.,0.],[0.3,6,1.2],0.37) + self.assertRaises(InterpKernelException,m.rotate,[0.,0.,0.],(0.3,6,"1.2"),0.37) + self.assertRaises(InterpKernelException,m.rotate,[0.,"0.",0.],[0.3,0.6,1.2],0.37) + self.assertRaises(InterpKernelException,m.rotate,[0.,0.,0.],[0.3,'0.6',1.2],0.37) + m2=m.buildPartOfMySelf([2,5],True) + m3=m.buildPartOfMySelf((2,5),True) + self.assertTrue(m2.isEqual(m3,1e-12)) + self.assertRaises(InterpKernelException,m.buildPartOfMySelf,[2,5.],True) + da1=m.getCoords().keepSelectedComponents([1]) + da2=m.getCoords().keepSelectedComponents((1,)) + self.assertTrue(da1.isEqual(da2,1e-12)) + self.assertRaises(InterpKernelException,m.getCoords().keepSelectedComponents,["1"]) + pass + + def testDAIBuildSubstraction1(self): + a=DataArrayInt.New() + aa=[2,3,6,8,9] + a.setValues(aa,5,1) + b=DataArrayInt.New() + bb=[1,3,5,9,11] + b.setValues(bb,5,1) + self.assertEqual([2,6,8],a.buildSubstraction(b).getValues()) + pass + + def testBuildOrthogonalField2(self): + m=MEDCouplingDataForTest.build2DTargetMesh_1(); + d1=DataArrayInt.New(); + d2=DataArrayInt.New(); + d3=DataArrayInt.New(); + d4=DataArrayInt.New(); + m1=m.buildDescendingConnectivity(d1,d2,d3,d4); + # + f1=m1.buildOrthogonalField(); + da1=f1.getArray(); + self.assertEqual(2,da1.getNumberOfComponents()); + self.assertEqual(13,da1.getNumberOfTuples()); + # + expected1=[-1.,0.,0.,1.,1.,0.,0.,-1.,0.707106781186548,0.707106781186548,0.,-1.,0.,1.,1.,0.,0.,1.,1.,0.,-1.,0.,0.,1.,1.,0.]; + for i in xrange(26): + self.assertAlmostEqual(expected1[i],da1.getIJ(0,i),14); + pass + pass + + def testSwigErrorProtection2(self): + m=MEDCouplingDataForTest.build2DTargetMesh_1(); + coo=m.getCoords() + c=m.getNodalConnectivity() + ci=m.getNodalConnectivityIndex() + del m + self.assertEqual(2,coo.getNumberOfComponents()); + self.assertEqual(6,ci.getNumberOfTuples()); + self.assertEqual(23,c.getNumberOfTuples()); + m=MEDCouplingDataForTest.build2DTargetMesh_1(); + f=m.getMeasureField(True) + c=f.getArray() + del f + self.assertEqual(1,c.getNumberOfComponents()); + m=MEDCouplingCMesh.New() + x=DataArrayDouble.New() + x.setValues([1.,2.,4.],3,1) + m.setCoordsAt(0,x) + del x + xx=m.getCoordsAt(0) + del m + self.assertEqual(3,xx.getNumberOfTuples()); + # + m=MEDCouplingDataForTest.build2DTargetMesh_1(); + f=m.getMeasureField(True) + m2=f.getMesh() + del m + del f + self.assertEqual(5,m2.getNumberOfCells()); + pass + + def testUMInsertNextCell1(self): + targetCoords=[-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 ] + targetConn=[0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4] + targetMesh=MEDCouplingUMesh.New(); + targetMesh.allocateCells(5); + self.assertRaises(InterpKernelException,targetMesh.insertNextCell,NORM_QUAD4,4,targetConn[0:4]) + targetMesh.setMeshDimension(2); + targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[0:4]) + self.assertRaises(InterpKernelException,targetMesh.insertNextCell,NORM_TETRA4,4,targetConn[0:4]) + self.assertRaises(InterpKernelException,targetMesh.insertNextCell,NORM_SEG2,2,targetConn[0:2]) + self.assertRaises(InterpKernelException,targetMesh.insertNextCell,NORM_POINT1,1,targetConn[0:1]) + targetMesh.insertNextCell(NORM_TRI3,3,targetConn[4:7]) + targetMesh.insertNextCell(NORM_TRI3,3,targetConn[7:10]) + targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[10:14]) + targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[14:18]) + targetMesh.finishInsertingCells(); + myCoords=DataArrayDouble.New(); + myCoords.setValues(targetCoords,9,2); + targetMesh.setCoords(myCoords); + targetMesh.checkCoherency(); + pass + + def testFieldOperatorDivDiffComp1(self): + m=MEDCouplingDataForTest.build2DTargetMesh_1(); + m1,d0,d1,d2,d3=m.buildDescendingConnectivity(); + # + f1=m1.buildOrthogonalField(); + arr1=[2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.] + arr=DataArrayDouble.New(); + arr.setValues(arr1,13,1); + f2=MEDCouplingFieldDouble.New(ON_CELLS); + f2.setArray(arr); + f2.setMesh(m1); + f2.checkCoherency(); + # + f3=f1/f2; + self.assertRaises(InterpKernelException,f2.__div__,f1) + f3.checkCoherency(); + f1/=f2; + #self.assertRaises(InterpKernelException,f2.__idiv__,f1) # mem leaks + self.assertTrue(f1.isEqual(f3,1e-10,1e-10)); + expected1=[-0.5, 0.0, 0.0, 0.33333333333333331, 0.25, 0.0, 0.0, -0.20000000000000001, 0.117851130197758, 0.117851130197758, 0.0, -0.14285714285714285, 0.0, 0.125, 0.1111111111111111, 0.0, 0.0, 0.10000000000000001, 0.090909090909090912, 0.0, -0.083333333333333329, 0.0, 0.0, 0.076923076923076927, 0.071428571428571425, 0.0] + for i in xrange(26): + self.assertAlmostEqual(expected1[i],f3.getIJ(0,i),10); + pass + pass + + def testDARearrange1(self): + da1=DataArrayInt.New(); + da1.alloc(12,1); + da1.iota(0); + # + self.assertEqual(12,da1.getNbOfElems()); + self.assertEqual(1,da1.getNumberOfComponents()); + self.assertEqual(12,da1.getNumberOfTuples()); + da1.rearrange(4); + self.assertEqual(12,da1.getNbOfElems()); + self.assertEqual(4,da1.getNumberOfComponents()); + self.assertEqual(3,da1.getNumberOfTuples()); + for i in xrange(12): + self.assertEqual(i,da1.getIJ(0,i)); + # + da1.rearrange(6); + self.assertEqual(12,da1.getNbOfElems()); + self.assertEqual(6,da1.getNumberOfComponents()); + self.assertEqual(2,da1.getNumberOfTuples()); + for i in xrange(12): + self.assertEqual(i,da1.getIJ(0,i)); + # + self.assertRaises(da1.rearrange(7),InterpKernelException); + # + da1.rearrange(12); + self.assertEqual(12,da1.getNbOfElems()); + self.assertEqual(12,da1.getNumberOfComponents()); + self.assertEqual(1,da1.getNumberOfTuples()); + for i in xrange(12): + self.assertEqual(i,da1.getIJ(0,i)); + # + da1.rearrange(3); + self.assertEqual(12,da1.getNbOfElems()); + self.assertEqual(3,da1.getNumberOfComponents()); + self.assertEqual(4,da1.getNumberOfTuples()); + for i in xrange(12): + self.assertEqual(i,da1.getIJ(0,i)); + #double + da2=da1.convertToDblArr(); + # + self.assertEqual(12,da2.getNbOfElems()); + self.assertEqual(3,da2.getNumberOfComponents()); + self.assertEqual(4,da2.getNumberOfTuples()); + da2.rearrange(4); + self.assertEqual(12,da2.getNbOfElems()); + self.assertEqual(4,da2.getNumberOfComponents()); + self.assertEqual(3,da2.getNumberOfTuples()); + for i in xrange(12): + self.assertAlmostEqual(float(i),da2.getIJ(0,i),14); + # + da2.rearrange(6); + self.assertEqual(12,da2.getNbOfElems()); + self.assertEqual(6,da2.getNumberOfComponents()); + self.assertEqual(2,da2.getNumberOfTuples()); + for i in xrange(12): + self.assertAlmostEqual(float(i),da2.getIJ(0,i),14); + # + self.assertRaises(da2.rearrange(7),InterpKernelException); + # + da2.rearrange(1); + self.assertTrue(ptr2==da2.getConstPointer()); + self.assertEqual(12,da2.getNbOfElems()); + self.assertEqual(1,da2.getNumberOfComponents()); + self.assertEqual(12,da2.getNumberOfTuples()); + for i in xrange(12): + self.assertAlmostEqual(float(i),da2.getIJ(0,i),14); + # + da2.rearrange(3); + self.assertEqual(12,da2.getNbOfElems()); + self.assertEqual(3,da2.getNumberOfComponents()); + self.assertEqual(4,da2.getNumberOfTuples()); + for i in xrange(12): + self.assertAlmostEqual(float(i),da2.getIJ(0,i),14); + pass + + def testDARearrange1(self): + da1=DataArrayInt.New(); + arr=[1,2,3,2,2,3,5,1,5,5,2,2] + da1.setValues(arr,4,3); + s=da1.getDifferentValues(True);# API different from C++ because SWIG complains... + expected1=[1,2,3,5] + self.assertEqual(expected1,s); + pass + + def testSwigErrorProtection3(self): + da=DataArrayInt.New() + da.setValues([1,2,3,4],4,3) + self.assertEqual([1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0],da.getValues()) + self.assertEqual(3,da.getNumberOfComponents()); + self.assertEqual(4,da.getNumberOfTuples()); + da=DataArrayInt.New() + da.setValues((1,2,3,4,4,3),4,3) + self.assertEqual([1, 2, 3, 4, 4, 3, 0, 0, 0, 0, 0, 0],da.getValues()) + self.assertEqual(3,da.getNumberOfComponents()); + self.assertEqual(4,da.getNumberOfTuples()); + da.setValues(10*[1]+290*[2],4,3) + self.assertEqual(10*[1]+[2,2],da.getValues()) + self.assertEqual(3,da.getNumberOfComponents()); + self.assertEqual(4,da.getNumberOfTuples()); + # + da=DataArrayDouble.New() + da.setValues([1,2,3.,4],4,3) + self.assertEqual([1., 2., 3., 4., 0., 0., 0., 0., 0., 0., 0., 0.],da.getValues()) + self.assertEqual(3,da.getNumberOfComponents()); + self.assertEqual(4,da.getNumberOfTuples()); + da=DataArrayDouble.New() + da.setValues((1,2,3,4.,4,3),4,3) + self.assertEqual([1., 2., 3., 4., 4., 3., 0., 0., 0., 0., 0., 0.],da.getValues()) + self.assertEqual(3,da.getNumberOfComponents()); + self.assertEqual(4,da.getNumberOfTuples()); + da.setValues(10*[1]+290*[2],4,3) + self.assertEqual(10*[1.]+[2.,2.],da.getValues()) + self.assertEqual(3,da.getNumberOfComponents()); + self.assertEqual(4,da.getNumberOfTuples()); + pass + + def testDAIBuildPermutationArr1(self): + a=DataArrayInt.New() + a.setValues([4,5,6,7,8],5,1) + b=DataArrayInt.New() + b.setValues([5,4,8,6,7],5,1) + c=a.buildPermutationArr(b) + self.assertEqual([1,0,4,2,3],c.getValues()) + self.assertTrue(a.isEqualWithoutConsideringStrAndOrder(b)) + b.setIJ(0,0,9) + self.assertTrue(not a.isEqualWithoutConsideringStrAndOrder(b)) + self.assertRaises(InterpKernelException,a.buildPermutationArr,b) + a.setIJ(3,0,4) + b.setIJ(0,0,5) + b.setIJ(4,0,4)#a==[4,5,6,4,8] and b==[5,4,8,6,4] + self.assertTrue(a.isEqualWithoutConsideringStrAndOrder(b)) + c=a.buildPermutationArr(b) + self.assertEqual([1,3,4,2,3],c.getValues()) + d=b.convertToDblArr() + expect3=[4,4,5,6,8] + b.sort() + self.assertEqual(expect3,b.getValues()) + d.sort() + self.assertEqual(5,d.getNumberOfTuples()); + self.assertEqual(1,d.getNumberOfComponents()); + for i in xrange(5): + self.assertAlmostEqual(float(expect3[i]),d.getIJ(i,0),14); + pass + pass + + def testAreCellsIncludedIn2(self): + myName="Vitoo"; + m=MEDCouplingDataForTest.build3DSurfTargetMesh_1(); + m2=m.buildPartOfMySelf([],True); + self.assertEqual(0,m2.getNumberOfCells()); + self.assertEqual(3,m2.getSpaceDimension()); + self.assertEqual(2,m2.getMeshDimension()); + m2.setName(myName); + test,tmp=m.areCellsIncludedIn(m2,0) + self.assertTrue(test); + self.assertEqual(myName,tmp.getName()); + self.assertEqual(0,tmp.getNumberOfTuples()) + self.assertEqual(1,tmp.getNumberOfComponents()) + pass + + def testUMeshGetPartBarycenterAndOwner1(self): + m1=MEDCouplingDataForTest.build2DTargetMesh_1(); + part1=[1,0,4]; + part=DataArrayInt.New(); + part.setValues(part1,3,1); + b=m1.getPartBarycenterAndOwner(part); + self.assertEqual(2,b.getNumberOfComponents()); + self.assertEqual(3,b.getNumberOfTuples()); + expected1=[0.36666666666666665,-0.13333333333333333,-0.05,-0.05,0.45,0.45]; + for i in xrange(6): + self.assertAlmostEqual(expected1[i],b.getIJ(0,i),14); + pass + pass + + def testUMeshGetPartMeasureField1(self): + m1=MEDCouplingDataForTest.build2DTargetMesh_1(); + part1=[1,0,4]; + part=DataArrayInt.New(); + part.setValues(part1,3,1); + b=m1.getPartMeasureField(True,part); + self.assertEqual(1,b.getNumberOfComponents()); + self.assertEqual(3,b.getNumberOfTuples()); + expected1=[0.125,0.25,0.25]; + for i in xrange(3): + self.assertAlmostEqual(expected1[i],b.getIJ(0,i),14); + pass + pass + + def testUMeshBuildPartOrthogonalField1(self): + m1=MEDCouplingDataForTest.build2DTargetMesh_1(); + m1.changeSpaceDimension(3); + part1=[1,0,4]; + part=DataArrayInt.New(); + part.setValues(part1,3,1); + b=m1.buildPartOrthogonalField(part); + self.assertEqual(3,b.getArray().getNumberOfComponents()); + self.assertEqual(3,b.getArray().getNumberOfTuples()); + expected1=[0.,0.,-1.,0.,0.,-1.,0.,0.,-1.]; + for i in xrange(9): + self.assertAlmostEqual(expected1[i],b.getArray().getIJ(0,i),14); + pass + pass + + def testUMeshGetTypesOfPart1(self): + m1=MEDCouplingDataForTest.build2DTargetMesh_1(); + part1=[0,3,4]; + p1=DataArrayInt.New() + p1.setValues(part1,3,1) + s=m1.getTypesOfPart(p1); + self.assertEqual([NORM_QUAD4],s); + part2=[2,2,2,1]; + p2=DataArrayInt.New() + p2.setValues(part2,4,1) + s=m1.getTypesOfPart(p2); + self.assertEqual([NORM_TRI3],s); + part3=[3,2,1]; + p3=DataArrayInt.New() + p3.setValues(part3,3,1) + s=m1.getTypesOfPart(p3); + self.assertEqual(s,[NORM_TRI3,NORM_QUAD4]); + pass + + def testUMeshKeepCellIdsByType1(self): + m1=MEDCouplingDataForTest.build2DTargetMesh_1(); + part1=[0,3,4] + p1=DataArrayInt.New() + p1.setValues(part1,3,1) + p1.setName("p1") + a=m1.keepCellIdsByType(NORM_TRI3,p1); + self.assertEqual("p1",a.getName()) + self.assertEqual(1,a.getNumberOfComponents()); + self.assertEqual(0,a.getNumberOfTuples()); + # + part2=[3,2,0,2,4] + p2=DataArrayInt.New() + p2.setValues(part2,5,1) + p2.setName("p2") + a=m1.keepCellIdsByType(NORM_TRI3,p2); + self.assertEqual("p2",a.getName()) + self.assertEqual(1,a.getNumberOfComponents()); + self.assertEqual(2,a.getNumberOfTuples()); + self.assertEqual(2,a.getIJ(0,0)); + self.assertEqual(2,a.getIJ(1,0)); + # + a=m1.keepCellIdsByType(NORM_QUAD4,p2); + self.assertEqual("p2",a.getName()) + self.assertEqual(1,a.getNumberOfComponents()); + self.assertEqual(3,a.getNumberOfTuples()); + self.assertEqual(3,a.getIJ(0,0)); + self.assertEqual(0,a.getIJ(1,0)); + self.assertEqual(4,a.getIJ(2,0)); + pass + + def testSwigErrorDaIntSelectByTupleId1(self): + a=DataArrayInt.New(); + arr1=[1,11,2,12,3,13,4,14,5,15,6,16,7,17] + a.setValues(arr1,7,2); + a.setInfoOnComponent(0,"toto"); + a.setInfoOnComponent(1,"tata"); + # + arr2=[4,2,0,6,5] + b=a.selectByTupleId(arr2); + self.assertEqual(5,b.getNumberOfTuples()); + self.assertEqual(2,b.getNumberOfComponents()); + self.assertTrue(b.getInfoOnComponent(0)=="toto"); + self.assertTrue(b.getInfoOnComponent(1)=="tata"); + expected1=[5,15,3,13,1,11,7,17,6,16] + self.assertEqual(expected1,b.getValues()) + # + a2=DataArrayInt.New() + a2.setValues(arr2,5,1) + b=a.selectByTupleId(a2); + self.assertEqual(5,b.getNumberOfTuples()); + self.assertEqual(2,b.getNumberOfComponents()); + self.assertTrue(b.getInfoOnComponent(0)=="toto"); + self.assertTrue(b.getInfoOnComponent(1)=="tata"); + expected1=[5,15,3,13,1,11,7,17,6,16] + self.assertEqual(expected1,b.getValues()) + pass + + def testSwigErrorRenum(self): + da=DataArrayDouble.New() + da.setValues([7.,107.,8.,108.,9.,109.,10.,110.,11.,111.,12.,112.,13.,113.,14.,114.,15.,115.,16.,116.],10,2) + d=DataArrayInt.New() + d.setValues([0,2,3,1,4,5,6,8,7,9],10,1) + da.renumberInPlace(d) + da.renumber(d) + pass + + def testSwigGetItem1(self): + da=DataArrayInt.New() + da.alloc(16,3) + da.rearrange(1) + da.iota(7) + da.rearrange(3) + da.setInfoOnComponent(0,"X [m]") + da.setInfoOnComponent(1,"Y [m]") + da.setInfoOnComponent(2,"Z [km]") + da2=da[5:-1] + self.assertEqual([22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51],da2.getValues()) + da2=da[4] + self.assertEqual([19, 20, 21],da2.getValues()) + try: + da2=da[4:17] + except InterpKernelException as e: + self.assertTrue(True) + else: + self.assertTrue(False) + pass + da2=da[5:-2,2] + self.assertEqual([24, 27, 30, 33, 36, 39, 42, 45, 48],da2.getValues()) + da2=da[5:8,:] + self.assertEqual([22, 23, 24, 25, 26, 27, 28, 29, 30],da2.getValues()) + da2=da[:] + self.assertTrue(da2.isEqual(da)) + da2=da[:,:] + self.assertTrue(da2.isEqual(da)) + try: + da2=da[:,:,:] + except InterpKernelException as e: + self.assertTrue(True) + else: + self.assertTrue(False) + pass + try: + da2=da[5:8,-2] + except InterpKernelException as e: + self.assertTrue(True) + else: + self.assertTrue(False) + pass + da2=da[5:8,:-2] + self.assertEqual([22, 25, 28],da2.getValues()) + try: + da2=da[5:-18,2] + except InterpKernelException as e: + self.assertTrue(True) + else: + self.assertTrue(False) + pass + da2=da[5:5,2] + self.assertEqual([],da2.getValues()) + pass + + def testSwigGetItem2(self): + da=DataArrayDouble.New() + da.alloc(16,3) + da.rearrange(1) + da.iota(7) + da.rearrange(3) + da.setInfoOnComponent(0,"X [m]") + da.setInfoOnComponent(1,"Y [m]") + da.setInfoOnComponent(2,"Z [km]") + da2=da[5:-1] + self.assertEqual([22., 23., 24., 25., 26., 27., 28., 29., 30., 31., 32., 33., 34., 35., 36., 37., 38., 39., 40., 41., 42., 43., 44., 45., 46., 47., 48., 49., 50., 51.],da2.getValues()) + da2=da[4] + self.assertEqual([19., 20., 21],da2.getValues()) + try: + da2=da[4:17] + except InterpKernelException as e: + self.assertTrue(True) + else: + self.assertTrue(False) + pass + da2=da[5:-2,2] + self.assertEqual([24., 27., 30., 33., 36., 39., 42., 45., 48.],da2.getValues()) + da2=da[5:8,:] + self.assertEqual([22., 23., 24., 25., 26., 27., 28., 29., 30.],da2.getValues()) + da2=da[:] + self.assertTrue(da2.isEqual(da,1e-12)) + da2=da[:,:] + self.assertTrue(da2.isEqual(da,1e-12)) + try: + da2=da[:,:,:] + except InterpKernelException as e: + self.assertTrue(True) + else: + self.assertTrue(False) + pass + try: + da2=da[5:8,-2] + except InterpKernelException as e: + self.assertTrue(True) + else: + self.assertTrue(False) + pass + da2=da[5:8,:-2] + self.assertEqual([22., 25., 28.],da2.getValues()) + try: + da2=da[5:-18,2] + except InterpKernelException as e: + self.assertTrue(True) + else: + self.assertTrue(False) + pass + da2=da[5:5,2] + self.assertEqual([],da2.getValues()) + pass + + def testSwigSetItem1(self): + da=DataArrayInt.New() + da.alloc(20,1) + da.iota(7) + da.rearrange(5) + da.setInfoOnComponent(0,"X [m]") ; da.setInfoOnComponent(1,"Y [km]") ; da.setInfoOnComponent(2,"Y [m]") + da.setInfoOnComponent(3,"Z [W]") ; da.setInfoOnComponent(4,"ZZ [km]") ; + da[:,2]=3 + self.assertEqual([7, 8, 3, 10, 11, 12, 13, 3, 15, 16, 17, 18, 3, 20, 21, 22, 23, 3, 25, 26],da.getValues()) + da.rearrange(1) ; da.iota(7) ; da.rearrange(5) + da[2]=3 + self.assertEqual([7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 3, 3, 3, 3, 3, 22, 23, 24, 25, 26],da.getValues()) + da.rearrange(1) ; da.iota(7) ; da.rearrange(5) + da[[0,3]]=-1 + self.assertEqual([-1, -1, -1, -1, -1, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, -1, -1, -1, -1, -1],da.getValues()) + da.rearrange(1) ; da.iota(7) ; da.rearrange(5) + da[:,[1,3,4]]=-3 + self.assertEqual([7, -3, 9, -3, -3, 12, -3, 14, -3, -3, 17, -3, 19, -3, -3, 22, -3, 24, -3, -3],da.getValues()) + da.rearrange(1) ; da.iota(7) ; da.rearrange(5) + da2=DataArrayInt.New() ; da2.setValues([0,2,3],3,1) + da[da2]=-7 + self.assertEqual([-7, -7, -7, -7, -7, 12, 13, 14, 15, 16, -7, -7, -7, -7, -7, -7, -7, -7, -7, -7],da.getValues()) + da.rearrange(1) ; da.iota(7) ; da.rearrange(5) + da[da2,-2:]=-7 + self.assertEqual([7, 8, 9, -7, -7, 12, 13, 14, 15, 16, 17, 18, 19, -7, -7, 22, 23, 24, -7, -7],da.getValues()) + # Let's test with DAI right hand side + da1=DataArrayInt.New() + da1.setValues([25,26,27,125,126,127],2,3) + # + da.rearrange(1) ; da.iota(7) ; da.rearrange(5) + da[-2:,1:4]=da1 + self.assertEqual([7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 25, 26, 27, 21, 22, 125, 126, 127, 26],da.getValues()) + da.rearrange(1) ; da.iota(7) ; da.rearrange(5) + da[1:,3]=[225,226,227] + self.assertEqual([7, 8, 9, 10, 11, 12, 13, 14, 225, 16, 17, 18, 19, 226, 21, 22, 23, 24, 227, 26],da.getValues()) + da.rearrange(1) ; da.iota(7) ; da.rearrange(5) + da[1,2:]=[225,226,227] + self.assertEqual([7, 8, 9, 10, 11, 12, 13, 225, 226, 227, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26],da.getValues()) + da.rearrange(1) ; da.iota(7) ; da.rearrange(5) + da[da2,-2:]=[88,99,1010,1111,1212,1313] + self.assertEqual([7, 8, 9, 88, 99, 12, 13, 14, 15, 16, 17, 18, 19, 1010, 1111, 22, 23, 24, 1212, 1313],da.getValues()) + da.rearrange(1) ; da.iota(7) ; da.rearrange(5) + da3=DataArrayInt.New(); da3.setValues([88,99,1010,1111,1212,1313],3,2) + da[da2,-2:]=da3 + self.assertEqual([7, 8, 9, 88, 99, 12, 13, 14, 15, 16, 17, 18, 19, 1010, 1111, 22, 23, 24, 1212, 1313],da.getValues()) + da.rearrange(1) ; da.iota(7) ; da.rearrange(5) + da[da2,[0,2]]=da3 + self.assertEqual([88, 8, 99, 10, 11, 12, 13, 14, 15, 16, 1010, 18, 1111, 20, 21, 1212, 23, 1313, 25, 26],da.getValues()) + da.rearrange(1) ; da.iota(7) ; da.rearrange(5) + da[da2,0:3:2]=da3 + self.assertEqual([88, 8, 99, 10, 11, 12, 13, 14, 15, 16, 1010, 18, 1111, 20, 21, 1212, 23, 1313, 25, 26],da.getValues()) + da.rearrange(1) ; da.iota(7) ; da.rearrange(5) + da[da2,0:3:2]=-8 + self.assertEqual([-8, 8, -8, 10, 11, 12, 13, 14, 15, 16, -8, 18, -8, 20, 21, -8, 23, -8, 25, 26],da.getValues()) + pass + + def testSwigSetItem2(self): + da=DataArrayDouble.New() + da.alloc(20,1) + da.iota(7) + da.rearrange(5) + da.setInfoOnComponent(0,"X [m]") ; da.setInfoOnComponent(1,"Y [km]") ; da.setInfoOnComponent(2,"Y [m]") + da.setInfoOnComponent(3,"Z [W]") ; da.setInfoOnComponent(4,"ZZ [km]") ; + da[:,2]=3. + self.assertEqual([7., 8., 3., 10., 11., 12., 13., 3., 15., 16., 17., 18., 3., 20., 21., 22., 23., 3., 25., 26.],da.getValues()) + da.rearrange(1) ; da.iota(7) ; da.rearrange(5) + da[2]=3. + self.assertEqual([7., 8., 9., 10., 11., 12., 13., 14., 15., 16., 3., 3., 3., 3., 3., 22., 23., 24., 25., 26.],da.getValues()) + da.rearrange(1) ; da.iota(7) ; da.rearrange(5) + da[[0,3]]=-1. + self.assertEqual([-1., -1., -1., -1., -1., 12., 13., 14., 15., 16., 17., 18., 19., 20., 21., -1., -1., -1., -1., -1.],da.getValues()) + da.rearrange(1) ; da.iota(7) ; da.rearrange(5) + da[:,[1,3,4]]=-3. + self.assertEqual([7., -3., 9., -3., -3., 12., -3., 14., -3., -3., 17., -3., 19., -3., -3., 22., -3., 24., -3., -3.],da.getValues()) + da.rearrange(1) ; da.iota(7) ; da.rearrange(5) + da2=DataArrayInt.New() ; da2.setValues([0,2,3],3,1) + da[da2]=-7. + self.assertEqual([-7., -7., -7., -7., -7., 12., 13., 14., 15., 16., -7., -7., -7., -7., -7., -7., -7., -7., -7., -7.],da.getValues()) + da.rearrange(1) ; da.iota(7) ; da.rearrange(5) + da[da2,-2:]=-7 + self.assertEqual([7., 8., 9., -7., -7., 12., 13., 14., 15., 16., 17., 18., 19., -7., -7., 22., 23., 24., -7., -7.],da.getValues()) + # Let's test with DAI right hand side + da1=DataArrayDouble.New() + da1.setValues([25,26,27,125,126,127],2,3) + # + da.rearrange(1) ; da.iota(7) ; da.rearrange(5) + da[-2:,1:4]=da1 + self.assertEqual([7., 8., 9., 10., 11., 12., 13., 14., 15., 16., 17., 25., 26., 27., 21., 22., 125., 126., 127., 26.],da.getValues()) + da.rearrange(1) ; da.iota(7) ; da.rearrange(5) + da[1:,3]=[225.,226.,227.] + self.assertEqual([7., 8., 9., 10., 11., 12., 13., 14., 225., 16., 17., 18., 19., 226., 21., 22., 23., 24., 227., 26.],da.getValues()) + da.rearrange(1) ; da.iota(7) ; da.rearrange(5) + da[1,2:]=[225,226,227] + self.assertEqual([7., 8., 9., 10., 11., 12., 13., 225., 226., 227., 17., 18., 19., 20., 21., 22., 23., 24., 25., 26.],da.getValues()) + da.rearrange(1) ; da.iota(7) ; da.rearrange(5) + da[da2,-2:]=[88,99,1010,1111,1212,1313] + self.assertEqual([7., 8., 9., 88., 99., 12., 13., 14., 15., 16., 17., 18., 19., 1010., 1111., 22., 23., 24., 1212., 1313.],da.getValues()) + da.rearrange(1) ; da.iota(7) ; da.rearrange(5) + da3=DataArrayDouble.New(); da3.setValues([88,99,1010,1111,1212,1313],3,2) + da[da2,-2:]=da3 + self.assertEqual([7., 8., 9., 88., 99., 12., 13., 14., 15., 16., 17., 18., 19., 1010., 1111., 22., 23., 24., 1212., 1313.],da.getValues()) + da.rearrange(1) ; da.iota(7) ; da.rearrange(5) + da[da2,[0,2]]=da3 + self.assertEqual([88., 8., 99., 10., 11., 12., 13., 14., 15., 16., 1010., 18., 1111., 20., 21., 1212., 23., 1313., 25., 26.],da.getValues()) + da.rearrange(1) ; da.iota(7) ; da.rearrange(5) + da[da2,0:3:2]=da3 + self.assertEqual([88., 8., 99., 10., 11., 12., 13., 14., 15., 16., 1010., 18., 1111., 20., 21., 1212., 23., 1313., 25., 26.],da.getValues()) + da.rearrange(1) ; da.iota(7) ; da.rearrange(5) + da[da2,0:3:2]=-8. + self.assertEqual([-8., 8., -8., 10., 11., 12., 13., 14., 15., 16., -8., 18., -8., 20., 21., -8., 23., -8., 25., 26.],da.getValues()) + pass + + def testSwigDADOp(self): + da=DataArrayDouble.New() + da.alloc(12,1) + da.iota(7.) + da1=DataArrayDouble.New() + da1.alloc(12,1) + da1.iota(8.) + da2=da+da1 + self.assertEqual([15., 17., 19., 21., 23., 25., 27., 29., 31., 33., 35., 37.],da2.getValues()) + da2=da+3 + da3=3+da + self.assertTrue(da2.isEqual(da3,1e-12)) + da2=da-1. + self.assertEqual([6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0],da2.getValues()) + da2=1-da + self.assertEqual([-6.0, -7.0, -8.0, -9.0, -10.0, -11.0, -12.0, -13.0, -14.0, -15.0, -16.0, -17.0],da2.getValues()) + da2=da*3 + self.assertEqual([21.0, 24.0, 27.0, 30.0, 33.0, 36.0, 39.0, 42.0, 45.0, 48.0, 51.0, 54.0],da2.getValues()) + da2=3.*da + self.assertEqual([21.0, 24.0, 27.0, 30.0, 33.0, 36.0, 39.0, 42.0, 45.0, 48.0, 51.0, 54.0],da2.getValues()) + da2=da*da1 + self.assertEqual([56.0, 72.0, 90.0, 110.0, 132.0, 156.0, 182.0, 210.0, 240.0, 272.0, 306.0, 342.0],da2.getValues()) + da2=da/4. + self.assertEqual([1.75, 2.0, 2.25, 2.5, 2.75, 3.0, 3.25, 3.5, 3.75, 4.0, 4.25, 4.5],da2.getValues()) + da3=4./da + da4=da3*da2 + self.assertTrue(da4.isUniform(1.,1e-12)) + st1=da.getHiddenCppPointer() + da+=1 + st2=da.getHiddenCppPointer() + self.assertEqual(st1,st2) + self.assertTrue(da.isEqual(da1,1e-12)) + da-=8 + st2=da.getHiddenCppPointer() + self.assertEqual(st1,st2) + self.assertEqual(range(12),da.getValues()) + da+=da1 + st2=da.getHiddenCppPointer() + self.assertEqual(st1,st2) + self.assertEqual([8.0, 10.0, 12.0, 14.0, 16.0, 18.0, 20.0, 22.0, 24.0, 26.0, 28.0, 30.0],da.getValues()) + da*=0.5 + st2=da.getHiddenCppPointer() + self.assertEqual(st1,st2) + self.assertEqual([4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0],da.getValues()) + da*=da1 + st2=da.getHiddenCppPointer() + self.assertEqual(st1,st2) + self.assertEqual([32.0, 45.0, 60.0, 77.0, 96.0, 117.0, 140.0, 165.0, 192.0, 221.0, 252.0, 285.0],da.getValues()) + da/=da1 + self.assertEqual(st1,st2) + self.assertEqual([4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0],da.getValues()) + da/=2 + st2=da.getHiddenCppPointer() + self.assertEqual(st1,st2) + self.assertEqual([2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 5.5, 6.0, 6.5, 7.0, 7.5],da.getValues()) + da.rearrange(3) + da5=DataArrayDouble.New() + da5.setValues([5.,4.,3.,2.],4,1) + da*=da5 # it works with unmathing number of compo + st2=da.getHiddenCppPointer() + self.assertEqual(st1,st2) + self.assertEqual([10.0, 12.5, 15.0, 14.0, 16.0, 18.0, 15.0, 16.5, 18.0, 13.0, 14.0, 15.0],da.getValues()) + pass + + def testSwigDAIOp(self): + da=DataArrayInt.New() + da.alloc(12,1) + da.iota(7) + da1=DataArrayInt.New() + da1.alloc(12,1) + da1.iota(8) + da2=da+da1 + self.assertEqual([15,17,19,21,23,25,27,29,31,33,35,37],da2.getValues()) + da2=da+3 + da3=3+da + self.assertTrue(da2.isEqual(da3)) + da2=da-1 + self.assertEqual([6,7,8,9,10,11,12,13,14,15,16,17],da2.getValues()) + da2=1-da + self.assertEqual([-6,-7,-8,-9,-10,-11,-12,-13,-14,-15,-16,-17],da2.getValues()) + da2=da*3 + self.assertEqual([21,24,27,30,33,36,39,42,45,48,51,54.0],da2.getValues()) + da2=3*da + self.assertEqual([21,24,27,30,33,36,39,42,45,48,51,54.0],da2.getValues()) + da2=da*da1 + self.assertEqual([56,72,90,110,132,156,182,210,240,272,306,342.0],da2.getValues()) + da2=da/4 + self.assertEqual([1,2,2,2,2,3,3,3,3,4,4,4],da2.getValues()) + da3=4/da + da4=da3*da2 + self.assertTrue(da4.isUniform(0)) + st1=da.getHiddenCppPointer() + da+=1 + st2=da.getHiddenCppPointer() + self.assertEqual(st1,st2) + self.assertTrue(da.isEqual(da1)) + da-=8 + st2=da.getHiddenCppPointer() + self.assertEqual(st1,st2) + self.assertEqual(range(12),da.getValues()) + da+=da1 + st2=da.getHiddenCppPointer() + self.assertEqual(st1,st2) + self.assertEqual([8,10,12,14,16,18,20,22,24,26,28,30],da.getValues()) + da/=2 + st2=da.getHiddenCppPointer() + self.assertEqual(st1,st2) + self.assertEqual([4,5,6,7,8,9,10,11,12,13,14,15],da.getValues()) + da*=da1 + st2=da.getHiddenCppPointer() + self.assertEqual(st1,st2) + self.assertEqual([32,45,60,77,96,117,140,165,192,221,252,285],da.getValues()) + da/=da1 + self.assertEqual(st1,st2) + self.assertEqual([4,5,6,7,8,9,10,11,12,13,14,15],da.getValues()) + da/=2 + st2=da.getHiddenCppPointer() + self.assertEqual(st1,st2) + self.assertEqual([2,2, 3,3, 4,4, 5,5, 6,6, 7,7],da.getValues()) + da.rearrange(3) + da5=DataArrayInt.New() + da5.setValues([5,4,3,2],4,1) + da*=da5 # it works with unmathing number of compo + st2=da.getHiddenCppPointer() + self.assertEqual(st1,st2) + self.assertEqual([10,10, 15,12,16,16,15,15, 18,12,14,14],da.getValues()) + da%=6 + st2=da.getHiddenCppPointer() + self.assertEqual(st1,st2) + self.assertEqual([4,4,3,0,4,4,3,3,0,0,2,2],da.getValues()) + pass + + def testSwigDAIOp2(self): + da=DataArrayInt.New() + st=da.getHiddenCppPointer() + da.alloc(10,3) + da.rearrange(1) + da.iota(0) + da.rearrange(3) + da[:,1]+=4 + da[-2:,2]+=10 + da[-2:,2]+=10 + da[:,2]+=da[:,0] + da[da[0],:]=7 + self.assertEqual(st,da.getHiddenCppPointer()) + self.assertEqual(da.getValues(),[7,7,7,3,8,8,7,7,7,9,14,20,12,17,26,7,7,7,18,23,38,21,26,44,24,29,70,27,32,76]) + pass + + def testDAIAggregateMulti1(self): + a=DataArrayInt.New() + a.setValues(range(4),2,2) + a.setName("aa") + b=DataArrayInt.New() + b.setValues(range(6),3,2) + c=DataArrayInt.Aggregate([a,b]) + self.assertEqual(range(4)+range(6),c.getValues()) + self.assertEqual("aa",c.getName()) + self.assertEqual(5,c.getNumberOfTuples()) + self.assertEqual(2,c.getNumberOfComponents()) + pass + + def testMergeUMeshes2(self): + m1=MEDCouplingDataForTest.build3DSurfTargetMesh_1(); + m2=MEDCouplingDataForTest.build3DSurfTargetMesh_1(); + m3=MEDCouplingDataForTest.build3DSurfTargetMesh_1(); + # + vec1=[0,2,3] + m2_2=m2.buildPartOfMySelf(vec1,False); + vec2=[1,1] + m3_2=m3.buildPartOfMySelf(vec2,False); + # + ms=[m1,m2_2,m3_2]; + # + m4=MEDCouplingUMesh.MergeUMeshes(ms); + m4.checkCoherency(); + self.assertEqual(10,m4.getNumberOfCells()); + self.assertEqual(20,m4.getNumberOfNodes()); + self.assertEqual(45,m4.getMeshLength()); + # + vec3=[0,1,2,3,4] + m4_1=m4.buildPartOfMySelf(vec3,False); + m4_1.setName(m1.getName()); + self.assertTrue(m4_1.isEqual(m1,1e-12)); + # + vec4=[5,6,7] + m4_2=m4.buildPartOfMySelf(vec4,False); + cellCor,nodeCor=m4_2.checkGeoEquivalWith(m2_2,10,1e-12); + # + vec5=[8,9] + m4_3=m4.buildPartOfMySelf(vec5,False); + self.assertEqual(2,m4_3.getNumberOfCells()); + self.assertEqual(3,m4_3.getNumberOfNodes()); + m3_2.zipCoords(); + m4_3.setName(m3_2.getName()); + self.assertTrue(m4_3.isEqual(m3_2,1e-12)); + # + pass + + def testBuild0DMeshFromCoords1(self): + sourceCoords=[-0.3,-0.3,0., 0.7,-0.3,0., -0.3,0.7,0., 0.7,0.7,0.] + coo=DataArrayDouble.New(); + coo.setValues(sourceCoords,4,3); + coo.setName("My0D"); + m=MEDCouplingUMesh.Build0DMeshFromCoords(coo); + m.checkCoherency(); + self.assertEqual(4,m.getNumberOfNodes()); + self.assertEqual(4,m.getNumberOfCells()); + self.assertEqual(3,m.getSpaceDimension()); + self.assertEqual(0,m.getMeshDimension()); + types1=m.getAllTypes(); + self.assertEqual([NORM_POINT1],types1); + for i in xrange(4): + conn=m.getNodeIdsOfCell(i); + self.assertEqual([i],conn); + self.assertTrue(NORM_POINT1==m.getTypeOfCell(i)); + pass + self.assertEqual(m.getName(),"My0D"); + pass + + def testDescriptionInMeshTimeUnit1(self): + text1="totoTTEDD"; + m=MEDCouplingDataForTest.build2DTargetMesh_1(); + m.setDescription(text1); + self.assertEqual(m.getDescription(),text1); + m2=m.deepCpy(); + self.assertTrue(m.isEqual(m2,1e-12)); + self.assertEqual(m2.getDescription(),text1); + m2.setDescription("ggg"); + self.assertTrue(not m.isEqual(m2,1e-12)); + # + f=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME); + f.setTimeUnit(text1); + self.assertEqual(f.getTimeUnit(),text1); + f2=f.deepCpy(); + self.assertEqual(f2.getTimeUnit(),text1); + # + pass + + def testMultiFields1(self): + mfs=MEDCouplingDataForTest.buildMultiFields_1(); + ms=mfs.getMeshes(); + dms,refs=mfs.getDifferentMeshes() + das=mfs.getArrays(); + das2,refs2=mfs.getDifferentArrays() + self.assertEqual(5,len(mfs.getFields())) + self.assertEqual(1,len(mfs.getFields()[0].getArrays())); + self.assertEqual(2,len(mfs.getFields()[1].getArrays())); + self.assertEqual(1,len(mfs.getFields()[2].getArrays())); + self.assertEqual(1,len(mfs.getFields()[3].getArrays())); + self.assertEqual(1,len(mfs.getFields()[4].getArrays())); + self.assertEqual(5,len(ms)); + self.assertEqual(2,len(dms)); + self.assertEqual(6,len(das)); + self.assertEqual(5,len(das2)); + mfs2=mfs.deepCpy(); + self.assertTrue(mfs.isEqual(mfs2,1e-12,1e-12)) + pass + + def testFieldOverTime1(self): + fs=MEDCouplingDataForTest.buildMultiFields_2(); + self.assertRaises(InterpKernelException,MEDCouplingFieldOverTime.New,fs); + f4bis=fs[4].buildNewTimeReprFromThis(ONE_TIME,False); + fs[4]=f4bis; + self.assertRaises(InterpKernelException,MEDCouplingFieldOverTime.New,fs); + f4bis.setTime(2.7,20,21); + fot=MEDCouplingFieldOverTime.New(fs); + dt=fot.getDefinitionTimeZone(); + hs=dt.getHotSpotsTime(); + self.assertEqual(6,len(hs)); + expected1=[0.2,0.7,1.2,1.35,1.7,2.7] + for i in xrange(6): + self.assertAlmostEqual(expected1[i],hs[i],12); + pass + meshId,arrId,arrIdInField,fieldId=dt.getIdsOnTimeRight(0.2); + self.assertEqual(0,meshId); + self.assertEqual(0,arrId); + self.assertEqual(0,arrIdInField); + self.assertEqual(0,fieldId); + # + meshId,arrId,arrIdInField,fieldId=dt.getIdsOnTimeRight(0.7); + self.assertEqual(0,meshId); + self.assertEqual(1,arrId); + self.assertEqual(0,arrIdInField); + self.assertEqual(1,fieldId); + # + meshId,arrId,arrIdInField,fieldId=dt.getIdsOnTimeLeft(1.2);#**** WARNING left here + self.assertEqual(0,meshId); + self.assertEqual(2,arrId); + self.assertEqual(1,arrIdInField); + self.assertEqual(1,fieldId); + # + meshId,arrId,arrIdInField,fieldId=dt.getIdsOnTimeRight(1.2);#**** WARNING right again here + self.assertEqual(1,meshId); + self.assertEqual(3,arrId); + self.assertEqual(0,arrIdInField); + self.assertEqual(2,fieldId); + # + meshId,arrId,arrIdInField,fieldId=dt.getIdsOnTimeRight(1.35); + self.assertEqual(1,meshId); + self.assertEqual(3,arrId); + self.assertEqual(0,arrIdInField); + self.assertEqual(2,fieldId); + # + meshId,arrId,arrIdInField,fieldId=dt.getIdsOnTimeRight(1.7); + self.assertEqual(0,meshId); + self.assertEqual(3,arrId); + self.assertEqual(0,arrIdInField); + self.assertEqual(3,fieldId); + # + meshId,arrId,arrIdInField,fieldId=dt.getIdsOnTimeRight(2.7); + self.assertEqual(1,meshId); + self.assertEqual(4,arrId); + self.assertEqual(0,arrIdInField); + self.assertEqual(4,fieldId); + # + dt2=MEDCouplingDefinitionTime(); + self.assertTrue(not dt2.isEqual(dt)); + dt2.assign(dt); + dt2.assign(dt);#to check memory management + self.assertTrue(dt2.isEqual(dt)); + # + dt3=MEDCouplingDefinitionTime(); + # + pass + + def testDAICheckAndPreparePermutation1(self): + vals1=[9,10,0,6,4,11,3,7]; + expect1=[5,6,0,3,2,7,1,4]; + vals2=[9,10,0,6,10,11,3,7]; + da=DataArrayInt.New(); + da.setValues(vals1,8,1); + da2=da.checkAndPreparePermutation(); + self.assertEqual(8,da2.getNumberOfTuples()); + self.assertEqual(1,da2.getNumberOfComponents()); + for i in xrange(8): + self.assertEqual(expect1[i],da2.getIJ(i,0)); + pass + # + da=DataArrayInt.New(); + da.alloc(8,1); + da.iota(0); + da2=da.checkAndPreparePermutation(); + self.assertEqual(8,da2.getNumberOfTuples()); + self.assertEqual(1,da2.getNumberOfComponents()); + self.assertTrue(da2.isIdentity()); + # + da=DataArrayInt.New(); + da.alloc(8,1); + da.setValues(vals2,8,1); + self.assertRaises(InterpKernelException,da.checkAndPreparePermutation); + pass + + def testDAIChangeSurjectiveFormat1(self): + vals1=[0,3,2,3,2,2,1,2] + expected1=[0,1,2,6,8] + expected2=[0, 6, 2,4,5,7, 1,3] + da=DataArrayInt.New(); + da.setValues(vals1,8,1); + # + da2,da2I=da.changeSurjectiveFormat(4); + self.assertEqual(5,da2I.getNumberOfTuples()); + self.assertEqual(8,da2.getNumberOfTuples()); + self.assertEqual(expected1,da2I.getValues()); + self.assertEqual(expected2,da2.getValues()); + # + self.assertRaises(InterpKernelException,da.changeSurjectiveFormat,3); + # + pass + + def testUMeshGetCellIdsLyingOnNodes1(self): + m=MEDCouplingDataForTest.build3DSurfTargetMesh_1(); + nodeIds1=[1,2,3,4,6] + nodeIds2=[6,7] + da=m.getCellIdsLyingOnNodes(nodeIds1,True); + self.assertEqual(1,da.getNumberOfTuples()); + self.assertEqual(1,da.getNumberOfComponents()); + self.assertEqual(1,da.getIJ(0,0)); + da2=DataArrayInt.New() + da2.setValues(nodeIds2,2,1) + da=m.getCellIdsLyingOnNodes(da2,False); + self.assertEqual(2,da.getNumberOfTuples()); + self.assertEqual(1,da.getNumberOfComponents()); + self.assertEqual(3,da.getIJ(0,0)); + self.assertEqual(4,da.getIJ(1,0)); + pass + + def testUMeshFindCellsIdsOnBoundary1(self): + m=MEDCouplingDataForTest.build3DSurfTargetMesh_1(); + da5=m.findCellsIdsOnBoundary(); + self.assertEqual(5,da5.getNumberOfTuples()); + self.assertTrue(da5.isIdentity()); + pass + + def testMeshSetTime1(self): + m1=MEDCouplingDataForTest.build3DSurfTargetMesh_1(); + m2=MEDCouplingDataForTest.build3DSurfTargetMesh_1(); + # + self.assertTrue(m1.isEqual(m2,1e-12)); + m1.setTime(3.14,6,7); + tmp3,tmp1,tmp2=m1.getTime(); + self.assertEqual(6,tmp1); + self.assertEqual(7,tmp2); + self.assertAlmostEqual(3.14,tmp3,12); + self.assertTrue(not m1.isEqual(m2,1e-12)); + m2.setTime(3.14,6,7); + self.assertTrue(m1.isEqual(m2,1e-12)); + m1.setTimeUnit("ms"); + self.assertTrue(m1.getTimeUnit()=="ms"); + m1.setTimeUnit("us"); + self.assertTrue(m1.getTimeUnit()=="us"); + self.assertTrue(not m1.isEqual(m2,1e-12)); + m2.setTimeUnit("us"); + self.assertTrue(m1.isEqual(m2,1e-12)); + m2.setTime(3.14,6,8); + self.assertTrue(not m1.isEqual(m2,1e-12)); + m2.setTime(3.14,7,7); + self.assertTrue(not m1.isEqual(m2,1e-12)); + m2.setTime(3.15,6,7); + self.assertTrue(not m1.isEqual(m2,1e-12)); + # + m1.setTime(10.34,55,12); + m3=m1.deepCpy(); + self.assertTrue(m1.isEqual(m3,1e-12)); + tmp3,tmp1,tmp2=m3.getTime(); + self.assertEqual(55,tmp1); + self.assertEqual(12,tmp2); + self.assertAlmostEqual(10.34,tmp3,12); + # + # testing CMesh + coo1=[0.,1.,2.,3.5] + a=DataArrayDouble.New(); + a.setValues(coo1,4,1); + b=MEDCouplingCMesh.New(); + b.setCoordsAt(0,a); + # + b.setTime(5.67,8,100); + tmp3,tmp1,tmp2=b.getTime(); + self.assertEqual(8,tmp1); + self.assertEqual(100,tmp2); + self.assertAlmostEqual(5.67,tmp3,12); + c=b.deepCpy(); + self.assertTrue(c.isEqual(b,1e-12)); + tmp3,tmp1,tmp2=c.getTime(); + self.assertEqual(8,tmp1); + self.assertEqual(100,tmp2); + self.assertAlmostEqual(5.67,tmp3,12); + pass + + def testApplyFuncTwo1(self): + m1=MEDCouplingDataForTest.build3DSurfTargetMesh_1(); + f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME); + f1.setMesh(m1); + # + vals=[1.,11.,21.,2.,12.,22.,3.,13.,23.,4.,14.,24.,5.,15.,25.] + da=DataArrayDouble.New(); + da.setValues(vals,5,3); + f1.setArray(da); + # + self.assertRaises(InterpKernelException,da.applyFunc2,1,"y+z"); + da.setInfoOnComponent(0,"x [m]"); + da.setInfoOnComponent(1,"y [mm]"); + da.setInfoOnComponent(2,"z [km]"); + da2=da.applyFunc2(1,"y+z"); + self.assertEqual(1,da2.getNumberOfComponents()); + self.assertEqual(5,da2.getNumberOfTuples()); + expected1=[32.,34.,36.,38.,40.] + for i in xrange(5): + self.assertAlmostEqual(expected1[i],da2.getIJ(0,i),12); + pass + da2=da.applyFunc(1,"y+z"); + expected2=[12.,14.,16.,18.,20.] + for i in xrange(5): + self.assertAlmostEqual(expected2[i],da2.getIJ(0,i),12); + pass + # + self.assertEqual(3,f1.getNumberOfComponents()); + self.assertEqual(5,f1.getNumberOfTuples()); + f1.applyFunc2(1,"y+z"); + self.assertEqual(1,f1.getNumberOfComponents()); + self.assertEqual(5,f1.getNumberOfTuples()); + for i in xrange(5): + self.assertAlmostEqual(expected1[i],f1.getArray().getIJ(0,i),12); + pass + # + pass + + def testApplyFuncThree1(self): + m1=MEDCouplingDataForTest.build3DSurfTargetMesh_1(); + f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME); + f1.setMesh(m1); + # + vals=[1.,11.,21.,2.,12.,22.,3.,13.,23.,4.,14.,24.,5.,15.,25.] + da=DataArrayDouble.New(); + da.setValues(vals,5,3); + f1.setArray(da); + # + vs=3*[None]; + vs[0]="x"; vs[1]="Y"; vs[2]="z"; + self.assertRaises(InterpKernelException,da.applyFunc3,1,vs,"y+z"); + vs[1]="y"; + da2=da.applyFunc3(1,vs,"y+z"); + expected1=[32.,34.,36.,38.,40.] + for i in xrange(5): + self.assertAlmostEqual(expected1[i],da2.getIJ(0,i),12); + pass + f1.setArray(da); + self.assertEqual(3,f1.getNumberOfComponents()); + self.assertEqual(5,f1.getNumberOfTuples()); + f1.applyFunc3(1,vs,"y+z"); + self.assertEqual(1,f1.getNumberOfComponents()); + self.assertEqual(5,f1.getNumberOfTuples()); + for i in xrange(5): + self.assertAlmostEqual(expected1[i],f1.getArray().getIJ(0,i),12); + pass + pass + + def testFillFromAnalyticTwo1(self): + m1=MEDCouplingDataForTest.build3DSurfTargetMesh_1(); + self.assertRaises(InterpKernelException,m1.fillFromAnalytic2,ON_NODES,1,"y+z"); + m1.getCoords().setInfoOnComponent(0,"x [m]"); + m1.getCoords().setInfoOnComponent(1,"y"); + m1.getCoords().setInfoOnComponent(2,"z"); + f1=m1.fillFromAnalytic2(ON_NODES,1,"y+z"); + self.assertEqual(1,f1.getNumberOfComponents()); + self.assertEqual(9,f1.getNumberOfTuples()); + expected1=[0.2, 0.7, 1.2, 0.7, 1.2, 1.7, 1.2, 1.7, 2.2] + for i in xrange(9): + self.assertAlmostEqual(expected1[i],f1.getArray().getIJ(0,i),12); + pass + pass + + def testFillFromAnalyticThree1(self): + m1=MEDCouplingDataForTest.build3DSurfTargetMesh_1(); + vs=3*[None]; + vs[0]="x"; vs[1]="Y"; vs[2]="z"; + self.assertRaises(InterpKernelException,m1.fillFromAnalytic3,ON_NODES,1,vs,"y+z"); + vs[1]="y"; + f1=m1.fillFromAnalytic3(ON_NODES,1,vs,"y+z"); + self.assertEqual(1,f1.getNumberOfComponents()); + self.assertEqual(9,f1.getNumberOfTuples()); + expected1=[0.2, 0.7, 1.2, 0.7, 1.2, 1.7, 1.2, 1.7, 2.2] + for i in xrange(9): + self.assertAlmostEqual(expected1[i],f1.getArray().getIJ(0,i),12); + pass + pass + + def testDAUnitVar1(self): + da=DataArrayDouble.New(); + da.alloc(1,3); + da.setInfoOnComponent(0,"XPS [m]"); + st1=da.getVarOnComponent(0); + self.assertTrue(st1=="XPS"); + st2=da.getUnitOnComponent(0); + self.assertTrue(st2=="m"); + # + da.setInfoOnComponent(0,"XPS [m]"); + st1=da.getVarOnComponent(0); + self.assertTrue(st1=="XPS"); + st2=da.getUnitOnComponent(0); + self.assertTrue(st2=="m"); + # + da.setInfoOnComponent(0,"XPP [m]"); + st1=da.getVarOnComponent(0); + self.assertTrue(st1=="XPP"); + st2=da.getUnitOnComponent(0); + self.assertTrue(st2=="m"); + # + da.setInfoOnComponent(0,"XPP kdep kefer [ m ]"); + st1=da.getVarOnComponent(0); + self.assertTrue(st1=="XPP kdep kefer"); + st2=da.getUnitOnComponent(0); + self.assertTrue(st2==" m "); + # + da.setInfoOnComponent(0," XPP k[ dep k]efer [ m^ 2/s^3*kJ ]"); + st1=da.getVarOnComponent(0); + self.assertTrue(st1==" XPP k[ dep k]efer"); + st2=da.getUnitOnComponent(0); + self.assertTrue(st2==" m^ 2/s^3*kJ "); + # + da.setInfoOnComponent(0," XPP kefer "); + st1=da.getVarOnComponent(0); + self.assertTrue(st1==" XPP kefer "); + st2=da.getUnitOnComponent(0); + self.assertTrue(st2==""); + # + da.setInfoOnComponent(0,"temperature( bof)"); + st1=da.getVarOnComponent(0); + self.assertTrue(st1=="temperature( bof)"); + st2=da.getUnitOnComponent(0); + self.assertTrue(st2==""); + # + da.setInfoOnComponent(0,"kkk [m]"); + da.setInfoOnComponent(1,"ppp [m^2/kJ]"); + da.setInfoOnComponent(2,"abcde [MW/s]"); + # + vs=da.getVarsOnComponent(); + self.assertEqual(3,len(vs)); + self.assertTrue(vs[0]=="kkk"); + self.assertTrue(vs[1]=="ppp"); + self.assertTrue(vs[2]=="abcde"); + vs=da.getUnitsOnComponent(); + self.assertEqual(3,len(vs)); + self.assertTrue(vs[0]=="m"); + self.assertTrue(vs[1]=="m^2/kJ"); + self.assertTrue(vs[2]=="MW/s"); + pass + + def testGaussCoordinates1(self): + #Testing 1D cell types + m1=MEDCouplingDataForTest.build1DMultiTypes_1(); + f=MEDCouplingFieldDouble.New(ON_GAUSS_PT,ONE_TIME); + f.setMesh(m1); + wg1=[0.3]; + gsCoo1=[0.2]; + refCoo1=[-1.0,1.0]; + f.setGaussLocalizationOnType(NORM_SEG2,refCoo1,gsCoo1,wg1); + wg2=wg1; + gsCoo2=[0.2]; + refCoo2=[-1.0,1.0,0.0]; + f.setGaussLocalizationOnType(NORM_SEG3,refCoo2,gsCoo2,wg2); + # + resToTest=f.getLocalizationOfDiscr(); + self.assertEqual(3,resToTest.getNumberOfComponents()); + self.assertEqual(2,resToTest.getNumberOfTuples()); + expected1=[0.6,0.6,0.6, 0.6,0.6,0.6] + for i in xrange(6): + self.assertAlmostEqual(expected1[i],resToTest.getIJ(0,i),14); + pass + # + #Testing 2D cell types + m2=MEDCouplingDataForTest.build2DMultiTypes_1(); + f=MEDCouplingFieldDouble.New(ON_GAUSS_PT,ONE_TIME); + f.setMesh(m2); + wg3=[0.3,0.3]; + tria3CooGauss=[ 0.1, 0.8, 0.2, 0.7 ] + gsCoo3=tria3CooGauss + tria3CooRef=[ 0.0, 0.0, 1.0 , 0.0, 0.0, 1.0 ] + refCoo3=tria3CooRef; + f.setGaussLocalizationOnType(NORM_TRI3,refCoo3,gsCoo3,wg3); + wg4=[0.3,0.3,0.3]; + tria6CooGauss=[ 0.3, 0.2, 0.2, 0.1, 0.2, 0.4 ] + gsCoo4=tria6CooGauss; + tria6CooRef=[0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.5, 0.0, 0.5, 0.5, 0.0, 0.5] + refCoo4=tria6CooRef; + f.setGaussLocalizationOnType(NORM_TRI6,refCoo4,gsCoo4,wg4); + wg5=[0.3,0.3,0.3,0.3]; + quad4CooGauss=[ 0.3, 0.2, 0.2, 0.1, 0.2, 0.4, 0.15, 0.27 ] + gsCoo5=quad4CooGauss; + quad4CooRef=[-1.0, 1.0, -1.0, -1.0, 1.0, -1.0, 1.0, 1.0] + refCoo5=quad4CooRef; + f.setGaussLocalizationOnType(NORM_QUAD4,refCoo5,gsCoo5,wg5); + wg6=[0.3,0.3,0.3,0.3]; + quad8CooGauss=[ 0.34, 0.16, 0.21, 0.3, 0.23, 0.4, 0.14, 0.37 ] + gsCoo6=quad8CooGauss; + quad8CooRef=[ -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] + refCoo6=quad8CooRef; + f.setGaussLocalizationOnType(NORM_QUAD8,refCoo6,gsCoo6,wg6); + # + resToTest=f.getLocalizationOfDiscr(); + self.assertEqual(3,resToTest.getNumberOfComponents()); + self.assertEqual(13,resToTest.getNumberOfTuples());#2+3+4+4 gauss points for resp TRI3,TRI6,QUAD4,QUAD8 + expected2=[5.1,1.55,0.0, 4.7,1.65,0.0, + 2.32,1.52,0.0, 1.6,1.32,0.0, 3.52,1.26,0.0,#TRI6 + 2.6,1.6,0.0, 2.4,1.8,0.0, 2.4,1.2,0.0, 2.3,1.46,0.0,#QUAD4 + 2.32,2.68,0.0, 2.6,2.42,0.0, 2.8,2.46,0.0, 2.74,2.28,0.0 ];#QUAD8 + for i in xrange(39): + self.assertAlmostEqual(expected2[i],resToTest.getIJ(0,i),14); + pass + # + #Testing 3D cell types + m3=MEDCouplingDataForTest.build3DMultiTypes_1(); + f=MEDCouplingFieldDouble.New(ON_GAUSS_PT,ONE_TIME); + f.setMesh(m3); + # + wg7=[0.3]; + tetra4CooGauss=[0.34, 0.16, 0.21] + gsCoo7=tetra4CooGauss; + tetra4CooRef=[0.0,1.0,0.0, 0.0,0.0,1.0, 0.0,0.0,0.0, 1.0,0.0,0.0] + refCoo7=tetra4CooRef; + f.setGaussLocalizationOnType(NORM_TETRA4,refCoo7,gsCoo7,wg7); + wg8=[0.3]; + tetra10CooGauss=[0.2, 0.3, 0.1] + gsCoo8=tetra10CooGauss; + tetra10CooRef=[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] + refCoo8=tetra10CooRef; + f.setGaussLocalizationOnType(NORM_TETRA10,refCoo8,gsCoo8,wg8); + wg9=[0.3]; + pyra5CooGauss=[0.2, 0.3, 0.1] + gsCoo9=pyra5CooGauss; + pyra5CooRef=[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] + refCoo9=pyra5CooRef; + f.setGaussLocalizationOnType(NORM_PYRA5,refCoo9,gsCoo9,wg9); + wg10=[0.3]; + pyra13CooGauss=[0.1, 0.2, 0.7] + gsCoo10=pyra13CooGauss; + pyra13CooRef=[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] + refCoo10=pyra13CooRef; + f.setGaussLocalizationOnType(NORM_PYRA13,refCoo10,gsCoo10,wg10); + wg11=[0.3]; + penta6CooGauss=[0.2, 0.3, 0.1] + gsCoo11=penta6CooGauss; + penta6CooRef=[-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] + refCoo11=penta6CooRef; + f.setGaussLocalizationOnType(NORM_PENTA6,refCoo11,gsCoo11,wg11); + wg12=[0.3]; + penta15CooGauss=[0.2, 0.3,0.15] + gsCoo12=penta15CooGauss; + penta15CooRef=[-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] + refCoo12=penta15CooRef; + f.setGaussLocalizationOnType(NORM_PENTA15,refCoo12,gsCoo12,wg12); + wg13=[0.3]; + hexa8CooGauss=[0.2,0.3,0.15] + gsCoo13=hexa8CooGauss; + hexa8CooRef=[-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] + refCoo13=hexa8CooRef; + f.setGaussLocalizationOnType(NORM_HEXA8,refCoo13,gsCoo13,wg13); + wg14=[0.3]; + hexa20CooGauss=[0.11,0.3,0.55] + gsCoo14=hexa20CooGauss; + hexa20CooRef=[-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] + refCoo14=hexa20CooRef; + f.setGaussLocalizationOnType(NORM_HEXA20,refCoo14,gsCoo14,wg14); + # + resToTest=f.getLocalizationOfDiscr(); + self.assertEqual(3,resToTest.getNumberOfComponents()); + self.assertEqual(8,resToTest.getNumberOfTuples());#2+3+4+4 gauss points for resp TRI3,TRI6,QUAD4,QUAD8 + expected3=[1.312,3.15,1.02, 0.56,3.3,0.6, 2.18,1.1,0.2, 1.18,1.54,0.98, 1.56,0.3,3.6, 1.613,0.801,4.374, 2.6,2.4,2.3, 2.31232,2.3933985,1.553255] + for i in xrange(24): + self.assertAlmostEqual(expected3[i],resToTest.getIJ(0,i),14); + pass + # + pass + + def testP2Localization1(self): + m=MEDCouplingUMesh.New("testP2",2); + coords=[0.,2.,3.5,0.,4.5,1.5,1.2,0.32,3.4,1.,2.1,2.4] + conn=[0,1,2,3,4,5] + coo=DataArrayDouble.New(); + coo.setValues(coords,6,2); + m.setCoords(coo); + m.allocateCells(1); + m.insertNextCell(NORM_TRI6,6,conn[0:6]) + m.finishInsertingCells(); + # + f=MEDCouplingFieldDouble.New(ON_NODES,ONE_TIME); + f.setMesh(m); + da=DataArrayDouble.New(); + vals1=[1.2,2.3,3.4, 2.2,3.3,4.4, 3.2,4.3,5.4, 4.2,5.3,6.4, 5.2,6.3,7.4, 6.2,7.3,8.4] + da.setValues(vals1,6,3); + f.setArray(da); + # + loc=[2.27,1.3] + locs=f.getValueOnMulti(loc); + expected1=[6.0921164547752236, 7.1921164547752232, 8.2921164547752255] + for i in xrange(3): + self.assertAlmostEqual(expected1[i],locs.getIJ(0,i),12); + pass + pass + + def testP2Localization2(self): + m=MEDCouplingUMesh.New("testP2_2",3); + coords=[0.33312787792955395, -0.35155740179580952, -0.03567564825034563, 1.307146326477638, -0.57234557776250305, -0.08608044208272235, 0.5551834466499993, 0.62324964668794192, -0.014638951108536295, 0.37761817224442129, -0.38324019806913578, 0.96283164472856886, 0.79494856035658679, -0.40628057809270046, 0.0021004190225864614, 1.023740446371799, 0.07665912970471335, -0.072889657161871096, 0.54564584619517376, 0.11132872093429744, 0.039647326652013051, 0.27164784387819052, -0.42018012100866675, 0.46563376500745146, 0.89501965094896418, -0.56148455362735061, 0.43337469695473035, 0.49118025152924394, 0.093884938060727313, 0.47216346905220891] + conn=[0,1,2,3,4,5,6,7,8,9] + coo=DataArrayDouble.New(); + coo.setValues(coords,10,3); + m.setCoords(coo); + m.allocateCells(1); + m.insertNextCell(NORM_TETRA10,10,conn[0:10]) + m.finishInsertingCells(); + # + f=MEDCouplingFieldDouble.New(ON_NODES,ONE_TIME); + f.setMesh(m); + da=DataArrayDouble.New(); + vals1=[1.1,2.1,3.1,4.1,5.2,6.2,7.2,8.2,9.2,10.2] + da.setValues(vals1,10,1); + f.setArray(da); + # + loc=[0.64637931739890486, -0.16185896817550552, 0.22678966365273748] + locs=f.getValueOnMulti(loc); + expected1=[10.0844021968047] + for i in xrange(1): + self.assertAlmostEqual(expected1[i],locs.getIJ(0,i),12); + pass + pass + + def testGetValueOn2(self): + m=MEDCouplingDataForTest.build2DTargetMesh_1(); + f=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME); + f.setMesh(m); + arr=DataArrayDouble.New(); + nbOfCells=m.getNumberOfCells(); + f.setArray(arr); + values1=[7.,107.,10007.,8.,108.,10008.,9.,109.,10009.,10.,110.,10010.,11.,111.,10011.] + arr.setValues(values1,nbOfCells,3); + loc=[-0.05,-0.05, 0.55,-0.25, 0.55,0.15, -0.05,0.45, 0.45,0.45] + f.checkCoherency(); + locs=f.getValueOnMulti(loc); + self.assertEqual(5,locs.getNumberOfTuples()); + self.assertEqual(3,locs.getNumberOfComponents()); + for j in xrange(15): + self.assertAlmostEqual(values1[j],locs.getIJ(0,j),12); + pass + # Testing ON_NODES + f=MEDCouplingFieldDouble.New(ON_NODES,NO_TIME); + f.setMesh(m); + arr=DataArrayDouble.New(); + nbOfNodes=m.getNumberOfNodes(); + f.setArray(arr); + values2=[7.,107.,10007.,8.,108.,10008.,9.,109.,10009.,10.,110.,10010.,11.,111.,10011.,12.,112.,10012.,13.,113.,10013.,14.,114.,10014.,15.,115.,10015.] + arr.setValues(values2,nbOfNodes,3); + loc2=[0.5432,-0.2432, 0.5478,0.1528, 0.5432,-0.2432, 0.5432,-0.2432] + expected2=[9.0272, 109.0272, 10009.0272, 11.4124,111.4124,10011.4124, 9.0272, 109.0272, 10009.0272, 9.0272, 109.0272, 10009.0272] + f.checkCoherency(); + loc3=DataArrayDouble.New() + loc3.setValues(loc2,4,2); + locs=f.getValueOnMulti(loc3); + self.assertEqual(4,locs.getNumberOfTuples()); + self.assertEqual(3,locs.getNumberOfComponents()); + for i in xrange(12): + self.assertAlmostEqual(expected2[i],locs.getIJ(0,i),12); + pass + # + pass + + def testDAIGetIdsNotEqual1(self): + d=DataArrayInt.New(); + vals1=[2,3,5,6,8,5,5,6,1,-5] + d.setValues(vals1,10,1); + d2=d.getIdsNotEqual(5); + self.assertEqual(7,d2.getNumberOfTuples()); + self.assertEqual(1,d2.getNumberOfComponents()); + expected1=[0,1,3,4,7,8,9] + for i in xrange(7): + self.assertEqual(expected1[i],d2.getIJ(0,i)); + pass + d.rearrange(2); + self.assertRaises(InterpKernelException,d.getIdsNotEqual,5); + vals2=[-4,5,6] + vals3=vals2; + d.rearrange(1); + d3=d.getIdsNotEqualList(vals3); + self.assertEqual(5,d3.getNumberOfTuples()); + self.assertEqual(1,d3.getNumberOfComponents()); + expected2=[0,1,4,8,9] + for i in xrange(5): + self.assertEqual(expected2[i],d3.getIJ(0,i)); + pass + pass + + def testDAIComputeOffsets1(self): + d=DataArrayInt.New(); + vals1=[3,5,1,2,0,8] + expected1=[0,3,8,9,11,11] + d.setValues(vals1,6,1); + d.computeOffsets(); + self.assertEqual(6,d.getNumberOfTuples()); + self.assertEqual(1,d.getNumberOfComponents()); + for i in xrange(6): + self.assertEqual(expected1[i],d.getIJ(0,i)); + pass + pass + + def testUMeshHexagonPrism1(self): + coords=[0.8660254037844386, 0.5, 0.0, 0.0, 1.0, 0.0, -0.8660254037844386, 0.5, 0.0, -0.8660254037844386, -0.5, 0.0, 0.0, -1.0, 0.0, 0.8660254037844386, -0.5, 0.0, + 0.8660254037844386, 0.5, 2.0, 0.0, 1.0, 2.0, -0.8660254037844386, 0.5, 2.0, -0.8660254037844386, -0.5, 2.0, 0.0, -1.0, 2.0, 0.8660254037844386, -0.5, 2.0]; + conn=[1,2,3,4,5,0,7,8,9,10,11,6] + mesh=MEDCouplingUMesh.New("MyFirstHexagonalPrism",3); + coo=DataArrayDouble.New(); + coo.setValues(coords,12,3); + mesh.setCoords(coo); + mesh.allocateCells(1); + mesh.insertNextCell(NORM_HEXGP12,12,conn[0:12]) + mesh.finishInsertingCells(); + # + mesh.checkCoherency(); + vols=mesh.getMeasureField(False); + self.assertEqual(1,vols.getNumberOfTuples()); + self.assertEqual(1,vols.getNumberOfComponents()); + self.assertAlmostEqual(-5.196152422706632,vols.getIJ(0,0),12); + bary=mesh.getBarycenterAndOwner(); + self.assertEqual(1,bary.getNumberOfTuples()); + self.assertEqual(3,bary.getNumberOfComponents()); + expected1=[0.,0.,1.] + for i in xrange(3): + self.assertAlmostEqual(expected1[i],bary.getIJ(0,i),12); + pass + d1=DataArrayInt.New(); + d2=DataArrayInt.New(); + d3=DataArrayInt.New(); + d4=DataArrayInt.New(); + m2=mesh.buildDescendingConnectivity(d1,d2,d3,d4); + self.assertEqual(8,m2.getNumberOfCells()); + expected4=[[1,2,3,4,5,0],[7,6,11,10,9,8],[1,7,8,2],[2,8,9,3],[3,9,10,4],[4,10,11,5],[5,11,6,0],[0,6,7,1]]; + expected2=[NORM_POLYGON, NORM_POLYGON, NORM_QUAD4, NORM_QUAD4, NORM_QUAD4, NORM_QUAD4, NORM_QUAD4, NORM_QUAD4]; + expected3=[6,6,4,4,4,4,4,4] + for i in xrange(8): + self.assertTrue(m2.getTypeOfCell(i)==expected2[i]); + v=m2.getNodeIdsOfCell(i); + self.assertTrue(len(v)==expected3[i]); + self.assertEqual(expected4[i],v); + # + mesh.convertAllToPoly(); + self.assertTrue(NORM_POLYHED==mesh.getTypeOfCell(0)); + mesh.unPolyze(); + self.assertTrue(NORM_HEXGP12==mesh.getTypeOfCell(0)); + self.assertEqual(13,mesh.getMeshLength()); + # + pass + + def testDADCheckIsMonotonic(self): + da=DataArrayDouble.New(); + da.setValues([-1.,1.01,2.03,6.],2,2); + self.assertRaises(InterpKernelException,da.isMonotonic,1e-12); + da.rearrange(1); + self.assertTrue(da.isMonotonic(1e-12)); + da.checkMonotonic(1e-12); + da.setIJ(2,0,6.1); + self.assertTrue(not da.isMonotonic(1e-12)); + self.assertRaises(InterpKernelException,da.checkMonotonic,1e-12); + da.setIJ(2,0,5.99); + self.assertTrue(da.isMonotonic(1e-12)); + self.assertTrue(not da.isMonotonic(1e-1)); + pass + + def testCheckCoherencyDeeper1(self): + m=MEDCouplingDataForTest.build3DSourceMesh_1(); + m.checkCoherency(); + m.checkCoherency1(); + m.getNodalConnectivity().setIJ(8,0,-1); + m.checkCoherency(); + self.assertRaises(InterpKernelException,m.checkCoherency1); + m.getNodalConnectivity().setIJ(8,0,-6); + m.checkCoherency(); + self.assertRaises(InterpKernelException,m.checkCoherency1); + m.getNodalConnectivity().setIJ(8,0,9);#9>=NbOfNodes + m.checkCoherency(); + self.assertRaises(InterpKernelException,m.checkCoherency1); + m.getNodalConnectivity().setIJ(8,0,8);#OK + m.checkCoherency(); + m.checkCoherency1(); + elts=[1,5] + m.convertToPolyTypes(elts); + m.checkCoherency(); + m.checkCoherency1(); + m.getNodalConnectivity().setIJ(2,0,9);#9>=NbOfNodes + m.checkCoherency(); + self.assertRaises(InterpKernelException,m.checkCoherency1); + m.getNodalConnectivity().setIJ(2,0,-3); + m.checkCoherency(); + self.assertRaises(InterpKernelException,m.checkCoherency1); + m.getNodalConnectivity().setIJ(2,0,-1); + m.checkCoherency(); + self.assertRaises(InterpKernelException,m.checkCoherency1);#Throw because cell#0 is not a polyhedron + m.getNodalConnectivity().setIJ(2,0,4); + m.checkCoherency(); + m.checkCoherency1(); + m.getNodalConnectivity().setIJ(7,0,-1); + m.checkCoherency(); + m.checkCoherency1();#OK because we are in polyhedron connec + m.getNodalConnectivity().setIJ(36,0,14); + m.checkCoherency(); + self.assertRaises(InterpKernelException,m.checkCoherency1);#Throw beacause now cell 5 is a TETRA4 (14) so mimatch of number index and static type. + pass + + def testUnPolyze2(self): + m=MEDCouplingUMesh.New("jjj",3); + coo=DataArrayDouble.New(); + coo.alloc(4,3); + coo.rearrange(1); + coo.iota(0); + coo.rearrange(3); + m.setCoords(coo); + m.allocateCells(2); + m.insertNextCell(NORM_TETRA4,4,[0,1,2,3]); + m.insertNextCell(NORM_TETRA4,4,[0,1,2,3]); + m.finishInsertingCells(); + m2=MEDCouplingUMesh.MergeUMeshesOnSameCoords(4*[m]); + m2.convertToPolyTypes([2]); + m2.unPolyze(); + self.assertEqual(NORM_TETRA4,m2.getTypeOfCell(2)); + self.assertEqual(40,m2.getMeshLength()); + temp2=m2.getNodeIdsOfCell(2); + self.assertEqual(temp2,[0,1,2,3]); + m2.checkCoherency1(); + m3=m2.deepCpy(); + m2.unPolyze(); + self.assertTrue(m3.isEqual(m2,1e-12)); + pass + + def testDACpyFrom1(self): + d=DataArrayDouble.New(); + d.alloc(12,1); + d.iota(14.); + d.rearrange(3); + d.setName("Toto"); + d.setInfoOnComponent(0,"X [m]"); + d.setInfoOnComponent(1,"Y [m]"); + d.setInfoOnComponent(2,"Z [m]"); + # + d1=DataArrayDouble.New(); + self.assertTrue(not d.isEqual(d1,1e-12)); + d1.cpyFrom(d); + self.assertTrue(d.isEqual(d1,1e-12)); + d1.cpyFrom(d); + self.assertTrue(d.isEqual(d1,1e-12)); + d1.rearrange(2); + self.assertTrue(not d.isEqual(d1,1e-12)); + d1.cpyFrom(d); + self.assertTrue(d.isEqual(d1,1e-12)); + # + d2=d.convertToIntArr(); + d4=DataArrayInt.New(); + self.assertTrue(not d2.isEqual(d4)); + d4.cpyFrom(d2); + self.assertTrue(d2.isEqual(d4)); + d4.cpyFrom(d2); + self.assertTrue(d2.isEqual(d4)); + d4.rearrange(2); + self.assertTrue(not d2.isEqual(d4)); + d4.cpyFrom(d2); + self.assertTrue(d2.isEqual(d4)); + pass + + def testDAITransformWithIndArr1(self): + tab1=[17,18,22,19] + tab2=[0,1,1,3,3,0,1,3,2,2,3,0] + expected=[17,18,18,19,19,17,18,19,22,22,19,17] + d=DataArrayInt.New(); + d.setValues(tab1,4,1); + d1=DataArrayInt.New(); + d1.setValues(tab2,12,1); + d2=d1[:] + # + d1.transformWithIndArr(d); + self.assertEqual(12,d1.getNumberOfTuples()); + self.assertEqual(1,d1.getNumberOfComponents()); + for i in xrange(12): + self.assertEqual(expected[i],d1.getIJ(i,0)); + pass + # + d1=d2 + d1.transformWithIndArr(tab1) + self.assertEqual(12,d1.getNumberOfTuples()); + self.assertEqual(1,d1.getNumberOfComponents()); + for i in xrange(12): + self.assertEqual(expected[i],d1.getIJ(i,0)); + pass + pass + + def testDAIBuildPermArrPerLevel1(self): + arr=[2,0,1,1,0,1,2,0,1,1,0,0] + expected1=[10,0,5,6,1,7,11,2,8,9,3,4] + da=DataArrayInt.New(); + da.setValues(arr,12,1); + da2=da.buildPermArrPerLevel(); + self.assertEqual(12,da2.getNumberOfTuples()); + self.assertEqual(1,da2.getNumberOfComponents()); + for i in xrange(12): + self.assertEqual(expected1[i],da2.getIJ(i,0)); + pass + pass + + def testDAIOperations1(self): + arr1=[-1,-2,4,7,3,2,6,6,4,3,0,1] + da=DataArrayInt.New(); + da.setValues(arr1,4,3); + da1=DataArrayInt.New(); + da1.alloc(12,1); + da1.iota(2); + self.assertRaises(InterpKernelException,DataArrayInt.Add,da,da1);#not same number of tuples/Components + da1.rearrange(3); + da2=DataArrayInt.Add(da,da1); + self.assertEqual(4,da2.getNumberOfTuples()); + self.assertEqual(3,da2.getNumberOfComponents()); + expected1=[1,1,8,12,9,9,14,15,14,14,12,14] + for i in xrange(12): + self.assertEqual(expected1[i],da2.getIJ(0,i)); + pass + da1.substractEqual(da); + expected2=[3,5,0,-2,3,5,2,3,6,8,12,12] + for i in xrange(12): + self.assertEqual(expected2[i],da1.getIJ(0,i)); + pass + da1.rearrange(1); da1.iota(2); da1.rearrange(3); + da1.addEqual(da); + for i in xrange(12): + self.assertEqual(expected1[i],da1.getIJ(0,i)); + pass + da1.rearrange(1); da1.iota(2); da1.rearrange(3); + da2=DataArrayInt.Multiply(da,da1); + self.assertEqual(4,da2.getNumberOfTuples()); + self.assertEqual(3,da2.getNumberOfComponents()); + expected3=[-2,-6,16,35,18,14,48,54,40,33,0,13] + for i in xrange(12): + self.assertEqual(expected3[i],da2.getIJ(0,i)); + pass + da.divideEqual(da1); + self.assertEqual(4,da.getNumberOfTuples()); + self.assertEqual(3,da.getNumberOfComponents()); + expected4=[0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0] + for i in xrange(12): + self.assertEqual(expected4[i],da.getIJ(0,i)); + pass + da.setValues(arr1,4,3); + da1.multiplyEqual(da); + self.assertEqual(4,da1.getNumberOfTuples()); + self.assertEqual(3,da1.getNumberOfComponents()); + for i in xrange(12): + self.assertEqual(expected3[i],da1.getIJ(0,i)); + pass + da1.rearrange(1); da1.iota(2); da1.rearrange(3); + da2=DataArrayInt.Divide(da,da1); + self.assertEqual(4,da2.getNumberOfTuples()); + self.assertEqual(3,da2.getNumberOfComponents()); + for i in xrange(12): + self.assertEqual(expected4[i],da2.getIJ(0,i)); + pass + da1.applyInv(321); + self.assertEqual(4,da1.getNumberOfTuples()); + self.assertEqual(3,da1.getNumberOfComponents()); + expected5=[160,107,80,64,53,45,40,35,32,29,26,24] + for i in xrange(12): + self.assertEqual(expected5[i],da1.getIJ(0,i)); + pass + da1.applyDivideBy(2); + self.assertEqual(4,da1.getNumberOfTuples()); + self.assertEqual(3,da1.getNumberOfComponents()); + expected6=[80,53,40,32,26,22,20,17,16,14,13,12] + for i in xrange(12): + self.assertEqual(expected6[i],da1.getIJ(0,i)); + pass + expected7=[3,4,5,4,5,1,6,3,2,0,6,5] + da1.applyModulus(7); + for i in xrange(12): + self.assertEqual(expected7[i],da1.getIJ(0,i)); + pass + da1.applyLin(1,1); + expected8=[3,3,3,3,3,1,3,3,0,0,3,3] + da1.applyRModulus(3); + for i in xrange(12): + self.assertEqual(expected8[i],da1.getIJ(0,i)); + pass + pass + + def testEmulateMEDMEMBDC1(self): + m,m1=MEDCouplingDataForTest.buildPointe_1(); + m2,da1,da2,da3,da4,da5,da0=m.emulateMEDMEMBDC(m1) + expected0=[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] + expected1=[1,32,29,23,41,36] + self.assertEqual(47,da0.getNumberOfTuples()); + self.assertEqual(1,da0.getNumberOfComponents()); + for i in xrange(47): + self.assertEqual(expected0[i],da0.getIJ(0,i)); + pass + self.assertEqual(6,da5.getNumberOfTuples()); + self.assertEqual(1,da5.getNumberOfComponents()); + for i in xrange(6): + self.assertEqual(expected1[i],da5.getIJ(0,i)); + pass + expected2=[0,1,2,3,4,0,5,6,7,4,8,9,1,7,10,11,12,13,14,5,15,16,17,8,18,19,20,10,21,22,23,2,13,24,25,21,16,26,27,12,19,28,29,15,22,30,31,18,36,26,28,30,24,37,32,33,34,35,38,36,39,40,41,42,37,38,43,44,45,46] + self.assertEqual(70,da1.getNumberOfTuples()); + self.assertEqual(1,da1.getNumberOfComponents()); + for i in xrange(70): + self.assertEqual(expected2[i],da1.getIJ(0,i)); + pass + expected3=[0,4,8,12,16,20,24,28,32,36,40,44,48,53,58,64,70] + self.assertEqual(17,da2.getNumberOfTuples()); + self.assertEqual(1,da2.getNumberOfComponents()); + for i in xrange(17): + self.assertEqual(expected3[i],da2.getIJ(0,i)); + pass + expected4=[0,2,4,6,7,9,11,12,14,16,17,19,20,22,24,25,27,29,30,32,34,35,37,39,40,42,43,45,46,48,49,51,52,53,54,55,56,58,60,62,63,64,65,66,67,68,69,70] + #expected4=[0,2,4,6,7,9,11,12,14,16,17,19,20,22,24,25,27,29,30,32,34,35,37,39,40,42,43,45,46,48,49,51,52,54,56,57,58,59,60,62,63,64,65,66,67,68,69,70]; + self.assertEqual(48,da4.getNumberOfTuples()); + self.assertEqual(1,da4.getNumberOfComponents()); + for i in xrange(48): + self.assertEqual(expected4[i],da4.getIJ(0,i)); + pass + expected5=[0,1,0,3,0,7,0,1,2,1,4,1,2,3,2,5,2,3,6,3,4,9,4,8,4,5,10,5,9,5,6,11,6,10,6,7,8,7,11,7,8,12,8,9,12,9,10,12,10,11,12,11,13,13,13,13,12,14,13,15,14,15,14,14,14,14,15,15,15,15] + self.assertEqual(70,da3.getNumberOfTuples()); + self.assertEqual(1,da3.getNumberOfComponents()); + for i in xrange(70): + self.assertEqual(expected5[i],da3.getIJ(0,i)); + pass + pass + + def testGetLevArrPerCellTypes1(self): + m,m1=MEDCouplingDataForTest.buildPointe_1(); + m1,d0,d1,d2,d3=m.buildDescendingConnectivity(); + order=[NORM_TRI3,NORM_QUAD4]; + da0,da1=m1.getLevArrPerCellTypes(order); + expected0=[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] + expected1=[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] + self.assertEqual(47,da0.getNumberOfTuples()); + self.assertEqual(1,da0.getNumberOfComponents()); + for i in xrange(47): + self.assertEqual(expected0[i],da0.getIJ(0,i)); + pass + self.assertEqual(2,da1.getNumberOfTuples()); + self.assertEqual(1,da1.getNumberOfComponents()); + self.assertEqual(36,da1.getIJ(0,0));#36 TRI3 + self.assertEqual(11,da1.getIJ(1,0));#11 QUAD4 + # + da2=da0.buildPermArrPerLevel(); + # + self.assertEqual(47,da2.getNumberOfTuples()); + self.assertEqual(1,da2.getNumberOfComponents()); + for i in xrange(47): + self.assertEqual(expected1[i],da2.getIJ(0,i)); + pass + pass + + def testSortCellsInMEDFileFrmt1(self): + m,m1=MEDCouplingDataForTest.buildPointe_1(); + m2=m.deepCpy() + da=DataArrayInt.New() + da.setValues([0,1,2,14,3,12,4,5,15,6,7,8,9,10,11,13],16,1) + daa=da.invertArrayN2O2O2N(16) + m.renumberCells(daa,False) + da2=m.sortCellsInMEDFileFrmt() + self.assertEqual(da2.getValues(),[0,1,2,14,3,12,4,5,15,6,7,8,9,10,11,13]) + self.assertTrue(m.isEqual(m2,1e-12)) + self.assertTrue(da.isEqual(da2)) + pass + + def testBuildPartAndReduceNodes1(self): + m=MEDCouplingDataForTest.build2DTargetMesh_1(); + arr=[1,0] + m2,da=m.buildPartAndReduceNodes(arr); + self.assertEqual(5,m2.getNumberOfNodes()); + self.assertEqual(2,m2.getNumberOfCells()); + f=m2.getMeasureField(True); + self.assertAlmostEqual(0.125,f.getArray().getIJ(0,0),12); + self.assertAlmostEqual(0.25,f.getArray().getIJ(1,0),12); + # + arr2=DataArrayInt.New() + arr2.setValues(arr,2,1) + m2,da=m.buildPartAndReduceNodes(arr2); + self.assertEqual(5,m2.getNumberOfNodes()); + self.assertEqual(2,m2.getNumberOfCells()); + f=m2.getMeasureField(True); + self.assertAlmostEqual(0.125,f.getArray().getIJ(0,0),12); + self.assertAlmostEqual(0.25,f.getArray().getIJ(1,0),12); + pass + + def testDAITransformWithIndArrR1(self): + tab1=[2,4,5,3,6,7] + tab2=[-1,-1,0,1,2,3,4,5,-1,-1,-1,-1] + expected=[0,3,1,2,4,5] + d=DataArrayInt.New(); + d.setValues(tab1,6,1); + d1=DataArrayInt.New(); + d1.setValues(tab2,12,1); + d2=d1[:] + # + d3=d.transformWithIndArrR(d1); + self.assertEqual(6,d3.getNumberOfTuples()); + self.assertEqual(1,d3.getNumberOfComponents()); + for i in xrange(6): + self.assertEqual(expected[i],d3.getIJ(i,0)); pass # + d1=d2 + d3=d.transformWithIndArrR(tab2) + self.assertEqual(6,d3.getNumberOfTuples()); + self.assertEqual(1,d3.getNumberOfComponents()); + for i in xrange(6): + self.assertEqual(expected[i],d3.getIJ(i,0)); + pass pass def setUp(self): diff --git a/src/MEDCoupling_Swig/MEDCouplingDataForTest.py b/src/MEDCoupling_Swig/MEDCouplingDataForTest.py index d152e2a4b..8c4c197b2 100644 --- a/src/MEDCoupling_Swig/MEDCouplingDataForTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingDataForTest.py @@ -1,24 +1,24 @@ # -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2010 CEA/DEN, EDF R&D +# Copyright (C) 2007-2011 CEA/DEN, EDF R&D # -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. # -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. # -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -from libMEDCoupling_Swig import * +from MEDCoupling import * class MEDCouplingDataForTest: def build2DTargetMesh_1(cls): @@ -37,6 +37,7 @@ class MEDCouplingDataForTest: myCoords.setValues(targetCoords,9,2); targetMesh.setCoords(myCoords); return targetMesh; + def build2DSourceMesh_1(cls): sourceCoords=[-0.3,-0.3, 0.7,-0.3, -0.3,0.7, 0.7,0.7] sourceConn=[0,3,1,0,2,3] @@ -68,6 +69,32 @@ class MEDCouplingDataForTest: targetMesh.setCoords(myCoords); return targetMesh + def build3DSourceMesh_1(self): + sourceCoords=[ 0.0, 0.0, 200.0, 0.0, 0.0, 0.0, 0.0, 200.0, 200.0, 0.0, 200.0, 0.0, 200.0, 0.0, 200.0, + 200.0, 0.0, 0.0, 200.0, 200.0, 200.0, 200.0, 200.0, 0.0, 100.0, 100.0, 100.0] + sourceConn=[8,1,7,3, 6,0,8,2, 7,4,5,8, 6,8,4,7, 6,8,0,4, 6,8,7,3, 8,1,3,0, 4,1,5,8, 1,7,5,8, 0,3,8,2, 8,1,0,4, 3,6,8,2] + sourceMesh=MEDCouplingUMesh.New(); + sourceMesh.setMeshDimension(3); + sourceMesh.allocateCells(12); + sourceMesh.insertNextCell(NORM_TETRA4,4,sourceConn[0:4]) + sourceMesh.insertNextCell(NORM_TETRA4,4,sourceConn[4:8]) + sourceMesh.insertNextCell(NORM_TETRA4,4,sourceConn[8:12]) + sourceMesh.insertNextCell(NORM_TETRA4,4,sourceConn[12:16]) + sourceMesh.insertNextCell(NORM_TETRA4,4,sourceConn[16:20]) + sourceMesh.insertNextCell(NORM_TETRA4,4,sourceConn[20:24]) + sourceMesh.insertNextCell(NORM_TETRA4,4,sourceConn[24:28]) + sourceMesh.insertNextCell(NORM_TETRA4,4,sourceConn[28:32]) + sourceMesh.insertNextCell(NORM_TETRA4,4,sourceConn[32:36]) + sourceMesh.insertNextCell(NORM_TETRA4,4,sourceConn[36:40]) + sourceMesh.insertNextCell(NORM_TETRA4,4,sourceConn[40:44]) + sourceMesh.insertNextCell(NORM_TETRA4,4,sourceConn[44:48]) + sourceMesh.finishInsertingCells(); + myCoords=DataArrayDouble.New(); + myCoords.setValues(sourceCoords,9,3); + sourceMesh.setCoords(myCoords); + return sourceMesh; + + def build3DSurfTargetMesh_1(self): targetCoords=[-0.3,-0.3,0.5, 0.2,-0.3,1., 0.7,-0.3,1.5, -0.3,0.2,0.5, 0.2,0.2,1., 0.7,0.2,1.5, -0.3,0.7,0.5, 0.2,0.7,1., 0.7,0.7,1.5] targetConn=[0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4] @@ -87,13 +114,13 @@ class MEDCouplingDataForTest: def build3DExtrudedUMesh_1(self): coords=[ - 0.,0.,0., 1.,1.,0., 1.,1.25,0., 0.,1.,0., 1.,1.5,0., 2.,0.,0., 2.,1.,0., 1.,2.,0., 0.,2.,0., 3.,1.,0., + 0.,0.,0., 1.,1.,0., 1.,1.25,0., 1.,0.,0., 1.,1.5,0., 2.,0.,0., 2.,1.,0., 1.,2.,0., 0.,2.,0., 3.,1.,0., 3.,2.,0., 0.,1.,0., 1.,3.,0., 2.,2.,0., 2.,3.,0., - 0.,0.,1., 1.,1.,1., 1.,1.25,1., 0.,1.,1., 1.,1.5,1., 2.,0.,1., 2.,1.,1., 1.,2.,1., 0.,2.,1., 3.,1.,1., + 0.,0.,1., 1.,1.,1., 1.,1.25,1., 1.,0.,1., 1.,1.5,1., 2.,0.,1., 2.,1.,1., 1.,2.,1., 0.,2.,1., 3.,1.,1., 3.,2.,1., 0.,1.,1., 1.,3.,1., 2.,2.,1., 2.,3.,1., - 0.,0.,2., 1.,1.,2., 1.,1.25,2., 0.,1.,2., 1.,1.5,2., 2.,0.,2., 2.,1.,2., 1.,2.,2., 0.,2.,2., 3.,1.,2., + 0.,0.,2., 1.,1.,2., 1.,1.25,2., 1.,0.,2., 1.,1.5,2., 2.,0.,2., 2.,1.,2., 1.,2.,2., 0.,2.,2., 3.,1.,2., 3.,2.,2., 0.,1.,2., 1.,3.,2., 2.,2.,2., 2.,3.,2., - 0.,0.,3., 1.,1.,3., 1.,1.25,3., 0.,1.,3., 1.,1.5,3., 2.,0.,3., 2.,1.,3., 1.,2.,3., 0.,2.,3., 3.,1.,3., + 0.,0.,3., 1.,1.,3., 1.,1.25,3., 1.,0.,3., 1.,1.5,3., 2.,0.,3., 2.,1.,3., 1.,2.,3., 0.,2.,3., 3.,1.,3., 3.,2.,3., 0.,1.,3., 1.,3.,3., 2.,2.,3., 2.,3.,3.] conn=[ @@ -321,9 +348,226 @@ class MEDCouplingDataForTest: targetMesh.setCoords(myCoords); return targetMesh; + def buildMultiFields_1(cls): + m1=MEDCouplingDataForTest.build2DTargetMesh_1(); + m1.setName("m1"); + m2=MEDCouplingDataForTest.build2DTargetMesh_1(); + m2.setName("m2"); + vals0=[-0.7,-1.,-2.,-3.,-4.]; + vals1=[0.,1.,2.,3.,4.,0.1,0.2,0.3,0.4]; + vals1_1=[170.,171.,172.,173.,174.,170.1,170.2,170.3,170.4]; + vals2=[5.,6.,7.,8.,9.]; + vals4=[15.,16.,17.,18.,19.]; + d0=DataArrayDouble.New(); + d0.setValues(vals0,5,1); + d1=DataArrayDouble.New(); + d1.setValues(vals1,9,1); + d1_1=DataArrayDouble.New(); + d1_1.setValues(vals1_1,9,1); + d2=DataArrayDouble.New(); + d2.setValues(vals2,5,1); + d4=DataArrayDouble.New(); + d4.setValues(vals4,5,1); + d0.setName("d0"); d1.setName("d1"); d1_1.setName("d1_1"); d2.setName("d2"); d4.setName("d4"); + d0.setInfoOnComponent(0,"c1"); + d1.setInfoOnComponent(0,"c6"); + d1_1.setInfoOnComponent(0,"c9"); + d2.setInfoOnComponent(0,"c5"); + d4.setInfoOnComponent(0,"c7"); + f0=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME); + f0.setMesh(m1); + f0.setArray(d0); + f0.setTime(0.2,5,6); + f0.setName("f0"); + f1=MEDCouplingFieldDouble.New(ON_NODES,LINEAR_TIME); + f1.setMesh(m1); + f1.setArrays([d1,d1_1]); + f1.setStartTime(0.7,7,8); + f1.setEndTime(1.2,9,10); + f1.setName("f1"); + f2=MEDCouplingFieldDouble.New(ON_CELLS,CONST_ON_TIME_INTERVAL); + f2.setMesh(m2); + f2.setArray(d2); + f2.setTime(1.2,11,12); + f2.setEndTime(1.5,13,14); + f2.setName("f2"); + f3=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME); + f3.setMesh(m1); + f3.setArray(d2); + f3.setTime(1.7,15,16); + f3.setName("f3"); + f4=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME); + f4.setMesh(m2); + f4.setArray(d4); + f4.setName("f4"); + ret=MEDCouplingMultiFields.New([f0,f1,f2,f3,f4]); + return ret; + + def buildMultiFields_2(cls): + m1=MEDCouplingDataForTest.build2DTargetMesh_1(); + m1.setName("m1"); + m2=MEDCouplingDataForTest.build2DTargetMesh_1(); + m2.setName("m2"); + vals0=[-0.7,-1.,-2.,-3.,-4.]; + vals1=[0.,1.,2.,3.,4.]; + vals1_1=[170.,171.,172.,173.,174.]; + vals2=[5.,6.,7.,8.,9.]; + vals4=[15.,16.,17.,18.,19.]; + d0=DataArrayDouble.New(); + d0.setValues(vals0,5,1); + d1=DataArrayDouble.New(); + d1.setValues(vals1,5,1); + d1_1=DataArrayDouble.New(); + d1_1.setValues(vals1_1,5,1); + d2=DataArrayDouble.New(); + d2.setValues(vals2,5,1); + d4=DataArrayDouble.New(); + d4.setValues(vals4,5,1); + d0.setName("d0"); d1.setName("d1"); d1_1.setName("d1_1"); d2.setName("d2"); d4.setName("d4"); + d0.setInfoOnComponent(0,"c1"); + d1.setInfoOnComponent(0,"c6"); + d1_1.setInfoOnComponent(0,"c9"); + d2.setInfoOnComponent(0,"c5"); + d4.setInfoOnComponent(0,"c7"); + f0=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME); + f0.setMesh(m1); + f0.setArray(d0); + f0.setTime(0.2,5,6); + f0.setName("f0"); + f1=MEDCouplingFieldDouble.New(ON_CELLS,LINEAR_TIME); + f1.setMesh(m1); + f1.setArrays([d1,d1_1]); + f1.setStartTime(0.7,7,8); + f1.setEndTime(1.2,9,10); + f1.setName("f1"); + f2=MEDCouplingFieldDouble.New(ON_CELLS,CONST_ON_TIME_INTERVAL); + f2.setMesh(m2); + f2.setArray(d2); + f2.setTime(1.2,11,12); + f2.setEndTime(1.5,13,14); + f2.setName("f2"); + f3=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME); + f3.setMesh(m1); + f3.setArray(d2); + f3.setTime(1.7,15,16); + f3.setName("f3"); + f4=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME); + f4.setMesh(m2); + f4.setArray(d4); + f4.setName("f4"); + return [f0,f1,f2,f3,f4] + + def build1DMultiTypes_1(self): + mesh=MEDCouplingUMesh.New("Multi1DMesh",1); + coo=MEDCouplingDataForTest.buildCoordsForMultiTypes_1(); + conn=[0,2, 0,2,1] + mesh.allocateCells(2); + mesh.insertNextCell(NORM_SEG2,2,conn[0:2]) + mesh.insertNextCell(NORM_SEG3,3,conn[2:5]) + mesh.finishInsertingCells(); + mesh.setCoords(coo); + return mesh; + + def build2DMultiTypes_1(self): + mesh=MEDCouplingUMesh.New("Multi2DMesh",2); + coo=MEDCouplingDataForTest.buildCoordsForMultiTypes_1(); + conn=[3,4,5, 3,4,5,6,7,8, 0,9,10,11, 0,9,10,11,12,13,14,15] + mesh.allocateCells(4); + mesh.insertNextCell(NORM_TRI3,3,conn[0:3]) + mesh.insertNextCell(NORM_TRI6,6,conn[3:9]) + mesh.insertNextCell(NORM_QUAD4,4,conn[9:13]) + mesh.insertNextCell(NORM_QUAD8,8,conn[13:21]) + mesh.finishInsertingCells(); + mesh.setCoords(coo); + return mesh; + + def build3DMultiTypes_1(self): + mesh=MEDCouplingUMesh.New("Multi3DMesh",3); + coo=MEDCouplingDataForTest.buildCoordsForMultiTypes_1(); + conn=[0,16,17,18, + 0,16,17,18,19,20,21,22,23,24, + 0,11,10,9,25, + 0,11,10,9,25,15,14,13,12,26,27,28,29, + 0,30,31,32,33,34, + 0,30,31,32,33,34,35,36,37,38,39,40,41,42,43, + 0,9,10,11,44,45,46,47, + 0,9,10,11,44,45,46,47,12,13,14,15,48,49,50,51,52,53,54,55 ]; + mesh.allocateCells(8); + mesh.insertNextCell(NORM_TETRA4,4,conn[0:4]) + mesh.insertNextCell(NORM_TETRA10,10,conn[4:14]) + mesh.insertNextCell(NORM_PYRA5,5,conn[14:19]) + mesh.insertNextCell(NORM_PYRA13,13,conn[19:32]) + mesh.insertNextCell(NORM_PENTA6,6,conn[32:38]) + mesh.insertNextCell(NORM_PENTA15,15,conn[38:53]) + mesh.insertNextCell(NORM_HEXA8,8,conn[53:61]) + mesh.insertNextCell(NORM_HEXA20,20,conn[61:81]) + mesh.finishInsertingCells(); + mesh.setCoords(coo); + return mesh; + + def buildCoordsForMultiTypes_1(self): + coords=DataArrayDouble.New(); + data=[0.0,0.0,0.0, 0.5,0.5,0.5, 1.0,1.0,1.0, 1.0,1.0,0.0, 2.0,2.5,0.0, 6.0,1.5,0.0, 1.0,2.0,0.0, 4.5,2.5,0.0, 4.0,0.5,0.0, 0.0,4.0,0.0, 4.0,4.0,0.0, 4.0,0.0,0.0, 0.0,2.0,0.0, 2.0,4.0,0.0, 4.0,2.0,0.0, 2.0,0.0,0.0, 0.0,6.0,0.0, 3.0,3.0,0.0, 1.3,3.0,3.0, 0.0,3.0,0.0, 1.5,4.5,0.0, 1.5,1.5,0.0, 0.65,1.5,1.5, 0.65,4.5,1.5, 2.15,3.0,1.5, 2.0,2.0,2.0, 3.0,1.0,1.0, 3.0,3.0,1.0, 1.0,3.0,1.0, 1.0,1.0,1.0, 0.0,3.0,0.0, 2.0,0.0,0.0, 0.0,0.0,6.0, 0.0,3.0,6.0, 3.0,0.0,6.0, 0.0,1.5,0.0, 1.5,1.5,0.0, 1.5,0.0,0.0, 0.0,1.5,6.0, 1.5,1.5,6.0, 1.5,0.0,6.0, 0.0,0.0,3.0, 0.0,3.0,3.0, 3.0,0.0,3.0, 0.0,0.0,4.0, 0.0,4.0,4.0, 4.0,4.0,4.0, 4.0,0.0,4.0, 0.0,2.0,4.0, 2.0,4.0,4.0, 4.0,2.0,4.0, 2.0,0.0,4.0, 0.0,0.0,2.0, 0.0,4.0,2.0, 4.0,4.0,2.0, 4.0,0.0,2.0] + coords.setValues(data,56,3); + coords.setInfoOnComponent(0,"X (cm)"); + coords.setInfoOnComponent(1,"Y (cm)"); + coords.setInfoOnComponent(2,"Z (cm)"); + return coords + + def buildHexa8Mesh_1(self): + mesh=MEDCouplingUMesh.New("Hexa8Only",3); + coo=DataArrayDouble.New(); + coords=[0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.5, 0.5, 0.0, 1.0, 0.5, 0.0, 0.0, 1.0, 0.0, 0.5, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.0, 0.5, 1.0, 0.0, 0.5, 0.0, 0.5, 0.5, 0.5, 0.5, 0.5, 1.0, 0.5, 0.5, 0.0, 1.0, 0.5, 0.5, 1.0, 0.5, 1.0, 1.0, 0.5, 0.0, 0.0, 1.0, 0.5, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.5, 1.0, 0.5, 0.5, 1.0, 1.0, 0.5, 1.0, 0.0, 1.0, 1.0, 0.5, 1.0, 1.0, 1.0, 1.0, 1.0] + coo.setValues(coords,27,3); + conn=[3,12,13,4,0,9,10,1, + 4,13,14,5,1,10,11,2, + 6,15,16,7,3,12,13,4, + 7,16,17,8,4,13,14,5, + 12,21,22,13,9,18,19,10, + 13,22,23,14,10,19,20,11, + 15,24,25,16,12,21,22,13, + 16,25,26,17,13,22,23,14]; + mesh.allocateCells(8); + for i in xrange(8): + mesh.insertNextCell(NORM_HEXA8,8,conn[8*i:8*(i+1)]) + pass + mesh.finishInsertingCells(); + mesh.setCoords(coo); + return mesh; + + def buildPointe_1(self): + mesh=MEDCouplingUMesh.New("Pointe.med",3); + mesh2=MEDCouplingUMesh.New("Pointe.med",2); + coords=[0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 2.0, 0.0, 1.0, 0.0, 2.0, 1.0, -2.0, 0.0, 1.0, 0.0, -2.0, 1.0, 1.0, 1.0, 2.0, -1.0, 1.0, 2.0, -1.0, -1.0, 2.0, 1.0, -1.0, 2.0, 1.0, 1.0, 3.0, -1.0, 1.0, 3.0, -1.0, -1.0, 3.0, 1.0, -1.0, 3.0, 1.0, 1.0, 4.0, -1.0, 1.0, 4.0, -1.0, -1.0, 4.0, 1.0, -1.0, 4.0, 0.0, 0.0, 5.0] + conn=[0,1,2,5,0,1,3,2,0,1,4,3,0,1,5,4,1,6,3,2,1,7,4,3,1,8,5,4,1,9,2,5,1,6,2,9,1,7,3,6,1,8,4,7,1,9,5,8, 6,7,8,9,1,14,17,16,15,18, 10,11,12,13,6,7,8,9,14,15,16,17,10,11,12,13] + coo=DataArrayDouble.New(); + coo.setValues(coords,19,3); + mesh.setCoords(coo); + mesh2.setCoords(coo); + mesh.allocateCells(16); + for i in xrange(12): + mesh.insertNextCell(NORM_TETRA4,4,conn[4*i:4*i+4]) + pass + mesh.insertNextCell(NORM_PYRA5,5,conn[48:53]) + mesh.insertNextCell(NORM_PYRA5,5,conn[53:58]) + mesh.insertNextCell(NORM_HEXA8,8,conn[58:66]) + mesh.insertNextCell(NORM_HEXA8,8,conn[66:74]) + mesh.finishInsertingCells(); + #[1,34,29,23,41,32] + conn2=[0,5,1,14,18,17,8,7,4,9,5,2, 12,8,9,13,6,7,8,9] + mesh2.allocateCells(6); + for i in xrange(4): + mesh2.insertNextCell(NORM_TRI3,3,conn2[3*i:3*i+3]) + pass + mesh2.insertNextCell(NORM_QUAD4,4,conn2[12:16]) + mesh2.insertNextCell(NORM_QUAD4,4,conn2[16:20]) + mesh2.finishInsertingCells(); + return [mesh,mesh2] + build2DTargetMesh_1=classmethod(build2DTargetMesh_1) build2DSourceMesh_1=classmethod(build2DSourceMesh_1) build3DTargetMesh_1=classmethod(build3DTargetMesh_1) + build3DSourceMesh_1=classmethod(build3DSourceMesh_1) build3DSurfTargetMesh_1=classmethod(build3DSurfTargetMesh_1) build3DExtrudedUMesh_1=classmethod(build3DExtrudedUMesh_1) buildCU1DMesh_U=classmethod(buildCU1DMesh_U) @@ -335,4 +579,12 @@ class MEDCouplingDataForTest: build2DCurveTargetMesh_3=classmethod(build2DCurveTargetMesh_3) build2DTargetMesh_3=classmethod(build2DTargetMesh_3) build2DTargetMesh_4=classmethod(build2DTargetMesh_4) + buildMultiFields_1=classmethod(buildMultiFields_1) + buildMultiFields_2=classmethod(buildMultiFields_2) + build1DMultiTypes_1=classmethod(build1DMultiTypes_1) + build2DMultiTypes_1=classmethod(build2DMultiTypes_1) + build3DMultiTypes_1=classmethod(build3DMultiTypes_1) + buildCoordsForMultiTypes_1=classmethod(buildCoordsForMultiTypes_1) + buildHexa8Mesh_1=classmethod(buildHexa8Mesh_1) + buildPointe_1=classmethod(buildPointe_1) pass diff --git a/src/MEDCoupling_Swig/MEDCouplingRemapper.i b/src/MEDCoupling_Swig/MEDCouplingRemapper.i new file mode 100644 index 000000000..b3dc0890b --- /dev/null +++ b/src/MEDCoupling_Swig/MEDCouplingRemapper.i @@ -0,0 +1,42 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +%module MEDCouplingRemapper + +#define MEDCOUPLING_EXPORT +#define INTERPKERNEL_EXPORT +#define MEDCOUPLINGREMAPPER_EXPORT + +%{ +#include "MEDCouplingMemArray.hxx" +#include "MEDCouplingUMesh.hxx" +#include "MEDCouplingField.hxx" +#include "MEDCouplingFieldDouble.hxx" +#include "MEDCouplingRemapper.hxx" + +using namespace ParaMEDMEM; +using namespace INTERP_KERNEL; +%} + +%newobject ParaMEDMEM::MEDCouplingRemapper::transferField; +%newobject ParaMEDMEM::MEDCouplingRemapper::reverseTransferField; + +%include "MEDCoupling.i" +%include "InterpolationOptions.hxx" +%include "MEDCouplingRemapper.hxx" diff --git a/src/MEDCoupling_Swig/MEDCouplingRemapperTest.py b/src/MEDCoupling_Swig/MEDCouplingRemapperTest.py index 4be38ae90..a1561e7b4 100644 --- a/src/MEDCoupling_Swig/MEDCouplingRemapperTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingRemapperTest.py @@ -1,24 +1,24 @@ # -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2010 CEA/DEN, EDF R&D +# Copyright (C) 2007-2011 CEA/DEN, EDF R&D # -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. # -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. # -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -from libMEDCouplingRemapper_Swig import * +from MEDCouplingRemapper import * from math import * import unittest @@ -48,6 +48,38 @@ class MEDCouplingBasicsTest(unittest.TestCase): pass self.failUnless(1==trgfield.getArray().getNumberOfComponents()); pass + + def testPrepareEx1(self): + sourceMesh=self.build2DSourceMesh_1(); + targetMesh=self.build2DTargetMesh_3(); + # + remapper=MEDCouplingRemapper(); + remapper.setPrecision(1e-12); + remapper.setIntersectionType(Triangulation); + srcFt=MEDCouplingFieldTemplate.New(ON_CELLS); + trgFt=MEDCouplingFieldTemplate.New(ON_CELLS); + srcFt.setMesh(sourceMesh); + trgFt.setMesh(targetMesh); + self.assertEqual(1,remapper.prepareEx(srcFt,trgFt)); + srcField=MEDCouplingFieldDouble.New(ON_CELLS); + srcField.setNature(ConservativeVolumic); + srcField.setMesh(sourceMesh); + array=DataArrayDouble.New(); + ptr=sourceMesh.getNumberOfCells()*[None] + for i in xrange(sourceMesh.getNumberOfCells()): + ptr[i]=float(i+7); + pass + array.setValues(ptr,sourceMesh.getNumberOfCells(),1); + srcField.setArray(array); + trgfield=remapper.transferField(srcField,4.220173); + values=trgfield.getArray().getValues(); + valuesExpected=[7.75, 7.0625, 4.220173,8.0] + self.assertEqual(4,trgfield.getArray().getNumberOfTuples()); + self.assertEqual(1,trgfield.getArray().getNumberOfComponents()); + for i0 in xrange(4): + self.assertAlmostEqual(valuesExpected[i0],values[i0],12); + pass + pass def build2DSourceMesh_1(self): sourceCoords=[-0.3,-0.3, 0.7,-0.3, -0.3,0.7, 0.7,0.7] @@ -78,6 +110,22 @@ class MEDCouplingBasicsTest(unittest.TestCase): myCoords.setValues(targetCoords,9,2); targetMesh.setCoords(myCoords); return targetMesh; + + def build2DTargetMesh_3(self): + targetCoords=[-0.6,-0.4, -0.1,-0.4, 1.1,-0.4, 2.1,-0.4, -0.6,0.1, -0.1,0.1, 1.1,0.1, 2.1,0.1, -0.6,1.1, -0.1,1.1] + targetConn=[0,4,5,1, 1,5,6,2, 2,6,7,3, 4,8,9,5] + targetMesh=MEDCouplingUMesh.New(); + targetMesh.setMeshDimension(2); + targetMesh.allocateCells(4); + for i in xrange(4): + targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[4*i:4*(i+1)]) + pass + targetMesh.finishInsertingCells(); + myCoords=DataArrayDouble.New(); + myCoords.setValues(targetCoords,10,2); + targetMesh.setCoords(myCoords); + return targetMesh; + pass def setUp(self): pass diff --git a/src/MEDCoupling_Swig/MEDCouplingTypemaps.i b/src/MEDCoupling_Swig/MEDCouplingTypemaps.i index d1af65ba8..95c008d16 100644 --- a/src/MEDCoupling_Swig/MEDCouplingTypemaps.i +++ b/src/MEDCoupling_Swig/MEDCouplingTypemaps.i @@ -1,27 +1,27 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifdef WITH_NUMPY2 #include #endif -static PyObject* convertMesh(ParaMEDMEM::MEDCouplingMesh* mesh, int owner) +static PyObject* convertMesh(ParaMEDMEM::MEDCouplingMesh* mesh, int owner) throw(INTERP_KERNEL::Exception) { PyObject *ret=0; if(dynamic_cast(mesh)) @@ -32,13 +32,24 @@ static PyObject* convertMesh(ParaMEDMEM::MEDCouplingMesh* mesh, int owner) ret=SWIG_NewPointerObj((void*)mesh,SWIGTYPE_p_ParaMEDMEM__MEDCouplingCMesh,owner); if(!ret) { - PyErr_SetString(PyExc_TypeError,"Not recognized type of mesh on downcast !"); - PyErr_Print(); + const char msg[]="Not recognized type of mesh on downcast !"; + PyErr_SetString(PyExc_TypeError,msg); + throw INTERP_KERNEL::Exception(msg); } return ret; } -static PyObject *convertIntArrToPyList(const int *ptr, int size) +static PyObject* convertMultiFields(ParaMEDMEM::MEDCouplingMultiFields *mfs, int owner) throw(INTERP_KERNEL::Exception) +{ + PyObject *ret=0; + if(dynamic_cast(mfs)) + ret=SWIG_NewPointerObj((void*)mfs,SWIGTYPE_p_ParaMEDMEM__MEDCouplingFieldOverTime,owner); + else + ret=SWIG_NewPointerObj((void*)mfs,SWIGTYPE_p_ParaMEDMEM__MEDCouplingMultiFields,owner); + return ret; +} + +static PyObject *convertIntArrToPyList(const int *ptr, int size) throw(INTERP_KERNEL::Exception) { #ifndef WITH_NUMPY2 PyObject *ret=PyList_New(size); @@ -53,7 +64,7 @@ static PyObject *convertIntArrToPyList(const int *ptr, int size) #endif } -static PyObject *convertIntArrToPyList2(const std::vector& v) +static PyObject *convertIntArrToPyList2(const std::vector& v) throw(INTERP_KERNEL::Exception) { #ifndef WITH_NUMPY2 int size=v.size(); @@ -69,7 +80,17 @@ static PyObject *convertIntArrToPyList2(const std::vector& v) #endif } -static PyObject *convertIntArrToPyListOfTuple(const int *vals, int nbOfComp, int nbOfTuples) +static PyObject *convertIntArrToPyList3(const std::set& v) throw(INTERP_KERNEL::Exception) +{ + int size=v.size(); + PyObject *ret=PyList_New(size); + std::set::const_iterator it=v.begin(); + for(int i=0;i& arr) +static void convertPyToNewIntArr3(PyObject *pyLi, std::vector& arr) throw(INTERP_KERNEL::Exception) { if(PyList_Check(pyLi)) { @@ -146,17 +189,38 @@ static void convertPyToNewIntArr3(PyObject *pyLi, std::vector& arr) } else { - PyErr_SetString(PyExc_TypeError,"list must contain integers only"); - PyErr_Print(); + const char msg[]="list must contain integers only"; + PyErr_SetString(PyExc_TypeError,msg); + throw INTERP_KERNEL::Exception(msg); + } + } + } + else if(PyTuple_Check(pyLi)) + { + int size=PyTuple_Size(pyLi); + arr.resize(size); + for(int i=0;i& arr) } else { - PyErr_SetString(PyExc_TypeError,"convertPyToNewIntArr3 : not a list nor PyArray"); - PyErr_Print(); - return ; + const char msg[]="convertPyToNewIntArr3 : not a list nor PyArray"; + PyErr_SetString(PyExc_TypeError,msg); + throw INTERP_KERNEL::Exception(msg); } #endif } } -static PyObject *convertDblArrToPyList(const double *ptr, int size) +static void fillArrayWithPyListInt(PyObject *pyLi, int *arrToFill, int sizeOfArray, int dftVal) throw(INTERP_KERNEL::Exception) +{ + if(PyList_Check(pyLi)) + { + int size=PyList_Size(pyLi); + for(int i=0;i& v) +static PyObject *convertDblArrToPyList2(const std::vector& v) throw(INTERP_KERNEL::Exception) { int size=v.size(); PyObject *ret=PyList_New(size); @@ -193,7 +314,7 @@ static PyObject *convertDblArrToPyList2(const std::vector& v) return ret; } -static PyObject *convertDblArrToPyListOfTuple(const double *vals, int nbOfComp, int nbOfTuples) +static PyObject *convertDblArrToPyListOfTuple(const double *vals, int nbOfComp, int nbOfTuples) throw(INTERP_KERNEL::Exception) { PyObject *ret=PyList_New(nbOfTuples); for(int i=0;i& v) +void convertPyObjToVecUMeshesCst(PyObject *ms, std::vector& v) throw(INTERP_KERNEL::Exception) { if(PyList_Check(ms)) { @@ -250,22 +474,81 @@ void convertPyObjToVecUMeshes(PyObject *ms, std::vector(argp); + v[i]=arg; + } + } + else + { + const char msg[]="convertPyObjToVecUMeshesCst : not a list"; + PyErr_SetString(PyExc_TypeError,msg); + throw INTERP_KERNEL::Exception(msg); + } +} + +void convertPyObjToVecDataArrayDblCst(PyObject *ms, std::vector& v) throw(INTERP_KERNEL::Exception) +{ + if(PyList_Check(ms)) + { + int size=PyList_Size(ms); + v.resize(size); + for(int i=0;i(argp); + v[i]=arg; + } + } + else + { + const char msg[]="convertPyObjToVecDataArrayDblCst : not a list"; + PyErr_SetString(PyExc_TypeError,msg); + throw INTERP_KERNEL::Exception(msg); + } +} + +void convertPyObjToVecFieldDblCst(PyObject *ms, std::vector& v) throw(INTERP_KERNEL::Exception) +{ + if(PyList_Check(ms)) + { + int size=PyList_Size(ms); + v.resize(size); + for(int i=0;i(argp); + const ParaMEDMEM::MEDCouplingFieldDouble *arg=reinterpret_cast< const ParaMEDMEM::MEDCouplingFieldDouble * >(argp); v[i]=arg; } } else { - PyErr_SetString(PyExc_TypeError,"convertPyObjToVecUMeshes : not a list"); - PyErr_Print(); + const char msg[]="convertPyObjToVecFieldDblCst : not a list"; + PyErr_SetString(PyExc_TypeError,msg); + throw INTERP_KERNEL::Exception(msg); } } -void convertPyObjToVecDataArrayInt(PyObject *ms, std::vector& v) +void convertPyObjToVecDataArrayIntCst(PyObject *ms, std::vector& v) throw(INTERP_KERNEL::Exception) { if(PyList_Check(ms)) { @@ -278,9 +561,9 @@ void convertPyObjToVecDataArrayInt(PyObject *ms, std::vector(argp); v[i]=arg; @@ -288,7 +571,300 @@ void convertPyObjToVecDataArrayInt(PyObject *ms, std::vector cpp int sw=1 + * if python list[int] -> cpp vector sw=2 + * if python tuple[int] -> cpp vector sw=2 + * if python DataArrayInt -> cpp DataArrayInt sw=3 + * + * switch between (int,vector,DataArrayInt) + */ +static void convertObjToPossibleCpp1(PyObject *value, int& sw, int& iTyypp, std::vector& stdvecTyypp, ParaMEDMEM::DataArrayInt *& daIntTyypp) throw(INTERP_KERNEL::Exception) +{ + sw=-1; + if(PyInt_Check(value)) + { + iTyypp=(int)PyInt_AS_LONG(value); + sw=1; + return; + } + if(PyTuple_Check(value)) + { + int size=PyTuple_Size(value); + stdvecTyypp.resize(size); + for(int i=0;i(argp); + sw=3; +} + +/*! + * if python double -> cpp double sw=1 + * if python int -> cpp double sw=1 + * if python list[double] -> cpp vector sw=2 + * if python list[int] -> cpp vector sw=2 + * if python tuple[double] -> cpp vector sw=2 + * if python tuple[int] -> cpp vector sw=2 + * if python DataArrayDouble -> cpp DataArrayDouble sw=3 + * + * switch between (int,vector,DataArrayInt) + */ +static void convertObjToPossibleCpp4(PyObject *value, int& sw, double& iTyypp, std::vector& stdvecTyypp, ParaMEDMEM::DataArrayDouble *& daIntTyypp) throw(INTERP_KERNEL::Exception) +{ + sw=-1; + if(PyFloat_Check(value)) + { + iTyypp=PyFloat_AS_DOUBLE(value); + sw=1; + return; + } + if(PyInt_Check(value)) + { + iTyypp=(double)PyInt_AS_LONG(value); + sw=1; + return; + } + if(PyTuple_Check(value)) + { + int size=PyTuple_Size(value); + stdvecTyypp.resize(size); + for(int i=0;i(argp); + sw=3; +} + +/*! + * if python int -> cpp int sw=1 + * if python list[int] -> cpp vector sw=2 + * if python tuple[int] -> cpp vector sw=2 + * if python slicp -> cpp pair sw=3 + * if python DataArrayInt -> cpp DataArrayInt sw=4 + * + * switch between (int,vector,DataArrayInt) + */ +static void convertObjToPossibleCpp2(PyObject *value, int nbelem, int& sw, int& iTyypp, std::vector& stdvecTyypp, std::pair >& p, ParaMEDMEM::DataArrayInt *& daIntTyypp) throw(INTERP_KERNEL::Exception) +{ + sw=-1; + if(PyInt_Check(value)) + { + iTyypp=(int)PyInt_AS_LONG(value); + sw=1; + return; + } + if(PyTuple_Check(value)) + { + int size=PyTuple_Size(value); + stdvecTyypp.resize(size); + for(int i=0;i(value); + if(PySlice_GetIndices(oC,nbelem,&strt,&stp,&step)!=0) + { + std::ostringstream oss; oss << "Slice in subscriptable object DataArray invalid : number of elemnts is : " << nbelem; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + p.first=strt; + p.second.first=stp; + p.second.second=step; + sw=3; + return ; + } + void *argp; + int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayInt,0|0); + if(!SWIG_IsOK(status)) + throw INTERP_KERNEL::Exception("4 types accepted : integer, tuple of integer, list of integer, slice, DataArrayInt"); + daIntTyypp=reinterpret_cast< ParaMEDMEM::DataArrayInt * >(argp); + sw=4; +} + +/*! + * if value int -> cpp it sw=1 + * if value list[int] -> vt sw=2 + * if value tuple[int] -> vt sw=2 + * if value slice -> pt sw=3 + * if value DataArrayInt -> dt sw=4 + * if value tuple [int,int] -> cpp it,ip sw=5 + * if value tuple [list[int],int] -> cpp vt,ip sw=6 + * if value tuple [tuple[int],int] -> cpp vt,ip sw=6 + * if value tuple [slice,int] -> cpp pt,ip sw=7 + * if value tuple [DaI,int] -> cpp dt,ip sw=8 + * if value tuple [int,list[int]] -> cpp it,vc sw=9 + * if value tuple [list[int],list[int]] -> cpp vt,vc sw=10 + * if value tuple [tuple[int],list[int]] -> cpp vt,vc sw=10 + * if value tuple [slice,list[int]] -> cpp pt,vc sw=11 + * if value tuple [DaI,list[int]] -> cpp dt,vc sw=12 + * if value tuple [int,tuple[int]] -> cpp it,vc sw=9 + * if value tuple [list[int],tuple[int]] -> cpp vt,vc sw=10 + * if value tuple [tuple[int],tuple[int]] -> cpp vt,vc sw=10 + * if value tuple [slice,tuple[int]] -> cpp pt,vc sw=11 + * if value tuple [DaI,tuple[int]] -> cpp dt,vc sw=12 + * if value tuple [int,slice] -> cpp it,pc sw=13 + * if value tuple [list[int],slice] -> cpp vt,pc sw=14 + * if value tuple [tuple[int],slice] -> cpp vt,pc sw=14 + * if value tuple [slice,slice] -> cpp pt,pc sw=15 + * if value tuple [DaI,slice] -> cpp dt,pc sw=16 + * + * switch between (int,vector,DataArrayInt) + */ +static void convertObjToPossibleCpp3(PyObject *value, int nbTuple, int nbCompo, int& sw, int& it, int& ic, std::vector& vt, std::vector& vc, + std::pair >& pt, std::pair >& pc, + ParaMEDMEM::DataArrayInt *&dt, ParaMEDMEM::DataArrayInt *&dc) throw(INTERP_KERNEL::Exception) +{ + if(!PyTuple_Check(value)) + { + convertObjToPossibleCpp2(value,nbTuple,sw,it,vt,pt,dt); + return ; + } + else + { + int sz=PyTuple_Size(value); + if(sz!=2) + throw INTERP_KERNEL::Exception("Unexpected nb of slice element : 1 or 2 expected !\n1st is for tuple selection, 2nd for component selection !"); + PyObject *ob0=PyTuple_GetItem(value,0); + int sw1,sw2; + convertObjToPossibleCpp2(ob0,nbTuple,sw1,it,vt,pt,dt); + PyObject *ob1=PyTuple_GetItem(value,1); + convertObjToPossibleCpp2(ob1,nbCompo,sw2,ic,vc,pc,dc); + sw=4*sw2+sw1; + } +} + +/*! + * if value int -> cpp val sw=1 + * if value double -> cpp val sw=1 + * if value DataArrayDouble -> cpp DataArrayDouble sw=2 + */ +static void convertObjToPossibleCpp5(PyObject *value, int& sw, double& val, ParaMEDMEM::DataArrayDouble *&d) +{ + sw=-1; + if(PyFloat_Check(value)) + { + val=PyFloat_AS_DOUBLE(value); + sw=1; + return; + } + if(PyInt_Check(value)) + { + val=(double)PyInt_AS_LONG(value); + sw=1; + return; } + void *argp; + int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayDouble,0|0); + if(!SWIG_IsOK(status)) + throw INTERP_KERNEL::Exception("3 types accepted : integer, double, DataArrayDouble"); + d=reinterpret_cast< ParaMEDMEM::DataArrayDouble * >(argp); + sw=2; } diff --git a/src/MEDCoupling_Swig/Makefile.am b/src/MEDCoupling_Swig/Makefile.am index fd14551f1..bbb98bfa7 100644 --- a/src/MEDCoupling_Swig/Makefile.am +++ b/src/MEDCoupling_Swig/Makefile.am @@ -1,64 +1,64 @@ -# Copyright (C) 2007-2010 CEA/DEN, EDF R&D +# Copyright (C) 2007-2011 CEA/DEN, EDF R&D # -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. # -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. # -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # # MED MEDCoupling_Swig : binding of C++ implementation and Python # include $(top_srcdir)/adm_local/unix/make_common_starter.am -lib_LTLIBRARIES = _libMEDCoupling_Swig.la _libMEDCouplingRemapper_Swig.la +lib_LTLIBRARIES = _MEDCoupling.la _MEDCouplingRemapper.la salomeinclude_HEADERS = \ - libMEDCoupling_Swig.i libMEDCouplingRemapper_Swig.i MEDCouplingTypemaps.i + MEDCoupling.i MEDCouplingRemapper.i MEDCouplingTypemaps.i -BUILT_SOURCES = libMEDCoupling_SwigWRAP.cxx libMEDCouplingRemapper_SwigWRAP.cxx +BUILT_SOURCES = MEDCouplingWRAP.cxx MEDCouplingRemapperWRAP.cxx SWIG_FLAGS = @SWIG_FLAGS@ -I$(srcdir) -I$(srcdir)/../MEDCoupling -I$(srcdir)/../INTERP_KERNEL/Bases -I$(srcdir)/../INTERP_KERNEL -dist__libMEDCoupling_Swig_la_SOURCES = libMEDCoupling_Swig.i MEDCouplingTypemaps.i -nodist__libMEDCoupling_Swig_la_SOURCES = libMEDCoupling_SwigWRAP.cxx -libMEDCoupling_Swig.py: libMEDCoupling_SwigWRAP.cxx +dist__MEDCoupling_la_SOURCES = MEDCoupling.i MEDCouplingTypemaps.i +nodist__MEDCoupling_la_SOURCES = MEDCouplingWRAP.cxx +MEDCoupling.py: MEDCouplingWRAP.cxx -libMEDCoupling_SwigWRAP.cxx: libMEDCoupling_Swig.i MEDCouplingTypemaps.i +MEDCouplingWRAP.cxx: MEDCoupling.i MEDCouplingTypemaps.i $(SWIG) $(SWIG_FLAGS) -o $@ $< -_libMEDCoupling_Swig_la_CPPFLAGS = $(PYTHON_INCLUDES) \ +_MEDCoupling_la_CPPFLAGS = $(PYTHON_INCLUDES) \ @CXXTMPDPTHFLAGS@ -I$(srcdir)/../MEDCoupling -I$(srcdir)/../INTERP_KERNEL -I$(srcdir)/../INTERP_KERNEL/Bases -_libMEDCoupling_Swig_la_LDFLAGS = -module $(PYTHON_LIBS) \ +_MEDCoupling_la_LDFLAGS = -module $(PYTHON_LIBS) \ ../MEDCoupling/libmedcoupling.la ../INTERP_KERNEL/libinterpkernel.la -dist__libMEDCouplingRemapper_Swig_la_SOURCES = libMEDCouplingRemapper_Swig.i -nodist__libMEDCouplingRemapper_Swig_la_SOURCES = libMEDCouplingRemapper_SwigWRAP.cxx -libMEDCouplingRemapper_Swig.py: libMEDCouplingRemapper_SwigWRAP.cxx +dist__MEDCouplingRemapper_la_SOURCES = MEDCouplingRemapper.i +nodist__MEDCouplingRemapper_la_SOURCES = MEDCouplingRemapperWRAP.cxx +MEDCouplingRemapper.py: MEDCouplingRemapperWRAP.cxx -libMEDCouplingRemapper_SwigWRAP.cxx: libMEDCouplingRemapper_Swig.i MEDCouplingTypemaps.i +MEDCouplingRemapperWRAP.cxx: MEDCouplingRemapper.i MEDCouplingTypemaps.i $(SWIG) $(SWIG_FLAGS) -o $@ $< -_libMEDCouplingRemapper_Swig_la_CPPFLAGS = $(PYTHON_INCLUDES) \ +_MEDCouplingRemapper_la_CPPFLAGS = $(PYTHON_INCLUDES) \ @CXXTMPDPTHFLAGS@ -I$(srcdir)/../MEDCoupling -I$(srcdir)/../INTERP_KERNEL -I$(srcdir)/../INTERP_KERNEL/Bases -_libMEDCouplingRemapper_Swig_la_LDFLAGS = -module $(PYTHON_LIBS) \ +_MEDCouplingRemapper_la_LDFLAGS = -module $(PYTHON_LIBS) \ ../MEDCoupling/libmedcouplingremapper.la ../INTERP_KERNEL/libinterpkernel.la -CLEANFILES = libMEDCoupling_SwigWRAP.cxx libMEDCoupling_Swig.py libMEDCouplingRemapper_SwigWRAP.cxx libMEDCouplingRemapper_Swig.py +CLEANFILES = MEDCouplingWRAP.cxx MEDCoupling.py MEDCouplingRemapperWRAP.cxx MEDCouplingRemapper.py -dist_salomescript_DATA= MEDCouplingBasicsTest.py MEDCouplingRemapperTest.py libMEDCoupling_Swig.py libMEDCouplingRemapper_Swig.py MEDCouplingDataForTest.py +dist_salomescript_DATA= MEDCouplingBasicsTest.py MEDCouplingRemapperTest.py MEDCoupling.py MEDCouplingRemapper.py MEDCouplingDataForTest.py libMEDCoupling_Swig.py UNIT_TEST_PROG = MEDCouplingBasicsTest.py MEDCouplingRemapperTest.py diff --git a/src/MEDCoupling_Swig/libMEDCouplingRemapper_Swig.i b/src/MEDCoupling_Swig/libMEDCouplingRemapper_Swig.i deleted file mode 100644 index b46f81984..000000000 --- a/src/MEDCoupling_Swig/libMEDCouplingRemapper_Swig.i +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -%module libMEDCouplingRemapper_Swig - -#define MEDCOUPLING_EXPORT -#define INTERPKERNEL_EXPORT -#define MEDCOUPLINGREMAPPER_EXPORT - -%{ -#include "MEDCouplingMemArray.hxx" -#include "MEDCouplingUMesh.hxx" -#include "MEDCouplingField.hxx" -#include "MEDCouplingFieldDouble.hxx" -#include "MEDCouplingRemapper.hxx" - -using namespace ParaMEDMEM; -using namespace INTERP_KERNEL; -%} - -%newobject ParaMEDMEM::MEDCouplingRemapper::transferField; -%newobject ParaMEDMEM::MEDCouplingRemapper::reverseTransferField; - -%include "libMEDCoupling_Swig.i" -%include "InterpolationOptions.hxx" -%include "MEDCouplingRemapper.hxx" diff --git a/src/MEDCoupling_Swig/libMEDCoupling_Swig.i b/src/MEDCoupling_Swig/libMEDCoupling_Swig.i deleted file mode 100644 index d6b35f447..000000000 --- a/src/MEDCoupling_Swig/libMEDCoupling_Swig.i +++ /dev/null @@ -1,1430 +0,0 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -%module libMEDCoupling_Swig - -#define MEDCOUPLING_EXPORT - -%include std_vector.i -%include std_string.i - -%{ -#include "MEDCouplingMemArray.hxx" -#include "MEDCouplingUMesh.hxx" -#include "MEDCouplingExtrudedMesh.hxx" -#include "MEDCouplingCMesh.hxx" -#include "MEDCouplingField.hxx" -#include "MEDCouplingFieldDouble.hxx" -#include "MEDCouplingGaussLocalization.hxx" -#include "MEDCouplingTypemaps.i" - -using namespace ParaMEDMEM; -using namespace INTERP_KERNEL; -%} - -%template(ivec) std::vector; -%template(dvec) std::vector; -%template(svec) std::vector; - -%typemap(out) ParaMEDMEM::MEDCouplingMesh* -{ - $result=convertMesh($1,$owner); -} - -%typemap(out) ParaMEDMEM::MEDCouplingPointSet* -{ - $result=convertMesh($1,$owner); -} - -#ifdef WITH_NUMPY2 -%init %{ import_array(); %} -#endif - -%feature("autodoc", "1"); -%feature("docstring"); - -%newobject ParaMEDMEM::DataArrayDouble::New; -%newobject ParaMEDMEM::DataArrayInt::New; -%newobject ParaMEDMEM::DataArrayDouble::convertToIntArr; -%newobject ParaMEDMEM::DataArrayInt::convertToDblArr; -%newobject ParaMEDMEM::MEDCouplingUMesh::New; -%newobject ParaMEDMEM::MEDCouplingField::buildMeasureField; -%newobject ParaMEDMEM::MEDCouplingFieldDouble::New; -%newobject ParaMEDMEM::MEDCouplingFieldDouble::mergeFields; -%newobject ParaMEDMEM::MEDCouplingFieldDouble::doublyContractedProduct; -%newobject ParaMEDMEM::MEDCouplingFieldDouble::determinant; -%newobject ParaMEDMEM::MEDCouplingFieldDouble::eigenValues; -%newobject ParaMEDMEM::MEDCouplingFieldDouble::eigenVectors; -%newobject ParaMEDMEM::MEDCouplingFieldDouble::inverse; -%newobject ParaMEDMEM::MEDCouplingFieldDouble::trace; -%newobject ParaMEDMEM::MEDCouplingFieldDouble::deviator; -%newobject ParaMEDMEM::MEDCouplingFieldDouble::magnitude; -%newobject ParaMEDMEM::MEDCouplingFieldDouble::maxPerTuple; -%newobject ParaMEDMEM::MEDCouplingFieldDouble::keepSelectedComponents; -%newobject ParaMEDMEM::MEDCouplingFieldDouble::dotFields; -%newobject ParaMEDMEM::MEDCouplingFieldDouble::dot; -%newobject ParaMEDMEM::MEDCouplingFieldDouble::crossProductFields; -%newobject ParaMEDMEM::MEDCouplingFieldDouble::crossProduct; -%newobject ParaMEDMEM::MEDCouplingFieldDouble::maxFields; -%newobject ParaMEDMEM::MEDCouplingFieldDouble::max; -%newobject ParaMEDMEM::MEDCouplingFieldDouble::minFields; -%newobject ParaMEDMEM::MEDCouplingFieldDouble::min; -%newobject ParaMEDMEM::MEDCouplingFieldDouble::getIdsInRange; -%newobject ParaMEDMEM::MEDCouplingFieldDouble::buildSubPart; -%newobject ParaMEDMEM::MEDCouplingFieldDouble::operator+; -%newobject ParaMEDMEM::MEDCouplingFieldDouble::operator-; -%newobject ParaMEDMEM::MEDCouplingFieldDouble::operator*; -%newobject ParaMEDMEM::MEDCouplingFieldDouble::operator/; -%newobject ParaMEDMEM::MEDCouplingUMesh::clone; -%newobject ParaMEDMEM::DataArrayDouble::deepCopy; -%newobject ParaMEDMEM::DataArrayDouble::performCpy; -%newobject ParaMEDMEM::DataArrayInt::deepCopy; -%newobject ParaMEDMEM::DataArrayInt::performCpy; -%newobject ParaMEDMEM::DataArrayInt::substr; -%newobject ParaMEDMEM::DataArrayInt::changeNbOfComponents; -%newobject ParaMEDMEM::DataArrayInt::keepSelectedComponents; -%newobject ParaMEDMEM::DataArrayInt::selectByTupleId; -%newobject ParaMEDMEM::DataArrayInt::renumber; -%newobject ParaMEDMEM::DataArrayInt::renumberR; -%newobject ParaMEDMEM::DataArrayInt::renumberAndReduce; -%newobject ParaMEDMEM::DataArrayInt::invertArrayO2N2N2O; -%newobject ParaMEDMEM::DataArrayInt::invertArrayN2O2O2N; -%newobject ParaMEDMEM::DataArrayDouble::aggregate; -%newobject ParaMEDMEM::DataArrayDouble::dot; -%newobject ParaMEDMEM::DataArrayDouble::crossProduct; -%newobject ParaMEDMEM::DataArrayDouble::add; -%newobject ParaMEDMEM::DataArrayDouble::substract; -%newobject ParaMEDMEM::DataArrayDouble::multiply; -%newobject ParaMEDMEM::DataArrayDouble::divide; -%newobject ParaMEDMEM::DataArrayDouble::substr; -%newobject ParaMEDMEM::DataArrayDouble::changeNbOfComponents; -%newobject ParaMEDMEM::DataArrayDouble::keepSelectedComponents; -%newobject ParaMEDMEM::DataArrayDouble::getIdsInRange; -%newobject ParaMEDMEM::DataArrayDouble::selectByTupleId; -%newobject ParaMEDMEM::DataArrayDouble::applyFunc; -%newobject ParaMEDMEM::DataArrayDouble::doublyContractedProduct; -%newobject ParaMEDMEM::DataArrayDouble::determinant; -%newobject ParaMEDMEM::DataArrayDouble::eigenValues; -%newobject ParaMEDMEM::DataArrayDouble::eigenVectors; -%newobject ParaMEDMEM::DataArrayDouble::inverse; -%newobject ParaMEDMEM::DataArrayDouble::trace; -%newobject ParaMEDMEM::DataArrayDouble::deviator; -%newobject ParaMEDMEM::DataArrayDouble::magnitude; -%newobject ParaMEDMEM::DataArrayDouble::maxPerTuple; -%newobject ParaMEDMEM::DataArrayDouble::renumber; -%newobject ParaMEDMEM::DataArrayDouble::renumberR; -%newobject ParaMEDMEM::DataArrayDouble::renumberAndReduce; -%newobject ParaMEDMEM::MEDCouplingFieldDouble::clone; -%newobject ParaMEDMEM::MEDCouplingFieldDouble::cloneWithMesh; -%newobject ParaMEDMEM::MEDCouplingFieldDouble::buildNewTimeReprFromThis; -%newobject ParaMEDMEM::MEDCouplingMesh::getCoordinatesAndOwner; -%newobject ParaMEDMEM::MEDCouplingMesh::getBarycenterAndOwner; -%newobject ParaMEDMEM::MEDCouplingMesh::buildOrthogonalField; -%newobject ParaMEDMEM::MEDCouplingMesh::getCellIdsFullyIncludedInNodeIds; -%newobject ParaMEDMEM::MEDCouplingMesh::buildPart; -%newobject ParaMEDMEM::MEDCouplingMesh::mergeMyselfWith; -%newobject ParaMEDMEM::MEDCouplingMesh::fillFromAnalytic; -%newobject ParaMEDMEM::MEDCouplingPointSet::zipCoordsTraducer; -%newobject ParaMEDMEM::MEDCouplingUMesh::zipConnectivityTraducer; -%newobject ParaMEDMEM::MEDCouplingUMesh::buildDescendingConnectivity; -%newobject ParaMEDMEM::MEDCouplingPointSet::buildBoundaryMesh; -%newobject ParaMEDMEM::MEDCouplingMesh::getMeasureField; -%newobject ParaMEDMEM::MEDCouplingUMesh::buildExtrudedMeshFromThis; -%newobject ParaMEDMEM::MEDCouplingUMesh::mergeUMeshes; -%newobject ParaMEDMEM::MEDCouplingUMesh::buildNewNumberingFromCommNodesFrmt; -%newobject ParaMEDMEM::MEDCouplingUMesh::rearrange2ConsecutiveCellTypes; -%newobject ParaMEDMEM::MEDCouplingUMesh::convertCellArrayPerGeoType; -%newobject ParaMEDMEM::MEDCouplingUMesh::getRenumArrForConsecutiveCellTypesSpec; -%newobject ParaMEDMEM::MEDCouplingUMesh::buildDirectionVectorField; -%newobject ParaMEDMEM::MEDCouplingUMesh::getEdgeRatioField; -%newobject ParaMEDMEM::MEDCouplingUMesh::getAspectRatioField; -%newobject ParaMEDMEM::MEDCouplingUMesh::getWarpField; -%newobject ParaMEDMEM::MEDCouplingUMesh::getSkewField; -%newobject ParaMEDMEM::MEDCouplingExtrudedMesh::New; -%newobject ParaMEDMEM::MEDCouplingExtrudedMesh::build3DUnstructuredMesh; -%newobject ParaMEDMEM::MEDCouplingCMesh::New; -%newobject ParaMEDMEM::MEDCouplingCMesh::buildUnstructured; -%feature("unref") DataArrayDouble "$this->decrRef();" -%feature("unref") MEDCouplingPointSet "$this->decrRef();" -%feature("unref") MEDCouplingMesh "$this->decrRef();" -%feature("unref") MEDCouplingUMesh "$this->decrRef();" -%feature("unref") MEDCouplingExtrudedMesh "$this->decrRef();" -%feature("unref") MEDCouplingCMesh "$this->decrRef();" -%feature("unref") DataArrayInt "$this->decrRef();" -%feature("unref") MEDCouplingField "$this->decrRef();" -%feature("unref") MEDCouplingFieldDouble "$this->decrRef();" - -%rename(assign) *::operator=; -%ignore ParaMEDMEM::MemArray::operator=; -%ignore ParaMEDMEM::MemArray::operator[]; -%ignore ParaMEDMEM::MEDCouplingPointSet::getCoords(); -%ignore ParaMEDMEM::MEDCouplingGaussLocalization::pushTinySerializationIntInfo; -%ignore ParaMEDMEM::MEDCouplingGaussLocalization::pushTinySerializationDblInfo; -%ignore ParaMEDMEM::MEDCouplingGaussLocalization::fillWithValues; -%ignore ParaMEDMEM::MEDCouplingGaussLocalization::buildNewInstanceFromTinyInfo; - -%rename (Exception) InterpKernelException; -%nodefaultctor; - -namespace INTERP_KERNEL -{ - class Exception - { - public: - Exception(const char* what); - ~Exception() throw (); - const char *what() const throw (); - }; -} - -%include "MEDCouplingTimeLabel.hxx" -%include "MEDCouplingRefCountObject.hxx" - -namespace ParaMEDMEM -{ - typedef enum - { - UNSTRUCTURED = 5, - UNSTRUCTURED_DESC = 6, - CARTESIAN = 7, - EXTRUDED = 8 - } MEDCouplingMeshType; - - class DataArrayInt; - class DataArrayDouble; - class MEDCouplingFieldDouble; - - class MEDCouplingMesh : public RefCountObject, public TimeLabel - { - public: - void setName(const char *name) { _name=name; } - const char *getName() const { return _name.c_str(); } - virtual MEDCouplingMeshType getType() const = 0; - bool isStructured() const; - virtual bool isEqual(const MEDCouplingMesh *other, double prec) const; - virtual bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const = 0; - virtual void copyTinyStringsFrom(const MEDCouplingMesh *other) throw(INTERP_KERNEL::Exception); - virtual void checkCoherency() const throw(INTERP_KERNEL::Exception) = 0; - virtual int getNumberOfCells() const throw(INTERP_KERNEL::Exception) = 0; - virtual int getNumberOfNodes() const throw(INTERP_KERNEL::Exception) = 0; - virtual int getSpaceDimension() const throw(INTERP_KERNEL::Exception) = 0; - virtual int getMeshDimension() const throw(INTERP_KERNEL::Exception) = 0; - virtual DataArrayDouble *getCoordinatesAndOwner() const = 0; - virtual DataArrayDouble *getBarycenterAndOwner() const = 0; - virtual INTERP_KERNEL::NormalizedCellType getTypeOfCell(int cellId) const = 0; - virtual std::string simpleRepr() const = 0; - virtual std::string advancedRepr() const = 0; - // tools - virtual void getBoundingBox(double *bbox) const = 0; - virtual MEDCouplingFieldDouble *getMeasureField(bool isAbs) const = 0; - virtual MEDCouplingFieldDouble *getMeasureFieldOnNode(bool isAbs) const = 0; - virtual MEDCouplingFieldDouble *fillFromAnalytic(TypeOfField t, int nbOfComp, const char *func) const throw(INTERP_KERNEL::Exception); - virtual MEDCouplingFieldDouble *buildOrthogonalField() const = 0; - virtual void rotate(const double *center, const double *vector, double angle) = 0; - virtual void translate(const double *vector) = 0; - virtual MEDCouplingMesh *buildPart(const int *start, const int *end) const = 0; - virtual MEDCouplingMesh *mergeMyselfWith(const MEDCouplingMesh *other) const throw(INTERP_KERNEL::Exception) = 0; - virtual bool areCompatibleForMerge(const MEDCouplingMesh *other) const; - static MEDCouplingMesh *mergeMeshes(const MEDCouplingMesh *mesh1, const MEDCouplingMesh *mesh2); - %extend - { - std::string __str__() const - { - return self->simpleRepr(); - } - - int getCellContainingPoint(PyObject *p, double eps) const - { - int sz; - double *pos=convertPyToNewDblArr2(p,&sz); - int ret=self->getCellContainingPoint(pos,eps); - delete [] pos; - return ret; - } - - void renumberCells(PyObject *li, bool check) throw(INTERP_KERNEL::Exception) - { - int size; - int *tmp=convertPyToNewIntArr2(li,&size); - self->renumberCells(tmp,check); - delete [] tmp; - } - - PyObject *checkGeoEquivalWith(const MEDCouplingMesh *other, int levOfCheck, double prec) const throw(INTERP_KERNEL::Exception) - { - DataArrayInt *cellCor, *nodeCor; - self->checkGeoEquivalWith(other,levOfCheck,prec,cellCor,nodeCor); - PyObject *res = PyList_New(2); - PyList_SetItem(res,0,SWIG_NewPointerObj(SWIG_as_voidptr(cellCor),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, cellCor?SWIG_POINTER_OWN | 0:0 )); - PyList_SetItem(res,1,SWIG_NewPointerObj(SWIG_as_voidptr(nodeCor),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, nodeCor?SWIG_POINTER_OWN | 0:0 )); - return res; - } - DataArrayInt *getCellIdsFullyIncludedInNodeIds(PyObject *li) const - { - int size; - int *tmp=convertPyToNewIntArr2(li,&size); - DataArrayInt *ret=self->getCellIdsFullyIncludedInNodeIds(tmp,tmp+size); - delete [] tmp; - return ret; - } - PyObject *getNodeIdsOfCell(int cellId) const - { - std::vector conn; - self->getNodeIdsOfCell(cellId,conn); - return convertIntArrToPyList2(conn); - } - - PyObject *getCoordinatesOfNode(int nodeId) const - { - std::vector coo; - self->getCoordinatesOfNode(nodeId,coo); - return convertDblArrToPyList2(coo); - } - - void scale(PyObject *point, double factor) - { - int sz; - double *p=convertPyToNewDblArr2(point,&sz); - self->scale(p,factor); - delete [] p; - } - } - }; -} - -%include "MEDCouplingMemArray.hxx" -%include "NormalizedUnstructuredMesh.hxx" -%include "MEDCouplingNatureOfField.hxx" -%include "MEDCouplingTimeDiscretization.hxx" -%include "MEDCouplingGaussLocalization.hxx" - -namespace ParaMEDMEM -{ - class MEDCouplingPointSet : public ParaMEDMEM::MEDCouplingMesh - { - public: - void updateTime(); - void setCoords(DataArrayDouble *coords); - DataArrayDouble *getCoordinatesAndOwner() const; - bool areCoordsEqual(const MEDCouplingPointSet& other, double prec) const; - void getBoundingBox(double *bbox) const; - void zipCoords(); - double getCaracteristicDimension() const; - void translate(const double *vector); - void changeSpaceDimension(int newSpaceDim, double dftVal=0.) throw(INTERP_KERNEL::Exception); - void tryToShareSameCoords(const MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception); - virtual void tryToShareSameCoordsPermute(const MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception) = 0; - static DataArrayDouble *mergeNodesArray(const MEDCouplingPointSet *m1, const MEDCouplingPointSet *m2); - static MEDCouplingPointSet *buildInstanceFromMeshType(MEDCouplingMeshType type); - virtual MEDCouplingPointSet *buildPartOfMySelf(const int *start, const int *end, bool keepCoords) const = 0; - virtual MEDCouplingPointSet *buildPartOfMySelfNode(const int *start, const int *end, bool fullyIn) const = 0; - virtual MEDCouplingPointSet *buildFacePartOfMySelfNode(const int *start, const int *end, bool fullyIn) const = 0; - virtual MEDCouplingPointSet *buildBoundaryMesh(bool keepCoords) const = 0; - virtual void renumberNodes(const int *newNodeNumbers, int newNbOfNodes); - virtual bool isEmptyMesh(const std::vector& tinyInfo) const = 0; - //! size of returned tinyInfo must be always the same. - void getTinySerializationInformation(std::vector& tinyInfo, std::vector& littleStrings) const; - void resizeForUnserialization(const std::vector& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector& littleStrings) const; - void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const; - void unserialization(const std::vector& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, - const std::vector& littleStrings); - virtual void giveElemsInBoundingBox(const double *bbox, double eps, std::vector& elems) = 0; - virtual void giveElemsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bbox, double eps, std::vector& elems) = 0; - virtual DataArrayInt *zipCoordsTraducer() = 0; - %extend - { - std::string __str__() const - { - return self->simpleRepr(); - } - - PyObject *buildNewNumberingFromCommonNodesFormat(const DataArrayInt *comm, const DataArrayInt *commIndex) const - { - int newNbOfNodes; - DataArrayInt *ret0=self->buildNewNumberingFromCommonNodesFormat(comm,commIndex,newNbOfNodes); - PyObject *res = PyList_New(2); - PyList_SetItem(res,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); - PyList_SetItem(res,1,SWIG_From_int(newNbOfNodes)); - return res; - } - - PyObject *findCommonNodes(int limitNodeId, double prec) const - { - DataArrayInt *comm, *commIndex; - self->findCommonNodes(limitNodeId,prec,comm,commIndex); - PyObject *res = PyList_New(2); - PyList_SetItem(res,0,SWIG_NewPointerObj(SWIG_as_voidptr(comm),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); - PyList_SetItem(res,1,SWIG_NewPointerObj(SWIG_as_voidptr(commIndex),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); - return res; - } - - PyObject *getCoords() const - { - DataArrayDouble *ret1=self->getCoords(); - ret1->incrRef(); - return SWIG_NewPointerObj((void*)ret1,SWIGTYPE_p_ParaMEDMEM__DataArrayDouble,SWIG_POINTER_OWN | 0); - } - PyObject *buildPartOfMySelf(PyObject *li, bool keepCoords) const - { - int size; - int *tmp=convertPyToNewIntArr2(li,&size); - MEDCouplingPointSet *ret=self->buildPartOfMySelf(tmp,tmp+size,keepCoords); - delete [] tmp; - return convertMesh(ret, SWIG_POINTER_OWN | 0 ); - } - PyObject *buildPartOfMySelfNode(PyObject *li, bool fullyIn) const - { - int size; - int *tmp=convertPyToNewIntArr2(li,&size); - MEDCouplingPointSet *ret=self->buildPartOfMySelfNode(tmp,tmp+size,fullyIn); - delete [] tmp; - return convertMesh(ret, SWIG_POINTER_OWN | 0 ); - } - PyObject *buildFacePartOfMySelfNode(PyObject *li, bool fullyIn) const - { - int size; - int *tmp=convertPyToNewIntArr2(li,&size); - MEDCouplingPointSet *ret=self->buildFacePartOfMySelfNode(tmp,tmp+size,fullyIn); - delete [] tmp; - return convertMesh(ret, SWIG_POINTER_OWN | 0 ); - } - PyObject *findBoundaryNodes() const - { - std::vector nodes; - self->findBoundaryNodes(nodes); - return convertIntArrToPyList2(nodes); - } - void rotate(PyObject *center, PyObject *vector, double alpha) - { - int sz; - double *c=convertPyToNewDblArr2(center,&sz); - if(!c) - return ; - double *v=convertPyToNewDblArr2(vector,&sz); - if(!v) - { delete [] c; return ; } - self->rotate(c,v,alpha); - delete [] c; - delete [] v; - } - void translate(PyObject *vector) - { - int sz; - double *v=convertPyToNewDblArr2(vector,&sz); - self->translate(v); - delete [] v; - } - void renumberNodes(PyObject *li, int newNbOfNodes) - { - int size; - int *tmp=convertPyToNewIntArr2(li,&size); - self->renumberNodes(tmp,newNbOfNodes); - delete [] tmp; - } - PyObject *findNodesOnPlane(PyObject *pt, PyObject *vec, double eps) const throw(INTERP_KERNEL::Exception) - { - std::vector nodes; - int sz; - double *p=convertPyToNewDblArr2(pt,&sz); - double *v=convertPyToNewDblArr2(vec,&sz); - self->findNodesOnPlane(p,v,eps,nodes); - delete [] v; - delete [] p; - return convertIntArrToPyList2(nodes); - } - static void rotate2DAlg(PyObject *center, double angle, int nbNodes, PyObject *coords) - { - int sz; - double *c=convertPyToNewDblArr2(center,&sz); - double *coo=convertPyToNewDblArr2(coords,&sz); - ParaMEDMEM::MEDCouplingPointSet::rotate2DAlg(c,angle,nbNodes,coo); - for(int i=0;isimpleRepr(); - } - void insertNextCell(INTERP_KERNEL::NormalizedCellType type, int size, PyObject *li) - { - int sz; - int *tmp=convertPyToNewIntArr2(li,&sz); - self->insertNextCell(type,size,tmp); - delete [] tmp; - } - PyObject *getAllTypes() const - { - std::set result=self->getAllTypes(); - std::set::const_iterator iL=result.begin(); - PyObject *res = PyList_New(result.size()); - for (int i=0;iL!=result.end(); i++, iL++) - PyList_SetItem(res,i,PyInt_FromLong(*iL)); - return res; - } - PyObject *mergeNodes(double precision) - { - bool ret1; - int ret2; - DataArrayInt *ret0=self->mergeNodes(precision,ret1,ret2); - PyObject *res = PyList_New(3); - PyList_SetItem(res,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); - PyList_SetItem(res,1,SWIG_From_bool(ret1)); - PyList_SetItem(res,2,SWIG_From_int(ret2)); - return res; - } - PyObject *checkButterflyCells() - { - std::vector cells; - self->checkButterflyCells(cells); - return convertIntArrToPyList2(cells); - } - - PyObject *splitByType() const - { - std::vector ms=self->splitByType(); - int sz=ms.size(); - PyObject *ret = PyList_New(sz); - for(int i=0;i idsPerGeoType; - convertPyToNewIntArr3(ids,idsPerGeoType); - MEDCouplingUMesh *ret=self->keepSpecifiedCells(type,idsPerGeoType); - return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh, SWIG_POINTER_OWN | 0 ); - } - - bool checkConsecutiveCellTypesAndOrder(PyObject *li) const - { - int sz; - INTERP_KERNEL::NormalizedCellType *order=(INTERP_KERNEL::NormalizedCellType *)convertPyToNewIntArr2(li,&sz); - bool ret=self->checkConsecutiveCellTypesAndOrder(order,order+sz); - delete [] order; - return ret; - } - - DataArrayInt *getRenumArrForConsecutiveCellTypesSpec(PyObject *li) const - { - int sz; - INTERP_KERNEL::NormalizedCellType *order=(INTERP_KERNEL::NormalizedCellType *)convertPyToNewIntArr2(li,&sz); - DataArrayInt *ret=self->getRenumArrForConsecutiveCellTypesSpec(order,order+sz); - delete [] order; - return ret; - } - - PyObject *getCellsContainingPoints(PyObject *p, int nbOfPoints, double eps) const - { - int sz; - double *pos=convertPyToNewDblArr2(p,&sz); - std::vector elts,eltsIndex; - self->getCellsContainingPoints(pos,nbOfPoints,eps,elts,eltsIndex); - delete [] pos; - PyObject *ret=PyList_New(2); - PyList_SetItem(ret,0,convertIntArrToPyList2(elts)); - PyList_SetItem(ret,1,convertIntArrToPyList2(eltsIndex)); - return ret; - } - - PyObject *getCellsContainingPoint(PyObject *p, double eps) const - { - int sz; - double *pos=convertPyToNewDblArr2(p,&sz); - std::vector elts; - self->getCellsContainingPoint(pos,eps,elts); - delete [] pos; - return convertIntArrToPyList2(elts); - } - - static PyObject *mergeUMeshesOnSameCoords(PyObject *ms) throw(INTERP_KERNEL::Exception) - { - std::vector meshes; - if(PyList_Check(ms)) - { - int sz=PyList_Size(ms); - meshes.resize(sz); - for(int i=0;i(arg); - } - } - else - { - PyErr_SetString(PyExc_TypeError,"mergeUMeshesOnSameCoords : not a list as first parameter"); - PyErr_Print(); - return 0; - } - MEDCouplingUMesh *ret=MEDCouplingUMesh::mergeUMeshesOnSameCoords(meshes); - return convertMesh(ret, SWIG_POINTER_OWN | 0 ); - } - - static PyObject *fuseUMeshesOnSameCoords(PyObject *ms, int compType) - { - int sz; - std::vector meshes; - convertPyObjToVecUMeshes(ms,meshes); - std::vector corr; - MEDCouplingUMesh *um=MEDCouplingUMesh::fuseUMeshesOnSameCoords(meshes,compType,corr); - sz=corr.size(); - PyObject *ret1=PyList_New(sz); - for(int i=0;i cells; - int sz; - double *v=convertPyToNewDblArr2(vec,&sz); - try - { - self->are2DCellsNotCorrectlyOriented(v,polyOnly,cells); - } - catch(INTERP_KERNEL::Exception& e) - { - delete [] v; - throw e; - } - delete [] v; - return convertIntArrToPyList2(cells); - } - - void orientCorrectly2DCells(PyObject *vec, bool polyOnly) throw(INTERP_KERNEL::Exception) - { - int sz; - double *v=convertPyToNewDblArr2(vec,&sz); - try - { - self->orientCorrectly2DCells(v,polyOnly); - } - catch(INTERP_KERNEL::Exception& e) - { - delete [] v; - throw e; - } - delete [] v; - } - - PyObject *arePolyhedronsNotCorrectlyOriented() const throw(INTERP_KERNEL::Exception) - { - std::vector cells; - self->arePolyhedronsNotCorrectlyOriented(cells); - return convertIntArrToPyList2(cells); - } - - PyObject *getFastAveragePlaneOfThis() const throw(INTERP_KERNEL::Exception) - { - double vec[3]; - double pos[3]; - self->getFastAveragePlaneOfThis(vec,pos); - double vals[6]; - std::copy(vec,vec+3,vals); - std::copy(pos,pos+3,vals+3); - return convertDblArrToPyListOfTuple(vals,3,2); - } - } - void convertToPolyTypes(const std::vector& cellIdsToConvert); - MEDCouplingUMesh *buildExtrudedMeshFromThis(const MEDCouplingUMesh *mesh1D, int policy); - static MEDCouplingUMesh *mergeUMeshes(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2) throw(INTERP_KERNEL::Exception); - }; - - class MEDCouplingExtrudedMesh : public ParaMEDMEM::MEDCouplingMesh - { - public: - static MEDCouplingExtrudedMesh *New(const MEDCouplingUMesh *mesh3D, MEDCouplingUMesh *mesh2D, int cell2DId) throw(INTERP_KERNEL::Exception); - MEDCouplingUMesh *build3DUnstructuredMesh() const; - %extend { - std::string __str__() const - { - return self->simpleRepr(); - } - PyObject *getMesh2D() const - { - MEDCouplingUMesh *ret=self->getMesh2D(); - ret->incrRef(); - return convertMesh(ret, SWIG_POINTER_OWN | 0 ); - } - PyObject *getMesh1D() const - { - MEDCouplingUMesh *ret=self->getMesh1D(); - ret->incrRef(); - return convertMesh(ret, SWIG_POINTER_OWN | 0 ); - } - PyObject *getMesh3DIds() const - { - DataArrayInt *ret=self->getMesh3DIds(); - ret->incrRef(); - return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ); - } - } - }; - - class MEDCouplingCMesh : public ParaMEDMEM::MEDCouplingMesh - { - public: - static MEDCouplingCMesh *New(); - void setCoords(DataArrayDouble *coordsX, - DataArrayDouble *coordsY=0, - DataArrayDouble *coordsZ=0); - void setCoordsAt(int i, DataArrayDouble *arr) throw(INTERP_KERNEL::Exception); - MEDCouplingUMesh *buildUnstructured() const; - %extend { - std::string __str__() const - { - return self->simpleRepr(); - } - } - }; -} - -%extend ParaMEDMEM::DataArray -{ - void copyPartOfStringInfoFrom(const DataArray& other, PyObject *li) throw(INTERP_KERNEL::Exception) - { - std::vector tmp; - convertPyToNewIntArr3(li,tmp); - self->copyPartOfStringInfoFrom(other,tmp); - } - - void copyPartOfStringInfoFrom2(PyObject *li, const DataArray& other) throw(INTERP_KERNEL::Exception) - { - std::vector tmp; - convertPyToNewIntArr3(li,tmp); - self->copyPartOfStringInfoFrom2(tmp,other); - } -} - -%extend ParaMEDMEM::DataArrayDouble - { - std::string __str__() const - { - return self->repr(); - } - - void setValues(PyObject *li, int nbOfTuples, int nbOfElsPerTuple) - { - int sz; - double *tmp=convertPyToNewDblArr2(li,&sz); - self->useArray(tmp,true,CPP_DEALLOC,nbOfTuples,nbOfElsPerTuple); - } - - PyObject *getValues() - { - const double *vals=self->getPointer(); - return convertDblArrToPyList(vals,self->getNbOfElems()); - } - - PyObject *getValuesAsTuple() - { - const double *vals=self->getPointer(); - int nbOfComp=self->getNumberOfComponents(); - int nbOfTuples=self->getNumberOfTuples(); - return convertDblArrToPyListOfTuple(vals,nbOfComp,nbOfTuples); - } - - DataArrayDouble *renumber(PyObject *li) throw(INTERP_KERNEL::Exception) - { - int size; - int *tmp=convertPyToNewIntArr2(li,&size); - if(size!=self->getNumberOfTuples()) - { - throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !"); - delete [] tmp; - } - DataArrayDouble *ret=self->renumber(tmp); - delete [] tmp; - return ret; - } - - DataArrayDouble *renumberR(PyObject *li) throw(INTERP_KERNEL::Exception) - { - int size; - int *tmp=convertPyToNewIntArr2(li,&size); - if(size!=self->getNumberOfTuples()) - { - throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !"); - delete [] tmp; - } - DataArrayDouble *ret=self->renumberR(tmp); - delete [] tmp; - return ret; - } - - DataArrayDouble *renumberAndReduce(PyObject *li, int newNbOfTuple) throw(INTERP_KERNEL::Exception) - { - int size; - int *tmp=convertPyToNewIntArr2(li,&size); - if(size!=self->getNumberOfTuples()) - { - throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !"); - delete [] tmp; - } - DataArrayDouble *ret=self->renumberAndReduce(tmp,newNbOfTuple); - delete [] tmp; - return ret; - } - - void renumberInPlace(PyObject *li) throw(INTERP_KERNEL::Exception) - { - int size; - int *tmp=convertPyToNewIntArr2(li,&size); - if(size!=self->getNumberOfTuples()) - { - throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !"); - delete [] tmp; - } - self->renumberInPlace(tmp); - delete [] tmp; - } - - void renumberInPlaceR(PyObject *li) throw(INTERP_KERNEL::Exception) - { - int size; - int *tmp=convertPyToNewIntArr2(li,&size); - if(size!=self->getNumberOfTuples()) - { - throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !"); - delete [] tmp; - } - self->renumberInPlaceR(tmp); - delete [] tmp; - } - - DataArrayDouble *selectByTupleId(PyObject *li) const - { - int size; - int *tmp=convertPyToNewIntArr2(li,&size); - DataArrayDouble *ret=self->selectByTupleId(tmp,tmp+size); - delete [] tmp; - return ret; - } - - PyObject *getMaxValue() const throw(INTERP_KERNEL::Exception) - { - int tmp; - double r1=self->getMaxValue(tmp); - PyObject *ret=PyTuple_New(2); - PyTuple_SetItem(ret,0,PyFloat_FromDouble(r1)); - PyTuple_SetItem(ret,1,PyInt_FromLong(tmp)); - return ret; - } - - PyObject *getMaxValue2() const throw(INTERP_KERNEL::Exception) - { - DataArrayInt *tmp; - double r1=self->getMaxValue2(tmp); - PyObject *ret=PyTuple_New(2); - PyTuple_SetItem(ret,0,PyFloat_FromDouble(r1)); - PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(tmp),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); - return ret; - } - - PyObject *getMinValue() const throw(INTERP_KERNEL::Exception) - { - int tmp; - double r1=self->getMinValue(tmp); - PyObject *ret=PyTuple_New(2); - PyTuple_SetItem(ret,0,PyFloat_FromDouble(r1)); - PyTuple_SetItem(ret,1,PyInt_FromLong(tmp)); - return ret; - } - - PyObject *getMinValue2() const throw(INTERP_KERNEL::Exception) - { - DataArrayInt *tmp; - double r1=self->getMinValue2(tmp); - PyObject *ret=PyTuple_New(2); - PyTuple_SetItem(ret,0,PyFloat_FromDouble(r1)); - PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(tmp),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); - return ret; - } - - DataArrayDouble *keepSelectedComponents(PyObject *li) const throw(INTERP_KERNEL::Exception) - { - std::vector tmp; - convertPyToNewIntArr3(li,tmp); - return self->keepSelectedComponents(tmp); - } - - void setSelectedComponents(const DataArrayDouble *a, PyObject *li) throw(INTERP_KERNEL::Exception) - { - std::vector tmp; - convertPyToNewIntArr3(li,tmp); - self->setSelectedComponents(a,tmp); - } - }; - -%extend ParaMEDMEM::DataArrayInt - { - std::string __str__() const - { - return self->repr(); - } - - void setValues(PyObject *li, int nbOfTuples, int nbOfElsPerTuple) - { - int size; - int *tmp=convertPyToNewIntArr2(li,&size); - self->useArray(tmp,true,CPP_DEALLOC,nbOfTuples,nbOfElsPerTuple); - } - - PyObject *getValues() - { - const int *vals=self->getPointer(); - return convertIntArrToPyList(vals,self->getNbOfElems()); - } - - PyObject *getValuesAsTuple() - { - const int *vals=self->getPointer(); - int nbOfComp=self->getNumberOfComponents(); - int nbOfTuples=self->getNumberOfTuples(); - return convertIntArrToPyListOfTuple(vals,nbOfComp,nbOfTuples); - } - - static PyObject *makePartition(PyObject *gps, int newNb) - { - std::vector groups; - std::vector< std::vector > fidsOfGroups; - convertPyObjToVecDataArrayInt(gps,groups); - ParaMEDMEM::DataArrayInt *ret0=ParaMEDMEM::DataArrayInt::makePartition(groups,newNb,fidsOfGroups); - PyObject *ret = PyList_New(2); - PyList_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); - int sz=fidsOfGroups.size(); - PyObject *ret1 = PyList_New(sz); - for(int i=0;igetNumberOfTuples()) - { - throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !"); - delete [] tmp; - } - self->renumberInPlace(tmp); - delete [] tmp; - } - - void renumberInPlaceR(PyObject *li) throw(INTERP_KERNEL::Exception) - { - int size; - int *tmp=convertPyToNewIntArr2(li,&size); - if(size!=self->getNumberOfTuples()) - { - throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !"); - delete [] tmp; - } - self->renumberInPlaceR(tmp); - delete [] tmp; - } - - DataArrayInt *renumberAndReduce(PyObject *li, int newNbOfTuple) throw(INTERP_KERNEL::Exception) - { - int size; - int *tmp=convertPyToNewIntArr2(li,&size); - if(size!=self->getNumberOfTuples()) - { - throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !"); - delete [] tmp; - } - DataArrayInt *ret=self->renumberAndReduce(tmp,newNbOfTuple); - delete [] tmp; - return ret; - } - - DataArrayInt *renumber(PyObject *li) throw(INTERP_KERNEL::Exception) - { - int size; - int *tmp=convertPyToNewIntArr2(li,&size); - if(size!=self->getNumberOfTuples()) - { - throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !"); - delete [] tmp; - } - DataArrayInt *ret=self->renumber(tmp); - delete [] tmp; - return ret; - } - - DataArrayInt *renumberR(PyObject *li) throw(INTERP_KERNEL::Exception) - { - int size; - int *tmp=convertPyToNewIntArr2(li,&size); - if(size!=self->getNumberOfTuples()) - { - throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !"); - delete [] tmp; - } - DataArrayInt *ret=self->renumberR(tmp); - delete [] tmp; - return ret; - } - - DataArrayInt *selectByTupleId(PyObject *li) const - { - int size; - int *tmp=convertPyToNewIntArr2(li,&size); - DataArrayInt *ret=self->selectByTupleId(tmp,tmp+size); - delete [] tmp; - return ret; - } - - DataArrayInt *keepSelectedComponents(PyObject *li) const throw(INTERP_KERNEL::Exception) - { - std::vector tmp; - convertPyToNewIntArr3(li,tmp); - return self->keepSelectedComponents(tmp); - } - - void setSelectedComponents(const DataArrayInt *a, PyObject *li) throw(INTERP_KERNEL::Exception) - { - std::vector tmp; - convertPyToNewIntArr3(li,tmp); - self->setSelectedComponents(a,tmp); - } - }; - -namespace ParaMEDMEM -{ - class MEDCouplingField : public ParaMEDMEM::RefCountObject, public ParaMEDMEM::TimeLabel - { - public: - virtual void checkCoherency() const throw(INTERP_KERNEL::Exception); - virtual bool areCompatibleForMerge(const MEDCouplingField *other) const; - virtual bool isEqual(const MEDCouplingField *other, double meshPrec, double valsPrec) const; - virtual bool isEqualWithoutConsideringStr(const MEDCouplingField *other, double meshPrec, double valsPrec) const; - void setMesh(const ParaMEDMEM::MEDCouplingMesh *mesh); - void setName(const char *name); - const char *getDescription() const; - void setDescription(const char *desc); - const char *getName() const; - TypeOfField getTypeOfField() const; - MEDCouplingFieldDouble *buildMeasureField(bool isAbs) const throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDiscretization *getDiscretization() const; - void setGaussLocalizationOnType(INTERP_KERNEL::NormalizedCellType type, const std::vector& refCoo, - const std::vector& gsCoo, const std::vector& wg) throw(INTERP_KERNEL::Exception); - void clearGaussLocalizations(); - MEDCouplingGaussLocalization& getGaussLocalization(int locId) throw(INTERP_KERNEL::Exception); - int getNbOfGaussLocalization() const throw(INTERP_KERNEL::Exception); - int getGaussLocalizationIdOfOneCell(int cellId) const throw(INTERP_KERNEL::Exception); - const MEDCouplingGaussLocalization& getGaussLocalization(int locId) const throw(INTERP_KERNEL::Exception); - %extend { - PyObject *getMesh() const - { - MEDCouplingMesh *ret1=(MEDCouplingMesh *)self->getMesh(); - ret1->incrRef(); - return convertMesh(ret1, SWIG_POINTER_OWN | 0 ); - } - - PyObject *buildSubMeshData(PyObject *li) const - { - int size; - int *tmp=convertPyToNewIntArr2(li,&size); - DataArrayInt *ret1; - MEDCouplingMesh *ret0=self->buildSubMeshData(tmp,tmp+size,ret1); - delete [] tmp; - PyObject *res = PyList_New(2); - PyList_SetItem(res,0,convertMesh(ret0, SWIG_POINTER_OWN | 0 )); - PyList_SetItem(res,1,SWIG_NewPointerObj((void*)ret1,SWIGTYPE_p_ParaMEDMEM__DataArrayInt,SWIG_POINTER_OWN | 0)); - return res; - } - void setGaussLocalizationOnCells(PyObject *li, const std::vector& refCoo, - const std::vector& gsCoo, const std::vector& wg) throw(INTERP_KERNEL::Exception) - { - int size; - int *tmp=convertPyToNewIntArr2(li,&size); - try - { - self->setGaussLocalizationOnCells(tmp,tmp+size,refCoo,gsCoo,wg); - } - catch(INTERP_KERNEL::Exception& e) - { - delete [] tmp; - throw e; - } - delete [] tmp; - } - PyObject *getCellIdsHavingGaussLocalization(int locId) const throw(INTERP_KERNEL::Exception) - { - std::vector tmp; - self->getCellIdsHavingGaussLocalization(locId,tmp); - return convertIntArrToPyList2(tmp); - } - } - }; - - class MEDCouplingFieldDouble : public ParaMEDMEM::MEDCouplingField - { - public: - static MEDCouplingFieldDouble *New(TypeOfField type, TypeOfTimeDiscretization td=NO_TIME); - void copyTinyStringsFrom(const MEDCouplingFieldDouble *other) throw(INTERP_KERNEL::Exception); - std::string simpleRepr() const; - std::string advancedRepr() const; - MEDCouplingFieldDouble *clone(bool recDeepCpy) const; - MEDCouplingFieldDouble *cloneWithMesh(bool recDeepCpy) const; - MEDCouplingFieldDouble *buildNewTimeReprFromThis(TypeOfTimeDiscretization td, bool deepCpy) const; - TypeOfTimeDiscretization getTimeDiscretization() const; - void checkCoherency() const throw(INTERP_KERNEL::Exception); - double getIJ(int tupleId, int compoId) const; - double getIJK(int cellId, int nodeIdInCell, int compoId) const; - void setArray(DataArrayDouble *array) throw(INTERP_KERNEL::Exception); - void setEndArray(DataArrayDouble *array) throw(INTERP_KERNEL::Exception); - void setTime(double val, int iteration, int order) throw(INTERP_KERNEL::Exception); - void setStartTime(double val, int iteration, int order) throw(INTERP_KERNEL::Exception); - void setEndTime(double val, int iteration, int order) throw(INTERP_KERNEL::Exception); - DataArrayDouble *getArray() const throw(INTERP_KERNEL::Exception); - DataArrayDouble *getEndArray() const throw(INTERP_KERNEL::Exception); - void applyLin(double a, double b, int compoId) throw(INTERP_KERNEL::Exception); - int getNumberOfComponents() const throw(INTERP_KERNEL::Exception); - int getNumberOfTuples() const throw(INTERP_KERNEL::Exception); - int getNumberOfValues() const throw(INTERP_KERNEL::Exception); - NatureOfField getNature() const { return _nature; } - void setNature(NatureOfField nat) throw(INTERP_KERNEL::Exception); - void updateTime(); - void changeUnderlyingMesh(const MEDCouplingMesh *other, int levOfCheck, double prec) throw(INTERP_KERNEL::Exception); - void substractInPlaceDM(const MEDCouplingFieldDouble *f, int levOfCheck, double prec) throw(INTERP_KERNEL::Exception); - bool mergeNodes(double eps) throw(INTERP_KERNEL::Exception); - bool zipCoords() throw(INTERP_KERNEL::Exception); - bool zipConnectivity(int compType) throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *doublyContractedProduct() const throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *determinant() const throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *eigenValues() const throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *eigenVectors() const throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *inverse() const throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *trace() const throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *deviator() const throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *magnitude() const throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *maxPerTuple() const throw(INTERP_KERNEL::Exception); - void changeNbOfComponents(int newNbOfComp, double dftValue=0.) throw(INTERP_KERNEL::Exception); - void sortPerTuple(bool asc) throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble &operator=(double value) throw(INTERP_KERNEL::Exception); - void fillFromAnalytic(int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception); - void applyFunc(int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception); - void applyFunc(int nbOfComp, double val) throw(INTERP_KERNEL::Exception); - void applyFunc(const char *func) throw(INTERP_KERNEL::Exception); - void applyFuncFast32(const char *func) throw(INTERP_KERNEL::Exception); - void applyFuncFast64(const char *func) throw(INTERP_KERNEL::Exception); - double accumulate(int compId) const throw(INTERP_KERNEL::Exception); - double getMaxValue() const throw(INTERP_KERNEL::Exception); - double getMinValue() const throw(INTERP_KERNEL::Exception); - double getAverageValue() const throw(INTERP_KERNEL::Exception); - double getWeightedAverageValue() const throw(INTERP_KERNEL::Exception); - double integral(int compId, bool isWAbs) const throw(INTERP_KERNEL::Exception); - double normL1(int compId) const throw(INTERP_KERNEL::Exception); - double normL2(int compId) const throw(INTERP_KERNEL::Exception); - DataArrayInt *getIdsInRange(double vmin, double vmax) const throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *buildSubPart(const DataArrayInt *part) const throw(INTERP_KERNEL::Exception); - static MEDCouplingFieldDouble *mergeFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception); - static MEDCouplingFieldDouble *dotFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2); - MEDCouplingFieldDouble *dot(const MEDCouplingFieldDouble& other) const; - static MEDCouplingFieldDouble *crossProductFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2); - MEDCouplingFieldDouble *crossProduct(const MEDCouplingFieldDouble& other) const; - static MEDCouplingFieldDouble *maxFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2); - MEDCouplingFieldDouble *max(const MEDCouplingFieldDouble& other) const; - static MEDCouplingFieldDouble *minFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2); - MEDCouplingFieldDouble *min(const MEDCouplingFieldDouble& other) const; - MEDCouplingFieldDouble *operator+(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception); - const MEDCouplingFieldDouble &operator+=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *operator-(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception); - const MEDCouplingFieldDouble &operator-=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *operator*(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception); - const MEDCouplingFieldDouble &operator*=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *operator/(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception); - const MEDCouplingFieldDouble &operator/=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception); - %extend { - std::string __str__() const - { - return self->simpleRepr(); - } - PyObject *getValueOn(PyObject *sl) const throw(INTERP_KERNEL::Exception) - { - int sz; - double *spaceLoc=convertPyToNewDblArr2(sl,&sz); - sz=self->getNumberOfComponents(); - double *res=new double[sz]; - try - { - self->getValueOn(spaceLoc,res); - } - catch(INTERP_KERNEL::Exception& e) - { - delete [] spaceLoc; - delete [] res; - throw e; - } - delete [] spaceLoc; - PyObject *ret=convertDblArrToPyList(res,sz); - delete [] res; - return ret; - } - PyObject *getValueOn(PyObject *sl, double time) const throw(INTERP_KERNEL::Exception) - { - int sz; - double *spaceLoc=convertPyToNewDblArr2(sl,&sz); - sz=self->getNumberOfComponents(); - double *res=new double[sz]; - try - { - self->getValueOn(spaceLoc,time,res); - } - catch(INTERP_KERNEL::Exception& e) - { - delete [] spaceLoc; - delete [] res; - throw e; - } - delete [] spaceLoc; - PyObject *ret=convertDblArrToPyList(res,sz); - delete [] res; - return ret; - } - void setValues(PyObject *li) - { - if(self->getArray()!=0) - { - int sz; - double *tmp=convertPyToNewDblArr2(li,&sz); - int nbTuples=self->getArray()->getNumberOfTuples(); - int nbOfCompo=self->getArray()->getNumberOfComponents(); - self->getArray()->useArray(tmp,true,CPP_DEALLOC,nbTuples,nbOfCompo); - } - else - PyErr_SetString(PyExc_TypeError,"setValuesCpy : field must contain an array behind"); - } - PyObject *getTime() - { - int tmp1,tmp2; - double tmp0=self->getTime(tmp1,tmp2); - PyObject *res = PyList_New(3); - PyList_SetItem(res,0,SWIG_From_double(tmp0)); - PyList_SetItem(res,1,SWIG_From_int(tmp1)); - PyList_SetItem(res,2,SWIG_From_int(tmp2)); - return res; - } - - PyObject *getStartTime() - { - int tmp1,tmp2; - double tmp0=self->getStartTime(tmp1,tmp2); - PyObject *res = PyList_New(3); - PyList_SetItem(res,0,SWIG_From_double(tmp0)); - PyList_SetItem(res,1,SWIG_From_int(tmp1)); - PyList_SetItem(res,2,SWIG_From_int(tmp2)); - return res; - } - - PyObject *getEndTime() - { - int tmp1,tmp2; - double tmp0=self->getEndTime(tmp1,tmp2); - PyObject *res = PyList_New(3); - PyList_SetItem(res,0,SWIG_From_double(tmp0)); - PyList_SetItem(res,1,SWIG_From_int(tmp1)); - PyList_SetItem(res,2,SWIG_From_int(tmp2)); - return res; - } - PyObject *accumulate() const - { - int sz=self->getNumberOfComponents(); - double *tmp=new double[sz]; - self->accumulate(tmp); - PyObject *ret=convertDblArrToPyList(tmp,sz); - delete [] tmp; - return ret; - } - PyObject *integral(bool isWAbs) const - { - int sz=self->getNumberOfComponents(); - double *tmp=new double[sz]; - self->integral(isWAbs,tmp); - PyObject *ret=convertDblArrToPyList(tmp,sz); - delete [] tmp; - return ret; - } - PyObject *normL1() const throw(INTERP_KERNEL::Exception) - { - int sz=self->getNumberOfComponents(); - double *tmp=new double[sz]; - self->normL1(tmp); - PyObject *ret=convertDblArrToPyList(tmp,sz); - delete [] tmp; - return ret; - } - PyObject *normL2() const throw(INTERP_KERNEL::Exception) - { - int sz=self->getNumberOfComponents(); - double *tmp=new double[sz]; - self->normL2(tmp); - PyObject *ret=convertDblArrToPyList(tmp,sz); - delete [] tmp; - return ret; - } - - void renumberCells(PyObject *li, bool check) throw(INTERP_KERNEL::Exception) - { - int size; - int *tmp=convertPyToNewIntArr2(li,&size); - try - { - self->renumberCells(tmp,check); - } - catch(INTERP_KERNEL::Exception& e) - { - delete [] tmp; - throw e; - } - delete [] tmp; - } - void renumberNodes(PyObject *li) throw(INTERP_KERNEL::Exception) - { - int size; - int *tmp=convertPyToNewIntArr2(li,&size); - try - { - self->renumberNodes(tmp); - } - catch(INTERP_KERNEL::Exception& e) - { - delete [] tmp; - throw e; - } - delete [] tmp; - } - - MEDCouplingFieldDouble *buildSubPart(PyObject *li) const throw(INTERP_KERNEL::Exception) - { - int size; - int *tmp=convertPyToNewIntArr2(li,&size); - MEDCouplingFieldDouble *ret=0; - try - { - ret=self->buildSubPart(tmp,tmp+size); - } - catch(INTERP_KERNEL::Exception& e) - { - delete [] tmp; - throw e; - } - delete [] tmp; - return ret; - } - - PyObject *getMaxValue2() const throw(INTERP_KERNEL::Exception) - { - DataArrayInt *tmp; - double r1=self->getMaxValue2(tmp); - PyObject *ret=PyTuple_New(2); - PyTuple_SetItem(ret,0,PyFloat_FromDouble(r1)); - PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(tmp),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); - return ret; - } - - PyObject *getMinValue2() const throw(INTERP_KERNEL::Exception) - { - DataArrayInt *tmp; - double r1=self->getMinValue2(tmp); - PyObject *ret=PyTuple_New(2); - PyTuple_SetItem(ret,0,PyFloat_FromDouble(r1)); - PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(tmp),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); - return ret; - } - - MEDCouplingFieldDouble *keepSelectedComponents(PyObject *li) const throw(INTERP_KERNEL::Exception) - { - std::vector tmp; - convertPyToNewIntArr3(li,tmp); - return self->keepSelectedComponents(tmp); - } - - void setSelectedComponents(const MEDCouplingFieldDouble *f, PyObject *li) throw(INTERP_KERNEL::Exception) - { - std::vector tmp; - convertPyToNewIntArr3(li,tmp); - self->setSelectedComponents(f,tmp); - } - } - }; -} diff --git a/src/MEDCoupling_Swig/libMEDCoupling_Swig.py b/src/MEDCoupling_Swig/libMEDCoupling_Swig.py new file mode 100644 index 000000000..bad586db1 --- /dev/null +++ b/src/MEDCoupling_Swig/libMEDCoupling_Swig.py @@ -0,0 +1,28 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2011 CEA/DEN, EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +print """ +*********************************************************************** +*********************************************************************** +libMEDCoupling_Swig module DEPRECATED ! +Please use instead \"import MEDCoupling\" or \"from MEDCoupling import *\" +*********************************************************************** +*********************************************************************** +"""