-// 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__
-// 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__
--- /dev/null
+// 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 T>
+ 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
-// 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"
-// 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__
namespace INTERP_KERNEL
{
- class INTERPKERNELBASES_EXPORT Exception : std::exception
+ class INTERPKERNELBASES_EXPORT Exception : public std::exception
{
public:
Exception(const char *what);
class _HashFn = hash<_Key>,
class _EqualKey = std::equal_to<_Key>,
class _Alloc = std::allocator<_Tp> >
- class hash_multimap
+ class HashMultiMap
{
private:
typedef hashtable<std::pair<const _Key, _Tp>, _Key, _HashFn,
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<class _InputIterator>
- 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<class _InputIterator>
- 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<class _InputIterator>
- 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<class _InputIterator>
- 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); }
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<class _K1, class _T1, class _HF, class _EqK, class _Al>
- 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(); }
};
template<class _Key, class _Tp, class _HF, class _EqKey, class _Alloc>
- 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<class _Key, class _Tp, class _HF, class _EqKey, class _Alloc>
- 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<class _Key, class _Tp, class _HashFn, class _EqlKey, class _Alloc>
- 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); }
}
namespace std
{
// Specialization of insert_iterator so that it will work for HashMap
- // and hash_multimap.
+ // and HashMultiMap.
template<class _Key, class _Tp, class _HashFn, class _EqKey, class _Alloc>
class insert_iterator<INTERP_KERNEL::HashMap<_Key, _Tp, _HashFn,
_EqKey, _Alloc> >
};
template<class _Key, class _Tp, class _HashFn, class _EqKey, class _Alloc>
- class insert_iterator<INTERP_KERNEL::hash_multimap<_Key, _Tp, _HashFn,
- _EqKey, _Alloc> >
+ class insert_iterator<INTERP_KERNEL::HashMultiMap<_Key, _Tp, _HashFn,
+ _EqKey, _Alloc> >
{
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;
-// 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__
-# 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
InterpKernelStlExt.hxx \
InterpKernelHashMap.hxx \
InterpKernelHashTable.hxx \
-InterpKernelHashFun.hxx
+InterpKernelHashFun.hxx \
+InterpKernelAutoPtr.hxx
# Libraries targets
-// 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__
typedef enum
{
- NORM_POINT0 = 0,
+ NORM_POINT1 = 0,
NORM_SEG2 = 1,
NORM_SEG3 = 2,
NORM_TRI3 = 3,
NORM_PENTA6 = 16,
NORM_HEXA8 = 18,
NORM_TETRA10 = 20,
+ NORM_HEXGP12 = 22,
NORM_PYRA13 = 23,
NORM_PENTA15 = 25,
NORM_HEXA20 = 30,
-// 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"
-// 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__
-// 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"
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
std::map<NormalizedCellType,CellModel> CellModel::_map_of_unique_instance;
- const CellModel& CellModel::getCellModel(NormalizedCellType type)
+ const CellModel& CellModel::GetCellModel(NormalizedCellType type)
{
if(_map_of_unique_instance.empty())
buildUniqueInstance();
{
if(_type==type)
return true;
- const CellModel& other=getCellModel(type);
+ const CellModel& other=GetCellModel(type);
if(_dim!=other.getDimension())
return false;
bool b1=isQuadratic();
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)));
_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)));
_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;
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;
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;
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;
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;
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;
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;
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;
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;
_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;
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;
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;
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:
-// 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__
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; }
private:
bool _dyn;
bool _quadratic;
+ bool _is_simplex;
unsigned _dim;
unsigned _nb_of_pts;
unsigned _nb_of_sons;
-// 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__
-// 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__
-// 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__
-// 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__
-// 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__
-// 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__
-// 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__
-// 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__
-// 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__
-// 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__
-// 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__
-// 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__
-// 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
-// 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__
-// 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__
-// 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"
#include <sstream>
#include <algorithm>
+#ifdef _POSIX_MAPPED_FILES
+#include <sys/mman.h>
+#else
+#ifdef WNT
+#include <windows.h>
+#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<char> INTERP_KERNEL::AsmX86::convertIntoMachineLangage(const std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
return ret;
}
-char *INTERP_KERNEL::AsmX86::convertMachineLangageInBasic(const std::vector<char>& ml, int& lgth) const
+char *INTERP_KERNEL::AsmX86::copyToExecMemZone(const std::vector<char>& 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;
}
void INTERP_KERNEL::AsmX86::convertMov(const std::string& inst, std::vector<char>& 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));
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));
{
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);
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));
{
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);
std::string::size_type pos=inst.find_first_of(' ');
std::string inst2=inst.substr(pos+1);
const char ASM1[]="ebp";
- const char ML1[1]={0x55};
+ const unsigned char ML1[1]={0x55};
if(inst2==ASM1)
{//push ebp
ml.insert(ml.end(),ML1,ML1+sizeof(ML1));
return ;
}
const char ASM2[]="ebx";
- const char ML2[1]={0x53};
+ const unsigned char ML2[1]={0x53};
if(inst2==ASM2)
{//push ebx
ml.insert(ml.end(),ML2,ML2+sizeof(ML2));
return ;
}
const char ASM3[]="rbp";
- const char ML3[1]={0x55};
+ const unsigned char ML3[1]={0x55};
if(inst2==ASM3)
{//push rbp
ml.insert(ml.end(),ML3,ML3+sizeof(ML3));
std::string::size_type pos=inst.find_first_of(' ');
std::string inst2=inst.substr(pos+1);
const char ASM1[]="ebp";
- const char ML1[1]={0x5d};
+ const unsigned char ML1[1]={0x5d};
if(inst2==ASM1)
{//push ebp
ml.insert(ml.end(),ML1,ML1+sizeof(ML1));
return ;
}
const char ASM2[]="ebx";
- const char ML2[1]={0x5b};
+ const unsigned char ML2[1]={0x5b};
if(inst2==ASM2)
{//push ebx
ml.insert(ml.end(),ML2,ML2+sizeof(ML2));
std::string params2=params.substr(1,params.length()-2);
if(params2.substr(0,3)=="esp")
{
- const char ML1[3]={0xdd,0x04,0x24};
+ const unsigned char ML1[3]={0xdd,0x04,0x24};
if(params2.length()==3)
{//fld qword [esp]
ml.insert(ml.end(),ML1,ML1+sizeof(ML1));
}
if(params2.substr(0,3)=="ebp")
{
- const char ML2[2]={0xdd,0x45};
+ const unsigned char ML2[2]={0xdd,0x45};
if(params2.length()==3)
{//fld qword [ebp]
ml.insert(ml.end(),ML2,ML2+sizeof(ML2));
}
if(params2.substr(0,3)=="rsp")
{
- const char ML2[3]={0xdd,0x04,0x24};
+ const unsigned char ML2[3]={0xdd,0x04,0x24};
ml.insert(ml.end(),ML2,ML2+sizeof(ML2));// to improve ! no fully managed !
return ;
}
void INTERP_KERNEL::AsmX86::convertFaddp(const std::string& inst, std::vector<char>& 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<char>& 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<char>& 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<char>& 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<char>& 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<char>& 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<char>& 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<char>& 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<char>& 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));
}
{
if(inst.substr(0,4)=="esp,")
{
- const char ML[2]={0x81,0xec};
+ const unsigned char ML[2]={0x81,0xec};
ml.insert(ml.end(),ML,ML+sizeof(ML));
std::string inst2=inst.substr(4);
appendAddress(inst2,4,ml);
}
if(inst.substr(0,4)=="rsp,")
{
- const char ML[4]={0x48,0x83,0xec,0x08};
+ const unsigned char ML[4]={0x48,0x83,0xec,0x08};
ml.insert(ml.end(),ML,ML+sizeof(ML)); // to improve 8 statically put (last of element of ML) !!!!
return;
}
{
if(inst.substr(0,4)=="esp,")
{
- const char ML[2]={0x81,0xc4};
+ const unsigned char ML[2]={0x81,0xc4};
ml.insert(ml.end(),ML,ML+sizeof(ML));
std::string inst2=inst.substr(4);
appendAddress(inst2,4,ml);
}
if(inst.substr(0,4)=="rsp,")
{
- const char ML[4]={0x48,0x83,0xc4,0x08};
+ const unsigned char ML[4]={0x48,0x83,0xc4,0x08};
ml.insert(ml.end(),ML,ML+sizeof(ML)); // to improve 8 statically put (last of element of ML) !!!!
return;
}
void INTERP_KERNEL::AsmX86::convertRet(const std::string& inst, std::vector<char>& 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<char>& 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<char>& 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));
void INTERP_KERNEL::AsmX86::convertFst(const std::string& inst, std::vector<char>& 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));
-// 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__
{
public:
std::vector<char> convertIntoMachineLangage(const std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
- char *convertMachineLangageInBasic(const std::vector<char>& ml, int& lgth) const;
+ char *copyToExecMemZone(const std::vector<char>& ml, unsigned& offset) const;
private:
void convertOneInstructionInML(const std::string& inst, std::vector<char>& ml) const throw(INTERP_KERNEL::Exception);
private:
-// 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"
#include <cctype>
#include <sstream>
+#include <limits>
#include <vector>
#include <iterator>
#include <iostream>
#include <algorithm>
-#ifdef _POSIX_MAPPED_FILES
-#include <sys/mman.h>
-#else
-#ifdef WNT
-#include <windows.h>
-#endif
-#endif
-
using namespace INTERP_KERNEL;
const char LeafExprVar::END_OF_RECOGNIZED_VAR[]="Vec";
val->setDouble(_value);
}
+void LeafExprVal::replaceValues(const std::vector<double>& 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)
{
}
return true;
}
+/*!
+ * Nothing to do it is not a bug.
+ */
+void LeafExprVar::replaceValues(const std::vector<double>& 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()
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<posOfCloseBracket;iter++)
+ {
+ std::size_t iter2=posOfCloseBracket-1-iter;
+ if(expr[iter2]==')')
+ level++;
+ else if(expr[iter2]=='(')
+ {
+ if(level==0)
+ return iter2;
+ else
+ level--;
+ }
+ }
return std::string::npos;
}
releaseFunctions();
if(!_expr.empty())
{
+ std::string tmp(_expr);
+ std::vector<double> valuesInExpr;
+ fillValuesInExpr(valuesInExpr);
checkBracketsParity();
if(!simplify())
parseDeeper();
+ replaceValues(valuesInExpr);
+ _expr=tmp;
}
_is_parsing_ok=true;
}
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);
std::size_t pos6=0;
for(int i=0;i<nbOfParamsInFunc;i++)
{
- std::size_t pos5=newExp2.find_first_of(',');
+ std::size_t pos5=newExp2.find_first_of(',',pos6);
std::size_t len=std::string::npos;
if(pos5!=std::string::npos)
len=pos5-pos6;
{
std::size_t pos=_expr.find_first_not_of("+-",0,2);
std::string minimizedExpr=_expr.substr(pos);
- std::size_t pos2=minimizedExpr.find_first_of("+-*/^()",0,7);
+ std::size_t pos2=minimizedExpr.find_first_of("+-*/^()<>",0,9);
if(pos2!=std::string::npos)
return false;
delete _leaf;
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;
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());
}
}
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;
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)
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;
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--;
}
}
-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<double>::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<double>& 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)
+ {
+ std::size_t pos4=_expr.find_first_not_of(FIGURES,pos3,10);
+ if(pos4==std::string::npos)
+ {//"x+1223334.223"
+ valuesInExpr.push_back(ReplaceAndTraduce(_expr,id,pos2,std::string::npos,delta));
+ break;
+ }
+ else
+ {
+ if(_expr[pos4]!='e' && _expr[pos4]!='E')
+ {//"x+1223334.223+x"
+ valuesInExpr.push_back(ReplaceAndTraduce(_expr,id,pos2,pos4,delta));
+ pos=pos4+delta;
+ continue;
+ }
+ else
+ {
+ if(++pos4<lgth)
+ {
+ if(_expr[pos4]=='+' || _expr[pos4]=='-')
+ pos4++;
+ if(pos4>=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<double>& valuesInExpr) throw(INTERP_KERNEL::Exception)
+{
+ if(_leaf)
+ _leaf->replaceValues(valuesInExpr);
+ else
+ {
+ for(std::list<ExprParser>::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;
}
for(std::vector<char>::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
for(std::vector<char>::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<std::string>& ass) const
{
for(std::list<ExprParser>::const_iterator iter=_sub_expr.begin();iter!=_sub_expr.end();iter++)
(*iter).compileX86LowLev(ass);
- for(std::list<Function *>::const_iterator iter2=_func_btw_sub_expr.begin();iter2!=_func_btw_sub_expr.end();iter2++)
- (*iter2)->operateX86(ass);
}
+ for(std::list<Function *>::const_iterator iter2=_func_btw_sub_expr.begin();iter2!=_func_btw_sub_expr.end();iter2++)
+ (*iter2)->operateX86(ass);
}
void ExprParser::compileX86_64LowLev(std::vector<std::string>& ass) const
{
for(std::list<ExprParser>::const_iterator iter=_sub_expr.begin();iter!=_sub_expr.end();iter++)
(*iter).compileX86_64LowLev(ass);
- for(std::list<Function *>::const_iterator iter2=_func_btw_sub_expr.begin();iter2!=_func_btw_sub_expr.end();iter2++)
- (*iter2)->operateX86(ass);
}
+ for(std::list<Function *>::const_iterator iter2=_func_btw_sub_expr.begin();iter2!=_func_btw_sub_expr.end();iter2++)
+ (*iter2)->operateX86(ass);
}
void LeafExprVal::compileX86(std::vector<std::string>& ass) const
-// 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__
virtual void fillValue(Value *val) const throw(INTERP_KERNEL::Exception) = 0;
virtual void compileX86(std::vector<std::string>& ass) const = 0;
virtual void compileX86_64(std::vector<std::string>& ass) const = 0;
+ virtual void replaceValues(const std::vector<double>& valuesInExpr) throw(INTERP_KERNEL::Exception) = 0;
static LeafExpr *buildInstanceFrom(const std::string& expr) throw(INTERP_KERNEL::Exception);
};
void compileX86(std::vector<std::string>& ass) const;
void compileX86_64(std::vector<std::string>& ass) const;
void fillValue(Value *val) const throw(INTERP_KERNEL::Exception);
+ void replaceValues(const std::vector<double>& valuesInExpr) throw(INTERP_KERNEL::Exception);
private:
double _value;
};
std::string getVar() const { return _var_name; }
void prepareExprEvaluation(const std::vector<std::string>& vars) const throw(INTERP_KERNEL::Exception);
void prepareExprEvaluationVec() const throw(INTERP_KERNEL::Exception);
+ void replaceValues(const std::vector<double>& valuesInExpr) throw(INTERP_KERNEL::Exception);
static bool isRecognizedKeyVar(const std::string& var, int& pos);
public:
static const char END_OF_RECOGNIZED_VAR[];
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);
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<double>& valuesInExpr) throw(INTERP_KERNEL::Exception);
+ void replaceValues(const std::vector<double>& 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;
-// 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"
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)
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 !");
}
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+="\"";
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';
return true;
}
+LogFunction::~LogFunction()
+{
+}
+
+void LogFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
+{
+ Value *val=stack.back();
+ val->ln();
+}
+
+void LogFunction::operateX86(std::vector<std::string>& 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<Value *>& stack) const throw(INTERP_KERNEL::Exception)
+{
+ Value *val=stack.back();
+ val->log10();
+}
+
+void Log10Function::operateX86(std::vector<std::string>& 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;
{
return false;
}
+
+GreaterThanFunction::~GreaterThanFunction()
+{
+}
+
+void GreaterThanFunction::operate(std::vector<Value *>& 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<std::string>& 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<Value *>& 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<std::string>& 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<Value *>& 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<std::string>& 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;
+}
+
-// 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__
//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
static const char REPR[];
};
+ class INTERPKERNELEXPREVAL_EXPORT LogFunction : public UnaryFunction
+ {
+ public:
+ ~LogFunction();
+ void operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception);
+ void operateX86(std::vector<std::string>& 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<Value *>& stack) const throw(INTERP_KERNEL::Exception);
+ void operateX86(std::vector<std::string>& 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:
public:
static const char REPR[];
};
+
+ class INTERPKERNELEXPREVAL_EXPORT GreaterThanFunction : public BinaryFunction
+ {
+ public:
+ ~GreaterThanFunction();
+ void operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception);
+ void operateX86(std::vector<std::string>& 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<Value *>& stack) const throw(INTERP_KERNEL::Exception);
+ void operateX86(std::vector<std::string>& 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<Value *>& stack) const throw(INTERP_KERNEL::Exception);
+ void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
+ const char *getRepr() const;
+ bool isACall() const;
+ public:
+ static const char REPR[];
+ };
}
#endif
-// 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"
-// 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__
-// 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"
_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);
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<double>::max():-std::numeric_limits<double>::max());
+}
+
+Value *ValueDouble::lowerThan(const Value *other) const throw(INTERP_KERNEL::Exception)
+{
+ const ValueDouble *valC=checkSameType(other);
+ return new ValueDouble(_data<valC->_data?std::numeric_limits<double>::max():-std::numeric_limits<double>::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<double>::max())
+ return new ValueDouble(theC->_data);
+ if(_data==-std::numeric_limits<double>::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<const ValueDouble *>(val);
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);
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);
{
double *it=std::find_if(_dest_data,_dest_data+_sz_dest_data,std::bind2nd(std::less_equal<double>(),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<double,double>(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<double>(),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<double,double>(std::log10));
+}
+
Value *ValueDoubleExpr::plus(const Value *other) const throw(INTERP_KERNEL::Exception)
{
const ValueDoubleExpr *otherC=static_cast<const ValueDoubleExpr *>(other);
std::transform(_dest_data,_dest_data+_sz_dest_data,otherC->getData(),ret->getData(),std::ptr_fun<const double&, const double&, const double& >(std::min));
return ret;
}
+
+Value *ValueDoubleExpr::greaterThan(const Value *other) const throw(INTERP_KERNEL::Exception)
+{
+ const ValueDoubleExpr *otherC=static_cast<const ValueDoubleExpr *>(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<double>::max());
+ return ret;
+ }
+ std::fill(ret->getData(),ret->getData()+_sz_dest_data,std::numeric_limits<double>::max());
+ return ret;
+}
+
+Value *ValueDoubleExpr::lowerThan(const Value *other) const throw(INTERP_KERNEL::Exception)
+{
+ const ValueDoubleExpr *otherC=static_cast<const ValueDoubleExpr *>(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<double>::max());
+ return ret;
+ }
+ std::fill(ret->getData(),ret->getData()+_sz_dest_data,std::numeric_limits<double>::max());
+ return ret;
+}
+
+Value *ValueDoubleExpr::ifFunc(const Value *the, const Value *els) const throw(INTERP_KERNEL::Exception)
+{
+ const ValueDoubleExpr *theC=static_cast<const ValueDoubleExpr *>(the);
+ const ValueDoubleExpr *elsC=static_cast<const ValueDoubleExpr *>(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<double>::max();
+ okmin=_dest_data[i]==-std::numeric_limits<double>::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 !");
+ }
+}
-// 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__
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;
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
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);
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);
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);
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);
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);
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;
-# 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
--- /dev/null
+// 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 <math.h>
+#include <algorithm>
+#include <sstream>
+
+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 !");
+}
--- /dev/null
+// 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 <vector>
+
+namespace INTERP_KERNEL
+{
+ typedef std::vector<double> DataVector;
+ typedef std::vector<int> 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<GaussInfo*> GaussInfoVector;
+ GaussInfoVector _my_gauss_info;
+ };
+}
+#endif //INTERPKERNELGAUSS
--- /dev/null
+# 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
-// 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__
-// 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__
-// 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"
-// 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__
-// 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"
-// 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__
-// 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"
-// 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__
-// 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"
MergePoints commonNode;
for(int i=0;i<nbOfV1;i++)
{
- std::vector<double>::const_iterator iter=find_if(distrib2.begin()+1,distrib2.end(),bind2nd(std::greater_equal<double>(),distrib1[i]));
+ std::vector<double>::const_iterator iter=find_if(distrib2.begin()+1,distrib2.end(),bind2nd(std::greater_equal<double>(),distrib1[i]));
if(iter!=distrib2.end())
{
for(int j=(iter-1)-distrib2.begin();j<nbOfV2;j++)
-// 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 __INTERPKERNELGEO2DEDGE_HXX__
-// 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 __INTERPKERNELGEO2DEDGE_TXX__
#define __INTERPKERNELGEO2DEDGE_TXX__
-// 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 "InterpKernelGeo2DEdgeArcCircle.hxx"
-// 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 __INTERPKERNELGEO2DEDGEARCCIRCLE_HXX__
-// 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 "InterpKernelGeo2DEdgeInfLin.hxx"
-// 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 __INTERPKERNELGEO2DEDGEINFLIN_HXX__
bool isIn(double characterVal) const { return true; }
void dynCastFunction(const EdgeLin * &seg,
const EdgeArcCircle * &arcSeg) const { seg=this; }
- void dumpInXfigFile(std::ostream& stream) const { }
private:
~EdgeInfLin() { }
};
-// 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 "InterpKernelGeo2DEdgeLin.hxx"
-// 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 __INTERPKERNELGEO2DEDGELIN_HXX__
-// 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 "InterpKernelGeo2DElementaryEdge.hxx"
-// 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 __INTERPKERNELGEO2DELEMENTARYEDGE_HXX__
-// 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 "InterpKernelGeo2DNode.hxx"
-// 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 __INTERPKERNELGEO2DNODE_HXX__
-// 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 "InterpKernelGeo2DPrecision.hxx"
-// 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 __INTERPKERNELGEO2DPRECISION_HXX__
-// 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 "InterpKernelGeo2DQuadraticPolygon.hxx"
-// 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 __INTERPKERNELGEO2DQUADRATICPOLYGON_HXX__
-# 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
-// 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 __GEOMETRIC2DINTERSECTOR_HXX__
-// 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 __GEOMETRIC2DINTERSECTOR_TXX__
#define __GEOMETRIC2DINTERSECTOR_TXX__
std::vector<Node *> nodes(nbNodes);
for(int i=0;i<nbNodes;i++)
nodes[i]=new Node(coords[i*SPACEDIM],coords[i*SPACEDIM+1]);
- if(!CellModel::getCellModel(type).isQuadratic())
+ if(!CellModel::GetCellModel(type).isQuadratic())
return QuadraticPolygon::buildLinearPolygon(nodes);
else
return QuadraticPolygon::buildArcCirclePolygon(nodes);
std::vector<Node *> nodes(nbOfPoints);
for(int i=0;i<nbOfPoints;i++)
nodes[i]=new Node(PlanarIntersector<MyMeshType,MyMatrix>::_coordsT+OTT<ConnType,numPol>::coo2C(startOfCellNodeConn[i])*SPACEDIM);
- if(CellModel::getCellModel(type).isQuadratic())
+ if(CellModel::GetCellModel(type).isQuadratic())
return QuadraticPolygon::buildLinearPolygon(nodes);
else
return QuadraticPolygon::buildArcCirclePolygon(nodes);
-// 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__
-// 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__
-// 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__
--- /dev/null
+// 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 <algorithm>
+#include <sstream>
+#include <numeric>
+#include <cstring>
+#include <limits>
+#include <vector>
+#include <list>
+#include <set>
+
+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<int> 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<lgth;i++)
+ if(std::find(tmp,tmp+newPos,conn[i])==tmp+newPos)
+ tmp[newPos++]=conn[i];
+ INTERP_KERNEL::NormalizedCellType ret=tryToUnPoly2D(tmp,newPos,retConn,retLgth);
+ delete [] tmp;
+ return ret;
+ }
+ if(cm.getDimension()==3)
+ {
+ int nbOfFaces,lgthOfPolyhConn;
+ int *zipFullReprOfPolyh=getFullPolyh3DCell(type,conn,lgth,nbOfFaces,lgthOfPolyhConn);
+ INTERP_KERNEL::NormalizedCellType ret=tryToUnPoly3D(zipFullReprOfPolyh,nbOfFaces,lgthOfPolyhConn,retConn,retLgth);
+ delete [] zipFullReprOfPolyh;
+ return ret;
+ }
+ throw INTERP_KERNEL::Exception("CellSimplify::simplifyDegeneratedCell : works only with 2D and 3D cell !");
+}
+
+
+/*!
+ * This static method tries to unpolygonize a cell whose connectivity is given by 'conn' and 'lgth'.
+ * Contrary to INTERP_KERNEL::CellSimplify::simplifyDegeneratedCell method 'conn' and 'retConn' do not overlap.
+ */
+INTERP_KERNEL::NormalizedCellType CellSimplify::tryToUnPoly2D(const int *conn, int lgth, int *retConn, int& retLgth)
+{
+ retLgth=lgth;
+ std::copy(conn,conn+lgth,retConn);
+ switch(lgth)
+ {
+ case 3:
+ return INTERP_KERNEL::NORM_TRI3;
+ case 4:
+ return INTERP_KERNEL::NORM_QUAD4;
+ default:
+ return INTERP_KERNEL::NORM_POLYGON;
+ }
+}
+
+/*!
+ * This method takes as input a 3D linear cell and put its representation in returned array. Warning the returned array has to be deallocated.
+ * The length of the returned array is specified by out parameter
+ * The format of output array is the following :
+ * 1,2,3,-1,3,4,2,-1,3,4,1,-1,1,2,4,NORM_TRI3,NORM_TRI3,NORM_TRI3 (faces type at the end of classical polyhedron nodal description)
+ */
+int *CellSimplify::getFullPolyh3DCell(INTERP_KERNEL::NormalizedCellType type, const int *conn, int lgth,
+ int& retNbOfFaces, int& retLgth)
+{
+ const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(type);
+ unsigned nbOfFaces=cm.getNumberOfSons2(conn,lgth);
+ int *tmp=new int[nbOfFaces*(lgth+1)];
+ int *work=tmp;
+ std::vector<int> faces;
+ for(unsigned j=0;j<nbOfFaces;j++)
+ {
+ INTERP_KERNEL::NormalizedCellType type;
+ unsigned offset=cm.fillSonCellNodalConnectivity2(j,conn,lgth,work,type);
+ //
+ int *tmp2=new int[offset];
+ tmp2[0]=work[0];
+ int newPos=1;
+ for(unsigned k=1;k<offset;k++)
+ if(std::find(tmp2,tmp2+newPos,work[k])==tmp2+newPos)
+ tmp2[newPos++]=work[k];
+ if(newPos<3)
+ {
+ delete [] tmp2;
+ continue;
+ }
+ int tmp3;
+ faces.push_back(tryToUnPoly2D(tmp2,newPos,work,tmp3));
+ delete [] tmp2;
+ //
+ work+=newPos;
+ *work++=-1;
+ }
+ std::copy(faces.begin(),faces.end(),--work);
+ retNbOfFaces=faces.size();
+ retLgth=std::distance(tmp,work);
+ return tmp;
+}
+
+/*!
+ * This static method tries to unpolygonize a cell whose connectivity is given by 'conn' (format is the same as specified in
+ * method INTERP_KERNEL::CellSimplify::getFullPolyh3DCell ) and 'lgth'+'nbOfFaces'.
+ * Contrary to INTERP_KERNEL::CellSimplify::simplifyDegeneratedCell method 'conn' and 'retConn' do not overlap.
+ */
+INTERP_KERNEL::NormalizedCellType CellSimplify::tryToUnPoly3D(const int *conn, int nbOfFaces, int lgth, int *retConn, int& retLgth)
+{
+ std::set<int> 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<int> tmp2;
+ std::set<int> bases(baseFace,baseFace+lgthBaseFace);
+ std::set<int> sides(sideFace,sideFace+4);
+ std::set_intersection(bases.begin(),bases.end(),sides.begin(),sides.end(),std::back_insert_iterator< std::vector<int> >(tmp2));
+ if(tmp2.size()!=2)
+ return false;
+ std::vector< std::pair<int,int> > baseEdges(lgthBaseFace);
+ std::vector< std::pair<int,int> > oppEdges(lgthBaseFace);
+ std::vector< std::pair<int,int> > sideEdges(4);
+ for(int i=0;i<lgthBaseFace;i++)
+ {
+ baseEdges[i]=std::pair<int,int>(baseFace[i],baseFace[(i+1)%lgthBaseFace]);
+ oppEdges[i]=std::pair<int,int>(retConn[i],retConn[(i+1)%lgthBaseFace]);
+ }
+ for(int i=0;i<4;i++)
+ sideEdges[i]=std::pair<int,int>(sideFace[i],sideFace[(i+1)%4]);
+ std::vector< std::pair<int,int> > tmp;
+ std::set< std::pair<int,int> > baseEdgesS(baseEdges.begin(),baseEdges.end());
+ std::set< std::pair<int,int> > sideEdgesS(sideEdges.begin(),sideEdges.end());
+ std::set_intersection(baseEdgesS.begin(),baseEdgesS.end(),sideEdgesS.begin(),sideEdgesS.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(tmp));
+ if(tmp.empty())
+ {
+ //reverse sideFace
+ for(int i=0;i<4;i++)
+ {
+ std::pair<int,int> p=sideEdges[i];
+ std::pair<int,int> r(p.second,p.first);
+ sideEdges[i]=r;
+ }
+ //end reverse sideFace
+ std::set< std::pair<int,int> > baseEdgesS(baseEdges.begin(),baseEdges.end());
+ std::set< std::pair<int,int> > sideEdgesS(sideEdges.begin(),sideEdges.end());
+ std::set_intersection(baseEdgesS.begin(),baseEdgesS.end(),sideEdgesS.begin(),sideEdgesS.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(tmp));
+ if(tmp.empty())
+ return false;
+ }
+ if(tmp.size()!=1)
+ return false;
+ bool found=false;
+ std::pair<int,int> 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<int,int> >::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<lgthBaseFace;i++)
+ tmp3[(offset+i)%lgthBaseFace]=oppEdges[i].first;
+ std::copy(tmp3,tmp3+lgthBaseFace,retConn);
+ delete [] tmp3;
+ return true;
+}
+
+bool CellSimplify::isWellOriented(const int *baseFace, int *retConn, const int *sideFace, int lgthBaseFace)
+{
+ return true;
+}
+
+/*!
+ * This method is trying to permute the connectivity of 'oppFace' face so that the k_th node of 'baseFace' is associated to the
+ * k_th node in retConnOfOppFace. Excluded faces 'baseFace' and 'oppFace' all the other faces in 'conn' must be QUAD4 faces.
+ * If the arragement process succeeds true is returned and retConnOfOppFace is filled.
+ */
+bool CellSimplify::tryToArrangeOppositeFace(const int *conn, int lgth, int lgthBaseFace, const int *baseFace, const int *oppFace, int nbOfFaces, int *retConnOfOppFace)
+{
+ retConnOfOppFace[0]=oppFace[0];
+ for(int j=1;j<lgthBaseFace;j++)
+ retConnOfOppFace[j]=oppFace[lgthBaseFace-j];
+ const int *curFace=conn;
+ int sideFace=0;
+ bool ret=true;
+ for(int i=0;i<nbOfFaces && ret;i++)
+ {
+ if(curFace!=baseFace && curFace!=oppFace)
+ {
+ if(sideFace==0)
+ ret=orientOppositeFace(baseFace,retConnOfOppFace,curFace,lgthBaseFace);
+ else
+ ret=isWellOriented(baseFace,retConnOfOppFace,curFace,lgthBaseFace);
+ sideFace++;
+ }
+ curFace=std::find(curFace,conn+lgth,-1);
+ curFace++;
+ }
+ return ret;
+}
+
+/*!
+ * Cell with 'conn' connectivity has been detected as a good candidate. Full check of this. If yes NORM_HEXA8 is returned.
+ * This method is only callable if in 'conn' there is 8 nodes and 6 faces.
+ * If fails a POLYHED is returned.
+ */
+INTERP_KERNEL::NormalizedCellType CellSimplify::tryToUnPolyHex8(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>(),(int)INTERP_KERNEL::NORM_QUAD4))==conn+lgth+nbOfFaces)
+ {//6 faces are QUAD4.
+ int oppositeFace=-1;
+ std::set<int> conn1(conn,conn+4);
+ for(int i=1;i<6 && oppositeFace<0;i++)
+ {
+ std::vector<int> tmp;
+ std::set<int> 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<int> >(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<int> tmp;
+ std::set<int> conn1(connHexag0,connHexag0+6);
+ std::set<int> conn2(connHexag1,connHexag1+6);
+ std::set_intersection(conn1.begin(),conn1.end(),conn2.begin(),conn2.end(),std::back_insert_iterator< std::vector<int> >(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<int> tmp;
+ std::set<int> conn1(tri_0,tri_0+3);
+ std::set<int> conn2(tri_1,tri_1+3);
+ std::set_intersection(conn1.begin(),conn1.end(),conn2.begin(),conn2.end(),std::back_insert_iterator< std::vector<int> >(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<int> 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<int> tmp;
+ std::set<int> conn2(w,w+3);
+ std::set_intersection(conn2.begin(),conn2.end(),quad4S.begin(),quad4S.end(),std::back_insert_iterator< std::vector<int> >(tmp));
+ ok=tmp.size()==2;
+ tmp.clear();
+ std::set_difference(conn2.begin(),conn2.end(),quad4S.begin(),quad4S.end(),std::back_insert_iterator< std::vector<int> >(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>(),(int)INTERP_KERNEL::NORM_TRI3))==conn+lgth+nbOfFaces)
+ {
+ std::set<int> tribase(conn,conn+3);
+ int point=-1;
+ bool ok=true;
+ for(int i=1;i<4 && ok;i++)
+ {
+ std::vector<int> tmp;
+ std::set<int> 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<int> >(tmp));
+ ok=tmp.size()==2;
+ tmp.clear();
+ std::set_difference(conn2.begin(),conn2.end(),tribase.begin(),tribase.end(),std::back_insert_iterator< std::vector<int> >(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;
+}
--- /dev/null
+// 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
-// 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_
int _val;
};
- class Row : public std::vector< typename std::pair<int,T> >
+ class Row : public std::vector< std::pair<int,T> >
{
public:
- Row():std::vector< typename std::pair<int,T> >(){};
+ Row():std::vector< std::pair<int,T> >(){};
Row (const Row& row)
{
this->resize(row.size());
}
typename std::vector< std::pair<int,T> >::const_iterator find(int elem) const
{
- return std::find_if(std::vector< typename std::pair<int,T> >::begin(),std::vector< typename std::pair<int,T> >::end(),KeyComparator(elem));
+ return std::find_if(std::vector< std::pair<int,T> >::begin(),std::vector< std::pair<int,T> >::end(),KeyComparator(elem));
}
- void erase(int elem) { std::vector< typename std::pair<int,T> >::erase(std::find_if(std::vector< typename std::pair<int,T> >::begin(),std::vector< typename std::pair<int,T> >::end(),KeyComparator(elem))); }
+ void erase(int elem) { std::vector< std::pair<int,T> >::erase(std::find_if(std::vector< std::pair<int,T> >::begin(),std::vector< std::pair<int,T> >::end(),KeyComparator(elem))); }
- void insert(const std::pair<int,T>& myPair) { push_back(myPair); }
+ void insert(const std::pair<int,T>& myPair) { vector<std::pair<int,T> >::push_back(myPair); }
};
private:
-// 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"
-// 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_
-// 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__
-// 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__
-// 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__
-// 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__
-// 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__
-// 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__
-// 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__
--- /dev/null
+// 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<Interpolation2DCurve>(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);
+ }
+}
-// 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__
+++ /dev/null
-// 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<Interpolation2DCurve>(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
--- /dev/null
+// 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<Interpolation3D>(io)
+ {
+ }
+}
-// 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__
-// 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__
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<Interpolation3D>(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
--- /dev/null
+// 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<Interpolation3DSurf>(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<Interpolation3DSurf>::setOptions(precision,printLevel,intersectionType, orientation);
+ InterpolationPlanar<Interpolation3DSurf>::setDoRotate(doRotate);
+ InterpolationPlanar<Interpolation3DSurf>::setMedianPlane(medianPlane);
+ }
+}
-// 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__
+++ /dev/null
-// 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<Interpolation3DSurf>(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<Interpolation3DSurf>::setOptions(precision,printLevel,intersectionType, orientation);
- InterpolationPlanar<Interpolation3DSurf>::setDoRotate(doRotate);
- InterpolationPlanar<Interpolation3DSurf>::setMedianPlane(medianPlane);
- }
-}
-
-#endif
-// 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
-// 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
-// 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
-// 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
-// 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__
-// 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__
-// 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"
-// 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__
-// 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__
-// 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__
-// 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__
}
/*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */
- /* 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,
}
/*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */
- /* 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 */
/*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */
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
// 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<double>::min() )
+ {
+ //sol[0]=1; sol[1]=sol[2]=sol[3]=0;
+ return false; // no solution
}
- }
- if ( max < std::numeric_limits<double>::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<double>::min() ) {
- //sol[0]=1; sol[1]=sol[2]=sol[3]=0;
- return false; // no solution
- }
+ if ( std::fabs( mRow[ nbRow-1 ] ) < std::numeric_limits<double>::min() )
+ {
+ //sol[0]=1; sol[1]=sol[2]=sol[3]=0;
+ return false; // no solution
+ }
mRow[ nbRow ] /= mRow[ nbRow-1 ];
// calculate solution (back substitution)
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<unsigned SZ, unsigned NB_OF_RES>
+ 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;k<SZ;k++)
+ {
+ np=nr*k+k;
+ if(fabs(B[np])<eps)
+ {
+ n=k;
+ do
+ {
+ n++;
+ if(fabs(B[nr*k+n])>eps)
+ {/* Rows permutation */
+ for(m=0;m<nr;m++)
+ std::swap(B[nr*k+m],B[nr*n+m]);
+ }
+ }
+ while (n<(int)SZ);
+ }
+ s=B[np];//s is the Pivot
+ std::transform(B+k*nr,B+(k+1)*nr,B+k*nr,std::bind2nd(std::divides<double>(),s));
+ for(j=0;j<SZ;j++)
+ {
+ if(j!=k)
+ {
+ g=B[j*nr+k];
+ for(mb=k;mb<nr;mb++)
+ B[j*nr+mb]-=B[k*nr+mb]*g;
+ }
+ }
+ }
+ for(j=0;j<NB_OF_RES;j++)
+ for(k=0;k<SZ;k++)
+ solutions[j*SZ+k]=B[nr*k+SZ+j];
+ //
+ return true;
+ }
/*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _*/
/* Calculate barycentric coordinates of a 2D point p */
bc[2] = 1. - bc[0] - bc[1];
}
- /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _*/
- /* Calculate barycentric coordinates of a point p */
- /* with respect to triangle or tetra verices. */
- /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _*/
-
- inline void barycentric_coords(const std::vector<const double*>& 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<const double*>& 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<double>::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<double>::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<double>::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<double>::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 !");
}
}
}
/*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */
- /*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. */
/*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */
/*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */
/* 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 */
/*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _*/
/* 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,
std::vector<double>& 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;
/*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _*/
/* 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,
}
/*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _*/
- /* 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. */
/*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _*/
/*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */
- /* fonction pour reconstituer un polygone convexe à partir */
+ /* fonction pour reconstituer un polygone convexe a partir */
/* d'un nuage de point. */
/*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */
/*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _*/
/* 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<int DIM> inline void intersec_de_polygone(const double * Coords_A, const double * Coords_B,
int nb_NodesA, int nb_NodesB,
-// 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__
-// 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__
-// 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__
-// 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__
-// 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__
-// 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__
-// 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__
-// 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__
-// 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__
-// 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__
-// 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__
-// 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__
-// 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
-// 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
-// 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
-// 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
-// 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
-// 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
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]],
-// 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
-// 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
-// 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_
-# 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
#
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
INTERPKERNELDefines.hxx \
InterpKernelMatrix.hxx \
InterpKernelMeshQuality.hxx \
+InterpKernelCellSimplify.hxx \
Interpolation.hxx \
Interpolation.txx \
Interpolation2D.hxx \
Interpolation3D.hxx \
Interpolation3D.txx \
Interpolation3DSurf.hxx \
-Interpolation3DSurf.txx \
InterpolationOptions.hxx \
InterpolationPlanar.hxx \
InterpolationPlanar.txx \
Interpolation1D.hxx \
Interpolation1D.txx \
Interpolation2DCurve.hxx \
-Interpolation2DCurve.txx \
InterpolationCurve.hxx \
InterpolationCurve.txx \
DirectedBoundingBox.hxx
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)
-// 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__
-// 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__
/////////////////////////////////////////////////////////////////////
/// 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
-// 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__
-// 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__
-// 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__
-// 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__
-// 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__
}
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<SPACEDIM>(Coords_A,&Coords_A[i_A1])= " << distance2<SPACEDIM>(Coords_A,&Coords_A[i_A1]) << std::endl;
std::cout << "abs(normal_A) = " << fabs(normal_A[0]) << " ; " <<fabs( normal_A[1]) << " ; " << fabs(normal_A[2]) << std::endl;
-// 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 __PLANARINTERSECTORP0P0_HXX__
-// 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 __PLANARINTERSECTORP0P0_TXX__
#define __PLANARINTERSECTORP0P0_TXX__
-// 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 __PLANARINTERSECTORP0P1_HXX__
-// 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 __PLANARINTERSECTORP0P1_TXX__
#define __PLANARINTERSECTORP0P1_TXX__
if(SPACEDIM==3)
orientation=PlanarIntersector<MyMeshType,MyMatrix>::projectionThis(&sourceCellCoordsTmp[0],quadrangle,sourceCellCoords.size()/SPACEDIM,4);
NormalizedCellType tS=PlanarIntersector<MyMeshType,MyMatrix>::_meshS.getTypeOfElement(OTT<ConnType,numPol>::indFC(iS));
- double surf=orientation*intersectGeometryWithQuadrangle(quadrangle,sourceCellCoordsTmp,CellModel::getCellModel(tS).isQuadratic());
+ double surf=orientation*intersectGeometryWithQuadrangle(quadrangle,sourceCellCoordsTmp,CellModel::GetCellModel(tS).isQuadratic());
surf=PlanarIntersector<MyMeshType,MyMatrix>::getValueRegardingOption(surf);
if(surf!=0.)
{
-// 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__
-// 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__
-// 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__
-// 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__
int orientation=1;
PlanarIntersector<MyMeshType,MyMatrix>::getRealTargetCoordinates(OTT<ConnType,numPol>::indFC(icellT),targetCellCoords);
NormalizedCellType tT=PlanarIntersector<MyMeshType,MyMatrix>::_meshT.getTypeOfElement(OTT<ConnType,numPol>::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<ConnType>::const_iterator iter=icellsS.begin();iter!=icellsS.end();iter++)
{
-// 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__
-// 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__
std::vector<double> * tgtCoords = & tgtCellCoords;
int tgtNbNodes = tgtCellCoords.size()/SPACEDIM;
NormalizedCellType tT=PlanarIntersector<MyMeshType,MyMatrix>::_meshT.getTypeOfElement(OTT<ConnType,numPol>::indFC(icellT));
- bool isTargetQuad=CellModel::getCellModel(tT).isQuadratic();
+ bool isTargetQuad=CellModel::GetCellModel(tT).isQuadratic();
typename MyMatrix::value_type& resRow=res[icellT];
-// 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__
-// 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__
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<MyMeshType,MyMatrix>::projectionThis(&CoordsS[0],littleTargetCell,3,3);
-// 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__
-// 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__
-// 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__
-// 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__
-// 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__
-// 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__
std::vector<Node *> nodes(nbNodes);
for(int i=0;i<nbNodes;i++)
nodes[i]=new Node(coords[i*SPACEDIM],coords[i*SPACEDIM+1]);
- if(!CellModel::getCellModel(type).isQuadratic())
+ if(!CellModel::GetCellModel(type).isQuadratic())
return QuadraticPolygon::buildLinearPolygon(nodes);
else
return QuadraticPolygon::buildArcCirclePolygon(nodes);
std::vector<Node *> nodes(nbOfPoints);
for(int i=0;i<nbOfPoints;i++)
nodes[i]=new Node(PlanarIntersector<MyMeshType,MyMatrix>::_coordsT+OTT<ConnType,numPol>::coo2C(startOfCellNodeConn[i])*SPACEDIM);
- if(CellModel::getCellModel(type).isQuadratic())
+ if(CellModel::GetCellModel(type).isQuadratic())
return QuadraticPolygon::buildLinearPolygon(nodes);
else
return QuadraticPolygon::buildArcCirclePolygon(nodes);
-// 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__
-// 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__
for(typename std::vector<ConnType>::const_iterator iterCellS=srcCells.begin();iterCellS!=srcCells.end();iterCellS++)
{
NormalizedCellType tS=Intersector3DP0P0<MyMeshType,MyMatrix>::_src_mesh.getTypeOfElement(OTT<ConnType,numPol>::indFC(*iterCellS));
- const CellModel& cmTypeS=CellModel::getCellModel(tS);
+ const CellModel& cmTypeS=CellModel::GetCellModel(tS);
std::vector<ConnType> connOfCurCellS;
Intersector3DP0P0<MyMeshType,MyMatrix>::getConnOfSourceCell(OTT<ConnType,numPol>::indFC(*iterCellS),connOfCurCellS);
if(PointLocatorAlgos<MyMeshType>::isElementContainsPointAlg3D(bary,&connOfCurCellS[0],connOfCurCellS.size(),coordsS,cmTypeS,_precision))
-// 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__
-// 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__
for(typename std::vector<ConnType>::const_iterator iterCellS=srcCells.begin();iterCellS!=srcCells.end();iterCellS++)
{
NormalizedCellType tS=Intersector3DP0P1<MyMeshType,MyMatrix>::_src_mesh.getTypeOfElement(OTT<ConnType,numPol>::indFC(*iterCellS));
- const CellModel& cmTypeS=CellModel::getCellModel(tS);
+ const CellModel& cmTypeS=CellModel::GetCellModel(tS);
std::vector<ConnType> connOfCurCellS;
Intersector3DP0P1<MyMeshType,MyMatrix>::getConnOfSourceCell(OTT<ConnType,numPol>::indFC(*iterCellS),connOfCurCellS);
for(int nodeIdT=0;nodeIdT<nbNodesT;nodeIdT++)
-// 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 __POINTLOCATOR3DINTERSECTORP1P0_HXX__
-// 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 __POINTLOCATOR3DINTERSECTORP1P0_TXX__
#define __POINTLOCATOR3DINTERSECTORP1P0_TXX__
NormalizedCellType tS=Intersector3DP1P0<MyMeshType,MyMatrix>::_src_mesh.getTypeOfElement(OTT<ConnType,numPol>::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<ConnType> connOfCurCellS;
Intersector3DP1P0<MyMeshType,MyMatrix>::getConnOfSourceCell(OTT<ConnType,numPol>::indFC(*iterCellS),connOfCurCellS);
if( PointLocatorAlgos<MyMeshType>::isElementContainsPointAlg3D(baryT,&connOfCurCellS[0],connOfCurCellS.size(),coordsS,cmTypeS,_precision) )
-// 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__
-// 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__
NormalizedCellType tS=Intersector3DP1P1<MyMeshType,MyMatrix>::_src_mesh.getTypeOfElement(OTT<ConnType,numPol>::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<MyMeshType,MyMatrix>::getStartConnOfTargetCell(targetCell);
for(int nodeIdT=0;nodeIdT<nbOfNodesT;nodeIdT++)
{
-// 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 __POINTLOCATORALGOS_TXX__
#define __POINTLOCATORALGOS_TXX__
#include "BBTree.txx"
#include <list>
+#include <set>
#include <limits>
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)
{
{
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)
return (min_sign!=-1 || max_sign!=1);
}
};
+
+ template<class MyMeshType>
+ class PointLocatorInSimplex : public PointLocatorAlgos<MyMeshType>
+ {
+ const MyMeshType& _mesh;
+ public:
+ PointLocatorInSimplex(const MyMeshType& mesh)
+ :PointLocatorAlgos<MyMeshType>(mesh),_mesh(mesh)
+ {
+ }
+
+ //================================================================================
+ /*!
+ * \brief Returns nodes composing the simplex the point x is in
+ */
+ //================================================================================
+
+ virtual std::list<int> locates(const double* x, double eps)
+ {
+ typedef typename MyMeshType::MyConnType ConnType;
+ const NumberingPolicy numPol=MyMeshType::My_numPol;
+
+ std::list<int> simplexNodes;
+ std::list<int> candidates = PointLocatorAlgos<MyMeshType>::locates(x,eps);
+ std::list<int>::iterator eIt = candidates.begin();
+ for ( ; eIt != candidates.end(); ++eIt )
+ {
+ const int i = OTT<ConnType,numPol>::ind2C( *eIt );
+ const double* coords= _mesh.getCoordinatesPtr();
+ const ConnType* conn=_mesh.getConnectivityPtr();
+ const ConnType* conn_index= _mesh.getConnectivityIndexPtr();
+ const ConnType* conn_elem=conn+OTT<ConnType,numPol>::ind2C(conn_index[i]);
+ int conn_elem_sz=conn_index[i+1]-conn_index[i];
+ NormalizedCellType type=_mesh.getTypeOfElement(OTT<ConnType,numPol>::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<int> 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<int> 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
-// 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__
-// 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__
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
{
-// 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__
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();
-// 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__
-// 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__
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();
-// 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__
-// 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__
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();
-// 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__
-// 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__
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();
-// 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__
-// 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__
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();
-// 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__
-// 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__
-// 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__
-// 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__
// get type of cell
NormalizedCellType normCellType=_src_mesh.getTypeOfElement(OTT<ConnType,numPol>::indFC(element));
- const CellModel& cellModelCell=CellModel::getCellModel(normCellType);
+ const CellModel& cellModelCell=CellModel::GetCellModel(normCellType);
unsigned nbOfNodes4Type=cellModelCell.isDynamic() ? _src_mesh.getNumberOfNodesOfElement(OTT<ConnType,numPol>::indFC(element)) : cellModelCell.getNumberOfNodes();
// halfspace filtering
bool isOutside[8] = {true, true, true, true, true, true, true, true};
{
// get sons connectivity
NormalizedCellType faceType;
- int *faceNodes, nbFaceNodes;
+ int *faceNodes, nbFaceNodes=-1;
if ( cellModelCell.isDynamic() )
{
faceNodes=new int[nbOfNodes4Type];
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);
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)
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]);
// get type of cell and nb of cell nodes
NormalizedCellType normCellType=_target_mesh.getTypeOfElement(OTT<ConnType,numPol>::indFC(targetCell));
- const CellModel& cellModelCell=CellModel::getCellModel(normCellType);
+ const CellModel& cellModelCell=CellModel::GetCellModel(normCellType);
unsigned nbOfCellNodes=cellModelCell.isDynamic() ? _target_mesh.getNumberOfNodesOfElement(OTT<ConnType,numPol>::indFC(targetCell)) : cellModelCell.getNumberOfNodes();
// get nb of cell sons (faces)
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)
-// 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__
-// 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"
-// 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__
-// 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"
-// 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__
-// 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__
-// 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"
-// 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"
-// 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"
-// 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__
-// 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__
-// 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__
//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<nbNodesT-1; iT++)
-// 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 : UnitTetraIntersectionBary.cxx
int ind1 = (i+1)%3, ind2 = (i+2)%3; // indices of coords on i-th tetra side
int nbCutOnSide = 0;
- bool isSegmentOnEdge;
+ bool isSegmentOnEdge=false;
for ( int ip = 0; ip < nbPoints; ++ip )
{
int isSegmentEnd = ( ip % 2 );
-// 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 : UnitTetraIntersectionBary.hxx
-// 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 __VTKNORMALIZEDUNSTRUCTUREDMESH_HXX__
-// 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 __VTKNORMALIZEDUNSTRUCTUREDMESH_TXX__
#define __VTKNORMALIZEDUNSTRUCTUREDMESH_TXX__
-// 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 __VECTORUTILS_HXX__
-// 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 __VOLSURFFORMULAE_HXX__
-// 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 __VOLSURFUSER_HXX__
-// 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 __VOLSURFUSER_TXX__
#define __VOLSURFUSER_TXX__
coords+SPACEDIM*N8);
}
break;
-
+ case INTERP_KERNEL::NORM_HEXGP12:
+ {
+ const int connecHexa12[43]={
+ OTT<ConnType,numPol>::coo2C(connec[0]),OTT<ConnType,numPol>::coo2C(connec[1]),OTT<ConnType,numPol>::coo2C(connec[2]),OTT<ConnType,numPol>::coo2C(connec[3]),OTT<ConnType,numPol>::coo2C(connec[4]),OTT<ConnType,numPol>::coo2C(connec[5]),-1,
+ OTT<ConnType,numPol>::coo2C(connec[6]),OTT<ConnType,numPol>::coo2C(connec[11]),OTT<ConnType,numPol>::coo2C(connec[10]),OTT<ConnType,numPol>::coo2C(connec[9]),OTT<ConnType,numPol>::coo2C(connec[8]),OTT<ConnType,numPol>::coo2C(connec[7]),-1,
+ OTT<ConnType,numPol>::coo2C(connec[0]),OTT<ConnType,numPol>::coo2C(connec[6]),OTT<ConnType,numPol>::coo2C(connec[7]),OTT<ConnType,numPol>::coo2C(connec[1]),-1,
+ OTT<ConnType,numPol>::coo2C(connec[1]),OTT<ConnType,numPol>::coo2C(connec[7]),OTT<ConnType,numPol>::coo2C(connec[8]),OTT<ConnType,numPol>::coo2C(connec[2]),-1,
+ OTT<ConnType,numPol>::coo2C(connec[2]),OTT<ConnType,numPol>::coo2C(connec[8]),OTT<ConnType,numPol>::coo2C(connec[9]),OTT<ConnType,numPol>::coo2C(connec[3]),-1,
+ OTT<ConnType,numPol>::coo2C(connec[3]),OTT<ConnType,numPol>::coo2C(connec[9]),OTT<ConnType,numPol>::coo2C(connec[10]),OTT<ConnType,numPol>::coo2C(connec[4]),-1,
+ OTT<ConnType,numPol>::coo2C(connec[4]),OTT<ConnType,numPol>::coo2C(connec[10]),OTT<ConnType,numPol>::coo2C(connec[11]),OTT<ConnType,numPol>::coo2C(connec[5]),-1,
+ OTT<ConnType,numPol>::coo2C(connec[5]),OTT<ConnType,numPol>::coo2C(connec[11]),OTT<ConnType,numPol>::coo2C(connec[6]),OTT<ConnType,numPol>::coo2C(connec[0])};
+ return calculateVolumeForPolyh2<ConnType,numPol>(connecHexa12,43,coords);
+ }
case INTERP_KERNEL::NORM_POLYHED :
{
return calculateVolumeForPolyh2<ConnType,numPol>(connec,lgth,coords);
barycenterOfPolyhedron<ConnType,numPol>(conn,22,coords,res);
break;
}
+ case INTERP_KERNEL::NORM_HEXGP12:
+ {
+ const int connecHexa12[43]={
+ OTT<ConnType,numPol>::coo2C(connec[0]),OTT<ConnType,numPol>::coo2C(connec[1]),OTT<ConnType,numPol>::coo2C(connec[2]),OTT<ConnType,numPol>::coo2C(connec[3]),OTT<ConnType,numPol>::coo2C(connec[4]),OTT<ConnType,numPol>::coo2C(connec[5]),-1,
+ OTT<ConnType,numPol>::coo2C(connec[6]),OTT<ConnType,numPol>::coo2C(connec[11]),OTT<ConnType,numPol>::coo2C(connec[10]),OTT<ConnType,numPol>::coo2C(connec[9]),OTT<ConnType,numPol>::coo2C(connec[8]),OTT<ConnType,numPol>::coo2C(connec[7]),-1,
+ OTT<ConnType,numPol>::coo2C(connec[0]),OTT<ConnType,numPol>::coo2C(connec[6]),OTT<ConnType,numPol>::coo2C(connec[7]),OTT<ConnType,numPol>::coo2C(connec[1]),-1,
+ OTT<ConnType,numPol>::coo2C(connec[1]),OTT<ConnType,numPol>::coo2C(connec[7]),OTT<ConnType,numPol>::coo2C(connec[8]),OTT<ConnType,numPol>::coo2C(connec[2]),-1,
+ OTT<ConnType,numPol>::coo2C(connec[2]),OTT<ConnType,numPol>::coo2C(connec[8]),OTT<ConnType,numPol>::coo2C(connec[9]),OTT<ConnType,numPol>::coo2C(connec[3]),-1,
+ OTT<ConnType,numPol>::coo2C(connec[3]),OTT<ConnType,numPol>::coo2C(connec[9]),OTT<ConnType,numPol>::coo2C(connec[10]),OTT<ConnType,numPol>::coo2C(connec[4]),-1,
+ OTT<ConnType,numPol>::coo2C(connec[4]),OTT<ConnType,numPol>::coo2C(connec[10]),OTT<ConnType,numPol>::coo2C(connec[11]),OTT<ConnType,numPol>::coo2C(connec[5]),-1,
+ OTT<ConnType,numPol>::coo2C(connec[5]),OTT<ConnType,numPol>::coo2C(connec[11]),OTT<ConnType,numPol>::coo2C(connec[6]),OTT<ConnType,numPol>::coo2C(connec[0])};
+ barycenterOfPolyhedron<ConnType,numPol>(connecHexa12,43,coords,res);
+ break;
+ }
case NORM_POLYHED:
{
barycenterOfPolyhedron<ConnType,numPol>(connec,lgth,coords,res);
-// 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_
-// 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__
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 ; }
-// 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"
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
{
return new MEDCouplingCMesh(*this,recDeepCpy);
}
-void MEDCouplingCMesh::updateTime()
+void MEDCouplingCMesh::updateTime() const
{
if(_x_array)
updateTimeWith(*_x_array);
}
}
+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;
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--)
}
}
+std::set<INTERP_KERNEL::NormalizedCellType> 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<INTERP_KERNEL::NormalizedCellType> ret2;
+ ret2.insert(ret);
+ return ret2;
+}
+
int MEDCouplingCMesh::getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const
{
int ret=getNumberOfCells();
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;j<spaceDim;j++)
if(tabs[j])
coo.push_back(tabs[j]->getConstPointer()[tmp2[j]]);
{
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)
{
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)
{
}
}
-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)
{
if(*(thisArr[i]))
(*(thisArr[i]))->decrRef();
- (*(thisArr[i]))=arr;
+ (*(thisArr[i]))=const_cast<DataArrayDouble *>(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<DataArrayDouble *>(coordsX);
if(_x_array)
_x_array->incrRef();
if(_y_array)
_y_array->decrRef();
- _y_array=coordsY;
+ _y_array=const_cast<DataArrayDouble *>(coordsY);
if(_y_array)
_y_array->incrRef();
if(_z_array)
_z_array->decrRef();
- _z_array=coordsZ;
+ _z_array=const_cast<DataArrayDouble *>(coordsZ);
if(_z_array)
_z_array->incrRef();
declareAsNew();
}
-MEDCouplingUMesh *MEDCouplingCMesh::buildUnstructured() const
+/*!
+ * See MEDCouplingUMesh::checkTypeConsistencyAndContig for more information
+ */
+DataArrayInt *MEDCouplingCMesh::checkTypeConsistencyAndContig(const std::vector<int>& code, const std::vector<const DataArrayInt *>& 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);
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; idim<dim; idim++)
{
- DataArrayDouble *c=getCoordsAt(idim);
+ const DataArrayDouble *c=getCoordsAt(idim);
if(c)
{
const double *coords=c->getConstPointer();
for(int icell=0;icell<nbelem;icell++)
{
int tmp2[3];
- getPosFromId(icell,dim,tmp,tmp2);
+ GetPosFromId(icell,dim,tmp,tmp2);
area_vol[icell]=1.;
for(int i=0;i<dim;i++)
area_vol[icell]*=thisArr[i][tmp2[i]+1]-thisArr[i][tmp2[i]];
double *pt=ret->getPointer();
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;j<spaceDim;j++)
- tabsPtr[j]=tabs[j]->getConstPointer();
+ {
+ tabsPtr[j]=tabs[j]->getConstPointer();
+ ret->setInfoOnComponent(j,tabs[j]->getInfoOnComponent(0).c_str());
+ }
int tmp2[3];
for(int i=0;i<nbNodes;i++)
{
- getPosFromId(i,spaceDim,tmp,tmp2);
+ GetPosFromId(i,spaceDim,tmp,tmp2);
for(int j=0;j<spaceDim;j++)
pt[i*spaceDim+j]=tabsPtr[j][tmp2[j]];
}
double *pt=ret->getPointer();
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<double> tabsPtr[3];
for(int j=0;j<spaceDim;j++)
{
int sz=tabs[j]->getNbOfElems()-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<double>());
int tmp2[3];
for(int i=0;i<nbCells;i++)
{
- getPosFromId(i,spaceDim,tmp,tmp2);
+ GetPosFromId(i,spaceDim,tmp,tmp2);
for(int j=0;j<spaceDim;j++)
pt[i*spaceDim+j]=tabsPtr[j][tmp2[j]];
}
connI->decrRef();
}
-void MEDCouplingCMesh::getTinySerializationInformation(std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const
+void MEDCouplingCMesh::getTinySerializationInformation(std::vector<double>& tinyInfoD, std::vector<int>& tinyInfo, std::vector<std::string>& 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++)
{
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<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings) const
a2Ptr=std::copy(thisArr[i]->getConstPointer(),thisArr[i]->getConstPointer()+thisArr[i]->getNumberOfTuples(),a2Ptr);
}
-void MEDCouplingCMesh::unserialization(const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2,
+void MEDCouplingCMesh::unserialization(const std::vector<double>& tinyInfoD, const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2,
const std::vector<std::string>& 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++)
{
(*(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]);
}
-// 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__
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;
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<INTERP_KERNEL::NormalizedCellType> getAllGeoTypes() const;
int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const;
void getNodeIdsOfCell(int cellId, std::vector<int>& conn) const;
void getCoordinatesOfNode(int nodeId, std::vector<double>& 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<int>& code, const std::vector<const DataArrayInt *>& 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;
void getSplitCellValues(int *res) const;
void getSplitNodeValues(int *res) const;
//serialisation-unserialization
- void getTinySerializationInformation(std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const;
+ void getTinySerializationInformation(std::vector<double>& tinyInfoD, std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const;
void resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings) const;
void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const;
- void unserialization(const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2,
+ void unserialization(const std::vector<double>& tinyInfoD, const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2,
const std::vector<std::string>& littleStrings);
private:
MEDCouplingCMesh();
--- /dev/null
+// 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 <cmath>
+
+using namespace ParaMEDMEM;
+
+const double MEDCouplingDefinitionTime::EPS_DFT=1e-15;
+
+MEDCouplingDefinitionTimeSlice *MEDCouplingDefinitionTimeSlice::New(const MEDCouplingFieldDouble *f, int meshId, const std::vector<int>& 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<int>& tiI, const std::vector<double>& 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(t2<t1)
+ throw INTERP_KERNEL::Exception("MEDCouplingDefinitionTimeSlice : End time strictly before Start time ...");
+}
+
+bool MEDCouplingDefinitionTimeSlice::isFullyIncludedInMe(const MEDCouplingDefinitionTimeSlice *other, double eps) const
+{
+ double t1=getStartTime();
+ double t2=getEndTime();
+ double o1=other->getStartTime();
+ double o2=other->getEndTime();
+ return o1>t1-eps && o2<t2+eps;
+}
+
+bool MEDCouplingDefinitionTimeSlice::isOverllapingWithMe(const MEDCouplingDefinitionTimeSlice *other, double eps) const
+{
+ double t1=getStartTime();
+ double t2=getEndTime();
+ double o1=other->getStartTime();
+ double o2=other->getEndTime();
+ return (o1<t1+eps && o2<t1+eps) || (o1>t2-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<t1+eps && o2<t1+eps);
+}
+
+MEDCouplingDefinitionTimeSliceInst *MEDCouplingDefinitionTimeSliceInst::New(const std::vector<int>& tiI, const std::vector<double>& tiD)
+{
+ MEDCouplingDefinitionTimeSliceInst *ret=new MEDCouplingDefinitionTimeSliceInst;
+ ret->unserialize(tiI,tiD);
+ return ret;
+}
+
+void MEDCouplingDefinitionTimeSliceInst::getTinySerializationInformation(std::vector<int>& tiI, std::vector<double>& 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<int>& tiI, const std::vector<double>& 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<const MEDCouplingDefinitionTimeSliceInst *>(&other);
+ if(!otherC)
+ return false;
+ return fabs(otherC->_instant-_instant)<eps;
+}
+
+void MEDCouplingDefinitionTimeSliceInst::getHotSpotsTime(std::vector<double>& 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)<eps;
+}
+
+void MEDCouplingDefinitionTimeSliceInst::appendRepr(std::ostream& stream) const
+{
+ stream << "single point " << _instant;
+ MEDCouplingDefinitionTimeSlice::appendRepr(stream);
+}
+
+double MEDCouplingDefinitionTimeSliceInst::getStartTime() const
+{
+ return _instant;
+}
+
+double MEDCouplingDefinitionTimeSliceInst::getEndTime() const
+{
+ return _instant;
+}
+
+MEDCouplingDefinitionTimeSliceInst::MEDCouplingDefinitionTimeSliceInst(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);
+ 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<int>& tiI, const std::vector<double>& 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<const MEDCouplingDefinitionTimeSliceCstOnTI *>(&other);
+ if(!otherC)
+ return false;
+ if(fabs(otherC->_start-_start)>eps)
+ return false;
+ return fabs(otherC->_end-_end)<eps;
+}
+
+void MEDCouplingDefinitionTimeSliceCstOnTI::getHotSpotsTime(std::vector<double>& 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-eps<tmp && _end+eps>tmp;
+}
+
+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<int>& tiI, std::vector<double>& 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<int>& tiI, const std::vector<double>& 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<int>& tiI, const std::vector<double>& 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<const MEDCouplingDefinitionTimeSliceLT *>(&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)<eps;
+}
+
+void MEDCouplingDefinitionTimeSliceLT::getHotSpotsTime(std::vector<double>& 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)<eps)
+ {
+ meshId=_mesh_id;
+ arrId=_array_id;
+ arrIdInField=0;
+ fieldId=_field_id;
+ return ;
+ }
+ if(fabs(tm-_end)<eps)
+ {
+ meshId=_mesh_id;
+ arrId=_array_id_end;
+ arrIdInField=1;
+ fieldId=_field_id;
+ return ;
+ }
+ throw INTERP_KERNEL::Exception("LinearTime request not in boundary of this ! use hot spots !");
+}
+
+bool MEDCouplingDefinitionTimeSliceLT::isContaining(double tmp, double eps) const
+{
+ return _start-eps<tmp && _end+eps>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<int>& tiI, std::vector<double>& 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<int>& tiI, const std::vector<double>& 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<const MEDCouplingFieldDouble *>& fs, const std::vector<int>& meshRefs, const std::vector<std::vector<int> >& 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;i<sz;i++)
+ {
+ if(arrRefs.empty())
+ throw INTERP_KERNEL::Exception("MEDCouplingDefinitionTime constructor : A field is null in list impossible to build a time definition !");
+ _slices[i]=MEDCouplingDefinitionTimeSlice::New(fs[i],meshRefs[i],arrRefs[i],i);
+ }
+ if(sz<=1)
+ return ;
+ const MEDCouplingDefinitionTimeSlice *ref=_slices[0];
+ _eps=fs[0]->getTimeTolerance();
+ for(std::size_t i=1;i<sz;i++)
+ {
+ if(!ref->isAfterMe(_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;i<sz;i++)
+ _slices[i]=other._slices[i]->copy();
+}
+
+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;i<sz;i++)
+ if(!_slices[i]->isEqual(*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<int> meshIds;
+ std::vector<int> arrIds;
+ std::vector<int> arrIdsInField;
+ std::vector<int> 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<int> meshIds;
+ std::vector<int> arrIds;
+ std::vector<int> arrIdsInField;
+ std::vector<int> 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<int>& meshIds, std::vector<int>& arrIds, std::vector<int>& arrIdsInField, std::vector<int>& fieldIds) const throw(INTERP_KERNEL::Exception)
+{
+ std::vector<int> ids;
+ int id=0;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingDefinitionTimeSlice> >::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;i<sz;i++)
+ _slices[ids[i]]->getIdsOnTime(tm,_eps,meshIds[i],arrIds[i],arrIdsInField[i],fieldIds[i]);
+}
+
+std::vector<double> MEDCouplingDefinitionTime::getHotSpotsTime() const
+{
+ std::vector<double> ret;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingDefinitionTimeSlice> >::const_iterator it=_slices.begin();it!=_slices.end();it++)
+ {
+ std::vector<double> 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<MEDCouplingDefinitionTimeSlice> >::const_iterator it=_slices.begin();it!=_slices.end();it++)
+ {
+ stream << " - ";
+ (*it)->appendRepr(stream);
+ stream << std::endl;
+ }
+}
+
+void MEDCouplingDefinitionTime::getTinySerializationInformation(std::vector<int>& tinyInfoI, std::vector<double>& tinyInfoD) const
+{
+ int sz=_slices.size();
+ tinyInfoD.resize(1);
+ tinyInfoD[0]=_eps;
+ tinyInfoI.resize(3*sz+2);
+ tinyInfoI[0]=sz;
+ std::vector<int> coreData;
+ for(int i=0;i<sz;i++)
+ {
+ std::vector<int> tmp1;
+ std::vector<double> 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<int>& tinyInfoI, const std::vector<double>& tinyInfoD)
+{
+ int sz=tinyInfoI[0];
+ _slices.resize(sz);
+ _eps=tinyInfoD[0];
+ int offset1=0;
+ int offset2=1;
+ for(int i=0;i<sz;i++)
+ {
+ TypeOfTimeDiscretization ty=(TypeOfTimeDiscretization) tinyInfoI[i+2];
+ int sz1=tinyInfoI[i+sz+2];
+ int sz2=tinyInfoI[i+2*sz+2];
+ std::vector<int> tmp1(tinyInfoI.begin()+3*sz+2+offset1,tinyInfoI.begin()+3*sz+2+offset1+sz1);
+ std::vector<double> tmp2(tinyInfoD.begin()+offset2,tinyInfoD.begin()+offset2+sz2);
+ MEDCouplingDefinitionTimeSlice *pt=MEDCouplingDefinitionTimeSlice::New(ty,tmp1,tmp2);
+ _slices[i]=pt;
+ offset1+=sz1;
+ offset2+=sz2;
+ }
+}
+
--- /dev/null
+// 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 <vector>
+#include <sstream>
+
+namespace ParaMEDMEM
+{
+ class MEDCouplingFieldDouble;
+
+ class MEDCouplingDefinitionTimeSlice : public RefCountObject
+ {
+ public:
+ static MEDCouplingDefinitionTimeSlice *New(const MEDCouplingFieldDouble *f, int meshId, const std::vector<int>& arrId, int fieldId) throw(INTERP_KERNEL::Exception);
+ static MEDCouplingDefinitionTimeSlice *New(TypeOfTimeDiscretization type, const std::vector<int>& tiI, const std::vector<double>& 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<double>& 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<int>& tiI, std::vector<double>& 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<int>& tiI, const std::vector<double>& tiD);
+ MEDCouplingDefinitionTimeSlice *copy() const;
+ bool isEqual(const MEDCouplingDefinitionTimeSlice& other, double eps) const;
+ void getHotSpotsTime(std::vector<double>& 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<int>& tiI, std::vector<double>& tiD) const;
+ void unserialize(const std::vector<int>& tiI, const std::vector<double>& 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<int>& tiI, const std::vector<double>& tiD);
+ MEDCouplingDefinitionTimeSlice *copy() const;
+ bool isEqual(const MEDCouplingDefinitionTimeSlice& other, double eps) const;
+ void getHotSpotsTime(std::vector<double>& 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<int>& tiI, std::vector<double>& tiD) const;
+ void unserialize(const std::vector<int>& tiI, const std::vector<double>& 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<int>& tiI, const std::vector<double>& tiD);
+ MEDCouplingDefinitionTimeSlice *copy() const;
+ bool isEqual(const MEDCouplingDefinitionTimeSlice& other, double eps) const;
+ void getHotSpotsTime(std::vector<double>& 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<int>& tiI, std::vector<double>& tiD) const;
+ void unserialize(const std::vector<int>& tiI, const std::vector<double>& 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<const MEDCouplingFieldDouble *>& fs, const std::vector<int>& meshRefs, const std::vector<std::vector<int> >& 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<int>& meshIds, std::vector<int>& arrIds, std::vector<int>& arrIdsInField, std::vector<int>& fieldIds) const throw(INTERP_KERNEL::Exception);
+ std::vector<double> getHotSpotsTime() const;
+ void appendRepr(std::ostream& stream) const;
+ public:
+ void getTinySerializationInformation(std::vector<int>& tinyInfoI, std::vector<double>& tinyInfoD) const;
+ void unserialize(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD);
+ private:
+ double _eps;
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingDefinitionTimeSlice> > _slices;
+ static const double EPS_DFT;
+ };
+}
+
+#endif
-// 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"
{
_mesh2D=other._mesh2D->clone(true);
_mesh1D=other._mesh1D->clone(true);
- _mesh3D_ids=other._mesh3D_ids->deepCopy();
+ _mesh3D_ids=other._mesh3D_ids->deepCpy();
}
else
{
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<INTERP_KERNEL::NormalizedCellType> MEDCouplingExtrudedMesh::getAllGeoTypes() const
+{
+ const std::set<INTERP_KERNEL::NormalizedCellType>& ret2D=_mesh2D->getAllTypes();
+ std::set<INTERP_KERNEL::NormalizedCellType> ret;
+ for(std::set<INTERP_KERNEL::NormalizedCellType>::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
for(int i=0;i<nbOfCells2D;i++)
{
INTERP_KERNEL::NormalizedCellType t=_mesh2D->getTypeOfCell(i);
- if(INTERP_KERNEL::CellModel::getCellModel(t).getExtrudedType()==type)
+ if(INTERP_KERNEL::CellModel::GetCellModel(t).getExtrudedType()==type)
ret++;
}
return ret*_mesh1D->getNumberOfCells();
{
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";
{
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";
{
}
+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];
bbox[2*id+1]+=tmp[id];
}
-void MEDCouplingExtrudedMesh::updateTime()
+void MEDCouplingExtrudedMesh::updateTime() const
{
if(_mesh2D)
{
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_";
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()
std::transform(zoneToUpdate,zoneToUpdate+3,zoneToUpdate,std::bind2nd(std::multiplies<double>(),(double)(1./nodalConnec.size())));
}
-int MEDCouplingExtrudedMesh::findCorrespCellByNodalConn(const std::vector<int>& nodalConnec, const int *revNodalPtr, const int *revNodalIndxPtr) throw(INTERP_KERNEL::Exception)
+int MEDCouplingExtrudedMesh::FindCorrespCellByNodalConn(const std::vector<int>& nodalConnec, const int *revNodalPtr, const int *revNodalIndxPtr) throw(INTERP_KERNEL::Exception)
{
std::vector<int>::const_iterator iter=nodalConnec.begin();
std::set<int> s1(revNodalPtr+revNodalIndxPtr[*iter],revNodalPtr+revNodalIndxPtr[*iter+1]);
* @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);
_mesh1D->scale(point,factor);
}
+DataArrayInt *MEDCouplingExtrudedMesh::checkTypeConsistencyAndContig(const std::vector<int>& code, const std::vector<const DataArrayInt *>& 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 !
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 !
std::vector<int> 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)
{
revDescIndx->decrRef();
}
-void MEDCouplingExtrudedMesh::getTinySerializationInformation(std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const
+void MEDCouplingExtrudedMesh::getTinySerializationInformation(std::vector<double>& tinyInfoD, std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const
{
std::vector<int> tinyInfo1;
std::vector<std::string> ls1;
- _mesh2D->getTinySerializationInformation(tinyInfo1,ls1);
+ std::vector<double> ls3;
+ _mesh2D->getTinySerializationInformation(ls3,tinyInfo1,ls1);
std::vector<int> tinyInfo2;
std::vector<std::string> ls2;
- _mesh1D->getTinySerializationInformation(tinyInfo2,ls2);
+ std::vector<double> 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());
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<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings) const
//
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
a2_2->decrRef();
}
-void MEDCouplingExtrudedMesh::unserialization(const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, const std::vector<std::string>& littleStrings)
+void MEDCouplingExtrudedMesh::unserialization(const std::vector<double>& tinyInfoD, const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, const std::vector<std::string>& 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];
a2Ptr+=a2tmp->getNbOfElems();
a1Ptr+=a1tmp->getNbOfElems();
ls2.insert(ls2.end(),littleStrings.begin(),littleStrings.begin()+ls1.size());
- _mesh2D->unserialization(ti1,a1tmp,a2tmp,ls2);
+ std::vector<double> 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();
-// 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__
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<INTERP_KERNEL::NormalizedCellType> getAllGeoTypes() const;
int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const;
void getNodeIdsOfCell(int cellId, std::vector<int>& conn) const;
void getCoordinatesOfNode(int nodeId, std::vector<double>& 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<int>& nodalConnec,
+ static int FindCorrespCellByNodalConn(const std::vector<int>& 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<int>& code, const std::vector<const DataArrayInt *>& 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<int>& tinyInfo, std::vector<std::string>& littleStrings) const;
+ void getTinySerializationInformation(std::vector<double>& tinyInfoD, std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const;
void resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings) const;
void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const;
- void unserialization(const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2,
+ void unserialization(const std::vector<double>& tinyInfoD, const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2,
const std::vector<std::string>& littleStrings);
private:
MEDCouplingExtrudedMesh(const MEDCouplingUMesh *mesh3D, MEDCouplingUMesh *mesh2D, int cell2DId) throw(INTERP_KERNEL::Exception);
-// 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"
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)
{
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)
{
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);
{
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);
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.
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)
{
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 !");
+}
-// 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__
#include "MEDCoupling.hxx"
#include "MEDCouplingTimeLabel.hxx"
+#include "MEDCouplingNatureOfField.hxx"
#include "MEDCouplingRefCountObject.hxx"
#include "NormalizedUnstructuredMesh.hxx"
#include "InterpKernelException.hxx"
namespace ParaMEDMEM
{
class DataArrayInt;
+ class DataArrayDouble;
class MEDCouplingMesh;
class MEDCouplingFieldDouble;
class MEDCouplingFieldDiscretization;
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<double>& refCoo,
const std::vector<double>& gsCoo, const std::vector<double>& wg) throw(INTERP_KERNEL::Exception);
void getCellIdsHavingGaussLocalization(int locId, std::vector<int>& 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;
};
-// 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 <set>
+#include <list>
#include <limits>
#include <algorithm>
#include <functional>
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;
/*!
* Excepted for MEDCouplingFieldDiscretizationPerCell no underlying TimeLabel object : nothing to do in generally.
*/
-void MEDCouplingFieldDiscretization::updateTime()
+void MEDCouplingFieldDiscretization::updateTime() const
{
}
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<double>::max());
+ INTERP_KERNEL::AutoPtr<double> tmp=new double[nbOfComp];
for(int i=0;i<oldNbOfElems;i++)
{
int newNb=old2NewPtr[i];
std::copy(ptSrc+i*nbOfComp,ptSrc+(i+1)*nbOfComp,ptToFill+newNb*nbOfComp);
else
{
- if(!std::equal(ptSrc+i*nbOfComp,ptSrc+(i+1)*nbOfComp,ptToFill+newNb*nbOfComp))
+ std::transform(ptSrc+i*nbOfComp,ptSrc+(i+1)*nbOfComp,ptToFill+newNb*nbOfComp,(double *)tmp,std::minus<double>());
+ std::transform((double *)tmp,((double *)tmp)+nbOfComp,(double *)tmp,std::ptr_fun<double,double>(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;
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;i<new2OldSz;i++)
+ {
+ int oldNb=new2OldPtr[i];
+ std::copy(ptSrc+oldNb*nbOfComp,ptSrc+(oldNb+1)*nbOfComp,ptToFill+i*nbOfComp);
+ }
+ arrCpy->decrRef();
+}
+
MEDCouplingFieldDiscretization::~MEDCouplingFieldDiscretization()
{
}
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<DataArrayDouble *>& 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<DataArrayDouble *>::const_iterator it=arrays.begin();it!=arrays.end();it++)
{
if(*it)
arr->getTuple(id,res);
}
+DataArrayDouble *MEDCouplingFieldDiscretizationP0::getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const
+{
+ std::vector<int> elts,eltsIndex;
+ mesh->getCellsContainingPoints(loc,nbOfPoints,_precision,elts,eltsIndex);
+ int spaceDim=mesh->getSpaceDimension();
+ int nbOfComponents=arr->getNumberOfComponents();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=DataArrayDouble::New();
+ ret->alloc(nbOfPoints,nbOfComponents);
+ double *ptToFill=ret->getPointer();
+ for(int i=0;i<nbOfPoints;i++,ptToFill+=nbOfComponents)
+ if(eltsIndex[i+1]-eltsIndex[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<double>(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");
}
/*!
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();
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<int> conn;
std::vector<double> coo;
- mesh->getNodeIdsOfCell(id,conn);
+ mesh->getNodeIdsOfCell(cellId,conn);
for(std::vector<int>::const_iterator iter=conn.begin();iter!=conn.end();iter++)
mesh->getCoordinatesOfNode(*iter,coo);
int spaceDim=mesh->getSpaceDimension();
std::vector<const double *> vec(nbOfNodes);
for(int i=0;i<nbOfNodes;i++)
vec[i]=&coo[i*spaceDim];
- double *tmp=new double[nbOfNodes];
+ INTERP_KERNEL::AutoPtr<double> tmp=new double[nbOfNodes];
INTERP_KERNEL::barycentric_coords(vec,loc,tmp);
int sz=arr->getNumberOfComponents();
- double *tmp2=new double[sz];
+ INTERP_KERNEL::AutoPtr<double> tmp2=new double[sz];
std::fill(res,res+sz,0.);
for(int i=0;i<nbOfNodes;i++)
{
- arr->getTuple(conn[i],tmp2);
- std::transform(tmp2,tmp2+sz,tmp2,std::bind2nd(std::multiplies<double>(),tmp[i]));
- std::transform(res,res+sz,tmp2,res,std::plus<double>());
+ arr->getTuple(conn[i],(double *)tmp2);
+ std::transform((double *)tmp2,((double *)tmp2)+sz,(double *)tmp2,std::bind2nd(std::multiplies<double>(),tmp[i]));
+ std::transform(res,res+sz,(double *)tmp2,res,std::plus<double>());
}
- delete [] tmp;
- delete [] tmp2;
}
void MEDCouplingFieldDiscretizationP1::getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const
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<int> elts,eltsIndex;
+ mesh->getCellsContainingPoints(loc,nbOfPoints,_precision,elts,eltsIndex);
+ int spaceDim=mesh->getSpaceDimension();
+ int nbOfComponents=arr->getNumberOfComponents();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=DataArrayDouble::New();
+ ret->alloc(nbOfPoints,nbOfComponents);
+ double *ptToFill=ret->getPointer();
+ for(int i=0;i<nbOfPoints;i++)
+ if(eltsIndex[i+1]-eltsIndex[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<double>(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
{
}
{
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);
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();
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<DataArrayInt> 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()
{
}
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<nbOfTuples;i++,start++)
+ retPtr[i+1]=retPtr[i]+_loc[*start].getNumberOfGaussPt();
+ return ret;
+}
+
void MEDCouplingFieldDiscretizationGauss::renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector<DataArrayDouble *>& 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();
DataArrayDouble *MEDCouplingFieldDiscretizationGauss::getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const
{
- throw INTERP_KERNEL::Exception("Not implemented yet !");
+ checkNoOrphanCells();
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> 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<int> > locIds;
+ std::vector<DataArrayInt *> parts=splitIntoSingleGaussDicrPerCellType(locIds);
+ std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > parts2(parts.size());
+ std::copy(parts.begin(),parts.end(),parts2.begin());
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> 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<parts2.size();i++)
+ {
+ INTERP_KERNEL::GaussCoords calculator;
+ for(std::vector<int>::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<double>& 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,
for(int i=0;i<nbOfLoc;i++)
{
std::vector<int> 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);
}
}
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 !");
/*!
* 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<double>& refCoo,
const std::vector<double>& gsCoo, const std::vector<double>& 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);
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<DataArrayInt> ret=DataArrayInt::New();
+ const int *w=_discr_per_cell->getConstPointer();
+ ret->alloc(nbOfTuples,1);
+ int *valsToFill=ret->getPointer();
+ for(int i=0;i<nbOfTuples;i++,w++)
+ if(*w!=DFT_INVALID_LOCID_VALUE)
+ valsToFill[i]=_loc[*w].getNumberOfGaussPt();
+ else
+ throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGauss::buildNbOfGaussPointPerCellField : orphan cell detected !");
+ ret->incrRef();
+ return ret;
+}
+
/*!
* This method makes the assumption that _discr_per_cell is set.
* This method reduces as much as possible number size of _loc.
_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<DataArrayInt *> MEDCouplingFieldDiscretizationGauss::splitIntoSingleGaussDicrPerCellType(std::vector< std::vector<int> >& locIds) const throw(INTERP_KERNEL::Exception)
+{
+ if(!_discr_per_cell)
+ throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGauss::splitIntoSingleGaussDicrPerCellType : no descretization set !");
+ locIds.clear();
+ std::vector<DataArrayInt *> ret;
+ const int *discrPerCell=_discr_per_cell->getConstPointer();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret2=_discr_per_cell->getIdsNotEqual(-1);
+ int nbOfTuplesSet=ret2->getNumberOfTuples();
+ std::list<int> idsRemaining(ret2->getConstPointer(),ret2->getConstPointer()+nbOfTuplesSet);
+ std::list<int>::iterator it=idsRemaining.begin();
+ while(it!=idsRemaining.end())
+ {
+ std::vector<int> ids;
+ std::set<int> curLocIds;
+ std::set<INTERP_KERNEL::NormalizedCellType> 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()
{
}
for(int i=0;i<nbOfCells;i++)
{
INTERP_KERNEL::NormalizedCellType type=mesh->getTypeOfCell(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();
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;i<nbOfTuples;i++)
+ {
+ INTERP_KERNEL::NormalizedCellType type=mesh->getTypeOfCell(i);
+ const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(type);
+ if(cm.isDynamic())
+ throw INTERP_KERNEL::Exception("Not implemented yet Gauss node on elements for polygons and polyedrons !");
+ retPtr[i+1]=retPtr[i]+cm.getNumberOfNodes();
+ }
+ return ret;
+}
+
void MEDCouplingFieldDiscretizationGaussNE::renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector<DataArrayDouble *>& 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.
for(int i=1;i<nbOfCells;i++)
{
INTERP_KERNEL::NormalizedCellType type=mesh->getTypeOfCell(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;i<nbOfCells;i++)
{
INTERP_KERNEL::NormalizedCellType type=mesh->getTypeOfCell(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;
}
for(int i=0;i<cellId;i++)
{
INTERP_KERNEL::NormalizedCellType type=mesh->getTypeOfCell(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);
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 !");
/*!
* 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 !");
}
-// 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__
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;
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);
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<int>& tinyInfo) const;
virtual void getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const;
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;
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<DataArrayDouble *>& arrays,
const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception);
DataArrayDouble *getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const;
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[];
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<DataArrayDouble *>& arrays,
const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception);
DataArrayDouble *getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const;
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;
*/
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
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<DataArrayDouble *>& arrays,
const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception);
DataArrayDouble *getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const;
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<double>& refCoo,
const std::vector<double>& gsCoo, const std::vector<double>& wg) throw(INTERP_KERNEL::Exception);
void setGaussLocalizationOnCells(const MEDCouplingMesh *m, const int *begin, const int *end, const std::vector<double>& refCoo,
int getGaussLocalizationIdOfOneType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception);
void getCellIdsHavingGaussLocalization(int locId, std::vector<int>& cellIds) const throw(INTERP_KERNEL::Exception);
const MEDCouplingGaussLocalization& getGaussLocalization(int locId) const throw(INTERP_KERNEL::Exception);
+ std::vector<DataArrayInt *> splitIntoSingleGaussDicrPerCellType(std::vector< std::vector<int> >& locIds) const throw(INTERP_KERNEL::Exception);
+ DataArrayInt *buildNbOfGaussPointPerCellField() const throw(INTERP_KERNEL::Exception);
protected:
MEDCouplingFieldDiscretizationGauss(const MEDCouplingFieldDiscretizationGauss& other);
void zipGaussLocalizations();
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<DataArrayDouble *>& arrays,
const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception);
DataArrayDouble *getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const;
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:
-// 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"
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);
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());
}
}
+/*!
+ * 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;
const MEDCouplingFieldDouble *otherC=dynamic_cast<const MEDCouplingFieldDouble *>(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))
const MEDCouplingFieldDouble *otherC=dynamic_cast<const MEDCouplingFieldDouble *>(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))
const MEDCouplingFieldDouble *otherC=dynamic_cast<const MEDCouplingFieldDouble *>(other);
if(!otherC)
return false;
- if(_nature!=otherC->_nature)
- return false;
if(!_time_discr->areCompatible(otherC->_time_discr))
return false;
return true;
const MEDCouplingFieldDouble *otherC=dynamic_cast<const MEDCouplingFieldDouble *>(other);
if(!otherC)
return false;
- if(_nature!=otherC->_nature)
- return false;
if(!_time_discr->areStrictlyCompatible(otherC->_time_discr))
return false;
return true;
const MEDCouplingFieldDouble *otherC=dynamic_cast<const MEDCouplingFieldDouble *>(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<const MEDCouplingFieldDouble *>(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.
* 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<DataArrayDouble *> arrays;
_time_discr->getArrays(arrays);
for(std::vector<DataArrayDouble *>::const_iterator iter=arrays.begin();iter!=arrays.end();iter++)
if(*iter)
- _type->renumberValuesOnNodes(old2NewBg,*iter);
+ _type->renumberValuesOnNodes(eps,old2NewBg,*iter);
}
/*!
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)
{
}
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);
}
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.
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<double> res2;
for(std::vector< const DataArrayDouble *>::const_iterator iter=arrs.begin();iter!=arrs.end();iter++)
{
_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<DataArrayDouble> 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<std::string>& varsOrder, const char *func) throw(INTERP_KERNEL::Exception)
+{
+ if(!_mesh)
+ throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::fillFromAnalytic2 : no mesh defined !");
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> 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.
* 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<std::string>& 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);
}
return getArray()->getNbOfElems();
}
-void MEDCouplingFieldDouble::updateTime()
+void MEDCouplingFieldDouble::updateTime() const
{
MEDCouplingField::updateTime();
updateTimeWith(*_time_discr);
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
_time_discr->setEndArray(array,this);
}
+void MEDCouplingFieldDouble::setArrays(const std::vector<DataArrayDouble *>& arrs) throw(INTERP_KERNEL::Exception)
+{
+ _time_discr->setArrays(arrs,this);
+}
+
void MEDCouplingFieldDouble::getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const
{
tinyInfo.clear();
_time_discr->getTinySerializationStrInformation(tinyInfo);
tinyInfo.push_back(_name);
tinyInfo.push_back(_desc);
+ tinyInfo.push_back(getTimeUnit());
}
/*!
_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());
}
/*!
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);
/*!
* 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<const MEDCouplingPointSet *>(_mesh);
if(!meshC)
_time_discr->getArrays(arrays);
for(std::vector<DataArrayDouble *>::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<const MEDCouplingPointSet *>(_mesh);
+ if(!meshC)
+ throw INTERP_KERNEL::Exception("Invalid support mesh to apply mergeNodes on it : must be a MEDCouplingPointSet one !");
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingPointSet> meshC2((MEDCouplingPointSet *)meshC->deepCpy());
+ bool ret;
+ int ret2;
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=meshC2->mergeNodes2(eps,ret,ret2);
+ if(!ret)//no nodes have been merged.
+ return ret;
+ std::vector<DataArrayDouble *> arrays;
+ _time_discr->getArrays(arrays);
+ for(std::vector<DataArrayDouble *>::const_iterator iter=arrays.begin();iter!=arrays.end();iter++)
+ if(*iter)
+ _type->renumberValuesOnNodes(epsOnVals,arr->getConstPointer(),*iter);
setMesh(meshC2);
return true;
}
/*!
* 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<const MEDCouplingPointSet *>(_mesh);
if(!meshC)
_time_discr->getArrays(arrays);
for(std::vector<DataArrayDouble *>::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;
}
/*!
* 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<const MEDCouplingUMesh *>(_mesh);
if(!meshC)
_time_discr->getArrays(arrays);
for(std::vector<DataArrayDouble *>::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<MEDCouplingMesh> meshC2(_mesh->deepCpy());
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=meshC2->simplexize(policy);
+ int newNbOfCells=meshC2->getNumberOfCells();
+ if(oldNbOfCells==newNbOfCells)
+ return false;
+ std::vector<DataArrayDouble *> arrays;
+ _time_discr->getArrays(arrays);
+ for(std::vector<DataArrayDouble *>::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();
_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();
return ret;
}
-MEDCouplingFieldDouble *MEDCouplingFieldDouble::dotFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2)
+MEDCouplingFieldDouble *MEDCouplingFieldDouble::MergeFields(const std::vector<const MEDCouplingFieldDouble *>& a) throw(INTERP_KERNEL::Exception)
+{
+ if(a.size()<=1)
+ throw INTERP_KERNEL::Exception("FieldDouble::MergeFields : size of array must be > 1 !");
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> > ms(a.size());
+ std::vector< const MEDCouplingUMesh *> ms2(a.size());
+ std::vector< const MEDCouplingTimeDiscretization *> tds(a.size());
+ std::vector<const MEDCouplingFieldDouble *>::const_iterator it=a.begin();
+ 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<MEDCouplingUMesh> 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());
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());
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());
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());
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());
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 !");
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());
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 !");
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());
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 !");
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());
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;
-// 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__
#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;
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); }
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<DataArrayDouble *>& 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<DataArrayDouble *> getArrays() const { std::vector<DataArrayDouble *> ret; _time_discr->getArrays(ret); return ret; }
double accumulate(int compId) const;
void accumulate(double *res) const;
double getMaxValue() const throw(INTERP_KERNEL::Exception);
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<std::string>& 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<std::string>& 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<int>& tinyInfo) const;
void getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const;
//
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);
MEDCouplingFieldDouble *keepSelectedComponents(const std::vector<int>& compoIds) const throw(INTERP_KERNEL::Exception);
void setSelectedComponents(const MEDCouplingFieldDouble *f, const std::vector<int>& 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<const MEDCouplingFieldDouble *>& 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;
};
}
--- /dev/null
+// 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 <cmath>
+
+using namespace ParaMEDMEM;
+
+MEDCouplingFieldOverTime *MEDCouplingFieldOverTime::New(const std::vector<MEDCouplingFieldDouble *>& fs) throw(INTERP_KERNEL::Exception)
+{
+ return new MEDCouplingFieldOverTime(fs);
+}
+
+double MEDCouplingFieldOverTime::getTimeTolerance() const throw(INTERP_KERNEL::Exception)
+{
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> >::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<MEDCouplingFieldDouble> >::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(curt<reft-eps)
+ throw INTERP_KERNEL::Exception("MEDCouplingFieldOverTime::checkCoherency : fields are NOT sorted properly in ascending time !");
+ reft=(*it)->getEndTime(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<MEDCouplingMesh *> ms;
+ std::vector<int> 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<const MEDCouplingFieldOverTime *>(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<const MEDCouplingFieldOverTime *>(other);
+ if(!otherC)
+ return false;
+ // to implement
+ return true;
+}
+
+std::vector<MEDCouplingMesh *> MEDCouplingFieldOverTime::getMeshes() const throw(INTERP_KERNEL::Exception)
+{
+ checkCoherency();
+ return MEDCouplingMultiFields::getMeshes();
+}
+
+std::vector<MEDCouplingMesh *> MEDCouplingFieldOverTime::getDifferentMeshes(std::vector<int>& refs) const throw(INTERP_KERNEL::Exception)
+{
+ checkCoherency();
+ return MEDCouplingMultiFields::getDifferentMeshes(refs);
+}
+
+std::vector<DataArrayDouble *> MEDCouplingFieldOverTime::getArrays() const throw(INTERP_KERNEL::Exception)
+{
+ checkCoherency();
+ return MEDCouplingMultiFields::getArrays();
+}
+
+std::vector<DataArrayDouble *> MEDCouplingFieldOverTime::getDifferentArrays(std::vector< std::vector<int> >& refs) const throw(INTERP_KERNEL::Exception)
+{
+ checkCoherency();
+ return MEDCouplingMultiFields::getDifferentArrays(refs);
+}
+
+MEDCouplingDefinitionTime MEDCouplingFieldOverTime::getDefinitionTimeZone() const
+{
+ std::vector< std::vector<int> > tmp;
+ getDifferentArrays(tmp);
+ std::vector<const MEDCouplingFieldDouble *> tmp2(_fs.begin(),_fs.end());
+ std::vector<int> tmp3;
+ getDifferentMeshes(tmp3);
+ return MEDCouplingDefinitionTime(tmp2,tmp3,tmp);
+}
+
+MEDCouplingFieldOverTime::MEDCouplingFieldOverTime(const std::vector<MEDCouplingFieldDouble *>& fs) throw(INTERP_KERNEL::Exception):MEDCouplingMultiFields(fs)
+{
+ checkCoherency();
+}
+
+MEDCouplingFieldOverTime::MEDCouplingFieldOverTime()
+{
+}
--- /dev/null
+// 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 <vector>
+
+namespace ParaMEDMEM
+{
+ class MEDCouplingFieldOverTime : public MEDCouplingMultiFields
+ {
+ public:
+ static MEDCouplingFieldOverTime *New(const std::vector<MEDCouplingFieldDouble *>& 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<MEDCouplingMesh *> getMeshes() const throw(INTERP_KERNEL::Exception);
+ std::vector<MEDCouplingMesh *> getDifferentMeshes(std::vector<int>& refs) const throw(INTERP_KERNEL::Exception);
+ std::vector<DataArrayDouble *> getArrays() const throw(INTERP_KERNEL::Exception);
+ std::vector<DataArrayDouble *> getDifferentArrays(std::vector< std::vector<int> >& refs) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingDefinitionTime getDefinitionTimeZone() const;
+ protected:
+ MEDCouplingFieldOverTime();
+ private:
+ MEDCouplingFieldOverTime(const std::vector<MEDCouplingFieldDouble *>& fs) throw(INTERP_KERNEL::Exception);
+ };
+}
+
+#endif
--- /dev/null
+// 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<int>& tinyInfo) const
+{
+ tinyInfo.clear();
+ tinyInfo.push_back((int)_type->getEnum());
+ tinyInfo.push_back((int)_nature);
+ std::vector<int> tinyInfo2;
+ _type->getTinySerializationIntInformation(tinyInfo2);
+ tinyInfo.insert(tinyInfo.end(),tinyInfo2.begin(),tinyInfo2.end());
+ tinyInfo.push_back(tinyInfo2.size());
+}
+
+void MEDCouplingFieldTemplate::getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const
+{
+ tinyInfo.clear();
+ _type->getTinySerializationDbleInformation(tinyInfo);
+}
+
+void MEDCouplingFieldTemplate::getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const
+{
+ tinyInfo.clear();
+ tinyInfo.push_back(_name);
+ tinyInfo.push_back(_desc);
+}
+
+void MEDCouplingFieldTemplate::resizeForUnserialization(const std::vector<int>& tinyInfoI, DataArrayInt *&dataInt)
+{
+ dataInt=0;
+ std::vector<int> tinyInfoITmp(tinyInfoI.begin()+2,tinyInfoI.end());
+ _type->resizeForUnserialization(tinyInfoITmp,dataInt);
+}
+
+void MEDCouplingFieldTemplate::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS)
+{
+ _nature=(NatureOfField)tinyInfoI[1];
+ _type->finishUnserialization(tinyInfoD);
+ _name=tinyInfoS[0];
+ _desc=tinyInfoS[1];
+}
+
+void MEDCouplingFieldTemplate::serialize(DataArrayInt *&dataInt) const
+{
+ _type->getSerializationIntArray(dataInt);
+}
+
--- /dev/null
+// 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<int>& tinyInfo) const;
+ void getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const;
+ void getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const;
+ void resizeForUnserialization(const std::vector<int>& tinyInfoI, DataArrayInt *&dataInt);
+ void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS);
+ void serialize(DataArrayInt *&dataInt) const;
+ //
+ private:
+ MEDCouplingFieldTemplate(const MEDCouplingFieldDouble *f) throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldTemplate(TypeOfField type);
+ };
+}
+
+#endif
-// 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"
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())
{
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)
*/
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)
/*!
* 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<int>& tinyData)
+ParaMEDMEM::MEDCouplingGaussLocalization ParaMEDMEM::MEDCouplingGaussLocalization::BuildNewInstanceFromTinyInfo(int dim, const std::vector<int>& tinyData)
{
std::vector<double> v1(dim*tinyData[1]),v2(dim*tinyData[2]),v3(tinyData[2]);
return ParaMEDMEM::MEDCouplingGaussLocalization((INTERP_KERNEL::NormalizedCellType)tinyData[0],v1,v2,v3);
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)
return dim;
}
-bool ParaMEDMEM::MEDCouplingGaussLocalization::areAlmostEqual(const std::vector<double>& v1, const std::vector<double>& v2, double eps)
+bool ParaMEDMEM::MEDCouplingGaussLocalization::AreAlmostEqual(const std::vector<double>& v1, const std::vector<double>& v2, double eps)
{
int sz=v1.size();
if(sz!=(int)v2.size())
-// 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__
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<int>& tinyData);
+ static MEDCouplingGaussLocalization BuildNewInstanceFromTinyInfo(int dim, const std::vector<int>& tinyData);
+ static bool AreAlmostEqual(const std::vector<double>& v1, const std::vector<double>& v2, double eps);
private:
int checkCoherencyOfRequest(int gaussPtIdInCell, int comp) const throw(INTERP_KERNEL::Exception);
- static bool areAlmostEqual(const std::vector<double>& v1, const std::vector<double>& v2, double eps);
private:
INTERP_KERNEL::NormalizedCellType _type;
std::vector<double> _ref_coord;
-// 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"
#include <set>
#include <cmath>
+#include <limits>
#include <numeric>
#include <functional>
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<std::string>::const_iterator iter=_info_on_compo.begin();iter!=_info_on_compo.end();iter++)
stream << "\"" << *iter << "\" ";
stream << "\n";
}
+std::vector<std::string> DataArray::getVarsOnComponent() const
+{
+ int nbOfCompo=(int)_info_on_compo.size();
+ std::vector<std::string> ret(nbOfCompo);
+ for(int i=0;i<nbOfCompo;i++)
+ ret[i]=getVarOnComponent(i);
+ return ret;
+}
+
+std::vector<std::string> DataArray::getUnitsOnComponent() const
+{
+ int nbOfCompo=(int)_info_on_compo.size();
+ std::vector<std::string> ret(nbOfCompo);
+ for(int i=0;i<nbOfCompo;i++)
+ ret[i]=getUnitOnComponent(i);
+ return ret;
+}
+
std::string DataArray::getInfoOnComponent(int i) const throw(INTERP_KERNEL::Exception)
{
if(i<(int)_info_on_compo.size())
}
}
+/*!
+ * In the info part of i_th component this method returns the var part.
+ * For example, if getInfoOnComponent(0) return "SIGXY (N/m^2)", getVarOnComponent(0) will return "SIGXY"
+ */
+std::string DataArray::getVarOnComponent(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 st0;
+ if(p1>p2)
+ 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())
}
}
+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<begin)
+ {
+ std::ostringstream oss; oss << msg << " : end before begin !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ if(step<=0)
+ {
+ std::ostringstream oss; oss << msg << " : invalid step should be > 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();
}
}
+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;i<nbOfElems;i++)
+ pt[i]=ptI[i];
+ copyStringInfoFrom(other);
+}
+
+void DataArrayDouble::allocIfNecessary(int nbOfTuple, int nbOfCompo)
+{
+ if(isAllocated())
+ {
+ if(nbOfTuple!=getNumberOfTuples() || nbOfCompo!=getNumberOfComponents())
+ alloc(nbOfTuple,nbOfCompo);
+ }
+ else
+ alloc(nbOfTuple,nbOfCompo);
+}
+
void DataArrayDouble::alloc(int nbOfTuple, int nbOfCompo)
{
_nb_of_tuples=nbOfTuple;
declareAsNew();
}
-void DataArrayDouble::fillWithZero()
+void DataArrayDouble::fillWithZero() throw(INTERP_KERNEL::Exception)
+{
+ fillWithValue(0.);
+}
+
+void DataArrayDouble::fillWithValue(double val) throw(INTERP_KERNEL::Exception)
{
- _mem.fillWithValue(0.);
+ if(!getPointer())
+ throw INTERP_KERNEL::Exception("DataArrayDouble::fillWithValue : allocate first !");
+ _mem.fillWithValue(val);
declareAsNew();
}
-void DataArrayDouble::fillWithValue(double val)
+void DataArrayDouble::iota(double init) throw(INTERP_KERNEL::Exception)
{
- _mem.fillWithValue(val);
+ double *ptr=getPointer();
+ if(!ptr)
+ throw INTERP_KERNEL::Exception("DataArrayDouble::iota : allocate first !");
+ if(getNumberOfComponents()!=1)
+ throw INTERP_KERNEL::Exception("DataArrayDouble::iota : works only for arrays with only one component, you can call 'rearrange' method before !");
+ int ntuples=getNumberOfTuples();
+ for(int i=0;i<ntuples;i++)
+ ptr[i]=init+double(i);
declareAsNew();
}
+bool DataArrayDouble::isUniform(double val, double eps) const
+{
+ if(getNumberOfComponents()!=1)
+ throw INTERP_KERNEL::Exception("DataArrayDouble::isUniform : must be applied on DataArrayDouble with only one component, you can call 'rearrange' method before !");
+ int nbOfTuples=getNumberOfTuples();
+ const double *w=getConstPointer();
+ const double *end=w+nbOfTuples;
+ const double vmin=val-eps;
+ const double vmax=val+eps;
+ for(;w!=end;w++)
+ if(*w<vmin || *w>vmax)
+ 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;i<nbOfElements;i++)
+ {
+ if(ptr[i]<ref+eps)
+ return false;
+ ref=ptr[i];
+ }
+ return true;
+}
+
std::string DataArrayDouble::repr() const
{
std::ostringstream ret;
return _mem.isEqual(other._mem,prec);
}
-void DataArrayDouble::reAlloc(int nbOfTuples)
+void DataArrayDouble::reAlloc(int nbOfTuples) throw(INTERP_KERNEL::Exception)
{
+ checkAllocated();
_mem.reAlloc(_info_on_compo.size()*nbOfTuples);
_nb_of_tuples=nbOfTuples;
declareAsNew();
return ret;
}
+DataArrayDouble *DataArrayDouble::fromNoInterlace() const throw(INTERP_KERNEL::Exception)
+{
+ if(_mem.isNull())
+ throw INTERP_KERNEL::Exception("DataArrayDouble::fromNoInterlace : Not defined array !");
+ double *tab=_mem.fromNoInterlace(getNumberOfComponents());
+ DataArrayDouble *ret=DataArrayDouble::New();
+ ret->useArray(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.
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<DataArrayDouble> 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 && *w<oldNbOfTuples)
+ std::copy(srcPt+(*w)*nbComp,srcPt+((*w)+1)*nbComp,pt+i*nbComp);
+ else
+ throw INTERP_KERNEL::Exception("DataArrayInt::selectByTupleIdSafe : some ids has been detected to be out of [0,this->getNumberOfTuples) !");
+ 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<bg)
+ throw INTERP_KERNEL::Exception("DataArrayDouble::selectByTupleId2 : end before begin !");
+ if(step<=0)
+ throw INTERP_KERNEL::Exception("DataArrayDouble::selectByTupleId2 : invalid step should > 0 !");
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> 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;i<newNbOfTuples;i++,srcPt+=step*nbComp)
+ std::copy(srcPt,srcPt+nbComp,pt+i*nbComp);
+ ret->copyStringInfoFrom(*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.
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)
{
*/
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();
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<int>& compoIds) const throw(INTERP_KERNEL::Exception)
{
+ checkAllocated();
MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret(DataArrayDouble::New());
int newNbOfCompo=compoIds.size();
int oldNbOfCompo=getNumberOfComponents();
+ for(std::vector<int>::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);
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<nbOfTuples;i++,inp1+=nbOfComp1,inp2+=nbOfComp2)
+ {
+ w=std::copy(inp1,inp1+nbOfComp1,w);
+ w=std::copy(inp2,inp2+nbOfComp2,w);
+ }
+ useArray(newArr,true,CPP_DEALLOC,nbOfTuples,nbOfComp1+nbOfComp2);
+ std::vector<int> compIds(nbOfComp2);
+ for(int i=0;i<nbOfComp2;i++)
+ compIds[i]=nbOfComp1+i;
+ copyPartOfStringInfoFrom2(compIds,*other);
+}
+
void DataArrayDouble::setSelectedComponents(const DataArrayDouble *a, const std::vector<int>& compoIds) throw(INTERP_KERNEL::Exception)
{
copyPartOfStringInfoFrom2(compoIds,*a);
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;i<newNbOfTuples;i++,pt+=stepTuples*nbComp)
+ for(int j=0;j<newNbOfComp;j++,srcPt++)
+ pt[j*stepComp]=*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::setPartOfValuesSimple1(double a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp) throw(INTERP_KERNEL::Exception)
+{
+ const char msg[]="DataArrayDouble::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");
+ double *pt=getPointer()+bgTuples*nbComp+bgComp;
+ for(int i=0;i<newNbOfTuples;i++,pt+=stepTuples*nbComp)
+ for(int j=0;j<newNbOfComp;j++)
+ pt[j*stepComp]=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::setPartOfValues2(const DataArrayDouble *a, const int *bgTuples, const int *endTuples, const int *bgComp, const int *endComp, bool strictCompoCompare) throw(INTERP_KERNEL::Exception)
+{
+ const char msg[]="DataArrayDouble::setPartOfValues2";
+ checkAllocated();
+ a->checkAllocated();
+ 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<newNbOfComp;j++,srcPt++)
+ {
+ DataArray::CheckValueInRange(nbOfTuples,*w,"invalid tuple id");
+ pt[(*w)*nbComp+j*stepComp]=*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::setPartOfValuesSimple3(double a, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp) throw(INTERP_KERNEL::Exception)
+{
+ const char msg[]="DataArrayDouble::setPartOfValuesSimple3";
+ 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");
+ double *pt=getPointer()+bgComp;
+ for(const int *w=bgTuples;w!=endTuples;w++)
+ for(int j=0;j<newNbOfComp;j++)
+ {
+ DataArray::CheckValueInRange(nbOfTuples,*w,"invalid tuple id");
+ pt[(*w)*nbComp+j*stepComp]=a;
+ }
+}
+
+void DataArrayDouble::SetArrayIn(DataArrayDouble *newArray, DataArrayDouble* &arrayToSet)
{
if(newArray!=arrayToSet)
{
double DataArrayDouble::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 !");
+ throw INTERP_KERNEL::Exception("DataArrayDouble::getMaxValue : 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::getMaxValue : array exists but number of tuples must be > 0 !");
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 !");
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 !");
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();
std::transform(ptr+i*nbComps,ptr+(i+1)*nbComps,res,res,std::plus<double>());
}
-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();
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;i<nbOfTuple;i++,dest++,src+=6)
- *dest=src[0]*src[0]+src[1]*src[1]+src[2]*src[2]+2.*src[3]*src[3]+2.*src[4]*src[4]+2.*src[5]*src[5];
+ DataArrayDouble *ret=DataArrayDouble::New();
+ ret->alloc(nbOfTuple,2);
+ double *w=ret->getPointer();
+ const double *wIn=getConstPointer();
+ for(int i=0;i<nbOfTuple;i++,w+=2,wIn+=2)
+ {
+ w[0]=wIn[0]*cos(wIn[1]);
+ w[1]=wIn[0]*sin(wIn[1]);
+ }
return ret;
}
-DataArrayDouble *DataArrayDouble::determinant() const throw(INTERP_KERNEL::Exception)
+DataArrayDouble *DataArrayDouble::fromCylToCart() const throw(INTERP_KERNEL::Exception)
{
- DataArrayDouble *ret=DataArrayDouble::New();
+ int nbOfComp=getNumberOfComponents();
+ if(nbOfComp!=3)
+ throw INTERP_KERNEL::Exception("DataArrayDouble::fromCylToCart : must be an array with exactly 3 components !");
int nbOfTuple=getNumberOfTuples();
- ret->alloc(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;i<nbOfTuple;i++,w+=3,wIn+=3)
{
- case 6:
- for(int i=0;i<nbOfTuple;i++,dest++,src+=6)
- *dest=src[0]*src[1]*src[2]+2.*src[4]*src[5]*src[3]-src[0]*src[4]*src[4]-src[2]*src[3]*src[3]-src[1]*src[5]*src[5];
- return ret;
- case 4:
- for(int i=0;i<nbOfTuple;i++,dest++,src+=4)
+ w[0]=wIn[0]*cos(wIn[1]);
+ w[1]=wIn[0]*sin(wIn[1]);
+ w[2]=wIn[2];
+ }
+ ret->setInfoOnComponent(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;i<nbOfTuple;i++,w+=3,wIn+=3)
+ {
+ w[0]=wIn[0]*cos(wIn[2])*sin(wIn[1]);
+ w[1]=wIn[0]*sin(wIn[2])*sin(wIn[1]);
+ w[2]=wIn[0]*cos(wIn[1]);
+ }
+ return ret;
+}
+
+DataArrayDouble *DataArrayDouble::doublyContractedProduct() 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();
+ int nbOfTuple=getNumberOfTuples();
+ ret->alloc(nbOfTuple,1);
+ const double *src=getConstPointer();
+ double *dest=ret->getPointer();
+ for(int i=0;i<nbOfTuple;i++,dest++,src+=6)
+ *dest=src[0]*src[0]+src[1]*src[1]+src[2]*src[2]+2.*src[3]*src[3]+2.*src[4]*src[4]+2.*src[5]*src[5];
+ return ret;
+}
+
+DataArrayDouble *DataArrayDouble::determinant() const throw(INTERP_KERNEL::Exception)
+{
+ checkAllocated();
+ DataArrayDouble *ret=DataArrayDouble::New();
+ int nbOfTuple=getNumberOfTuples();
+ ret->alloc(nbOfTuple,1);
+ const double *src=getConstPointer();
+ double *dest=ret->getPointer();
+ switch(getNumberOfComponents())
+ {
+ case 6:
+ for(int i=0;i<nbOfTuple;i++,dest++,src+=6)
+ *dest=src[0]*src[1]*src[2]+2.*src[4]*src[5]*src[3]-src[0]*src[4]*src[4]-src[2]*src[3]*src[3]-src[1]*src[5]*src[5];
+ return ret;
+ case 4:
+ for(int i=0;i<nbOfTuple;i++,dest++,src+=4)
*dest=src[0]*src[3]-src[1]*src[2];
return ret;
case 9:
DataArrayDouble *DataArrayDouble::magnitude() const throw(INTERP_KERNEL::Exception)
{
+ checkAllocated();
int nbOfComp=getNumberOfComponents();
DataArrayDouble *ret=DataArrayDouble::New();
int nbOfTuple=getNumberOfTuples();
DataArrayDouble *DataArrayDouble::maxPerTuple() const throw(INTERP_KERNEL::Exception)
{
+ checkAllocated();
int nbOfComp=getNumberOfComponents();
DataArrayDouble *ret=DataArrayDouble::New();
int nbOfTuple=getNumberOfTuples();
void DataArrayDouble::sortPerTuple(bool asc) throw(INTERP_KERNEL::Exception)
{
+ checkAllocated();
double *pt=getPointer();
int nbOfTuple=getNumberOfTuples();
int nbOfComp=getNumberOfComponents();
declareAsNew();
}
-void DataArrayDouble::applyLin(double a, double b, int compoId)
+void DataArrayDouble::applyLin(double a, double b, int compoId) throw(INTERP_KERNEL::Exception)
{
+ checkAllocated();
double *ptr=getPointer()+compoId;
int nbOfComp=getNumberOfComponents();
int nbOfTuple=getNumberOfTuples();
declareAsNew();
}
+void DataArrayDouble::applyLin(double a, double b) throw(INTERP_KERNEL::Exception)
+{
+ checkAllocated();
+ double *ptr=getPointer();
+ int nbOfElems=getNbOfElems();
+ for(int i=0;i<nbOfElems;i++,ptr++)
+ *ptr=a*(*ptr)+b;
+ declareAsNew();
+}
+
+/*!
+ * This method applies the operation 'numerator/x' for each element 'x' in 'this'.
+ * If there is a value in 'this' exactly equal to 0. an exception is thrown.
+ * Warning if presence of null this is modified for each values previous than place where exception was thrown !
+ */
+void DataArrayDouble::applyInv(double numerator) throw(INTERP_KERNEL::Exception)
+{
+ checkAllocated();
+ double *ptr=getPointer();
+ int nbOfElems=getNbOfElems();
+ for(int i=0;i<nbOfElems;i++,ptr++)
+ {
+ if(*ptr!=0.)
+ {
+ *ptr=numerator/(*ptr);
+ }
+ else
+ {
+ std::ostringstream oss; oss << "DataArrayDouble::applyInv : presence of null value in tuple #" << i/getNumberOfComponents() << " component #" << i%getNumberOfComponents();
+ oss << " !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ declareAsNew();
+}
+
DataArrayDouble *DataArrayDouble::applyFunc(int nbOfComp, FunctionToEvaluate func) const throw(INTERP_KERNEL::Exception)
{
+ checkAllocated();
DataArrayDouble *newArr=DataArrayDouble::New();
int nbOfTuples=getNumberOfTuples();
int oldNbOfComp=getNumberOfComponents();
DataArrayDouble *DataArrayDouble::applyFunc(int nbOfComp, const char *func) const throw(INTERP_KERNEL::Exception)
{
+ checkAllocated();
INTERP_KERNEL::ExprParser expr(func);
expr.parse();
std::set<std::string> vars;
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<std::string>(oss," "));
throw INTERP_KERNEL::Exception(oss.str().c_str());
DataArrayDouble *DataArrayDouble::applyFunc(const char *func) const throw(INTERP_KERNEL::Exception)
{
+ checkAllocated();
INTERP_KERNEL::ExprParser expr(func);
expr.parse();
expr.prepareExprEvaluationVec();
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<std::string> 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<std::string>(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<nbOfTuples;i++)
+ {
+ try
+ {
+ expr.evaluateExpr(nbOfComp,ptr+i*oldNbOfComp,ptrToFill+i*nbOfComp);
+ }
+ catch(INTERP_KERNEL::Exception& e)
+ {
+ std::ostringstream oss; oss << "For tuple # " << i << " with value (";
+ std::copy(ptr+oldNbOfComp*i,ptr+oldNbOfComp*(i+1),std::ostream_iterator<double>(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<std::string>& varsOrder, const char *func) const throw(INTERP_KERNEL::Exception)
+{
+ checkAllocated();
+ INTERP_KERNEL::ExprParser expr(func);
+ expr.parse();
+ std::set<std::string> 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<std::string>(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<nbOfTuples;i++)
+ {
+ try
+ {
+ expr.evaluateExpr(nbOfComp,ptr+i*oldNbOfComp,ptrToFill+i*nbOfComp);
+ }
+ catch(INTERP_KERNEL::Exception& e)
+ {
+ std::ostringstream oss; oss << "For tuple # " << i << " with value (";
+ std::copy(ptr+oldNbOfComp*i,ptr+oldNbOfComp*(i+1),std::ostream_iterator<double>(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();
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();
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<int> res;
int nbOfTuples=getNumberOfTuples();
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<const DataArrayDouble *> tmp(2);
+ tmp[0]=a1; tmp[1]=a2;
+ return Aggregate(tmp);
+}
+
+DataArrayDouble *DataArrayDouble::Aggregate(const std::vector<const DataArrayDouble *>& a) throw(INTERP_KERNEL::Exception)
+{
+ if(a.empty())
+ throw INTERP_KERNEL::Exception("DataArrayDouble::Aggregate : input list must be NON EMPTY !");
+ std::vector<const DataArrayDouble *>::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<const DataArrayDouble *> arr(2);
+ arr[0]=a1; arr[1]=a2;
+ return Meld(arr);
+}
+
+DataArrayDouble *DataArrayDouble::Meld(const std::vector<const DataArrayDouble *>& a) throw(INTERP_KERNEL::Exception)
+{
+ if(a.empty())
+ throw INTERP_KERNEL::Exception("DataArrayDouble::Meld : array must be NON empty !");
+ std::vector<const DataArrayDouble *>::const_iterator it;
+ for(it=a.begin();it!=a.end();it++)
+ (*it)->checkAllocated();
+ it=a.begin();
+ int nbOfTuples=(*it)->getNumberOfTuples();
+ std::vector<int> nbc(a.size());
+ std::vector<const double *> 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;i<nbOfTuples;i++)
+ for(int j=0;j<(int)a.size();j++)
+ {
+ retPtr=std::copy(pts[j],pts[j]+nbc[j],retPtr);
+ pts[j]+=nbc[j];
+ }
+ int k=0;
+ for(int i=0;i<(int)a.size();i++)
+ for(int j=0;j<nbc[i];j++,k++)
+ ret->setInfoOnComponent(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();
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())
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();
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())
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<double>());
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<double>());
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<double>());
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<double>());
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)
{
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;
}
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<double>());
- 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<double>());
+ 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<nbOfTuple;i++)
+ res=std::transform(a1Ptr+i*nbOfComp,a1Ptr+(i+1)*nbOfComp,res,std::bind2nd(std::divides<double>(),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<double>());
+ if(nbOfComp==nbOfComp2)
+ {
+ std::transform(getConstPointer(),getConstPointer()+nbOfTuple*nbOfComp,other->getConstPointer(),getPointer(),std::divides<double>());
+ }
+ else
+ {
+ if(nbOfComp2==1)
+ {
+ const double *ptr=other->getConstPointer();
+ double *myPtr=getPointer();
+ for(int i=0;i<nbOfTuple;i++)
+ myPtr=std::transform(myPtr,myPtr+nbOfComp,myPtr,std::bind2nd(std::divides<double>(),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<int>& 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<std::string>& tinyInfo) const
{
- if(deepCpy)
- return deepCopy();
+ if(isAllocated())
+ {
+ int nbOfCompo=getNumberOfComponents();
+ tinyInfo.resize(nbOfCompo+1);
+ tinyInfo[0]=getName();
+ for(int i=0;i<nbOfCompo;i++)
+ tinyInfo[i+1]=getInfoOnComponent(i);
+ }
else
{
- incrRef();
- return const_cast<DataArrayInt *>(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<int>& 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<int>& tinyInfoI, const std::vector<std::string>& tinyInfoS)
+{
+ setName(tinyInfoS[0].c_str());
+ if(isAllocated())
+ {
+ int nbOfCompo=getNumberOfComponents();
+ for(int i=0;i<nbOfCompo;i++)
+ setInfoOnComponent(i,tinyInfoS[i+1].c_str());
+ }
+}
+
+DataArrayInt *DataArrayInt::New()
+{
+ return new DataArrayInt;
+}
+
+bool DataArrayInt::isAllocated() const
+{
+ return getConstPointer()!=0;
+}
+
+void DataArrayInt::checkAllocated() const throw(INTERP_KERNEL::Exception)
+{
+ if(!isAllocated())
+ throw INTERP_KERNEL::Exception("DataArrayInt::checkAllocated : Array is defined but not allocated ! Call alloc or setValues method first !");
+}
+
+DataArrayInt *DataArrayInt::deepCpy() const
+{
+ return new DataArrayInt(*this);
+}
+
+DataArrayInt *DataArrayInt::performCpy(bool dCpy) const
+{
+ if(dCpy)
+ return deepCpy();
+ else
+ {
+ incrRef();
+ return const_cast<DataArrayInt *>(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<nbOfElems;i++)
+ pt[i]=ptI[i];
+ copyStringInfoFrom(other);
+}
+
+void DataArrayInt::allocIfNecessary(int nbOfTuple, int nbOfCompo)
+{
+ if(isAllocated())
+ {
+ if(nbOfTuple!=getNumberOfTuples() || nbOfCompo!=getNumberOfComponents())
+ alloc(nbOfTuple,nbOfCompo);
+ }
+ else
+ alloc(nbOfTuple,nbOfCompo);
+}
+
+void DataArrayInt::alloc(int nbOfTuple, int nbOfCompo)
+{
+ _nb_of_tuples=nbOfTuple;
+ _info_on_compo.resize(nbOfCompo);
+ _mem.alloc(nbOfCompo*_nb_of_tuples);
+ declareAsNew();
+}
+
+void DataArrayInt::fillWithZero()
{
_mem.fillWithValue(0);
declareAsNew();
declareAsNew();
}
+void DataArrayInt::iota(int init) throw(INTERP_KERNEL::Exception)
+{
+ int *ptr=getPointer();
+ if(!ptr)
+ throw INTERP_KERNEL::Exception("DataArrayInt::iota : allocate first !");
+ if(getNumberOfComponents()!=1)
+ throw INTERP_KERNEL::Exception("DataArrayInt::iota : works only for arrays with only one component, you can call 'rearrange' method before !");
+ int ntuples=getNumberOfTuples();
+ for(int i=0;i<ntuples;i++)
+ ptr[i]=init+i;
+ declareAsNew();
+}
+
std::string DataArrayInt::repr() const
{
std::ostringstream ret;
_mem.reprZip(getNumberOfComponents(),stream);
}
-void DataArrayInt::transformWithIndArr(const int *indArr)
+void DataArrayInt::transformWithIndArr(const int *indArrBg, const int *indArrEnd) throw(INTERP_KERNEL::Exception)
{
if(getNumberOfComponents()!=1)
- throw INTERP_KERNEL::Exception("Call transformWithIndArr method on DataArrayInt with only one component !");
+ throw INTERP_KERNEL::Exception("Call transformWithIndArr method on DataArrayInt with only one component, you can call 'rearrange' method before !");
+ int nbElemsIn=std::distance(indArrBg,indArrEnd);
int nbOfTuples=getNumberOfTuples();
int *pt=getPointer();
- for(int i=0;i<nbOfTuples;i++)
- pt[i]=indArr[pt[i]];
+ for(int i=0;i<nbOfTuples;i++,pt++)
+ {
+ if(*pt>=0 && *pt<nbElemsIn)
+ *pt=indArrBg[*pt];
+ else
+ {
+ std::ostringstream oss; oss << "DataArrayInt::transformWithIndArr : error on tuple #" << i << " value is " << *pt << " and indirectionnal array as a size equal to " << nbElemsIn;
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ declareAsNew();
+}
+
+DataArrayInt *DataArrayInt::transformWithIndArrR(const int *indArrBg, const int *indArrEnd) const throw(INTERP_KERNEL::Exception)
+{
+ if(getNumberOfComponents()!=1)
+ throw INTERP_KERNEL::Exception("Call transformWithIndArrR method on DataArrayInt with only one component, you can call 'rearrange' method before !");
+ int nbElemsIn=std::distance(indArrBg,indArrEnd);
+ int nbOfTuples=getNumberOfTuples();
+ int *pt=getPointer();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=DataArrayInt::New();
+ ret->alloc(nbOfTuples,1);
+ ret->fillWithValue(-1);
+ int *tmp=ret->getPointer();
+ for(int i=0;i<nbOfTuples;i++,pt++)
+ {
+ int pos=indArrBg[*pt];
+ if(pos>=0 && pos<nbElemsIn)
+ tmp[pos]=i;
+ else
+ {
+ std::ostringstream oss; oss << "DataArrayInt::transformWithIndArrR : error on tuple #" << i << " value is " << *pt << " and indirectionnal array as a size equal to " << nbElemsIn;
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ ret->incrRef();
+ return ret;
}
/*!
return _mem.isEqual(other._mem,0);
}
+bool DataArrayInt::isEqualWithoutConsideringStrAndOrder(const DataArrayInt& other) const throw(INTERP_KERNEL::Exception)
+{
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> a=deepCpy();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> 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<=i<getNumberOfTuples()
+ * other.getIJ(i,0)==this->getIJ(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<DataArrayInt> ret=DataArrayInt::New();
+ ret->alloc(nbTuple,1);
+ ret->fillWithValue(-1);
+ const int *pt=getConstPointer();
+ std::map<int,int> mm;
+ for(int i=0;i<nbTuple;i++)
+ mm[pt[i]]=i;
+ pt=other.getConstPointer();
+ int *retToFill=ret->getPointer();
+ for(int i=0;i<nbTuple;i++)
+ {
+ std::map<int,int>::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;
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();
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();
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<DataArrayInt> 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 && *w<oldNbOfTuples)
+ std::copy(srcPt+(*w)*nbComp,srcPt+((*w)+1)*nbComp,pt+i*nbComp);
+ else
+ throw INTERP_KERNEL::Exception("DataArrayInt::selectByTupleIdSafe : some ids has been detected to be out of [0,this->getNumberOfTuples) !");
+ 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<bg)
+ throw INTERP_KERNEL::Exception("DataArrayInt::selectByTupleId2 : end before begin !");
+ if(step<=0)
+ throw INTERP_KERNEL::Exception("DataArrayInt::selectByTupleId2 : invalid step should > 0 !");
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> 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;i<newNbOfTuples;i++,srcPt+=step*nbComp)
+ std::copy(srcPt,srcPt+nbComp,pt+i*nbComp);
+ ret->copyStringInfoFrom(*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'<this->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<DataArrayInt> ret(DataArrayInt::New());
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> retI(DataArrayInt::New());
+ retI->alloc(targetNb+1,1);
+ const int *input=getConstPointer();
+ std::vector< std::vector<int> > tmp(targetNb);
+ for(int i=0;i<nbOfTuples;i++)
+ {
+ int tmp2=input[i];
+ if(tmp2<targetNb)
+ tmp[tmp2].push_back(i);
+ else
+ {
+ std::ostringstream oss; oss << "DataArrayInt::changeSurjectiveFormat : At pos " << i << " presence of element " << tmp2 << " higher than " << targetNb;
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ int *retIPtr=retI->getPointer();
+ *retIPtr=0;
+ for(std::vector< std::vector<int> >::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<int> >::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 i<j then ret[i]<ret[j]
+ * - The first tuple with the lowest value will have the value 0, inversely the last tuple with highest value will have value 'this->getNumberOfTuples()-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<int,int> m;
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=DataArrayInt::New();
+ ret->alloc(nbOfTuples,1);
+ int *opt=ret->getPointer();
+ for(int i=0;i<nbOfTuples;i++,pt++,opt++)
+ {
+ int val=*pt;
+ std::map<int,int>::iterator it=m.find(val);
+ if(it!=m.end())
+ {
+ *opt=(*it).second;
+ (*it).second++;
+ }
+ else
+ {
+ *opt=0;
+ m.insert(std::pair<int,int>(val,1));
+ }
+ }
+ int sum=0;
+ for(std::map<int,int>::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;i<nbOfTuples;i++,pt++,opt++)
+ *opt+=m[*pt];
+ //
+ ret->incrRef();
+ 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
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();
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)
{
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.
*/
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();
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();
DataArrayInt *DataArrayInt::keepSelectedComponents(const std::vector<int>& compoIds) const throw(INTERP_KERNEL::Exception)
{
+ checkAllocated();
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret(DataArrayInt::New());
int newNbOfCompo=compoIds.size();
int oldNbOfCompo=getNumberOfComponents();
+ for(std::vector<int>::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);
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<nbOfTuples;i++,inp1+=nbOfComp1,inp2+=nbOfComp2)
+ {
+ w=std::copy(inp1,inp1+nbOfComp1,w);
+ w=std::copy(inp2,inp2+nbOfComp2,w);
+ }
+ useArray(newArr,true,CPP_DEALLOC,nbOfTuples,nbOfComp1+nbOfComp2);
+ std::vector<int> compIds(nbOfComp2);
+ for(int i=0;i<nbOfComp2;i++)
+ compIds[i]=nbOfComp1+i;
+ copyPartOfStringInfoFrom2(compIds,*other);
+}
+
void DataArrayInt::setSelectedComponents(const DataArrayInt *a, const std::vector<int>& compoIds) throw(INTERP_KERNEL::Exception)
{
copyPartOfStringInfoFrom2(compoIds,*a);
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;i<newNbOfTuples;i++,pt+=stepTuples*nbComp)
+ for(int j=0;j<newNbOfComp;j++,srcPt++)
+ pt[j*stepComp]=*srcPt;
}
-DataArrayInt *DataArrayInt::aggregate(const DataArrayInt *a1, const DataArrayInt *a2, int offsetA2)
+/*!
+ * 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::setPartOfValuesSimple1(int a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp) 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();
- 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<newNbOfTuples;i++,pt+=stepTuples*nbComp)
+ for(int j=0;j<newNbOfComp;j++)
+ pt[j*stepComp]=a;
}
/*!
- * 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<newNb and that appears in no groups will appears with 0 in return array.
- *
- * @param groups in arrays specifying ids of each groups.
- * @param newNb specifies size of whole set. Must be at least equal to max eltid in 'groups'.
- * @return an array of size newNb specifying fid of each item.
+ * 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.
*/
-DataArrayInt *DataArrayInt::makePartition(const std::vector<DataArrayInt *>& groups, int newNb, std::vector< std::vector<int> >& 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<DataArrayInt *>::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<sfid;j++)
- {
- bool found=false;
- for(int i=0;i<nbOfElem;i++)
- {
+ const char msg[]="DataArrayInt::setPartOfValues2";
+ checkAllocated();
+ a->checkAllocated();
+ 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;j<newNbOfComp;j++,srcPt++)
+ {
+ DataArray::CheckValueInRange(nbOfTuples,*w,"invalid tuple id");
+ pt[(*w)*nbComp+j*stepComp]=*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::setPartOfValuesSimple3(int a, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp) throw(INTERP_KERNEL::Exception)
+{
+ const char msg[]="DataArrayInt::setPartOfValuesSimple3";
+ 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 *pt=getPointer()+bgComp;
+ for(const int *w=bgTuples;w!=endTuples;w++)
+ for(int j=0;j<newNbOfComp;j++)
+ {
+ DataArray::CheckValueInRange(nbOfTuples,*w,"invalid tuple id");
+ pt[(*w)*nbComp+j*stepComp]=a;
+ }
+}
+
+void DataArrayInt::SetArrayIn(DataArrayInt *newArray, DataArrayInt* &arrayToSet)
+{
+ if(newArray!=arrayToSet)
+ {
+ if(arrayToSet)
+ arrayToSet->decrRef();
+ 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<int> res;
+ int nbOfTuples=getNumberOfTuples();
+ for(int i=0;i<nbOfTuples;i++,cptr++)
+ if(*cptr==val)
+ res.push_back(i);
+ DataArrayInt *ret=DataArrayInt::New();
+ ret->alloc(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<int> res;
+ int nbOfTuples=getNumberOfTuples();
+ for(int i=0;i<nbOfTuples;i++,cptr++)
+ if(*cptr!=val)
+ res.push_back(i);
+ DataArrayInt *ret=DataArrayInt::New();
+ ret->alloc(res.size(),1);
+ std::copy(res.begin(),res.end(),ret->getPointer());
+ return ret;
+}
+
+DataArrayInt *DataArrayInt::getIdsEqualList(const std::vector<int>& 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<int> vals2(vals.begin(),vals.end());
+ const int *cptr=getConstPointer();
+ std::vector<int> res;
+ int nbOfTuples=getNumberOfTuples();
+ for(int i=0;i<nbOfTuples;i++,cptr++)
+ if(vals2.find(*cptr)!=vals2.end())
+ res.push_back(i);
+ DataArrayInt *ret=DataArrayInt::New();
+ ret->alloc(res.size(),1);
+ std::copy(res.begin(),res.end(),ret->getPointer());
+ return ret;
+}
+
+DataArrayInt *DataArrayInt::getIdsNotEqualList(const std::vector<int>& 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<int> vals2(vals.begin(),vals.end());
+ const int *cptr=getConstPointer();
+ std::vector<int> res;
+ int nbOfTuples=getNumberOfTuples();
+ for(int i=0;i<nbOfTuples;i++,cptr++)
+ if(vals2.find(*cptr)==vals2.end())
+ res.push_back(i);
+ DataArrayInt *ret=DataArrayInt::New();
+ ret->alloc(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<int>& 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<int> 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<const DataArrayInt *>& a) throw(INTERP_KERNEL::Exception)
+{
+ if(a.empty())
+ throw INTERP_KERNEL::Exception("DataArrayInt::Aggregate : input list must be NON EMPTY !");
+ std::vector<const DataArrayInt *>::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<nbOfTuple;i++,ptr+=nbOfComp)
+ *ptr=a*(*ptr)+b;
+ declareAsNew();
+}
+
+void DataArrayInt::applyLin(int a, int b) throw(INTERP_KERNEL::Exception)
+{
+ checkAllocated();
+ int *ptr=getPointer();
+ int nbOfElems=getNbOfElems();
+ for(int i=0;i<nbOfElems;i++,ptr++)
+ *ptr=a*(*ptr)+b;
+ declareAsNew();
+}
+
+/*!
+ * This method applies the operation 'numerator/x' for each element 'x' in 'this'.
+ * If there is a value in 'this' exactly equal to 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::applyInv(int numerator) throw(INTERP_KERNEL::Exception)
+{
+ checkAllocated();
+ int *ptr=getPointer();
+ int nbOfElems=getNbOfElems();
+ for(int i=0;i<nbOfElems;i++,ptr++)
+ {
+ if(*ptr!=0)
+ {
+ *ptr=numerator/(*ptr);
+ }
+ else
+ {
+ std::ostringstream oss; oss << "DataArrayInt::applyInv : presence of null value in tuple #" << i/getNumberOfComponents() << " component #" << i%getNumberOfComponents();
+ oss << " !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ declareAsNew();
+}
+
+void DataArrayInt::applyDivideBy(int val) throw(INTERP_KERNEL::Exception)
+{
+ if(val==0)
+ throw INTERP_KERNEL::Exception("DataArrayInt::applyDivideBy : Trying to divide by 0 !");
+ checkAllocated();
+ int *ptr=getPointer();
+ int nbOfElems=getNbOfElems();
+ std::transform(ptr,ptr+nbOfElems,ptr,std::bind2nd(std::divides<int>(),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<int>(),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;i<nbOfElems;i++,ptr++)
+ {
+ if(*ptr>0)
+ {
+ *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<const DataArrayInt *> arr(2);
+ arr[0]=a1; arr[1]=a2;
+ return Meld(arr);
+}
+
+DataArrayInt *DataArrayInt::Meld(const std::vector<const DataArrayInt *>& a) throw(INTERP_KERNEL::Exception)
+{
+ if(a.empty())
+ throw INTERP_KERNEL::Exception("DataArrayInt::Meld : array must be NON empty !");
+ std::vector<const DataArrayInt *>::const_iterator it;
+ for(it=a.begin();it!=a.end();it++)
+ (*it)->checkAllocated();
+ it=a.begin();
+ int nbOfTuples=(*it)->getNumberOfTuples();
+ std::vector<int> nbc(a.size());
+ std::vector<const int *> 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;i<nbOfTuples;i++)
+ for(int j=0;j<(int)a.size();j++)
+ {
+ retPtr=std::copy(pts[j],pts[j]+nbc[j],retPtr);
+ pts[j]+=nbc[j];
+ }
+ int k=0;
+ for(int i=0;i<(int)a.size();i++)
+ for(int j=0;j<nbc[i];j++,k++)
+ ret->setInfoOnComponent(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<newNb and that appears in no groups will appears with 0 in return array.
+ *
+ * @param groups in arrays specifying ids of each groups.
+ * @param newNb specifies size of whole set. Must be at least equal to max eltid in 'groups'.
+ * @return an array of size newNb specifying fid of each item.
+ */
+DataArrayInt *DataArrayInt::MakePartition(const std::vector<const DataArrayInt *>& groups, int newNb, std::vector< std::vector<int> >& 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 DataArrayInt *>::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<sfid;j++)
+ {
+ bool found=false;
+ for(int i=0;i<nbOfElem;i++)
+ {
if(retPtr[ptr[i]]==j)
{
retPtr[ptr[i]]=fid;
fidsOfGroups.clear();
fidsOfGroups.resize(groups.size());
int grId=0;
- for(std::vector<DataArrayInt *>::const_iterator iter=groups.begin();iter!=groups.end();iter++,grId++)
+ for(std::vector<const DataArrayInt *>::const_iterator iter=groups.begin();iter!=groups.end();iter++,grId++)
{
std::set<int> tmp;
const int *ptr=(*iter)->getConstPointer();
return ret;
}
-int *DataArrayInt::checkAndPreparePermutation(const int *start, const int *end)
+DataArrayInt *DataArrayInt::BuildUnion(const std::vector<const DataArrayInt *>& a) throw(INTERP_KERNEL::Exception)
+{
+ int valm=std::numeric_limits<int>::max();
+ for(std::vector<const DataArrayInt *>::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<int> r;
+ for(std::vector<const DataArrayInt *>::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<const DataArrayInt *>& a) throw(INTERP_KERNEL::Exception)
+{
+ int valm=std::numeric_limits<int>::max();
+ for(std::vector<const DataArrayInt *>::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<int> r;
+ for(std::vector<const DataArrayInt *>::const_iterator it=a.begin();it!=a.end();it++)
+ {
+ const int *pt=(*it)->getConstPointer();
+ int nbOfTuples=(*it)->getNumberOfTuples();
+ std::set<int> s1(pt,pt+nbOfTuples);
+ if(it!=a.begin())
+ {
+ std::set<int> 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<bool> tmp(nbOfElement);
+ const int *pt=getConstPointer();
+ int nbOfTuples=getNumberOfTuples();
+ for(const int *w=pt;w!=pt+nbOfTuples;w++)
+ if(*w>=0 && *w<nbOfElement)
+ tmp[*w]=true;
+ else
+ throw INTERP_KERNEL::Exception("DataArrayInt::buildComplement : an element is not in valid range : [0,nbOfElement) !");
+ int nbOfRetVal=std::count(tmp.begin(),tmp.end(),false);
+ DataArrayInt *ret=DataArrayInt::New();
+ ret->alloc(nbOfRetVal,1);
+ int j=0;
+ int *retPtr=ret->getPointer();
+ for(int i=0;i<nbOfElement;i++)
+ if(!tmp[i])
+ retPtr[j++]=i;
+ return ret;
+}
+
+DataArrayInt *DataArrayInt::buildSubstraction(const DataArrayInt *other) const throw(INTERP_KERNEL::Exception)
+{
+ checkAllocated();
+ other->checkAllocated();
+ 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<int> s1(pt,pt+nbOfTuples);
+ pt=other->getConstPointer();
+ nbOfTuples=other->getNumberOfTuples();
+ std::set<int> s2(pt,pt+nbOfTuples);
+ std::vector<int> r;
+ std::set_difference(s1.begin(),s1.end(),s2.begin(),s2.end(),std::back_insert_iterator< std::vector<int> >(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::vector<const DataArrayInt *>arrs(2);
+ arrs[0]=this; arrs[1]=other;
+ return BuildUnion(arrs);
+}
+
+DataArrayInt *DataArrayInt::buildIntersection(const DataArrayInt *other) const throw(INTERP_KERNEL::Exception)
+{
+ std::vector<const DataArrayInt *>arrs(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<int>());
+ 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<nbOfTuples;i++)
+ {
+ int tmp2=work[i];
+ work[i]=work[i-1]+tmp;
+ tmp=tmp2;
+ }
+ declareAsNew();
+}
+
+/*!
+ * This method returns all different values found in 'this'.
+ */
+std::set<int> DataArrayInt::getDifferentValues() const throw(INTERP_KERNEL::Exception)
+{
+ checkAllocated();
+ std::set<int> 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<int>());
+ 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<int>());
+ 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<int>());
+ 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<int>());
+ 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<int>());
+ 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<nbOfTuple;i++)
+ res=std::transform(aMaxPtr+i*nbOfCompMax,aMaxPtr+(i+1)*nbOfCompMax,res,std::bind2nd(std::multiplies<int>(),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<int>());
+ }
+ else
+ {
+ if(nbOfComp2==1)
+ {
+ const int *ptr=other->getConstPointer();
+ int *myPtr=getPointer();
+ for(int i=0;i<nbOfTuple;i++)
+ myPtr=std::transform(myPtr,myPtr+nbOfComp,myPtr,std::bind2nd(std::multiplies<int>(),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<int>());
+ 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<nbOfTuple;i++)
+ res=std::transform(a1Ptr+i*nbOfComp,a1Ptr+(i+1)*nbOfComp,res,std::bind2nd(std::divides<int>(),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<int>());
+ }
+ else
+ {
+ if(nbOfComp2==1)
+ {
+ const int *ptr=other->getConstPointer();
+ int *myPtr=getPointer();
+ for(int i=0;i<nbOfTuple;i++)
+ myPtr=std::transform(myPtr,myPtr+nbOfComp,myPtr,std::bind2nd(std::divides<int>(),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<int>());
+ 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<int>());
+ declareAsNew();
+}
+
+int *DataArrayInt::CheckAndPreparePermutation(const int *start, const int *end)
{
int sz=std::distance(start,end);
int *ret=new int[sz];
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<int>& 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<std::string>& tinyInfo) const
+{
+ if(isAllocated())
+ {
+ int nbOfCompo=getNumberOfComponents();
+ tinyInfo.resize(nbOfCompo+1);
+ tinyInfo[0]=getName();
+ for(int i=0;i<nbOfCompo;i++)
+ tinyInfo[i+1]=getInfoOnComponent(i);
+ }
+ else
+ {
+ tinyInfo.resize(1);
+ tinyInfo[0]=getName();
+ }
+}
+
+/*!
+ * Useless method for end user. Only for MPI/Corba/File serialsation for multi arrays class.
+ * This method returns if a feeding is needed.
+ */
+bool DataArrayInt::resizeForUnserialization(const std::vector<int>& 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<int>& tinyInfoI, const std::vector<std::string>& tinyInfoS)
+{
+ setName(tinyInfoS[0].c_str());
+ if(isAllocated())
+ {
+ int nbOfCompo=getNumberOfComponents();
+ for(int i=0;i<nbOfCompo;i++)
+ setInfoOnComponent(i,tinyInfoS[i+1].c_str());
+ }
+}
-// 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_HXX__
#include "MEDCouplingRefCountObject.hxx"
#include "InterpKernelException.hxx"
+#include <set>
#include <string>
#include <vector>
#include <iterator>
public:
MemArray():_nb_of_elem(-1),_ownership(false),_dealloc(CPP_DEALLOC) { }
MemArray(const MemArray<T>& 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(); }
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);
MEDCOUPLING_EXPORT void reprWithoutNameStream(std::ostream& stream) const;
MEDCOUPLING_EXPORT std::string getName() const { return _name; }
MEDCOUPLING_EXPORT const std::vector<std::string> &getInfoOnComponent() const { return _info_on_compo; }
+ MEDCOUPLING_EXPORT std::vector<std::string> getVarsOnComponent() const;
+ MEDCOUPLING_EXPORT std::vector<std::string> 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;
{
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;
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<int>& 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<int>& 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); }
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);
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<std::string>& 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<const DataArrayDouble *>& 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<const DataArrayDouble *>& 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<int>& tinyInfo) const;
+ void getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const;
+ bool resizeForUnserialization(const std::vector<int>& tinyInfoI);
+ void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<std::string>& tinyInfoS);
private:
DataArrayDouble() { }
private:
{
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<int>& 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<int>& 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<DataArrayInt *>& groups, int newNb, std::vector< std::vector<int> >& 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<int>& vals) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT DataArrayInt *getIdsNotEqualList(const std::vector<int>& vals) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT bool presenceOfValue(const std::vector<int>& 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<const DataArrayInt *>& 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<const DataArrayInt *>& a) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT static DataArrayInt *MakePartition(const std::vector<const DataArrayInt *>& groups, int newNb, std::vector< std::vector<int> >& fidsOfGroups);
+ MEDCOUPLING_EXPORT static DataArrayInt *BuildUnion(const std::vector<const DataArrayInt *>& a) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT static DataArrayInt *BuildIntersection(const std::vector<const DataArrayInt *>& 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<int> 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<int>& tinyInfo) const;
+ void getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const;
+ bool resizeForUnserialization(const std::vector<int>& tinyInfoI);
+ void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<std::string>& tinyInfoS);
private:
DataArrayInt() { }
private:
-// 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__
T *pt=_pointer.getPointer();
std::fill(pt,pt+_nb_of_elem,val);
}
+
+ template<class T>
+ T *MemArray<T>::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<nbOfTuples;i++)
+ for(int j=0;j<nbOfComp;j++,w++)
+ *w=pt[j*nbOfTuples+i];
+ return ret;
+ }
+
+ template<class T>
+ T *MemArray<T>::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<nbOfComp;i++)
+ for(int j=0;j<nbOfTuples;j++,w++)
+ *w=pt[j*nbOfComp+i];
+ return ret;
+ }
+
+ template<class T>
+ void MemArray<T>::sort()
+ {
+ T *pt=_pointer.getPointer();
+ std::sort(pt,pt+_nb_of_elem);
+ }
template<class T>
void MemArray<T>::alloc(int nbOfElements)
-// 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"
#include "MEDCouplingAutoRefCountObjectPtr.hxx"
#include <set>
+#include <cmath>
#include <sstream>
#include <iterator>
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.
*/
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;
}
/*!
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;
}
/*!
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<MEDCouplingFieldDouble> 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<std::string>& varsOrder, const char *func) const
+{
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> 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<int>& elts) const
+{
+ int ret=getCellContainingPoint(pos,eps);
+ elts.push_back(ret);
+}
+
+void MEDCouplingMesh::getCellsContainingPoints(const double *pos, int nbOfPoints, double eps, std::vector<int>& elts, std::vector<int>& eltsIndex) const
+{
+ eltsIndex.resize(nbOfPoints+1);
+ eltsIndex[0]=0;
+ elts.clear();
+ int spaceDim=getSpaceDimension();
+ const double *work=pos;
+ for(int i=0;i<nbOfPoints;i++,work+=spaceDim)
+ {
+ int ret=getCellContainingPoint(work,eps);
+ if(ret>=0)
+ {
+ elts.push_back(ret);
+ eltsIndex[i+1]=eltsIndex[i]+1;
+ }
+ else
+ eltsIndex[i+1]=eltsIndex[i];
+ }
+}
-// 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__
#include "NormalizedUnstructuredMesh.hxx"
#include "InterpKernelException.hxx"
+#include <set>
#include <vector>
namespace ParaMEDMEM
class DataArrayInt;
class DataArrayDouble;
+ class MEDCouplingUMesh;
class MEDCouplingFieldDouble;
class MEDCOUPLING_EXPORT MEDCouplingMesh : public RefCountObject, public TimeLabel
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;
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;
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<INTERP_KERNEL::NormalizedCellType> getAllGeoTypes() const = 0;
virtual void getNodeIdsOfCell(int cellId, std::vector<int>& conn) const = 0;
virtual DataArrayInt *getCellIdsFullyIncludedInNodeIds(const int *partBg, const int *partEnd) const;
virtual void getCoordinatesOfNode(int nodeId, std::vector<double>& coo) const = 0;
virtual std::string simpleRepr() const = 0;
virtual std::string advancedRepr() const = 0;
// tools
+ virtual DataArrayInt *checkTypeConsistencyAndContig(const std::vector<int>& code, const std::vector<const DataArrayInt *>& 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<int>& elts) const;
+ virtual void getCellsContainingPoints(const double *pos, int nbOfPoints, double eps, std::vector<int>& elts, std::vector<int>& 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<std::string>& 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;
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<int>& tinyInfo, std::vector<std::string>& littleStrings) const = 0;
+ virtual void getTinySerializationInformation(std::vector<double>& tinyInfoD, std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const = 0;
virtual void resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings) const = 0;
virtual void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const = 0;
- virtual void unserialization(const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2,
+ virtual void unserialization(const std::vector<double>& tinyInfoD, const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2,
const std::vector<std::string>& 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;
};
}
--- /dev/null
+// 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<MEDCouplingFieldDouble *>& 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<sz;i++)
+ {
+ const MEDCouplingFieldDouble *f1=_fs[i];
+ const MEDCouplingFieldDouble *f2=other->_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<int> refs1,refs2;
+ std::vector<MEDCouplingMesh *> ms1=getDifferentMeshes(refs1);
+ std::vector<MEDCouplingMesh *> ms2=other->getDifferentMeshes(refs2);
+ if(ms1.size()!=ms2.size())
+ return false;
+ if(refs1!=refs2)
+ return false;
+ std::vector< std::vector<int> > refs3,refs4;
+ std::vector<DataArrayDouble *> das1=getDifferentArrays(refs3);
+ std::vector<DataArrayDouble *> 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<MEDCouplingFieldDouble> >::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<MEDCouplingFieldDouble> >::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<MEDCouplingFieldDouble> >::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<MEDCouplingFieldDouble> >::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<MEDCouplingMesh *> ms;
+ std::vector<int> 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;i<sz;i++)
+ if(!_fs[i]->isEqualWithoutConsideringStr(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<const MEDCouplingFieldDouble *> MEDCouplingMultiFields::getFields() const
+{
+ std::vector<const MEDCouplingFieldDouble *> 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<MEDCouplingFieldDouble> >::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<MEDCouplingMesh *> MEDCouplingMultiFields::getMeshes() const throw(INTERP_KERNEL::Exception)
+{
+ std::vector<MEDCouplingMesh *> ms;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> >::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<MEDCouplingMesh *>(m));
+ }
+ return ms;
+}
+
+std::vector<MEDCouplingMesh *> MEDCouplingMultiFields::getDifferentMeshes(std::vector<int>& refs) const throw(INTERP_KERNEL::Exception)
+{
+ refs.resize(_fs.size());
+ std::vector<MEDCouplingMesh *> ms;
+ int id=0;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> >::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<MEDCouplingMesh *>::iterator it=std::find(ms.begin(),ms.end(),m);
+ if(it==ms.end())
+ {
+ ms.push_back(const_cast<MEDCouplingMesh *>(m));
+ refs[id]=ms.size()-1;
+ }
+ else
+ refs[id]=std::distance(ms.begin(),it);
+ }
+ else
+ refs[id]=-1;
+ }
+ return ms;
+}
+
+std::vector<DataArrayDouble *> MEDCouplingMultiFields::getArrays() const throw(INTERP_KERNEL::Exception)
+{
+ std::vector<DataArrayDouble *> tmp;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> >::const_iterator it=_fs.begin();it!=_fs.end();it++)
+ {
+ std::vector<DataArrayDouble *> tmp2=(*it)->getArrays();
+ tmp.insert(tmp.end(),tmp2.begin(),tmp2.end());
+ }
+ return tmp;
+}
+
+std::vector<DataArrayDouble *> MEDCouplingMultiFields::getDifferentArrays(std::vector< std::vector<int> >& refs) const throw(INTERP_KERNEL::Exception)
+{
+ refs.resize(_fs.size());
+ int id=0;
+ std::vector<DataArrayDouble *> ret;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> >::const_iterator it=_fs.begin();it!=_fs.end();it++,id++)
+ {
+ std::vector<DataArrayDouble *> tmp2;
+ if((const MEDCouplingFieldDouble *)(*it))
+ {
+ tmp2=(*it)->getArrays();
+ refs[id].resize(tmp2.size());
+ }
+ else
+ refs[id].clear();
+ int id2=0;
+ for(std::vector<DataArrayDouble *>::const_iterator it2=tmp2.begin();it2!=tmp2.end();it2++,id2++)
+ {
+ if(*it2)
+ {
+ std::vector<DataArrayDouble *>::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<MEDCouplingFieldDouble> >::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<MEDCouplingFieldDouble *>& 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<int> refs;
+ std::vector< std::vector<int> > refs2;
+ std::vector<MEDCouplingMesh *> ms=other.getDifferentMeshes(refs);
+ int msLgh=ms.size();
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> > ms2(msLgh);
+ for(int i=0;i<msLgh;i++)
+ ms2[i]=ms[i]->deepCpy();
+ std::vector<DataArrayDouble *> das=other.getDifferentArrays(refs2);
+ int dasLgth=das.size();
+ std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > das2(dasLgth);
+ for(int i=0;i<dasLgth;i++)
+ das2[i]=das[i]->deepCpy();
+ for(int i=0;i<sz;i++)
+ {
+ if((const MEDCouplingFieldDouble *)other._fs[i])
+ {
+ MEDCouplingFieldTemplate *tmp=MEDCouplingFieldTemplate::New(other._fs[i]);
+ _fs[i]=MEDCouplingFieldDouble::New(tmp,other._fs[i]->getTimeDiscretization());
+ tmp->decrRef();
+ if(refs[i]!=-1)
+ _fs[i]->setMesh(ms2[refs[i]]);
+ int nbOfArr=refs2[i].size();
+ std::vector<DataArrayDouble *> tmp2(nbOfArr);
+ for(int j=0;j<nbOfArr;j++)
+ {
+ if(refs2[i][j]!=-1)
+ tmp2[j]=das2[refs2[i][j]];
+ else
+ tmp2[j]=0;
+ }
+ _fs[i]->setArrays(tmp2);
+ std::vector<int> tinyInfo;
+ std::vector<double> 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<int>& tinyInfo, std::vector<double>& tinyInfo2, int& nbOfDiffMeshes, int& nbOfDiffArr) const
+{
+ std::vector<int> refs;
+ std::vector<MEDCouplingMesh *> ms=getDifferentMeshes(refs);
+ nbOfDiffMeshes=ms.size();
+ std::vector< std::vector<int> > refs2;
+ std::vector<DataArrayDouble *> fs=getDifferentArrays(refs2);
+ nbOfDiffArr=fs.size();
+ //
+ int sz=refs.size();//==_fs.size()
+ int sz2=0;
+ for(int i=0;i<sz;i++)
+ sz2+=refs2[i].size();
+ //
+ tinyInfo2.clear();
+ std::vector<int> doubleDaInd(sz);
+ std::vector<int> timeDiscrInt;
+ tinyInfo.resize(sz2+5*sz+3);
+ tinyInfo[0]=sz;
+ tinyInfo[1]=sz2;
+ for(int i=0;i<sz;i++)
+ {
+ std::vector<double> tmp;
+ std::vector<int> 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;i<sz;i++)
+ tinyInfo[i+3]=refs[i];
+ for(int i=0;i<sz;i++)
+ tinyInfo[i+sz+3]=refs2[i].size();
+ for(int i=0;i<sz;i++)
+ tinyInfo[i+2*sz+3]=(int)_fs[i]->getTimeDiscretization();
+ int k=0;
+ for(int i=0;i<sz;i++)
+ for(std::vector<int>::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<int>& tinyInfoI, const std::vector<double>& tinyInfoD,
+ const std::vector<MEDCouplingFieldTemplate *>& ft, const std::vector<MEDCouplingMesh *>& ms,
+ const std::vector<DataArrayDouble *>& das)
+{
+ int sz=tinyInfoI[0];
+ _fs.resize(sz);
+ int sz2=tinyInfoI[1];
+ // dealing with ft with no mesh set.
+ for(int i=0;i<sz;i++)
+ {
+ int meshId=tinyInfoI[3+i];
+ if(meshId!=-1)
+ ft[i]->setMesh(ms[meshId]);
+ }
+ // dealing with fieldtemplate->fielddouble
+ int k=0;
+ int offI=0;
+ int offD=0;
+ for(int i=0;i<sz;i++)
+ {
+ _fs[i]=MEDCouplingFieldDouble::New(ft[i],(TypeOfTimeDiscretization)tinyInfoI[2*sz+3+i]);
+ int sz3=tinyInfoI[sz+i+3];
+ std::vector<DataArrayDouble *> tmp(sz3);
+ for(int j=0;j<sz3;j++,k++)
+ {
+ int daId=tinyInfoI[5*sz+k+3];
+ if(daId!=-1)
+ tmp[j]=das[daId];
+ else
+ tmp[j]=0;
+ }
+ _fs[i]->setArrays(tmp);
+ // time discr tiny info
+ int lgthI=tinyInfoI[4*sz+3+i];
+ int lgthD=tinyInfoI[3*sz+3+i];
+ //
+ std::vector<int> tdInfoI(tinyInfoI.begin()+sz2+5*sz+3+offI,tinyInfoI.begin()+sz2+5*sz+3+offI+lgthI);
+ std::vector<double> tdInfoD(tinyInfoD.begin()+offD,tinyInfoD.begin()+offD+lgthD);
+ _fs[i]->getTimeDiscretizationUnderGround()->finishUnserialization2(tdInfoI,tdInfoD);
+ //
+ offI+=lgthI;
+ offD+=lgthD;
+ }
+}
--- /dev/null
+// 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 <vector>
+
+namespace ParaMEDMEM
+{
+ class MEDCouplingMesh;
+ class DataArrayDouble;
+ class MEDCouplingFieldDouble;
+ class MEDCouplingFieldTemplate;
+
+ class MEDCouplingMultiFields : public RefCountObject, public TimeLabel
+ {
+ public:
+ static MEDCouplingMultiFields *New(const std::vector<MEDCouplingFieldDouble *>& 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<const MEDCouplingFieldDouble *> getFields() const;
+ int getNumberOfFields() const;
+ const MEDCouplingFieldDouble *getFieldAtPos(int id) const throw(INTERP_KERNEL::Exception);
+ virtual std::vector<MEDCouplingMesh *> getMeshes() const throw(INTERP_KERNEL::Exception);
+ virtual std::vector<MEDCouplingMesh *> getDifferentMeshes(std::vector<int>& refs) const throw(INTERP_KERNEL::Exception);
+ virtual std::vector<DataArrayDouble *> getArrays() const throw(INTERP_KERNEL::Exception);
+ virtual std::vector<DataArrayDouble *> getDifferentArrays(std::vector< std::vector<int> >& refs) const throw(INTERP_KERNEL::Exception);
+ void updateTime() const;
+ void getTinySerializationInformation(std::vector<int>& tinyInfo, std::vector<double>& tinyInfo2, int& nbOfDiffMeshes, int& nbOfDiffArr) const;
+ void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD,
+ const std::vector<MEDCouplingFieldTemplate *>& ft, const std::vector<MEDCouplingMesh *>& ms,
+ const std::vector<DataArrayDouble *>& das);
+ virtual void checkCoherency() const throw(INTERP_KERNEL::Exception);
+ protected:
+ MEDCouplingMultiFields(const std::vector<MEDCouplingFieldDouble *>& fs) throw(INTERP_KERNEL::Exception);
+ MEDCouplingMultiFields(const MEDCouplingMultiFields& other);
+ MEDCouplingMultiFields();
+ protected:
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> > _fs;
+ };
+}
+
+#endif
+
-// 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"
-// 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__
-// 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__
-// 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
-// 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__
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;
private:
void prepare();
private:
- ParaMEDMEM::MEDCouplingUMesh *_mesh;
+ const ParaMEDMEM::MEDCouplingUMesh *_mesh;
int *_conn_for_interp;
int *_conn_index_for_interp;
};
-// 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__
#include <limits>
template<int SPACEDIM,int MESHDIM>
-MEDCouplingNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::MEDCouplingNormalizedUnstructuredMesh(ParaMEDMEM::MEDCouplingUMesh *mesh):_mesh(mesh)
+MEDCouplingNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::MEDCouplingNormalizedUnstructuredMesh(const ParaMEDMEM::MEDCouplingUMesh *mesh):_mesh(mesh)
{
if(_mesh)
_mesh->incrRef();
boundingBox[i]=std::numeric_limits<double>::max();
boundingBox[SPACEDIM+i]=-std::numeric_limits<double>::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<SPACEDIM;j++)
template<int SPACEDIM,int MESHDIM>
const double *MEDCouplingNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::getCoordinatesPtr() const
{
- ParaMEDMEM::DataArrayDouble *array=_mesh->getCoords();
+ const ParaMEDMEM::DataArrayDouble *array=_mesh->getCoords();
return array->getConstPointer();
}
MEDCouplingNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::~MEDCouplingNormalizedUnstructuredMesh()
{
if(_mesh)
- _mesh->decrRef();
+ ((ParaMEDMEM::MEDCouplingUMesh *)_mesh)->decrRef();
releaseTempArrays();
}
-// 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"
throw INTERP_KERNEL::Exception("Unable to get space dimension because no coordinates specified !");
}
-void MEDCouplingPointSet::updateTime()
+void MEDCouplingPointSet::updateTime() const
{
if(_coords)
{
}
}
-void MEDCouplingPointSet::setCoords(DataArrayDouble *coords)
+void MEDCouplingPointSet::setCoords(const DataArrayDouble *coords)
{
if( coords != _coords )
{
if (_coords)
_coords->decrRef();
- _coords=coords;
+ _coords=const_cast<DataArrayDouble *>(coords);
if(_coords)
_coords->incrRef();
declareAsNew();
/*!
* 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)
*/
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());
std::copy(c.begin(),c.end(),comm->getPointer());
}
+std::vector<int> MEDCouplingPointSet::getNodeIdsNearPoint(const double *pos, double eps) const throw(INTERP_KERNEL::Exception)
+{
+ std::vector<int> 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<int>& c, std::vector<int>& 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<double> bbox(2*nbNodes*spaceDim);
+ for(int i=0;i<nbNodes;i++)
+ {
+ for(int j=0;j<spaceDim;j++)
+ {
+ bbox[2*spaceDim*i+2*j]=coordsPtr[spaceDim*i+j];
+ bbox[2*spaceDim*i+2*j+1]=coordsPtr[spaceDim*i+j];
+ }
+ }
+ std::vector<int> 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.
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<int> commRemain(comm->getConstPointer(),comm->getConstPointer()+comm->getNumberOfTuples());
- std::vector<int> 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<nbOfGrps;i++)
+ pt[cPtr[cIPtr[i]]]=-(i+2);
int newNb=0;
for(int iNode=0;iNode<nbNodesOld;iNode++)
{
- if(retPtr[iNode]!=-1)
- continue;
- if(commRemain.empty())
- {
- retPtr[iNode]=newNb++;
- continue;
- }
- if(commRemain[0]!=iNode)
- retPtr[iNode]=newNb;
- else
+ if(pt[iNode]<0)
{
- for(std::vector<int>::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<int>(),delta));
+ if(pt[iNode]==-1)
+ pt[iNode]=newNb++;
+ else
+ {
+ int grpId=-(pt[iNode]+2);
+ for(int j=cIPtr[grpId];j<cIPtr[grpId+1];j++)
+ pt[cPtr[j]]=newNb;
+ newNb++;
+ }
}
- newNb++;
}
newNbOfNodes=newNb;
return ret;
* 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.
- * @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)
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<int> 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<oldNbOfNodes;i++)
+ {
+ std::transform(oldCoordsPtr+i*spaceDim,oldCoordsPtr+(i+1)*spaceDim,ptToFill+newNodeNumbers[i]*spaceDim,
+ ptToFill+newNodeNumbers[i]*spaceDim,std::plus<double>());
+ div[newNodeNumbers[i]]++;
+ }
+ for(int i=0;i<newNbOfNodes;i++)
+ ptToFill=std::transform(ptToFill,ptToFill+spaceDim,ptToFill,std::bind2nd(std::multiplies<double>(),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.
/*!
* 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<const MEDCouplingPointSet *>& ms) throw(INTERP_KERNEL::Exception)
+{
+ if(ms.empty())
+ throw INTERP_KERNEL::Exception("MEDCouplingPointSet::MergeNodesArray : input array must be NON EMPTY !");
+ std::vector<const MEDCouplingPointSet *>::const_iterator it=ms.begin();
+ std::vector<const DataArrayDouble *> 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)
{
/*!
* First step of serialization process. Used by ParaMEDMEM and MEDCouplingCorba to transfert data between process.
*/
-void MEDCouplingPointSet::getTinySerializationInformation(std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const
+void MEDCouplingPointSet::getTinySerializationInformation(std::vector<double>& tinyInfoD, std::vector<int>& tinyInfo, std::vector<std::string>& 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;i<spaceDim;i++)
- littleStrings[i+1]=getCoords()->getInfoOnComponent(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);
}
}
{
if(_coords)
{
- a2=getCoords();
+ a2=const_cast<DataArrayDouble *>(getCoords());
a2->incrRef();
}
else
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);
}
}
* Second and final unserialization process.
* @param tinyInfo must be equal to the result given by getTinySerializationInformation method.
*/
-void MEDCouplingPointSet::unserialization(const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, const std::vector<std::string>& littleStrings)
+void MEDCouplingPointSet::unserialization(const std::vector<double>& tinyInfoD, const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, const std::vector<std::string>& 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;i<tinyInfo[1];i++)
- getCoords()->setInfoOnComponent(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]);
+ }
}
/*!
{
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);
*/
MEDCouplingMesh *MEDCouplingPointSet::buildPart(const int *start, const int *end) const
{
- return buildPartOfMySelf(start,end,false);
+ return buildPartOfMySelf(start,end,true);
}
/*!
* 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
{
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);
-// 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__
{
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:
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;
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<int> getNodeIdsNearPoint(const double *pos, double eps) const throw(INTERP_KERNEL::Exception);
+ void getNodeIdsNearPoints(const double *pos, int nbOfNodes, double eps, std::vector<int>& c, std::vector<int>& 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;
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<int>& 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<const MEDCouplingPointSet *>& 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;
virtual void findBoundaryNodes(std::vector<int>& 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<int>& tinyInfo) const = 0;
//! size of returned tinyInfo must be always the same.
- void getTinySerializationInformation(std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const;
+ void getTinySerializationInformation(std::vector<double>& tinyInfoD, std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const;
void resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings) const;
void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const;
- void unserialization(const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2,
+ void unserialization(const std::vector<double>& tinyInfoD, const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2,
const std::vector<std::string>& littleStrings);
- virtual void giveElemsInBoundingBox(const double *bbox, double eps, std::vector<int>& elems) = 0;
- virtual void giveElemsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bbox, double eps, std::vector<int>& elems) = 0;
+ virtual void getCellsInBoundingBox(const double *bbox, double eps, std::vector<int>& elems) = 0;
+ virtual void getCellsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bbox, double eps, std::vector<int>& elems) = 0;
virtual DataArrayInt *zipCoordsTraducer() = 0;
protected:
virtual void checkFullyDefined() const throw(INTERP_KERNEL::Exception) = 0;
template<int SPACEDIM>
void findCommonNodesAlg(std::vector<double>& bbox,
int nbNodes, int limitNodeId, double prec, std::vector<int>& c, std::vector<int>& cI) const;
+ template<int SPACEDIM>
+ void findNodeIdsNearPointAlg(std::vector<double>& bbox, const double *pos, int nbNodes, double eps,
+ std::vector<int>& c, std::vector<int>& cI) const;
protected:
DataArrayDouble *_coords;
};
-// 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__
BBTree<SPACEDIM,int> myTree(&bbox[0],0,0,nbNodes,-prec);
double bb[2*SPACEDIM];
double prec2=prec*prec;
+ std::vector<bool> isDone(nbNodes);
+ for(int i=0;i<nbNodes;i++)
+ {
+ if(!isDone[i])
+ {
+ for(int j=0;j<SPACEDIM;j++)
+ {
+ bb[2*j]=coordsPtr[SPACEDIM*i+j];
+ bb[2*j+1]=coordsPtr[SPACEDIM*i+j];
+ }
+ std::vector<int> intersectingElems;
+ myTree.getIntersectingElems(bb,intersectingElems);
+ if(intersectingElems.size()>1)
+ {
+ std::vector<int> commonNodes;
+ for(std::vector<int>::const_iterator it=intersectingElems.begin();it!=intersectingElems.end();it++)
+ if(*it!=i)
+ if(*it>=limitNodeId)
+ if(INTERP_KERNEL::distance2<SPACEDIM>(coordsPtr+SPACEDIM*i,coordsPtr+SPACEDIM*(*it))<prec2)
+ {
+ commonNodes.push_back(*it);
+ isDone[*it]=true;
+ }
+ if(!commonNodes.empty())
+ {
+ cI.push_back(cI.back()+commonNodes.size()+1);
+ c.push_back(i);
+ c.insert(c.end(),commonNodes.begin(),commonNodes.end());
+ }
+ }
+ }
+ }
+ }
+
+ template<int SPACEDIM>
+ void MEDCouplingPointSet::findNodeIdsNearPointAlg(std::vector<double>& bbox, const double *pos, int nbNodes, double eps,
+ std::vector<int>& c, std::vector<int>& cI) const
+ {
+ const double *coordsPtr=_coords->getConstPointer();
+ BBTree<SPACEDIM,int> myTree(&bbox[0],0,0,getNumberOfNodes(),-eps);
+ double bb[2*SPACEDIM];
+ double eps2=eps*eps;
for(int i=0;i<nbNodes;i++)
{
- if(std::find(c.begin(),c.end(),i)!=c.end())
- continue;
for(int j=0;j<SPACEDIM;j++)
{
- bb[2*j]=coordsPtr[SPACEDIM*i+j];
- bb[2*j+1]=coordsPtr[SPACEDIM*i+j];
+ bb[2*j]=pos[SPACEDIM*i+j];
+ bb[2*j+1]=pos[SPACEDIM*i+j];
}
std::vector<int> intersectingElems;
myTree.getIntersectingElems(bb,intersectingElems);
- if(intersectingElems.size()>1)
- {
- std::vector<int> commonNodes;
- for(std::vector<int>::const_iterator it=intersectingElems.begin();it!=intersectingElems.end();it++)
- if(*it!=i)
- if(*it>=limitNodeId)
- if(INTERP_KERNEL::distance2<SPACEDIM>(coordsPtr+SPACEDIM*i,coordsPtr+SPACEDIM*(*it))<prec2)
- commonNodes.push_back(*it);
- if(!commonNodes.empty())
- {
- cI.push_back(cI.back()+commonNodes.size()+1);
- c.push_back(i);
- c.insert(c.end(),commonNodes.begin(),commonNodes.end());
- }
- }
+ std::vector<int> commonNodes;
+ for(std::vector<int>::const_iterator it=intersectingElems.begin();it!=intersectingElems.end();it++)
+ if(INTERP_KERNEL::distance2<SPACEDIM>(pos+SPACEDIM*i,coordsPtr+SPACEDIM*(*it))<eps2)
+ commonNodes.push_back(*it);
+ cI.push_back(cI.back()+commonNodes.size());
+ c.insert(c.end(),commonNodes.begin(),commonNodes.end());
}
}
}
-// 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 "MEDCouplingRefCountObject.hxx"
-// 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_MEDCOUPLINGREFCOUNTOBJECT_HXX__
-// 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 "MEDCouplingRemapper.hxx"
#include "MEDCouplingMemArray.hxx"
#include "MEDCouplingFieldDouble.hxx"
+#include "MEDCouplingFieldTemplate.hxx"
#include "MEDCouplingFieldDiscretization.hxx"
#include "MEDCouplingExtrudedMesh.hxx"
#include "MEDCouplingNormalizedUnstructuredMesh.txx"
#include "Interpolation1D.txx"
-#include "Interpolation2DCurve.txx"
+#include "Interpolation2DCurve.hxx"
#include "Interpolation2D.txx"
#include "Interpolation3D.txx"
-#include "Interpolation3DSurf.txx"
+#include "Interpolation3DSurf.hxx"
using namespace ParaMEDMEM;
int MEDCouplingRemapper::prepare(const MEDCouplingMesh *srcMesh, const MEDCouplingMesh *targetMesh, const char *method) throw(INTERP_KERNEL::Exception)
{
releaseData(true);
- _src_mesh=(MEDCouplingMesh *)srcMesh; _target_mesh=(MEDCouplingMesh *)targetMesh;
+ _src_mesh=const_cast<MEDCouplingMesh *>(srcMesh); _target_mesh=const_cast<MEDCouplingMesh *>(targetMesh);
_src_mesh->incrRef(); _target_mesh->incrRef();
int meshInterpType=((int)_src_mesh->getType()*16)+(int)_target_mesh->getType();
switch(meshInterpType)
}
}
+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())
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<std::map<int,double> > matrix1D;
return 1;
}
-void MEDCouplingRemapper::updateTime()
+void MEDCouplingRemapper::updateTime() const
{
}
-// 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__
class MEDCouplingMesh;
class MEDCouplingUMesh;
class MEDCouplingFieldDouble;
+ class MEDCouplingFieldTemplate;
}
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);
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);
-// 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"
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);
}
throw INTERP_KERNEL::Exception("time tolerance is expected to be greater than 0. !");
}
-void MEDCouplingTimeDiscretization::updateTime()
+void MEDCouplingTimeDiscretization::updateTime() const
{
if(_array)
updateTimeWith(*_array);
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)
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)
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))
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);
{
}
-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);
}
}
-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 !");
}
MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::doublyContractedProduct() const throw(INTERP_KERNEL::Exception)
{
MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
+ ret->setTimeUnit(getTimeUnit());
std::vector<DataArrayDouble *> arrays;
getArrays(arrays);
std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
{
std::vector<DataArrayDouble *> arrays;
getArrays(arrays);
- std::vector<DataArrayDouble *> arrays2(arrays.size());
+ std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
for(int j=0;j<(int)arrays.size();j++)
{
if(arrays[j])
else
arrays2[j]=0;
}
- setArrays(arrays2,0);
+ std::vector<DataArrayDouble *> 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<DataArrayDouble *> arrays;
getArrays(arrays);
- std::vector<DataArrayDouble *> arrays2(arrays.size());
+ std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
for(int j=0;j<(int)arrays.size();j++)
{
if(arrays[j])
else
arrays2[j]=0;
}
- setArrays(arrays2,0);
+ std::vector<DataArrayDouble *> 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<DataArrayDouble *> arrays;
+ getArrays(arrays);
+ std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > 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<DataArrayDouble *> 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<std::string>& varsOrder, const char *func)
+{
+ std::vector<DataArrayDouble *> arrays;
+ getArrays(arrays);
+ std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > 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<DataArrayDouble *> 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<DataArrayDouble *> arrays;
getArrays(arrays);
- std::vector<DataArrayDouble *> arrays2(arrays.size());
+ std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
for(int j=0;j<(int)arrays.size();j++)
{
if(arrays[j])
else
arrays2[j]=0;
}
- setArrays(arrays2,0);
+ std::vector<DataArrayDouble *> 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)
setArrays(arrays3,0);
}
+void MEDCouplingTimeDiscretization::fillFromAnalytic2(const DataArrayDouble *loc, int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception)
+{
+ std::vector<DataArrayDouble *> arrays;
+ getArrays(arrays);
+ std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
+ for(int j=0;j<(int)arrays.size();j++)
+ arrays2[j]=loc->applyFunc2(nbOfComp,func);
+ std::vector<DataArrayDouble *> 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<std::string>& varsOrder, const char *func) throw(INTERP_KERNEL::Exception)
+{
+ std::vector<DataArrayDouble *> arrays;
+ getArrays(arrays);
+ std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
+ for(int j=0;j<(int)arrays.size();j++)
+ arrays2[j]=loc->applyFunc3(nbOfComp,varsOrder,func);
+ std::vector<DataArrayDouble *> arrays3(arrays.size());
+ for(int j=0;j<(int)arrays.size();j++)
+ arrays3[j]=arrays2[j];
+ setArrays(arrays3,0);
+}
+
MEDCouplingNoTimeLabel::MEDCouplingNoTimeLabel()
{
}
{
std::ostringstream stream;
stream << REPR;
+ stream << "\nTime unit is : \"" << _time_unit << "\"";
return stream.str();
}
return otherC!=0;
}
+bool MEDCouplingNoTimeLabel::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const
+{
+ if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other))
+ return false;
+ const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
+ return otherC!=0;
+}
+
+bool MEDCouplingNoTimeLabel::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const
+{
+ if(!MEDCouplingTimeDiscretization::areCompatibleForMeld(other))
+ return false;
+ const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
+ return otherC!=0;
+}
+
bool MEDCouplingNoTimeLabel::isEqual(const MEDCouplingTimeDiscretization *other, double prec) const
{
const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(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<const MEDCouplingTimeDiscretization *>& other) const
+{
+ std::vector<const DataArrayDouble *> a(other.size());
+ int i=0;
+ for(std::vector<const MEDCouplingTimeDiscretization *>::const_iterator it=other.begin();it!=other.end();it++,i++)
+ {
+ const MEDCouplingNoTimeLabel *itC=dynamic_cast<const MEDCouplingNoTimeLabel *>(*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<const MEDCouplingNoTimeLabel *>(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);
const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(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();
const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(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();
const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(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();
const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(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();
const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(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();
const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(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();
const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(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();
const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(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();
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);
throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
}
+/*!
+ * idem getTinySerializationIntInformation except that it is for multi field fetch
+ */
+void MEDCouplingNoTimeLabel::getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const
+{
+ tinyInfo.clear();
+}
+
+/*!
+ * idem getTinySerializationDbleInformation except that it is for multi field fetch
+ */
+void MEDCouplingNoTimeLabel::getTinySerializationDbleInformation2(std::vector<double>& 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<int>& tinyInfoI, const std::vector<double>& tinyInfoD)
+{
+ _time_tolerance=tinyInfoD[0];
+}
+
MEDCouplingWithTimeStep::MEDCouplingWithTimeStep(const MEDCouplingWithTimeStep& other, bool deepCpy):MEDCouplingTimeDiscretization(other,deepCpy),
_time(other._time),_iteration(other._iteration),_order(other._order)
{
{
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();
}
_order=tinyInfoI[3];
}
+/*!
+ * idem getTinySerializationIntInformation except that it is for multi field fetch
+ */
+void MEDCouplingWithTimeStep::getTinySerializationIntInformation2(std::vector<int>& 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<double>& 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<int>& tinyInfoI, const std::vector<double>& 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))
return otherC!=0;
}
+bool MEDCouplingWithTimeStep::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const
+{
+ if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other))
+ return false;
+ const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
+ return otherC!=0;
+}
+
+bool MEDCouplingWithTimeStep::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const
+{
+ if(!MEDCouplingTimeDiscretization::areCompatibleForMeld(other))
+ return false;
+ const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
+ return otherC!=0;
+}
+
bool MEDCouplingWithTimeStep::isEqual(const MEDCouplingTimeDiscretization *other, double prec) const
{
const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(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<const MEDCouplingTimeDiscretization *>& other) const
+{
+ std::vector<const DataArrayDouble *> a(other.size());
+ int i=0;
+ for(std::vector<const MEDCouplingTimeDiscretization *>::const_iterator it=other.begin();it!=other.end();it++,i++)
+ {
+ const MEDCouplingWithTimeStep *itC=dynamic_cast<const MEDCouplingWithTimeStep *>(*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<const MEDCouplingWithTimeStep *>(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;
}
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;
const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(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();
const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(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();
const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(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();
const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(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();
const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(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();
const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(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();
const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(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();
_end_order=tinyInfoI[5];
}
+/*!
+ * idem getTinySerializationIntInformation except that it is for multi field fetch
+ */
+void MEDCouplingConstOnTimeInterval::getTinySerializationIntInformation2(std::vector<int>& 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<double>& 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<int>& tinyInfoI, const std::vector<double>& 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)
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();
}
bool MEDCouplingConstOnTimeInterval::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const
{
- if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other))
+ if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(other))
+ return false;
+ const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
+ return otherC!=0;
+}
+
+bool MEDCouplingConstOnTimeInterval::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const
+{
+ if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other))
+ return false;
+ const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
+ return otherC!=0;
+}
+
+bool MEDCouplingConstOnTimeInterval::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const
+{
+ if(!MEDCouplingTimeDiscretization::areCompatibleForMeld(other))
return false;
const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
return otherC!=0;
MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::aggregate(const MEDCouplingTimeDiscretization *other) const
{
- const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
+ const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(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<const MEDCouplingTimeDiscretization *>& other) const
+{
+ std::vector<const DataArrayDouble *> a(other.size());
+ int i=0;
+ for(std::vector<const MEDCouplingTimeDiscretization *>::const_iterator it=other.begin();it!=other.end();it++,i++)
+ {
+ const MEDCouplingConstOnTimeInterval *itC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(*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<const MEDCouplingConstOnTimeInterval *>(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;
}
const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(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();
const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(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();
const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(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();
const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(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();
const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(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();
const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(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();
const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(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();
const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(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();
_end_array=0;
}
-void MEDCouplingTwoTimeSteps::updateTime()
+void MEDCouplingTwoTimeSteps::updateTime() const
{
MEDCouplingTimeDiscretization::updateTime();
if(_end_array)
_end_array->copyStringInfoFrom(*otherC->_end_array);
}
-DataArrayDouble *MEDCouplingTwoTimeSteps::getEndArray() const
+const DataArrayDouble *MEDCouplingTwoTimeSteps::getEndArray() const
+{
+ return _end_array;
+}
+
+DataArrayDouble *MEDCouplingTwoTimeSteps::getEndArray()
{
return _end_array;
}
_end_order=tinyInfoI[5];
}
+/*!
+ * idem getTinySerializationIntInformation except that it is for multi field fetch
+ */
+void MEDCouplingTwoTimeSteps::getTinySerializationIntInformation2(std::vector<int>& 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<double>& 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<int>& tinyInfoI, const std::vector<double>& 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)
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();
}
if(!MEDCouplingTimeDiscretization::areCompatible(other))
return false;
const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(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
return otherC!=0;
}
+bool MEDCouplingLinearTime::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const
+{
+ if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other))
+ return false;
+ const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(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<const MEDCouplingLinearTime *>(other);
+ return otherC!=0;
+}
+
/*!
* vals is expected to be of size 2*_array->getNumberOfTuples()==_array->getNumberOfTuples()+_end_array->getNumberOfTuples()
*/
const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(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<const MEDCouplingTimeDiscretization *>& other) const
+{
+ std::vector<const DataArrayDouble *> a(other.size());
+ std::vector<const DataArrayDouble *> b(other.size());
+ int i=0;
+ for(std::vector<const MEDCouplingTimeDiscretization *>::const_iterator it=other.begin();it!=other.end();it++,i++)
+ {
+ const MEDCouplingLinearTime *itC=dynamic_cast<const MEDCouplingLinearTime *>(*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<const MEDCouplingLinearTime *>(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);
const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(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();
const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(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();
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;
const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(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();
const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(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();
const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(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();
const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(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();
const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(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();
-// 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__
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<const MEDCouplingTimeDiscretization *>& 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;
virtual void getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const;
virtual void resizeForUnserialization(const std::vector<int>& tinyInfoI, std::vector<DataArrayDouble *>& arrays);
virtual void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS);
+ virtual void getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const = 0;
+ virtual void getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const = 0;
+ virtual void finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD) = 0;
virtual MEDCouplingTimeDiscretization *performCpy(bool deepCpy) const = 0;
void setTimeTolerance(double val) { _time_tolerance=val; }
double getTimeTolerance() const { return _time_tolerance; }
virtual void setArray(DataArrayDouble *array, TimeLabel *owner);
virtual void setEndArray(DataArrayDouble *array, TimeLabel *owner);
virtual void setArrays(const std::vector<DataArrayDouble *>& 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<double>& vals, double *res) const = 0;
virtual void getArrays(std::vector<DataArrayDouble *>& arrays) const;
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;
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<std::string>& 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<std::string>& varsOrder, const char *func) throw(INTERP_KERNEL::Exception);
//
virtual ~MEDCouplingTimeDiscretization();
protected:
+ std::string _time_unit;
double _time_tolerance;
DataArrayDouble *_array;
protected:
std::string getStringRepr() const;
TypeOfTimeDiscretization getEnum() const { return DISCRETIZATION; }
MEDCouplingTimeDiscretization *aggregate(const MEDCouplingTimeDiscretization *other) const;
+ MEDCouplingTimeDiscretization *aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& 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;
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);
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<int>& tinyInfo) const;
+ void getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const;
+ void finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD);
public:
static const TypeOfTimeDiscretization DISCRETIZATION=NO_TIME;
static const char REPR[];
void copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other);
TypeOfTimeDiscretization getEnum() const { return DISCRETIZATION; }
MEDCouplingTimeDiscretization *aggregate(const MEDCouplingTimeDiscretization *other) const;
+ MEDCouplingTimeDiscretization *aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& 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;
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<int>& tinyInfo) const;
void getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const;
void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS);
+ void getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const;
+ void getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const;
+ void finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD);
MEDCouplingTimeDiscretization *performCpy(bool deepCpy) const;
void checkNoTimePresence() const throw(INTERP_KERNEL::Exception);
void checkTimePresence(double time) const throw(INTERP_KERNEL::Exception);
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<double>& vals, double *res) const;
void getValueOnTime(int eltId, double time, double *value) const throw(INTERP_KERNEL::Exception);
void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
void getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const;
void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS);
+ void getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const;
+ void getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const;
+ void finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& 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);
TypeOfTimeDiscretization getEnum() const { return DISCRETIZATION; }
std::string getStringRepr() const;
MEDCouplingTimeDiscretization *aggregate(const MEDCouplingTimeDiscretization *other) const;
+ MEDCouplingTimeDiscretization *aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& 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;
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:
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;
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<int>& tinyInfo) const;
void getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const;
void getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const;
void resizeForUnserialization(const std::vector<int>& tinyInfoI, std::vector<DataArrayDouble *>& arrays);
void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS);
+ void getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const;
+ void getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const;
+ void finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD);
std::vector< const DataArrayDouble *> getArraysForTime(double time) const throw(INTERP_KERNEL::Exception);
void setArrays(const std::vector<DataArrayDouble *>& arrays, TimeLabel *owner) throw(INTERP_KERNEL::Exception);
protected:
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<double>& 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<const MEDCouplingTimeDiscretization *>& 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;
-// 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"
{
}
- 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<other._time)
_time=other._time;
-// 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_TIMELABEL_HXX__
public:
TimeLabel& operator=(const TimeLabel& other);
//! This method should be called when write access has been done on this.
- void declareAsNew();
+ void declareAsNew() const;
//! This method should be called on high level classes as Field or Mesh to take into acount modifications done in aggragates objects.
- virtual void updateTime() = 0;
+ virtual void updateTime() const = 0;
unsigned int getTimeOfThis() const { return _time; }
protected:
TimeLabel();
virtual ~TimeLabel();
- void updateTimeWith(const TimeLabel& other);
+ void updateTimeWith(const TimeLabel& other) const;
private:
static unsigned int GLOBAL_TIME;
- unsigned int _time;
+ mutable unsigned int _time;
};
}
-// 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 "MEDCouplingUMesh.hxx"
#include "BBTree.txx"
#include "DirectedBoundingBox.hxx"
#include "InterpKernelMeshQuality.hxx"
+#include "InterpKernelCellSimplify.hxx"
+#include "InterpKernelGeo2DEdgeArcCircle.hxx"
#include "MEDCouplingAutoRefCountObjectPtr.hxx"
+#include "InterpKernelAutoPtr.hxx"
#include <sstream>
#include <numeric>
return new MEDCouplingUMesh(*this,recDeepCpy);
}
-void MEDCouplingUMesh::updateTime()
+void MEDCouplingUMesh::updateTime() const
{
MEDCouplingPointSet::updateTime();
if(_nodal_connec)
throw INTERP_KERNEL::Exception("No mesh dimension specified !");
for(std::set<INTERP_KERNEL::NormalizedCellType>::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);
}
}
+/*!
+ * 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<nbOfCells;i++)
+ {
+ const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel((INTERP_KERNEL::NormalizedCellType)ptr[ptrI[i]]);
+ if((int)cm.getDimension()!=meshDim)
+ {
+ std::ostringstream oss;
+ oss << "MEDCouplingUMesh::checkCoherency1 : cell << #" << i<< " with type Type " << cm.getRepr() << " in 'this' whereas meshdim == " << meshDim << " !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ int nbOfNodesInCell=ptrI[i+1]-ptrI[i]-1;
+ if(!cm.isDynamic())
+ if(nbOfNodesInCell!=(int)cm.getNumberOfNodes())
+ {
+ std::ostringstream oss;
+ oss << "MEDCouplingUMesh::checkCoherency1 : cell #" << i << " with static Type '" << cm.getRepr() << "' has " << cm.getNumberOfNodes();
+ oss << " nodes whereas in connectivity there is " << nbOfNodesInCell << " nodes ! Looks very bad !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ for(const int *w=ptr+ptrI[i]+1;w!=ptr+ptrI[i+1];w++)
+ {
+ int nodeId=*w;
+ if(nodeId>=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)
* @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());
+ }
}
/*!
updateTime();
}
+std::set<INTERP_KERNEL::NormalizedCellType> 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.
MEDCouplingMesh::checkFastEquivalWith(other,prec);
if(_types!=otherC->_types)
throw INTERP_KERNEL::Exception("checkDeepEquivalWith : Types are not equal !");
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> m=mergeUMeshes(this,otherC);
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> m=MergeUMeshes(this,otherC);
bool areNodesMerged;
int newNbOfNodes;
int oldNbOfNodes=getNumberOfNodes();
* 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.
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<MEDCouplingUMesh *> ms(2);
- ms[0]=const_cast<MEDCouplingUMesh *>(this);
- ms[1]=const_cast<MEDCouplingUMesh *>(otherC);
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> m=mergeUMeshesOnSameCoords(ms);
+ std::vector<const MEDCouplingUMesh *> ms(2);
+ ms[0]=this;
+ ms[1]=otherC;
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> m=MergeUMeshesOnSameCoords(ms);
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> 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<int>(),maxId));
* \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();
* \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();
{
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<nbOfSons;i++)
{
INTERP_KERNEL::NormalizedCellType cmsId;
unsigned nbOfNodesSon=cm.fillSonCellNodalConnectivity2(i,conn+pos+1,posP1-pos-1,tmp,cmsId);
- const INTERP_KERNEL::CellModel& cms=INTERP_KERNEL::CellModel::getCellModel(cmsId);
+ const INTERP_KERNEL::CellModel& cms=INTERP_KERNEL::CellModel::GetCellModel(cmsId);
std::set<int> shareableCells(revNodalB[tmp[0]].begin(),revNodalB[tmp[0]].end());
for(unsigned j=1;j<nbOfNodesSon && !shareableCells.empty();j++)
{
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];
}
/*!
- * 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<int> cellIds(nbOfCells);
+ for(int i=0;i<nbOfCells;i++)
+ cellIds[i]=i;
+ convertToPolyTypes(cellIds);
+}
+
+/*!
+ * This method is the opposite of ParaMEDMEM::MEDCouplingUMesh::convertToPolyTypes method.
+ * The aim is to take all polygons or polyhedrons cell and to try to traduce them into classical cells.
+ *
+ */
+void MEDCouplingUMesh::unPolyze()
+{
+ checkFullyDefined();
+ if(getMeshDimension()<=1)
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::unPolyze 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;i<nbOfCells;i++)
+ {
+ lgthOfCurCell=index[i+1]-posOfCurCell;
+ INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)conn[posOfCurCell];
+ const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(type);
+ INTERP_KERNEL::NormalizedCellType newType=INTERP_KERNEL::NORM_ERROR;
+ int newLgth;
+ if(cm.isDynamic())
+ {
+ if(cm.getDimension()==2)
+ {
+ INTERP_KERNEL::AutoPtr<int> 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<int> 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();
* 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();
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<MEDCouplingUMesh> mesh=MergeUMeshesOnSameCoords(this,other);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> 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)<nbOfCells;
+}
+
/*!
* @param areNodesMerged if at least two nodes have been merged.
* @return old to new node correspondance.
return ret;
}
+/*!
+ * Idem ParaMEDMEM::MEDCouplingUMesh::mergeNodes method except that the merged nodes are meld into the barycenter of them.
+ */
+DataArrayInt *MEDCouplingUMesh::mergeNodes2(double precision, bool& areNodesMerged, int& newNbOfNodes)
+{
+ DataArrayInt *ret=buildPermArrayForMergeNode(-1,precision,areNodesMerged,newNbOfNodes);
+ if(areNodesMerged)
+ renumberNodes2(ret->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<DataArrayDouble> newCoords=mergeNodesArray(&other,this);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> newCoords=MergeNodesArray(&other,this);
_coords->incrRef();
MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> oldCoords=_coords;
setCoords(newCoords);
* 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
{
}
}
+/*!
+ * 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<int> 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'.
/*!
* 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
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<int> 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.
*/
meshDM1->decrRef();
}
+MEDCouplingUMesh *MEDCouplingUMesh::buildUnstructured() const throw(INTERP_KERNEL::Exception)
+{
+ incrRef();
+ return const_cast<MEDCouplingUMesh *>(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)
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)
{
*/
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();
* 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<int>& elems)
+void MEDCouplingUMesh::getCellsInBoundingBox(const double *bbox, double eps, std::vector<int>& elems)
{
if(getMeshDimension()==-1)
{
}
/*!
- * 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<int>& elems)
+void MEDCouplingUMesh::getCellsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bbox, double eps, std::vector<int>& elems)
{
if(getMeshDimension()==-1)
{
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;i<spaceDim;i++)
+ ret << "\"" << _coords->getInfoOnComponent(i) << "\" ";
+ ret << "\n";
+ }
else
ret << msg0 << "\n";
ret << "Number of nodes : ";
ret << "Cell types present : ";
for(std::set<INTERP_KERNEL::NormalizedCellType>::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";
const int *ci=_nodal_connec_index->getConstPointer();
for(int i=0;i<nbOfCells;i++)
{
- const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::getCellModel((INTERP_KERNEL::NormalizedCellType)c[ci[i]]);
+ const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel((INTERP_KERNEL::NormalizedCellType)c[ci[i]]);
stream << "Cell #" << i << " " << cm.getRepr() << " : ";
std::copy(c+ci[i]+1,c+ci[i+1],std::ostream_iterator<int>(stream," "));
stream << "\n";
return std::count_if(pt+ptI[cellId]+1,pt+ptI[cellId+1],std::bind2nd(std::not_equal_to<int>(),-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<INTERP_KERNEL::NormalizedCellType> MEDCouplingUMesh::getTypesOfPart(const int *begin, const int *end) const throw(INTERP_KERNEL::Exception)
+{
+ checkFullyDefined();
+ std::set<INTERP_KERNEL::NormalizedCellType> 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();
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)
/*!
* First step of serialization process. Used by ParaMEDMEM and MEDCouplingCorba to transfert data between process.
*/
-void MEDCouplingUMesh::getTinySerializationInformation(std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const
+void MEDCouplingUMesh::getTinySerializationInformation(std::vector<double>& tinyInfoD, std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const
{
- MEDCouplingPointSet::getTinySerializationInformation(tinyInfo,littleStrings);
+ MEDCouplingPointSet::getTinySerializationInformation(tinyInfoD,tinyInfo,littleStrings);
tinyInfo.push_back(getMeshDimension());
tinyInfo.push_back(getNumberOfCells());
if(_nodal_connec)
*/
bool MEDCouplingUMesh::isEmptyMesh(const std::vector<int>& tinyInfo) const
{
- return tinyInfo[4]<=0;
+ return tinyInfo[6]<=0;
}
/*!
{
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);
}
/*!
* Second and final unserialization process.
* @param tinyInfo must be equal to the result given by getTinySerializationInformation method.
*/
-void MEDCouplingUMesh::unserialization(const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, const std::vector<std::string>& littleStrings)
+void MEDCouplingUMesh::unserialization(const std::vector<double>& tinyInfoD, const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, const std::vector<std::string>& 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();
{
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;
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;
}
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<int,INTERP_KERNEL::ALL_C_MODE>(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<double,double>(fabs));
+ }
+ else
+ {
+ area_vol[0]=std::numeric_limits<double>::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'.
*/
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<nbOfCells;i++,vals+=3)
+ if(getSpaceDimension()==3)
{
- int offset=connI[i];
- INTERP_KERNEL::crossprod<3>(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<double>(),1./n));
+ DataArrayDouble *loc=getBarycenterAndOwner();
+ const double *locPtr=loc->getConstPointer();
+ for(int i=0;i<nbOfCells;i++,vals+=3)
+ {
+ int offset=connI[i];
+ INTERP_KERNEL::crossprod<3>(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<double>(),1./n));
+ }
+ loc->decrRef();
+ }
+ else
+ {
+ for(int i=0;i<nbOfCells;i++)
+ { vals[3*i]=0.; vals[3*i+1]=0.; vals[3*i+2]=1.; }
}
}
- else
+ else//meshdimension==1
{
+ double tmp[2];
for(int i=0;i<nbOfCells;i++)
- { vals[3*i]=0.; vals[3*i+1]=0.; vals[3*i+2]=1.; }
+ {
+ int offset=connI[i];
+ std::transform(coords+2*conn[offset+2],coords+2*conn[offset+2]+2,coords+2*conn[offset+1],tmp,std::minus<double>());
+ double n=INTERP_KERNEL::norm<2>(tmp);
+ std::transform(tmp,tmp+2,tmp,std::bind2nd(std::multiplies<double>(),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<double>(),1./n));
+ }
+ loc->decrRef();
+ }
+ else
+ {
+ for(int i=0;i<nbelems;i++)
+ { vals[3*i]=0.; vals[3*i+1]=0.; vals[3*i+2]=1.; }
+ }
+ }
+ else//meshdimension==1
+ {
+ double tmp[2];
+ for(const int *i=begin;i!=end;i++)
+ {
+ int offset=connI[*i];
+ std::transform(coords+2*conn[offset+2],coords+2*conn[offset+2]+2,coords+2*conn[offset+1],tmp,std::minus<double>());
+ double n=INTERP_KERNEL::norm<2>(tmp);
+ std::transform(tmp,tmp+2,tmp,std::bind2nd(std::multiplies<double>(),1./n));
+ *vals++=-tmp[1];
+ *vals++=tmp[0];
+ }
}
ret->setArray(array);
- loc->decrRef();
array->decrRef();
ret->setMesh(this);
return ret;
}
/*!
- * 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;i<nbCells;i++)
+ {
+ if(conn[connI[i]+1]!=ref)
+ return false;
+ ref=conn[connI[i]+2];
+ }
+ return true;
+}
+
+/*!
+ * 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
+ */
+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 !");
/*!
* 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
{
/*!
* 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<int>& elts) const
{
const int *conn=_nodal_connec->getConstPointer();
const int *connI=_nodal_connec_index->getConstPointer();
double bb[2*SPACEDIM];
- for(int j=0;j<SPACEDIM;j++)
- { bb[2*j]=std::numeric_limits<double>::max(); bb[2*j+1]=-std::numeric_limits<double>::max(); }
BBTree<SPACEDIM,int> myTree(&bbox[0],0,0,nbOfCells,-eps);
for(int i=0;i<nbOfPoints;i++)
{
eltsIndex[i+1]=eltsIndex[i];
for(int j=0;j<SPACEDIM;j++)
{
- bb[2*j]=std::min(bb[2*j],pos[SPACEDIM*i+j]);
- bb[2*j+1]=std::max(bb[2*j+1],pos[SPACEDIM*i+j]);
+ bb[2*j]=pos[SPACEDIM*i+j];
+ bb[2*j+1]=pos[SPACEDIM*i+j];
}
std::vector<int> candidates;
myTree.getIntersectingElems(bb,candidates);
}
}
+/*!
+ * 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<int>& elts, std::vector<int>& eltsIndex) const
{
else
throw INTERP_KERNEL::Exception("For spaceDim==2 only meshDim==2 implemented for getelementscontainingpoints !");
}
-
-
-
}
/*!
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);
* \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())
{
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) !");
}
}
/*!
- * 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.
*/
{
int oldNbOfNodes=getNumberOfNodes();
int nbOf1DCells=mesh1D->getNumberOfCells();
+ int spaceDim=getSpaceDimension();
DataArrayDouble *ret=DataArrayDouble::New();
std::vector<bool> 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<int> v;
std::vector<double> c;
double vec[3];
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<double>());
+ std::transform(c.begin(),c.begin()+spaceDim,c.begin()+spaceDim,vec,std::minus<double>());
for(int j=0;j<oldNbOfNodes;j++)
- work=std::transform(vec,vec+3,retPtr+3*(i*oldNbOfNodes+j),work,std::plus<double>());
+ work=std::transform(vec,vec+spaceDim,retPtr+spaceDim*(i*oldNbOfNodes+j),work,std::plus<double>());
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<double>());
+ std::transform(c.begin(),c.begin()+spaceDim,c.begin()+spaceDim,vec,std::minus<double>());
for(int j=0;j<oldNbOfNodes;j++)
- work=std::transform(vec,vec+3,retPtr+3*(i*oldNbOfNodes+j),work,std::plus<double>());
+ work=std::transform(vec,vec+spaceDim,retPtr+spaceDim*(i*oldNbOfNodes+j),work,std::plus<double>());
}
}
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;i<nbOfLevsInVec;i++)
+ {
+ const double *begin=coo1D+2*conn1D[connI1D[i-1]+1];
+ const double *end=coo1D+2*conn1D[connI1D[i-1]+2];
+ const double *third=i+1<nbOfLevsInVec?coo1D+2*conn1D[connI1D[i]+2]:coo1D+2*conn1D[connI1D[i-2]+1];
+ const double vec[2]={end[0]-begin[0],end[1]-begin[1]};
+ tmp->translate(vec);
+ double tmp3[2],radius,alpha,alpha0;
+ const double *p0=i+1<nbOfLevsInVec?begin:third;
+ const double *p1=i+1<nbOfLevsInVec?end:begin;
+ const double *p2=i+1<nbOfLevsInVec?third:end;
+ INTERP_KERNEL::EdgeArcCircle::getArcOfCirclePassingThru(p0,p1,p2,tmp3,radius,alpha,alpha0);
+ double cosangle=i+1<nbOfLevsInVec?(p0[0]-tmp3[0])*(p1[0]-tmp3[0])+(p0[1]-tmp3[1])*(p1[1]-tmp3[1]):(p2[0]-tmp3[0])*(p1[0]-tmp3[0])+(p2[1]-tmp3[1])*(p1[1]-tmp3[1]);
+ double angle=acos(cosangle/(radius*radius));
+ tmp->rotate(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;i<nbOfLevsInVec;i++)
+ {
+ const double *begin=coo1D+3*conn1D[connI1D[i-1]+1];
+ const double *end=coo1D+3*conn1D[connI1D[i-1]+2];
+ const double *third=i+1<nbOfLevsInVec?coo1D+3*conn1D[connI1D[i]+2]:coo1D+3*conn1D[connI1D[i-2]+1];
+ const double vec[3]={end[0]-begin[0],end[1]-begin[1],end[2]-begin[2]};
+ tmp->translate(vec);
+ double tmp3[2],radius,alpha,alpha0;
+ const double *p0=i+1<nbOfLevsInVec?begin:third;
+ const double *p1=i+1<nbOfLevsInVec?end:begin;
+ const double *p2=i+1<nbOfLevsInVec?third:end;
+ double vecPlane[3]={
+ (p1[1]-p0[1])*(p2[2]-p1[2])-(p1[2]-p0[2])*(p2[1]-p1[1]),
+ (p1[2]-p0[2])*(p2[0]-p1[0])-(p1[0]-p0[0])*(p2[2]-p1[2]),
+ (p1[0]-p0[0])*(p2[1]-p1[1])-(p1[1]-p0[1])*(p2[0]-p1[0]),
+ };
+ double norm=sqrt(vecPlane[0]*vecPlane[0]+vecPlane[1]*vecPlane[1]+vecPlane[2]*vecPlane[2]);
+ if(norm>1.e-7)
+ {
+ vecPlane[0]/=norm; vecPlane[1]/=norm; vecPlane[2]/=norm;
+ double norm2=sqrt(vecPlane[0]*vecPlane[0]+vecPlane[1]*vecPlane[1]);
+ double vec2[2]={vecPlane[1]/norm2,-vecPlane[0]/norm2};
+ double s2=norm2;
+ double 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+1<nbOfLevsInVec?(p0r[0]-tmp3[0])*(p1r[0]-tmp3[0])+(p0r[1]-tmp3[1])*(p1r[1]-tmp3[1]):(p2r[0]-tmp3[0])*(p1r[0]-tmp3[0])+(p2r[1]-tmp3[1])*(p1r[1]-tmp3[1]);
+ double angle=acos(cosangle/(radius*radius));
+ tmp->rotate(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.
*/
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();
for(int i=0;i<nbOfCells && ret;i++)
{
INTERP_KERNEL::NormalizedCellType type=getTypeOfCell(i);
- const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::getCellModel(type);
+ const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(type);
ret=cm.isQuadratic();
}
return ret;
for(int i=0;i<nbOfCells && !ret;i++)
{
INTERP_KERNEL::NormalizedCellType type=getTypeOfCell(i);
- const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::getCellModel(type);
+ const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(type);
ret=cm.isQuadratic();
}
return ret;
for(int i=0;i<nbOfCells;i++)
{
INTERP_KERNEL::NormalizedCellType type=getTypeOfCell(i);
- const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::getCellModel(type);
+ const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(type);
if(cm.isQuadratic())
{
INTERP_KERNEL::NormalizedCellType typel=cm.getLinearType();
- const INTERP_KERNEL::CellModel& cml=INTERP_KERNEL::CellModel::getCellModel(typel);
+ const INTERP_KERNEL::CellModel& cml=INTERP_KERNEL::CellModel::GetCellModel(typel);
delta+=cm.getNumberOfNodes()-cml.getNumberOfNodes();
}
}
for(int i=0;i<nbOfCells;i++,ociptr++)
{
INTERP_KERNEL::NormalizedCellType type=getTypeOfCell(i);
- const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::getCellModel(type);
+ const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(type);
if(!cm.isQuadratic())
{
_types.insert(type);
{
INTERP_KERNEL::NormalizedCellType typel=cm.getLinearType();
_types.insert(typel);
- const INTERP_KERNEL::CellModel& cml=INTERP_KERNEL::CellModel::getCellModel(typel);
+ const INTERP_KERNEL::CellModel& cml=INTERP_KERNEL::CellModel::GetCellModel(typel);
int newNbOfNodes=cml.getNumberOfNodes();
*ocptr++=(int)typel;
ocptr=std::copy(icptr+iciptr[i]+1,icptr+iciptr[i]+newNbOfNodes+1,ocptr);
setConnectivity(newConn,newConnI,false);
}
+/*!
+ * This methods modify this by converting each cells into simplex cell, that is too say triangle for meshdim==2 or tetra for meshdim==3.
+ * This cut into simplex is performed following the parameter 'policy'. This method so typically increases the number of cells of this.
+ * This method returns new2old array that specifies a each cell of 'this' after the call what was its id it comes.
+ *
+ * The semantic of 'policy' parameter :
+ * - 1 only QUAD4. For QUAD4 the cut is done along 0-2 diagonal for QUAD4
+ * - 2 only QUAD4. For QUAD4 the cut is done along 1-3 diagonal for QUAD4
+ */
+DataArrayInt *MEDCouplingUMesh::simplexize(int policy) throw(INTERP_KERNEL::Exception)
+{
+ switch(policy)
+ {
+ case 0:
+ return simplexizePol0();
+ case 1:
+ return simplexizePol1();
+ default:
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::simplexize : unrecognized policy ! Must be 0 or 1 !");
+ }
+}
+
+bool MEDCouplingUMesh::areOnlySimplexCells() const throw(INTERP_KERNEL::Exception)
+{
+ checkFullyDefined();
+ if(getMeshDimension()<1)
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::areOnlySimplexCells : only available with meshes having a meshdim >= 1 !");
+ int nbCells=getNumberOfCells();
+ const int *conn=_nodal_connec->getConstPointer();
+ const int *connI=_nodal_connec_index->getConstPointer();
+ for(int i=0;i<nbCells;i++)
+ {
+ const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel((INTERP_KERNEL::NormalizedCellType)conn[connI[i]]);
+ if(!cm.isSimplex())
+ return false;
+ }
+ return true;
+}
+
+/*!
+ * This method implements policy 0 of virtual method ParaMEDMEM::MEDCouplingUMesh::simplexize.
+ */
+DataArrayInt *MEDCouplingUMesh::simplexizePol0() 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;i<nbOfCells;i++,ci++)
+ {
+ if((INTERP_KERNEL::NormalizedCellType)oldc[ci[0]]==INTERP_KERNEL::NORM_QUAD4)
+ {
+ const int tmp[8]={(int)INTERP_KERNEL::NORM_TRI3,oldc[ci[0]+1],oldc[ci[0]+2],oldc[ci[0]+3],
+ (int)INTERP_KERNEL::NORM_TRI3,oldc[ci[0]+1],oldc[ci[0]+3],oldc[ci[0]+4]};
+ pt=std::copy(tmp,tmp+8,pt);
+ ptI[1]=ptI[0]+4;
+ ptI[2]=ptI[0]+8;
+ *retPt++=i;
+ *retPt++=i;
+ ptI+=2;
+ }
+ else
+ {
+ pt=std::copy(oldc+ci[0],oldc+ci[1],pt);
+ ptI[1]=ptI[0]+ci[1]-ci[0];
+ ptI++;
+ *retPt++=i;
+ }
+ }
+ _nodal_connec->decrRef();
+ _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;i<nbOfCells;i++,ci++)
+ {
+ if((INTERP_KERNEL::NormalizedCellType)oldc[ci[0]]==INTERP_KERNEL::NORM_QUAD4)
+ {
+ const int tmp[8]={(int)INTERP_KERNEL::NORM_TRI3,oldc[ci[0]+1],oldc[ci[0]+2],oldc[ci[0]+4],
+ (int)INTERP_KERNEL::NORM_TRI3,oldc[ci[0]+2],oldc[ci[0]+3],oldc[ci[0]+4]};
+ pt=std::copy(tmp,tmp+8,pt);
+ ptI[1]=ptI[0]+4;
+ ptI[2]=ptI[0]+8;
+ *retPt++=i;
+ *retPt++=i;
+ ptI+=2;
+ }
+ else
+ {
+ pt=std::copy(oldc+ci[0],oldc+ci[1],pt);
+ ptI[1]=ptI[0]+ci[1]-ci[0];
+ ptI++;
+ *retPt++=i;
+ }
+ }
+ _nodal_connec->decrRef();
+ _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;i<nbOfCells;i++)
+ {
+ lgthOfCurCell=index[i+1]-posOfCurCell;
+ INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)conn[posOfCurCell];
+ int newLgth;
+ INTERP_KERNEL::NormalizedCellType newType=INTERP_KERNEL::CellSimplify::simplifyDegeneratedCell(type,conn+posOfCurCell+1,lgthOfCurCell-1,
+ conn+newPos+1,newLgth);
+ conn[newPos]=newType;
+ newPos+=newLgth+1;
+ posOfCurCell=index[i+1];
+ index[i+1]=newPos;
+ }
+ if(newPos!=initMeshLgth)
+ _nodal_connec->reAlloc(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.
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);
}
}
{
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<int> tmp(connI[i+1]-connI[i]-2);
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);
}
}
{
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;
}
}
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<int>& code, const std::vector<const DataArrayInt *>& 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<INTERP_KERNEL::NormalizedCellType> types;
+ int nb=0;
+ for(std::size_t i=0;i<n;i++)
+ if(std::find(types.begin(),types.end(),(INTERP_KERNEL::NormalizedCellType)code[3*i])==types.end())
+ {
+ types.push_back((INTERP_KERNEL::NormalizedCellType)code[3*i]);
+ nb+=code[3*i+1];
+ if(_types.find((INTERP_KERNEL::NormalizedCellType)code[3*i])==_types.end())
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::checkTypeConsistencyAndContig : expected geo types not in this !");
+ }
+ if(types.size()!=n)
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::checkTypeConsistencyAndContig : code contains duplication of types in unstructured mesh !");
+ if(idsPerType.empty())
+ {
+ if(!checkConsecutiveCellTypesAndOrder(&types[0],&types[0]+types.size()))
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::checkTypeConsistencyAndContig : non contiguous type !");
+ if(types.size()==_types.size())
+ return 0;
+ }
+ DataArrayInt *ret=DataArrayInt::New();
+ ret->alloc(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<INTERP_KERNEL::NormalizedCellType>::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;k<pos2;k++)
+ *retPtr++=k+offset;
+ i=j;
+ }
+ else
+ {
+ retPtr=std::transform(idsPerType[code[3*kk+2]]->getConstPointer(),idsPerType[code[3*kk+2]]->getConstPointer()+idsPerType[code[3*kk+2]]->getNbOfElems(),
+ retPtr,std::bind2nd(std::plus<int>(),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<DataArrayInt> tmp0=DataArrayInt::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp1=DataArrayInt::New();
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> ret1=buildDescendingConnectivity(desc,descIndx,tmp0,tmp1);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret0=ret1->sortCellsInMEDFileFrmt();
+ desc->transformWithIndArr(ret0->getConstPointer(),ret0->getConstPointer()+ret0->getNbOfElems());
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> 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<DataArrayInt> ret=getRenumArrForConsecutiveCellTypesSpec(MEDMEM_ORDER,MEDMEM_ORDER+N);
+ renumberCells(ret->getConstPointer(),false);
+ ret->incrRef();
+ return ret;
}
/*!
}
/*!
- * 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<int>::max();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmpa=DataArrayInt::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> 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<int>::max())
- {
- int nextMinPos=std::numeric_limits<int>::max();
- for(int j=0;j<nbOfCells;j++)
+ const INTERP_KERNEL::NormalizedCellType *where=std::find(orderBg,orderEnd,(INTERP_KERNEL::NormalizedCellType)conn[*i]);
+ if(where!=orderEnd)
{
- if(tmp[j]==minPos)
- {
- optr[j]=k++;
- tmp[j]=std::numeric_limits<int>::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<DataArrayInt> tmpa=getLevArrPerCellTypes(orderBg,orderEnd,nbPerType);
+ nbPerType->decrRef();
+ return tmpa->buildPermArrPerLevel();
}
/*!
}
/*!
- * 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.
*/
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<int> 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()<this->getNumberOfCells(). This method makes the assumption that ids contained in 'da'
* are in [0:getNumberOfCells())
* 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<int>& idsPerGeoType) const
+MEDCouplingUMesh *MEDCouplingUMesh::keepSpecifiedCells(INTERP_KERNEL::NormalizedCellType type, const int *idsPerGeoTypeBg, const int *idsPerGeoTypeEnd) const
{
std::vector<int> idsTokeep;
int nbOfCells=getNumberOfCells();
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++;
}
ret->decrRef();
return 0;
}
- ret2->setName(getName());
+ ret2->copyTinyInfoFrom(this);
return ret2;
}
if(other->getType()!=UNSTRUCTURED)
throw INTERP_KERNEL::Exception("Merge of umesh only available with umesh each other !");
const MEDCouplingUMesh *otherC=static_cast<const MEDCouplingUMesh *>(other);
- return mergeUMeshes(this,otherC);
+ return MergeUMeshes(this,otherC);
}
/*!
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();
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<int,INTERP_KERNEL::ALL_C_MODE>(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<MEDCouplingUMesh> ret=MEDCouplingUMesh::New(da->getName().c_str(),0);
+ ret->setCoords(da);
+ int nbOfTuples=da->getNumberOfTuples();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> c=DataArrayInt::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> 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;i<nbOfTuples;i++)
+ {
+ *cp++=INTERP_KERNEL::NORM_POINT1;
+ *cp++=i;
+ *cip++=2*(i+1);
+ }
+ ret->setConnectivity(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<const MEDCouplingUMesh *> tmp(2);
+ tmp[0]=const_cast<MEDCouplingUMesh *>(mesh1); tmp[1]=const_cast<MEDCouplingUMesh *>(mesh2);
+ return MergeUMeshes(tmp);
+}
+
+MEDCouplingUMesh *MEDCouplingUMesh::MergeUMeshes(std::vector<const MEDCouplingUMesh *>& a) throw(INTERP_KERNEL::Exception)
+{
+ if(a.empty())
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::MergeUMeshes : input array must be NON EMPTY !");
+ std::vector<const MEDCouplingUMesh *>::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<const MEDCouplingPointSet *> aps(a.size());
+ std::copy(a.begin(),a.end(),aps.begin());
+ DataArrayDouble *pts=MergeNodesArray(aps);
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> 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<int>(),delta));
- DataArrayInt *newNodal2=mesh2->getNodalConnectivity()->deepCopy();
- delta=mesh1->getNumberOfNodes();
- const int *nI2=mesh2->getNodalConnectivityIndex()->getConstPointer();
- int *pt=newNodal2->getPointer();
- for(int i=0;i<nbOfCells2;i++)
- {
- pt++;
- for(int j=0;j<nI2[i+1]-nI2[i]-1;j++,pt++)
- if(*pt!=-1)
- *pt+=delta;
- }
- DataArrayInt *nodal=DataArrayInt::aggregate(mesh1->getNodalConnectivity(),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<int>(),offset));
+ for(int j=0;j<curNbOfCell;j++)
+ {
+ const int *src=curC+curCI[j];
+ *cPtr++=*src++;
+ for(;src!=curC+curCI[j+1];src++,cPtr++)
+ {
+ if(*src!=-1)
+ *cPtr=*src+offset2;
+ else
+ *cPtr=-1;
+ }
+ }
+ offset+=curCI[curNbOfCell];
+ offset2+=(*it)->getNumberOfNodes();
+ }
+ //
+ 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<const MEDCouplingUMesh *> 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<MEDCouplingUMesh *>& meshes)
+MEDCouplingUMesh *MEDCouplingUMesh::MergeUMeshesOnSameCoords(const std::vector<const MEDCouplingUMesh *>& 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<MEDCouplingUMesh *>::const_iterator iter=meshes.begin();
+ std::vector<const MEDCouplingUMesh *>::const_iterator iter=meshes.begin();
int meshLgth=0;
int meshIndexLgth=0;
for(;iter!=meshes.end();iter++)
if(coords!=(*iter)->getCoords())
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();
}
* @return The mesh lying on the same coordinates than those in meshes. All cells in 'meshes' are in returned mesh with
* @exception if meshes is a empty vector or meshes are not lying on same coordinates or meshes not have the same dimension.
*/
-MEDCouplingUMesh *MEDCouplingUMesh::fuseUMeshesOnSameCoords(const std::vector<MEDCouplingUMesh *>& meshes, int compType, std::vector<DataArrayInt *>& corr)
+MEDCouplingUMesh *MEDCouplingUMesh::FuseUMeshesOnSameCoords(const std::vector<const MEDCouplingUMesh *>& meshes, int compType, std::vector<DataArrayInt *>& 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();
tmp->alloc(curNbOfCells,1);
std::copy(o2nPtr+offset,o2nPtr+offset+curNbOfCells,tmp->getPointer());
offset+=curNbOfCells;
+ tmp->setName(meshes[i]->getName());
corr[i]=tmp;
}
o2n->decrRef();
void MEDCouplingUMesh::appendExtrudedCell(const int *connBg, const int *connEnd, int nbOfNodesPerLev, bool isQuad, std::vector<int>& 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);
/*!
* 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);
/*!
* 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<std::pair<int,int> > edges;
int nbOfFaces=std::count(begin,end,-1)+1;
* 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<std::pair<int,int> > edges;
int nbOfFaces=std::count(begin,end,-1)+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
//
#ifndef __PARAMEDMEM_MEDCOUPLINGUMESH_HXX__
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;
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<INTERP_KERNEL::NormalizedCellType>& getAllTypes() const { return _types; }
+ MEDCOUPLING_EXPORT std::set<INTERP_KERNEL::NormalizedCellType> getAllGeoTypes() const;
+ MEDCOUPLING_EXPORT std::set<INTERP_KERNEL::NormalizedCellType> 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<int>& conn) const;
MEDCOUPLING_EXPORT int getMeshLength() const;
MEDCOUPLING_EXPORT void computeTypes();
//! size of returned tinyInfo must be always the same.
- MEDCOUPLING_EXPORT void getTinySerializationInformation(std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const;
+ MEDCOUPLING_EXPORT void getTinySerializationInformation(std::vector<double>& tinyInfoD, std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const;
MEDCOUPLING_EXPORT bool isEmptyMesh(const std::vector<int>& tinyInfo) const;
MEDCOUPLING_EXPORT void resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings) const;
MEDCOUPLING_EXPORT void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const;
- MEDCOUPLING_EXPORT void unserialization(const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, const std::vector<std::string>& littleStrings);
+ MEDCOUPLING_EXPORT void unserialization(const std::vector<double>& tinyInfoD, const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, const std::vector<std::string>& littleStrings);
//tools
MEDCOUPLING_EXPORT bool areCellsEqual(int cell1, int cell2, int compType) const;
MEDCOUPLING_EXPORT bool areCellsEqual0(int cell1, int cell2) const;
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<int>& 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<int>& 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<int>& elems);
- MEDCOUPLING_EXPORT void giveElemsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bbox, double eps, std::vector<int>& elems);
+ MEDCOUPLING_EXPORT void getCellsInBoundingBox(const double *bbox, double eps, std::vector<int>& elems);
+ MEDCOUPLING_EXPORT void getCellsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bbox, double eps, std::vector<int>& 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<int>& elts) const;
MEDCOUPLING_EXPORT void getCellsContainingPoints(const double *pos, int nbOfPoints, double eps, std::vector<int>& elts, std::vector<int>& eltsIndex) const;
MEDCOUPLING_EXPORT void checkButterflyCells(std::vector<int>& cells) const;
MEDCOUPLING_EXPORT void getBoundingBoxForBBTree(std::vector<double>& 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<int>& 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<int>& cells) const throw(INTERP_KERNEL::Exception);
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<int>& code, const std::vector<const DataArrayInt *>& 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<MEDCouplingUMesh *> 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<int>& 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<MEDCouplingUMesh *>& meshes);
- MEDCOUPLING_EXPORT static MEDCouplingUMesh *fuseUMeshesOnSameCoords(const std::vector<MEDCouplingUMesh *>& meshes, int compType, std::vector<DataArrayInt *>& 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<const MEDCouplingUMesh *>& 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<const MEDCouplingUMesh *>& meshes);
+ MEDCOUPLING_EXPORT static MEDCouplingUMesh *FuseUMeshesOnSameCoords(const std::vector<const MEDCouplingUMesh *>& meshes, int compType, std::vector<DataArrayInt *>& 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<int>& 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<int SPACEDIM>
void findCommonCellsBase(int compType, std::vector<int>& res, std::vector<int>& resI) const;
bool areCellsEqualInPool(const std::vector<int>& candidates, int compType, std::vector<int>& result) const;
-// 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"
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)
{
}
{
for(std::set<INTERP_KERNEL::NormalizedCellType>::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);
}
}
+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)
{
return (INTERP_KERNEL::NormalizedCellType)desc_connec[desc_connec_index[cellId]+1];
}
+std::set<INTERP_KERNEL::NormalizedCellType> MEDCouplingUMeshDesc::getAllGeoTypes() const
+{
+ return _types;
+}
+
int MEDCouplingUMeshDesc::getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const
{
const int *desc_connec=_desc_connec->getConstPointer();
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<int>& tinyInfo, std::vector<std::string>& littleStrings) const
+DataArrayInt *MEDCouplingUMeshDesc::checkTypeConsistencyAndContig(const std::vector<int>& code, const std::vector<const DataArrayInt *>& idsPerType) const throw(INTERP_KERNEL::Exception)
+{
+ throw INTERP_KERNEL::Exception("Not implemented yet !");
+}
+
+void MEDCouplingUMeshDesc::getTinySerializationInformation(std::vector<double>& tinyInfoD, std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const
{
- MEDCouplingPointSet::getTinySerializationInformation(tinyInfo,littleStrings);
+ MEDCouplingPointSet::getTinySerializationInformation(tinyInfoD,tinyInfo,littleStrings);
tinyInfo.push_back(getMeshDimension());
tinyInfo.push_back(getNumberOfNodes());
tinyInfo.push_back(getNumberOfCells());
return tinyInfo[5]<=0;
}
-void MEDCouplingUMeshDesc::resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings)
+void MEDCouplingUMeshDesc::resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings) const
{
std::vector<int> tinyInfoTmp(tinyInfo.begin()+1,tinyInfo.end());
MEDCouplingPointSet::resizeForUnserialization(tinyInfoTmp,a1,a2,littleStrings);
std::copy(faceConnIndex,faceConnIndex+getNumberOfFaces()+1,ptA1);
}
-void MEDCouplingUMeshDesc::unserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, const std::vector<std::string>& littleStrings)
+void MEDCouplingUMeshDesc::unserialization(const std::vector<double>& tinyInfoD, const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, const std::vector<std::string>& littleStrings)
{
std::vector<int> 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();
setMeshDimension(tinyInfo[2]);
}
-void MEDCouplingUMeshDesc::giveElemsInBoundingBox(const double *bbox, double eps, std::vector<int>& elems)
+void MEDCouplingUMeshDesc::getCellsInBoundingBox(const double *bbox, double eps, std::vector<int>& elems)
{
int dim=getSpaceDimension();
double* elem_bb=new double[2*dim];
delete [] elem_bb;
}
-void MEDCouplingUMeshDesc::giveElemsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox &bbox, double eps, std::vector<int>& elems)
+void MEDCouplingUMeshDesc::getCellsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox &bbox, double eps, std::vector<int>& elems)
{
int dim=getSpaceDimension();
double* elem_bb=new double[2*dim];
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 !");
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<int>& nodes) const
{
//not implemented yet
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 !");
int MEDCouplingUMeshDesc::getCellContainingPoint(const double *pos, double eps) const
{
- //not implemented yet.
- return -1;
+ throw INTERP_KERNEL::Exception("MEDCouplingUMeshDesc::getCellContainingPoint : not implemented yet !");
}
-// 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__
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,
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<INTERP_KERNEL::NormalizedCellType> getAllGeoTypes() const;
MEDCOUPLING_EXPORT int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const;
MEDCOUPLING_EXPORT void getNodeIdsOfCell(int cellId, std::vector<int>& conn) const;
MEDCOUPLING_EXPORT void getCoordinatesOfNode(int nodeId, std::vector<double>& coo) const;
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<int>& tinyInfo, std::vector<std::string>& littleStrings) const;
+ MEDCOUPLING_EXPORT DataArrayInt *checkTypeConsistencyAndContig(const std::vector<int>& code, const std::vector<const DataArrayInt *>& idsPerType) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void getTinySerializationInformation(std::vector<double>& tinyInfoD, std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const;
MEDCOUPLING_EXPORT bool isEmptyMesh(const std::vector<int>& tinyInfo) const;
- MEDCOUPLING_EXPORT void resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings);
+ MEDCOUPLING_EXPORT void resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings) const;
MEDCOUPLING_EXPORT void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const;
- MEDCOUPLING_EXPORT void unserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, const std::vector<std::string>& littleStrings);
- MEDCOUPLING_EXPORT void giveElemsInBoundingBox(const double *bbox, double eps, std::vector<int>& elems);
- MEDCOUPLING_EXPORT void giveElemsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox &bbox, double eps, std::vector<int>& elems);
+ MEDCOUPLING_EXPORT void unserialization(const std::vector<double>& tinyInfoD, const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, const std::vector<std::string>& littleStrings);
+ MEDCOUPLING_EXPORT void getCellsInBoundingBox(const double *bbox, double eps, std::vector<int>& elems);
+ MEDCOUPLING_EXPORT void getCellsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox &bbox, double eps, std::vector<int>& 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<int>& 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;
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;
-# 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
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
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
MEDCouplingNatureOfField.hxx \
MEDCouplingRemapper.hxx \
MEDCouplingExtrudedMesh.hxx \
- MEDCouplingGaussLocalization.hxx
+ MEDCouplingGaussLocalization.hxx \
+ MEDCouplingMultiFields.hxx \
+ MEDCouplingFieldTemplate.hxx \
+ MEDCouplingDefinitionTime.hxx \
+ MEDCouplingFieldOverTime.hxx
-// 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__
namespace ParaMEDMEM
{
+ class DataArrayDouble;
class MEDCouplingUMesh;
+ class MEDCouplingFieldDouble;
+ class MEDCouplingMultiFields;
class MEDCouplingBasicsTest : public CppUnit::TestFixture
{
CPPUNIT_TEST( testFillFromAnalytic3 );
CPPUNIT_TEST( testFieldDoubleOpEqual1 );
CPPUNIT_TEST( testAreaBary3D2 );
+ //MEDCouplingBasicsTest3.cxx
CPPUNIT_TEST( testGetMeasureFieldCMesh1 );
CPPUNIT_TEST( testFieldDoubleZipCoords1 );
CPPUNIT_TEST( testFieldDoubleZipConnectivity1 );
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 );
void testFillFromAnalytic3();
void testFieldDoubleOpEqual1();
void testAreaBary3D2();
+ //MEDCouplingBasicsTest3.cxx
void testGetMeasureFieldCMesh1();
void testFieldDoubleZipCoords1();
void testFieldDoubleZipConnectivity1();
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();
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<MEDCouplingFieldDouble *> buildMultiFields_2();
static double sumAll(const std::vector< std::map<int,double> >& matrix);
};
}
-// 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"
#include "MEDCouplingExtrudedMesh.hxx"
#include "MEDCouplingFieldDouble.hxx"
#include "MEDCouplingMemArray.hxx"
+#include "MEDCouplingMultiFields.hxx"
#include "MEDCouplingBasicsTestData1.hxx"
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]={
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<ParaMEDMEM::DataArrayDouble *> 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<ParaMEDMEM::MEDCouplingFieldDouble *> 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<MEDCouplingFieldDouble *> 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<ParaMEDMEM::DataArrayDouble *> 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<ParaMEDMEM::MEDCouplingFieldDouble *> 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<int,double> >& matrix)
{
double ret=0.;
-// 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"
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);
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();
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();
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();
//
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));
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();
}
/*!
- * This test check MEDCouplingUMesh::buildExtrudedMeshFromThis method.
+ * This test check MEDCouplingUMesh::buildExtrudedMesh method.
*/
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());
//play with polygons and polyedrons
std::vector<int> 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));
}
/*!
- * 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()
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);
m1->tryToShareSameCoords(*m2,1e-12);
MEDCouplingUMesh *m3=build2DTargetMesh_1();
m3->tryToShareSameCoords(*m2,1e-12);
- std::vector<MEDCouplingUMesh *> meshes;
+ std::vector<const MEDCouplingUMesh *> 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());
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));
MEDCouplingUMesh *m1=build3DSurfTargetMesh_1();
std::vector<MEDCouplingUMesh *> v=m1->splitByType();
CPPUNIT_ASSERT_EQUAL(3,(int)v.size());
- MEDCouplingUMesh *m2=MEDCouplingUMesh::mergeUMeshesOnSameCoords(v);
+ std::vector<const MEDCouplingUMesh *> 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<MEDCouplingUMesh *>::const_iterator iter=v.begin();iter!=v.end();iter++)
void MEDCouplingBasicsTest::testFuseUMeshesOnSameCoords()
{
- std::vector<MEDCouplingUMesh *> meshes;
+ std::vector<const MEDCouplingUMesh *> meshes;
MEDCouplingUMesh *m2=build2DTargetMesh_1();
int cells1[3]={2,3,4};
MEDCouplingPointSet *m3_1=m2->buildPartOfMySelf(cells1,cells1+3,true);
m2->decrRef();
//
std::vector<DataArrayInt *> 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};
CPPUNIT_ASSERT_EQUAL(expectedVals2[i][j],vals[j]);
}
std::vector< std::vector<int> > fidsOfGroups;
- DataArrayInt *arr2=DataArrayInt::makePartition(corr,m7->getNumberOfCells(),fidsOfGroups);
+ std::vector<const DataArrayInt *> 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());
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<MEDCouplingUMesh *> meshes;
+ std::vector<const MEDCouplingUMesh *> meshes;
meshes.push_back(m1);
meshes.push_back(m3);
meshes.push_back(m3);
meshes.push_back(m4);
std::vector<DataArrayInt *> corr;
- MEDCouplingUMesh *m5=MEDCouplingUMesh::fuseUMeshesOnSameCoords(meshes,0,corr);
+ MEDCouplingUMesh *m5=MEDCouplingUMesh::FuseUMeshesOnSameCoords(meshes,0,corr);
CPPUNIT_ASSERT_EQUAL(18,m5->getNumberOfCells());
std::vector<DataArrayInt *>::iterator it=corr.begin();
const int exp1[4]={18,5,5,4};
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);
-// 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"
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);
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();
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());
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);
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();
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);
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();
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();
//
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.};
//
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<MEDCouplingUMesh *>(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<int> 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<int> 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<int> 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<int> arr5V(arr5,arr5+3);
- std::vector<int> arr6V(arr6,arr6+3);
- std::vector<int> 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<int> 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<int> 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<int> 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();
-}
--- /dev/null
+// 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 <cmath>
+#include <functional>
+#include <iterator>
+
+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<MEDCouplingUMesh *>(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<int> 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<int> 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<int> 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<int> arr5V(arr5,arr5+3);
+ std::vector<int> arr6V(arr6,arr6+3);
+ std::vector<int> 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<int> 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<int> 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<int> 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<int> 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<int> 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<int> 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<int> 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<int> 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<INTERP_KERNEL::NormalizedCellType> 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<int> 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<const MEDCouplingUMesh *> 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<const MEDCouplingFieldDouble *> 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<int> 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<INTERP_KERNEL::NormalizedCellType> 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<const DataArrayInt *> 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<const MEDCouplingUMesh *> 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<INTERP_KERNEL::NormalizedCellType>& 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<int> 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();
+}
+
--- /dev/null
+// 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 <cmath>
+#include <functional>
+#include <iterator>
+
+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<MEDCouplingMesh *> ms=mfs->getMeshes();
+ std::vector<int> refs;
+ std::vector<MEDCouplingMesh *> dms=mfs->getDifferentMeshes(refs);
+ std::vector<DataArrayDouble *> das=mfs->getArrays();
+ std::vector< std::vector<int> > refs2;
+ std::vector<DataArrayDouble *> 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<MEDCouplingFieldDouble *> 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<double> 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<int> tmp1;
+ std::vector<double> tmp2;
+ CPPUNIT_ASSERT(!dt2.isEqual(dt3));
+ dt2.getTinySerializationInformation(tmp1,tmp2);
+ dt3.unserialize(tmp1,tmp2);
+ CPPUNIT_ASSERT(dt2.isEqual(dt3));
+ //
+ for(std::vector<MEDCouplingFieldDouble *>::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<std::string> 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<std::string> 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<std::string> 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<double> wg1(1); wg1[0]=0.3;
+ std::vector<double> gsCoo1(1); gsCoo1[0]=0.2;
+ std::vector<double> refCoo1(2); refCoo1[0]=-1.0; refCoo1[1]=1.0;
+ f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_SEG2,refCoo1,gsCoo1,wg1);
+ std::vector<double> wg2(wg1);
+ std::vector<double> gsCoo2(1); gsCoo2[0]=0.2;
+ std::vector<double> 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<double> wg3(2); wg3[0]=0.3; wg3[1]=0.3;
+ const double tria3CooGauss[4]={ 0.1, 0.8, 0.2, 0.7 };
+ std::vector<double> gsCoo3(tria3CooGauss,tria3CooGauss+4);
+ const double tria3CooRef[6]={ 0.0, 0.0, 1.0 , 0.0, 0.0, 1.0 };
+ std::vector<double> refCoo3(tria3CooRef,tria3CooRef+6);
+ f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_TRI3,refCoo3,gsCoo3,wg3);
+ std::vector<double> 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<double> 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<double> refCoo4(tria6CooRef,tria6CooRef+12);
+ f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_TRI6,refCoo4,gsCoo4,wg4);
+ std::vector<double> 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<double> 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<double> refCoo5(quad4CooRef,quad4CooRef+8);
+ f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_QUAD4,refCoo5,gsCoo5,wg5);
+ std::vector<double> 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<double> 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<double> 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<double> wg7(1); wg7[0]=0.3;
+ const double tetra4CooGauss[3]={0.34, 0.16, 0.21};
+ std::vector<double> 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<double> refCoo7(tetra4CooRef,tetra4CooRef+12);
+ f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_TETRA4,refCoo7,gsCoo7,wg7);
+ std::vector<double> wg8(1); wg8[0]=0.3;
+ const double tetra10CooGauss[3]={0.2, 0.3, 0.1};
+ std::vector<double> 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<double> refCoo8(tetra10CooRef,tetra10CooRef+30);
+ f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_TETRA10,refCoo8,gsCoo8,wg8);
+ std::vector<double> wg9(1); wg9[0]=0.3;
+ const double pyra5CooGauss[3]={0.2, 0.3, 0.1};
+ std::vector<double> 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<double> refCoo9(pyra5CooRef,pyra5CooRef+15);
+ f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_PYRA5,refCoo9,gsCoo9,wg9);
+ std::vector<double> wg10(1); wg10[0]=0.3;
+ const double pyra13CooGauss[3]={0.1, 0.2, 0.7};
+ std::vector<double> 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<double> refCoo10(pyra13CooRef,pyra13CooRef+39);
+ f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_PYRA13,refCoo10,gsCoo10,wg10);
+ std::vector<double> wg11(1); wg11[0]=0.3;
+ const double penta6CooGauss[3]={0.2, 0.3, 0.1};
+ std::vector<double> 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<double> refCoo11(penta6CooRef,penta6CooRef+18);
+ f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_PENTA6,refCoo11,gsCoo11,wg11);
+ std::vector<double> wg12(1); wg12[0]=0.3;
+ const double penta15CooGauss[3]={0.2, 0.3,0.15};
+ std::vector<double> 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<double> refCoo12(penta15CooRef,penta15CooRef+45);
+ f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_PENTA15,refCoo12,gsCoo12,wg12);
+ std::vector<double> wg13(1); wg13[0]=0.3;
+ const double hexa8CooGauss[3]={0.2,0.3,0.15};
+ std::vector<double> 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<double> refCoo13(hexa8CooRef,hexa8CooRef+24);
+ f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_HEXA8,refCoo13,gsCoo13,wg13);
+ std::vector<double> wg14(1); wg14[0]=0.3;
+ const double hexa20CooGauss[3]={0.11,0.3,0.55};
+ std::vector<double> 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<double> 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<int> 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<int> 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<int> 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<const MEDCouplingUMesh *> ms(4,m);
+ MEDCouplingUMesh *m2=MEDCouplingUMesh::MergeUMeshesOnSameCoords(ms);
+ std::vector<int> 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<int> 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();
+}
-// 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,
-// 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"
#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"
INTERP_KERNEL::Interpolation3D myInterpolator;
std::vector<std::map<int,double> > 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();
std::vector<std::map<int,double> > 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();
std::vector<std::map<int,double> > 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();
std::vector<std::map<int,double> > 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();
std::vector<std::map<int,double> > 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();
INTERP_KERNEL::Interpolation3D myInterpolator;
std::vector<std::map<int,double> > 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();
std::vector<std::map<int,double> > 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();
INTERP_KERNEL::Interpolation3D myInterpolator;
std::vector<std::map<int,double> > 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();
std::vector<std::map<int,double> > 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();
-// 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"
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;i<sourceMesh->getNumberOfCells();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]={
-// 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__
CPPUNIT_TEST( testNatureOfField );
CPPUNIT_TEST( testExtruded );
CPPUNIT_TEST( testExtruded2 );
+ CPPUNIT_TEST( testPrepareEx1 );
CPPUNIT_TEST_SUITE_END();
public:
void test2DInterpP0P0_1();
void testNatureOfField();
void testExtruded();
void testExtruded2();
+ void testPrepareEx1();
private:
static MEDCouplingUMesh *build1DTargetMesh_2();
static MEDCouplingUMesh *build2DTargetMesh_3();
-# 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
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
CLEANFILES = \
UnitTestsResult
-
\ No newline at end of file
-// 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 );
-// 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 );
--- /dev/null
+// 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<int>;
+%template(dvec) std::vector<double>;
+%template(svec) std::vector<std::string>;
+
+%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<std::string>& 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<double> pos=convertPyToNewDblArr2(p,&sz);
+ std::vector<int> elts,eltsIndex;
+ self->getCellsContainingPoints(pos,nbOfPoints,eps,elts,eltsIndex);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> d0=DataArrayInt::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> 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<double> pos=convertPyToNewDblArr2(p,&sz);
+ std::vector<int> 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<int> 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<int> 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<int> conn;
+ self->getNodeIdsOfCell(cellId,conn);
+ return convertIntArrToPyList2(conn);
+ }
+
+ PyObject *getCoordinatesOfNode(int nodeId) const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<double> 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<int> 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<int> 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<int> code;
+ std::vector<const DataArrayInt *> 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<double> v=convertPyToNewDblArr2(vector,&sz);
+ self->translate(v);
+ }
+
+ void rotate(PyObject *center, PyObject *vector, double alpha) throw(INTERP_KERNEL::Exception)
+ {
+ int sz;
+ INTERP_KERNEL::AutoPtr<double> c=convertPyToNewDblArr2(center,&sz);
+ if(!c)
+ return ;
+ INTERP_KERNEL::AutoPtr<double> v=convertPyToNewDblArr2(vector,&sz);
+ if(!v)
+ { return ; }
+ self->rotate(c,v,alpha);
+ }
+
+ PyObject *getAllGeoTypes() const throw(INTERP_KERNEL::Exception)
+ {
+ std::set<INTERP_KERNEL::NormalizedCellType> result=self->getAllGeoTypes();
+ std::set<INTERP_KERNEL::NormalizedCellType>::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<int>& tinyInfo) const throw(INTERP_KERNEL::Exception) = 0;
+ //! size of returned tinyInfo must be always the same.
+ void getTinySerializationInformation(std::vector<double>& tinyInfoD, std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const throw(INTERP_KERNEL::Exception);
+ void resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings) const throw(INTERP_KERNEL::Exception);
+ void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const throw(INTERP_KERNEL::Exception);
+ void unserialization(const std::vector<double>& tinyInfoD, const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2,
+ const std::vector<std::string>& littleStrings) throw(INTERP_KERNEL::Exception);
+ virtual void getCellsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bbox, double eps, std::vector<int>& 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<int> 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<int> 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<int> 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<int> 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<int> 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<int> 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<int> 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<double> pos=convertPyToNewDblArr2(pt,&size);
+ if(size<self->getSpaceDimension())
+ throw INTERP_KERNEL::Exception("getNodeIdsNearPoint : to tiny array ! must be at least of size SpaceDim !");
+ std::vector<int> tmp=self->getNodeIdsNearPoint(pos,eps);
+ return convertIntArrToPyList2(tmp);
+ }
+
+ PyObject *getNodeIdsNearPoints(PyObject *pt, int nbOfNodes, double eps) const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<int> c,cI;
+ int size;
+ INTERP_KERNEL::AutoPtr<double> pos=convertPyToNewDblArr2(pt,&size);
+ if(size<self->getSpaceDimension()*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<DataArrayInt> d0=DataArrayInt::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> 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<int> 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;i<sz;i++)
+ PyList_SetItem(coords,i,PyFloat_FromDouble(coo[i]));
+ delete [] coo;
+ delete [] c;
+ }
+ static void Rotate3DAlg(PyObject *center, PyObject *vect, double angle, int nbNodes, PyObject *coords) throw(INTERP_KERNEL::Exception)
+ {
+ int sz,sz2;
+ double *c=convertPyToNewDblArr2(center,&sz);
+ double *coo=convertPyToNewDblArr2(coords,&sz);
+ double *v=convertPyToNewDblArr2(vect,&sz2);
+ ParaMEDMEM::MEDCouplingPointSet::Rotate3DAlg(c,v,angle,nbNodes,coo);
+ for(int i=0;i<sz;i++)
+ PyList_SetItem(coords,i,PyFloat_FromDouble(coo[i]));
+ delete [] coo;
+ delete [] c;
+ }
+ }
+ };
+
+ class MEDCouplingUMesh : public ParaMEDMEM::MEDCouplingPointSet
+ {
+ public:
+ static MEDCouplingUMesh *New();
+ static MEDCouplingUMesh *New(const char *meshName, int meshDim);
+ MEDCouplingUMesh *clone(bool recDeepCpy) const;
+ void updateTime() const;
+ void checkCoherency() const throw(INTERP_KERNEL::Exception);
+ void setMeshDimension(int meshDim) throw(INTERP_KERNEL::Exception);
+ void allocateCells(int nbOfCells) throw(INTERP_KERNEL::Exception);
+ void finishInsertingCells() throw(INTERP_KERNEL::Exception);
+ void setConnectivity(DataArrayInt *conn, DataArrayInt *connIndex, bool isComputingTypes=true) throw(INTERP_KERNEL::Exception);
+ INTERP_KERNEL::NormalizedCellType getTypeOfCell(int cellId) const throw(INTERP_KERNEL::Exception);
+ int getNumberOfNodesInCell(int cellId) const throw(INTERP_KERNEL::Exception);
+ int getMeshLength() const throw(INTERP_KERNEL::Exception);
+ void computeTypes() throw(INTERP_KERNEL::Exception);
+ std::string reprConnectivityOfThis() const throw(INTERP_KERNEL::Exception);
+ //tools
+ DataArrayInt *findCellsIdsOnBoundary() const throw(INTERP_KERNEL::Exception);
+ bool checkConsecutiveCellTypes() const throw(INTERP_KERNEL::Exception);
+ DataArrayInt *rearrange2ConsecutiveCellTypes() throw(INTERP_KERNEL::Exception);
+ DataArrayInt *sortCellsInMEDFileFrmt() throw(INTERP_KERNEL::Exception);
+ DataArrayInt *convertCellArrayPerGeoType(const DataArrayInt *da) const throw(INTERP_KERNEL::Exception);
+ DataArrayInt *zipConnectivityTraducer(int compType) throw(INTERP_KERNEL::Exception);
+ MEDCouplingUMesh *buildDescendingConnectivity(DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *revDesc, DataArrayInt *revDescIndx) const throw(INTERP_KERNEL::Exception);
+ void orientCorrectlyPolyhedrons() throw(INTERP_KERNEL::Exception);
+ bool isPresenceOfQuadratic() const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *buildDirectionVectorField() const throw(INTERP_KERNEL::Exception);
+ bool isContiguous1D() const throw(INTERP_KERNEL::Exception);
+ void convertQuadraticCellsToLinear() throw(INTERP_KERNEL::Exception);
+ void convertDegeneratedCells() throw(INTERP_KERNEL::Exception);
+ bool areOnlySimplexCells() const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *getEdgeRatioField() const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *getAspectRatioField() const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *getWarpField() const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *getSkewField() const throw(INTERP_KERNEL::Exception);
+ static MEDCouplingUMesh *Build0DMeshFromCoords(DataArrayDouble *da) throw(INTERP_KERNEL::Exception);
+ static MEDCouplingUMesh *MergeUMeshes(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2) throw(INTERP_KERNEL::Exception);
+ static MEDCouplingUMesh *MergeUMeshesOnSameCoords(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2) throw(INTERP_KERNEL::Exception);
+ %extend {
+ std::string __str__() const
+ {
+ return self->simpleRepr();
+ }
+ void insertNextCell(INTERP_KERNEL::NormalizedCellType type, int size, PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ int sz;
+ INTERP_KERNEL::AutoPtr<int> 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<INTERP_KERNEL::NormalizedCellType> result=self->getAllTypes();
+ std::set<INTERP_KERNEL::NormalizedCellType>::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<int> cells;
+ self->checkButterflyCells(cells);
+ return convertIntArrToPyList2(cells);
+ }
+
+ PyObject *splitByType() const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<MEDCouplingUMesh *> ms=self->splitByType();
+ int sz=ms.size();
+ PyObject *ret = PyList_New(sz);
+ for(int i=0;i<sz;i++)
+ PyList_SetItem(ret,i,SWIG_NewPointerObj(SWIG_as_voidptr(ms[i]),SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh, SWIG_POINTER_OWN | 0 ));
+ return ret;
+ }
+
+ PyObject *keepSpecifiedCells(INTERP_KERNEL::NormalizedCellType type, PyObject *ids) const throw(INTERP_KERNEL::Exception)
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> 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<INTERP_KERNEL::NormalizedCellType> 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<INTERP_KERNEL::NormalizedCellType> 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<INTERP_KERNEL::NormalizedCellType> 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<const ParaMEDMEM::MEDCouplingUMesh *> 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<const MEDCouplingUMesh *> meshes;
+ convertPyObjToVecUMeshesCst(ms,meshes);
+ std::vector<DataArrayInt *> corr;
+ MEDCouplingUMesh *um=MEDCouplingUMesh::FuseUMeshesOnSameCoords(meshes,compType,corr);
+ sz=corr.size();
+ PyObject *ret1=PyList_New(sz);
+ for(int i=0;i<sz;i++)
+ PyList_SetItem(ret1,i,SWIG_NewPointerObj(SWIG_as_voidptr(corr[i]),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyObject *ret=PyList_New(2);
+ PyList_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(um),SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh, SWIG_POINTER_OWN | 0 ));
+ PyList_SetItem(ret,1,ret1);
+ return ret;
+ }
+
+ PyObject *are2DCellsNotCorrectlyOriented(PyObject *vec, bool polyOnly) const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<int> 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<int> 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<const ParaMEDMEM::MEDCouplingUMesh *> 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<DataArrayInt> d0=DataArrayInt::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> d1=DataArrayInt::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> d2=DataArrayInt::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> 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<DataArrayInt> d0=DataArrayInt::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> 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<DataArrayInt> d0=DataArrayInt::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> 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<INTERP_KERNEL::NormalizedCellType> result=self->getTypesOfPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
+ std::set<INTERP_KERNEL::NormalizedCellType>::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<int> 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<int>& 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<int> tmp;
+ convertPyToNewIntArr3(li,tmp);
+ self->copyPartOfStringInfoFrom(other,tmp);
+ }
+
+ void copyPartOfStringInfoFrom2(PyObject *li, const DataArray& other) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<int> 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<int> 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<int> 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<int> 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<int> 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<int> 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<int> 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<int> 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<int> tmp;
+ convertPyToNewIntArr3(li,tmp);
+ return self->keepSelectedComponents(tmp);
+ }
+
+ void setSelectedComponents(const DataArrayDouble *a, PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<int> tmp;
+ convertPyToNewIntArr3(li,tmp);
+ self->setSelectedComponents(a,tmp);
+ }
+
+ PyObject *getTuple(int tupleId) throw(INTERP_KERNEL::Exception)
+ {
+ int sz=self->getNumberOfComponents();
+ INTERP_KERNEL::AutoPtr<double> tmp=new double[sz];
+ self->getTuple(tupleId,tmp);
+ return convertDblArrToPyList(tmp,sz);
+ }
+
+ static DataArrayDouble *Aggregate(PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<const DataArrayDouble *> tmp;
+ convertPyObjToVecDataArrayDblCst(li,tmp);
+ return DataArrayDouble::Aggregate(tmp);
+ }
+
+ static DataArrayDouble *Meld(PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<const DataArrayDouble *> 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<int> vt1,vc1;
+ std::pair<int, std::pair<int,int> > pt1,pc1;
+ DataArrayInt *dt1=0,*dc1=0;
+ int sw;
+ convertObjToPossibleCpp3(obj,nbOfTuples,nbOfComponents,sw,it1,ic1,vt1,vc1,pt1,pc1,dt1,dc1);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> 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<int> v2(1,ic1);
+ return ret->keepSelectedComponents(v2);
+ }
+ case 6:
+ {
+ ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size());
+ std::vector<int> v2(1,ic1);
+ return ret->keepSelectedComponents(v2);
+ }
+ case 7:
+ {
+ ret=self->selectByTupleId2(pt1.first,pt1.second.first,pt1.second.second);
+ std::vector<int> v2(1,ic1);
+ return ret->keepSelectedComponents(v2);
+ }
+ case 8:
+ {
+ ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems());
+ std::vector<int> 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<int> v2(nbOfComp);
+ for(int i=0;i<nbOfComp;i++)
+ v2[i]=pc1.first+i*pc1.second.second;
+ return ret->keepSelectedComponents(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<int> v2(nbOfComp);
+ for(int i=0;i<nbOfComp;i++)
+ v2[i]=pc1.first+i*pc1.second.second;
+ return ret->keepSelectedComponents(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<int> v2(nbOfComp);
+ for(int i=0;i<nbOfComp;i++)
+ v2[i]=pc1.first+i*pc1.second.second;
+ return ret->keepSelectedComponents(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<int> v2(nbOfComp);
+ for(int i=0;i<nbOfComp;i++)
+ v2[i]=pc1.first+i*pc1.second.second;
+ return ret->keepSelectedComponents(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<double> v1;
+ DataArrayDouble *d1=0;
+ convertObjToPossibleCpp4(value,sw1,i1,v1,d1);
+ int it1,ic1;
+ std::vector<int> vt1,vc1;
+ std::pair<int, std::pair<int,int> > pt1,pc1;
+ DataArrayInt *dt1=0,*dc1=0;
+ convertObjToPossibleCpp3(obj,nbOfTuples,nbOfComponents,sw2,it1,ic1,vt1,vc1,pt1,pc1,dt1,dc1);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> 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<bb || ss<=0)
+ throw INTERP_KERNEL::Exception("Invalid slice in tuple selection");
+ int nbOfE=(ee-bb)/ss;
+ std::vector<int> nv(nbOfE);
+ for(int jj=0;jj<nbOfE;jj++)
+ nv[jj]=bb+jj*ss;
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple2(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<DataArrayDouble> 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<DataArrayDouble> 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<DataArrayDouble> 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<DataArrayDouble> 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<DataArrayDouble> 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<DataArrayDouble> 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<DataArrayDouble> 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<DataArrayDouble> 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<int> 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<const DataArrayInt *> groups;
+ std::vector< std::vector<int> > 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<sz;i++)
+ PyList_SetItem(ret1,i,convertIntArrToPyList2(fidsOfGroups[i]));
+ PyList_SetItem(ret,1,ret1);
+ return ret;
+ }
+
+ void transformWithIndArr(PyObject *li)
+ {
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> 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<int> 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<int> 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<int> 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<int> 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<int> 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<int> 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<int> 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<int> 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<int> tmp;
+ convertPyToNewIntArr3(li,tmp);
+ return self->keepSelectedComponents(tmp);
+ }
+
+ void setSelectedComponents(const DataArrayInt *a, PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<int> tmp;
+ convertPyToNewIntArr3(li,tmp);
+ self->setSelectedComponents(a,tmp);
+ }
+
+ PyObject *getTuple(int tupleId) throw(INTERP_KERNEL::Exception)
+ {
+ int sz=self->getNumberOfComponents();
+ INTERP_KERNEL::AutoPtr<int> 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<const DataArrayInt *> tmp;
+ convertPyObjToVecDataArrayIntCst(li,tmp);
+ return DataArrayInt::Meld(tmp);
+ }
+
+ static DataArrayInt *Aggregate(PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<const DataArrayInt *> tmp;
+ convertPyObjToVecDataArrayIntCst(li,tmp);
+ return DataArrayInt::Aggregate(tmp);
+ }
+
+ static DataArrayInt *BuildUnion(PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<const DataArrayInt *> tmp;
+ convertPyObjToVecDataArrayIntCst(li,tmp);
+ return DataArrayInt::BuildUnion(tmp);
+ }
+
+ static DataArrayInt *BuildIntersection(PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<const DataArrayInt *> 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<int> vt1,vc1;
+ std::pair<int, std::pair<int,int> > pt1,pc1;
+ DataArrayInt *dt1=0,*dc1=0;
+ int sw;
+ convertObjToPossibleCpp3(obj,nbOfTuples,nbOfComponents,sw,it1,ic1,vt1,vc1,pt1,pc1,dt1,dc1);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> 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<int> v2(1,ic1);
+ return ret->keepSelectedComponents(v2);
+ }
+ case 6:
+ {
+ ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size());
+ std::vector<int> v2(1,ic1);
+ return ret->keepSelectedComponents(v2);
+ }
+ case 7:
+ {
+ ret=self->selectByTupleId2(pt1.first,pt1.second.first,pt1.second.second);
+ std::vector<int> v2(1,ic1);
+ return ret->keepSelectedComponents(v2);
+ }
+ case 8:
+ {
+ ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems());
+ std::vector<int> 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<int> v2(nbOfComp);
+ for(int i=0;i<nbOfComp;i++)
+ v2[i]=pc1.first+i*pc1.second.second;
+ return ret->keepSelectedComponents(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<int> v2(nbOfComp);
+ for(int i=0;i<nbOfComp;i++)
+ v2[i]=pc1.first+i*pc1.second.second;
+ return ret->keepSelectedComponents(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<int> v2(nbOfComp);
+ for(int i=0;i<nbOfComp;i++)
+ v2[i]=pc1.first+i*pc1.second.second;
+ return ret->keepSelectedComponents(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<int> v2(nbOfComp);
+ for(int i=0;i<nbOfComp;i++)
+ v2[i]=pc1.first+i*pc1.second.second;
+ return ret->keepSelectedComponents(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<int> v1;
+ DataArrayInt *d1=0;
+ convertObjToPossibleCpp1(value,sw1,i1,v1,d1);
+ int it1,ic1;
+ std::vector<int> vt1,vc1;
+ std::pair<int, std::pair<int,int> > pt1,pc1;
+ DataArrayInt *dt1=0,*dc1=0;
+ convertObjToPossibleCpp3(obj,nbOfTuples,nbOfComponents,sw2,it1,ic1,vt1,vc1,pt1,pc1,dt1,dc1);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> 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<bb || ss<=0)
+ throw INTERP_KERNEL::Exception("Invalid slice in tuple selection");
+ int nbOfE=(ee-bb)/ss;
+ std::vector<int> nv(nbOfE);
+ for(int jj=0;jj<nbOfE;jj++)
+ nv[jj]=bb+jj*ss;
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple2(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<int> aa;
+ int sw;
+ convertObjToPossibleCpp1(obj,sw,val,aa,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> 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<int> aa;
+ int sw;
+ convertObjToPossibleCpp1(obj,sw,val,aa,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> 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<int> 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<int> aa;
+ int sw;
+ convertObjToPossibleCpp1(obj,sw,val,aa,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> 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<int> aa;
+ int sw;
+ convertObjToPossibleCpp1(obj,sw,val,aa,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> 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<int> 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<int> aa;
+ int sw;
+ convertObjToPossibleCpp1(obj,sw,val,aa,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> 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<int> aa;
+ int sw;
+ convertObjToPossibleCpp1(obj,sw,val,aa,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> 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<int> 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<int> aa;
+ int sw;
+ convertObjToPossibleCpp1(obj,sw,val,aa,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> 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<int> aa;
+ int sw;
+ convertObjToPossibleCpp1(obj,sw,val,aa,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> 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<int> 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<int> aa;
+ int sw;
+ convertObjToPossibleCpp1(obj,sw,val,aa,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> 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<int> aa;
+ int sw;
+ convertObjToPossibleCpp1(obj,sw,val,aa,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> 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<int> 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<double>& refCoo,
+ const std::vector<double>& gsCoo, const std::vector<double>& 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<int> 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<double>& refCoo,
+ const std::vector<double>& gsCoo, const std::vector<double>& 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<int> 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<int> 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<std::string>& 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<DataArrayDouble *> arrs=self->getArrays();
+ for(std::vector<DataArrayDouble *>::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<sz;i++)
+ {
+ if(arrs[i])
+ PyTuple_SetItem(ret,i,SWIG_NewPointerObj(SWIG_as_voidptr(arrs[i]),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, SWIG_POINTER_OWN | 0 ));
+ else
+ PyTuple_SetItem(ret,i,SWIG_NewPointerObj(SWIG_as_voidptr(0),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, 0 | 0 ));
+ }
+ return ret;
+ }
+
+ void setArrays(PyObject *ls) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<const DataArrayDouble *> tmp;
+ convertPyObjToVecDataArrayDblCst(ls,tmp);
+ int sz=tmp.size();
+ std::vector<DataArrayDouble *> arrs(sz);
+ for(int i=0;i<sz;i++)
+ arrs[i]=const_cast<DataArrayDouble *>(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<double> spaceLoc=convertPyToNewDblArr2(sl,&sz);
+ sz=self->getNumberOfComponents();
+ INTERP_KERNEL::AutoPtr<double> 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<double> 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<double> spaceLoc=convertPyToNewDblArr2(sl,&sz);
+ sz=self->getNumberOfComponents();
+ INTERP_KERNEL::AutoPtr<double> 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<double> 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<double> 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<double> 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<double> 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<int> 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<int> 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<int> 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<int> tmp;
+ convertPyToNewIntArr3(li,tmp);
+ return self->keepSelectedComponents(tmp);
+ }
+
+ void setSelectedComponents(const MEDCouplingFieldDouble *f, PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<int> tmp;
+ convertPyToNewIntArr3(li,tmp);
+ self->setSelectedComponents(f,tmp);
+ }
+
+ static MEDCouplingFieldDouble *MergeFields(PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<const MEDCouplingFieldDouble *> 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<const ParaMEDMEM::MEDCouplingFieldDouble *> tmp;
+ convertPyObjToVecFieldDblCst(li,tmp);
+ int sz=tmp.size();
+ std::vector<MEDCouplingFieldDouble *> fs(sz);
+ for(int i=0;i<sz;i++)
+ fs[i]=const_cast<MEDCouplingFieldDouble *>(tmp[i]);
+ return MEDCouplingMultiFields::New(fs);
+ }
+ PyObject *getFields() const
+ {
+ std::vector<const MEDCouplingFieldDouble *> fields=self->getFields();
+ int sz=fields.size();
+ PyObject *res = PyList_New(sz);
+ for(int i=0;i<sz;i++)
+ {
+ if(fields[i])
+ {
+ fields[i]->incrRef();
+ 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<MEDCouplingMesh *> ms=self->getMeshes();
+ int sz=ms.size();
+ PyObject *res = PyList_New(sz);
+ for(int i=0;i<sz;i++)
+ {
+ if(ms[i])
+ {
+ ms[i]->incrRef();
+ 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<int> refs;
+ std::vector<MEDCouplingMesh *> ms=self->getDifferentMeshes(refs);
+ int sz=ms.size();
+ PyObject *res = PyList_New(sz);
+ for(int i=0;i<sz;i++)
+ {
+ if(ms[i])
+ {
+ ms[i]->incrRef();
+ 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<DataArrayDouble *> ms=self->getArrays();
+ int sz=ms.size();
+ PyObject *res = PyList_New(sz);
+ for(int i=0;i<sz;i++)
+ {
+ if(ms[i])
+ {
+ ms[i]->incrRef();
+ 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<int> > refs;
+ std::vector<DataArrayDouble *> ms=self->getDifferentArrays(refs);
+ int sz=ms.size();
+ PyObject *res = PyList_New(sz);
+ PyObject *res2 = PyList_New(sz);
+ for(int i=0;i<sz;i++)
+ {
+ if(ms[i])
+ {
+ ms[i]->incrRef();
+ 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<double> 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<const ParaMEDMEM::MEDCouplingFieldDouble *> tmp;
+ convertPyObjToVecFieldDblCst(li,tmp);
+ int sz=tmp.size();
+ std::vector<MEDCouplingFieldDouble *> fs(sz);
+ for(int i=0;i<sz;i++)
+ fs[i]=const_cast<MEDCouplingFieldDouble *>(tmp[i]);
+ return MEDCouplingFieldOverTime::New(fs);
+ }
+ }
+ };
+}
# -*- 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
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);
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);
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)
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();
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();
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]);
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());
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));
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):
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();
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());
#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));
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);
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]
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));
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):
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);
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);
#
f1=m.buildOrthogonalField();
# to avoid valgrind leaks
- # self.assertRaises(Exception,f2.__imul__,f1);
+ # self.assertRaises(InterpKernelException,f2.__imul__,f1);
pass
def testOperationsOnFields4(self):
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);
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);
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):
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
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]
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));
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],
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));
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):
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):
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
#
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;
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
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();
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);
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();
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.]
#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
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
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
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();
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);
#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);
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);
#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
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);
#
#
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.]
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());
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));
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");
#
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();
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());
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();
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):
# -*- 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):
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]
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]
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=[
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)
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
--- /dev/null
+// 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"
# -*- 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
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]
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
-// 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 <numpy/arrayobject.h>
#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<ParaMEDMEM::MEDCouplingUMesh *>(mesh))
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<ParaMEDMEM::MEDCouplingFieldOverTime *>(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);
#endif
}
-static PyObject *convertIntArrToPyList2(const std::vector<int>& v)
+static PyObject *convertIntArrToPyList2(const std::vector<int>& v) throw(INTERP_KERNEL::Exception)
{
#ifndef WITH_NUMPY2
int size=v.size();
#endif
}
-static PyObject *convertIntArrToPyListOfTuple(const int *vals, int nbOfComp, int nbOfTuples)
+static PyObject *convertIntArrToPyList3(const std::set<int>& v) throw(INTERP_KERNEL::Exception)
+{
+ int size=v.size();
+ PyObject *ret=PyList_New(size);
+ std::set<int>::const_iterator it=v.begin();
+ for(int i=0;i<size;i++,it++)
+ PyList_SetItem(ret,i,PyInt_FromLong(*it));
+ return ret;
+}
+
+static PyObject *convertIntArrToPyListOfTuple(const int *vals, int nbOfComp, int nbOfTuples) throw(INTERP_KERNEL::Exception)
{
PyObject *ret=PyList_New(nbOfTuples);
for(int i=0;i<nbOfTuples;i++)
return ret;
}
-static int *convertPyToNewIntArr2(PyObject *pyLi, int *size)
+static int *convertPyToNewIntArr2(PyObject *pyLi, int *size) throw(INTERP_KERNEL::Exception)
{
if(PyList_Check(pyLi))
{
else
{
delete [] tmp;
- PyErr_SetString(PyExc_TypeError,"list must contain integers only");
- PyErr_Print();
- return NULL;
+ const char msg[]="list must contain integers only";
+ PyErr_SetString(PyExc_TypeError,msg);
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+ return tmp;
+ }
+ else if(PyTuple_Check(pyLi))
+ {
+ *size=PyTuple_Size(pyLi);
+ int *tmp=new int[*size];
+ for(int i=0;i<*size;i++)
+ {
+ PyObject *o=PyTuple_GetItem(pyLi,i);
+ if(PyInt_Check(o))
+ {
+ int val=(int)PyInt_AS_LONG(o);
+ tmp[i]=val;
+ }
+ else
+ {
+ delete [] tmp;
+ const char msg[]="tuple must contain integers only";
+ PyErr_SetString(PyExc_TypeError,msg);
+ throw INTERP_KERNEL::Exception(msg);
}
}
return tmp;
else
{
#ifndef WITH_NUMPY2
- PyErr_SetString(PyExc_TypeError,"convertPyToNewIntArr2 : not a list");
- PyErr_Print();
- return 0;
+ const char msg[]="convertPyToNewIntArr2 : not a list";
+ PyErr_SetString(PyExc_TypeError,msg);
+ throw INTERP_KERNEL::Exception(msg);
#else
if(PyArray_Check(pyLi))
{
}
else
{
- PyErr_SetString(PyExc_TypeError,"convertPyToNewIntArr2 : not a list nor PyArray");
- PyErr_Print();
- return 0;
+ const char msg[]="convertPyToNewIntArr2 : not a list nor PyArray";
+ PyErr_SetString(PyExc_TypeError,msg);
+ throw INTERP_KERNEL::Exception(msg);
}
#endif
}
}
-static void convertPyToNewIntArr3(PyObject *pyLi, std::vector<int>& arr)
+static void convertPyToNewIntArr3(PyObject *pyLi, std::vector<int>& arr) throw(INTERP_KERNEL::Exception)
{
if(PyList_Check(pyLi))
{
}
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<size;i++)
+ {
+ PyObject *o=PyTuple_GetItem(pyLi,i);
+ if(PyInt_Check(o))
+ {
+ int val=(int)PyInt_AS_LONG(o);
+ arr[i]=val;
+ }
+ else
+ {
+ const char msg[]="tuple must contain integers only";
+ PyErr_SetString(PyExc_TypeError,msg);
+ throw INTERP_KERNEL::Exception(msg);
}
}
}
else
{
#ifndef WITH_NUMPY2
- PyErr_SetString(PyExc_TypeError,"convertPyToNewIntArr3 : not a list");
- PyErr_Print();
- return ;
+ const char msg[]="convertPyToNewIntArr3 : not a list";
+ PyErr_SetString(PyExc_TypeError,msg);
+ throw INTERP_KERNEL::Exception(msg);
#else
if(PyArray_Check(pyLi))
{
}
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<size;i++)
+ {
+ PyObject *o=PyList_GetItem(pyLi,i);
+ if(PyInt_Check(o))
+ {
+ int val=(int)PyInt_AS_LONG(o);
+ if(i<sizeOfArray)
+ arrToFill[i]=val;
+ }
+ else
+ {
+ const char msg[]="list must contain integers only";
+ PyErr_SetString(PyExc_TypeError,msg);
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+ for(int i=size;i<sizeOfArray;i++)
+ arrToFill[i]=dftVal;
+ return;
+
+ }
+ else if(PyTuple_Check(pyLi))
+ {
+ int size=PyTuple_Size(pyLi);
+ for(int i=0;i<size;i++)
+ {
+ PyObject *o=PyTuple_GetItem(pyLi,i);
+ if(PyInt_Check(o))
+ {
+ int val=(int)PyInt_AS_LONG(o);
+ if(i<sizeOfArray)
+ arrToFill[i]=val;
+ }
+ else
+ {
+ const char msg[]="tuple must contain integers only";
+ PyErr_SetString(PyExc_TypeError,msg);
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+ for(int i=size;i<sizeOfArray;i++)
+ arrToFill[i]=dftVal;
+ return;
+ }
+ else
+ {
+ const char msg[]="fillArrayWithPyListInt : not a list";
+ PyErr_SetString(PyExc_TypeError,msg);
+ throw INTERP_KERNEL::Exception(msg);
+ }
+}
+
+static PyObject *convertDblArrToPyList(const double *ptr, int size) throw(INTERP_KERNEL::Exception)
{
PyObject *ret=PyList_New(size);
for(int i=0;i<size;i++)
return ret;
}
-static PyObject *convertDblArrToPyList2(const std::vector<double>& v)
+static PyObject *convertDblArrToPyList2(const std::vector<double>& v) throw(INTERP_KERNEL::Exception)
{
int size=v.size();
PyObject *ret=PyList_New(size);
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<nbOfTuples;i++)
return ret;
}
-static double *convertPyToNewDblArr2(PyObject *pyLi, int *size)
+static double *convertPyToNewDblArr2(PyObject *pyLi, int *size) throw(INTERP_KERNEL::Exception)
{
if(PyList_Check(pyLi))
{
double val=PyFloat_AS_DOUBLE(o);
tmp[i]=val;
}
+ else if(PyInt_Check(o))
+ {
+ long val0=PyInt_AS_LONG(o);
+ double val=val0;
+ tmp[i]=val;
+ }
+ else
+ {
+ delete [] tmp;
+ const char msg[]="convertPyToNewDblArr2 : list must contain floats/integers only";
+ PyErr_SetString(PyExc_TypeError,msg);
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+ return tmp;
+ }
+ else if(PyTuple_Check(pyLi))
+ {
+ *size=PyTuple_Size(pyLi);
+ double *tmp=new double[*size];
+ for(int i=0;i<*size;i++)
+ {
+ PyObject *o=PyTuple_GetItem(pyLi,i);
+ if(PyFloat_Check(o))
+ {
+ double val=PyFloat_AS_DOUBLE(o);
+ tmp[i]=val;
+ }
+ else if(PyInt_Check(o))
+ {
+ long val0=PyInt_AS_LONG(o);
+ double val=val0;
+ tmp[i]=val;
+ }
else
{
- PyErr_SetString(PyExc_TypeError,"convertPyToNewDblArr2 : list must contain floats only");
- PyErr_Print();
- return NULL;
+ delete [] tmp;
+ const char msg[]="convertPyToNewDblArr2 : tuple must contain floats/integers only";
+ PyErr_SetString(PyExc_TypeError,msg);
+ throw INTERP_KERNEL::Exception(msg);
}
}
return tmp;
}
else
{
- PyErr_SetString(PyExc_TypeError,"convertPyToNewIntArr : not a list");
- PyErr_Print();
- return 0;
+ const char msg[]="convertPyToNewDblArr2 : not a list";
+ PyErr_SetString(PyExc_TypeError,msg);
+ throw INTERP_KERNEL::Exception(msg);
+ }
+}
+
+static void fillArrayWithPyListDbl(PyObject *pyLi, double *arrToFill, int sizeOfArray, double dftVal) throw(INTERP_KERNEL::Exception)
+{
+ if(PyList_Check(pyLi))
+ {
+ int size=PyList_Size(pyLi);
+ for(int i=0;i<size;i++)
+ {
+ PyObject *o=PyList_GetItem(pyLi,i);
+ if(PyFloat_Check(o))
+ {
+ double val=PyFloat_AS_DOUBLE(o);
+ if(i<sizeOfArray)
+ arrToFill[i]=val;
+ }
+ else if(PyInt_Check(o))
+ {
+ long val0=PyInt_AS_LONG(o);
+ double val=val0;
+ if(i<sizeOfArray)
+ arrToFill[i]=val;
+ }
+ else
+ {
+ const char msg[]="fillArrayWithPyListDbl : list must contain floats/integers only";
+ PyErr_SetString(PyExc_TypeError,msg);
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+ for(int i=size;i<sizeOfArray;i++)
+ arrToFill[i]=dftVal;
+ return;
+ }
+ else if(PyTuple_Check(pyLi))
+ {
+ int size=PyTuple_Size(pyLi);
+ for(int i=0;i<size;i++)
+ {
+ PyObject *o=PyTuple_GetItem(pyLi,i);
+ if(PyFloat_Check(o))
+ {
+ double val=PyFloat_AS_DOUBLE(o);
+ arrToFill[i]=val;
+ }
+ else if(PyInt_Check(o))
+ {
+ long val0=PyInt_AS_LONG(o);
+ double val=val0;
+ arrToFill[i]=val;
+ }
+ else
+ {
+ const char msg[]="fillArrayWithPyListDbl : tuple must contain floats/integers only";
+ PyErr_SetString(PyExc_TypeError,msg);
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+ for(int i=size;i<sizeOfArray;i++)
+ arrToFill[i]=dftVal;
+ return ;
+ }
+ else
+ {
+ const char msg[]="convertPyToNewIntArr : not a list";
+ PyErr_SetString(PyExc_TypeError,msg);
+ throw INTERP_KERNEL::Exception(msg);
}
}
-void convertPyObjToVecUMeshes(PyObject *ms, std::vector<ParaMEDMEM::MEDCouplingUMesh *>& v)
+void convertPyObjToVecUMeshesCst(PyObject *ms, std::vector<const ParaMEDMEM::MEDCouplingUMesh *>& v) throw(INTERP_KERNEL::Exception)
{
if(PyList_Check(ms))
{
int status=SWIG_ConvertPtr(obj,&argp,SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh,0|0);
if(!SWIG_IsOK(status))
{
- PyErr_SetString(PyExc_TypeError,"list must contain only DataArrayInt");
- PyErr_Print();
- return;
+ const char msg[]="list must contain only MEDCouplingUMesh";
+ PyErr_SetString(PyExc_TypeError,msg);
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ const ParaMEDMEM::MEDCouplingUMesh *arg=reinterpret_cast< const ParaMEDMEM::MEDCouplingUMesh * >(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<const ParaMEDMEM::DataArrayDouble *>& v) throw(INTERP_KERNEL::Exception)
+{
+ if(PyList_Check(ms))
+ {
+ int size=PyList_Size(ms);
+ v.resize(size);
+ for(int i=0;i<size;i++)
+ {
+ PyObject *obj=PyList_GetItem(ms,i);
+ void *argp;
+ int status=SWIG_ConvertPtr(obj,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayDouble,0|0);
+ if(!SWIG_IsOK(status))
+ {
+ const char msg[]="list must contain only DataArrayDouble";
+ PyErr_SetString(PyExc_TypeError,msg);
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ const ParaMEDMEM::DataArrayDouble *arg=reinterpret_cast< const ParaMEDMEM::DataArrayDouble * >(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<const ParaMEDMEM::MEDCouplingFieldDouble *>& v) throw(INTERP_KERNEL::Exception)
+{
+ if(PyList_Check(ms))
+ {
+ int size=PyList_Size(ms);
+ v.resize(size);
+ for(int i=0;i<size;i++)
+ {
+ PyObject *obj=PyList_GetItem(ms,i);
+ void *argp;
+ int status=SWIG_ConvertPtr(obj,&argp,SWIGTYPE_p_ParaMEDMEM__MEDCouplingFieldDouble,0|0);
+ if(!SWIG_IsOK(status))
+ {
+ const char msg[]="list must contain only MEDCouplingFieldDouble";
+ PyErr_SetString(PyExc_TypeError,msg);
+ throw INTERP_KERNEL::Exception(msg);
}
- ParaMEDMEM::MEDCouplingUMesh *arg=reinterpret_cast< ParaMEDMEM::MEDCouplingUMesh * >(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<ParaMEDMEM::DataArrayInt *>& v)
+void convertPyObjToVecDataArrayIntCst(PyObject *ms, std::vector<const ParaMEDMEM::DataArrayInt *>& v) throw(INTERP_KERNEL::Exception)
{
if(PyList_Check(ms))
{
int status=SWIG_ConvertPtr(obj,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayInt,0|0);
if(!SWIG_IsOK(status))
{
- PyErr_SetString(PyExc_TypeError,"list must contain only DataArrayInt");
- PyErr_Print();
- return;
+ const char msg[]="list must contain only DataArrayInt";
+ PyErr_SetString(PyExc_TypeError,msg);
+ throw INTERP_KERNEL::Exception(msg);
}
ParaMEDMEM::DataArrayInt *arg=reinterpret_cast< ParaMEDMEM::DataArrayInt * >(argp);
v[i]=arg;
}
else
{
- PyErr_SetString(PyExc_TypeError,"convertPyObjToVecDataArrayInt : not a list");
- PyErr_Print();
+ const char msg[]="convertPyObjToVecDataArrayInt : not a list";
+ PyErr_SetString(PyExc_TypeError,msg);
+ throw INTERP_KERNEL::Exception(msg);
+ }
+}
+
+/*!
+ * if python int -> cpp int sw=1
+ * if python list[int] -> cpp vector<int> sw=2
+ * if python tuple[int] -> cpp vector<int> sw=2
+ * if python DataArrayInt -> cpp DataArrayInt sw=3
+ *
+ * switch between (int,vector<int>,DataArrayInt)
+ */
+static void convertObjToPossibleCpp1(PyObject *value, int& sw, int& iTyypp, std::vector<int>& 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<size;i++)
+ {
+ PyObject *o=PyTuple_GetItem(value,i);
+ if(PyInt_Check(o))
+ stdvecTyypp[i]=(int)PyInt_AS_LONG(o);
+ else
+ {
+ std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not integer ! only tuples of integers accepted !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ sw=2;
+ return;
+ }
+ if(PyList_Check(value))
+ {
+ int size=PyList_Size(value);
+ stdvecTyypp.resize(size);
+ for(int i=0;i<size;i++)
+ {
+ PyObject *o=PyList_GetItem(value,i);
+ if(PyInt_Check(o))
+ stdvecTyypp[i]=(int)PyInt_AS_LONG(o);
+ else
+ {
+ std::ostringstream oss; oss << "List as been detected but element #" << i << " is not integer ! only lists of integers accepted !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ sw=2;
+ 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, DataArrayInt");
+ daIntTyypp=reinterpret_cast< ParaMEDMEM::DataArrayInt * >(argp);
+ sw=3;
+}
+
+/*!
+ * if python double -> cpp double sw=1
+ * if python int -> cpp double sw=1
+ * if python list[double] -> cpp vector<double> sw=2
+ * if python list[int] -> cpp vector<double> sw=2
+ * if python tuple[double] -> cpp vector<double> sw=2
+ * if python tuple[int] -> cpp vector<double> sw=2
+ * if python DataArrayDouble -> cpp DataArrayDouble sw=3
+ *
+ * switch between (int,vector<int>,DataArrayInt)
+ */
+static void convertObjToPossibleCpp4(PyObject *value, int& sw, double& iTyypp, std::vector<double>& 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<size;i++)
+ {
+ PyObject *o=PyTuple_GetItem(value,i);
+ if(PyFloat_Check(o))
+ stdvecTyypp[i]=PyFloat_AS_DOUBLE(o);
+ else if(PyInt_Check(o))
+ stdvecTyypp[i]=(double)PyInt_AS_LONG(o);
+ else
+ {
+ std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not double ! only tuples of doubles accepted or integer !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ sw=2;
+ return;
+ }
+ if(PyList_Check(value))
+ {
+ int size=PyList_Size(value);
+ stdvecTyypp.resize(size);
+ for(int i=0;i<size;i++)
+ {
+ PyObject *o=PyList_GetItem(value,i);
+ if(PyFloat_Check(o))
+ stdvecTyypp[i]=PyFloat_AS_DOUBLE(o);
+ else if(PyInt_Check(o))
+ stdvecTyypp[i]=(double)PyInt_AS_LONG(o);
+ else
+ {
+ std::ostringstream oss; oss << "List as been detected but element #" << i << " is not double ! only lists of doubles accepted or integer !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ sw=2;
+ return;
+ }
+ void *argp;
+ int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayDouble,0|0);
+ if(!SWIG_IsOK(status))
+ throw INTERP_KERNEL::Exception("5 types accepted : double float, integer, tuple of double float or int, list of double float or int, DataArrayDouble");
+ daIntTyypp=reinterpret_cast< ParaMEDMEM::DataArrayDouble * >(argp);
+ sw=3;
+}
+
+/*!
+ * if python int -> cpp int sw=1
+ * if python list[int] -> cpp vector<int> sw=2
+ * if python tuple[int] -> cpp vector<int> sw=2
+ * if python slicp -> cpp pair sw=3
+ * if python DataArrayInt -> cpp DataArrayInt sw=4
+ *
+ * switch between (int,vector<int>,DataArrayInt)
+ */
+static void convertObjToPossibleCpp2(PyObject *value, int nbelem, int& sw, int& iTyypp, std::vector<int>& stdvecTyypp, std::pair<int, std::pair<int,int> >& 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<size;i++)
+ {
+ PyObject *o=PyTuple_GetItem(value,i);
+ if(PyInt_Check(o))
+ stdvecTyypp[i]=(int)PyInt_AS_LONG(o);
+ else
+ {
+ std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not integer ! only tuples of integers accepted !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ sw=2;
+ return;
+ }
+ if(PyList_Check(value))
+ {
+ int size=PyList_Size(value);
+ stdvecTyypp.resize(size);
+ for(int i=0;i<size;i++)
+ {
+ PyObject *o=PyList_GetItem(value,i);
+ if(PyInt_Check(o))
+ stdvecTyypp[i]=(int)PyInt_AS_LONG(o);
+ else
+ {
+ std::ostringstream oss; oss << "List as been detected but element #" << i << " is not integer ! only lists of integers accepted !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ sw=2;
+ return;
+ }
+ if(PySlice_Check(value))
+ {
+ Py_ssize_t strt,stp,step;
+ PySliceObject *oC=reinterpret_cast<PySliceObject *>(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<int>,DataArrayInt)
+ */
+static void convertObjToPossibleCpp3(PyObject *value, int nbTuple, int nbCompo, int& sw, int& it, int& ic, std::vector<int>& vt, std::vector<int>& vc,
+ std::pair<int, std::pair<int,int> >& pt, std::pair<int, std::pair<int,int> >& 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;
}
-# 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
+++ /dev/null
-// 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"
+++ /dev/null
-// 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<int>;
-%template(dvec) std::vector<double>;
-%template(svec) std::vector<std::string>;
-
-%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<int> conn;
- self->getNodeIdsOfCell(cellId,conn);
- return convertIntArrToPyList2(conn);
- }
-
- PyObject *getCoordinatesOfNode(int nodeId) const
- {
- std::vector<double> 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<int>& tinyInfo) const = 0;
- //! size of returned tinyInfo must be always the same.
- void getTinySerializationInformation(std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const;
- void resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings) const;
- void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const;
- void unserialization(const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2,
- const std::vector<std::string>& littleStrings);
- virtual void giveElemsInBoundingBox(const double *bbox, double eps, std::vector<int>& elems) = 0;
- virtual void giveElemsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bbox, double eps, std::vector<int>& 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<int> 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<int> 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;i<sz;i++)
- PyList_SetItem(coords,i,PyFloat_FromDouble(coo[i]));
- delete [] coo;
- delete [] c;
- }
- static void rotate3DAlg(PyObject *center, PyObject *vect, double angle, int nbNodes, PyObject *coords)
- {
- int sz,sz2;
- double *c=convertPyToNewDblArr2(center,&sz);
- double *coo=convertPyToNewDblArr2(coords,&sz);
- double *v=convertPyToNewDblArr2(vect,&sz2);
- ParaMEDMEM::MEDCouplingPointSet::rotate3DAlg(c,v,angle,nbNodes,coo);
- for(int i=0;i<sz;i++)
- PyList_SetItem(coords,i,PyFloat_FromDouble(coo[i]));
- delete [] coo;
- delete [] c;
- }
- }
- };
-
- class MEDCouplingUMesh : public ParaMEDMEM::MEDCouplingPointSet
- {
- public:
- static MEDCouplingUMesh *New();
- static MEDCouplingUMesh *New(const char *meshName, int meshDim);
- MEDCouplingUMesh *clone(bool recDeepCpy) const;
- void updateTime();
- void checkCoherency() const throw(INTERP_KERNEL::Exception);
- void setMeshDimension(int meshDim) throw(INTERP_KERNEL::Exception);
- void allocateCells(int nbOfCells);
- void finishInsertingCells();
- void setConnectivity(DataArrayInt *conn, DataArrayInt *connIndex, bool isComputingTypes=true);
- DataArrayInt *getNodalConnectivity() const;
- DataArrayInt *getNodalConnectivityIndex() const;
- INTERP_KERNEL::NormalizedCellType getTypeOfCell(int cellId) const;
- int getNumberOfNodesInCell(int cellId) const;
- int getMeshLength() const;
- void computeTypes();
- std::string reprConnectivityOfThis() const;
- //tools
- bool checkConsecutiveCellTypes() const;
- DataArrayInt *rearrange2ConsecutiveCellTypes();
- DataArrayInt *convertCellArrayPerGeoType(const DataArrayInt *da) const throw(INTERP_KERNEL::Exception);
- DataArrayInt *zipConnectivityTraducer(int compType);
- void getReverseNodalConnectivity(DataArrayInt *revNodal, DataArrayInt *revNodalIndx) const;
- MEDCouplingUMesh *buildDescendingConnectivity(DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *revDesc, DataArrayInt *revDescIndx) const;
- void orientCorrectlyPolyhedrons() throw(INTERP_KERNEL::Exception);
- bool isPresenceOfQuadratic() const;
- MEDCouplingFieldDouble *buildDirectionVectorField() const;
- void convertQuadraticCellsToLinear() throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *getEdgeRatioField() const throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *getAspectRatioField() const throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *getWarpField() const throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *getSkewField() const throw(INTERP_KERNEL::Exception);
- %extend {
- std::string __str__() const
- {
- return self->simpleRepr();
- }
- 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<INTERP_KERNEL::NormalizedCellType> result=self->getAllTypes();
- std::set<INTERP_KERNEL::NormalizedCellType>::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<int> cells;
- self->checkButterflyCells(cells);
- return convertIntArrToPyList2(cells);
- }
-
- PyObject *splitByType() const
- {
- std::vector<MEDCouplingUMesh *> ms=self->splitByType();
- int sz=ms.size();
- PyObject *ret = PyList_New(sz);
- for(int i=0;i<sz;i++)
- PyList_SetItem(ret,i,SWIG_NewPointerObj(SWIG_as_voidptr(ms[i]),SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh, SWIG_POINTER_OWN | 0 ));
- return ret;
- }
-
- PyObject *keepSpecifiedCells(INTERP_KERNEL::NormalizedCellType type, PyObject *ids) const
- {
- std::vector<int> 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<int> 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<int> elts;
- self->getCellsContainingPoint(pos,eps,elts);
- delete [] pos;
- return convertIntArrToPyList2(elts);
- }
-
- static PyObject *mergeUMeshesOnSameCoords(PyObject *ms) throw(INTERP_KERNEL::Exception)
- {
- std::vector<ParaMEDMEM::MEDCouplingUMesh *> meshes;
- if(PyList_Check(ms))
- {
- int sz=PyList_Size(ms);
- meshes.resize(sz);
- for(int i=0;i<sz;i++)
- {
- PyObject *o=PyList_GetItem(ms,i);
- void *arg;
- SWIG_ConvertPtr(o,&arg,SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh, 0 | 0 );
- meshes[i]=reinterpret_cast<ParaMEDMEM::MEDCouplingUMesh *>(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<MEDCouplingUMesh *> meshes;
- convertPyObjToVecUMeshes(ms,meshes);
- std::vector<DataArrayInt *> corr;
- MEDCouplingUMesh *um=MEDCouplingUMesh::fuseUMeshesOnSameCoords(meshes,compType,corr);
- sz=corr.size();
- PyObject *ret1=PyList_New(sz);
- for(int i=0;i<sz;i++)
- PyList_SetItem(ret1,i,SWIG_NewPointerObj(SWIG_as_voidptr(corr[i]),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
- PyObject *ret=PyList_New(2);
- PyList_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(um),SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh, SWIG_POINTER_OWN | 0 ));
- PyList_SetItem(ret,1,ret1);
- return ret;
- }
-
- PyObject *are2DCellsNotCorrectlyOriented(PyObject *vec, bool polyOnly) const throw(INTERP_KERNEL::Exception)
- {
- std::vector<int> 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<int> 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<int>& 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<int> tmp;
- convertPyToNewIntArr3(li,tmp);
- self->copyPartOfStringInfoFrom(other,tmp);
- }
-
- void copyPartOfStringInfoFrom2(PyObject *li, const DataArray& other) throw(INTERP_KERNEL::Exception)
- {
- std::vector<int> 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<int> tmp;
- convertPyToNewIntArr3(li,tmp);
- return self->keepSelectedComponents(tmp);
- }
-
- void setSelectedComponents(const DataArrayDouble *a, PyObject *li) throw(INTERP_KERNEL::Exception)
- {
- std::vector<int> 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<DataArrayInt *> groups;
- std::vector< std::vector<int> > 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;i<sz;i++)
- PyList_SetItem(ret1,i,convertIntArrToPyList2(fidsOfGroups[i]));
- PyList_SetItem(ret,1,ret1);
- 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;
- }
-
- 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<int> tmp;
- convertPyToNewIntArr3(li,tmp);
- return self->keepSelectedComponents(tmp);
- }
-
- void setSelectedComponents(const DataArrayInt *a, PyObject *li) throw(INTERP_KERNEL::Exception)
- {
- std::vector<int> 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<double>& refCoo,
- const std::vector<double>& gsCoo, const std::vector<double>& 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<double>& refCoo,
- const std::vector<double>& gsCoo, const std::vector<double>& 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<int> 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<int> tmp;
- convertPyToNewIntArr3(li,tmp);
- return self->keepSelectedComponents(tmp);
- }
-
- void setSelectedComponents(const MEDCouplingFieldDouble *f, PyObject *li) throw(INTERP_KERNEL::Exception)
- {
- std::vector<int> tmp;
- convertPyToNewIntArr3(li,tmp);
- self->setSelectedComponents(f,tmp);
- }
- }
- };
-}
--- /dev/null
+# -*- 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 *\"
+***********************************************************************
+***********************************************************************
+"""