From 44389378ce5671154c3031adc9706fe2f74272ea Mon Sep 17 00:00:00 2001 From: vsr Date: Wed, 6 Mar 2013 13:56:43 +0000 Subject: [PATCH] Merge from V6_main 06/03/2013 --- adm_local/CMakeLists.txt | 1 + adm_local/unix/CMakeLists.txt | 20 +++ adm_local/unix/config_files/CMakeLists.txt | 40 +++++ doc/doxygen/main.dox | 18 +-- src/INTERP_KERNEL/CellModel.cxx | 103 +++++++++++++ src/INTERP_KERNEL/CellModel.hxx | 5 + src/MEDCoupling/MEDCouplingUMesh.cxx | 142 +++++++++++++++--- src/MEDCoupling/MEDCouplingUMesh.hxx | 4 + src/MEDCoupling_Swig/MEDCouplingBasicsTest.py | 53 +++++++ src/MEDCoupling_Swig/MEDCouplingCommon.i | 78 +++++----- src/MEDLoader/Swig/MEDLoaderCommon.i | 10 +- 11 files changed, 405 insertions(+), 69 deletions(-) create mode 100644 adm_local/unix/CMakeLists.txt create mode 100644 adm_local/unix/config_files/CMakeLists.txt diff --git a/adm_local/CMakeLists.txt b/adm_local/CMakeLists.txt index 7d6dfa86e..75d5607e1 100644 --- a/adm_local/CMakeLists.txt +++ b/adm_local/CMakeLists.txt @@ -17,4 +17,5 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # +ADD_SUBDIRECTORY(unix) ADD_SUBDIRECTORY(cmake_files) diff --git a/adm_local/unix/CMakeLists.txt b/adm_local/unix/CMakeLists.txt new file mode 100644 index 000000000..fcdb331f1 --- /dev/null +++ b/adm_local/unix/CMakeLists.txt @@ -0,0 +1,20 @@ +# Copyright (C) 2007-2012 CEA/DEN, EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +ADD_SUBDIRECTORY(config_files) diff --git a/adm_local/unix/config_files/CMakeLists.txt b/adm_local/unix/config_files/CMakeLists.txt new file mode 100644 index 000000000..20fd7f47e --- /dev/null +++ b/adm_local/unix/config_files/CMakeLists.txt @@ -0,0 +1,40 @@ +# Copyright (C) 2007-2012 CEA/DEN, EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +SET(dist_admlocalm4_DATA + ac_check_sizeof_fortran.m4 + check_GUI.m4 + check_Med.m4 + check_Med2.m4 + check_med3.m4 + check_bft.m4 + check_fvm.m4 + check_metis.m4 + check_parmetis.m4 + check_scotch.m4 + med_check_sizeof_medint.m4 + renumber.m4 + splitter.m4 + with_Kernel.m4 +) + +FOREACH(f ${dist_admlocalm4_DATA}) + SET(DEST adm_local/unix/config_files) + INSTALL(FILES ${f} DESTINATION ${DEST}) +ENDFOREACH(f ${dist_admlocalm4_DATA}) diff --git a/doc/doxygen/main.dox b/doc/doxygen/main.dox index a8e64c5b0..d4a1b6f13 100644 --- a/doc/doxygen/main.dox +++ b/doc/doxygen/main.dox @@ -18,9 +18,9 @@ library: \image html medlayers_70pc.png -The fondamentals consists in three atomic libraries: +The fondamentals consists in three atomic libraries: -- \ref medcoupling that describes DataStructures used for cross process exchange of meshes and fields. +- \ref medcoupling that describes DataStructures used for cross process exchange of meshes and fields. - \ref medloader that provides I/O functions to the MED file format - \ref interptools (INTERP_KERNEL + REMAPPER) that provides mathematical structures and algorithms for interpolation and @@ -40,25 +40,25 @@ you to deal with most standard use case of fields manipulation. The user guide can be found here: - User guide of the MED Graphical Interface + href="../../dev/MED/medop-userguide.html">User guide of the MED Graphical Interface (in french) You could also be interested to read the software specifications and requirements for this graphical module, and even the technical considerations for development: - Software - specifications and requirements of the MED Graphical Interface + href="../../dev/MED/medop-specifications.html">Software + specifications and requirements of the MED Graphical Interface (in french) - Developer guide of the MED Graphical Interface + href="../../dev/MED/medop-develguide.html">Developer guide of the MED Graphical Interface (in french) \section S3 A set of tools for file manipulation - Chapter \ref tools describes various tools based on MEDMEM that can -be helpful for handling MED files (conversion tools and splitting tools). +be helpful for handling MED files (conversion tools and splitting tools). -\section install Installation -The install procedure of the %MED SALOME module can handle a variety of configurations +\section install Installation +The install procedure of the %MED SALOME module can handle a variety of configurations to suit the needs of its user. Instructions for configuring and installing the module an be found in \ref medmem_install. diff --git a/src/INTERP_KERNEL/CellModel.cxx b/src/INTERP_KERNEL/CellModel.cxx index f1d517d57..0ff626212 100644 --- a/src/INTERP_KERNEL/CellModel.cxx +++ b/src/INTERP_KERNEL/CellModel.cxx @@ -116,6 +116,7 @@ namespace INTERP_KERNEL _reverse_extruded_type=NORM_ERROR; _linear_type=NORM_ERROR; _quadratic_type=NORM_ERROR; + _nb_of_little_sons=std::numeric_limits::max(); switch(type) { case NORM_POINT1: @@ -158,6 +159,12 @@ namespace INTERP_KERNEL _sons_con[1][0]=0; _sons_con[1][1]=3; _sons_con[1][2]=1; _nb_of_sons_con[1]=3; _sons_con[2][0]=1; _sons_con[2][1]=3; _sons_con[2][2]=2; _nb_of_sons_con[2]=3; _sons_con[3][0]=2; _sons_con[3][1]=3; _sons_con[3][2]=0; _nb_of_sons_con[3]=3; + _little_sons_con[0][0]=0; _little_sons_con[0][1]=1; _nb_of_little_sons=6; + _little_sons_con[1][0]=1; _little_sons_con[1][1]=2; + _little_sons_con[2][0]=2; _little_sons_con[2][1]=0; + _little_sons_con[3][0]=0; _little_sons_con[3][1]=3; + _little_sons_con[4][0]=1; _little_sons_con[4][1]=3; + _little_sons_con[5][0]=2; _little_sons_con[5][1]=3; } break; case NORM_HEXA8: @@ -170,6 +177,18 @@ namespace INTERP_KERNEL _sons_con[3][0]=1; _sons_con[3][1]=5; _sons_con[3][2]=6; _sons_con[3][3]=2; _nb_of_sons_con[3]=4; _sons_con[4][0]=2; _sons_con[4][1]=6; _sons_con[4][2]=7; _sons_con[4][3]=3; _nb_of_sons_con[4]=4; _sons_con[5][0]=3; _sons_con[5][1]=7; _sons_con[5][2]=4; _sons_con[5][3]=0; _nb_of_sons_con[5]=4; + _little_sons_con[0][0]=0; _little_sons_con[0][1]=1; _nb_of_little_sons=12; + _little_sons_con[1][0]=1; _little_sons_con[1][1]=2; + _little_sons_con[2][0]=2; _little_sons_con[2][1]=3; + _little_sons_con[3][0]=3; _little_sons_con[3][1]=0; + _little_sons_con[4][0]=4; _little_sons_con[4][1]=5; + _little_sons_con[5][0]=5; _little_sons_con[5][1]=6; + _little_sons_con[6][0]=6; _little_sons_con[6][1]=7; + _little_sons_con[7][0]=7; _little_sons_con[7][1]=4; + _little_sons_con[8][0]=0; _little_sons_con[8][1]=4; + _little_sons_con[9][0]=1; _little_sons_con[9][1]=5; + _little_sons_con[10][0]=2; _little_sons_con[10][1]=6; + _little_sons_con[11][0]=3; _little_sons_con[11][1]=7; } break; case NORM_QUAD4: @@ -238,6 +257,14 @@ namespace INTERP_KERNEL _sons_con[2][0]=1; _sons_con[2][1]=4; _sons_con[2][2]=2; _nb_of_sons_con[2]=3; _sons_con[3][0]=2; _sons_con[3][1]=4; _sons_con[3][2]=3; _nb_of_sons_con[3]=3; _sons_con[4][0]=3; _sons_con[4][1]=4; _sons_con[4][2]=0; _nb_of_sons_con[4]=3; + _little_sons_con[0][0]=0; _little_sons_con[0][1]=1; _nb_of_little_sons=8; + _little_sons_con[1][0]=1; _little_sons_con[1][1]=2; + _little_sons_con[2][0]=2; _little_sons_con[2][1]=3; + _little_sons_con[3][0]=3; _little_sons_con[3][1]=0; + _little_sons_con[4][0]=0; _little_sons_con[4][1]=4; + _little_sons_con[5][0]=1; _little_sons_con[5][1]=4; + _little_sons_con[6][0]=2; _little_sons_con[6][1]=4; + _little_sons_con[7][0]=3; _little_sons_con[7][1]=4; } break; case NORM_PENTA6: @@ -249,6 +276,15 @@ namespace INTERP_KERNEL _sons_con[2][0]=0; _sons_con[2][1]=3; _sons_con[2][2]=4; _sons_con[2][3]=1; _nb_of_sons_con[2]=4; _sons_con[3][0]=1; _sons_con[3][1]=4; _sons_con[3][2]=5; _sons_con[3][3]=2; _nb_of_sons_con[3]=4; _sons_con[4][0]=2; _sons_con[4][1]=5; _sons_con[4][2]=3; _sons_con[4][3]=0; _nb_of_sons_con[4]=4; + _little_sons_con[0][0]=0; _little_sons_con[0][1]=1; _nb_of_little_sons=9; + _little_sons_con[1][0]=1; _little_sons_con[1][1]=2; + _little_sons_con[2][0]=2; _little_sons_con[2][1]=0; + _little_sons_con[3][0]=3; _little_sons_con[3][1]=4; + _little_sons_con[4][0]=4; _little_sons_con[4][1]=5; + _little_sons_con[5][0]=5; _little_sons_con[5][1]=3; + _little_sons_con[6][0]=0; _little_sons_con[6][1]=3; + _little_sons_con[7][0]=1; _little_sons_con[7][1]=4; + _little_sons_con[8][0]=2; _little_sons_con[8][1]=5; } break; case NORM_TETRA10: @@ -259,6 +295,12 @@ namespace INTERP_KERNEL _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[2][0]=1; _sons_con[2][1]=3; _sons_con[2][2]=2; _sons_con[2][3]=8; _sons_con[2][4]=9; _sons_con[2][5]=5; _nb_of_sons_con[2]=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; + _little_sons_con[0][0]=0; _little_sons_con[0][1]=1; _little_sons_con[0][2]=4; _nb_of_little_sons=6; + _little_sons_con[1][0]=1; _little_sons_con[1][1]=2; _little_sons_con[1][2]=5; + _little_sons_con[2][0]=2; _little_sons_con[2][1]=0; _little_sons_con[2][2]=6; + _little_sons_con[3][0]=0; _little_sons_con[3][1]=3; _little_sons_con[3][2]=7; + _little_sons_con[4][0]=1; _little_sons_con[4][1]=3; _little_sons_con[4][2]=8; + _little_sons_con[5][0]=2; _little_sons_con[5][1]=3; _little_sons_con[5][2]=9; } break; case NORM_HEXGP12: @@ -285,6 +327,14 @@ namespace INTERP_KERNEL _sons_con[2][0]=1; _sons_con[2][1]=4; _sons_con[2][2]=2; _sons_con[2][3]=10; _sons_con[2][4]=11; _sons_con[2][5]=6; _nb_of_sons_con[2]=6; _sons_con[3][0]=2; _sons_con[3][1]=4; _sons_con[3][2]=3; _sons_con[3][3]=11; _sons_con[3][4]=12; _sons_con[3][5]=7; _nb_of_sons_con[3]=6; _sons_con[4][0]=3; _sons_con[4][1]=4; _sons_con[4][2]=0; _sons_con[4][3]=12; _sons_con[4][4]=9; _sons_con[4][5]=8; _nb_of_sons_con[4]=6; _quadratic=true; + _little_sons_con[0][0]=0; _little_sons_con[0][1]=1; _little_sons_con[0][2]=5; _nb_of_little_sons=8; + _little_sons_con[1][0]=1; _little_sons_con[1][1]=2; _little_sons_con[1][2]=6; + _little_sons_con[2][0]=2; _little_sons_con[2][1]=3; _little_sons_con[2][2]=7; + _little_sons_con[3][0]=3; _little_sons_con[3][1]=0; _little_sons_con[3][2]=8; + _little_sons_con[4][0]=0; _little_sons_con[4][1]=4; _little_sons_con[4][2]=9; + _little_sons_con[5][0]=1; _little_sons_con[5][1]=4; _little_sons_con[5][2]=10; + _little_sons_con[6][0]=2; _little_sons_con[6][1]=4; _little_sons_con[6][2]=11; + _little_sons_con[7][0]=3; _little_sons_con[7][1]=4; _little_sons_con[7][2]=12; } break; case NORM_PENTA15: @@ -296,6 +346,15 @@ namespace INTERP_KERNEL _sons_con[2][0]=0; _sons_con[2][1]=3; _sons_con[2][2]=4; _sons_con[2][3]=1; _sons_con[2][4]=12; _sons_con[2][5]=9; _sons_con[2][6]=13; _sons_con[2][7]=6; _nb_of_sons_con[2]=8; _sons_con[3][0]=1; _sons_con[3][1]=4; _sons_con[3][2]=5; _sons_con[3][3]=2; _sons_con[3][4]=13; _sons_con[3][5]=10; _sons_con[3][6]=14; _sons_con[3][7]=7; _nb_of_sons_con[3]=8; _sons_con[4][0]=2; _sons_con[4][1]=4; _sons_con[4][2]=5; _sons_con[4][3]=0; _sons_con[4][4]=14; _sons_con[4][5]=11; _sons_con[4][6]=12; _sons_con[4][7]=8; _nb_of_sons_con[4]=8; _quadratic=true; + _little_sons_con[0][0]=0; _little_sons_con[0][1]=1; _little_sons_con[0][2]=6; _nb_of_little_sons=9; + _little_sons_con[1][0]=1; _little_sons_con[1][1]=2; _little_sons_con[1][2]=7; + _little_sons_con[2][0]=2; _little_sons_con[2][1]=0; _little_sons_con[2][2]=8; + _little_sons_con[3][0]=3; _little_sons_con[3][1]=4; _little_sons_con[3][2]=9; + _little_sons_con[4][0]=4; _little_sons_con[4][1]=5; _little_sons_con[4][2]=10; + _little_sons_con[5][0]=5; _little_sons_con[5][1]=3; _little_sons_con[5][2]=11; + _little_sons_con[6][0]=0; _little_sons_con[6][1]=3; _little_sons_con[6][2]=12; + _little_sons_con[7][0]=1; _little_sons_con[7][1]=4; _little_sons_con[7][2]=13; + _little_sons_con[8][0]=2; _little_sons_con[8][1]=5; _little_sons_con[8][2]=14; } break; case NORM_HEXA20: @@ -308,6 +367,18 @@ namespace INTERP_KERNEL _sons_con[3][0]=1; _sons_con[3][1]=5; _sons_con[3][3]=6; _sons_con[3][3]=2; _sons_con[3][4]=17; _sons_con[3][5]=13; _sons_con[3][6]=18; _sons_con[3][7]=9;_nb_of_sons_con[3]=8; _sons_con[4][0]=2; _sons_con[4][1]=6; _sons_con[4][3]=7; _sons_con[4][3]=3; _sons_con[4][4]=18; _sons_con[4][5]=14; _sons_con[4][6]=19; _sons_con[4][7]=10; _nb_of_sons_con[4]=8; _sons_con[5][0]=3; _sons_con[5][1]=7; _sons_con[5][3]=4; _sons_con[5][3]=0; _sons_con[5][4]=19; _sons_con[5][5]=15; _sons_con[5][6]=16; _sons_con[5][7]=11; _nb_of_sons_con[5]=8; _quadratic=true; + _little_sons_con[0][0]=0; _little_sons_con[0][1]=1; _little_sons_con[0][2]=8; _nb_of_little_sons=12; + _little_sons_con[1][0]=1; _little_sons_con[1][1]=2; _little_sons_con[1][2]=9; + _little_sons_con[2][0]=2; _little_sons_con[2][1]=3; _little_sons_con[2][2]=10; + _little_sons_con[3][0]=3; _little_sons_con[3][1]=0; _little_sons_con[3][2]=11; + _little_sons_con[4][0]=4; _little_sons_con[4][1]=5; _little_sons_con[4][2]=12; + _little_sons_con[5][0]=5; _little_sons_con[5][1]=6; _little_sons_con[5][2]=13; + _little_sons_con[6][0]=6; _little_sons_con[6][1]=7; _little_sons_con[6][2]=14; + _little_sons_con[7][0]=7; _little_sons_con[7][1]=4; _little_sons_con[7][2]=15; + _little_sons_con[8][0]=0; _little_sons_con[8][1]=4; _little_sons_con[8][2]=16; + _little_sons_con[9][0]=1; _little_sons_con[9][1]=5; _little_sons_con[9][2]=17; + _little_sons_con[10][0]=2; _little_sons_con[10][1]=6; _little_sons_con[10][2]=18; + _little_sons_con[11][0]=3; _little_sons_con[11][1]=7; _little_sons_con[11][2]=19; } break; case NORM_HEXA27: @@ -370,6 +441,14 @@ namespace INTERP_KERNEL return std::count(conn,conn+lgth,-1)+1; } + unsigned CellModel::getNumberOfEdgesIn3D(const int *conn, int lgth) const + { + if(!isDynamic()) + return _nb_of_little_sons; + else//polyhedron + return (lgth-std::count(conn,conn+lgth,-1))/2; + } + /*! * Equivalent to getSonType except that this method deals with dynamic type. */ @@ -442,6 +521,30 @@ namespace INTERP_KERNEL } } + unsigned CellModel::fillSonEdgesNodalConnectivity3D(int sonId, const int *nodalConn, int lgth, int *sonNodalConn, NormalizedCellType& typeOfSon) const + { + if(!isDynamic()) + { + if(!isQuadratic()) + { + typeOfSon=NORM_SEG2; + sonNodalConn[0]=nodalConn[_little_sons_con[sonId][0]]; + sonNodalConn[1]=nodalConn[_little_sons_con[sonId][1]]; + return 2; + } + else + { + typeOfSon=NORM_SEG3; + sonNodalConn[0]=nodalConn[_little_sons_con[sonId][0]]; + sonNodalConn[1]=nodalConn[_little_sons_con[sonId][1]]; + sonNodalConn[2]=nodalConn[_little_sons_con[sonId][2]]; + return 3; + } + } + else + throw INTERP_KERNEL::Exception("CellModel::fillSonEdgesNodalConnectivity3D : not implemented yet for NORM_POLYHED !"); + } + //================================================================================ /*! * \brief Return number of nodes in sonId-th son of a Dynamic() cell diff --git a/src/INTERP_KERNEL/CellModel.hxx b/src/INTERP_KERNEL/CellModel.hxx index 62c7828ee..cff77c2de 100644 --- a/src/INTERP_KERNEL/CellModel.hxx +++ b/src/INTERP_KERNEL/CellModel.hxx @@ -37,6 +37,7 @@ namespace INTERP_KERNEL public: static const unsigned MAX_NB_OF_SONS=8; static const unsigned MAX_NB_OF_NODES_PER_ELEM=30; + static const unsigned MAX_NB_OF_LITTLE_SONS=12; private: CellModel(NormalizedCellType type); static void buildUniqueInstance(); @@ -55,6 +56,7 @@ namespace INTERP_KERNEL INTERPKERNEL_EXPORT unsigned getNumberOfNodes() const { return _nb_of_pts; } INTERPKERNEL_EXPORT unsigned getNumberOfSons() const { return _nb_of_sons; } INTERPKERNEL_EXPORT unsigned getNumberOfSons2(const int *conn, int lgth) const; + INTERPKERNEL_EXPORT unsigned getNumberOfEdgesIn3D(const int *conn, int lgth) const; INTERPKERNEL_EXPORT unsigned getNumberOfNodesConstituentTheSon(unsigned sonId) const { return _nb_of_sons_con[sonId]; } INTERPKERNEL_EXPORT unsigned getNumberOfNodesConstituentTheSon2(unsigned sonId, const int *nodalConn, int lgth) const; INTERPKERNEL_EXPORT NormalizedCellType getExtrudedType() const { return _extruded_type; } @@ -65,6 +67,7 @@ namespace INTERP_KERNEL INTERPKERNEL_EXPORT NormalizedCellType getSonType2(unsigned sonId) const; INTERPKERNEL_EXPORT unsigned fillSonCellNodalConnectivity(int sonId, const int *nodalConn, int *sonNodalConn) const; INTERPKERNEL_EXPORT unsigned fillSonCellNodalConnectivity2(int sonId, const int *nodalConn, int lgth, int *sonNodalConn, NormalizedCellType& typeOfSon) const; + INTERPKERNEL_EXPORT unsigned fillSonEdgesNodalConnectivity3D(int sonId, const int *nodalConn, int lgth, int *sonNodalConn, NormalizedCellType& typeOfSon) const; private: bool _dyn; bool _quadratic; @@ -73,12 +76,14 @@ namespace INTERP_KERNEL unsigned _dim; unsigned _nb_of_pts; unsigned _nb_of_sons; + unsigned _nb_of_little_sons; NormalizedCellType _type; NormalizedCellType _extruded_type; NormalizedCellType _reverse_extruded_type; NormalizedCellType _linear_type; NormalizedCellType _quadratic_type; unsigned _sons_con[MAX_NB_OF_SONS][MAX_NB_OF_NODES_PER_ELEM]; + unsigned _little_sons_con[MAX_NB_OF_LITTLE_SONS][3]; unsigned _nb_of_sons_con[MAX_NB_OF_SONS]; NormalizedCellType _sons_type[MAX_NB_OF_SONS]; static std::map _map_of_unique_instance; diff --git a/src/MEDCoupling/MEDCouplingUMesh.cxx b/src/MEDCoupling/MEDCouplingUMesh.cxx index 8443998f0..f43fa22d5 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.cxx +++ b/src/MEDCoupling/MEDCouplingUMesh.cxx @@ -553,6 +553,28 @@ int MEDCouplingOrientationSensitiveNbrer(int id, unsigned nb, const INTERP_KERNE } } +class MinusOneSonsGenerator +{ +public: + MinusOneSonsGenerator(const INTERP_KERNEL::CellModel& cm):_cm(cm) { } + unsigned getNumberOfSons2(const int *conn, int lgth) const { return _cm.getNumberOfSons2(conn,lgth); } + unsigned fillSonCellNodalConnectivity2(int sonId, const int *nodalConn, int lgth, int *sonNodalConn, INTERP_KERNEL::NormalizedCellType& typeOfSon) const { return _cm.fillSonCellNodalConnectivity2(sonId,nodalConn,lgth,sonNodalConn,typeOfSon); } + static const int DELTA=1; +private: + const INTERP_KERNEL::CellModel& _cm; +}; + +class MinusTwoSonsGenerator +{ +public: + MinusTwoSonsGenerator(const INTERP_KERNEL::CellModel& cm):_cm(cm) { } + unsigned getNumberOfSons2(const int *conn, int lgth) const { return _cm.getNumberOfEdgesIn3D(conn,lgth); } + unsigned fillSonCellNodalConnectivity2(int sonId, const int *nodalConn, int lgth, int *sonNodalConn, INTERP_KERNEL::NormalizedCellType& typeOfSon) const { return _cm.fillSonEdgesNodalConnectivity3D(sonId,nodalConn,lgth,sonNodalConn,typeOfSon); } + static const int DELTA=2; +private: + const INTERP_KERNEL::CellModel& _cm; +}; + /// @endcond /*! @@ -576,7 +598,22 @@ int MEDCouplingOrientationSensitiveNbrer(int id, unsigned nb, const INTERP_KERNE */ MEDCouplingUMesh *MEDCouplingUMesh::buildDescendingConnectivity(DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *revDesc, DataArrayInt *revDescIndx) const throw(INTERP_KERNEL::Exception) { - return buildDescendingConnectivityGen(desc,descIndx,revDesc,revDescIndx,MEDCouplingFastNbrer); + return buildDescendingConnectivityGen(desc,descIndx,revDesc,revDescIndx,MEDCouplingFastNbrer); +} + +/*! + * \a this has to have a mesh dimension equal to 3. If it is not the case an INTERP_KERNEL::Exception will be thrown. + * This behaves exactly as MEDCouplingUMesh::buildDescendingConnectivity does except that this method compute directly the transition from mesh dimension 3 to sub edges (dimension 1) + * in one shot. That is to say that this method is equivalent to 2 successive calls to MEDCouplingUMesh::buildDescendingConnectivity. + * This method returns 4 arrays and a mesh as MEDCouplingUMesh::buildDescendingConnectivity does. + * \sa MEDCouplingUMesh::buildDescendingConnectivity + */ +MEDCouplingUMesh *MEDCouplingUMesh::explode3DMeshTo1D(DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *revDesc, DataArrayInt *revDescIndx) const throw(INTERP_KERNEL::Exception) +{ + checkFullyDefined(); + if(getMeshDimension()!=3) + throw INTERP_KERNEL::Exception("MEDCouplingUMesh::explode3DMeshTo1D : This has to have a mesh dimension to 3 !"); + return buildDescendingConnectivityGen(desc,descIndx,revDesc,revDescIndx,MEDCouplingFastNbrer); } /*! @@ -592,7 +629,7 @@ MEDCouplingUMesh *MEDCouplingUMesh::buildDescendingConnectivity(DataArrayInt *de */ MEDCouplingUMesh *MEDCouplingUMesh::buildDescendingConnectivity2(DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *revDesc, DataArrayInt *revDescIndx) const throw(INTERP_KERNEL::Exception) { - return buildDescendingConnectivityGen(desc,descIndx,revDesc,revDescIndx,MEDCouplingOrientationSensitiveNbrer); + return buildDescendingConnectivityGen(desc,descIndx,revDesc,revDescIndx,MEDCouplingOrientationSensitiveNbrer); } /*! @@ -668,6 +705,7 @@ void MEDCouplingUMesh::ComputeNeighborsOfCellsAdv(const DataArrayInt *desc, cons * \b WARNING this method do the assumption that connectivity lies on the coordinates set. * For speed reasons no check of this will be done. */ +template MEDCouplingUMesh *MEDCouplingUMesh::buildDescendingConnectivityGen(DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *revDesc, DataArrayInt *revDescIndx, DimM1DescNbrer nbrer) const throw(INTERP_KERNEL::Exception) { checkConnectivityFullyDefined(); @@ -678,7 +716,7 @@ MEDCouplingUMesh *MEDCouplingUMesh::buildDescendingConnectivityGen(DataArrayInt const int *conn=_nodal_connec->getConstPointer(); const int *connIndex=_nodal_connec_index->getConstPointer(); std::string name="Mesh constituent of "; name+=getName(); - MEDCouplingAutoRefCountObjectPtr ret=MEDCouplingUMesh::New(name.c_str(),getMeshDimension()-1); + MEDCouplingAutoRefCountObjectPtr ret=MEDCouplingUMesh::New(name.c_str(),getMeshDimension()-SonsGenerator::DELTA); ret->setCoords(getCoords()); ret->allocateCells(2*nbOfCells); descIndx->alloc(nbOfCells+1,1); @@ -689,12 +727,13 @@ MEDCouplingUMesh *MEDCouplingUMesh::buildDescendingConnectivityGen(DataArrayInt int pos=connIndex[eltId]; int posP1=connIndex[eltId+1]; const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel((INTERP_KERNEL::NormalizedCellType)conn[pos]); - unsigned nbOfSons=cm.getNumberOfSons2(conn+pos+1,posP1-pos-1); + SonsGenerator sg(cm); + unsigned nbOfSons=sg.getNumberOfSons2(conn+pos+1,posP1-pos-1); INTERP_KERNEL::AutoPtr tmp=new int[posP1-pos]; for(unsigned i=0;i=0) revNodalIndxPtr[tmp[k]+1]++; @@ -3963,7 +4002,7 @@ MEDCouplingUMesh *MEDCouplingUMesh::buildExtrudedMesh(const MEDCouplingUMesh *me 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 !"); + throw INTERP_KERNEL::Exception("Invalid call to buildExtrudedMesh this and mesh1D must have same space 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) @@ -4413,12 +4452,19 @@ DataArrayInt *MEDCouplingUMesh::convertLinearCellsToQuadratic(int conversionType case 1: ret=convertLinearCellsToQuadratic1D0(conn,connI,coords,types); connSafe=conn; connISafe=connI; coordsSafe=coords; + break; case 2: ret=convertLinearCellsToQuadratic2D0(conn,connI,coords,types); connSafe=conn; connISafe=connI; coordsSafe=coords; + break; + case 3: + ret=convertLinearCellsToQuadratic3D0(conn,connI,coords,types); + connSafe=conn; connISafe=connI; coordsSafe=coords; + break; default: - throw INTERP_KERNEL::Exception("MEDCouplingUMesh::convertLinearCellsToQuadratic : conversion of type 0 mesh dimensions available are [1] !"); + throw INTERP_KERNEL::Exception("MEDCouplingUMesh::convertLinearCellsToQuadratic : conversion of type 0 mesh dimensions available are [1,2,3] !"); } + break; //case 1: //return convertLinearCellsToQuadratic1(); default: @@ -4453,19 +4499,18 @@ DataArrayInt *MEDCouplingUMesh::convertLinearCellsToQuadratic1D0(DataArrayInt *& { types.insert(INTERP_KERNEL::NORM_SEG3); newConn->pushBackSilent((int)INTERP_KERNEL::NORM_SEG3); - newConn->pushBackValsSilent(cPtr+cPtr[0]+1,cPtr+cPtr[0]+3); + newConn->pushBackValsSilent(cPtr+icPtr[0]+1,cPtr+icPtr[0]+3); newConn->pushBackSilent(offset++); - newConnI->pushBackSilent(lastVal+4); + lastVal+=4; + newConnI->pushBackSilent(lastVal); ret->pushBackSilent(i); - lastVal+=4; } else { types.insert(type); - int tmp=lastVal+(icPtr[1]-icPtr[0]); - newConnI->pushBackSilent(tmp); - newConn->pushBackValsSilent(cPtr+cPtr[0],cPtr+cPtr[1]); - lastVal=tmp; + lastVal+=(icPtr[1]-icPtr[0]); + newConnI->pushBackSilent(lastVal); + newConn->pushBackValsSilent(cPtr+icPtr[0],cPtr+icPtr[1]); } } MEDCouplingAutoRefCountObjectPtr tmp=bary->selectByTupleIdSafe(ret->begin(),ret->end()); @@ -4473,6 +4518,52 @@ DataArrayInt *MEDCouplingUMesh::convertLinearCellsToQuadratic1D0(DataArrayInt *& return ret.retn(); } +DataArrayInt *MEDCouplingUMesh::convertLinearCellsToQuadratic2DAnd3D0(const MEDCouplingUMesh *m1D, const DataArrayInt *desc, const DataArrayInt *descI, DataArrayInt *&conn, DataArrayInt *&connI, DataArrayDouble *& coords, std::set& types) const throw(INTERP_KERNEL::Exception) +{ + MEDCouplingAutoRefCountObjectPtr newConn=DataArrayInt::New(); newConn->alloc(0,1); + MEDCouplingAutoRefCountObjectPtr newConnI=DataArrayInt::New(); newConnI->alloc(1,1); newConnI->setIJ(0,0,0); + MEDCouplingAutoRefCountObjectPtr ret=DataArrayInt::New(); ret->alloc(0,1); + // + const int *descPtr(desc->begin()),*descIPtr(descI->begin()); + DataArrayInt *conn1D=0,*conn1DI=0; + std::set types1D; + DataArrayDouble *coordsTmp=0; + MEDCouplingAutoRefCountObjectPtr ret1D=m1D->convertLinearCellsToQuadratic1D0(conn1D,conn1DI,coordsTmp,types1D); ret1D=0; + MEDCouplingAutoRefCountObjectPtr coordsTmpSafe(coordsTmp); + MEDCouplingAutoRefCountObjectPtr conn1DSafe(conn1D),conn1DISafe(conn1DI); + const int *c1DPtr=conn1D->begin(); + const int *c1DIPtr=conn1DI->begin(); + int nbOfCells=getNumberOfCells(); + const int *cPtr=_nodal_connec->getConstPointer(); + const int *icPtr=_nodal_connec_index->getConstPointer(); + int lastVal=0; + for(int i=0;ipushBackSilent(typ2); + newConn->pushBackValsSilent(cPtr+icPtr[0]+1,cPtr+icPtr[1]); + for(const int *d=descPtr+descIPtr[0];d!=descPtr+descIPtr[1];d++) + newConn->pushBackSilent(c1DPtr[c1DIPtr[*d]+3]); + lastVal+=(icPtr[1]-icPtr[0])+(descIPtr[1]-descIPtr[0]); + newConnI->pushBackSilent(lastVal); + ret->pushBackSilent(i); + } + else + { + types.insert(typ); + lastVal+=(icPtr[1]-icPtr[0]); + newConnI->pushBackSilent(lastVal); + newConn->pushBackValsSilent(cPtr+icPtr[0],cPtr+icPtr[1]); + } + } + conn=newConn.retn(); connI=newConnI.retn(); coords=coordsTmpSafe.retn(); + return ret.retn(); +} + /*! * Implementes \a conversionType 0 for meshes with meshDim = 2, of MEDCouplingUMesh::convertLinearCellsToQuadratic method. * \return a newly created DataArrayInt instance that the caller should deal with containing cell ids of converted cells. @@ -4480,13 +4571,22 @@ DataArrayInt *MEDCouplingUMesh::convertLinearCellsToQuadratic1D0(DataArrayInt *& */ DataArrayInt *MEDCouplingUMesh::convertLinearCellsToQuadratic2D0(DataArrayInt *&conn, DataArrayInt *&connI, DataArrayDouble *& coords, std::set& types) const throw(INTERP_KERNEL::Exception) { - MEDCouplingAutoRefCountObjectPtr desc(DataArrayInt::New()),descI(DataArrayInt::New()); - DataArrayInt *tmp2=DataArrayInt::New(),*tmp3=DataArrayInt::New(); - MEDCouplingAutoRefCountObjectPtr m1D=buildDescendingConnectivity2(desc,descI,tmp2,tmp3); tmp2->decrRef(); tmp3->decrRef(); - DataArrayInt *conn1D=0,*conn1DI=0; - std::set types1D; - MEDCouplingAutoRefCountObjectPtr ret1D=m1D->convertLinearCellsToQuadratic1D0(conn1D,conn1DI,coords,types1D); ret1D=0; - return 0;//tony + + MEDCouplingAutoRefCountObjectPtr desc(DataArrayInt::New()),descI(DataArrayInt::New()),tmp2(DataArrayInt::New()),tmp3(DataArrayInt::New()); + MEDCouplingAutoRefCountObjectPtr m1D=buildDescendingConnectivity(desc,descI,tmp2,tmp3); tmp2=0; tmp3=0; + return convertLinearCellsToQuadratic2DAnd3D0(m1D,desc,descI,conn,connI,coords,types); +} + +/*! + * Implementes \a conversionType 0 for meshes with meshDim = 3, of MEDCouplingUMesh::convertLinearCellsToQuadratic method. + * \return a newly created DataArrayInt instance that the caller should deal with containing cell ids of converted cells. + * \sa MEDCouplingUMesh::convertLinearCellsToQuadratic. + */ +DataArrayInt *MEDCouplingUMesh::convertLinearCellsToQuadratic3D0(DataArrayInt *&conn, DataArrayInt *&connI, DataArrayDouble *& coords, std::set& types) const throw(INTERP_KERNEL::Exception) +{ + MEDCouplingAutoRefCountObjectPtr desc(DataArrayInt::New()),descI(DataArrayInt::New()),tmp2(DataArrayInt::New()),tmp3(DataArrayInt::New()); + MEDCouplingAutoRefCountObjectPtr m1D=explode3DMeshTo1D(desc,descI,tmp2,tmp3); tmp2=0; tmp3=0; + return convertLinearCellsToQuadratic2DAnd3D0(m1D,desc,descI,conn,connI,coords,types); } /*! diff --git a/src/MEDCoupling/MEDCouplingUMesh.hxx b/src/MEDCoupling/MEDCouplingUMesh.hxx index 5fc45aefe..5ada04133 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.hxx +++ b/src/MEDCoupling/MEDCouplingUMesh.hxx @@ -116,6 +116,7 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT bool areCellsIncludedIn(const MEDCouplingUMesh *other, int compType, DataArrayInt *& arr) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT bool areCellsIncludedIn2(const MEDCouplingUMesh *other, DataArrayInt *& arr) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void getReverseNodalConnectivity(DataArrayInt *revNodal, DataArrayInt *revNodalIndx) const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT MEDCouplingUMesh *explode3DMeshTo1D(DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *revDesc, DataArrayInt *revDescIndx) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT MEDCouplingUMesh *buildDescendingConnectivity(DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *revDesc, DataArrayInt *revDescIndx) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT MEDCouplingUMesh *buildDescendingConnectivity2(DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *revDesc, DataArrayInt *revDescIndx) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void computeNeighborsOfCells(DataArrayInt *&neighbors, DataArrayInt *&neighborsIdx) const throw(INTERP_KERNEL::Exception); @@ -272,13 +273,16 @@ namespace ParaMEDMEM MEDCouplingUMesh *buildPartOfMySelfKeepCoords(const int *begin, const int *end) const; MEDCouplingUMesh *buildPartOfMySelfKeepCoords2(int start, int end, int step) const; DataArrayInt *convertLinearCellsToQuadratic1D0(DataArrayInt *&conn, DataArrayInt *&connI, DataArrayDouble *& coords, std::set& types) const throw(INTERP_KERNEL::Exception); + DataArrayInt *convertLinearCellsToQuadratic2DAnd3D0(const MEDCouplingUMesh *m1D, const DataArrayInt *desc, const DataArrayInt *descI, DataArrayInt *&conn, DataArrayInt *&connI, DataArrayDouble *& coords, std::set& types) const throw(INTERP_KERNEL::Exception); DataArrayInt *convertLinearCellsToQuadratic2D0(DataArrayInt *&conn, DataArrayInt *&connI, DataArrayDouble *& coords, std::set& types) const throw(INTERP_KERNEL::Exception); + DataArrayInt *convertLinearCellsToQuadratic3D0(DataArrayInt *&conn, DataArrayInt *&connI, DataArrayDouble *& coords, std::set& types) const throw(INTERP_KERNEL::Exception); template void getCellsContainingPointsAlg(const double *coords, const double *pos, int nbOfPoints, double eps, std::vector& elts, std::vector& eltsIndex) const; /// @cond INTERNAL static MEDCouplingUMesh *MergeUMeshesLL(std::vector& a) throw(INTERP_KERNEL::Exception); typedef int (*DimM1DescNbrer)(int id, unsigned nb, const INTERP_KERNEL::CellModel& cm, bool compute, const int *conn1, const int *conn2); + template MEDCouplingUMesh *buildDescendingConnectivityGen(DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *revDesc, DataArrayInt *revDescIndx, DimM1DescNbrer nbrer) const throw(INTERP_KERNEL::Exception); DataArrayInt *buildUnionOf2DMesh() const throw(INTERP_KERNEL::Exception); DataArrayInt *buildUnionOf3DMesh() const throw(INTERP_KERNEL::Exception); diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py index b1a329f0a..310f5cbe6 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py @@ -11257,6 +11257,59 @@ class MEDCouplingBasicsTest(unittest.TestCase): self.assertTrue(d.isEqual(DataArrayInt([0,0,3,9,0,0,3,9,0,0,3,9],6,2))) pass + def testSwig2ConvertLinearCellsToQuadratic1(self): + coordsExp=DataArrayDouble([-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,-0.3,-0.05,-0.05,0.2,0.2,-0.05,-0.05,-0.3,0.45,-0.05,0.45,-0.3,0.45,0.2,0.7,-0.05,-0.05,0.7,0.2,0.45,-0.3,0.45,0.45,0.7,0.7,0.45],22,2) + # 2D + m2D=MEDCouplingDataForTest.build2DTargetMesh_1() + m2D.convertLinearCellsToQuadratic(0) + m2D.checkCoherency1() + self.assertEqual(m2D.getNodalConnectivity().getValues(),[8,0,3,4,1,9,10,11,12,6,1,4,2,11,13,14,6,4,5,2,15,16,13,8,6,7,4,3,17,18,10,19,8,7,8,5,4,20,21,15,18]) + self.assertEqual(m2D.getNodalConnectivityIndex().getValues(),[0,9,16,23,32,41]) + self.assertTrue(m2D.getCoords().isEqual(coordsExp,1e-14)) + # 1D + m1D=MEDCouplingDataForTest.build2DTargetMesh_1().buildDescendingConnectivity()[0] + m1D.convertLinearCellsToQuadratic(0) + m1D.checkCoherency1() + self.assertEqual(m1D.getNodalConnectivity().getValues(),[2,0,3,9,2,3,4,10,2,4,1,11,2,1,0,12,2,4,2,13,2,2,1,14,2,4,5,15,2,5,2,16,2,6,7,17,2,7,4,18,2,3,6,19,2,7,8,20,2,8,5,21]) + self.assertEqual(m1D.getNodalConnectivityIndex().getValues(),[0,4,8,12,16,20,24,28,32,36,40,44,48,52]) + self.assertTrue(m1D.getCoords().isEqual(coordsExp,1e-14)) + # 3D + m2D=MEDCouplingDataForTest.build2DTargetMesh_1() + m2D.changeSpaceDimension(3) + arr=DataArrayDouble(4); arr.iota(0) ; z=MEDCouplingCMesh() ; z.setCoords(arr) + m1D=z.buildUnstructured() ; m1D.setCoords(arr.changeNbOfComponents(3,0.)) + m1D.getCoords()[:]=m1D.getCoords()[:,[1,2,0]] + cooTmp=m2D.getCoords()[:] + m3D=m2D.buildExtrudedMesh(m1D,0) + m3D.convertLinearCellsToQuadratic(0) + m3D.checkCoherency1() + # check of new m3D content + coordsExp2=[coordsExp.changeNbOfComponents(3,i) for i in xrange(4)] + coordsExp3=[DataArrayDouble.Meld(cooTmp[:,[0,1]],cooTmp[:,2]+(0.5+float(i))) for i in xrange(3)] + coordsExp4=DataArrayDouble.Aggregate([coordsExp2[0],coordsExp3[0],coordsExp2[1],coordsExp3[1],coordsExp2[2],coordsExp3[2],coordsExp2[3]]) + c=DataArrayDouble.Aggregate(m3D.getCoords(),coordsExp4) + self.assertEqual(len(coordsExp4),115) + self.assertEqual(len(m3D.getCoords()),115) + a,b=c.findCommonTuples(1e-14) + self.assertEqual(len(b),len(coordsExp4)+1) + e,f=DataArrayInt.BuildOld2NewArrayFromSurjectiveFormat2(2*115,a,b) + self.assertEqual(f,115) + self.assertTrue(e.isEqual(DataArrayInt([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,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,0,1,2,3,4,5,6,7,8,36,37,38,39,48,49,53,54,58,59,60,66,67,44,47,52,45,46,57,64,65,70,9,10,11,12,13,14,15,16,17,40,41,42,43,50,51,55,56,61,62,63,68,69,75,78,81,76,77,84,88,89,92,18,19,20,21,22,23,24,25,26,71,72,73,74,79,80,82,83,85,86,87,90,91,97,100,103,98,99,106,110,111,114,27,28,29,30,31,32,33,34,35,93,94,95,96,101,102,104,105,107,108,109,112,113]))) + self.assertTrue(DataArrayInt([30,0,3,4,1,9,12,13,10,36,37,38,39,40,41,42,43,44,45,46,47,25,1,4,2,10,13,11,38,48,49,42,50,51,47,46,52,25,4,5,2,13,14,11,53,54,48,55,56,50,46,57,52,30,6,7,4,3,15,16,13,12,58,59,37,60,61,62,41,63,64,65,46,45,30,7,8,5,4,16,17,14,13,66,67,53,59,68,69,55,62,65,70,57,46,30,9,12,13,10,18,21,22,19,40,41,42,43,71,72,73,74,75,76,77,78,25,10,13,11,19,22,20,42,50,51,73,79,80,78,77,81,25,13,14,11,22,23,20,55,56,50,82,83,79,77,84,81,30,15,16,13,12,24,25,22,21,61,62,41,63,85,86,72,87,88,89,77,76,30,16,17,14,13,25,26,23,22,68,69,55,62,90,91,82,86,89,92,84,77,30,18,21,22,19,27,30,31,28,71,72,73,74,93,94,95,96,97,98,99,100,25,19,22,20,28,31,29,73,79,80,95,101,102,100,99,103,25,22,23,20,31,32,29,82,83,79,104,105,101,99,106,103,30,24,25,22,21,33,34,31,30,85,86,72,87,107,108,94,109,110,111,99,98,30,25,26,23,22,34,35,32,31,90,91,82,86,112,113,104,108,111,114,106,99]).isEqual(m3D.getNodalConnectivity())) + self.assertTrue(DataArrayInt([0,21,37,53,74,95,116,132,148,169,190,211,227,243,264,285]).isEqual(m3D.getNodalConnectivityIndex())) + # testing explode3DMeshTo1D + m3DSlice0=m3D[:5] + m3DSlice0.zipCoords() + a,b,c,d,e=m3DSlice0.explode3DMeshTo1D() + self.assertTrue(b.isEqual(DataArrayInt([0,1,2,3,4,5,6,7,8,9,10,11,2,12,13,6,14,15,11,10,16,17,18,12,19,20,14,10,21,16,22,23,1,24,25,26,5,27,28,29,10,9,30,31,17,23,32,33,19,26,29,34,21,10]))) + self.assertTrue(c.isEqual(DataArrayInt([0,12,21,30,42,54]))) + self.assertTrue(d.isEqual(DataArrayInt([0,0,3,0,1,0,0,0,3,0,1,0,0,0,3,0,1,2,3,4,0,1,1,2,1,1,2,1,1,2,2,4,2,2,4,2,2,4,3,3,4,3,3,3,4,3,3,3,4,4,4,4,4,4]))) + self.assertTrue(e.isEqual(DataArrayInt([0,1,3,5,6,7,9,11,12,13,15,20,22,24,25,27,28,30,32,33,35,36,38,39,41,42,43,45,46,47,49,50,51,52,53,54]))) + self.assertTrue(a.getNodalConnectivity().isEqual(DataArrayInt([2,0,3,18,2,3,4,19,2,4,1,20,2,1,0,21,2,9,12,22,2,12,13,23,2,13,10,24,2,10,9,25,2,0,9,26,2,3,12,27,2,4,13,28,2,1,10,29,2,4,2,30,2,2,1,31,2,13,11,32,2,11,10,33,2,2,11,34,2,4,5,35,2,5,2,36,2,13,14,37,2,14,11,38,2,5,14,39,2,6,7,40,2,7,4,41,2,3,6,42,2,15,16,43,2,16,13,44,2,12,15,45,2,6,15,46,2,7,16,47,2,7,8,48,2,8,5,49,2,16,17,50,2,17,14,51,2,8,17,52]))) + self.assertTrue(a.getNodalConnectivityIndex().isEqual(DataArrayInt([0,4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64,68,72,76,80,84,88,92,96,100,104,108,112,116,120,124,128,132,136,140]))) + self.assertTrue(a.getCoords().isEqual(DataArrayDouble([-0.3,-0.3,0.0,0.2,-0.3,0.0,0.7,-0.3,0.0,-0.3,0.2,0.0,0.2,0.2,0.0,0.7,0.2,0.0,-0.3,0.7,0.0,0.2,0.7,0.0,0.7,0.7,0.0,-0.3,-0.3,1.0,0.2,-0.3,1.0,0.7,-0.3,1.0,-0.3,0.2,1.0,0.2,0.2,1.0,0.7,0.2,1.0,-0.3,0.7,1.0,0.2,0.7,1.0,0.7,0.7,1.0,-0.3,-0.05,0.0,-0.05,0.2,0.0,0.2,-0.05,0.0,-0.05,-0.3,0.0,-0.3,-0.05,1.0,-0.05,0.2,1.0,0.2,-0.05,1.0,-0.05,-0.3,1.0,-0.3,-0.3,0.5,-0.3,0.2,0.5,0.2,0.2,0.5,0.2,-0.3,0.5,0.45,-0.05,0.0,0.45,-0.3,0.0,0.45,-0.05,1.0,0.45,-0.3,1.0,0.7,-0.3,0.5,0.45,0.2,0.0,0.7,-0.05,0.0,0.45,0.2,1.0,0.7,-0.05,1.0,0.7,0.2,0.5,-0.05,0.7,0.0,0.2,0.45,0.0,-0.3,0.45,0.0,-0.05,0.7,1.0,0.2,0.45,1.0,-0.3,0.45,1.0,-0.3,0.7,0.5,0.2,0.7,0.5,0.45,0.7,0.0,0.7,0.45,0.0,0.45,0.7,1.0,0.7,0.45,1.0,0.7,0.7,0.5],53,3),1e-14)) + pass + def setUp(self): pass pass diff --git a/src/MEDCoupling_Swig/MEDCouplingCommon.i b/src/MEDCoupling_Swig/MEDCouplingCommon.i index 872da9e44..179790356 100644 --- a/src/MEDCoupling_Swig/MEDCouplingCommon.i +++ b/src/MEDCoupling_Swig/MEDCouplingCommon.i @@ -282,6 +282,7 @@ using namespace INTERP_KERNEL; %newobject ParaMEDMEM::MEDCouplingUMesh::zipConnectivityTraducer; %newobject ParaMEDMEM::MEDCouplingUMesh::buildDescendingConnectivity; %newobject ParaMEDMEM::MEDCouplingUMesh::buildDescendingConnectivity2; +%newobject ParaMEDMEM::MEDCouplingUMesh::explode3DMeshTo1D; %newobject ParaMEDMEM::MEDCouplingUMesh::buildExtrudedMesh; %newobject ParaMEDMEM::MEDCouplingUMesh::buildSpreadZonesWithPoly; %newobject ParaMEDMEM::MEDCouplingUMesh::MergeUMeshes; @@ -496,8 +497,8 @@ namespace ParaMEDMEM virtual DataArrayInt *computeNbOfNodesPerCell() const throw(INTERP_KERNEL::Exception); virtual int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception); virtual INTERP_KERNEL::NormalizedCellType getTypeOfCell(int cellId) const throw(INTERP_KERNEL::Exception); - virtual std::string simpleRepr() const; - virtual std::string advancedRepr() const; + virtual std::string simpleRepr() const throw(INTERP_KERNEL::Exception); + virtual std::string advancedRepr() const throw(INTERP_KERNEL::Exception); void writeVTK(const char *fileName) const throw(INTERP_KERNEL::Exception); // tools virtual MEDCouplingFieldDouble *getMeasureField(bool isAbs) const throw(INTERP_KERNEL::Exception); @@ -515,7 +516,7 @@ namespace ParaMEDMEM static const char *GetReprOfGeometricType(INTERP_KERNEL::NormalizedCellType type) throw(INTERP_KERNEL::Exception); %extend { - std::string __str__() const + std::string __str__() const throw(INTERP_KERNEL::Exception) { return self->simpleRepr(); } @@ -993,7 +994,7 @@ namespace ParaMEDMEM virtual DataArrayInt *findBoundaryNodes() const; %extend { - std::string __str__() const + std::string __str__() const throw(INTERP_KERNEL::Exception) { return self->simpleRepr(); } @@ -1394,6 +1395,7 @@ namespace ParaMEDMEM DataArrayInt *zipConnectivityTraducer(int compType, int startCellId=0) throw(INTERP_KERNEL::Exception); MEDCouplingUMesh *buildDescendingConnectivity(DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *revDesc, DataArrayInt *revDescIndx) const throw(INTERP_KERNEL::Exception); MEDCouplingUMesh *buildDescendingConnectivity2(DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *revDesc, DataArrayInt *revDescIndx) const throw(INTERP_KERNEL::Exception); + MEDCouplingUMesh *explode3DMeshTo1D(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); @@ -1428,7 +1430,7 @@ namespace ParaMEDMEM return MEDCouplingUMesh::New(meshName,meshDim); } - std::string __str__() const + std::string __str__() const throw(INTERP_KERNEL::Exception) { return self->simpleRepr(); } @@ -2151,6 +2153,22 @@ namespace ParaMEDMEM return ret; } + PyObject *explode3DMeshTo1D() const throw(INTERP_KERNEL::Exception) + { + MEDCouplingAutoRefCountObjectPtr d0=DataArrayInt::New(); + MEDCouplingAutoRefCountObjectPtr d1=DataArrayInt::New(); + MEDCouplingAutoRefCountObjectPtr d2=DataArrayInt::New(); + MEDCouplingAutoRefCountObjectPtr d3=DataArrayInt::New(); + MEDCouplingUMesh *m=self->explode3DMeshTo1D(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.retn()),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,2,SWIG_NewPointerObj(SWIG_as_voidptr(d1.retn()),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,3,SWIG_NewPointerObj(SWIG_as_voidptr(d2.retn()),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,4,SWIG_NewPointerObj(SWIG_as_voidptr(d3.retn()),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + return ret; + } + PyObject *buildDescendingConnectivity() const throw(INTERP_KERNEL::Exception) { MEDCouplingAutoRefCountObjectPtr d0=DataArrayInt::New(); @@ -2160,14 +2178,10 @@ namespace ParaMEDMEM 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(); + PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(d0.retn()),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,2,SWIG_NewPointerObj(SWIG_as_voidptr(d1.retn()),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,3,SWIG_NewPointerObj(SWIG_as_voidptr(d2.retn()),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,4,SWIG_NewPointerObj(SWIG_as_voidptr(d3.retn()),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); return ret; } @@ -2180,14 +2194,10 @@ namespace ParaMEDMEM MEDCouplingUMesh *m=self->buildDescendingConnectivity2(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(); + PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(d0.retn()),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,2,SWIG_NewPointerObj(SWIG_as_voidptr(d1.retn()),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,3,SWIG_NewPointerObj(SWIG_as_voidptr(d2.retn()),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,4,SWIG_NewPointerObj(SWIG_as_voidptr(d3.retn()),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); return ret; } @@ -2446,7 +2456,7 @@ namespace ParaMEDMEM return MEDCouplingExtrudedMesh::New(mesh3D,mesh2D,cell2DId); } - std::string __str__() const + std::string __str__() const throw(INTERP_KERNEL::Exception) { return self->simpleRepr(); } @@ -2498,7 +2508,7 @@ namespace ParaMEDMEM { return MEDCouplingCMesh::New(meshName); } - std::string __str__() const + std::string __str__() const throw(INTERP_KERNEL::Exception) { return self->simpleRepr(); } @@ -2529,7 +2539,7 @@ namespace ParaMEDMEM { return MEDCouplingCurveLinearMesh::New(meshName); } - std::string __str__() const + std::string __str__() const throw(INTERP_KERNEL::Exception) { return self->simpleRepr(); } @@ -6490,8 +6500,8 @@ namespace ParaMEDMEM void synchronizeTimeWithSupport() throw(INTERP_KERNEL::Exception); void copyTinyAttrFrom(const MEDCouplingFieldDouble *other) throw(INTERP_KERNEL::Exception); void copyAllTinyAttrFrom(const MEDCouplingFieldDouble *other) throw(INTERP_KERNEL::Exception); - std::string simpleRepr() const; - std::string advancedRepr() const; + std::string simpleRepr() const throw(INTERP_KERNEL::Exception); + std::string advancedRepr() const throw(INTERP_KERNEL::Exception); void writeVTK(const char *fileName) const throw(INTERP_KERNEL::Exception); MEDCouplingFieldDouble *clone(bool recDeepCpy) const; MEDCouplingFieldDouble *cloneWithMesh(bool recDeepCpy) const; @@ -6588,7 +6598,7 @@ namespace ParaMEDMEM return MEDCouplingFieldDouble::New(ft,td); } - std::string __str__() const + std::string __str__() const throw(INTERP_KERNEL::Exception) { return self->simpleRepr(); } @@ -7006,8 +7016,8 @@ namespace ParaMEDMEM public: static MEDCouplingFieldTemplate *New(const MEDCouplingFieldDouble *f) throw(INTERP_KERNEL::Exception); static MEDCouplingFieldTemplate *New(TypeOfField type); - std::string simpleRepr() const; - std::string advancedRepr() const; + std::string simpleRepr() const throw(INTERP_KERNEL::Exception); + std::string advancedRepr() const throw(INTERP_KERNEL::Exception); void updateTime() const; %extend { @@ -7021,7 +7031,7 @@ namespace ParaMEDMEM return MEDCouplingFieldTemplate::New(type); } - std::string __str__() const + std::string __str__() const throw(INTERP_KERNEL::Exception) { return self->simpleRepr(); } @@ -7033,15 +7043,15 @@ namespace ParaMEDMEM public: int getNumberOfFields() const; MEDCouplingMultiFields *deepCpy() const; - virtual std::string simpleRepr() const; - virtual std::string advancedRepr() const; + virtual std::string simpleRepr() const throw(INTERP_KERNEL::Exception); + virtual std::string advancedRepr() const throw(INTERP_KERNEL::Exception); 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); void updateTime() const throw(INTERP_KERNEL::Exception); %extend { - std::string __str__() const + std::string __str__() const throw(INTERP_KERNEL::Exception) { return self->simpleRepr(); } @@ -7247,7 +7257,7 @@ namespace ParaMEDMEM fs[i]=const_cast(tmp[i]); return MEDCouplingFieldOverTime::New(fs); } - std::string __str__() const + std::string __str__() const throw(INTERP_KERNEL::Exception) { return self->simpleRepr(); } diff --git a/src/MEDLoader/Swig/MEDLoaderCommon.i b/src/MEDLoader/Swig/MEDLoaderCommon.i index 6082423e5..a770f351e 100644 --- a/src/MEDLoader/Swig/MEDLoaderCommon.i +++ b/src/MEDLoader/Swig/MEDLoaderCommon.i @@ -829,7 +829,7 @@ namespace ParaMEDMEM return MEDFileMeshes::New(fileName); } - std::string __str__() const + std::string __str__() const throw(INTERP_KERNEL::Exception) { return self->simpleRepr(); } @@ -1716,7 +1716,7 @@ namespace ParaMEDMEM public: void setValue(double val) throw(INTERP_KERNEL::Exception); double getValue() const throw(INTERP_KERNEL::Exception); - std::string simpleRepr() const; + std::string simpleRepr() const throw(INTERP_KERNEL::Exception); %extend { std::string __str__() const throw(INTERP_KERNEL::Exception) @@ -1743,7 +1743,7 @@ namespace ParaMEDMEM static MEDFileParameterDouble1TS *New(const char *fileName, const char *paramName) throw(INTERP_KERNEL::Exception); static MEDFileParameterDouble1TS *New(const char *fileName, const char *paramName, int dt, int it) throw(INTERP_KERNEL::Exception); virtual MEDFileParameter1TS *deepCpy() const throw(INTERP_KERNEL::Exception); - virtual std::string simpleRepr() const; + virtual std::string simpleRepr() const throw(INTERP_KERNEL::Exception); void setName(const char *name) throw(INTERP_KERNEL::Exception); const char *getName() const throw(INTERP_KERNEL::Exception); void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception); @@ -1798,7 +1798,7 @@ namespace ParaMEDMEM void setName(const char *name); MEDFileParameterMultiTS *deepCpy() const throw(INTERP_KERNEL::Exception); void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception); - std::string simpleRepr() const; + std::string simpleRepr() const throw(INTERP_KERNEL::Exception); void appendValue(int dt, int it, double time, double val) throw(INTERP_KERNEL::Exception); double getDoubleValue(int iteration, int order) const throw(INTERP_KERNEL::Exception); int getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception); @@ -1989,7 +1989,7 @@ namespace ParaMEDMEM MEDFileParameters *deepCpy() const throw(INTERP_KERNEL::Exception); void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception); std::vector getParamsNames() const throw(INTERP_KERNEL::Exception); - std::string simpleRepr() const; + std::string simpleRepr() const throw(INTERP_KERNEL::Exception); void resize(int newSize) throw(INTERP_KERNEL::Exception); void pushParam(MEDFileParameterMultiTS *param) throw(INTERP_KERNEL::Exception); void setParamAtPos(int i, MEDFileParameterMultiTS *param) throw(INTERP_KERNEL::Exception); -- 2.39.2