From: vsr Date: Wed, 18 Dec 2013 15:06:54 +0000 (+0000) Subject: Merge from V7_3_BR branch 18/12/2013 X-Git-Tag: V7_3_1b1^2~46 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6ff6047d97540bac9220e7eba6c221eb9a7a5579;p=modules%2Fmed.git Merge from V7_3_BR branch 18/12/2013 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index e43611172..d2acb80b3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,7 +29,7 @@ CMAKE_POLICY(SET CMP0003 NEW) STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC) SET(${PROJECT_NAME_UC}_MAJOR_VERSION 7) -SET(${PROJECT_NAME_UC}_MINOR_VERSION 2) +SET(${PROJECT_NAME_UC}_MINOR_VERSION 3) SET(${PROJECT_NAME_UC}_PATCH_VERSION 0) SET(${PROJECT_NAME_UC}_VERSION ${${PROJECT_NAME_UC}_MAJOR_VERSION}.${${PROJECT_NAME_UC}_MINOR_VERSION}.${${PROJECT_NAME_UC}_PATCH_VERSION}) diff --git a/adm_local/cmake_files/FindSalomeXDR.cmake b/adm_local/cmake_files/FindSalomeXDR.cmake index 2db53e88f..50fef653f 100644 --- a/adm_local/cmake_files/FindSalomeXDR.cmake +++ b/adm_local/cmake_files/FindSalomeXDR.cmake @@ -24,7 +24,7 @@ # !! Please read the generic detection procedure in SalomeMacros.cmake !! # -SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS(XDR XDR_FOUND 1) +SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS(XDR XDR_INCLUDE_DIRS 1) #MARK_AS_ADVANCED() #IF(XDR_FOUND) # useless here because XDR is used only in CXX of MEDLoader diff --git a/adm_local/cmake_files/FindXDR.cmake b/adm_local/cmake_files/FindXDR.cmake index 11a9cb7c9..8b39fda0f 100644 --- a/adm_local/cmake_files/FindXDR.cmake +++ b/adm_local/cmake_files/FindXDR.cmake @@ -27,11 +27,10 @@ ENDIF(XDR_ROOT_DIR) FIND_LIBRARY(XDR_LIBRARIES xdr) FIND_PATH(XDR_INCLUDE_DIRS rpc/xdr.h) SET(XDR_DEFINITIONS "-DHAS_XDR") -SET(XDR_FOUND 1) IF(WIN32) LIST(APPEND XDR_INCLUDE_DIRS "${XDR_ROOT_DIR}/include/src/msvc") ENDIF(WIN32) INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(XDR REQUIRED_VARS XDR_FOUND) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(XDR REQUIRED_VARS XDR_INCLUDE_DIRS) diff --git a/adm_local_without_kernel/cmake_files/FindGraphviz.cmake b/adm_local_without_kernel/cmake_files/FindGraphviz.cmake index 6eb1e5a71..d25cffe63 100644 --- a/adm_local_without_kernel/cmake_files/FindGraphviz.cmake +++ b/adm_local_without_kernel/cmake_files/FindGraphviz.cmake @@ -35,19 +35,23 @@ FIND_PATH(GRAPHVIZ_INCLUDE_DIR NAMES graphviz/graph.h) SET(GRAPHVIZ_INCLUDE_DIRS ${GRAPHVIZ_INCLUDE_DIR} ${GRAPHVIZ_INCLUDE_DIR}/graphviz) FIND_LIBRARY(GRAPHVIZ_cdt_LIBRARY NAMES cdt PATH_SUFFIXES bin) -FIND_LIBRARY(GRAPHVIZ_cgraph_LIBRARY NAMES cgraph PATH_SUFFIXES bin) FIND_LIBRARY(GRAPHVIZ_graph_LIBRARY NAMES graph PATH_SUFFIXES bin) FIND_LIBRARY(GRAPHVIZ_gvc_LIBRARY NAMES gvc PATH_SUFFIXES bin) FIND_LIBRARY(GRAPHVIZ_pathplan_LIBRARY NAMES pathplan PATH_SUFFIXES bin) SET(GRAPHVIZ_LIBRARIES ${GRAPHVIZ_cdt_LIBRARY} - ${GRAPHVIZ_cgraph_LIBRARY} ${GRAPHVIZ_graph_LIBRARY} ${GRAPHVIZ_gvc_LIBRARY} ${GRAPHVIZ_pathplan_LIBRARY} ) +## Don't detect cgraph on Windows +#IF(NOT WIN32) +# FIND_LIBRARY(GRAPHVIZ_cgraph_LIBRARY NAMES cgraph PATH_SUFFIXES bin) +# SET(GRAPHVIZ_LIBRARIES ${GRAPHVIZ_cgraph_LIBRARY}) +#ENDIF() + # Handle the standard arguments of the find_package() command: INCLUDE(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(Graphviz REQUIRED_VARS diff --git a/adm_local_without_kernel/cmake_files/FindSalomePython.cmake b/adm_local_without_kernel/cmake_files/FindSalomePython.cmake index 680f862a5..9fa592048 100644 --- a/adm_local_without_kernel/cmake_files/FindSalomePython.cmake +++ b/adm_local_without_kernel/cmake_files/FindSalomePython.cmake @@ -74,6 +74,10 @@ SET(_found1 ${PYTHONINTERP_FOUND}) IF (PYTHONINTERP_FOUND) # Now ensure we find the Python libraries matching the interpreter: # This uses the variable PYTHON_EXECUTABLE + + GET_FILENAME_COMPONENT(_python_bin "${PYTHON_EXECUTABLE}" NAME ) + SET(PYTHONBIN "${_python_bin}" CACHE STRING "Name of Python interpreter") + GET_FILENAME_COMPONENT(_python_dir "${PYTHON_EXECUTABLE}" PATH) GET_FILENAME_COMPONENT(CMAKE_INCLUDE_PATH "${_python_dir}/../include/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}" ABSOLUTE) GET_FILENAME_COMPONENT(CMAKE_LIBRARY_PATH "${_python_dir}/../lib" ABSOLUTE) diff --git a/adm_local_without_kernel/cmake_files/SalomeMacros.cmake b/adm_local_without_kernel/cmake_files/SalomeMacros.cmake index a402d661b..f79dbcf52 100755 --- a/adm_local_without_kernel/cmake_files/SalomeMacros.cmake +++ b/adm_local_without_kernel/cmake_files/SalomeMacros.cmake @@ -801,32 +801,56 @@ ENDMACRO(SALOME_GENERATE_ENVIRONMENT_SCRIPT) # and puts this variable into argument. # MACRO(SALOME_GENERATE_TESTS_ENVIRONMENT output) - SET(_env) - SET(_WIN_LD_LIBRARY OFF) - FOREACH(_item ${_${PROJECT_NAME}_EXTRA_ENV}) - IF(${_item} STREQUAL "LD_LIBRARY_PATH") - SET(_WIN_LD_LIBRARY ON) - ENDIF() - SET(_env_${_item}) - FOREACH(_val ${_${PROJECT_NAME}_EXTRA_ENV_${_item}}) - IF(WIN32) - SET(_env_${_item} "${_val};${_env_${_item}}") - ELSE() - SET(_env_${_item} "${_val}:${_env_${_item}}") - ENDIF() - ENDFOREACH() - ENDFOREACH() + SET(_env) + SET(_WIN_LD_LIBRARY OFF) + FOREACH(_item ${_${PROJECT_NAME}_EXTRA_ENV}) + IF(${_item} STREQUAL "LD_LIBRARY_PATH") + SET(_WIN_LD_LIBRARY ON) + ENDIF() + SET(_env_${_item}) + FOREACH(_val ${_${PROJECT_NAME}_EXTRA_ENV_${_item}}) + IF(WIN32) + STRING(REPLACE "/" "\\" _val "${_val}") + SET(_env_${_item} "${_val};${_env_${_item}}") + ELSE() + SET(_env_${_item} "${_val}:${_env_${_item}}") + ENDIF() + ENDFOREACH() + ENDFOREACH() + + IF(_WIN_LD_LIBRARY AND WIN32) + SET(_env_PATH "${_env_PATH}$ENV{LD_LIBRARY_PATH};${_env_LD_LIBRARY_PATH}") + ENDIF() + + IF(WIN32) + SET(sep ",") + ELSE() + SET(sep ";") + ENDIF() + + FOREACH(_item ${_${PROJECT_NAME}_EXTRA_ENV}) + IF(WIN32) + IF(NOT ${_item} STREQUAL "LD_LIBRARY_PATH") + SET(_env "${_item}=$ENV{${_item}};${_env_${_item}}${sep}${_env}") + ENDIF() + ELSE() + SET(_env "${_item}=$ENV{${_item}}:${_env_${_item}}${sep}${_env}") + ENDIF() + ENDFOREACH() + + # Get module name as substring of "Salome" + STRING(SUBSTRING "${PROJECT_NAME}" 6 -1 PRNAME) + SET(_env "${PRNAME}_ROOT_DIR=${CMAKE_INSTALL_PREFIX}${sep}${_env}") + + # Creating follow string for Windows environement: + # "VAR1_ENV=1\;2\;3\;...\;...\;...;VAR2_ENV=1\;2\;3\;...\;...\;...;VAR3_ENV=1\;2\;3\;...\;...\;...;..." + IF(WIN32) + STRING(REGEX REPLACE "\\\\*;" "\\\\;" _env "${_env}") + STRING(REGEX REPLACE "\\\\*;*," ";" _env "${_env}") + ENDIF() - IF(_WIN_LD_LIBRARY AND WIN32) - SET(_env_PATH "${_env_PATH} ${_env_LD_LIBRARY_PATH}") - ENDIF() + SET(${output} "${_env}") - FOREACH(_item ${_${PROJECT_NAME}_EXTRA_ENV}) - IF(NOT(WIN32 AND ${_item} STREQUAL "LD_LIBRARY_PATH")) - SET(_env "${_item}=${_env_${_item}} ${_env}") - ENDIF() - ENDFOREACH() - SET(${output} ${_env}) ENDMACRO(SALOME_GENERATE_TESTS_ENVIRONMENT) ######################################################################### @@ -847,7 +871,8 @@ MACRO(SALOME_APPEND_LIST_OF_LIST result element_list) SET(_tmp_res) STRING(REPLACE ";" "," _tmp_res "${${element_list}}") - LIST(LENGTH result _list_len) + # Yet another CMake stupidity - LIST(LENGTH ";" var) returns 0 + STRING(LENGTH result _list_len) IF(NOT _list_len EQUAL 0) SET(${result} "${${result}}${_tmp_res};") # LIST(APPEND ...) doesn't handle well empty elements!? ELSE() diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DBounds.hxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DBounds.hxx index ed3c2f305..be590241c 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DBounds.hxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DBounds.hxx @@ -44,6 +44,10 @@ namespace INTERP_KERNEL Bounds():_x_min(0.),_x_max(0.),_y_min(0.),_y_max(0.) { } double &operator[](int i); const double& operator[](int i) const; + double getXMin() const { return _x_min; } + double getXMax() const { return _x_max; } + double getYMin() const { return _y_min; } + double getYMax() const { return _y_max; } double getDiagonal() const; void getBarycenter(double& xBary, double& yBary) const; void applySimilarity(double xBary, double yBary, double dimChar); diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.cxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.cxx index 464702dd0..bc3c20662 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.cxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.cxx @@ -250,6 +250,17 @@ void ComposedEdge::getBarycenterGeneral(double *bary) const _sub_edges.back()->getBarycenter(bary,w); } +double ComposedEdge::normalizeMe(double& xBary, double& yBary) +{ + Bounds b; + b.prepareForAggregation(); + fillBounds(b); + double dimChar=b.getCaracteristicDim(); + b.getBarycenter(xBary,yBary); + applyGlobalSimilarity(xBary,yBary,dimChar); + return dimChar; +} + double ComposedEdge::normalize(ComposedEdge *other, double& xBary, double& yBary) { Bounds b; @@ -419,10 +430,59 @@ void ComposedEdge::getBarycenter(double *bary, double& weigh) const bary[1]/=weigh; } -/** - * Detect if the node is in the Polygon (ComposedEdge or not) +/*! + * \sa ComposedEdge::isInOrOut2 */ bool ComposedEdge::isInOrOut(Node *nodeToTest) const +{ + std::set< IntersectElement > inOutSwitch; + double ref(isInOrOutAlg(nodeToTest,inOutSwitch)); + bool ret=false; + for(std::set< IntersectElement >::iterator iter4=inOutSwitch.begin();iter4!=inOutSwitch.end();iter4++) + { + if((*iter4).getVal1()getLoc()==ON_1) + ret=!ret; + } + else + break; + } + return ret; +} + +/*! + * This method is close to ComposedEdge::isInOrOut behaviour except that here EPSILON is taken into account to detect if it is IN or OUT. + * If \a nodeToTest is close to an edge in \a this, true will be returned even if it is outside informatically from \a this. + * This method makes the hypothesis that + * + * \sa ComposedEdge::isInOrOut + */ +bool ComposedEdge::isInOrOut2(Node *nodeToTest) const +{ + std::set< IntersectElement > inOutSwitch; + double ref(isInOrOutAlg(nodeToTest,inOutSwitch)); + bool ret=false; + for(std::set< IntersectElement >::iterator iter4=inOutSwitch.begin();iter4!=inOutSwitch.end();iter4++) + { + double val((*iter4).getVal1()); + if(fabs(val-ref)>=QUADRATIC_PLANAR::_precision) + { + if(valgetLoc()==ON_1) + ret=!ret; + } + else + break; + } + else + return true; + } + return ret; +} + +double ComposedEdge::isInOrOutAlg(Node *nodeToTest, std::set< IntersectElement >& inOutSwitch) const { Bounds b; b.prepareForAggregation(); fillBounds(b); @@ -447,7 +507,6 @@ bool ComposedEdge::isInOrOut(Node *nodeToTest) const // ok for e1 - Let's go. EdgeInfLin *e1=new EdgeInfLin(nodeToTest,radialDistrib[i]+radialDistrib3[i]/2.); double ref=e1->getCharactValue(*nodeToTest); - std::set< IntersectElement > inOutSwitch; for(std::list::const_iterator iter4=_sub_edges.begin();iter4!=_sub_edges.end();iter4++) { ElementaryEdge *val=(*iter4); @@ -471,21 +530,10 @@ bool ComposedEdge::isInOrOut(Node *nodeToTest) const //if overlapped we can forget } else - throw Exception("Invalid use of ComposedEdge::isInOrOut : only one level supported !"); + throw Exception("Invalid use of ComposedEdge::isInOrOutAlg : only one level supported !"); } e1->decrRef(); - bool ret=false; - for(std::set< IntersectElement >::iterator iter4=inOutSwitch.begin();iter4!=inOutSwitch.end();iter4++) - { - if((*iter4).getVal1()getLoc()==ON_1) - ret=!ret; - } - else - break; - } - return ret; + return ref; } /*bool ComposedEdge::isInOrOut(Node *aNodeOn, Node *nodeToTest) const diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.hxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.hxx index 206a7017e..3e5221ee3 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.hxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.hxx @@ -22,6 +22,7 @@ #define __INTERPKERNELGEO2DCOMPOSEDNODE_HXX__ #include "INTERPKERNELDefines.hxx" +#include "InterpKernelGeo2DEdge.hxx" #include #include @@ -58,6 +59,7 @@ namespace INTERP_KERNEL INTERPKERNEL_EXPORT double getHydraulicDiameter() const; INTERPKERNEL_EXPORT void getBarycenter(double *bary) const; INTERPKERNEL_EXPORT void getBarycenterGeneral(double *bary) const; + INTERPKERNEL_EXPORT double normalizeMe(double& xBary, double& yBary); INTERPKERNEL_EXPORT double normalize(ComposedEdge *other, double& xBary, double& yBary); INTERPKERNEL_EXPORT double normalizeExt(ComposedEdge *other, double& xBary, double& yBary); INTERPKERNEL_EXPORT void unApplyGlobalSimilarityExt(ComposedEdge& other, double xBary, double yBary, double fact); @@ -89,10 +91,12 @@ namespace INTERP_KERNEL INTERPKERNEL_EXPORT bool changeStartNodeWith(Node *node) const; INTERPKERNEL_EXPORT void dumpInXfigFile(std::ostream& stream, int resolution, const Bounds& box) const; INTERPKERNEL_EXPORT bool isInOrOut(Node *nodeToTest) const; + INTERPKERNEL_EXPORT bool isInOrOut2(Node *nodeToTest) const; INTERPKERNEL_EXPORT bool getDirection() const; INTERPKERNEL_EXPORT bool intresincEqCoarse(const Edge *other) const; private: std::list* getListBehind() { return &_sub_edges; } + double isInOrOutAlg(Node *nodeToTest, std::set< IntersectElement >& inOutSwitch) const; protected: ~ComposedEdge(); private: diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.cxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.cxx index 12fbbee7f..8a00bee6e 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.cxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.cxx @@ -23,6 +23,7 @@ #include "InterpKernelGeo2DEdgeInfLin.hxx" //#include "EdgeParabol.hxx" #include "InterpKernelGeo2DEdgeArcCircle.hxx" +#include "InterpKernelGeo2DComposedEdge.hxx" #include "InterpKernelException.hxx" #include diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.hxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.hxx index 4076f70b2..aa0164d7f 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.hxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.hxx @@ -22,7 +22,6 @@ #define __INTERPKERNELGEO2DEDGE_HXX__ #include "INTERPKERNELDefines.hxx" -#include "InterpKernelGeo2DComposedEdge.hxx" #include "InterpKernelException.hxx" #include "InterpKernelGeo2DBounds.hxx" #include "InterpKernelGeo2DNode.hxx" @@ -94,6 +93,8 @@ namespace INTERP_KERNEL unsigned _ass2End2 : 1; }; + class Edge; + class ComposedEdge; /*! * This class is in charge to store an intersection point as result of \b non oververlapping edge intersection. * This class manages the cases when intersect element is one of the extrimities of edge1 and/or edge2. diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DElementaryEdge.cxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DElementaryEdge.cxx index 43e13b4de..4d161d7fc 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DElementaryEdge.cxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DElementaryEdge.cxx @@ -21,6 +21,7 @@ #include "InterpKernelGeo2DElementaryEdge.hxx" #include "InterpKernelException.hxx" #include "InterpKernelGeo2DEdge.hxx" +#include "InterpKernelGeo2DComposedEdge.hxx" using namespace INTERP_KERNEL; diff --git a/src/INTERP_KERNELTest/CMakeLists.txt b/src/INTERP_KERNELTest/CMakeLists.txt index 113208562..6d3bb0e07 100644 --- a/src/INTERP_KERNELTest/CMakeLists.txt +++ b/src/INTERP_KERNELTest/CMakeLists.txt @@ -80,6 +80,8 @@ TARGET_LINK_LIBRARIES(InterpKernelTest medloader medcoupling interpkernel ${CPPU ADD_EXECUTABLE(TestINTERP_KERNEL ${TestINTERP_KERNEL_SOURCES}) TARGET_LINK_LIBRARIES(TestINTERP_KERNEL InterpKernelTest ${CPPUNIT_LIBRARIES} ${PLATFORM_LIBS}) ADD_TEST(TestINTERP_KERNEL TestINTERP_KERNEL) +SALOME_GENERATE_TESTS_ENVIRONMENT(tests_env) +SET_TESTS_PROPERTIES(TestINTERP_KERNEL PROPERTIES ENVIRONMENT "${tests_env}") INSTALL(TARGETS TestINTERP_KERNEL DESTINATION ${SALOME_INSTALL_BINS}) INSTALL(TARGETS InterpKernelTest DESTINATION ${SALOME_INSTALL_LIBS}) diff --git a/src/MEDCoupling/MEDCoupling1GTUMesh.cxx b/src/MEDCoupling/MEDCoupling1GTUMesh.cxx index 3ad0c08d4..ca92e2fa0 100644 --- a/src/MEDCoupling/MEDCoupling1GTUMesh.cxx +++ b/src/MEDCoupling/MEDCoupling1GTUMesh.cxx @@ -1960,12 +1960,14 @@ MEDCoupling1DGTUMesh *MEDCoupling1SGTUMesh::computeDualMesh2D() const /*! * This method aggregate the bbox of each cell and put it into bbox * + * \param [in] arcDetEps - a parameter specifying in case of 2D quadratic polygon cell the detection limit between linear and arc circle. (By default 1e-12) + * For all other cases this input parameter is ignored. * \return DataArrayDouble * - newly created object (to be managed by the caller) \a this number of cells tuples and 2*spacedim components. * * \throw If \a this is not fully set (coordinates and connectivity). * \throw If a cell in \a this has no valid nodeId. */ -DataArrayDouble *MEDCoupling1SGTUMesh::getBoundingBoxForBBTree() const +DataArrayDouble *MEDCoupling1SGTUMesh::getBoundingBoxForBBTree(double arcDetEps) const { int spaceDim(getSpaceDimension()),nbOfCells(getNumberOfCells()),nbOfNodes(getNumberOfNodes()),nbOfNodesPerCell(getNumberOfNodesPerCell()); MEDCouplingAutoRefCountObjectPtr ret(DataArrayDouble::New()); ret->alloc(nbOfCells,2*spaceDim); @@ -3352,12 +3354,14 @@ MEDCoupling1DGTUMesh *MEDCoupling1DGTUMesh::buildSetInstanceFromThis(int spaceDi /*! * This method aggregate the bbox of each cell and put it into bbox parameter. * + * \param [in] arcDetEps - a parameter specifying in case of 2D quadratic polygon cell the detection limit between linear and arc circle. (By default 1e-12) + * For all other cases this input parameter is ignored. * \return DataArrayDouble * - newly created object (to be managed by the caller) \a this number of cells tuples and 2*spacedim components. * * \throw If \a this is not fully set (coordinates and connectivity). * \throw If a cell in \a this has no valid nodeId. */ -DataArrayDouble *MEDCoupling1DGTUMesh::getBoundingBoxForBBTree() const +DataArrayDouble *MEDCoupling1DGTUMesh::getBoundingBoxForBBTree(double arcDetEps) const { checkFullyDefined(); int spaceDim(getSpaceDimension()),nbOfCells(getNumberOfCells()),nbOfNodes(getNumberOfNodes()); diff --git a/src/MEDCoupling/MEDCoupling1GTUMesh.hxx b/src/MEDCoupling/MEDCoupling1GTUMesh.hxx index 93ba77249..805ba002d 100644 --- a/src/MEDCoupling/MEDCoupling1GTUMesh.hxx +++ b/src/MEDCoupling/MEDCoupling1GTUMesh.hxx @@ -130,7 +130,7 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT void renumberNodesInConn(const int *newNodeNumbersO2N); MEDCOUPLING_EXPORT void fillCellIdsToKeepFromNodeIds(const int *begin, const int *end, bool fullyIn, DataArrayInt *&cellIdsKeptArr) const; MEDCOUPLING_EXPORT int getNumberOfNodesInCell(int cellId) const; - MEDCOUPLING_EXPORT DataArrayDouble *getBoundingBoxForBBTree() const; + MEDCOUPLING_EXPORT DataArrayDouble *getBoundingBoxForBBTree(double arcDetEps=1e-12) const; // overload of MEDCoupling1GTUMesh MEDCOUPLING_EXPORT void checkCoherencyOfConnectivity() const; MEDCOUPLING_EXPORT void allocateCells(int nbOfCells=0); @@ -219,7 +219,7 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT void renumberNodesInConn(const int *newNodeNumbersO2N); MEDCOUPLING_EXPORT void fillCellIdsToKeepFromNodeIds(const int *begin, const int *end, bool fullyIn, DataArrayInt *&cellIdsKeptArr) const; MEDCOUPLING_EXPORT int getNumberOfNodesInCell(int cellId) const; - MEDCOUPLING_EXPORT DataArrayDouble *getBoundingBoxForBBTree() const; + MEDCOUPLING_EXPORT DataArrayDouble *getBoundingBoxForBBTree(double arcDetEps=1e-12) const; // overload of MEDCoupling1GTUMesh MEDCOUPLING_EXPORT void checkCoherencyOfConnectivity() const; MEDCOUPLING_EXPORT void allocateCells(int nbOfCells=0); diff --git a/src/MEDCoupling/MEDCouplingExtrudedMesh.cxx b/src/MEDCoupling/MEDCouplingExtrudedMesh.cxx index a76eea128..3658b43be 100644 --- a/src/MEDCoupling/MEDCouplingExtrudedMesh.cxx +++ b/src/MEDCoupling/MEDCouplingExtrudedMesh.cxx @@ -250,7 +250,7 @@ INTERP_KERNEL::NormalizedCellType MEDCouplingExtrudedMesh::getTypeOfCell(int cel std::set MEDCouplingExtrudedMesh::getAllGeoTypes() const { - const std::set& ret2D=_mesh2D->getAllTypes(); + std::set ret2D(_mesh2D->getAllGeoTypes()); std::set ret; for(std::set::const_iterator it=ret2D.begin();it!=ret2D.end();it++) ret.insert(INTERP_KERNEL::CellModel::GetCellModel(*it).getExtrudedType()); diff --git a/src/MEDCoupling/MEDCouplingMemArray.cxx b/src/MEDCoupling/MEDCouplingMemArray.cxx index 88390fc3a..ff071afa6 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.cxx +++ b/src/MEDCoupling/MEDCouplingMemArray.cxx @@ -4595,6 +4595,8 @@ DataArrayDouble *DataArrayDouble::Aggregate(const DataArrayDouble *a1, const Dat * the number of component in the result array is same as that of each of given arrays. * Info on components is copied from the first of the given arrays. Number of components * in the given arrays must be the same. + * If the number of non null of elements in \a arr is equal to one the returned object is a copy of it + * not the object itself. * \param [in] arr - a sequence of arrays to include in the result array. * \return DataArrayDouble * - the new instance of DataArrayDouble. * The caller is to delete this result array using decrRef() as it is no more @@ -8393,13 +8395,14 @@ DataArrayIntIterator *DataArrayInt::iterator() * array using decrRef() as it is no more needed. * \throw If \a this is not allocated. * \throw If \a this->getNumberOfComponents() != 1. + * \sa DataArrayInt::getIdsEqualTuple */ DataArrayInt *DataArrayInt::getIdsEqual(int val) const { checkAllocated(); 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(); + const int *cptr(getConstPointer()); MEDCouplingAutoRefCountObjectPtr ret(DataArrayInt::New()); ret->alloc(0,1); int nbOfTuples=getNumberOfTuples(); for(int i=0;i ret(DataArrayInt::New()); ret->alloc(0,1); int nbOfTuples=getNumberOfTuples(); for(int i=0;igetNumberOfComponents() != std::distance(tupleBg,tupleEnd). + * \throw If \a this->getNumberOfComponents() is equal to 0. + * \sa DataArrayInt::getIdsEqual + */ +DataArrayInt *DataArrayInt::getIdsEqualTuple(const int *tupleBg, const int *tupleEnd) const +{ + std::size_t nbOfCompoExp(std::distance(tupleBg,tupleEnd)); + checkAllocated(); + if(getNumberOfComponents()!=(int)nbOfCompoExp) + { + std::ostringstream oss; oss << "DataArrayInt::getIdsEqualTuple : mismatch of number of components. Input tuple has " << nbOfCompoExp << " whereas this array has " << getNumberOfComponents() << " components !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + if(nbOfCompoExp==0) + throw INTERP_KERNEL::Exception("DataArrayInt::getIdsEqualTuple : number of components should be > 0 !"); + MEDCouplingAutoRefCountObjectPtr ret(DataArrayInt::New()); ret->alloc(0,1); + const int *bg(begin()),*end2(end()),*work(begin()); + while(work!=end2) + { + work=std::search(work,end2,tupleBg,tupleEnd); + if(work!=end2) + { + std::size_t pos(std::distance(bg,work)); + if(pos%nbOfCompoExp==0) + ret->pushBackSilent(pos/nbOfCompoExp); + work++; + } + } + return ret.retn(); +} /*! * Assigns \a newValue to all elements holding \a oldValue within \a this @@ -8800,6 +8842,8 @@ DataArrayInt *DataArrayInt::Aggregate(const DataArrayInt *a1, const DataArrayInt * the number of component in the result array is same as that of each of given arrays. * Info on components is copied from the first of the given arrays. Number of components * in the given arrays must be the same. + * If the number of non null of elements in \a arr is equal to one the returned object is a copy of it + * not the object itself. * \param [in] arr - a sequence of arrays to include in the result array. * \return DataArrayInt * - the new instance of DataArrayInt. * The caller is to delete this result array using decrRef() as it is no more diff --git a/src/MEDCoupling/MEDCouplingMemArray.hxx b/src/MEDCoupling/MEDCouplingMemArray.hxx index af0e9b255..3f6e38a89 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.hxx +++ b/src/MEDCoupling/MEDCouplingMemArray.hxx @@ -534,6 +534,7 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT DataArrayInt *getIdsNotEqual(int val) const; MEDCOUPLING_EXPORT DataArrayInt *getIdsEqualList(const int *valsBg, const int *valsEnd) const; MEDCOUPLING_EXPORT DataArrayInt *getIdsNotEqualList(const int *valsBg, const int *valsEnd) const; + MEDCOUPLING_EXPORT DataArrayInt *getIdsEqualTuple(const int *tupleBg, const int *tupleEnd) const; MEDCOUPLING_EXPORT int changeValue(int oldValue, int newValue); MEDCOUPLING_EXPORT int locateTuple(const std::vector& tupl) const; MEDCOUPLING_EXPORT int locateValue(int value) const; diff --git a/src/MEDCoupling/MEDCouplingPointSet.hxx b/src/MEDCoupling/MEDCouplingPointSet.hxx index 412d83c7b..aa5622b19 100644 --- a/src/MEDCoupling/MEDCouplingPointSet.hxx +++ b/src/MEDCoupling/MEDCouplingPointSet.hxx @@ -131,7 +131,7 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const; MEDCOUPLING_EXPORT void unserialization(const std::vector& tinyInfoD, const std::vector& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, const std::vector& littleStrings); - MEDCOUPLING_EXPORT virtual DataArrayDouble *getBoundingBoxForBBTree() const = 0; + MEDCOUPLING_EXPORT virtual DataArrayDouble *getBoundingBoxForBBTree(double arcDetEps=1e-12) const = 0; MEDCOUPLING_EXPORT virtual DataArrayInt *getCellsInBoundingBox(const double *bbox, double eps) const = 0; MEDCOUPLING_EXPORT virtual DataArrayInt *getCellsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bbox, double eps) = 0; MEDCOUPLING_EXPORT virtual DataArrayInt *zipCoordsTraducer(); diff --git a/src/MEDCoupling/MEDCouplingUMesh.cxx b/src/MEDCoupling/MEDCouplingUMesh.cxx index 44c34fd20..70e17c9c1 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.cxx +++ b/src/MEDCoupling/MEDCouplingUMesh.cxx @@ -419,12 +419,39 @@ MEDCouplingUMeshCellByTypeEntry *MEDCouplingUMesh::cellsByType() * Returns a set of all cell types available in \a this mesh. * \return std::set - the set of cell types. * \warning this method does not throw any exception even if \a this is not defined. + * \sa MEDCouplingUMesh::getAllGeoTypesSorted */ std::set MEDCouplingUMesh::getAllGeoTypes() const { return _types; } +/*! + * This method returns the sorted list of geometric types in \a this. + * Sorted means in the same order than the cells in \a this. A single entry in return vector means the maximal chunk of consecutive cells in \a this + * having the same geometric type. So a same geometric type can appear more than once if the cells are not sorted per geometric type. + * + * \throw if connectivity in \a this is not correctly defined. + * + * \sa MEDCouplingMesh::getAllGeoTypes + */ +std::vector MEDCouplingUMesh::getAllGeoTypesSorted() const +{ + std::vector ret; + checkConnectivityFullyDefined(); + int nbOfCells(getNumberOfCells()); + if(nbOfCells==0) + return ret; + if(getMeshLength()<1) + throw INTERP_KERNEL::Exception("MEDCouplingUMesh::getAllGeoTypesSorted : the connectivity in this seems invalid !"); + const int *c(_nodal_connec->begin()),*ci(_nodal_connec_index->begin()); + ret.push_back((INTERP_KERNEL::NormalizedCellType)c[*ci++]); + for(int i=1;i MEDCouplingUMesh::getTypesOfPart(const int *begin, const int *end) const { @@ -3994,6 +4021,9 @@ void MEDCouplingUMesh::DistanceToPoint2DCurveAlg(const double *pt, const int *ce /*! * Finds cells in contact with a ball (i.e. a point with precision). + * For speed reasons, the INTERP_KERNEL::NORM_QUAD4, INTERP_KERNEL::NORM_TRI6 and INTERP_KERNEL::NORM_QUAD8 cells are considered as convex cells to detect if a point is IN or OUT. + * If it is not the case, please change their types to INTERP_KERNEL::NORM_POLYGON or INTERP_KERNEL::NORM_QPOLYG before invoking this method. + * * \warning This method is suitable if the caller intends to evaluate only one * point, for more points getCellsContainingPoints() is recommended as it is * faster. @@ -4015,6 +4045,8 @@ int MEDCouplingUMesh::getCellContainingPoint(const double *pos, double eps) cons /*! * Finds cells in contact with a ball (i.e. a point with precision). + * For speed reasons, the INTERP_KERNEL::NORM_QUAD4, INTERP_KERNEL::NORM_TRI6 and INTERP_KERNEL::NORM_QUAD8 cells are considered as convex cells to detect if a point is IN or OUT. + * If it is not the case, please change their types to INTERP_KERNEL::NORM_POLYGON or INTERP_KERNEL::NORM_QPOLYG before invoking this method. * \warning This method is suitable if the caller intends to evaluate only one * point, for more points getCellsContainingPoints() is recommended as it is * faster. @@ -4172,7 +4204,7 @@ void MEDCouplingUMesh::getCellsContainingPointsAlg(const double *coords, const d { elts=DataArrayInt::New(); eltsIndex=DataArrayInt::New(); eltsIndex->alloc(nbOfPoints+1,1); eltsIndex->setIJ(0,0,0); elts->alloc(0,1); int *eltsIndexPtr(eltsIndex->getPointer()); - MEDCouplingAutoRefCountObjectPtr bboxArr(getBoundingBoxForBBTree()); + MEDCouplingAutoRefCountObjectPtr bboxArr(getBoundingBoxForBBTree(eps)); const double *bbox(bboxArr->begin()); int nbOfCells=getNumberOfCells(); const int *conn=_nodal_connec->getConstPointer(); @@ -4191,10 +4223,35 @@ void MEDCouplingUMesh::getCellsContainingPointsAlg(const double *coords, const d myTree.getIntersectingElems(bb,candidates); for(std::vector::const_iterator iter=candidates.begin();iter!=candidates.end();iter++) { - int sz=connI[(*iter)+1]-connI[*iter]-1; - if(INTERP_KERNEL::PointLocatorAlgos >::isElementContainsPoint(pos+i*SPACEDIM, - (INTERP_KERNEL::NormalizedCellType)conn[connI[*iter]], - coords,conn+connI[*iter]+1,sz,eps)) + int sz(connI[(*iter)+1]-connI[*iter]-1); + INTERP_KERNEL::NormalizedCellType ct((INTERP_KERNEL::NormalizedCellType)conn[connI[*iter]]); + bool status(false); + if(ct!=INTERP_KERNEL::NORM_POLYGON && ct!=INTERP_KERNEL::NORM_QPOLYG) + status=INTERP_KERNEL::PointLocatorAlgos >::isElementContainsPoint(pos+i*SPACEDIM,ct,coords,conn+connI[*iter]+1,sz,eps); + else + { + if(SPACEDIM!=2) + throw INTERP_KERNEL::Exception("MEDCouplingUMesh::getCellsContainingPointsAlg : not implemented yet for POLYGON and QPOLYGON in spaceDim 3 !"); + INTERP_KERNEL::QUADRATIC_PLANAR::_precision=eps; + INTERP_KERNEL::QUADRATIC_PLANAR::_arc_detection_precision=eps; + std::vector nodes(sz); + INTERP_KERNEL::QuadraticPolygon *pol(0); + for(int j=0;jnormalizeMe(b,c); n->applySimilarity(b,c,a); + status=pol->isInOrOut2(n); + delete pol; n->decrRef(); + } + if(status) { eltsIndexPtr[i+1]++; elts->pushBackSilent(*iter); @@ -4206,6 +4263,8 @@ void MEDCouplingUMesh::getCellsContainingPointsAlg(const double *coords, const d * Finds cells in contact with several balls (i.e. points with precision). * This method is an extension of getCellContainingPoint() and * getCellsContainingPoint() for the case of multiple points. + * For speed reasons, the INTERP_KERNEL::NORM_QUAD4, INTERP_KERNEL::NORM_TRI6 and INTERP_KERNEL::NORM_QUAD8 cells are considered as convex cells to detect if a point is IN or OUT. + * If it is not the case, please change their types to INTERP_KERNEL::NORM_POLYGON or INTERP_KERNEL::NORM_QPOLYG before invoking this method. * \param [in] pos - an array of coordinates of points in full interlace mode : * X0,Y0,Z0,X1,Y1,Z1,... Size of the array must be \a * this->getSpaceDimension() * \a nbOfPoints @@ -6202,12 +6261,45 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::getSkewField() const /*! * This method aggregate the bbox of each cell and put it into bbox parameter. * + * \param [in] arcDetEps - a parameter specifying in case of 2D quadratic polygon cell the detection limit between linear and arc circle. (By default 1e-12) + * For all other cases this input parameter is ignored. * \return DataArrayDouble * - newly created object (to be managed by the caller) \a this number of cells tuples and 2*spacedim components. * * \throw If \a this is not fully set (coordinates and connectivity). * \throw If a cell in \a this has no valid nodeId. + * \sa MEDCouplingUMesh::getBoundingBoxForBBTreeFast, MEDCouplingUMesh::getBoundingBoxForBBTree2DQuadratic */ -DataArrayDouble *MEDCouplingUMesh::getBoundingBoxForBBTree() const +DataArrayDouble *MEDCouplingUMesh::getBoundingBoxForBBTree(double arcDetEps) const +{ + int mDim(getMeshDimension()),sDim(getSpaceDimension()); + if(mDim!=2 || sDim!=2) + return getBoundingBoxForBBTreeFast(); + else + { + bool presenceOfQuadratic(false); + for(std::set::const_iterator it=_types.begin();it!=_types.end();it++) + { + const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(*it)); + if(cm.isQuadratic()) + presenceOfQuadratic=true; + } + if(presenceOfQuadratic) + return getBoundingBoxForBBTree2DQuadratic(arcDetEps); + else + return getBoundingBoxForBBTreeFast(); + } +} + +/*! + * This method aggregate the bbox of each cell only considering the nodes constituting each cell and put it into bbox parameter. + * So meshes having quadratic cells the computed bounding boxes can be invalid ! + * + * \return DataArrayDouble * - newly created object (to be managed by the caller) \a this number of cells tuples and 2*spacedim components. + * + * \throw If \a this is not fully set (coordinates and connectivity). + * \throw If a cell in \a this has no valid nodeId. + */ +DataArrayDouble *MEDCouplingUMesh::getBoundingBoxForBBTreeFast() const { checkFullyDefined(); int spaceDim(getSpaceDimension()),nbOfCells(getNumberOfCells()),nbOfNodes(getNumberOfNodes()); @@ -6246,6 +6338,48 @@ DataArrayDouble *MEDCouplingUMesh::getBoundingBoxForBBTree() const return ret.retn(); } +/*! + * This method aggregate the bbox regarding foreach 2D cell in \a this the whole shape. So this method is particulary useful for 2D meshes having quadratic cells + * because for this type of cells getBoundingBoxForBBTreeFast method may return invalid bounding boxes. + * + * \param [in] arcDetEps - a parameter specifying in case of 2D quadratic polygon cell the detection limit between linear and arc circle. (By default 1e-12) + * \return DataArrayDouble * - newly created object (to be managed by the caller) \a this number of cells tuples and 2*spacedim components. + * \throw If \a this is not fully defined. + * \throw If \a this is not a mesh with meshDimension equal to 2. + * \throw If \a this is not a mesh with spaceDimension equal to 2. + */ +DataArrayDouble *MEDCouplingUMesh::getBoundingBoxForBBTree2DQuadratic(double arcDetEps) const +{ + checkFullyDefined(); + int spaceDim(getSpaceDimension()),mDim(getMeshDimension()),nbOfCells(getNumberOfCells()),nbOfNodes(getNumberOfNodes()); + if(mDim!=2 || spaceDim!=2) + throw INTERP_KERNEL::Exception("MEDCouplingUMesh::getBoundingBoxForBBTree2DQuadratic : This method should be applied on mesh with mesh dimension equal to 2 and space dimension also equal to 2!"); + MEDCouplingAutoRefCountObjectPtr ret(DataArrayDouble::New()); ret->alloc(nbOfCells,2*spaceDim); + double *bbox(ret->getPointer()); + const double *coords(_coords->getConstPointer()); + const int *conn(_nodal_connec->getConstPointer()),*connI(_nodal_connec_index->getConstPointer()); + for(int i=0;i nodes(sz); + INTERP_KERNEL::QuadraticPolygon *pol(0); + for(int j=0;jfillBounds(b); delete pol; + bbox[0]=b.getXMin(); bbox[1]=b.getXMax(); bbox[2]=b.getYMin(); bbox[3]=b.getYMax(); + } + return ret.retn(); +} + /// @cond INTERNAL namespace ParaMEDMEMImpl @@ -6288,7 +6422,7 @@ std::vector MEDCouplingUMesh::getDistributionOfTypes() const const int *connI=_nodal_connec_index->getConstPointer(); const int *work=connI; int nbOfCells=getNumberOfCells(); - std::size_t n=getAllTypes().size(); + std::size_t n=getAllGeoTypes().size(); std::vector ret(3*n,-1); //ret[3*k+2]==-1 because it has no sense here std::set types; for(std::size_t i=0;work!=connI+nbOfCells;i++) @@ -6959,7 +7093,7 @@ DataArrayInt *MEDCouplingUMesh::convertCellArrayPerGeoType(const DataArrayInt *d const int *conn=_nodal_connec->getConstPointer(); const int *connI=_nodal_connec_index->getConstPointer(); int nbOfCells=getNumberOfCells(); - std::set types=getAllTypes(); + std::set types(getAllGeoTypes()); int *tmp=new int[nbOfCells]; for(std::set::const_iterator iter=types.begin();iter!=types.end();iter++) { @@ -8150,7 +8284,7 @@ void MEDCouplingUMesh::writeVTKLL(std::ostream& ofs, const std::string& cellData int nbOfCells=getNumberOfCells(); if(nbOfCells<=0) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::writeVTK : the unstructured mesh has no cells !"); - static const int PARAMEDMEM2VTKTYPETRADUCER[INTERP_KERNEL::NORM_MAXTYPE+1]={1,3,21,5,9,7,22,34,23,28,-1,-1,-1,-1,10,14,13,-1,12,-1,24,-1,16,27,-1,26,-1,29,-1,-1,25,42,-1,4}; + static const int PARAMEDMEM2VTKTYPETRADUCER[INTERP_KERNEL::NORM_MAXTYPE+1]={1,3,21,5,9,7,22,34,23,28,-1,-1,-1,-1,10,14,13,-1,12,-1,24,-1,16,27,-1,26,-1,29,-1,-1,25,42,36,4}; ofs << " <" << getVTKDataSetType() << ">\n"; ofs << " \n"; ofs << " \n" << pointData << std::endl; diff --git a/src/MEDCoupling/MEDCouplingUMesh.hxx b/src/MEDCoupling/MEDCouplingUMesh.hxx index fea05ddee..56eb0193a 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.hxx +++ b/src/MEDCoupling/MEDCouplingUMesh.hxx @@ -61,8 +61,8 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT void finishInsertingCells(); MEDCOUPLING_EXPORT MEDCouplingUMeshCellIterator *cellIterator(); MEDCOUPLING_EXPORT MEDCouplingUMeshCellByTypeEntry *cellsByType(); - MEDCOUPLING_EXPORT const std::set& getAllTypes() const { return _types; } MEDCOUPLING_EXPORT std::set getAllGeoTypes() const; + MEDCOUPLING_EXPORT std::vector getAllGeoTypesSorted() const; MEDCOUPLING_EXPORT std::set getTypesOfPart(const int *begin, const int *end) const; MEDCOUPLING_EXPORT void setConnectivity(DataArrayInt *conn, DataArrayInt *connIndex, bool isComputingTypes=true); MEDCOUPLING_EXPORT const DataArrayInt *getNodalConnectivity() const { return _nodal_connec; } @@ -164,7 +164,9 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT DataArrayInt *convexEnvelop2D(); MEDCOUPLING_EXPORT DataArrayInt *findAndCorrectBadOriented3DExtrudedCells(); MEDCOUPLING_EXPORT DataArrayInt *findAndCorrectBadOriented3DCells(); - MEDCOUPLING_EXPORT DataArrayDouble *getBoundingBoxForBBTree() const; + MEDCOUPLING_EXPORT DataArrayDouble *getBoundingBoxForBBTree(double arcDetEps=1e-12) const; + MEDCOUPLING_EXPORT DataArrayDouble *getBoundingBoxForBBTreeFast() const; + MEDCOUPLING_EXPORT DataArrayDouble *getBoundingBoxForBBTree2DQuadratic(double arcDetEps=1e-12) const; MEDCOUPLING_EXPORT MEDCouplingUMesh *buildExtrudedMesh(const MEDCouplingUMesh *mesh1D, int policy); MEDCOUPLING_EXPORT bool isFullyQuadratic() const; MEDCOUPLING_EXPORT bool isPresenceOfQuadratic() const; diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest1.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest1.cxx index fc06ef5a3..9f05e9a11 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest1.cxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest1.cxx @@ -591,11 +591,11 @@ void MEDCouplingBasicsTest1::testBuildPartOfMySelf() MEDCouplingUMesh *subMesh=dynamic_cast(subMeshSimple); CPPUNIT_ASSERT(subMesh); std::string name(subMesh->getName()); - CPPUNIT_ASSERT_EQUAL(2,(int)mesh->getAllTypes().size()); - CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,*mesh->getAllTypes().begin()); - CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_QUAD4,*(++(mesh->getAllTypes().begin()))); - CPPUNIT_ASSERT_EQUAL(1,(int)subMesh->getAllTypes().size()); - CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_QUAD4,*subMesh->getAllTypes().begin()); + CPPUNIT_ASSERT_EQUAL(2,(int)mesh->getAllGeoTypes().size()); + CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,*mesh->getAllGeoTypes().begin()); + CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_QUAD4,*(++(mesh->getAllGeoTypes().begin()))); + CPPUNIT_ASSERT_EQUAL(1,(int)subMesh->getAllGeoTypes().size()); + CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_QUAD4,*subMesh->getAllGeoTypes().begin()); CPPUNIT_ASSERT(name=="Toto"); CPPUNIT_ASSERT(mesh->getCoords()==subMesh->getCoords()); CPPUNIT_ASSERT_EQUAL(2,subMesh->getNumberOfCells()); @@ -611,9 +611,9 @@ void MEDCouplingBasicsTest1::testBuildPartOfMySelf() subMesh=dynamic_cast(subMeshSimple); CPPUNIT_ASSERT(subMesh); name=subMesh->getName(); - CPPUNIT_ASSERT_EQUAL(2,(int)subMesh->getAllTypes().size()); - CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,*subMesh->getAllTypes().begin()); - CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_QUAD4,*(++(subMesh->getAllTypes().begin()))); + CPPUNIT_ASSERT_EQUAL(2,(int)subMesh->getAllGeoTypes().size()); + CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,*subMesh->getAllGeoTypes().begin()); + CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_QUAD4,*(++(subMesh->getAllGeoTypes().begin()))); CPPUNIT_ASSERT(name=="Toto"); CPPUNIT_ASSERT(mesh->getCoords()==subMesh->getCoords()); CPPUNIT_ASSERT_EQUAL(3,subMesh->getNumberOfCells()); @@ -640,8 +640,8 @@ void MEDCouplingBasicsTest1::testBuildPartOfMySelfNode() MEDCouplingPointSet *subMeshSimple=mesh->buildPartOfMySelfNode(tab1,tab1+4,true); MEDCouplingUMesh *subMesh=dynamic_cast(subMeshSimple); CPPUNIT_ASSERT(subMesh); - CPPUNIT_ASSERT_EQUAL(1,(int)subMesh->getAllTypes().size()); - CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_QUAD4,*subMesh->getAllTypes().begin()); + CPPUNIT_ASSERT_EQUAL(1,(int)subMesh->getAllGeoTypes().size()); + CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_QUAD4,*subMesh->getAllGeoTypes().begin()); CPPUNIT_ASSERT_EQUAL(1,subMesh->getNumberOfCells()); CPPUNIT_ASSERT_EQUAL((std::size_t)5,subMesh->getNodalConnectivity()->getNbOfElems()); CPPUNIT_ASSERT_EQUAL((std::size_t)2,subMesh->getNodalConnectivityIndex()->getNbOfElems()); @@ -655,9 +655,9 @@ void MEDCouplingBasicsTest1::testBuildPartOfMySelfNode() subMeshSimple=mesh->buildPartOfMySelfNode(tab1,tab1+2,false); subMesh=dynamic_cast(subMeshSimple); CPPUNIT_ASSERT(subMesh); - CPPUNIT_ASSERT_EQUAL(2,(int)subMesh->getAllTypes().size()); - CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,*subMesh->getAllTypes().begin()); - CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_QUAD4,*(++subMesh->getAllTypes().begin())); + CPPUNIT_ASSERT_EQUAL(2,(int)subMesh->getAllGeoTypes().size()); + CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,*subMesh->getAllGeoTypes().begin()); + CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_QUAD4,*(++subMesh->getAllGeoTypes().begin())); CPPUNIT_ASSERT_EQUAL(3,subMesh->getNumberOfCells()); CPPUNIT_ASSERT_EQUAL((std::size_t)14,subMesh->getNodalConnectivity()->getNbOfElems()); CPPUNIT_ASSERT_EQUAL((std::size_t)4,subMesh->getNodalConnectivityIndex()->getNbOfElems()); @@ -672,9 +672,9 @@ void MEDCouplingBasicsTest1::testBuildPartOfMySelfNode() subMeshSimple=mesh->buildPartOfMySelfNode(tab2,tab2+7,true); subMesh=dynamic_cast(subMeshSimple); CPPUNIT_ASSERT(subMesh); - CPPUNIT_ASSERT_EQUAL(2,(int)subMesh->getAllTypes().size()); - CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,*subMesh->getAllTypes().begin()); - CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_QUAD4,*(++subMesh->getAllTypes().begin())); + CPPUNIT_ASSERT_EQUAL(2,(int)subMesh->getAllGeoTypes().size()); + CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,*subMesh->getAllGeoTypes().begin()); + CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_QUAD4,*(++subMesh->getAllGeoTypes().begin())); CPPUNIT_ASSERT_EQUAL(3,subMesh->getNumberOfCells()); subMeshSimple->decrRef(); // @@ -684,7 +684,7 @@ void MEDCouplingBasicsTest1::testBuildPartOfMySelfNode() void MEDCouplingBasicsTest1::testZipCoords() { MEDCouplingUMesh *mesh=build2DTargetMesh_1(); - CPPUNIT_ASSERT_EQUAL(2,(int)mesh->getAllTypes().size()); + CPPUNIT_ASSERT_EQUAL(2,(int)mesh->getAllGeoTypes().size()); CPPUNIT_ASSERT_EQUAL(2,mesh->getSpaceDimension()); CPPUNIT_ASSERT_EQUAL(9,mesh->getNumberOfNodes()); CPPUNIT_ASSERT_EQUAL(5,mesh->getNumberOfCells()); @@ -695,7 +695,7 @@ void MEDCouplingBasicsTest1::testZipCoords() DataArrayDouble *oldCoords=mesh->getCoords(); oldCoords->incrRef(); mesh->zipCoords(); - CPPUNIT_ASSERT_EQUAL(2,(int)mesh->getAllTypes().size()); + CPPUNIT_ASSERT_EQUAL(2,(int)mesh->getAllGeoTypes().size()); CPPUNIT_ASSERT_EQUAL(2,mesh->getSpaceDimension()); CPPUNIT_ASSERT_EQUAL(9,mesh->getNumberOfNodes()); CPPUNIT_ASSERT_EQUAL(5,mesh->getNumberOfCells()); @@ -713,7 +713,7 @@ void MEDCouplingBasicsTest1::testZipCoords() const int expectedTraducer[9]={0,1,-1,2,3,4,-1,5,6}; CPPUNIT_ASSERT(std::equal(expectedTraducer,expectedTraducer+9,traducer->getPointer())); traducer->decrRef(); - CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_QUAD4,*subMesh->getAllTypes().begin()); + CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_QUAD4,*subMesh->getAllGeoTypes().begin()); CPPUNIT_ASSERT_EQUAL(2,subMesh->getNumberOfCells()); const int subConn[10]={4,0,2,3,1,4,5,6,4,3}; const int subConnIndex[3]={0,5,10}; @@ -727,7 +727,7 @@ void MEDCouplingBasicsTest1::testZipCoords() subMeshPtSet=mesh->buildPartOfMySelf(tab1,tab1+2,false); subMesh=dynamic_cast(subMeshPtSet); CPPUNIT_ASSERT(subMesh); - CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_QUAD4,*subMesh->getAllTypes().begin()); + CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_QUAD4,*subMesh->getAllGeoTypes().begin()); CPPUNIT_ASSERT_EQUAL(2,subMesh->getNumberOfCells()); CPPUNIT_ASSERT_EQUAL(7,subMesh->getNumberOfNodes()); CPPUNIT_ASSERT_EQUAL((std::size_t)10,subMesh->getNodalConnectivity()->getNbOfElems()); diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest2.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest2.cxx index d1482a268..79b232f4a 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest2.cxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest2.cxx @@ -747,7 +747,7 @@ void MEDCouplingBasicsTest2::testConvertQuadraticCellsToLinear() { MEDCouplingUMesh *mesh=build2DTargetMesh_3(); mesh->checkCoherency(); - const std::set& types=mesh->getAllTypes(); + std::set types=mesh->getAllGeoTypes(); CPPUNIT_ASSERT_EQUAL(5,(int)types.size()); INTERP_KERNEL::NormalizedCellType expected1[5]={INTERP_KERNEL::NORM_POLYGON, INTERP_KERNEL::NORM_TRI3, INTERP_KERNEL::NORM_QUAD4, INTERP_KERNEL::NORM_TRI6, INTERP_KERNEL::NORM_QUAD8}; std::set expected1Bis(expected1,expected1+5); @@ -763,8 +763,8 @@ void MEDCouplingBasicsTest2::testConvertQuadraticCellsToLinear() MEDCouplingFieldDouble *f2=mesh->getMeasureField(false); CPPUNIT_ASSERT(f1->getArray()->isEqual(*f2->getArray(),1e-12)); CPPUNIT_ASSERT_EQUAL(48,mesh->getMeshLength()); - const std::set& types2=mesh->getAllTypes(); - CPPUNIT_ASSERT_EQUAL(3,(int)types.size()); + std::set types2=mesh->getAllGeoTypes(); + CPPUNIT_ASSERT_EQUAL(3,(int)types2.size()); INTERP_KERNEL::NormalizedCellType expected2[3]={INTERP_KERNEL::NORM_POLYGON, INTERP_KERNEL::NORM_TRI3, INTERP_KERNEL::NORM_QUAD4}; std::set expected2Bis(expected2,expected2+3); CPPUNIT_ASSERT(expected2Bis==types2); diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest3.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest3.cxx index 762f4709c..a7db7454e 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest3.cxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest3.cxx @@ -1573,7 +1573,7 @@ void MEDCouplingBasicsTest3::testSimplexize1() MEDCouplingFieldDouble *f=m->getMeasureField(false); for(int i=0;i<7;i++) CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i]*sqrt(2.),f->getIJ(i,0),1e-10); - std::set types=m->getAllTypes(); + std::set types=m->getAllGeoTypes(); 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()))); @@ -1590,7 +1590,7 @@ void MEDCouplingBasicsTest3::testSimplexize1() for(int i=0;i<7;i++) CPPUNIT_ASSERT_EQUAL(expected2[i],da->getIJ(i,0)); m->checkCoherency(); - types=m->getAllTypes(); + types=m->getAllGeoTypes(); 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()))); @@ -2449,7 +2449,7 @@ void MEDCouplingBasicsTest3::testBuild0DMeshFromCoords1() CPPUNIT_ASSERT_EQUAL(4,m->getNumberOfCells()); CPPUNIT_ASSERT_EQUAL(3,m->getSpaceDimension()); CPPUNIT_ASSERT_EQUAL(0,m->getMeshDimension()); - const std::set& types=m->getAllTypes(); + std::set types=m->getAllGeoTypes(); CPPUNIT_ASSERT_EQUAL(1,(int)types.size()); CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_POINT1,*types.begin()); for(int i=0;i<4;i++) diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest5.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest5.cxx index 85da2ecce..fb039d015 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest5.cxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest5.cxx @@ -1403,7 +1403,7 @@ void MEDCouplingBasicsTest5::testUMeshSetPartOfMySelf2() // resize with explicit ids list MEDCouplingUMesh *m=build2DTargetMesh_1(); std::set s; s.insert(INTERP_KERNEL::NORM_TRI3); s.insert(INTERP_KERNEL::NORM_QUAD4); - CPPUNIT_ASSERT(s==m->getAllTypes()); + CPPUNIT_ASSERT(s==m->getAllGeoTypes()); const int ids1[3]={0,3,4}; MEDCouplingUMesh *part=static_cast(m->buildPartOfMySelf(ids1,ids1+3,true)); part->simplexize(0)->decrRef(); @@ -1417,7 +1417,7 @@ void MEDCouplingBasicsTest5::testUMeshSetPartOfMySelf2() CPPUNIT_ASSERT(std::equal(expected2,expected2+6,m->getNodalConnectivityIndex()->getConstPointer())); CPPUNIT_ASSERT_EQUAL((std::size_t)6,m->getNodalConnectivityIndex()->getNbOfElems()); s.clear(); s.insert(INTERP_KERNEL::NORM_TRI3); - CPPUNIT_ASSERT(s==m->getAllTypes()); + CPPUNIT_ASSERT(s==m->getAllGeoTypes()); m->decrRef(); part->decrRef(); part2->decrRef(); // no resize with explicit ids list m=build2DTargetMesh_1(); @@ -1431,7 +1431,7 @@ void MEDCouplingBasicsTest5::testUMeshSetPartOfMySelf2() CPPUNIT_ASSERT(std::equal(expected4,expected4+6,m->getNodalConnectivityIndex()->getConstPointer())); CPPUNIT_ASSERT_EQUAL((std::size_t)6,m->getNodalConnectivityIndex()->getNbOfElems()); s.clear(); s.insert(INTERP_KERNEL::NORM_TRI3); s.insert(INTERP_KERNEL::NORM_QUAD4); s.insert(INTERP_KERNEL::NORM_POLYGON); - CPPUNIT_ASSERT(s==m->getAllTypes()); + CPPUNIT_ASSERT(s==m->getAllGeoTypes()); m->decrRef(); part->decrRef(); // resize with range ids m=build2DTargetMesh_1(); @@ -1444,7 +1444,7 @@ void MEDCouplingBasicsTest5::testUMeshSetPartOfMySelf2() CPPUNIT_ASSERT(std::equal(expected6,expected6+6,m->getNodalConnectivityIndex()->getConstPointer())); CPPUNIT_ASSERT_EQUAL((std::size_t)6,m->getNodalConnectivityIndex()->getNbOfElems()); s.clear(); s.insert(INTERP_KERNEL::NORM_QUAD4); - CPPUNIT_ASSERT(s==m->getAllTypes()); + CPPUNIT_ASSERT(s==m->getAllGeoTypes()); m->decrRef(); part->decrRef(); // no resize with range ids m=build2DTargetMesh_1(); @@ -1458,7 +1458,7 @@ void MEDCouplingBasicsTest5::testUMeshSetPartOfMySelf2() CPPUNIT_ASSERT(std::equal(expected8,expected8+6,m->getNodalConnectivityIndex()->getConstPointer())); CPPUNIT_ASSERT_EQUAL((std::size_t)6,m->getNodalConnectivityIndex()->getNbOfElems()); s.clear(); s.insert(INTERP_KERNEL::NORM_TRI3); s.insert(INTERP_KERNEL::NORM_QUAD4); s.insert(INTERP_KERNEL::NORM_POLYGON); - CPPUNIT_ASSERT(s==m->getAllTypes()); + CPPUNIT_ASSERT(s==m->getAllGeoTypes()); m->decrRef(); part->decrRef(); // no resize with range ids negative direction m=build2DTargetMesh_1(); @@ -1472,7 +1472,7 @@ s.clear(); s.insert(INTERP_KERNEL::NORM_TRI3); s.insert(INTERP_KERNEL::NORM_QUAD CPPUNIT_ASSERT(std::equal(expected10,expected10+6,m->getNodalConnectivityIndex()->getConstPointer())); CPPUNIT_ASSERT_EQUAL((std::size_t)6,m->getNodalConnectivityIndex()->getNbOfElems()); s.clear(); s.insert(INTERP_KERNEL::NORM_TRI3); s.insert(INTERP_KERNEL::NORM_QUAD4); s.insert(INTERP_KERNEL::NORM_POLYGON); - CPPUNIT_ASSERT(s==m->getAllTypes()); + CPPUNIT_ASSERT(s==m->getAllGeoTypes()); part->decrRef(); m->decrRef(); } @@ -1500,7 +1500,7 @@ void MEDCouplingBasicsTest5::testUnPolyze3() m->unPolyze(); CPPUNIT_ASSERT_EQUAL(1,m->getNumberOfCells()); std::set s; s.insert(INTERP_KERNEL::NORM_PENTA6); - CPPUNIT_ASSERT(s==m->getAllTypes()); + CPPUNIT_ASSERT(s==m->getAllGeoTypes()); // const int expected1[2]={0,7}; const int expected2[7]={16,0,2,1,3,5,4}; diff --git a/src/MEDCoupling_Swig/CMakeLists.txt b/src/MEDCoupling_Swig/CMakeLists.txt index d136337d2..29b0934aa 100644 --- a/src/MEDCoupling_Swig/CMakeLists.txt +++ b/src/MEDCoupling_Swig/CMakeLists.txt @@ -78,13 +78,16 @@ INSTALL(FILES MEDCoupling.i MEDCouplingCommon.i MEDCouplingRefCountObject.i MEDC INSTALL(FILES MEDCouplingBasicsTest.py MEDCouplingRemapperTest.py MEDCouplingDataForTest.py MEDCouplingNumPyTest.py DESTINATION ${SALOME_INSTALL_SCRIPT_PYTHON}) INSTALL(FILES MEDCouplingExamplesTest.py DESTINATION ${SALOME_INSTALL_SCRIPT_PYTHON}) +SALOME_GENERATE_TESTS_ENVIRONMENT(tests_env) + ADD_TEST(MEDCouplingBasicsTest ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/MEDCouplingBasicsTest.py) +SET_TESTS_PROPERTIES(MEDCouplingBasicsTest PROPERTIES ENVIRONMENT "${tests_env}") ADD_TEST(MEDCouplingExamplesTest ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/MEDCouplingExamplesTest.py) +SET_TESTS_PROPERTIES(MEDCouplingExamplesTest PROPERTIES ENVIRONMENT "${tests_env}") ADD_TEST(MEDCouplingRemapperTest ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/MEDCouplingRemapperTest.py) -SET_TESTS_PROPERTIES(MEDCouplingBasicsTest MEDCouplingExamplesTest MEDCouplingRemapperTest - PROPERTIES ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_LIBS}:$ENV{LD_LIBRARY_PATH}") +SET_TESTS_PROPERTIES(MEDCouplingRemapperTest PROPERTIES ENVIRONMENT "${tests_env}") + IF(NUMPY_FOUND) ADD_TEST(MEDCouplingNumPyTest ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/MEDCouplingNumPyTest.py) - SET_TESTS_PROPERTIES(MEDCouplingNumPyTest - PROPERTIES ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_LIBS}:$ENV{LD_LIBRARY_PATH}") + SET_TESTS_PROPERTIES(MEDCouplingNumPyTest PROPERTIES ENVIRONMENT "${tests_env}") ENDIF(NUMPY_FOUND) diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py index 18ae38854..f4e4e111b 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py @@ -123,7 +123,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): self.assertTrue(myCoords.getIJ(3,2)==-0.305) mesh.setCoords(myCoords); mesh.checkCoherency(); - self.assertTrue(mesh.getAllTypes()==[4]) + self.assertTrue(mesh.getAllGeoTypes()==[4]) myFalseConn=DataArrayInt.New() myFalseConn.setValues(tab4,6,4) self.assertTrue(myFalseConn.getIJ(1,1)==3) @@ -385,11 +385,11 @@ class MEDCouplingBasicsTest(unittest.TestCase): subMesh=mesh.buildPartOfMySelf(tab1,True); self.assertTrue(isinstance(subMesh,MEDCouplingUMesh)) name=subMesh.getName(); - self.assertEqual(2,len(mesh.getAllTypes())); - self.assertEqual(NORM_TRI3,mesh.getAllTypes()[0]); - self.assertEqual(NORM_QUAD4,mesh.getAllTypes()[1]); - self.assertEqual(1,len(subMesh.getAllTypes())); - self.assertEqual(NORM_QUAD4,subMesh.getAllTypes()[0]); + self.assertEqual(2,len(mesh.getAllGeoTypes())); + self.assertEqual(NORM_TRI3,mesh.getAllGeoTypes()[0]); + self.assertEqual(NORM_QUAD4,mesh.getAllGeoTypes()[1]); + self.assertEqual(1,len(subMesh.getAllGeoTypes())); + self.assertEqual(NORM_QUAD4,subMesh.getAllGeoTypes()[0]); self.assertEqual(name,"Toto"); self.assertEqual(2,subMesh.getNumberOfCells()); subConn=[4,0,3,4,1,4,7,8,5,4]; @@ -402,9 +402,9 @@ class MEDCouplingBasicsTest(unittest.TestCase): subMesh=mesh.buildPartOfMySelf(tab2[0:3],True); self.assertTrue(isinstance(subMesh,MEDCouplingUMesh)); name=subMesh.getName(); - self.assertEqual(2,len(subMesh.getAllTypes())); - self.assertEqual(NORM_TRI3,subMesh.getAllTypes()[0]); - self.assertEqual(NORM_QUAD4,subMesh.getAllTypes()[1]); + self.assertEqual(2,len(subMesh.getAllGeoTypes())); + self.assertEqual(NORM_TRI3,subMesh.getAllGeoTypes()[0]); + self.assertEqual(NORM_QUAD4,subMesh.getAllGeoTypes()[1]); self.assertEqual(name,"Toto"); self.assertEqual(3,subMesh.getNumberOfCells()); subConn2=[4,0,3,4,1,3,4,5,2,4,6,7,4,3] @@ -426,8 +426,8 @@ class MEDCouplingBasicsTest(unittest.TestCase): tab1=[5,7,8,4] subMesh=mesh.buildPartOfMySelfNode(tab1[0:4],True); self.assertTrue(isinstance(subMesh,MEDCouplingUMesh)) - self.assertEqual(1,len(subMesh.getAllTypes())); - self.assertEqual(NORM_QUAD4,subMesh.getAllTypes()[0]); + self.assertEqual(1,len(subMesh.getAllGeoTypes())); + self.assertEqual(NORM_QUAD4,subMesh.getAllGeoTypes()[0]); self.assertEqual(1,subMesh.getNumberOfCells()); self.assertEqual(5,subMesh.getNodalConnectivity().getNbOfElems()); self.assertEqual(2,subMesh.getNodalConnectivityIndex().getNbOfElems()); @@ -442,9 +442,9 @@ class MEDCouplingBasicsTest(unittest.TestCase): 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]); - self.assertEqual(NORM_QUAD4,subMesh.getAllTypes()[1]); + self.assertEqual(2,len(subMesh.getAllGeoTypes())); + self.assertEqual(NORM_TRI3,subMesh.getAllGeoTypes()[0]); + self.assertEqual(NORM_QUAD4,subMesh.getAllGeoTypes()[1]); self.assertEqual(3,subMesh.getNumberOfCells()); self.assertEqual(14,subMesh.getNodalConnectivity().getNbOfElems()); self.assertEqual(4,subMesh.getNodalConnectivityIndex().getNbOfElems()); @@ -456,15 +456,15 @@ class MEDCouplingBasicsTest(unittest.TestCase): tab2=[0,3,2,1,4,5,6] subMesh=mesh.buildPartOfMySelfNode(tab2[0:7],True); self.assertTrue(isinstance(subMesh,MEDCouplingUMesh)) - self.assertEqual(2,len(subMesh.getAllTypes())); - self.assertEqual(NORM_TRI3,subMesh.getAllTypes()[0]); - self.assertEqual(NORM_QUAD4,subMesh.getAllTypes()[1]); + self.assertEqual(2,len(subMesh.getAllGeoTypes())); + self.assertEqual(NORM_TRI3,subMesh.getAllGeoTypes()[0]); + self.assertEqual(NORM_QUAD4,subMesh.getAllGeoTypes()[1]); self.assertEqual(3,subMesh.getNumberOfCells()); pass def testZipCoords(self): mesh=MEDCouplingDataForTest.build2DTargetMesh_1(); - self.assertEqual(2,len(mesh.getAllTypes())); + self.assertEqual(2,len(mesh.getAllGeoTypes())); self.assertEqual(2,mesh.getSpaceDimension()); self.assertEqual(9,mesh.getNumberOfNodes()); self.assertEqual(5,mesh.getNumberOfCells()); @@ -472,7 +472,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): oldConnIndex=mesh.getNodalConnectivityIndex().getValues()[0:mesh.getNumberOfCells()+1] oldCoords=mesh.getCoords(); mesh.zipCoords(); - self.assertEqual(2,len(mesh.getAllTypes())); + self.assertEqual(2,len(mesh.getAllGeoTypes())); self.assertEqual(2,mesh.getSpaceDimension()); self.assertEqual(9,mesh.getNumberOfNodes()); self.assertEqual(5,mesh.getNumberOfCells()); @@ -486,7 +486,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): traducer=subMesh.zipCoordsTraducer(); expectedTraducer=[0, 1, -1, 2, 3, 4, -1, 5, 6] self.assertEqual(expectedTraducer,list(traducer.getValues())); - self.assertEqual(NORM_QUAD4,subMesh.getAllTypes()[0]); + self.assertEqual(NORM_QUAD4,subMesh.getAllGeoTypes()[0]); self.assertEqual(2,subMesh.getNumberOfCells()); subConn=[4,0,2,3,1,4,5,6,4,3] subConnIndex=[0,5,10] @@ -498,7 +498,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): # subMesh=mesh.buildPartOfMySelf(tab1,False); self.assertTrue(isinstance(subMesh,MEDCouplingUMesh)) - self.assertEqual(NORM_QUAD4,subMesh.getAllTypes()[0]); + self.assertEqual(NORM_QUAD4,subMesh.getAllGeoTypes()[0]); self.assertEqual(2,subMesh.getNumberOfCells()); self.assertEqual(7,subMesh.getNumberOfNodes()); self.assertEqual(10,subMesh.getNodalConnectivity().getNbOfElems()); @@ -2619,7 +2619,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): def testConvertQuadraticCellsToLinear(self): mesh=MEDCouplingDataForTest.build2DTargetMesh_3(); mesh.checkCoherency(); - types=mesh.getAllTypes(); + types=mesh.getAllGeoTypes(); types.sort() self.assertEqual(5,len(types)); expected1=[NORM_POLYGON, NORM_TRI3, NORM_QUAD4, NORM_TRI6, NORM_QUAD8] @@ -2636,7 +2636,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): f2=mesh.getMeasureField(False); self.assertTrue(f1.getArray().isEqual(f2.getArray(),1e-12)); self.assertEqual(48,mesh.getMeshLength()); - types2=mesh.getAllTypes(); + types2=mesh.getAllGeoTypes(); types2.sort() self.assertEqual(3,len(types2)); expected2=[NORM_POLYGON, NORM_TRI3, NORM_QUAD4] @@ -5195,7 +5195,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): for i in xrange(7): self.assertAlmostEqual(expected1[i]*sqrt(2.),f.getIJ(i,0),10); pass - types=m.getAllTypes(); + types=m.getAllGeoTypes(); self.assertEqual([NORM_TRI3,NORM_POLYGON],types); # m=MEDCouplingDataForTest.build3DSurfTargetMesh_1(); @@ -5207,7 +5207,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): self.assertEqual(expected2[i],da.getIJ(i,0)); pass m.checkCoherency(); - types=m.getAllTypes(); + types=m.getAllGeoTypes(); self.assertEqual([NORM_TRI3,NORM_POLYGON],types); self.assertEqual(7,m.getNumberOfCells()); self.assertEqual(NORM_TRI3,m.getTypeOfCell(0)); @@ -6630,7 +6630,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): self.assertEqual(4,m.getNumberOfCells()); self.assertEqual(3,m.getSpaceDimension()); self.assertEqual(0,m.getMeshDimension()); - types1=m.getAllTypes(); + types1=m.getAllGeoTypes(); self.assertEqual([NORM_POINT1],types1); for i in xrange(4): conn=m.getNodeIdsOfCell(i); @@ -10150,14 +10150,14 @@ class MEDCouplingBasicsTest(unittest.TestCase): def testUMeshSetPartOfMySelf2(self): # resize with explicit ids list m=MEDCouplingDataForTest.build2DTargetMesh_1() - self.assertEqual([3,4],m.getAllTypes()) + self.assertEqual([3,4],m.getAllGeoTypes()) part=m[[0,3,4]] part.simplexize(0) part2=part[[1,2,5]] m[[0,3,4]]=part2 self.assertEqual([3,0,4,1,3,1,4,2,3,4,5,2,3,6,7,4,3,7,5,4],m.getNodalConnectivity().getValues()) self.assertEqual([0,4,8,12,16,20],m.getNodalConnectivityIndex().getValues()) - self.assertEqual([3],m.getAllTypes()) + self.assertEqual([3],m.getAllGeoTypes()) # no resize with explicit ids list m=MEDCouplingDataForTest.build2DTargetMesh_1() part=m[[0,3]] @@ -10165,14 +10165,14 @@ class MEDCouplingBasicsTest(unittest.TestCase): m[[3,4]]=part self.assertEqual([4,0,3,4,1,3,1,4,2,3,4,5,2,5,0,3,4,1,5,6,7,4,3],m.getNodalConnectivity().getValues()) self.assertEqual([0,5,9,13,18,23],m.getNodalConnectivityIndex().getValues()) - self.assertEqual([3,4,5],m.getAllTypes()) + self.assertEqual([3,4,5],m.getAllGeoTypes()) # resize with range ids m=MEDCouplingDataForTest.build2DTargetMesh_1() part=m[3:] m[1:3]=part self.assertEqual([4,0,3,4,1,4,6,7,4,3,4,7,8,5,4,4,6,7,4,3,4,7,8,5,4],m.getNodalConnectivity().getValues()) self.assertEqual([0,5,10,15,20,25],m.getNodalConnectivityIndex().getValues()) - self.assertEqual([4],m.getAllTypes()) + self.assertEqual([4],m.getAllGeoTypes()) # no resize with range ids m=MEDCouplingDataForTest.build2DTargetMesh_1() part=m[0::3] @@ -10180,7 +10180,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): m[3:]=part self.assertEqual([4,0,3,4,1,3,1,4,2,3,4,5,2,5,0,3,4,1,5,6,7,4,3],m.getNodalConnectivity().getValues()) self.assertEqual([0,5,9,13,18,23],m.getNodalConnectivityIndex().getValues()) - self.assertEqual([3,4,5],m.getAllTypes()) + self.assertEqual([3,4,5],m.getAllGeoTypes()) # no resize with range ids negative direction m=MEDCouplingDataForTest.build2DTargetMesh_1() part=m[3::-3] @@ -10188,7 +10188,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): m[:-3:-1]=part self.assertEqual([4,0,3,4,1,3,1,4,2,3,4,5,2,5,0,3,4,1,5,6,7,4,3],m.getNodalConnectivity().getValues()) self.assertEqual([0,5,9,13,18,23],m.getNodalConnectivityIndex().getValues()) - self.assertEqual([3,4,5],m.getAllTypes()) + self.assertEqual([3,4,5],m.getAllGeoTypes()) pass def testUnPolyze3(self): @@ -10208,7 +10208,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): # m.unPolyze(); # - self.assertEqual([NORM_PENTA6],m.getAllTypes()) + self.assertEqual([NORM_PENTA6],m.getAllGeoTypes()) self.assertTrue(DataArrayInt([0,7]).isEqual(m.getNodalConnectivityIndex())) self.assertTrue(DataArrayInt([16,0,2,1,3,5,4]).isEqual(m.getNodalConnectivity())) # @@ -11046,9 +11046,13 @@ class MEDCouplingBasicsTest(unittest.TestCase): m=MEDCouplingUMesh("toto",3) m.allocateCells(0) m.insertNextCell(NORM_TETRA4,[0,1,2,3]) + self.assertEqual([NORM_TETRA4],m.getAllGeoTypesSorted()) m.insertNextCell(NORM_HEXA8,[4,5,6,7,8,9,10,11]) + self.assertEqual([NORM_TETRA4,NORM_HEXA8],m.getAllGeoTypesSorted()) m.insertNextCell(NORM_HEXA8,[12,13,14,15,16,17,18,19]) + self.assertEqual([NORM_TETRA4,NORM_HEXA8],m.getAllGeoTypesSorted()) m.insertNextCell(NORM_TETRA4,[20,21,22,23]) + self.assertEqual([NORM_TETRA4,NORM_HEXA8,NORM_TETRA4],m.getAllGeoTypesSorted()) c1=DataArrayDouble([0.,0.,0.,0.,1.,0.,1.,0.,0.,0.,0.,1.],4,3) c2=DataArrayDouble([0.,0.,0.,0.,1.,0.,1.,1.,0.,1.,0.,0., 0.,0.,1.,0.,1.,1.,1.,1.,1.,1.,0.,1.],8,3) ; c2+=[2.,0.,0.] c3=c2+[2.,0.,0.] @@ -11884,7 +11888,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): m.getNodalConnectivity().setIJ(87,0,21)# put again 21 as at the beginning # self.assertTrue(m.unPolyze()) - self.assertEqual([NORM_HEXGP12],m.getAllTypes()) + self.assertEqual([NORM_HEXGP12],m.getAllGeoTypes()) self.assertTrue(m.computeIsoBarycenterOfNodesPerCell().isEqual(dReference,1e-12)) m.getNodalConnectivity().setIJ(25,0,24) self.assertRaises(InterpKernelException,m.computeIsoBarycenterOfNodesPerCell) @@ -13334,7 +13338,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): self.assertTrue(isinstance(mcpy0,MEDCouplingUMesh)) self.assertTrue(mcpy0.getNodalConnectivity().isEqual(DataArrayInt([31,3,2,8,9,31,1,0,6,7,-1,7,6,1,31,2,1,7,8,-1,2,1,-1,8,-1,7,31,5,4,10,11,-1,11,10,-1,5,31,4,3,9,10,-1,5,3,9]))) self.assertTrue(mcpy0.getNodalConnectivityIndex().isEqual(DataArrayInt([0,5,14,26,36,45]))) - self.assertEqual(mcpy0.getAllTypes(),[NORM_POLYHED]) + self.assertEqual(mcpy0.getAllGeoTypes(),[NORM_POLYHED]) mcpy0.checkCoherency() mcpy0.checkCoherency2() mcpy1=mcpy0.convertIntoSingleGeoTypeMesh() @@ -13996,6 +14000,45 @@ class MEDCouplingBasicsTest(unittest.TestCase): self.assertEqual([3,12,5,6,14,16,23,100,23,1,0,6],d0i.getValues()) pass + def testSwig2GetCellsContainingPointsForNonConvexPolygon1(self): + coo=DataArrayDouble([-0.5,-0.5,-0.5,0.5,0.5,0.5,0.5,-0.5,0.,-0.5,0.,0.,0.5,0.,],7,2) + m=MEDCouplingUMesh("Intersect2D",2) ; m.setCoords(coo) ; m.allocateCells() + m.insertNextCell(NORM_POLYGON,[6,3,4,5]) + m.insertNextCell(NORM_POLYGON,[4,0,1,2,6,5]) + m.checkCoherency2() + # + self.assertTrue(m.getCellsContainingPoint((0.4,-0.4),1e-12).isEqual(DataArrayInt([0]))) + self.assertTrue(m.getCellsContainingPoint((-0.4,-0.4),1e-12).isEqual(DataArrayInt([1]))) + self.assertTrue(m.getCellsContainingPoint((0.,-0.4),1e-12).isEqual(DataArrayInt([0,1]))) + pass + + def testSwig2GetCellsContainingPointsForNonConvexPolygon2(self): + coo=DataArrayDouble([-0.5,-0.5,-0.5,0.5,0.5,0.5,0.5,-0.5,-2.0816681711721685e-17,-2.0816681711721685e-17,-0.17677669529663687,0.1767766952966369,0.,0.5,0.5,0.,0.17677669529663684,-0.17677669529663692,0.17677669529663692,0.17677669529663684,-0.17677669529663692,-0.17677669529663687,0.,-0.5,-0.5,0.,0.33838834764831843,-0.3383883476483185,-0.33838834764831843,0.33838834764831843,-0.21213203435596423,0.21213203435596426,0.2121320343559642,-0.2121320343559643,0.21213203435596426,0.2121320343559642,-0.21213203435596423,-0.21213203435596428,0.3560660171779821,-0.35606601717798214,-0.35606601717798214,0.35606601717798214,0.19445436482630052,-0.19445436482630063,-0.19445436482630055,0.19445436482630057,0.,0.27],24,2) + m=MEDCouplingUMesh("mesh",2) ; m.setCoords(coo) ; m.allocateCells() + m.insertNextCell(NORM_QPOLYG,[8,5,4,9]) + m.insertNextCell(NORM_QPOLYG,[5,8,4,10]) + m.insertNextCell(NORM_QPOLYG,[16,8,5,15,21,9,22,17]) + m.insertNextCell(NORM_QPOLYG,[15,1,2,3,16,20,6,7,19,17]) + m.insertNextCell(NORM_QPOLYG,[15,5,8,16,22,10,21,18]) + m.insertNextCell(NORM_QPOLYG,[16,3,0,1,15,19,11,12,20,18]) + m.checkCoherency2() + self.assertTrue(m.getCellsContainingPoint([0.,0.27],1e-12).isEqual(DataArrayInt([2]))) + pass + + def testSwig2DAIGetIdsEqualTuple1(self): + da=DataArrayInt([0,7,1,2,4,1,2,1,1,2,0,1,2,1,5,1,1,2],9,2) + self.assertTrue(da.getIdsEqualTuple([1,2]).isEqual(DataArrayInt([1,4,8]))) + self.assertTrue(da.getIdsEqualTuple((1,2)).isEqual(DataArrayInt([1,4,8]))) + self.assertTrue(da.getIdsEqualTuple(DataArrayInt([1,2])).isEqual(DataArrayInt([1,4,8]))) + da.rearrange(3) + self.assertRaises(InterpKernelException,da.getIdsEqualTuple,[1,2])# mismatch nb of compo (3) and nb of elts in input tuple (2) + self.assertTrue(da.getIdsEqualTuple([2,0,1]).isEqual(DataArrayInt([3]))) + self.assertTrue(da.getIdsEqualTuple([2,0,7]).isEqual(DataArrayInt([]))) + da.rearrange(1) + self.assertTrue(da.getIdsEqualTuple(2).isEqual(DataArrayInt([3,6,9,12,17]))) + self.assertTrue(da.getIdsEqualTuple(2).isEqual(da.getIdsEqual(2))) + pass + def setUp(self): pass pass diff --git a/src/MEDCoupling_Swig/MEDCouplingCommon.i b/src/MEDCoupling_Swig/MEDCouplingCommon.i index 4362b1c8a..984571254 100644 --- a/src/MEDCoupling_Swig/MEDCouplingCommon.i +++ b/src/MEDCoupling_Swig/MEDCouplingCommon.i @@ -267,6 +267,8 @@ using namespace INTERP_KERNEL; %newobject ParaMEDMEM::MEDCouplingUMesh::ComputeRangesFromTypeDistribution; %newobject ParaMEDMEM::MEDCouplingUMesh::buildUnionOf2DMesh; %newobject ParaMEDMEM::MEDCouplingUMesh::buildUnionOf3DMesh; +%newobject ParaMEDMEM::MEDCouplingUMesh::getBoundingBoxForBBTreeFast; +%newobject ParaMEDMEM::MEDCouplingUMesh::getBoundingBoxForBBTree2DQuadratic; %newobject ParaMEDMEM::MEDCouplingUMeshCellByTypeEntry::__iter__; %newobject ParaMEDMEM::MEDCouplingUMeshCellEntry::__iter__; %newobject ParaMEDMEM::MEDCoupling1GTUMesh::New; @@ -917,7 +919,7 @@ namespace ParaMEDMEM virtual void checkFullyDefined() const throw(INTERP_KERNEL::Exception); virtual bool isEmptyMesh(const std::vector& tinyInfo) const throw(INTERP_KERNEL::Exception); virtual MEDCouplingPointSet *deepCpyConnectivityOnly() const throw(INTERP_KERNEL::Exception); - virtual DataArrayDouble *getBoundingBoxForBBTree() const throw(INTERP_KERNEL::Exception); + virtual DataArrayDouble *getBoundingBoxForBBTree(double arcDetEps=1e-12) const throw(INTERP_KERNEL::Exception); %extend { std::string __str__() const throw(INTERP_KERNEL::Exception) @@ -1534,6 +1536,8 @@ namespace ParaMEDMEM DataArrayInt *convertNodalConnectivityToStaticGeoTypeMesh() const throw(INTERP_KERNEL::Exception); DataArrayInt *buildUnionOf2DMesh() const throw(INTERP_KERNEL::Exception); DataArrayInt *buildUnionOf3DMesh() const throw(INTERP_KERNEL::Exception); + DataArrayDouble *getBoundingBoxForBBTreeFast() const throw(INTERP_KERNEL::Exception); + DataArrayDouble *getBoundingBoxForBBTree2DQuadratic(double arcDetEps=1e-12) 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); @@ -1566,6 +1570,16 @@ namespace ParaMEDMEM { return self->cellIterator(); } + + PyObject *getAllGeoTypesSorted() const throw(INTERP_KERNEL::Exception) + { + std::vector result=self->getAllGeoTypesSorted(); + std::vector::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; + } void setPartOfMySelf(PyObject *li, const MEDCouplingUMesh& otherOnSameCoordsThanThis) throw(INTERP_KERNEL::Exception) { @@ -1723,15 +1737,6 @@ namespace ParaMEDMEM ret->incrRef(); return ret; } - PyObject *getAllTypes() const throw(INTERP_KERNEL::Exception) - { - std::set result=self->getAllTypes(); - std::set::const_iterator iL=result.begin(); - PyObject *res = PyList_New(result.size()); - for (int i=0;iL!=result.end(); i++, iL++) - PyList_SetItem(res,i,PyInt_FromLong(*iL)); - return res; - } static PyObject *ComputeSpreadZoneGraduallyFromSeed(PyObject *seed, const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn, int nbOfDepthPeeling=-1) throw(INTERP_KERNEL::Exception) { diff --git a/src/MEDCoupling_Swig/MEDCouplingMemArray.i b/src/MEDCoupling_Swig/MEDCouplingMemArray.i index 248cd2028..d664d0894 100644 --- a/src/MEDCoupling_Swig/MEDCouplingMemArray.i +++ b/src/MEDCoupling_Swig/MEDCouplingMemArray.i @@ -67,6 +67,7 @@ %newobject ParaMEDMEM::DataArrayInt::getIdsNotEqual; %newobject ParaMEDMEM::DataArrayInt::getIdsEqualList; %newobject ParaMEDMEM::DataArrayInt::getIdsNotEqualList; +%newobject ParaMEDMEM::DataArrayInt::getIdsEqualTuple; %newobject ParaMEDMEM::DataArrayInt::sumPerTuple; %newobject ParaMEDMEM::DataArrayInt::negate; %newobject ParaMEDMEM::DataArrayInt::computeAbs; @@ -2753,6 +2754,14 @@ namespace ParaMEDMEM return self->accumulatePerChunck(bg,bg+sz); } + DataArrayInt *getIdsEqualTuple(PyObject *inputTuple) const throw(INTERP_KERNEL::Exception) + { + int sw,sz,val; + std::vector val2; + const int *bg(convertObjToPossibleCpp1_Safe(inputTuple,sw,sz,val,val2)); + return self->getIdsEqualTuple(bg,bg+sz); + } + PyObject *splitInBalancedSlices(int nbOfSlices) const throw(INTERP_KERNEL::Exception) { std::vector< std::pair > slcs(self->splitInBalancedSlices(nbOfSlices)); diff --git a/src/MEDGUI/MEDGUIDataBaseDockWidget.cxx b/src/MEDGUI/MEDGUIDataBaseDockWidget.cxx index d14c0679d..e1c36448f 100644 --- a/src/MEDGUI/MEDGUIDataBaseDockWidget.cxx +++ b/src/MEDGUI/MEDGUIDataBaseDockWidget.cxx @@ -29,6 +29,7 @@ MEDGUIDataBaseDockWidget::MEDGUIDataBaseDockWidget(CAM_Application *app, QWidget * parent):QDockWidget(parent),_app(app) { setWindowTitle("MEDUtils DataBase"); + setObjectName("MEDUtils DataBase"); setMinimumWidth(270); setMinimumHeight(300); QWidget *content = new QWidget; diff --git a/src/MEDGUI/MED_msg_ja.ts b/src/MEDGUI/MED_msg_ja.ts index f869a536d..4844a1c84 100644 --- a/src/MEDGUI/MED_msg_ja.ts +++ b/src/MEDGUI/MED_msg_ja.ts @@ -9,19 +9,19 @@ MED_INF_FIELDNAME - 読み取りするフィールドの名前を指定して下さい + 読み取るフィールドの名前を入力してください。 MED_INF_MESHNAME - 読み取りするメッシュの名前を指定して下さい + 読みたいメッシュの名前を入力してください。 MED_INF_NOIOR - オブジェクトは、IOR を持たない + Object has no IOR MED_INF_NOTIMPL - このオブジェクトは実装されない + Not Implemented for this Object MED_WRN_WARNING @@ -33,11 +33,11 @@ MEN_DUMPMESH - メッシュリスト + Dump Mesh MEN_DUMPSUBMESH - サブメッシュリスト + Dump SubMesh MEN_HIDE @@ -45,7 +45,7 @@ MEN_EXPLORE - MED ファイルを探索 + Explore Med File MEN_FIELDSEL @@ -57,7 +57,7 @@ MEN_POPUPTEST - ポップアップテスト + Popup Test STB_SHOW @@ -65,31 +65,31 @@ STB_DUMPMESH - メッシュリスト + dump Mesh STB_DUMPSUBMESH - メッシュリスト + dump Mesh STB_HIDE - 非表示 + Hide STB_EXPLORE - MED ファイルを探索 + Explore Med File STB_FIELDSEL - フィールドを読み取り + Read a field STB_MESHSEL - メッシュ読み込み + Read a mesh STB_POPUPTEST - ポップアップテスト + Popup test TB_MED @@ -101,11 +101,11 @@ TOP_DUMPMESH - メッシュリスト + Dump Mesh TOP_DUMPSUBMESH - サブメッシュリスト + Dump SubMesh TOP_HIDE @@ -113,7 +113,7 @@ TOP_EXPLORE - MED ファイルを探索 + Explore Med File TOP_FIELDSEL @@ -121,11 +121,11 @@ TOP_MESHSEL - メッシュの選択 + Mesh selection TOP_POPUPTEST - ポップアップテスト + Popup test diff --git a/src/MEDLoader/MEDFileField.cxx b/src/MEDLoader/MEDFileField.cxx index 278c7168f..b68147e4b 100644 --- a/src/MEDLoader/MEDFileField.cxx +++ b/src/MEDLoader/MEDFileField.cxx @@ -4137,6 +4137,8 @@ void MEDFileAnyTypeField1TSWithoutSDA::updateData(int newLgth, const std::vector throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 1 !"); MEDCouplingAutoRefCountObjectPtr newArr=createNewEmptyDataArrayInstance(); newArr->alloc(newLgth,getNumberOfComponents()); + if(oldArr) + newArr->copyStringInfoFrom(*oldArr); int pos=0; for(std::vector< std::pair >::const_iterator it=oldStartStops.begin();it!=oldStartStops.end();it++) { diff --git a/src/MEDLoader/MEDFileField.hxx b/src/MEDLoader/MEDFileField.hxx index 0ff3e041b..3da4614aa 100644 --- a/src/MEDLoader/MEDFileField.hxx +++ b/src/MEDLoader/MEDFileField.hxx @@ -50,26 +50,27 @@ namespace ParaMEDMEM class MEDFileFieldLoc : public RefCountObject { public: - void MEDLOADER_EXPORT simpleRepr(std::ostream& oss) const; - std::string MEDLOADER_EXPORT getName() const { return _name; } - void MEDLOADER_EXPORT setName(const char *name); + MEDLOADER_EXPORT void simpleRepr(std::ostream& oss) const; + MEDLOADER_EXPORT std::string getName() const { return _name; } + MEDLOADER_EXPORT void setName(const char *name); static MEDFileFieldLoc *New(med_idt fid, const char *locName); static MEDFileFieldLoc *New(med_idt fid, int id); static MEDFileFieldLoc *New(const char *locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector& refCoo, const std::vector& gsCoo, const std::vector& w); std::size_t getHeapMemorySizeWithoutChildren() const; std::vector getDirectChildren() const; MEDFileFieldLoc *deepCpy() const; - int MEDLOADER_EXPORT getNbOfGaussPtPerCell() const { return _nb_gauss_pt; } - void MEDLOADER_EXPORT writeLL(med_idt fid) const; - std::string MEDLOADER_EXPORT repr() const; - bool MEDLOADER_EXPORT isName(const char *name) const { return _name==name; } - int MEDLOADER_EXPORT getDimension() const { return _dim; } - int MEDLOADER_EXPORT getNumberOfGaussPoints() const { return _nb_gauss_pt; } - int MEDLOADER_EXPORT getNumberOfPointsInCells() const { return _nb_node_per_cell; } - const MEDLOADER_EXPORT std::vector& getRefCoords() const { return _ref_coo; } - const MEDLOADER_EXPORT std::vector& getGaussCoords() const { return _gs_coo; } - const MEDLOADER_EXPORT std::vector& getGaussWeights() const { return _w; } - bool MEDLOADER_EXPORT isEqual(const MEDFileFieldLoc& other, double eps) const; + MEDLOADER_EXPORT int getNbOfGaussPtPerCell() const { return _nb_gauss_pt; } + MEDLOADER_EXPORT void writeLL(med_idt fid) const; + MEDLOADER_EXPORT std::string repr() const; + MEDLOADER_EXPORT bool isName(const char *name) const { return _name==name; } + MEDLOADER_EXPORT int getDimension() const { return _dim; } + MEDLOADER_EXPORT int getNumberOfGaussPoints() const { return _nb_gauss_pt; } + MEDLOADER_EXPORT int getNumberOfPointsInCells() const { return _nb_node_per_cell; } + MEDLOADER_EXPORT const std::vector& getRefCoords() const { return _ref_coo; } + MEDLOADER_EXPORT const std::vector& getGaussCoords() const { return _gs_coo; } + MEDLOADER_EXPORT const std::vector& getGaussWeights() const { return _w; } + MEDLOADER_EXPORT INTERP_KERNEL::NormalizedCellType getGeoType() const { return _geo_type; } + MEDLOADER_EXPORT bool isEqual(const MEDFileFieldLoc& other, double eps) const; private: MEDFileFieldLoc(med_idt fid, const char *locName); MEDFileFieldLoc(med_idt fid, int id); diff --git a/src/MEDLoader/MEDFileFieldOverView.cxx b/src/MEDLoader/MEDFileFieldOverView.cxx index c9c047ef6..6d9da0165 100644 --- a/src/MEDLoader/MEDFileFieldOverView.cxx +++ b/src/MEDLoader/MEDFileFieldOverView.cxx @@ -27,7 +27,7 @@ using namespace ParaMEDMEM; const unsigned char MEDMeshMultiLev::PARAMEDMEM_2_VTKTYPE[MEDMeshMultiLev::PARAMEDMEM_2_VTKTYPE_LGTH]= - {1,3,21,5,9,7,22,34,23,28,255,255,255,255,10,14,13,255,12,255,24,255,16,27,255,26,255,29,255,255,25,42,255,4}; + {1,3,21,5,9,7,22,34,23,28,255,255,255,255,10,14,13,255,12,255,24,255,16,27,255,26,255,29,255,255,25,42,36,4}; const char MEDFileField1TSStructItem2::NEWLY_CREATED_PFL_NAME[]="???"; @@ -206,6 +206,168 @@ DataArray *MEDMeshMultiLev::buildDataArray(const MEDFileField1TSStructItem& fst, return constructDataArray(fst,globs,vals); } +/*! + * \param [out] famIds - Can be null. If not null the instance has to be dealt by the caller (decrRef). + * \param [out] isWithoutCopy - When true the returned instance \a famIds if not null is directly those in the data structure. + */ +void MEDMeshMultiLev::retrieveFamilyIdsOnCells(DataArrayInt *& famIds, bool& isWithoutCopy) const +{ + const DataArrayInt *fids(_cell_fam_ids); + if(!fids) + { famIds=0; isWithoutCopy=true; return ; } + std::size_t sz(_geo_types.size()); + bool presenceOfPfls(false); + for(std::size_t i=0;i(fids); famIds->incrRef(); isWithoutCopy=_cell_fam_ids_nocpy; return ; } + //bad luck the slowest part + isWithoutCopy=false; + std::vector< MEDCouplingAutoRefCountObjectPtr > retSafe(sz); + std::vector< const DataArrayInt *> ret(sz); + int start(0); + for(std::size_t i=0;i tmp(fids->selectByTupleId2(start,start+lgth,1)); + retSafe[i]=tmp->selectByTupleIdSafe(pfl->begin(),pfl->end()); + } + else + { + retSafe[i]=fids->selectByTupleId2(start,start+lgth,1); + } + ret[i]=retSafe[i]; + start+=lgth; + } + famIds=DataArrayInt::Aggregate(ret); +} + +/*! + * \param [out] numIds - Can be null. If not null the instance has to be dealt by the caller (decrRef). + * \param [out] isWithoutCopy - When true the returned instance \a numIds if not null is directly those in the data structure. + */ +void MEDMeshMultiLev::retrieveNumberIdsOnCells(DataArrayInt *& numIds, bool& isWithoutCopy) const +{ + const DataArrayInt *nids(_cell_num_ids); + if(!nids) + { numIds=0; isWithoutCopy=true; return ; } + std::size_t sz(_geo_types.size()); + bool presenceOfPfls(false); + for(std::size_t i=0;i(nids); numIds->incrRef(); isWithoutCopy=_cell_num_ids_nocpy; return ; } + //bad luck the slowest part + isWithoutCopy=false; + std::vector< MEDCouplingAutoRefCountObjectPtr > retSafe(sz); + std::vector< const DataArrayInt *> ret(sz); + int start(0); + for(std::size_t i=0;i tmp(nids->selectByTupleId2(start,start+lgth,1)); + retSafe[i]=tmp->selectByTupleIdSafe(pfl->begin(),pfl->end()); + } + else + { + retSafe[i]=nids->selectByTupleId2(start,start+lgth,1); + } + ret[i]=retSafe[i]; + start+=lgth; + } + numIds=DataArrayInt::Aggregate(ret); +} + +/*! + * \param [out] famIds - Can be null. If not null the instance has to be dealt by the caller (decrRef). + * \param [out] isWithoutCopy - When true the returned instance \a famIds if not null is directly those in the data structure. + */ +void MEDMeshMultiLev::retrieveFamilyIdsOnNodes(DataArrayInt *& famIds, bool& isWithoutCopy) const +{ + const DataArrayInt *fids(_node_fam_ids); + if(!fids) + { famIds=0; isWithoutCopy=true; return ; } + const DataArrayInt *nr(_node_reduction); + if(nr) + { + isWithoutCopy=false; + famIds=fids->selectByTupleIdSafe(nr->begin(),nr->end()); + } + else + { + isWithoutCopy=_node_fam_ids_nocpy; + famIds=const_cast(fids); famIds->incrRef(); + } +} + +/*! + * \param [out] numIds - Can be null. If not null the instance has to be dealt by the caller (decrRef). + * \param [out] isWithoutCopy - When true the returned instance \a numIds if not null is directly those in the data structure. + */ +void MEDMeshMultiLev::retrieveNumberIdsOnNodes(DataArrayInt *& numIds, bool& isWithoutCopy) const +{ + const DataArrayInt *fids(_node_num_ids); + if(!fids) + { numIds=0; isWithoutCopy=true; return ; } + const DataArrayInt *nr(_node_reduction); + if(nr) + { + isWithoutCopy=false; + numIds=fids->selectByTupleIdSafe(nr->begin(),nr->end()); + } + else + { + isWithoutCopy=_node_num_ids_nocpy; + numIds=const_cast(fids); numIds->incrRef(); + } +} + +void MEDMeshMultiLev::setFamilyIdsOnCells(DataArrayInt *famIds, bool isNoCopy) +{ + _cell_fam_ids=famIds; + if(famIds) + famIds->incrRef(); + _cell_fam_ids_nocpy=isNoCopy; +} + +void MEDMeshMultiLev::setNumberIdsOnCells(DataArrayInt *numIds, bool isNoCopy) +{ + _cell_num_ids=numIds; + if(numIds) + numIds->incrRef(); + _cell_num_ids_nocpy=isNoCopy; +} + +void MEDMeshMultiLev::setFamilyIdsOnNodes(DataArrayInt *famIds, bool isNoCopy) +{ + _node_fam_ids=famIds; + if(famIds) + famIds->incrRef(); + _node_fam_ids_nocpy=isNoCopy; +} + +void MEDMeshMultiLev::setNumberIdsOnNodes(DataArrayInt *numIds, bool isNoCopy) +{ + _node_num_ids=numIds; + if(numIds) + numIds->incrRef(); + _node_num_ids_nocpy=isNoCopy; +} + std::string MEDMeshMultiLev::getPflNameOfId(int id) const { std::size_t sz(_pfls.size()); @@ -382,11 +544,11 @@ DataArray *MEDMeshMultiLev::constructDataArray(const MEDFileField1TSStructItem& } } -MEDMeshMultiLev::MEDMeshMultiLev() +MEDMeshMultiLev::MEDMeshMultiLev():_nb_nodes(0),_cell_fam_ids_nocpy(false) { } -MEDMeshMultiLev::MEDMeshMultiLev(int nbNodes, const std::vector& gts, const std::vector& pfls, const std::vector& nbEntities):_geo_types(gts),_nb_entities(nbEntities),_nb_nodes(nbNodes) +MEDMeshMultiLev::MEDMeshMultiLev(int nbNodes, const std::vector& gts, const std::vector& pfls, const std::vector& nbEntities):_geo_types(gts),_nb_entities(nbEntities),_nb_nodes(nbNodes),_cell_fam_ids_nocpy(false),_cell_num_ids_nocpy(false),_node_fam_ids_nocpy(false),_node_num_ids_nocpy(false) { std::size_t sz(_geo_types.size()); if(sz!=pfls.size() || sz!=nbEntities.size()) @@ -400,7 +562,7 @@ MEDMeshMultiLev::MEDMeshMultiLev(int nbNodes, const std::vector _parts.resize(sz); _pfls.resize(sz); _geo_types.resize(sz); + _nb_entities.resize(sz); for(std::size_t i=0;i throw INTERP_KERNEL::Exception("MEDUMeshMultiLev constructor : presence of a null pointer !"); _parts[i]=obj; _geo_types[i]=obj->getCellModelEnum(); + _nb_entities[i]=obj->getNumberOfCells(); + } + // ids fields management + _cell_fam_ids_nocpy=(levs.size()==1); + if(_cell_fam_ids_nocpy) + { + const DataArrayInt *tmp(m->getFamilyFieldAtLevel(levs[0])); + if(tmp) + { + tmp->incrRef(); + _cell_fam_ids=(const_cast(tmp)); + } + } + else + { + std::vector tmps(levs.size()); + bool f(true); + for(std::size_t i=0;igetFamilyFieldAtLevel(levs[i]); + if(!tmps[i]) + f=false; + } + if(f) + _cell_fam_ids=DataArrayInt::Aggregate(tmps); + } + _cell_num_ids_nocpy=(levs.size()==1); + if(_cell_num_ids_nocpy) + { + const DataArrayInt *tmp(m->getNumberFieldAtLevel(levs[0])); + if(tmp) + { + tmp->incrRef(); + _cell_num_ids=(const_cast(tmp)); + } + } + else + { + std::vector tmps(levs.size()); + bool n(true); + for(std::size_t i=0;igetNumberFieldAtLevel(levs[i]); + if(!tmps[i]) + n=false; + } + if(n) + _cell_num_ids=DataArrayInt::Aggregate(tmps); } + // node part + _node_fam_ids_nocpy=true; + { + const DataArrayInt *tmp(m->getFamilyFieldAtLevel(1)); + if(tmp) + { + tmp->incrRef(); + _node_fam_ids=(const_cast(tmp)); + } + } + _node_num_ids_nocpy=true; + { + const DataArrayInt *tmp(m->getNumberFieldAtLevel(1)); + if(tmp) + { + tmp->incrRef(); + _node_num_ids=(const_cast(tmp)); + } + } } MEDUMeshMultiLev *MEDUMeshMultiLev::New(const MEDFileUMesh *m, const std::vector& gts, const std::vector& pfls, const std::vector& nbEntities) @@ -445,14 +675,80 @@ MEDUMeshMultiLev *MEDUMeshMultiLev::New(const MEDFileUMesh *m, const std::vector MEDUMeshMultiLev::MEDUMeshMultiLev(const MEDFileUMesh *m, const std::vector& gts, const std::vector& pfls, const std::vector& nbEntities):MEDMeshMultiLev(m->getNumberOfNodes(),gts,pfls,nbEntities) { std::size_t sz(gts.size()); + if(sz<1) + throw INTERP_KERNEL::Exception("constructor of MEDUMeshMultiLev : number of different geo type must be >= 1 !"); + unsigned dim(INTERP_KERNEL::CellModel::GetCellModel(gts[0]).getDimension()); _parts.resize(sz); + bool isSameDim(true),isNoPfl(true); for(std::size_t i=0;igetDirectUndergroundSingleGeoTypeMesh(gts[i])); + if(INTERP_KERNEL::CellModel::GetCellModel(gts[i]).getDimension()!=dim) + isSameDim=false; + if(pfls[i]) + isNoPfl=false; if(elt) elt->incrRef(); _parts[i]=elt; } + // ids fields management + int lev((int)dim-m->getMeshDimension()); + if(isSameDim && isNoPfl && m->getGeoTypesAtLevel(lev)==gts)//optimized part + { + _cell_fam_ids_nocpy=true; + const DataArrayInt *famIds(m->getFamilyFieldAtLevel(lev)); + if(famIds) + { _cell_fam_ids=const_cast(famIds); famIds->incrRef(); } + _cell_num_ids_nocpy=true; + const DataArrayInt *numIds(m->getNumberFieldAtLevel(lev)); + if(numIds) + { _cell_num_ids=const_cast(numIds); numIds->incrRef(); } + _node_fam_ids_nocpy=true; + famIds=m->getFamilyFieldAtLevel(1); + if(famIds) + { _node_fam_ids=const_cast(famIds); famIds->incrRef(); } + _node_num_ids_nocpy=true; + numIds=m->getNumberFieldAtLevel(1); + if(numIds) + { _node_num_ids=const_cast(numIds); numIds->incrRef(); } + return ; + } + // + _cell_fam_ids_nocpy=false; + std::vector< MEDCouplingAutoRefCountObjectPtr > famIdsSafe(sz); + std::vector famIds(sz); + bool f(true); + for(std::size_t i=0;iextractFamilyFieldOnGeoType(gts[i]); + famIds[i]=famIdsSafe[i]; + if(!famIds[i]) + f=false; + } + if(f) + _cell_fam_ids=DataArrayInt::Aggregate(famIds); + _cell_num_ids_nocpy=false; + std::vector< MEDCouplingAutoRefCountObjectPtr > numIdsSafe(sz); + std::vector numIds(sz); + bool n(true); + for(std::size_t i=0;iextractNumberFieldOnGeoType(gts[i]); + numIds[i]=numIdsSafe[i]; + if(!numIds[i]) + n=false; + } + if(n) + _cell_num_ids=DataArrayInt::Aggregate(numIds); + // node ids management + _node_fam_ids_nocpy=true; + const DataArrayInt *nodeFamIds(m->getFamilyFieldAtLevel(1)); + if(nodeFamIds) + { _node_fam_ids=const_cast(nodeFamIds); nodeFamIds->incrRef(); } + _node_num_ids_nocpy=true; + const DataArrayInt *nodeNumIds(m->getNumberFieldAtLevel(1)); + if(nodeNumIds) + { _node_num_ids=const_cast(nodeNumIds); nodeNumIds->incrRef(); } } void MEDUMeshMultiLev::selectPartOfNodes(const DataArrayInt *pflNodes) @@ -585,7 +881,7 @@ bool MEDUMeshMultiLev::buildVTUArrays(DataArrayDouble *& coords, DataArrayByte * { *dPtr++=nnpc; dPtr=std::copy(connPtr,connPtr+nnpc,dPtr); - *cPtr=k+nnpc; k=*cPtr++; + *cPtr++=k; k+=nnpc+1; } if(isPolyh) { std::fill(ePtr,ePtr+curNbCells,-1); ePtr+=curNbCells; } @@ -599,7 +895,7 @@ bool MEDUMeshMultiLev::buildVTUArrays(DataArrayDouble *& coords, DataArrayByte * { *dPtr++=connIPtr[1]-connIPtr[0]; dPtr=std::copy(connPtr+connIPtr[0],connPtr+connIPtr[1],dPtr); - *cPtr=k+connIPtr[1]-connIPtr[0]; k=*cPtr++; + *cPtr++=k; k+=connIPtr[1]-connIPtr[0]; } } else @@ -609,7 +905,7 @@ bool MEDUMeshMultiLev::buildVTUArrays(DataArrayDouble *& coords, DataArrayByte * std::set s(connPtr+connIPtr[0],connPtr+connIPtr[1]); s.erase(-1); *dPtr++=(int)s.size(); dPtr=std::copy(s.begin(),s.end(),dPtr); - *cPtr=k+(int)s.size(); k=*cPtr++; + *cPtr++=k; k+=(int)s.size()+1; } } if(isPolyh) @@ -733,8 +1029,72 @@ MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev() { } -MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev(int nbOfNodes, const std::vector& gts, const std::vector& pfls, const std::vector& nbEntities):MEDMeshMultiLev(nbOfNodes,gts,pfls,nbEntities) +MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev(const MEDFileStructuredMesh *m, const std::vector& lev) { + // ids fields management + _cell_fam_ids_nocpy=true; _cell_num_ids_nocpy=true; + const DataArrayInt *tmp(0); + tmp=m->getFamilyFieldAtLevel(0); + if(tmp) + { + tmp->incrRef(); + _cell_fam_ids=const_cast(tmp); + } + tmp=m->getNumberFieldAtLevel(0); + if(tmp) + { + tmp->incrRef(); + _cell_num_ids=const_cast(tmp); + } + // + _node_fam_ids_nocpy=true; _node_num_ids_nocpy=true; + tmp=0; + tmp=m->getFamilyFieldAtLevel(1); + if(tmp) + { + tmp->incrRef(); + _node_fam_ids=const_cast(tmp); + } + tmp=m->getNumberFieldAtLevel(1); + if(tmp) + { + tmp->incrRef(); + _node_num_ids=const_cast(tmp); + } +} + +MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev(const MEDFileStructuredMesh *m, int nbOfNodes, const std::vector& gts, const std::vector& pfls, const std::vector& nbEntities):MEDMeshMultiLev(nbOfNodes,gts,pfls,nbEntities) +{ + // ids fields management + _cell_fam_ids_nocpy=true; _cell_num_ids_nocpy=true; + const DataArrayInt *tmp(0); + tmp=m->getFamilyFieldAtLevel(0); + if(tmp) + { + tmp->incrRef(); + _cell_fam_ids=const_cast(tmp); + } + tmp=m->getNumberFieldAtLevel(0); + if(tmp) + { + tmp->incrRef(); + _cell_num_ids=const_cast(tmp); + } + // + _node_fam_ids_nocpy=true; _node_num_ids_nocpy=true; + tmp=0; + tmp=m->getFamilyFieldAtLevel(1); + if(tmp) + { + tmp->incrRef(); + _node_fam_ids=const_cast(tmp); + } + tmp=m->getNumberFieldAtLevel(1); + if(tmp) + { + tmp->incrRef(); + _node_num_ids=const_cast(tmp); + } } void MEDStructuredMeshMultiLev::selectPartOfNodes(const DataArrayInt *pflNodes) @@ -778,7 +1138,7 @@ MEDCMeshMultiLev *MEDCMeshMultiLev::New(const MEDFileCMesh *m, const std::vector return new MEDCMeshMultiLev(m,gts,pfls,nbEntities); } -MEDCMeshMultiLev::MEDCMeshMultiLev(const MEDFileCMesh *m, const std::vector& levs) +MEDCMeshMultiLev::MEDCMeshMultiLev(const MEDFileCMesh *m, const std::vector& levs):MEDStructuredMeshMultiLev(m,levs) { if(!m) throw INTERP_KERNEL::Exception("MEDCMeshMultiLev constructor : null input pointer !"); @@ -795,7 +1155,7 @@ MEDCMeshMultiLev::MEDCMeshMultiLev(const MEDFileCMesh *m, const std::vector } } -MEDCMeshMultiLev::MEDCMeshMultiLev(const MEDFileCMesh *m, const std::vector& gts, const std::vector& pfls, const std::vector& nbEntities):MEDStructuredMeshMultiLev(m->getNumberOfNodes(),gts,pfls,nbEntities) +MEDCMeshMultiLev::MEDCMeshMultiLev(const MEDFileCMesh *m, const std::vector& gts, const std::vector& pfls, const std::vector& nbEntities):MEDStructuredMeshMultiLev(m,m->getNumberOfNodes(),gts,pfls,nbEntities) { if(!m) throw INTERP_KERNEL::Exception("MEDCMeshMultiLev constructor 2 : null input pointer !"); @@ -837,6 +1197,7 @@ MEDMeshMultiLev *MEDCMeshMultiLev::prepare() const if(pfl) { std::vector< std::pair > cellParts; + MEDCouplingAutoRefCountObjectPtr ret2; if(MEDCouplingStructuredMesh::IsPartStructured(pfl->begin(),pfl->end(),cgs,cellParts)) { MEDCouplingAutoRefCountObjectPtr ret(new MEDCMeshMultiLev(*this)); @@ -848,7 +1209,7 @@ MEDMeshMultiLev *MEDCMeshMultiLev::prepare() const for(std::size_t i=0;i<_coords.size();i++) coords[i]=_coords[i]->selectByTupleId2(cellParts[i].first,cellParts[i].second+1,1); ret->_coords=coords; - return ret.retn(); + ret2=(MEDCMeshMultiLev *)ret; ret2->incrRef(); } else { @@ -860,8 +1221,21 @@ MEDMeshMultiLev *MEDCMeshMultiLev::prepare() const MEDCouplingAutoRefCountObjectPtr ret(new MEDUMeshMultiLev(*this,m3)); if(nr) { m3->zipCoords(); nnr=nr->deepCpy(); nnr->sort(true); ret->setNodeReduction(nnr); } - return ret.retn(); + ret2=(MEDUMeshMultiLev *)ret; ret2->incrRef(); + } + const DataArrayInt *famIds(_cell_fam_ids),*numIds(_cell_num_ids); + if(famIds) + { + MEDCouplingAutoRefCountObjectPtr tmp(famIds->selectByTupleIdSafe(pfl->begin(),pfl->end())); + ret2->setFamilyIdsOnCells(tmp,false); } + if(numIds) + { + MEDCouplingAutoRefCountObjectPtr tmp(numIds->selectByTupleIdSafe(pfl->begin(),pfl->end())); + ret2->setNumberIdsOnCells(tmp,false); + } + return ret2.retn(); + } else { @@ -896,7 +1270,7 @@ MEDCurveLinearMeshMultiLev *MEDCurveLinearMeshMultiLev::New(const MEDFileCurveLi return new MEDCurveLinearMeshMultiLev(m,gts,pfls,nbEntities); } -MEDCurveLinearMeshMultiLev::MEDCurveLinearMeshMultiLev(const MEDFileCurveLinearMesh *m, const std::vector& levs) +MEDCurveLinearMeshMultiLev::MEDCurveLinearMeshMultiLev(const MEDFileCurveLinearMesh *m, const std::vector& levs):MEDStructuredMeshMultiLev(m,levs) { if(!m) throw INTERP_KERNEL::Exception("MEDCurveLinearMeshMultiLev constructor : null input pointer !"); @@ -910,7 +1284,7 @@ MEDCurveLinearMeshMultiLev::MEDCurveLinearMeshMultiLev(const MEDFileCurveLinearM _structure=m->getMesh()->getNodeGridStructure(); } -MEDCurveLinearMeshMultiLev::MEDCurveLinearMeshMultiLev(const MEDFileCurveLinearMesh *m, const std::vector& gts, const std::vector& pfls, const std::vector& nbEntities):MEDStructuredMeshMultiLev(m->getNumberOfNodes(),gts,pfls,nbEntities) +MEDCurveLinearMeshMultiLev::MEDCurveLinearMeshMultiLev(const MEDFileCurveLinearMesh *m, const std::vector& gts, const std::vector& pfls, const std::vector& nbEntities):MEDStructuredMeshMultiLev(m,m->getNumberOfNodes(),gts,pfls,nbEntities) { if(!m) throw INTERP_KERNEL::Exception("MEDCurveLinearMeshMultiLev constructor 2 : null input pointer !"); @@ -946,6 +1320,7 @@ MEDMeshMultiLev *MEDCurveLinearMeshMultiLev::prepare() const if(pfl) { std::vector< std::pair > cellParts,nodeParts; + MEDCouplingAutoRefCountObjectPtr ret2; if(MEDCouplingStructuredMesh::IsPartStructured(pfl->begin(),pfl->end(),cgs,cellParts)) { nodeParts=cellParts; @@ -963,7 +1338,7 @@ MEDMeshMultiLev *MEDCurveLinearMeshMultiLev::prepare() const ret->_pfls[0]=0; ret->_coords=_coords->selectByTupleIdSafe(p->begin(),p->end()); ret->_structure=st; - return ret.retn(); + ret2=(MEDCurveLinearMeshMultiLev *)ret; ret2->incrRef(); } else { @@ -974,8 +1349,20 @@ MEDMeshMultiLev *MEDCurveLinearMeshMultiLev::prepare() const MEDCouplingAutoRefCountObjectPtr ret(new MEDUMeshMultiLev(*this,m3)); if(nr) { m3->zipCoords(); nnr=nr->deepCpy(); nnr->sort(true); ret->setNodeReduction(nnr); } - return ret.retn(); + ret2=(MEDUMeshMultiLev *)ret; ret2->incrRef(); + } + const DataArrayInt *famIds(_cell_fam_ids),*numIds(_cell_num_ids); + if(famIds) + { + MEDCouplingAutoRefCountObjectPtr tmp(famIds->selectByTupleIdSafe(pfl->begin(),pfl->end())); + ret2->setFamilyIdsOnCells(tmp,false); + } + if(numIds) + { + MEDCouplingAutoRefCountObjectPtr tmp(numIds->selectByTupleIdSafe(pfl->begin(),pfl->end())); + ret2->setNumberIdsOnCells(tmp,false); } + return ret2.retn(); } else { diff --git a/src/MEDLoader/MEDFileFieldOverView.hxx b/src/MEDLoader/MEDFileFieldOverView.hxx index ff4ce6c41..e8d13ebfe 100644 --- a/src/MEDLoader/MEDFileFieldOverView.hxx +++ b/src/MEDLoader/MEDFileFieldOverView.hxx @@ -39,6 +39,7 @@ namespace ParaMEDMEM class MEDFileMesh; class MEDFileUMesh; class MEDFileCMesh; + class MEDFileStructuredMesh; class MEDFileCurveLinearMesh; class MEDFileFieldGlobs; class MEDFileFieldGlobsReal; @@ -80,6 +81,14 @@ namespace ParaMEDMEM void setNodeReduction(const DataArrayInt *nr); bool isFastlyTheSameStruct(const MEDFileField1TSStructItem& fst, const MEDFileFieldGlobsReal *globs) const; MEDLOADER_EXPORT DataArray *buildDataArray(const MEDFileField1TSStructItem& fst, const MEDFileFieldGlobsReal *globs, const DataArray *vals) const; + MEDLOADER_EXPORT void retrieveFamilyIdsOnCells(DataArrayInt *& famIds, bool& isWithoutCopy) const; + MEDLOADER_EXPORT void retrieveNumberIdsOnCells(DataArrayInt *& numIds, bool& isWithoutCopy) const; + MEDLOADER_EXPORT void retrieveFamilyIdsOnNodes(DataArrayInt *& famIds, bool& isWithoutCopy) const; + MEDLOADER_EXPORT void retrieveNumberIdsOnNodes(DataArrayInt *& numIds, bool& isWithoutCopy) const; + void setFamilyIdsOnCells(DataArrayInt *famIds, bool isNoCopy); + void setNumberIdsOnCells(DataArrayInt *numIds, bool isNoCopy); + void setFamilyIdsOnNodes(DataArrayInt *famIds, bool isNoCopy); + void setNumberIdsOnNodes(DataArrayInt *numIds, bool isNoCopy); virtual void selectPartOfNodes(const DataArrayInt *pflNodes) = 0; virtual MEDMeshMultiLev *prepare() const = 0; int getNumberOfCells(INTERP_KERNEL::NormalizedCellType t) const; @@ -97,6 +106,15 @@ namespace ParaMEDMEM std::vector _nb_entities; MEDCouplingAutoRefCountObjectPtr _node_reduction; int _nb_nodes; + // + MEDCouplingAutoRefCountObjectPtr _cell_fam_ids; + bool _cell_fam_ids_nocpy; + MEDCouplingAutoRefCountObjectPtr _cell_num_ids; + bool _cell_num_ids_nocpy; + MEDCouplingAutoRefCountObjectPtr _node_fam_ids; + bool _node_fam_ids_nocpy; + MEDCouplingAutoRefCountObjectPtr _node_num_ids; + bool _node_num_ids_nocpy; public: static const int PARAMEDMEM_2_VTKTYPE_LGTH=34; static const unsigned char PARAMEDMEM_2_VTKTYPE[PARAMEDMEM_2_VTKTYPE_LGTH]; @@ -131,7 +149,8 @@ namespace ParaMEDMEM protected: MEDStructuredMeshMultiLev(); MEDStructuredMeshMultiLev(const MEDStructuredMeshMultiLev& other); - MEDStructuredMeshMultiLev(int nbOfNodes, const std::vector& gts, const std::vector& pfls, const std::vector& nbEntities); + MEDStructuredMeshMultiLev(const MEDFileStructuredMesh *m, const std::vector& lev); + MEDStructuredMeshMultiLev(const MEDFileStructuredMesh *m, int nbOfNodes, const std::vector& gts, const std::vector& pfls, const std::vector& nbEntities); }; class MEDCMeshMultiLev : public MEDStructuredMeshMultiLev diff --git a/src/MEDLoader/MEDFileMesh.cxx b/src/MEDLoader/MEDFileMesh.cxx index a873bdfae..dd31d0a96 100644 --- a/src/MEDLoader/MEDFileMesh.cxx +++ b/src/MEDLoader/MEDFileMesh.cxx @@ -274,6 +274,45 @@ void MEDFileMesh::copyFamGrpMapsFrom(const MEDFileMesh& other) _families=other._families; } + +/*! + * This method clear all the groups in the map. + * So this method does not operate at all on arrays. + * So this method can lead to orphan families. + * + * \sa MEDFileMesh::clearFamMap, MEDFileMesh::clearFamGrpMaps + */ +void MEDFileMesh::clearGrpMap() +{ + _groups.clear(); +} + +/*! + * This method clear all the families in the map. + * So this method does not operate at all on arrays. + * WARNING ! if there are some groups lying on cleared families, those groups will be impacted ! + * + * \sa MEDFileMesh::clearFamMap, MEDFileMesh::clearFamGrpMaps + */ +void MEDFileMesh::clearFamMap() +{ + _families.clear(); +} + +/*! + * This method clear all the families and groups in the map. + * So this method does not operate at all on arrays. + * As all groups and families entry will be removed after + * the call of MEDFileMesh::setFamilyFieldArr method with 0 or None (python) in the 2nd parameter can be useful to reduce the size of the object. + * + * \sa MEDFileMesh::clearFamMap, MEDFileMesh::clearFamMap + */ +void MEDFileMesh::clearFamGrpMaps() +{ + clearGrpMap(); + clearFamMap(); +} + /*! * Returns names of families constituting a group. * \param [in] name - the name of the group of interest. @@ -2941,6 +2980,22 @@ MEDCouplingUMesh *MEDFileUMesh::getLevelM3Mesh(bool renum) const return getMeshAtLevel(-3,renum); } +/*! + * This method is for advanced users. There is two storing strategy of mesh in \a this. + * Either MEDCouplingUMesh, or vector of MEDCoupling1GTUMesh instances. + * When assignement is done the first one is done, which is not optimal in write mode for MED file. + * This method allows to switch from MEDCouplingUMesh mode to MEDCoupling1GTUMesh mode. + */ +void MEDFileUMesh::forceComputationOfParts() const +{ + for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_ms.begin();it!=_ms.end();it++) + { + const MEDFileUMeshSplitL1 *elt(*it); + if(elt) + elt->forceComputationOfParts(); + } +} + /*! * This method returns a vector of mesh parts containing each exactly one geometric type. * This method will never launch an automatic computation of split by type (an INTERP_KERNEL::Exception will be then thrown). @@ -2966,6 +3021,46 @@ MEDCoupling1GTUMesh *MEDFileUMesh::getDirectUndergroundSingleGeoTypeMesh(INTERP_ return sp->getDirectUndergroundSingleGeoTypeMesh(gt); } +/*! + * Given a relative level \a meshDimRelToMax it returns the sorted vector of geometric types present in \a this. + * \throw if the reqsuested \a meshDimRelToMax does not exist. + */ +std::vector MEDFileUMesh::getGeoTypesAtLevel(int meshDimRelToMax) const +{ + const MEDFileUMeshSplitL1 *sp(getMeshAtLevSafe(meshDimRelToMax)); + return sp->getGeoTypes(); +} + +/*! + * This method extracts from whole family field ids the part relative to the input parameter \a gt. + * \param [in] gt - the geometric type for which the family field is asked. + * \return DataArrayInt * - a pointer to DataArrayInt that the caller is to + * delete using decrRef() as it is no more needed. + * \sa MEDFileUMesh::extractNumberFieldOnGeoType + */ +DataArrayInt *MEDFileUMesh::extractFamilyFieldOnGeoType(INTERP_KERNEL::NormalizedCellType gt) const +{ + const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(gt); + int lev=(int)cm.getDimension()-getMeshDimension(); + const MEDFileUMeshSplitL1 *sp(getMeshAtLevSafe(lev)); + return sp->extractFamilyFieldOnGeoType(gt); +} + +/*! + * This method extracts from whole number field ids the part relative to the input parameter \a gt. + * \param [in] gt - the geometric type for which the number field is asked. + * \return DataArrayInt * - a pointer to DataArrayInt that the caller is to + * delete using decrRef() as it is no more needed. + * \sa MEDFileUMesh::extractFamilyFieldOnGeoType + */ +DataArrayInt *MEDFileUMesh::extractNumberFieldOnGeoType(INTERP_KERNEL::NormalizedCellType gt) const +{ + const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(gt); + int lev=(int)cm.getDimension()-getMeshDimension(); + const MEDFileUMeshSplitL1 *sp(getMeshAtLevSafe(lev)); + return sp->extractNumberFieldOnGeoType(gt); +} + const MEDFileUMeshSplitL1 *MEDFileUMesh::getMeshAtLevSafe(int meshDimRelToMaxExt) const { if(meshDimRelToMaxExt==1) diff --git a/src/MEDLoader/MEDFileMesh.hxx b/src/MEDLoader/MEDFileMesh.hxx index 87455300a..d5b544972 100644 --- a/src/MEDLoader/MEDFileMesh.hxx +++ b/src/MEDLoader/MEDFileMesh.hxx @@ -92,6 +92,9 @@ namespace ParaMEDMEM MEDLOADER_EXPORT void setFamilyInfo(const std::map& info); MEDLOADER_EXPORT void setGroupInfo(const std::map >&info); MEDLOADER_EXPORT void copyFamGrpMapsFrom(const MEDFileMesh& other); + MEDLOADER_EXPORT void clearGrpMap(); + MEDLOADER_EXPORT void clearFamMap(); + MEDLOADER_EXPORT void clearFamGrpMaps(); MEDLOADER_EXPORT const std::map& getFamilyInfo() const { return _families; } MEDLOADER_EXPORT const std::map >& getGroupInfo() const { return _groups; } MEDLOADER_EXPORT std::vector getFamiliesOnGroup(const char *name) const; @@ -214,6 +217,7 @@ namespace ParaMEDMEM MEDLOADER_EXPORT const DataArrayInt *getRevNumberFieldAtLevel(int meshDimRelToMaxExt) const; MEDLOADER_EXPORT const DataArrayAsciiChar *getNameFieldAtLevel(int meshDimRelToMaxExt) const; MEDLOADER_EXPORT int getNumberOfNodes() const; + MEDLOADER_EXPORT std::vector getGeoTypesAtLevel(int meshDimRelToMax) const; MEDLOADER_EXPORT void whichAreNodesFetched(const MEDFileField1TSStructItem& st, const MEDFileFieldGlobsReal *globs, std::vector& nodesFetched) const; MEDLOADER_EXPORT std::vector getNonEmptyLevels() const; MEDLOADER_EXPORT std::vector getNonEmptyLevelsExt() const; @@ -242,8 +246,11 @@ namespace ParaMEDMEM MEDLOADER_EXPORT MEDCouplingUMesh *getLevelM1Mesh(bool renum=false) const; MEDLOADER_EXPORT MEDCouplingUMesh *getLevelM2Mesh(bool renum=false) const; MEDLOADER_EXPORT MEDCouplingUMesh *getLevelM3Mesh(bool renum=false) const; + MEDLOADER_EXPORT void forceComputationOfParts() const; MEDLOADER_EXPORT std::vector getDirectUndergroundSingleGeoTypeMeshes(int meshDimRelToMax) const; MEDLOADER_EXPORT MEDCoupling1GTUMesh *getDirectUndergroundSingleGeoTypeMesh(INTERP_KERNEL::NormalizedCellType gt) const; + MEDLOADER_EXPORT DataArrayInt *extractFamilyFieldOnGeoType(INTERP_KERNEL::NormalizedCellType gt) const; + MEDLOADER_EXPORT DataArrayInt *extractNumberFieldOnGeoType(INTERP_KERNEL::NormalizedCellType gt) const; // MEDLOADER_EXPORT void setFamilyNameAttachedOnId(int id, const std::string& newFamName); MEDLOADER_EXPORT void setCoords(DataArrayDouble *coords); diff --git a/src/MEDLoader/MEDFileMeshLL.cxx b/src/MEDLoader/MEDFileMeshLL.cxx index cbc4dc6e6..39c409025 100644 --- a/src/MEDLoader/MEDFileMeshLL.cxx +++ b/src/MEDLoader/MEDFileMeshLL.cxx @@ -535,13 +535,25 @@ MEDFileUMeshSplitL1::MEDFileUMeshSplitL1(const MEDFileUMeshL2& l2, const char *m { for(int i=0;igetFam(); - _fam=DataArrayInt::Aggregate(fams); + if(sz!=1) + _fam=DataArrayInt::Aggregate(fams); + else + { + fams[0]->incrRef(); + _fam=const_cast(fams[0]); + } } if(l2.isNumDefinedOnLev(id)) { for(int i=0;igetNum(); - _num=DataArrayInt::Aggregate(nums); + if(sz!=1) + _num=DataArrayInt::Aggregate(nums); + else + { + nums[0]->incrRef(); + _num=const_cast(nums[0]); + } computeRevNum(); } if(l2.isNamesDefinedOnLev(id)) @@ -701,6 +713,11 @@ void MEDFileUMeshSplitL1::assignMesh(MEDCouplingUMesh *m, bool newOrOld) assignCommonPart(); } +void MEDFileUMeshSplitL1::forceComputationOfParts() const +{ + _m_by_types.forceComputationOfPartsFromUMesh(); +} + void MEDFileUMeshSplitL1::assignParts(const std::vector< const MEDCoupling1GTUMesh * >& mParts) { _m_by_types.assignParts(mParts); @@ -765,6 +782,11 @@ DataArrayInt *MEDFileUMeshSplitL1::getFamilyPartArr(const int *idsBg, const int return da.retn(); } +std::vector MEDFileUMeshSplitL1::getGeoTypes() const +{ + return _m_by_types.getGeoTypes(); +} + MEDCouplingUMesh *MEDFileUMeshSplitL1::getWholeMesh(bool renum) const { MEDCouplingAutoRefCountObjectPtr tmp; @@ -775,6 +797,26 @@ MEDCouplingUMesh *MEDFileUMeshSplitL1::getWholeMesh(bool renum) const return tmp.retn(); } +DataArrayInt *MEDFileUMeshSplitL1::extractFamilyFieldOnGeoType(INTERP_KERNEL::NormalizedCellType gt) const +{ + const DataArrayInt *fam(_fam); + if(!fam) + return 0; + int start(0),stop(0); + _m_by_types.getStartStopOfGeoTypeWithoutComputation(gt,start,stop); + return fam->selectByTupleId2(start,stop,1); +} + +DataArrayInt *MEDFileUMeshSplitL1::extractNumberFieldOnGeoType(INTERP_KERNEL::NormalizedCellType gt) const +{ + const DataArrayInt *num(_num); + if(!num) + return 0; + int start(0),stop(0); + _m_by_types.getStartStopOfGeoTypeWithoutComputation(gt,start,stop); + return num->selectByTupleId2(start,stop,1); +} + DataArrayInt *MEDFileUMeshSplitL1::getOrCreateAndGetFamilyField() { if((DataArrayInt *)_fam) @@ -1009,6 +1051,20 @@ MEDCouplingUMesh *MEDFileUMeshAggregateCompute::getUmesh() const return _m; } +std::vector MEDFileUMeshAggregateCompute::getGeoTypes() const +{ + if(_mp_time>=_m_time) + { + std::size_t sz(_m_parts.size()); + std::vector ret(sz); + for(std::size_t i=0;igetCellModelEnum(); + return ret; + } + else + return _m->getAllGeoTypesSorted(); +} + std::vector MEDFileUMeshAggregateCompute::getPartsWithoutComputation() const { if(_mp_time<_m_time) @@ -1044,6 +1100,27 @@ MEDCoupling1GTUMesh *MEDFileUMeshAggregateCompute::getPartWithoutComputation(INT throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getPartWithoutComputation : the geometric type is not existing !"); } +void MEDFileUMeshAggregateCompute::getStartStopOfGeoTypeWithoutComputation(INTERP_KERNEL::NormalizedCellType gt, int& start, int& stop) const +{ + start=0; stop=0; + std::vector v(getPartsWithoutComputation()); + std::size_t sz(v.size()); + for(std::size_t i=0;igetCellModelEnum()==gt) + { + stop=start+v[i]->getNumberOfCells(); + return; + } + else + start+=v[i]->getNumberOfCells(); + } + } + throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getStartStopOfGeoTypeWithoutComputation : the geometric type is not existing !"); +} + void MEDFileUMeshAggregateCompute::forceComputationOfPartsFromUMesh() const { const MEDCouplingUMesh *m(_m); diff --git a/src/MEDLoader/MEDFileMeshLL.hxx b/src/MEDLoader/MEDFileMeshLL.hxx index 172b9c8d5..eb1d37adc 100644 --- a/src/MEDLoader/MEDFileMeshLL.hxx +++ b/src/MEDLoader/MEDFileMeshLL.hxx @@ -145,8 +145,10 @@ namespace ParaMEDMEM void assignUMesh(MEDCouplingUMesh *m); MEDCouplingUMesh *getUmesh() const; std::vector getParts() const; + std::vector getGeoTypes() const; std::vector getPartsWithoutComputation() const; MEDCoupling1GTUMesh *getPartWithoutComputation(INTERP_KERNEL::NormalizedCellType gt) const; + void getStartStopOfGeoTypeWithoutComputation(INTERP_KERNEL::NormalizedCellType gt, int& start, int& stop) const; std::size_t getTimeOfThis() const; std::size_t getHeapMemorySizeWithoutChildren() const; std::vector getDirectChildren() const; @@ -159,8 +161,8 @@ namespace ParaMEDMEM std::vector getDistributionOfTypes() const; int getSize() const; void setCoords(DataArrayDouble *coords); - private: void forceComputationOfPartsFromUMesh() const; + private: std::size_t getTimeOfParts() const; std::size_t getTimeOfUMesh() const; private: @@ -188,6 +190,7 @@ namespace ParaMEDMEM void synchronizeTinyInfo(const MEDFileMesh& master) const; void assignMesh(MEDCouplingUMesh *m, bool newOrOld); void assignParts(const std::vector< const MEDCoupling1GTUMesh * >& mParts); + void forceComputationOfParts() const; bool empty() const; bool presenceOfOneFams(const std::vector& ids) const; int getMeshDimension() const; @@ -196,8 +199,11 @@ namespace ParaMEDMEM MEDCouplingUMesh *getFamilyPart(const int *idsBg, const int *idsEnd, bool renum) const; DataArrayInt *getFamilyPartArr(const int *idsBg, const int *idsEnd, bool renum) const; MEDCouplingUMesh *getWholeMesh(bool renum) const; + std::vector getGeoTypes() const; std::vector getDirectUndergroundSingleGeoTypeMeshes() const { return _m_by_types.getPartsWithoutComputation(); } MEDCoupling1GTUMesh *getDirectUndergroundSingleGeoTypeMesh(INTERP_KERNEL::NormalizedCellType gt) const { return _m_by_types.getPartWithoutComputation(gt); } + DataArrayInt *extractFamilyFieldOnGeoType(INTERP_KERNEL::NormalizedCellType gt) const; + DataArrayInt *extractNumberFieldOnGeoType(INTERP_KERNEL::NormalizedCellType gt) const; std::vector getDistributionOfTypes() const { return _m_by_types.getDistributionOfTypes(); } DataArrayInt *getOrCreateAndGetFamilyField(); const DataArrayInt *getFamilyField() const; diff --git a/src/MEDLoader/MEDLoader.cxx b/src/MEDLoader/MEDLoader.cxx index f14e17a15..75c9acc1a 100644 --- a/src/MEDLoader/MEDLoader.cxx +++ b/src/MEDLoader/MEDLoader.cxx @@ -284,6 +284,11 @@ void MEDLoaderNS::dispatchElems(int nbOfElemCell, int nbOfElemFace, int& nbOfEle /// @endcond +void MEDLoader::AssignStaticWritePropertiesTo(ParaMEDMEM::MEDFileWritable& obj) +{ + obj.setTooLongStrPolicy(_TOO_LONG_STR); +} + bool MEDLoader::HasXDR() { #ifdef HAS_XDR @@ -1063,7 +1068,7 @@ std::vector< std::pair > MEDLoader::GetNodeFieldIterations(const char * ParaMEDMEM::MEDCouplingMesh *MEDLoader::ReadMeshFromFile(const char *fileName, const char *meshName, int meshDimRelToMax) { CheckFileForRead(fileName); - MEDCouplingAutoRefCountObjectPtr mm=MEDFileMesh::New(fileName,meshName); + MEDCouplingAutoRefCountObjectPtr mm(MEDFileMesh::New(fileName,meshName)); MEDFileMesh *mmPtr(mm); MEDFileUMesh *mmuPtr=dynamic_cast(mmPtr); if(mmuPtr) @@ -1087,7 +1092,7 @@ ParaMEDMEM::MEDCouplingMesh *MEDLoader::ReadMeshFromFile(const char *fileName, c ParaMEDMEM::MEDCouplingMesh *MEDLoader::ReadMeshFromFile(const char *fileName, int meshDimRelToMax) { CheckFileForRead(fileName); - MEDCouplingAutoRefCountObjectPtr mm=MEDFileMesh::New(fileName); + MEDCouplingAutoRefCountObjectPtr mm(MEDFileMesh::New(fileName)); MEDFileMesh *mmPtr(mm); MEDFileUMesh *mmuPtr=dynamic_cast(mmPtr); if(mmuPtr) @@ -1111,7 +1116,7 @@ ParaMEDMEM::MEDCouplingMesh *MEDLoader::ReadMeshFromFile(const char *fileName, i ParaMEDMEM::MEDCouplingUMesh *MEDLoader::ReadUMeshFromFile(const char *fileName, const char *meshName, int meshDimRelToMax) { CheckFileForRead(fileName); - MEDCouplingAutoRefCountObjectPtr mm=MEDFileMesh::New(fileName,meshName); + MEDCouplingAutoRefCountObjectPtr mm(MEDFileMesh::New(fileName,meshName)); MEDFileMesh *mmPtr(mm); MEDFileUMesh *mmuPtr=dynamic_cast(mmPtr); if(!mmuPtr) @@ -1125,7 +1130,7 @@ ParaMEDMEM::MEDCouplingUMesh *MEDLoader::ReadUMeshFromFile(const char *fileName, ParaMEDMEM::MEDCouplingUMesh *MEDLoader::ReadUMeshFromFile(const char *fileName, int meshDimRelToMax) { CheckFileForRead(fileName); - MEDCouplingAutoRefCountObjectPtr mm=MEDFileMesh::New(fileName); + MEDCouplingAutoRefCountObjectPtr mm(MEDFileMesh::New(fileName)); MEDFileMesh *mmPtr(mm); MEDFileUMesh *mmuPtr=dynamic_cast(mmPtr); if(!mmuPtr) @@ -1146,7 +1151,7 @@ int MEDLoader::ReadUMeshDimFromFile(const char *fileName, const char *meshName) ParaMEDMEM::MEDCouplingUMesh *MEDLoader::ReadUMeshFromFamilies(const char *fileName, const char *meshName, int meshDimRelToMax, const std::vector& fams) { CheckFileForRead(fileName); - MEDCouplingAutoRefCountObjectPtr mm=MEDFileMesh::New(fileName,meshName); + MEDCouplingAutoRefCountObjectPtr mm(MEDFileMesh::New(fileName,meshName)); MEDFileMesh *mmPtr(mm); MEDFileUMesh *mmuPtr=dynamic_cast(mmPtr); if(!mmuPtr) @@ -1357,7 +1362,8 @@ void MEDLoader::WriteMesh(const char *fileName, const ParaMEDMEM::MEDCouplingMes const MEDCoupling1GTUMesh *um2(dynamic_cast(mesh)); if(um2) { - MEDCouplingAutoRefCountObjectPtr mmu=MEDFileUMesh::New(); + MEDCouplingAutoRefCountObjectPtr mmu(MEDFileUMesh::New()); + AssignStaticWritePropertiesTo(*mmu); mmu->setMeshAtLevel(0,const_cast(um2)); mmu->write(fileName,mod); return ; @@ -1365,7 +1371,8 @@ void MEDLoader::WriteMesh(const char *fileName, const ParaMEDMEM::MEDCouplingMes const MEDCouplingCMesh *um3(dynamic_cast(mesh)); if(um3) { - MEDCouplingAutoRefCountObjectPtr mmc=MEDFileCMesh::New(); + MEDCouplingAutoRefCountObjectPtr mmc(MEDFileCMesh::New()); + AssignStaticWritePropertiesTo(*mmc); mmc->setMesh(const_cast(um3)); mmc->write(fileName,mod); return ; @@ -1373,7 +1380,8 @@ void MEDLoader::WriteMesh(const char *fileName, const ParaMEDMEM::MEDCouplingMes const MEDCouplingCurveLinearMesh *um4(dynamic_cast(mesh)); if(um4) { - MEDCouplingAutoRefCountObjectPtr mmc=MEDFileCurveLinearMesh::New(); + MEDCouplingAutoRefCountObjectPtr mmc(MEDFileCurveLinearMesh::New()); + AssignStaticWritePropertiesTo(*mmc); mmc->setMesh(const_cast(um4)); mmc->write(fileName,mod); return ; @@ -1386,7 +1394,8 @@ void MEDLoader::WriteUMesh(const char *fileName, const ParaMEDMEM::MEDCouplingUM if(!mesh) throw INTERP_KERNEL::Exception("MEDLoader::WriteUMesh : input mesh is null !"); int mod=writeFromScratch?2:0; - MEDCouplingAutoRefCountObjectPtr m=MEDFileUMesh::New(); + MEDCouplingAutoRefCountObjectPtr m(MEDFileUMesh::New()); + AssignStaticWritePropertiesTo(*m); MEDCouplingAutoRefCountObjectPtr mcpy(static_cast(mesh->deepCpy())); m->setMeshAtLevel(0,mcpy,true); m->write(fileName,mod); @@ -1408,7 +1417,8 @@ void MEDLoader::WriteUMeshesPartition(const char *fileName, const char *meshName std::ostringstream oss; oss << "File with name \'" << fileName << "\' has not valid permissions !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - MEDCouplingAutoRefCountObjectPtr m=MEDFileUMesh::New(); + MEDCouplingAutoRefCountObjectPtr m(MEDFileUMesh::New()); + AssignStaticWritePropertiesTo(*m); m->setGroupsFromScratch(0,meshes,true); m->setName(meshNameC); int mod=writeFromScratch?2:0; @@ -1423,14 +1433,16 @@ void MEDLoader::WriteUMeshesPartitionDep(const char *fileName, const char *meshN void MEDLoader::WriteUMeshes(const char *fileName, const std::vector& meshes, bool writeFromScratch) { int mod=writeFromScratch?2:0; - MEDCouplingAutoRefCountObjectPtr m=MEDFileUMesh::New(); + MEDCouplingAutoRefCountObjectPtr m(MEDFileUMesh::New()); + AssignStaticWritePropertiesTo(*m); m->setMeshes(meshes,true); m->write(fileName,mod); } void MEDLoaderNS::writeFieldWithoutReadingAndMappingOfMeshInFile(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f, bool writeFromScratch) { - MEDCouplingAutoRefCountObjectPtr ff=MEDFileField1TS::New(); + MEDCouplingAutoRefCountObjectPtr ff(MEDFileField1TS::New()); + MEDLoader::AssignStaticWritePropertiesTo(*ff); MEDCouplingAutoRefCountObjectPtr f2(f->deepCpy()); const MEDCouplingMesh *m(f2->getMesh()); const MEDCouplingUMesh *um(dynamic_cast(m)); @@ -1441,9 +1453,10 @@ void MEDLoaderNS::writeFieldWithoutReadingAndMappingOfMeshInFile(const char *fil int mod=writeFromScratch?2:0; if(um) { - MEDCouplingAutoRefCountObjectPtr mmu=MEDFileUMesh::New(); - MEDCouplingAutoRefCountObjectPtr o2n=um->getRenumArrForMEDFileFrmt(); - MEDCouplingAutoRefCountObjectPtr n2o=o2n->invertArrayO2N2N2O(o2n->getNumberOfTuples()); + MEDCouplingAutoRefCountObjectPtr mmu(MEDFileUMesh::New()); + MEDLoader::AssignStaticWritePropertiesTo(*mmu); + MEDCouplingAutoRefCountObjectPtr o2n(um->getRenumArrForMEDFileFrmt()); + MEDCouplingAutoRefCountObjectPtr n2o(o2n->invertArrayO2N2N2O(o2n->getNumberOfTuples())); f2->renumberCells(o2n->begin(),false); mmu->setMeshAtLevel(0,const_cast(static_cast(f2->getMesh()))); mmu->setRenumFieldArr(0,n2o); @@ -1452,21 +1465,24 @@ void MEDLoaderNS::writeFieldWithoutReadingAndMappingOfMeshInFile(const char *fil } else if(um2) { - MEDCouplingAutoRefCountObjectPtr mmu=MEDFileUMesh::New(); + MEDCouplingAutoRefCountObjectPtr mmu(MEDFileUMesh::New()); + MEDLoader::AssignStaticWritePropertiesTo(*mmu); mmu->setMeshAtLevel(0,const_cast(um2)); ff->setFieldNoProfileSBT(f2); mmu->write(fileName,mod); } else if(um3) { - MEDCouplingAutoRefCountObjectPtr mmc=MEDFileCMesh::New(); + MEDCouplingAutoRefCountObjectPtr mmc(MEDFileCMesh::New()); + MEDLoader::AssignStaticWritePropertiesTo(*mmc); mmc->setMesh(const_cast(um3)); ff->setFieldNoProfileSBT(f2); mmc->write(fileName,mod); } else if(um4) { - MEDCouplingAutoRefCountObjectPtr mmc=MEDFileCurveLinearMesh::New(); + MEDCouplingAutoRefCountObjectPtr mmc(MEDFileCurveLinearMesh::New()); + MEDLoader::AssignStaticWritePropertiesTo(*mmc); mmc->setMesh(const_cast(um4)); ff->setFieldNoProfileSBT(f2); mmc->write(fileName,mod); @@ -1501,7 +1517,8 @@ void MEDLoader::WriteField(const char *fileName, const ParaMEDMEM::MEDCouplingFi MEDLoaderNS::writeFieldWithoutReadingAndMappingOfMeshInFile(fileName,f,false); else { - MEDCouplingAutoRefCountObjectPtr mm=MEDFileMesh::New(fileName,f->getMesh()->getName().c_str()); + MEDCouplingAutoRefCountObjectPtr mm(MEDFileMesh::New(fileName,f->getMesh()->getName().c_str())); + AssignStaticWritePropertiesTo(*mm); const MEDFileMesh *mmPtr(mm); const MEDFileUMesh *mmuPtr=dynamic_cast(mmPtr); if(!mmuPtr) @@ -1525,7 +1542,8 @@ void MEDLoader::WriteField(const char *fileName, const ParaMEDMEM::MEDCouplingFi std::ostringstream oss; oss << "MEDLoader::WriteField : The file \""<< fileName << "\" already contains a mesh named \""<< f->getMesh()->getName() << "\" and this mesh in the file is not compatible (a subpart) with the mesh you intend to write ! This is maybe due to a too strict policy ! Try with to lease it by calling SetCompPolicyForCell !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - MEDCouplingAutoRefCountObjectPtr f1ts=MEDFileField1TS::New(); + MEDCouplingAutoRefCountObjectPtr f1ts(MEDFileField1TS::New()); + AssignStaticWritePropertiesTo(*f1ts); if(part->isIdentity() && part->getNumberOfTuples()==mread->getNumberOfCells()) f1ts->setFieldNoProfileSBT(f2); else @@ -1546,7 +1564,8 @@ void MEDLoader::WriteField(const char *fileName, const ParaMEDMEM::MEDCouplingFi std::ostringstream oss; oss << "MEDLoader::WriteField : The file \""<< fileName << "\" already contains a mesh named \""<< f->getMesh()->getName() << "\" and this mesh in the file is not compatible (a subpart regarding nodes) with the mesh you intend to write ! This is maybe due to a too strict epsilon ! Try with to lease it by calling SetEpsilonForNodeComp !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - MEDCouplingAutoRefCountObjectPtr f1ts=MEDFileField1TS::New(); + MEDCouplingAutoRefCountObjectPtr f1ts(MEDFileField1TS::New()); + AssignStaticWritePropertiesTo(*f1ts); if(part->isIdentity() && part->getNumberOfTuples()==mread->getNumberOfNodes()) f1ts->setFieldNoProfileSBT(f2); else @@ -1576,7 +1595,8 @@ void MEDLoader::WriteFieldUsingAlreadyWrittenMesh(const char *fileName, const Pa std::ostringstream oss; oss << "File with name \'" << fileName << "\' has not valid permissions or not exists !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - MEDCouplingAutoRefCountObjectPtr f1ts=MEDFileField1TS::New(); + MEDCouplingAutoRefCountObjectPtr f1ts(MEDFileField1TS::New()); + AssignStaticWritePropertiesTo(*f1ts); MEDCouplingUMesh *m=dynamic_cast(const_cast(f->getMesh())); if(!m) throw INTERP_KERNEL::Exception("MEDLoader::WriteFieldUsingAlreadyWrittenMesh : only umesh in input field supported !"); diff --git a/src/MEDLoader/MEDLoader.hxx b/src/MEDLoader/MEDLoader.hxx index 5e7187a19..1f0a7b130 100644 --- a/src/MEDLoader/MEDLoader.hxx +++ b/src/MEDLoader/MEDLoader.hxx @@ -35,6 +35,7 @@ namespace ParaMEDMEM class MEDCouplingMesh; class MEDCouplingUMesh; class MEDCouplingFieldDouble; + class MEDFileWritable; } class MEDLOADER_EXPORT MEDLoader @@ -97,6 +98,8 @@ class MEDLOADER_EXPORT MEDLoader static void WriteField(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f, bool writeFromScratch); static void WriteFieldDep(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f, bool writeFromScratch); static void WriteFieldUsingAlreadyWrittenMesh(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f); + public: + static void AssignStaticWritePropertiesTo(ParaMEDMEM::MEDFileWritable& obj); private: MEDLoader(); public: diff --git a/src/MEDLoader/SauvMedConvertor.cxx b/src/MEDLoader/SauvMedConvertor.cxx index 8578ffb7a..ad16d610a 100644 --- a/src/MEDLoader/SauvMedConvertor.cxx +++ b/src/MEDLoader/SauvMedConvertor.cxx @@ -3274,7 +3274,7 @@ void IntermediateMED::setFields( SauvUtilities::DoubleField* fld, ParaMEDMEM::MEDFileFields* medFields, ParaMEDMEM::MEDFileUMesh* mesh, const TID castemID, - std::set< std::string >& usedFieldNames) + std::set< std::string >& usedFieldNames) { bool sameNbGauss = true; if ( !fld || !fld->isMedCompatible( sameNbGauss )) return; diff --git a/src/MEDLoader/SauvReader.cxx b/src/MEDLoader/SauvReader.cxx index 428658fc2..7c76e36cb 100644 --- a/src/MEDLoader/SauvReader.cxx +++ b/src/MEDLoader/SauvReader.cxx @@ -642,7 +642,8 @@ void SauvReader::read_PILE_COORDONNEES (const int nbObjects, std::vector& supports) +void SauvReader::setFieldSupport(const vector& supports, + SauvUtilities::DoubleField* field) { SauvUtilities::Group* group = NULL; set sup_set( supports.begin(), supports.end() ); @@ -652,19 +653,31 @@ SauvUtilities::Group* SauvReader::getFieldSupport(const vector_groups.size() && !group; ++i ) + // check if sub-components are on cells of different types + map nbGaussByCellType; + for ( size_t i = 0; i < supports.size(); ++i ) { - Group & grp = _iMed->_groups[i]; - if (sup_set.size() == grp._groups.size()) - { - bool sameOrder = true; - for ( size_t j = 0; j < supports.size() && sameOrder; ++j ) - sameOrder = ( supports[j] == grp._groups[ j % grp._groups.size() ]); - if ( sameOrder ) - group = & _iMed->_groups[i]; - } + map::iterator ct2ng = nbGaussByCellType.find( supports[i]->_cellType ); + if ( ct2ng == nbGaussByCellType.end() ) + nbGaussByCellType[ supports[i]->_cellType ] = field->_sub[i].nbGauss(); + else if ( ct2ng->second != field->_sub[i].nbGauss() ) + return; } + bool isSameCellType = ( nbGaussByCellType.size() == 1 ); + // try to find an existing composite group with the same sub-groups + if ( isSameCellType ) + for ( size_t i = 0; i < _iMed->_groups.size() && !group; ++i ) + { + Group & grp = _iMed->_groups[i]; + if (sup_set.size() == grp._groups.size()) + { + bool sameOrder = true; + for ( size_t j = 0; j < supports.size() && sameOrder; ++j ) + sameOrder = ( supports[j] == grp._groups[ j % grp._groups.size() ]); + if ( sameOrder ) + group = & _iMed->_groups[i]; + } + } if ( !group ) // no such a group, add a new one { vector newGroups( supports.begin(), @@ -680,15 +693,67 @@ SauvUtilities::Group* SauvReader::getFieldSupport(const vector_groups.swap( newGroups ); } } + // sort field sub-components and supports by cell type + if ( group && !isSameCellType ) + { + // sort groups + vector& groups = group->_groups; + bool isModified = false, isSwapped = true; + while ( isSwapped ) + { + isSwapped = false; + for ( size_t i = 1; i < groups.size(); ++i ) + { + int nbN1 = groups[i-1]->empty() ? 0 : groups[i-1]->_cells[0]->_nodes.size(); + int nbN2 = groups[i ]->empty() ? 0 : groups[i ]->_cells[0]->_nodes.size(); + if ( nbN1 > nbN2 ) + { + isSwapped = isModified = true; + std::swap( groups[i], groups[i-1] ); + } + } + } + // relocate sub-components according to a new order of groups + if ( isModified ) + { + vector< DoubleField::_Sub_data > newSub( field->_sub.size() ); + vector< vector< double > > newValues( field->_comp_values.size() ); + size_t iFromSub = 0, iNewSub = 0, iNewComp = 0; + for ( ; iFromSub < field->_sub.size(); iFromSub += groups.size() ) + { + size_t iFromComp = iNewComp; + for ( size_t iG = 0; iG < groups.size(); ++iG ) + { + size_t iComp = iFromComp; + for ( size_t iSub = iFromSub; iSub < field->_sub.size(); ++iSub ) + if ( field->_sub[ iSub ]._support == groups[ iG ] ) + { + newSub[ iNewSub++ ] = field->_sub[ iSub ]; + int iC = 0, nbC = field->_sub[ iSub ].nbComponents(); + for ( ; iC < nbC; ++iC ) + newValues[ iNewComp++ ].swap( field->_comp_values[ iComp++ ]); + break; + } + else + { + iComp += field->_sub[ iSub ].nbComponents(); + } + } + } + field->_sub.swap( newSub ); + field->_comp_values.swap( newValues ); + } + } } if ( group ) group->_isProfile = true; - return group; + + field->_group = group; } //================================================================================ /*! - * \brief set field names + * \brief Set field names */ //================================================================================ @@ -813,7 +878,7 @@ void SauvReader::read_PILE_NODES_FIELD (const int nbObjects, // set a supporting group including all subs supports but only // if all subs have the same components if ( fdouble && fdouble->hasSameComponentsBySupport() ) - fdouble->_group = getFieldSupport( supports ); + setFieldSupport( supports, fdouble ); else for ( i_sub = 0; i_sub < nb_sub; ++i_sub ) fdouble->_sub[ i_sub ]._support->_isProfile = true; @@ -983,7 +1048,7 @@ void SauvReader::read_PILE_FIELD (const int nbObjects, // set id of a group including all sub supports but only // if all subs have the same nb of components if ( fdouble && fdouble->hasSameComponentsBySupport() ) - fdouble->_group = getFieldSupport( supports ); + setFieldSupport( supports, fdouble ); else for ( i_sub = 0; i_sub < nb_sub; ++i_sub ) fdouble->_sub[ i_sub ]._support->_isProfile = true; diff --git a/src/MEDLoader/SauvReader.hxx b/src/MEDLoader/SauvReader.hxx index abf232a05..cb7b7e6b6 100644 --- a/src/MEDLoader/SauvReader.hxx +++ b/src/MEDLoader/SauvReader.hxx @@ -72,7 +72,8 @@ class SauvReader : public ParaMEDMEM::RefCountObject void read_PILE_MODL (const int nbObjects, std::vector& objectNames, std::vector& nameIndices); void read_PILE_FIELD (const int nbObjects, std::vector& objectNames, std::vector& nameIndices); - SauvUtilities::Group* getFieldSupport(const std::vector& fieldSupports); + void setFieldSupport(const std::vector& supports, + SauvUtilities::DoubleField* field); void setFieldNames(const std::vector& fields, const std::vector& objectNames, const std::vector& nameIndices); diff --git a/src/MEDLoader/SauvWriter.cxx b/src/MEDLoader/SauvWriter.cxx index 697847bb6..6478c2bbe 100644 --- a/src/MEDLoader/SauvWriter.cxx +++ b/src/MEDLoader/SauvWriter.cxx @@ -212,11 +212,9 @@ namespace } } -//================================================================================ -/*! - * \brief Creates SauvWriter - */ -//================================================================================ +SauvWriter::SauvWriter():_cpy_grp_if_on_single_family(false) +{ +} SauvWriter* SauvWriter::New() { @@ -233,6 +231,16 @@ std::vector SauvWriter::getDirectChildren() const return std::vector(); } +void SauvWriter::setCpyGrpIfOnASingleFamilyStatus(bool status) +{ + _cpy_grp_if_on_single_family=status; +} + +bool SauvWriter::getCpyGrpIfOnASingleFamilyStatus() const +{ + return _cpy_grp_if_on_single_family; +} + //================================================================================ /*! * \brief Fills own DS by MEDFileData @@ -447,7 +455,23 @@ void SauvWriter::fillGroupSubMeshes() if (k != famNames.size()) famSubMeshes.resize(k); SubMesh* grpSubMesh = addSubMesh( groupName, famSubMeshes[0]->_dimRelExt ); - grpSubMesh->_subs.swap( famSubMeshes ); + if(!_cpy_grp_if_on_single_family) + grpSubMesh->_subs.swap( famSubMeshes ); + else + { + /* If a group sub mesh consists of only one family, the group is written as + * a copy of this family. + * A mesh composed of only one submesh may cause an issue with some Gibi operators.*/ + if (famSubMeshes.size() == 1) + { + for(int i = 0; i < famSubMeshes[0]->cellIDsByTypeSize() ; i++) + { + grpSubMesh->_cellIDsByType[i] = famSubMeshes[0]->_cellIDsByType[i]; + } + } + else + grpSubMesh->_subs.swap( famSubMeshes ); + } } } diff --git a/src/MEDLoader/SauvWriter.hxx b/src/MEDLoader/SauvWriter.hxx index d6e732c1c..bbbdce98d 100644 --- a/src/MEDLoader/SauvWriter.hxx +++ b/src/MEDLoader/SauvWriter.hxx @@ -46,11 +46,13 @@ namespace ParaMEDMEM class SauvWriter : public ParaMEDMEM::RefCountObject { public: - MEDLOADER_EXPORT static SauvWriter * New(); + MEDLOADER_EXPORT static SauvWriter *New(); MEDLOADER_EXPORT void setMEDFileDS(const MEDFileData* medData, unsigned meshIndex = 0); MEDLOADER_EXPORT void write(const char* fileName); - + MEDLOADER_EXPORT void setCpyGrpIfOnASingleFamilyStatus(bool status); + MEDLOADER_EXPORT bool getCpyGrpIfOnASingleFamilyStatus() const; private: + SauvWriter(); std::size_t getHeapMemorySizeWithoutChildren() const; std::vector getDirectChildren() const; /*! @@ -109,6 +111,7 @@ namespace ParaMEDMEM std::vector _longNames[ LN_NB ]; std::fstream* _sauvFile; + bool _cpy_grp_if_on_single_family; }; } diff --git a/src/MEDLoader/Swig/CMakeLists.txt b/src/MEDLoader/Swig/CMakeLists.txt index c011c3ce4..2ee412614 100644 --- a/src/MEDLoader/Swig/CMakeLists.txt +++ b/src/MEDLoader/Swig/CMakeLists.txt @@ -69,10 +69,22 @@ INSTALL(FILES sauv2med PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EX INSTALL(FILES case2med PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ DESTINATION ${SALOME_INSTALL_BINS} ) INSTALL(FILES med2case PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ DESTINATION ${SALOME_INSTALL_BINS} ) +SALOME_GENERATE_TESTS_ENVIRONMENT(tests_env) + ADD_TEST(MEDLoaderTest ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/MEDLoaderTest.py) +SET_TESTS_PROPERTIES(MEDLoaderTest PROPERTIES ENVIRONMENT "${tests_env}") ADD_TEST(MEDLoaderTest2 ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/MEDLoaderTest2.py) +SET_TESTS_PROPERTIES(MEDLoaderTest2 PROPERTIES ENVIRONMENT "${tests_env}") ADD_TEST(MEDLoaderTest3 ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/MEDLoaderTest3.py) +SET_TESTS_PROPERTIES(MEDLoaderTest3 PROPERTIES ENVIRONMENT "${tests_env}") ADD_TEST(MEDLoaderTest4 ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/MEDLoaderTest4.py) +SET_TESTS_PROPERTIES(MEDLoaderTest4 PROPERTIES ENVIRONMENT "${tests_env}") ADD_TEST(MEDLoaderExamplesTest ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/MEDLoaderExamplesTest.py) +SET_TESTS_PROPERTIES(MEDLoaderExamplesTest PROPERTIES ENVIRONMENT "${tests_env}") ADD_TEST(SauvLoaderTest ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/SauvLoaderTest.py) -ADD_TEST(MEDLoaderCouplingTrainingSession ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/MEDLoaderCouplingTrainingSession.py) +SET_TESTS_PROPERTIES(SauvLoaderTest PROPERTIES ENVIRONMENT "${tests_env}") + +IF(NUMPY_FOUND) + ADD_TEST(MEDLoaderCouplingTrainingSession ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/MEDLoaderCouplingTrainingSession.py) + SET_TESTS_PROPERTIES(MEDLoaderCouplingTrainingSession PROPERTIES ENVIRONMENT "${tests_env}") +ENDIF(NUMPY_FOUND) diff --git a/src/MEDLoader/Swig/MEDLoaderCommon.i b/src/MEDLoader/Swig/MEDLoaderCommon.i index 7d915e52a..06607db5e 100644 --- a/src/MEDLoader/Swig/MEDLoaderCommon.i +++ b/src/MEDLoader/Swig/MEDLoaderCommon.i @@ -105,6 +105,8 @@ using namespace ParaMEDMEM; %newobject ParaMEDMEM::MEDFileUMesh::getLevelM2Mesh; %newobject ParaMEDMEM::MEDFileUMesh::getLevelM3Mesh; %newobject ParaMEDMEM::MEDFileUMesh::getDirectUndergroundSingleGeoTypeMesh; +%newobject ParaMEDMEM::MEDFileUMesh::extractFamilyFieldOnGeoType; +%newobject ParaMEDMEM::MEDFileUMesh::extractNumberFieldOnGeoType; %newobject ParaMEDMEM::MEDFileUMesh::zipCoords; %newobject ParaMEDMEM::MEDFileCMesh::New; %newobject ParaMEDMEM::MEDFileCurveLinearMesh::New; @@ -237,6 +239,7 @@ public: static std::vector GetCellFieldNamesOnMesh(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception); static std::vector GetNodeFieldNamesOnMesh(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception); static double GetTimeAttachedOnFieldIteration(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception); + static void AssignStaticWritePropertiesTo(ParaMEDMEM::MEDFileWritable& obj) throw(INTERP_KERNEL::Exception); %extend { static PyObject *MEDFileVersion() @@ -508,6 +511,9 @@ namespace ParaMEDMEM virtual void createGroupOnAll(int meshDimRelToMaxExt, const char *groupName) throw(INTERP_KERNEL::Exception); virtual bool keepFamIdsOnlyOnLevs(const std::vector& famIds, const std::vector& levs) throw(INTERP_KERNEL::Exception); void copyFamGrpMapsFrom(const MEDFileMesh& other) throw(INTERP_KERNEL::Exception); + void clearGrpMap() throw(INTERP_KERNEL::Exception); + void clearFamMap() throw(INTERP_KERNEL::Exception); + void clearFamGrpMaps() throw(INTERP_KERNEL::Exception); const std::map& getFamilyInfo() const throw(INTERP_KERNEL::Exception); const std::map >& getGroupInfo() const throw(INTERP_KERNEL::Exception); std::vector getFamiliesOnGroup(const char *name) const throw(INTERP_KERNEL::Exception); @@ -723,6 +729,7 @@ namespace ParaMEDMEM MEDCouplingUMesh *getLevelM1Mesh(bool renum=false) const throw(INTERP_KERNEL::Exception); MEDCouplingUMesh *getLevelM2Mesh(bool renum=false) const throw(INTERP_KERNEL::Exception); MEDCouplingUMesh *getLevelM3Mesh(bool renum=false) const throw(INTERP_KERNEL::Exception); + void forceComputationOfParts() const throw(INTERP_KERNEL::Exception); // void setFamilyNameAttachedOnId(int id, const std::string& newFamName) throw(INTERP_KERNEL::Exception); void setCoords(DataArrayDouble *coords) throw(INTERP_KERNEL::Exception); @@ -734,6 +741,8 @@ namespace ParaMEDMEM void setMeshAtLevel(int meshDimRelToMax, MEDCouplingUMesh *m, bool newOrOld=false) throw(INTERP_KERNEL::Exception); void optimizeFamilies() throw(INTERP_KERNEL::Exception); DataArrayInt *zipCoords() throw(INTERP_KERNEL::Exception); + DataArrayInt *extractFamilyFieldOnGeoType(INTERP_KERNEL::NormalizedCellType gt) const throw(INTERP_KERNEL::Exception); + DataArrayInt *extractNumberFieldOnGeoType(INTERP_KERNEL::NormalizedCellType gt) const throw(INTERP_KERNEL::Exception); %extend { MEDFileUMesh(const char *fileName, const char *mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception) @@ -750,6 +759,16 @@ namespace ParaMEDMEM { return MEDFileUMesh::New(); } + + PyObject *getGeoTypesAtLevel(int meshDimRelToMax) const throw(INTERP_KERNEL::Exception) + { + std::vector result(self->getGeoTypesAtLevel(meshDimRelToMax)); + std::vector::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 *getRevNumberFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception) { @@ -2800,6 +2819,13 @@ namespace ParaMEDMEM public: static SauvReader* New(const char *fileName) throw(INTERP_KERNEL::Exception); MEDFileData * loadInMEDFileDS() throw(INTERP_KERNEL::Exception); + %extend + { + SauvReader(const char *fileName) throw(INTERP_KERNEL::Exception) + { + return SauvReader::New(fileName); + } + } }; class SauvWriter : public RefCountObject @@ -2808,6 +2834,15 @@ namespace ParaMEDMEM static SauvWriter * New(); void setMEDFileDS(const MEDFileData* medData, unsigned meshIndex = 0) throw(INTERP_KERNEL::Exception); void write(const char* fileName) throw(INTERP_KERNEL::Exception); + void setCpyGrpIfOnASingleFamilyStatus(bool status) throw(INTERP_KERNEL::Exception); + bool getCpyGrpIfOnASingleFamilyStatus() const throw(INTERP_KERNEL::Exception); + %extend + { + SauvWriter() throw(INTERP_KERNEL::Exception) + { + return SauvWriter::New(); + } + } }; /////////////// @@ -2835,6 +2870,61 @@ namespace ParaMEDMEM DataArray *buildDataArray(const MEDFileField1TSStructItem& fst, const MEDFileFieldGlobsReal *globs, const DataArray *vals) const throw(INTERP_KERNEL::Exception); protected: ~MEDMeshMultiLev(); + public: + %extend + { + PyObject *retrieveFamilyIdsOnCells() const throw(INTERP_KERNEL::Exception) + { + DataArrayInt *famIds(0); + bool isWithoutCopy(false); + self->retrieveFamilyIdsOnCells(famIds,isWithoutCopy); + PyObject *ret=PyTuple_New(2); + PyObject *ret1Py=isWithoutCopy?Py_True:Py_False; + Py_XINCREF(ret1Py); + PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(famIds),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,1,ret1Py); + return ret; + } + + PyObject *retrieveNumberIdsOnCells() const throw(INTERP_KERNEL::Exception) + { + DataArrayInt *numIds(0); + bool isWithoutCopy(false); + self->retrieveNumberIdsOnCells(numIds,isWithoutCopy); + PyObject *ret=PyTuple_New(2); + PyObject *ret1Py=isWithoutCopy?Py_True:Py_False; + Py_XINCREF(ret1Py); + PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(numIds),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,1,ret1Py); + return ret; + } + + PyObject *retrieveFamilyIdsOnNodes() const throw(INTERP_KERNEL::Exception) + { + DataArrayInt *famIds(0); + bool isWithoutCopy(false); + self->retrieveFamilyIdsOnNodes(famIds,isWithoutCopy); + PyObject *ret=PyTuple_New(2); + PyObject *ret1Py=isWithoutCopy?Py_True:Py_False; + Py_XINCREF(ret1Py); + PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(famIds),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,1,ret1Py); + return ret; + } + + PyObject *retrieveNumberIdsOnNodes() const throw(INTERP_KERNEL::Exception) + { + DataArrayInt *numIds(0); + bool isWithoutCopy(false); + self->retrieveNumberIdsOnNodes(numIds,isWithoutCopy); + PyObject *ret=PyTuple_New(2); + PyObject *ret1Py=isWithoutCopy?Py_True:Py_False; + Py_XINCREF(ret1Py); + PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(numIds),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,1,ret1Py); + return ret; + } + } }; class MEDUMeshMultiLev : public MEDMeshMultiLev @@ -2847,14 +2937,17 @@ namespace ParaMEDMEM PyObject *buildVTUArrays() const throw(INTERP_KERNEL::Exception) { DataArrayDouble *coords(0); DataArrayByte *types(0); DataArrayInt *cellLocations(0),*cells(0),*faceLocations(0),*faces(0); - self->buildVTUArrays(coords,types,cellLocations,cells,faceLocations,faces); - PyObject *ret=PyTuple_New(6); - PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(coords),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, SWIG_POINTER_OWN | 0 )); - PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(types),SWIGTYPE_p_ParaMEDMEM__DataArrayByte, SWIG_POINTER_OWN | 0 )); - PyTuple_SetItem(ret,2,SWIG_NewPointerObj(SWIG_as_voidptr(cellLocations),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); - PyTuple_SetItem(ret,3,SWIG_NewPointerObj(SWIG_as_voidptr(cells),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); - PyTuple_SetItem(ret,4,SWIG_NewPointerObj(SWIG_as_voidptr(faceLocations),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); - PyTuple_SetItem(ret,5,SWIG_NewPointerObj(SWIG_as_voidptr(faces),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + bool ncc(self->buildVTUArrays(coords,types,cellLocations,cells,faceLocations,faces)); + PyObject *ret0Py=ncc?Py_True:Py_False; + Py_XINCREF(ret0Py); + PyObject *ret=PyTuple_New(7); + PyTuple_SetItem(ret,0,ret0Py); + PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(coords),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,2,SWIG_NewPointerObj(SWIG_as_voidptr(types),SWIGTYPE_p_ParaMEDMEM__DataArrayByte, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,3,SWIG_NewPointerObj(SWIG_as_voidptr(cellLocations),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,4,SWIG_NewPointerObj(SWIG_as_voidptr(cells),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,5,SWIG_NewPointerObj(SWIG_as_voidptr(faceLocations),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,6,SWIG_NewPointerObj(SWIG_as_voidptr(faces),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); return ret; } } diff --git a/src/MEDLoader/Swig/MEDLoaderCouplingTrainingSession.py b/src/MEDLoader/Swig/MEDLoaderCouplingTrainingSession.py index 399e200dd..6f219b438 100644 --- a/src/MEDLoader/Swig/MEDLoaderCouplingTrainingSession.py +++ b/src/MEDLoader/Swig/MEDLoaderCouplingTrainingSession.py @@ -21,7 +21,7 @@ from MEDLoader import * from MEDCouplingRemapper import * -import math +import math, os d=DataArrayDouble.New(6,2) d[:,0]=3. diff --git a/src/MEDLoader/Swig/MEDLoaderDataForTest.py b/src/MEDLoader/Swig/MEDLoaderDataForTest.py index 22e8cfc28..8a0aee21c 100644 --- a/src/MEDLoader/Swig/MEDLoaderDataForTest.py +++ b/src/MEDLoader/Swig/MEDLoaderDataForTest.py @@ -657,6 +657,55 @@ class MEDLoaderDataForTest: # data=MEDFileData() ; data.setMeshes(ms) ; data.setFields(fs) return data + + def buildAMEDFileDataWithGroupOnOneFamilyForSauv(self): + # Coordinates + coords = [0.,0., 0.,1., 1.,1., 1.,0.] + # lvl 0 connectivity + conn2D = [1,2,3,4] + # lvl -1 connectivity + conn1D = [0,1, 1,2, 2,3, 4,1] + # lvl 0 mesh + mesh2D=MEDCouplingUMesh.New() + mesh2D.setMeshDimension(2) + mesh2D.allocateCells(1) + mesh2D.insertNextCell(NORM_QUAD4,4,conn2D) + mesh2D.finishInsertingCells() + # lvl -1 mesh + mesh1D=MEDCouplingUMesh.New() + mesh1D.setMeshDimension(1) + mesh1D.allocateCells(4) + mesh1D.insertNextCell(NORM_SEG2,2,conn1D[0:2]) + mesh1D.insertNextCell(NORM_SEG2,2,conn1D[2:4]) + mesh1D.insertNextCell(NORM_SEG2,2,conn1D[4:6]) + mesh1D.insertNextCell(NORM_SEG2,2,conn1D[6:8]) + mesh1D.finishInsertingCells() + # assigning coordinates + meshCoords=DataArrayDouble.New() + meshCoords.setValues(coords, 4, 2) + mesh2D.setCoords(meshCoords) + mesh1D.setCoords(meshCoords) + # Creating a multi level mesh + mm = MEDFileUMesh.New() + mm.setMeshAtLevel(0, mesh2D) + mm.setMeshAtLevel(-1, mesh1D) + mm.setName("carre") + # Creating groups + # Creating a group with an element on level -1 + grp0_LM1 = DataArrayInt.New([0]) + grp0_LM1.setName("grp0_LM1") + # Creating a group with all elements on level -1 + grp1_LM1 = DataArrayInt.New([0,1,2,3]) + grp1_LM1.setName("grp1_LM1") + # + mm.setGroupsAtLevel(-1,[grp0_LM1,grp1_LM1]) + # + ms=MEDFileMeshes.New() + ms.setMeshAtPos(0,mm) + mfd=MEDFileData.New() + mfd.setMeshes(ms) + # + return mfd build1DMesh_1=classmethod(build1DMesh_1) build2DCurveMesh_1=classmethod(build2DCurveMesh_1) @@ -675,4 +724,5 @@ class MEDLoaderDataForTest: buildVecFieldOnGauss_2_Simpler=classmethod(buildVecFieldOnGauss_2_Simpler) buildVecFieldOnGaussNE_1=classmethod(buildVecFieldOnGaussNE_1) buildACompleteMEDDataStructureWithFieldsOnCells_1=classmethod(buildACompleteMEDDataStructureWithFieldsOnCells_1) + buildAMEDFileDataWithGroupOnOneFamilyForSauv=classmethod(buildAMEDFileDataWithGroupOnOneFamilyForSauv) pass diff --git a/src/MEDLoader/Swig/MEDLoaderExamplesTest.py b/src/MEDLoader/Swig/MEDLoaderExamplesTest.py index 861f614d1..bcf070846 100644 --- a/src/MEDLoader/Swig/MEDLoaderExamplesTest.py +++ b/src/MEDLoader/Swig/MEDLoaderExamplesTest.py @@ -21,6 +21,7 @@ from MEDLoader import * import unittest +import os class MEDLoaderBasicsTest(unittest.TestCase): def testExampleReadFieldOnAllEntity1(self): diff --git a/src/MEDLoader/Swig/MEDLoaderTest.py b/src/MEDLoader/Swig/MEDLoaderTest.py index 344023135..441ee6610 100644 --- a/src/MEDLoader/Swig/MEDLoaderTest.py +++ b/src/MEDLoader/Swig/MEDLoaderTest.py @@ -658,6 +658,58 @@ class MEDLoaderTest(unittest.TestCase): self.assertTrue(m0.isEqual(mRead,1e-12)) pass + def testChangeGroupName(self): + """ This test is a non regression test on MEDFileUMesh.changeGroupName thanks to Alliance. + """ + mfd=MEDLoaderDataForTest.buildAMEDFileDataWithGroupOnOneFamilyForSauv() + mesh = mfd.getMeshes().getMeshAtPos(0) + mesh.changeGroupName("grp0_LM1", "xonall1") + self.assertTrue("xonall1" in mesh.getGroupsNames()) + pass + + def testFieldWithTooLongName(self): + """ This test is a non regression test, to check that in basic API the policies are taken into account. + """ + fname="Pyfile75.med" + # Coordinates + coords = [0.,0., 0.,1., 1.,1., 1.,0.] + # lvl 0 connectivity + conn2D = [1,2,3,4] + # lvl 0 mesh + m=MEDLoader.MEDCouplingUMesh.New("mesh",2) + m.allocateCells(1) + m.insertNextCell(MEDLoader.NORM_QUAD4,4,conn2D) + m.finishInsertingCells() + # assigning coordinates + meshCoords=MEDLoader.DataArrayDouble.New() + meshCoords.setValues(coords, 4, 2) + m.setCoords(meshCoords) + # + f=MEDLoader.MEDCouplingFieldDouble.New(MEDLoader.ON_CELLS,MEDLoader.ONE_TIME) + f.setMesh(m) + d=MEDLoader.DataArrayDouble.New() + d.alloc(1,1) + d.iota(1.) + # seting a long name + d.setInfoOnComponent(0,"CONCENTRATION of I129") + f.setArray(d) + f.setName("field") + # + mm=MEDLoader.MEDFileUMesh() + MEDLoader.MEDLoader.SetTooLongStrPolicy(2) + MEDLoader.MEDLoader.AssignStaticWritePropertiesTo(mm) + self.assertEqual(2,mm.getTooLongStrPolicy()) + MEDLoader.MEDLoader.SetTooLongStrPolicy(0) + MEDLoader.MEDLoader.AssignStaticWritePropertiesTo(mm) + self.assertEqual(0,mm.getTooLongStrPolicy()) + del mm + # + MEDLoader.MEDLoader.SetTooLongStrPolicy(2) + self.assertRaises(MEDLoader.InterpKernelException,MEDLoader.MEDLoader.WriteField,fname,f,True)# the component name is too long + policy 2 -> throw + f.getArray().setInfoOnComponent(0,'I129') + MEDLoader.MEDLoader.WriteField(fname,f,True) + pass + pass unittest.main() diff --git a/src/MEDLoader/Swig/MEDLoaderTest3.py b/src/MEDLoader/Swig/MEDLoaderTest3.py index 21654c9d0..2d49e5ed3 100644 --- a/src/MEDLoader/Swig/MEDLoaderTest3.py +++ b/src/MEDLoader/Swig/MEDLoaderTest3.py @@ -173,6 +173,9 @@ class MEDLoaderTest(unittest.TestCase): # mm=MEDFileMesh.New(outFileName) # + self.assertEqual([NORM_TRI3,NORM_QUAD4,NORM_POLYGON],mm.getGeoTypesAtLevel(0)) + self.assertEqual([NORM_SEG2,NORM_SEG3],mm.getGeoTypesAtLevel(-1)) + self.assertEqual([NORM_POINT1],mm.getGeoTypesAtLevel(-2)) mm0=mm.getDirectUndergroundSingleGeoTypeMesh(NORM_POLYGON) self.assertTrue(isinstance(mm0,MEDCoupling1DGTUMesh)) self.assertTrue(mm0.getNodalConnectivity().isEqual(DataArrayInt([6,7,4,3,7,8,5,4]))) diff --git a/src/MEDLoader/Swig/MEDLoaderTest4.py b/src/MEDLoader/Swig/MEDLoaderTest4.py index 71b025dd3..f71305882 100644 --- a/src/MEDLoader/Swig/MEDLoaderTest4.py +++ b/src/MEDLoader/Swig/MEDLoaderTest4.py @@ -50,6 +50,10 @@ class MEDLoaderTest4(unittest.TestCase): m.setName("mesh") ; m.getCoords().setInfoOnComponents(["XX [m]","YYY [km]"]) m1=m.buildDescendingConnectivity()[0] mm=MEDFileUMesh() ; mm.setMeshes([m,m1]) + fam=DataArrayInt(9) ; fam.iota(0) ; mm.setFamilyFieldArr(0,fam) + fam=DataArrayInt(32) ; fam.iota(20) ; mm.setFamilyFieldArr(-1,fam) ; del fam + num=DataArrayInt(9) ; num.iota(100) ; mm.setRenumFieldArr(0,num) + num=DataArrayInt(32) ; num.iota(120) ; mm.setRenumFieldArr(-1,num) ; del num # fieldName="zeField" fs=MEDFileFieldMultiTS() @@ -175,13 +179,20 @@ class MEDLoaderTest4(unittest.TestCase): for i in xrange(1,5): self.assertTrue(fcscp.isDataSetSupportEqualToThePreviousOne(i,fields)) pass - a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() + ncc,a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() + self.assertTrue(not ncc) self.assertTrue(a0.isEqual(a0Exp.changeNbOfComponents(3,0.),1e-12)) self.assertTrue(a1.isEqual(DataArrayByte([3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,5,5,5,5,9,9,9,9,9]))) - self.assertTrue(a2.isEqual(DataArrayInt([2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,67,70,73,76,80,84,88,92,96]))) + self.assertTrue(a2.isEqual(DataArrayInt([0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57,60,63,66,69,72,75,78,81,84,87,90,93,96,100,104,108,112,117,122,127,132]))) self.assertTrue(a3.isEqual(DataArrayInt([2,0,1,2,1,2,2,2,0,2,3,4,2,4,5,2,5,3,2,6,7,2,7,8,2,8,6,2,9,10,2,10,11,2,11,9,2,12,13,2,13,14,2,14,15,2,15,12,2,16,17,2,17,18,2,18,19,2,19,16,2,20,21,2,21,22,2,22,23,2,23,20,2,24,25,2,25,26,2,26,27,2,27,24,2,28,29,2,29,30,2,30,31,2,31,28,3,0,1,2,3,3,4,5,3,6,7,8,3,9,10,11,4,12,13,14,15,4,16,17,18,19,4,20,21,22,23,4,24,25,26,27,4,28,29,30,31]))) self.assertTrue(a4 is None) self.assertTrue(a5 is None) + a6,a7=mml2.retrieveFamilyIdsOnCells() + self.assertTrue(a6.isEqual(DataArrayInt([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,0,1,2,3,4,5,6,7,8]))) + self.assertTrue(not a7) + a8,a9=mml2.retrieveNumberIdsOnCells() + self.assertTrue(a8.isEqual(DataArrayInt([120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,100,101,102,103,104,105,106,107,108]))) + self.assertTrue(not a9) for i in xrange(5): fsst=MEDFileField1TSStructItem.BuildItemFrom(fields[0][i],mst) fields[0][i].loadArraysIfNecessary() @@ -380,10 +391,11 @@ class MEDLoaderTest4(unittest.TestCase): for i in xrange(1,5): self.assertTrue(fcscp.isDataSetSupportEqualToThePreviousOne(i,fields)) pass - a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() + ncc,a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() + self.assertTrue(not ncc) self.assertTrue(a0.isEqual(a0Exp.changeNbOfComponents(3,0.),1e-12)) self.assertTrue(a1.isEqual(DataArrayByte([3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,5,5,5,5,9,9,9,9,9]))) - self.assertTrue(a2.isEqual(DataArrayInt([2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,67,70,73,76,80,84,88,92,96]))) + self.assertTrue(a2.isEqual(DataArrayInt([0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57,60,63,66,69,72,75,78,81,84,87,90,93,96,100,104,108,112,117,122,127,132]))) self.assertTrue(a3.isEqual(DataArrayInt([2,0,1,2,1,2,2,2,0,2,3,4,2,4,5,2,5,3,2,6,7,2,7,8,2,8,6,2,9,10,2,10,11,2,11,9,2,12,13,2,13,14,2,14,15,2,15,12,2,16,17,2,17,18,2,18,19,2,19,16,2,20,21,2,21,22,2,22,23,2,23,20,2,24,25,2,25,26,2,26,27,2,27,24,2,28,29,2,29,30,2,30,31,2,31,28,3,0,1,2,3,3,4,5,3,6,7,8,3,9,10,11,4,12,13,14,15,4,16,17,18,19,4,20,21,22,23,4,24,25,26,27,4,28,29,30,31]))) self.assertTrue(a4 is None) self.assertTrue(a5 is None) @@ -538,10 +550,11 @@ class MEDLoaderTest4(unittest.TestCase): for i in xrange(1,3): self.assertTrue(fcscp.isDataSetSupportEqualToThePreviousOne(i,fields)) pass - a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() + ncc,a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() + self.assertTrue(not ncc) self.assertTrue(a0.isEqual(a0Exp.changeNbOfComponents(3,0.),1e-12)) self.assertTrue(a1.isEqual(DataArrayByte([3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,5,5,5,5,9,9,9,9,9]))) - self.assertTrue(a2.isEqual(DataArrayInt([2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,67,70,73,76,80,84,88,92,96]))) + self.assertTrue(a2.isEqual(DataArrayInt([0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57,60,63,66,69,72,75,78,81,84,87,90,93,96,100,104,108,112,117,122,127,132]))) self.assertTrue(a3.isEqual(DataArrayInt([2,0,1,2,1,2,2,2,0,2,3,4,2,4,5,2,5,3,2,6,7,2,7,8,2,8,6,2,9,10,2,10,11,2,11,9,2,12,13,2,13,14,2,14,15,2,15,12,2,16,17,2,17,18,2,18,19,2,19,16,2,20,21,2,21,22,2,22,23,2,23,20,2,24,25,2,25,26,2,26,27,2,27,24,2,28,29,2,29,30,2,30,31,2,31,28,3,0,1,2,3,3,4,5,3,6,7,8,3,9,10,11,4,12,13,14,15,4,16,17,18,19,4,20,21,22,23,4,24,25,26,27,4,28,29,30,31]))) assert a4 is None assert a5 is None @@ -567,10 +580,11 @@ class MEDLoaderTest4(unittest.TestCase): for i in xrange(1,2): self.assertTrue(fcscp.isDataSetSupportEqualToThePreviousOne(i,fields)) pass - a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() + ncc,a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() + self.assertTrue(not ncc) self.assertTrue(a0.isEqual(a0Exp.changeNbOfComponents(3,0.),1e-12)) self.assertTrue(a1.isEqual(DataArrayByte([5,5,5,5,9,9,9,9,9]))) - self.assertTrue(a2.isEqual(DataArrayInt([3,6,9,12,16,20,24,28,32]))) + self.assertTrue(a2.isEqual(DataArrayInt([0,4,8,12,16,21,26,31,36]))) self.assertTrue(a3.isEqual(DataArrayInt([3,0,1,2,3,3,4,5,3,6,7,8,3,9,10,11,4,12,13,14,15,4,16,17,18,19,4,20,21,22,23,4,24,25,26,27,4,28,29,30,31]))) self.assertTrue(a4 is None) self.assertTrue(a5 is None) @@ -788,10 +802,11 @@ class MEDLoaderTest4(unittest.TestCase): for i in xrange(1,5): self.assertTrue(fcscp.isDataSetSupportEqualToThePreviousOne(i,fields)) pass - a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() + ncc,a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() + self.assertTrue(not ncc) self.assertTrue(a0.isEqual(a0Exp.changeNbOfComponents(3,0.),1e-12)) self.assertTrue(a1.isEqual(DataArrayByte([5,5,5,5,9,9,9,9,9]))) - self.assertTrue(a2.isEqual(DataArrayInt([3,6,9,12,16,20,24,28,32]))) + self.assertTrue(a2.isEqual(DataArrayInt([0,4,8,12,16,21,26,31,36]))) self.assertTrue(a3.isEqual(DataArrayInt([3,0,1,2,3,3,4,5,3,6,7,8,3,9,10,11,4,12,13,14,15,4,16,17,18,19,4,20,21,22,23,4,24,25,26,27,4,28,29,30,31]))) self.assertTrue(a4 is None) self.assertTrue(a5 is None) @@ -845,6 +860,8 @@ class MEDLoaderTest4(unittest.TestCase): m.insertNextCell(NORM_QUAD4,[0,5,6,1]) ; m.insertNextCell(NORM_QUAD4,[1,6,7,2]) ; m.insertNextCell(NORM_QUAD4,[5,10,11,6]) ; m.insertNextCell(NORM_QUAD4,[6,11,12,7]) m.insertNextCell(NORM_QUAD4,[12,13,8,7]) mm=MEDFileUMesh() ; mm.setMeshes([m]) + fam=DataArrayInt(11) ; fam.iota(0) ; mm.setFamilyFieldArr(0,fam) ; del fam + num=DataArrayInt(11) ; num.iota(100) ; mm.setRenumFieldArr(0,num) ; del num # fieldName1="zeField1" ; pfl1=DataArrayInt([0,1,2,3,4,5]) ; pfl1.setName("pfl1") # on cells fieldName2="zeField2" ; pfl2=DataArrayInt([2,3,4,7,8,9,13,14]) ; pfl2.setName("pfl2") # on nodes @@ -911,13 +928,20 @@ class MEDLoaderTest4(unittest.TestCase): for i in xrange(1,5): self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))) pass - a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() + ncc,a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() + self.assertTrue(not ncc) self.assertTrue(a0.isEqual(a0Exp[pfl2].changeNbOfComponents(3,0.),1e-12)) self.assertTrue(a1.isEqual(DataArrayByte([5,5,5,5,5,5]))) - self.assertTrue(a2.isEqual(DataArrayInt([3,6,9,12,15,18]))) + self.assertTrue(a2.isEqual(DataArrayInt([0,4,8,12,16,20]))) self.assertTrue(a3.isEqual(DataArrayInt([3,0,3,1,3,3,4,1,3,1,4,2,3,4,5,2,3,6,5,4,3,6,7,5]))) assert a4 is None assert a5 is None + a6,a7=mml2.retrieveFamilyIdsOnCells() + self.assertTrue(a6.isEqual(DataArrayInt([0,1,2,3,4,5]))) + self.assertTrue(not a7) + a8,a9=mml2.retrieveNumberIdsOnCells() + self.assertTrue(a8.isEqual(DataArrayInt([100,101,102,103,104,105]))) + self.assertTrue(not a9) for i in xrange(5): nbOfT=[6,8] fieldNames=[fieldName1,fieldName2] @@ -941,13 +965,20 @@ class MEDLoaderTest4(unittest.TestCase): for i in xrange(1,5): self.assertTrue(fcscp.isDataSetSupportEqualToThePreviousOne(i,fields)) pass - a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() + ncc,a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() + self.assertTrue(not ncc) self.assertTrue(a0.isEqual(a0Exp.changeNbOfComponents(3,0.),1e-12)) self.assertTrue(a1.isEqual(DataArrayByte([5,5,5,5,5,5,9,9]))) - self.assertTrue(a2.isEqual(DataArrayInt([3,6,9,12,15,18,22,26]))) + self.assertTrue(a2.isEqual(DataArrayInt([0,4,8,12,16,20,24,29]))) self.assertTrue(a3.isEqual(DataArrayInt([3,2,7,3,3,7,8,3,3,3,8,4,3,8,9,4,3,13,9,8,3,13,14,9,4,6,11,12,7,4,12,13,8,7]))) self.assertTrue(a4 is None) self.assertTrue(a5 is None) + a6,a7=mml2.retrieveFamilyIdsOnCells() + self.assertTrue(a6.isEqual(DataArrayInt([0,1,2,3,4,5,9,10]))) + self.assertTrue(not a7) + a8,a9=mml2.retrieveNumberIdsOnCells() + self.assertTrue(a8.isEqual(DataArrayInt([100,101,102,103,104,105,109,110]))) + self.assertTrue(not a9) for i in xrange(5): f=allFMTSLeavesPerCommonSupport[1][0][0][i] fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst) @@ -969,6 +1000,9 @@ class MEDLoaderTest4(unittest.TestCase): coordsY=DataArrayDouble([0,1.7,3.4]) ; coordsY.setInfoOnComponents(["YYY [km]"]) m.setCoords(coordsX,coordsY) mm=MEDFileCMesh() ; mm.setMesh(m) + fam=DataArrayInt(8) ; fam.iota(0) ; mm.setFamilyFieldArr(0,fam) ; del fam + num=DataArrayInt(8) ; num.iota(100) ; mm.setRenumFieldArr(0,num) ; del num + num=DataArrayInt(15) ; num.iota(200) ; mm.setRenumFieldArr(1,num) ; del num # fieldName0="zeField0" ; # on cells fieldName1="zeField1" ; pfl1=DataArrayInt([2,3,6,7]) ; pfl1.setName("pfl1") # on cells @@ -1059,6 +1093,15 @@ class MEDLoaderTest4(unittest.TestCase): for i in xrange(1,5): self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))) pass + a6,a7=mml2.retrieveFamilyIdsOnCells() + self.assertTrue(a6.isEqual(DataArrayInt([0,1,2,3,4,5,6,7]))) + self.assertTrue(a7) # True because no copy + a8,a9=mml2.retrieveNumberIdsOnCells() + self.assertTrue(a8.isEqual(DataArrayInt([100,101,102,103,104,105,106,107]))) + self.assertTrue(a9) # True because no copy + a10,a11=mml2.retrieveNumberIdsOnNodes() + self.assertTrue(a10.isEqual(DataArrayInt([200,201,202,203,204,205,206,207,208,209,210,211,212,213,214]))) + self.assertTrue(a11) # True because no copy for i in xrange(5): f=allFMTSLeavesPerCommonSupport[0][0][0][i] fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst) @@ -1086,6 +1129,15 @@ class MEDLoaderTest4(unittest.TestCase): a,b=mml2.buildVTUArrays() self.assertTrue(a.isEqual(coordsX[[2,3,4]],1e-12)) self.assertTrue(b.isEqual(coordsY,1e-12)) + a6,a7=mml2.retrieveFamilyIdsOnCells() + self.assertTrue(a6.isEqual(DataArrayInt([2,3,6,7]))) + self.assertTrue(not a7) # False because copy + a8,a9=mml2.retrieveNumberIdsOnCells() + self.assertTrue(a8.isEqual(DataArrayInt([102,103,106,107]))) + self.assertTrue(not a9) # False because copy + a10,a11=mml2.retrieveNumberIdsOnNodes() + self.assertTrue(a10.isEqual(DataArrayInt([202,203,204,207,208,209,212,213,214]))) + self.assertTrue(not a11) # False because copy for i in xrange(1,5): self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))) pass @@ -1113,15 +1165,22 @@ class MEDLoaderTest4(unittest.TestCase): mml=fcscp.buildFromScratchDataSetSupport(0,fields) mml2=mml.prepare() self.assertTrue(isinstance(mml2,MEDUMeshMultiLev)) # here the 3rd support is a part of CMesh but impossible to simplify more than a UMesh - a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() + ncc,a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() + self.assertTrue(not ncc) a0Exp=DataArrayDouble([0.,0.,1.1,0.,2.2,0.,3.3,0.,4.4,0.,0.,1.7,1.1,1.7,2.2,1.7,3.3,1.7,4.4,1.7,0.,3.4,1.1,3.4,2.2,3.4,3.3,3.4,4.4,3.4],15,2) a0Exp.setInfoOnComponents(["XX [m]","YYY [km]"]) self.assertTrue(a0.isEqual(a0Exp.changeNbOfComponents(3,0.),1e-12)) self.assertTrue(a1.isEqual(DataArrayByte([9,9,9,9]))) - self.assertTrue(a2.isEqual(DataArrayInt([4,8,12,16]))) + self.assertTrue(a2.isEqual(DataArrayInt([0,5,10,15]))) self.assertTrue(a3.isEqual(DataArrayInt([4,3,2,7,8,4,4,3,8,9,4,7,6,11,12,4,9,8,13,14]))) self.assertTrue(a4 is None) self.assertTrue(a5 is None) + a6,a7=mml2.retrieveFamilyIdsOnCells() + self.assertTrue(a6.isEqual(DataArrayInt([2,3,5,7]))) + self.assertTrue(not a7) # False because copy + a8,a9=mml2.retrieveNumberIdsOnCells() + self.assertTrue(a8.isEqual(DataArrayInt([102,103,105,107]))) + self.assertTrue(not a9) # False because copy for i in xrange(5): f=allFMTSLeavesPerCommonSupport[2][0][0][i] fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst) @@ -1144,6 +1203,8 @@ class MEDLoaderTest4(unittest.TestCase): a0Exp.setInfoOnComponents(["XX [m]","YYY [km]"]) m.setCoords(a0Exp) mm=MEDFileCurveLinearMesh() ; mm.setMesh(m) + fam=DataArrayInt(8) ; fam.iota(0) ; mm.setFamilyFieldArr(0,fam) ; del fam + num=DataArrayInt(8) ; num.iota(100) ; mm.setRenumFieldArr(0,num) ; del num # fieldName0="zeField0" ; # on cells fieldName1="zeField1" ; pfl1=DataArrayInt([2,3,6,7]) ; pfl1.setName("pfl1") # on cells @@ -1231,6 +1292,12 @@ class MEDLoaderTest4(unittest.TestCase): a,b=mml2.buildVTUArrays() self.assertTrue(a.isEqual(a0Exp,1e-12)) self.assertEqual(b,[5,3]) + a6,a7=mml2.retrieveFamilyIdsOnCells() + self.assertTrue(a6.isEqual(DataArrayInt([0,1,2,3,4,5,6,7]))) + self.assertTrue(a7) # True because no copy + a8,a9=mml2.retrieveNumberIdsOnCells() + self.assertTrue(a8.isEqual(DataArrayInt([100,101,102,103,104,105,106,107]))) + self.assertTrue(a9) # True because no copy for i in xrange(1,5): self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))) pass @@ -1261,6 +1328,12 @@ class MEDLoaderTest4(unittest.TestCase): a,b=mml2.buildVTUArrays() self.assertTrue(a.isEqual(a0Exp[pfl2],1e-12)) self.assertEqual(b,[3,3]) + a6,a7=mml2.retrieveFamilyIdsOnCells() + self.assertTrue(a6.isEqual(DataArrayInt([2,3,6,7]))) + self.assertTrue(not a7) # False because copy + a8,a9=mml2.retrieveNumberIdsOnCells() + self.assertTrue(a8.isEqual(DataArrayInt([102,103,106,107]))) + self.assertTrue(not a9) # False because copy for i in xrange(1,5): self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))) pass @@ -1288,15 +1361,22 @@ class MEDLoaderTest4(unittest.TestCase): mml=fcscp.buildFromScratchDataSetSupport(0,fields) mml2=mml.prepare() self.assertTrue(isinstance(mml2,MEDUMeshMultiLev)) # here the 3rd support is a part of CMesh but impossible to simplify more than a UMesh - a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() + ncc,a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() + self.assertTrue(not ncc) a0Exp=DataArrayDouble([0.,0.,1.1,0.,2.2,0.,3.3,0.,4.4,0.,0.,1.7,1.1,1.7,2.2,1.7,3.3,1.7,4.4,1.7,0.,3.4,1.1,3.4,2.2,3.4,3.3,3.4,4.4,3.4],15,2) a0Exp.setInfoOnComponents(["XX [m]","YYY [km]"]) self.assertTrue(a0.isEqual(a0Exp.changeNbOfComponents(3,0.),1e-12)) self.assertTrue(a1.isEqual(DataArrayByte([9,9,9,9]))) - self.assertTrue(a2.isEqual(DataArrayInt([4,8,12,16]))) + self.assertTrue(a2.isEqual(DataArrayInt([0,5,10,15]))) self.assertTrue(a3.isEqual(DataArrayInt([4,3,2,7,8,4,4,3,8,9,4,7,6,11,12,4,9,8,13,14]))) self.assertTrue(a4 is None) self.assertTrue(a5 is None) + a6,a7=mml2.retrieveFamilyIdsOnCells() + self.assertTrue(a6.isEqual(DataArrayInt([2,3,5,7]))) + self.assertTrue(not a7) # False because copy + a8,a9=mml2.retrieveNumberIdsOnCells() + self.assertTrue(a8.isEqual(DataArrayInt([102,103,105,107]))) + self.assertTrue(not a9) # False because copy for i in xrange(5): f=allFMTSLeavesPerCommonSupport[2][0][0][i] fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst) @@ -1399,10 +1479,11 @@ class MEDLoaderTest4(unittest.TestCase): mml=fcscp.buildFromScratchDataSetSupport(0,fields) mml2=mml.prepare() self.assertTrue(isinstance(mml2,MEDUMeshMultiLev)) - a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() + ncc,a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() + self.assertTrue(not ncc) self.assertTrue(a0.isEqual(a0Exp.changeNbOfComponents(3,0.),1e-12)) self.assertTrue(a1.isEqual(DataArrayByte([5,5,5,5,5,5,9,9,9,9,9]))) - self.assertTrue(a2.isEqual(DataArrayInt([3,6,9,12,15,18,22,26,30,34,38]))) + self.assertTrue(a2.isEqual(DataArrayInt([0,4,8,12,16,20,24,29,34,39,44]))) self.assertTrue(a3.isEqual(DataArrayInt([3,2,7,3,3,7,8,3,3,3,8,4,3,8,9,4,3,13,9,8,3,13,14,9,4,0,5,6,1,4,1,6,7,2,4,5,10,11,6,4,6,11,12,7,4,12,13,8,7]))) self.assertTrue(a4 is None) self.assertTrue(a5 is None) @@ -1541,10 +1622,11 @@ class MEDLoaderTest4(unittest.TestCase): mml=fcscp.buildFromScratchDataSetSupport(0,fields) mml2=mml.prepare() self.assertTrue(isinstance(mml2,MEDUMeshMultiLev)) - a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() + ncc,a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() + self.assertTrue(not ncc) self.assertTrue(a0.isEqual(a0Exp[pfl2].changeNbOfComponents(3,0.),1e-12)) self.assertTrue(a1.isEqual(DataArrayByte([5,5,9,9,9]))) - self.assertTrue(a2.isEqual(DataArrayInt([3,6,10,14,18]))) + self.assertTrue(a2.isEqual(DataArrayInt([0,4,8,13,18]))) self.assertTrue(a3.isEqual(DataArrayInt([3,1,4,2,3,4,5,2,4,0,3,4,1,4,3,6,7,4,4,7,8,5,4]))) self.assertTrue(a4 is None) self.assertTrue(a5 is None) @@ -1668,10 +1750,11 @@ class MEDLoaderTest4(unittest.TestCase): mml=fcscp.buildFromScratchDataSetSupport(0,fields) mml2=mml.prepare() self.assertTrue(isinstance(mml2,MEDUMeshMultiLev)) - a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() + ncc,a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() + self.assertTrue(not ncc) self.assertTrue(a0.isEqual(a0Exp[pfl1].changeNbOfComponents(3,0.),1e-12)) self.assertTrue(a1.isEqual(DataArrayByte([5,5,9,9,9]))) - self.assertTrue(a2.isEqual(DataArrayInt([3,6,10,14,18]))) + self.assertTrue(a2.isEqual(DataArrayInt([0,4,8,13,18]))) self.assertTrue(a3.isEqual(DataArrayInt([3,1,4,2,3,4,5,2,4,0,3,4,1,4,3,6,7,4,4,7,8,5,4]))) self.assertTrue(a4 is None) self.assertTrue(a5 is None) @@ -1765,10 +1848,11 @@ class MEDLoaderTest4(unittest.TestCase): mml=fcscp.buildFromScratchDataSetSupport(0,fields) mml2=mml.prepare() self.assertTrue(isinstance(mml2,MEDUMeshMultiLev)) - a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() + ncc,a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() + self.assertTrue(not ncc) self.assertTrue(a0.isEqual(a0Exp.changeNbOfComponents(3,0.),1e-12)) self.assertTrue(a1.isEqual(DataArrayByte([9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9]))) - self.assertTrue(a2.isEqual(DataArrayInt([4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64]))) + self.assertTrue(a2.isEqual(DataArrayInt([0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75]))) self.assertTrue(a3.isEqual(DataArrayInt([4,1,0,5,6,4,3,2,7,8,4,4,3,8,9,4,6,5,10,11,4,9,8,13,14,4,19,18,23,24,4,2,1,6,7,4,7,6,11,12,4,11,10,15,16,4,12,11,16,17,4,8,7,12,13,4,13,12,17,18,4,17,16,21,22,4,14,13,18,19,4,16,15,20,21,4,18,17,22,23]))) # <- here the mesh is renumbered : the mesh is equal to m[[0,2,3,4,7,15, 1,5,8,9, 6,10,13, 11,12,14]] self.assertTrue(a4 is None) self.assertTrue(a5 is None) @@ -1854,10 +1938,11 @@ class MEDLoaderTest4(unittest.TestCase): mml=fcscp.buildFromScratchDataSetSupport(0,fields) mml2=mml.prepare() self.assertTrue(isinstance(mml2,MEDUMeshMultiLev)) - a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() + ncc,a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() + self.assertTrue(not ncc) self.assertTrue(a0.isEqual(a0Exp.changeNbOfComponents(3,0.),1e-12)) self.assertTrue(a1.isEqual(DataArrayByte([9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9]))) - self.assertTrue(a2.isEqual(DataArrayInt([4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64]))) + self.assertTrue(a2.isEqual(DataArrayInt([0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75]))) self.assertTrue(a3.isEqual(DataArrayInt([4,1,0,5,6,4,2,1,6,7,4,3,2,7,8,4,4,3,8,9,4,6,5,10,11,4,7,6,11,12,4,8,7,12,13,4,9,8,13,14,4,11,10,15,16,4,12,11,16,17,4,13,12,17,18,4,14,13,18,19,4,16,15,20,21,4,17,16,21,22,4,18,17,22,23,4,19,18,23,24]))) # <- here the mesh is NOT renumbered : the mesh is equal to m self.assertTrue(a4 is None) self.assertTrue(a5 is None) @@ -1967,10 +2052,11 @@ class MEDLoaderTest4(unittest.TestCase): mml=fcscp.buildFromScratchDataSetSupport(0,fields) mml2=mml.prepare() self.assertTrue(isinstance(mml2,MEDUMeshMultiLev)) - a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() + ncc,a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() + self.assertTrue(ncc) self.assertTrue(a0.isEqual(a0Exp,1e-12)) self.assertTrue(a1.isEqual(DataArrayByte([12,12,42,42,42]))) - self.assertTrue(a2.isEqual(DataArrayInt([8,16,24,32,40]))) + self.assertTrue(a2.isEqual(DataArrayInt([0,9,18,27,36]))) self.assertTrue(a3.isEqual(DataArrayInt([8,1,0,6,7,13,12,18,19,8,2,1,7,8,14,13,19,20,8,2,3,8,9,14,15,20,21,8,3,4,9,10,15,16,21,22,8,4,5,10,11,16,17,22,23]))) self.assertTrue(a4.isEqual(DataArrayInt([-1,-1,0,31,62]))) self.assertTrue(a5.isEqual(DataArrayInt([6,4,3,2,8,9,4,15,21,20,14,4,3,15,14,2,4,2,14,20,8,4,8,20,21,9,4,9,21,15,3,6,4,4,3,9,10,4,16,22,21,15,4,4,16,15,3,4,3,15,21,9,4,9,21,22,10,4,10,22,16,4,6,4,5,4,10,11,4,17,23,22,16,4,5,17,16,4,4,4,16,22,10,4,10,22,23,11,4,11,23,17,5]))) @@ -2002,10 +2088,11 @@ class MEDLoaderTest4(unittest.TestCase): mml=fcscp.buildFromScratchDataSetSupport(0,fields) mml2=mml.prepare() self.assertTrue(isinstance(mml2,MEDUMeshMultiLev)) - a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() + ncc,a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() + self.assertTrue(ncc) self.assertTrue(a0.isEqual(a0Exp,1e-12)) self.assertTrue(a1.isEqual(DataArrayByte([42,42]))) - self.assertTrue(a2.isEqual(DataArrayInt([8,16]))) + self.assertTrue(a2.isEqual(DataArrayInt([0,9]))) self.assertTrue(a3.isEqual(DataArrayInt([8,2,3,8,9,14,15,20,21,8,3,4,9,10,15,16,21,22]))) self.assertTrue(a4.isEqual(DataArrayInt([0,31]))) self.assertTrue(a5.isEqual(DataArrayInt([6,4,3,2,8,9,4,15,21,20,14,4,3,15,14,2,4,2,14,20,8,4,8,20,21,9,4,9,21,15,3,6,4,4,3,9,10,4,16,22,21,15,4,4,16,15,3,4,3,15,21,9,4,9,21,22,10,4,10,22,16,4]))) @@ -2028,10 +2115,11 @@ class MEDLoaderTest4(unittest.TestCase): mml=fcscp.buildFromScratchDataSetSupport(0,fields) mml2=mml.prepare() self.assertTrue(isinstance(mml2,MEDUMeshMultiLev)) - a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() + ncc,a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() + self.assertTrue(ncc) self.assertTrue(a0.isEqual(a0Exp,1e-12)) self.assertTrue(a1.isEqual(DataArrayByte([42,42,42]))) - self.assertTrue(a2.isEqual(DataArrayInt([8,16,24]))) + self.assertTrue(a2.isEqual(DataArrayInt([0,9,18]))) self.assertTrue(a3.isEqual(DataArrayInt([8,2,3,8,9,14,15,20,21,8,3,4,9,10,15,16,21,22,8,4,5,10,11,16,17,22,23]))) self.assertTrue(a4.isEqual(DataArrayInt([0,31,62]))) self.assertTrue(a5.isEqual(DataArrayInt([6,4,3,2,8,9,4,15,21,20,14,4,3,15,14,2,4,2,14,20,8,4,8,20,21,9,4,9,21,15,3,6,4,4,3,9,10,4,16,22,21,15,4,4,16,15,3,4,3,15,21,9,4,9,21,22,10,4,10,22,16,4,6,4,5,4,10,11,4,17,23,22,16,4,5,17,16,4,4,4,16,22,10,4,10,22,23,11,4,11,23,17,5]))) @@ -2113,17 +2201,23 @@ class MEDLoaderTest4(unittest.TestCase): mml=fcscp.buildFromScratchDataSetSupport(0,fields) mml2=mml.prepare() self.assertTrue(isinstance(mml2,MEDUMeshMultiLev)) - a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() + ncc,a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() + self.assertTrue(ncc) self.assertTrue(a0.isEqual(a0Exp,1e-12)) self.assertTrue(a1.isEqual(DataArrayByte([42,42,42]))) - self.assertTrue(a2.isEqual(DataArrayInt([8,16,24]))) + self.assertTrue(a2.isEqual(DataArrayInt([0,9,18]))) self.assertTrue(a3.isEqual(DataArrayInt([8,2,3,8,9,14,15,20,21,8,3,4,9,10,15,16,21,22,8,4,5,10,11,16,17,22,23]))) self.assertTrue(a4.isEqual(DataArrayInt([0,31,62]))) self.assertTrue(a5.isEqual(DataArrayInt([6,4,3,2,8,9,4,15,21,20,14,4,3,15,14,2,4,2,14,20,8,4,8,20,21,9,4,9,21,15,3,6,4,4,3,9,10,4,16,22,21,15,4,4,16,15,3,4,3,15,21,9,4,9,21,22,10,4,10,22,16,4,6,4,5,4,10,11,4,17,23,22,16,4,5,17,16,4,4,4,16,22,10,4,10,22,23,11,4,11,23,17,5]))) for i in xrange(1,5): self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))) pass - pass + a6,a7=mml2.retrieveFamilyIdsOnCells() + self.assertTrue(a6.isEqual(DataArrayInt([0,0,0]))) + self.assertTrue(a7) + a8,a9=mml2.retrieveNumberIdsOnCells() + self.assertTrue(a8 is None) + self.assertTrue(a9) for i in xrange(5): f=allFMTSLeavesPerCommonSupport[0][0][0][i] fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst) @@ -2154,7 +2248,7 @@ class MEDLoaderTest4(unittest.TestCase): """ fname="ForMEDReader15.med" m0=MEDCouplingCMesh() - arr=DataArrayDouble(5) ; arr.iota(0) + arr=DataArrayDouble(3) ; arr.iota(0) m0.setCoords(arr,arr,arr) m0.setName("mesh") m0=m0.buildUnstructured() @@ -2170,6 +2264,8 @@ class MEDLoaderTest4(unittest.TestCase): # mm=MEDFileUMesh() mm.setMeshAtLevel(0,m0) + fam=DataArrayInt(8) ; fam.iota(0) ; mm.setFamilyFieldArr(0,fam) ; del fam + num=DataArrayInt(8) ; num.iota(100) ; mm.setRenumFieldArr(0,num) ; del num # ffs=MEDFileFieldMultiTS() # TimeStep 0 @@ -2236,9 +2332,841 @@ class MEDLoaderTest4(unittest.TestCase): mm.write(fname,2) ffs.write(fname,0) ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values - + ms=MEDFileMeshes(fname) + fields=MEDFileFields(fname,False) + fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()] + allFMTSLeavesToDisplay=[] + for fields in fields_per_mesh: + allFMTSLeavesToDisplay2=[] + for fmts in fields: + allFMTSLeavesToDisplay2+=fmts.splitDiscretizations() + pass + allFMTSLeavesToDisplay.append(allFMTSLeavesToDisplay2) + pass + self.assertEqual(len(allFMTSLeavesToDisplay),1) + self.assertEqual(len(allFMTSLeavesToDisplay[0]),2) + allFMTSLeavesPerTimeSeries=MEDFileAnyTypeFieldMultiTS.SplitIntoCommonTimeSeries(sum(allFMTSLeavesToDisplay,[])) + self.assertEqual(len(allFMTSLeavesPerTimeSeries),1) # one time serie here : because the 2 fields are defined on the same time steps + self.assertEqual(len(allFMTSLeavesPerTimeSeries[0]),2) + allFMTSLeavesPerCommonSupport=MEDFileAnyTypeFieldMultiTS.SplitPerCommonSupport(allFMTSLeavesPerTimeSeries[0],ms[ms.getMeshesNames()[0]]) + self.assertEqual(len(allFMTSLeavesPerCommonSupport),1) + self.assertEqual(len(allFMTSLeavesPerCommonSupport[0][0]),2) + # + mst=MEDFileMeshStruct.New(ms[0]) + # + fcscp=allFMTSLeavesPerCommonSupport[0][1] + mml=fcscp.buildFromScratchDataSetSupport(0,fields) + mml2=mml.prepare() + self.assertTrue(isinstance(mml2,MEDUMeshMultiLev)) + ncc,a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() + self.assertTrue(ncc) + self.assertTrue(a0.isEqual(DataArrayDouble([0.,0.,0.,1.,0.,0.,2.,0.,0.,0.,1.,0.,1.,1.,0.,2.,1.,0.,0.,2.,0.,1.,2.,0.,2.,2.,0.,0.,0.,1.,1.,0.,1.,2.,0.,1.,0.,1.,1.,1.,1.,1.,2.,1.,1.,0.,2.,1.,1.,2.,1.,2.,2.,1.,0.,0.,2.,1.,0.,2.,2.,0.,2.,0.,1.,2.,1.,1.,2.,2.,1.,2.,0.,2.,2.,1.,2.,2.,2.,2.,2.0],27,3),1e-12)) + self.assertTrue(a1.isEqual(DataArrayByte([12,12,12,12,12,12,12,12]))) + self.assertTrue(a2.isEqual(DataArrayInt([0,9,18,27,36,45,54,63]))) + self.assertTrue(a3.isEqual(DataArrayInt([8,1,0,3,4,10,9,12,13,8,2,1,4,5,11,10,13,14,8,4,3,6,7,13,12,15,16,8,5,4,7,8,14,13,16,17,8,10,9,12,13,19,18,21,22,8,11,10,13,14,20,19,22,23,8,13,12,15,16,22,21,24,25,8,14,13,16,17,23,22,25,26]))) + self.assertTrue(a4 is None) + self.assertTrue(a5 is None) + a6,a7=mml2.retrieveFamilyIdsOnCells() + self.assertTrue(a6.isEqual(DataArrayInt([0,1,2,3,4,5,6,7]))) + self.assertTrue(a7) # no copy here + a8,a9=mml2.retrieveNumberIdsOnCells() + self.assertTrue(a8.isEqual(DataArrayInt([100,101,102,103,104,105,106,107]))) + self.assertTrue(a9) # no copy here pass + def test16(self): + """ Here 2 meshes "mesh1" and "mesh2" and 4 fields (no profiles here) : + - "zeField1_0" (CELLS) and "zeField2_0" (NODES) on "mesh1" + - "zeField3_1" (CELLS) and "zeField4_1" (NODES) on "mesh2" + time steps series are the same for the whole 4 fields + """ + fname="ForMEDReader16.med" + m0=MEDCouplingCMesh() + arr=DataArrayDouble(3) ; arr.iota(0) + m0.setCoords(arr,arr,arr) + m0.setName("mesh1") + m0=m0.buildUnstructured() + # + fCell1=MEDCouplingFieldDouble(ON_CELLS) + fCell1.setName("zeField1_0") + fCell1.setMesh(m0) + # + fNode1=MEDCouplingFieldDouble(ON_NODES) + fNode1.setName("zeField2_0") + fNode1.setMesh(m0) + # + mms=MEDFileMeshes() + mm1=MEDFileUMesh() + mm1.setMeshAtLevel(0,m0) + fam=DataArrayInt([0,1,0,1,2,3,2,3]); mm1.setFamilyFieldArr(0,fam) ; del fam + num=DataArrayInt(8) ; num.iota(100) ; mm1.setRenumFieldArr(0,num) ; del num + mm1.setFamilyId("FAMILLE_ZERO",0) ; mm1.setFamilyId("Family1_1",1) ; mm1.setFamilyId("Family1_2",2) ; mm1.setFamilyId("Family1_3",3) ; mm1.setFamilyId("Family1_4",4) + mm1.setFamiliesIdsOnGroup("Grp1_1",[0,1]) ; mm1.setFamiliesIdsOnGroup("Grp1_2",[2,3]) + mms.pushMesh(mm1) ; del mm1 + # + m1=m0.deepCpy() ; m1.translate([2.5,0.,0.]) ; m1.setName("mesh2") + # + fCell2=MEDCouplingFieldDouble(ON_CELLS) + fCell2.setName("zeField3_1") + fCell2.setMesh(m1) + # + fNode2=MEDCouplingFieldDouble(ON_NODES) + fNode2.setName("zeField4_1") + fNode2.setMesh(m1) + # + mm2=MEDFileUMesh() + mm2.setMeshAtLevel(0,m1) + fam=DataArrayInt([0,1,0,1,2,3,2,3]); mm2.setFamilyFieldArr(0,fam) ; del fam + num=DataArrayInt(8) ; num.iota(200) ; mm2.setRenumFieldArr(0,num) ; del num + mm2.setFamilyId("FAMILLE_ZERO",0) ; mm2.setFamilyId("Family2_1",1) ; mm2.setFamilyId("Family2_2",2) ; mm2.setFamilyId("Family2_3",3) ; mm2.setFamilyId("Family2_4",4) + mm2.setFamiliesIdsOnGroup("Grp2_1",[0,1]) ; mm2.setFamiliesIdsOnGroup("Grp2_2",[2,3]) ; mm2.setFamiliesIdsOnGroup("Grp2_3",[1,2,3]) + mms.pushMesh(mm2) ; del mm2 + ffs1_1=MEDFileFieldMultiTS() + ffs1_2=MEDFileFieldMultiTS() + ffs2_1=MEDFileFieldMultiTS() + ffs2_2=MEDFileFieldMultiTS() + mts=MEDFileFields() + for elt in ffs1_1,ffs1_2,ffs2_1,ffs2_2: + mts.pushField(elt) + pass + # TimeStep 0 + t=(1.,0,0) ; off=0. + f1ts1=MEDFileField1TS() + f1ts2=MEDFileField1TS() + a=DataArrayDouble(m0.getNumberOfCells()) ; a.iota(off) ; a.setInfoOnComponents(["xx [m]"]) + fCell1.setArray(a) + fCell1.setTime(*t) + fCell1.checkCoherency() + a=DataArrayDouble(m0.getNumberOfNodes()) ; a.iota(off) ; a.setInfoOnComponents(["xx [m]"]) + a=a.negate() + fNode1.setArray(a) + fNode1.setTime(*t) + fNode1.checkCoherency() + f1ts1.setFieldNoProfileSBT(fCell1) ; ffs1_1.pushBackTimeStep(f1ts1) + f1ts2.setFieldNoProfileSBT(fNode1) ; ffs1_2.pushBackTimeStep(f1ts2) + # + f1ts1=MEDFileField1TS() + f1ts2=MEDFileField1TS() + a=DataArrayDouble(m1.getNumberOfCells()) ; a.iota(1000.+off) ; a.setInfoOnComponents(["xx [m]"]) + fCell2.setArray(a) + fCell2.setTime(*t) + fCell2.checkCoherency() + a=DataArrayDouble(m1.getNumberOfNodes()) ; a.iota(1000+off) ; a.setInfoOnComponents(["xx [m]"]) + a=a.negate() + fNode2.setArray(a) + fNode2.setTime(*t) + fNode2.checkCoherency() + f1ts1.setFieldNoProfileSBT(fCell2) ; ffs2_1.pushBackTimeStep(f1ts1) + f1ts2.setFieldNoProfileSBT(fNode2) ; ffs2_2.pushBackTimeStep(f1ts2) + # TimeStep 1 + t=(2.1,1,0) ; off=100. + f1ts1=MEDFileField1TS() + f1ts2=MEDFileField1TS() + a=DataArrayDouble(m0.getNumberOfCells()) ; a.iota(off) ; a.setInfoOnComponents(["xx [m]"]) + fCell1.setArray(a) + fCell1.setTime(*t) + fCell1.checkCoherency() + a=DataArrayDouble(m0.getNumberOfNodes()) ; a.iota(off) ; a.setInfoOnComponents(["xx [m]"]) + a=a.negate() + fNode1.setArray(a) + fNode1.setTime(*t) + fNode1.checkCoherency() + f1ts1.setFieldNoProfileSBT(fCell1) ; ffs1_1.pushBackTimeStep(f1ts1) + f1ts2.setFieldNoProfileSBT(fNode1) ; ffs1_2.pushBackTimeStep(f1ts2) + # + f1ts1=MEDFileField1TS() + f1ts2=MEDFileField1TS() + a=DataArrayDouble(m1.getNumberOfCells()) ; a.iota(1000.+off) ; a.setInfoOnComponents(["xx [m]"]) + fCell2.setArray(a) + fCell2.setTime(*t) + fCell2.checkCoherency() + a=DataArrayDouble(m1.getNumberOfNodes()) ; a.iota(1000+off) ; a.setInfoOnComponents(["xx [m]"]) + a=a.negate() + fNode2.setArray(a) + fNode2.setTime(*t) + fNode2.checkCoherency() + f1ts1.setFieldNoProfileSBT(fCell2) ; ffs2_1.pushBackTimeStep(f1ts1) + f1ts2.setFieldNoProfileSBT(fNode2) ; ffs2_2.pushBackTimeStep(f1ts2) + # TimeStep 2 + t=(3.1,2,0) ; off=200. + f1ts1=MEDFileField1TS() + f1ts2=MEDFileField1TS() + a=DataArrayDouble(m0.getNumberOfCells()) ; a.iota(off) ; a.setInfoOnComponents(["xx [m]"]) + fCell1.setArray(a) + fCell1.setTime(*t) + fCell1.checkCoherency() + a=DataArrayDouble(m0.getNumberOfNodes()) ; a.iota(off) ; a.setInfoOnComponents(["xx [m]"]) + a=a.negate() + fNode1.setArray(a) + fNode1.setTime(*t) + fNode1.checkCoherency() + f1ts1.setFieldNoProfileSBT(fCell1) ; ffs1_1.pushBackTimeStep(f1ts1) + f1ts2.setFieldNoProfileSBT(fNode1) ; ffs1_2.pushBackTimeStep(f1ts2) + # + f1ts1=MEDFileField1TS() + f1ts2=MEDFileField1TS() + a=DataArrayDouble(m1.getNumberOfCells()) ; a.iota(1000.+off) ; a.setInfoOnComponents(["xx [m]"]) + fCell2.setArray(a) + fCell2.setTime(*t) + fCell2.checkCoherency() + a=DataArrayDouble(m1.getNumberOfNodes()) ; a.iota(1000+off) ; a.setInfoOnComponents(["xx [m]"]) + a=a.negate() + fNode2.setArray(a) + fNode2.setTime(*t) + fNode2.checkCoherency() + f1ts1.setFieldNoProfileSBT(fCell2) ; ffs2_1.pushBackTimeStep(f1ts1) + f1ts2.setFieldNoProfileSBT(fNode2) ; ffs2_2.pushBackTimeStep(f1ts2) + # + mms.write(fname,2) ; mts.write(fname,0) + ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values + ms=MEDFileMeshes(fname) + fields=MEDFileFields(fname,False) + fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()] + allFMTSLeavesToDisplay=[] + for fields in fields_per_mesh: + allFMTSLeavesToDisplay2=[] + for fmts in fields: + allFMTSLeavesToDisplay2+=fmts.splitDiscretizations() + pass + allFMTSLeavesToDisplay.append(allFMTSLeavesToDisplay2) + pass + self.assertEqual(len(allFMTSLeavesToDisplay),2) + self.assertEqual(len(allFMTSLeavesToDisplay[0]),2) + self.assertEqual(len(allFMTSLeavesToDisplay[1]),2) + allFMTSLeavesPerTimeSeries=MEDFileAnyTypeFieldMultiTS.SplitIntoCommonTimeSeries(sum(allFMTSLeavesToDisplay,[])) + self.assertEqual(len(allFMTSLeavesPerTimeSeries),1) # one time serie here : because the 2 fields are defined on the same time steps + self.assertEqual(len(allFMTSLeavesPerTimeSeries[0]),4) + allFMTSLeavesPerCommonSupport1=MEDFileAnyTypeFieldMultiTS.SplitPerCommonSupport(allFMTSLeavesToDisplay[0],ms[ms.getMeshesNames()[0]]) + self.assertEqual(len(allFMTSLeavesPerCommonSupport1),1) + self.assertEqual(len(allFMTSLeavesPerCommonSupport1[0][0]),2) + allFMTSLeavesPerCommonSupport2=MEDFileAnyTypeFieldMultiTS.SplitPerCommonSupport(allFMTSLeavesToDisplay[0],ms[ms.getMeshesNames()[0]]) + self.assertEqual(len(allFMTSLeavesPerCommonSupport2),1) + self.assertEqual(len(allFMTSLeavesPerCommonSupport2[0][0]),2) + pass + + def test17(self): + """ First test on GAUSS_NE (Elno). Here no Profiles. + 2 times steps. + """ + fname="ForMEDReader17.med" + fieldName1="MyFirstElno" + fieldName2="ACellField" + fieldName3="ANodeField" + coo=DataArrayDouble([0.,0.,1.,0.,2.,0.,0.,1.,1.,1.,2.,1.],6,2) + m=MEDCouplingUMesh("mesh",2) + m.setCoords(coo) + m.allocateCells() + m.insertNextCell(NORM_QUAD4,[0,3,4,1]) + m.insertNextCell(NORM_QUAD4,[1,4,5,2]) + m.checkCoherency2() + # + t=(1.1,0,-1) + f=MEDCouplingFieldDouble(ON_GAUSS_NE) ; f.setTime(*t) ; f.setMesh(m) + f.setArray(DataArrayDouble([3.,5.,7.,6.,2.,3.,11.,8.])) + f.setName(fieldName1) + f.checkCoherency() + MEDLoader.WriteField(fname,f,True) + f2=MEDCouplingFieldDouble(ON_CELLS) ; f2.setTime(*t) ; f2.setMesh(m) + f2.setArray(DataArrayDouble([7.,11.],2,1)) + f2.setName(fieldName2) + MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fname,f2) + f3=MEDCouplingFieldDouble(ON_NODES) ; f3.setTime(*t) ; f3.setMesh(m) + f3.setArray(DataArrayDouble([1.,2.,4.,1.,2.,4.],6,1)) + f3.setName(fieldName3) + MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fname,f3) + # + t=(2.1,1,-1) + f=MEDCouplingFieldDouble(ON_GAUSS_NE) ; f.setTime(*t) ; f.setMesh(m) + f.setArray(DataArrayDouble([7.,6.,3.,5.,11.,8.,2.,3.])) + f.setName(fieldName1) + f.checkCoherency() + MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fname,f) + f2=MEDCouplingFieldDouble(ON_CELLS) ; f2.setTime(*t) ; f2.setMesh(m) + f2.setArray(DataArrayDouble([11.,7.],2,1)) + f2.setName(fieldName2) + MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fname,f2) + f3=MEDCouplingFieldDouble(ON_NODES) ; f3.setTime(*t) ; f3.setMesh(m) + f3.setArray(DataArrayDouble([4.,2.,1.,4.,2.,1.],6,1)) + f3.setName(fieldName3) + MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fname,f3) + ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values + ms=MEDFileMeshes(fname) + fields=MEDFileFields(fname,False) + fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()] + allFMTSLeavesToDisplay=[] + for fields in fields_per_mesh: + allFMTSLeavesToDisplay2=[] + for fmts in fields: + allFMTSLeavesToDisplay2+=fmts.splitDiscretizations() + pass + allFMTSLeavesToDisplay.append(allFMTSLeavesToDisplay2) + pass + self.assertEqual(len(allFMTSLeavesToDisplay),1) + self.assertEqual(len(allFMTSLeavesToDisplay[0]),3) + allFMTSLeavesPerTimeSeries=MEDFileAnyTypeFieldMultiTS.SplitIntoCommonTimeSeries(sum(allFMTSLeavesToDisplay,[])) + self.assertEqual(len(allFMTSLeavesPerTimeSeries),1) + self.assertEqual(len(allFMTSLeavesPerTimeSeries[0]),3) + allFMTSLeavesPerCommonSupport1=MEDFileAnyTypeFieldMultiTS.SplitPerCommonSupport(allFMTSLeavesToDisplay[0],ms[ms.getMeshesNames()[0]]) + self.assertEqual(len(allFMTSLeavesPerCommonSupport1),1) + self.assertEqual(len(allFMTSLeavesPerCommonSupport1[0][0]),3) + # + mst=MEDFileMeshStruct.New(ms[0]) + # + fcscp=allFMTSLeavesPerCommonSupport1[0][1] + mml=fcscp.buildFromScratchDataSetSupport(0,fields) + mml2=mml.prepare() + self.assertTrue(isinstance(mml2,MEDUMeshMultiLev)) + ncc,a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() + self.assertTrue(not ncc) # spaceDim 2 -> VTK wants 3D + self.assertTrue(a0.isEqual(DataArrayDouble([0.,0.,0.,1.,0.,0.,2.,0.,0.,0.,1.,0.,1.,1.,0.,2.,1.,0.],6,3),1e-12)) + self.assertTrue(a1.isEqual(DataArrayByte([9,9]))) + self.assertTrue(a2.isEqual(DataArrayInt([0,5]))) + self.assertTrue(a3.isEqual(DataArrayInt([4,0,3,4,1,4,1,4,5,2]))) + self.assertTrue(a4 is None) + self.assertTrue(a5 is None) + a6,a7=mml2.retrieveFamilyIdsOnCells() + self.assertTrue(a6.isEqual(DataArrayInt([0,0]))) + self.assertTrue(a7) # no copy here + a8,a9=mml2.retrieveNumberIdsOnCells() + self.assertTrue(a8.isEqual(DataArrayInt([0,1]))) + self.assertTrue(a9) # no copy here + for i in xrange(1,2): + self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))) + pass + vExp0=[DataArrayDouble([7.,11.]),DataArrayDouble([11.,7.])] + vExp1=[DataArrayDouble([3.,5.,7.,6.,2.,3.,11.,8.]),DataArrayDouble([7.,6.,3.,5.,11.,8.,2.,3.])] + for i in xrange(2): + f=allFMTSLeavesPerCommonSupport1[0][0][0][i] + fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst) + f.loadArraysIfNecessary() + v=mml.buildDataArray(fsst,fields,f.getUndergroundDataArray()) + self.assertEqual(f.getName(),fieldName2) + self.assertEqual(v.getHiddenCppPointer(),f.getUndergroundDataArray().getHiddenCppPointer()) + self.assertTrue(v.isEqual(vExp0[i],1e-12)) + # + f=allFMTSLeavesPerCommonSupport1[0][0][1][i] + fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst) + f.loadArraysIfNecessary() + v=mml.buildDataArray(fsst,fields,f.getUndergroundDataArray()) + self.assertEqual(f.getName(),fieldName1) + self.assertEqual(v.getHiddenCppPointer(),f.getUndergroundDataArray().getHiddenCppPointer()) + self.assertTrue(v.isEqual(vExp1[i],1e-12)) + pass + pass + + def test18(self): + """ First test on GAUSS_PT. Here no Profiles. 2 times steps. + """ + fname="ForMEDReader18.med" + fieldName1="MyFirstGauss" + fieldName2="ACellField" + fieldName3="ANodeField" + coo=DataArrayDouble([0.,0.,1.,0.,2.,0.,0.,1.,1.,1.,2.,1.],6,2) + m=MEDCouplingUMesh("mesh",2) + m.setCoords(coo) + m.allocateCells() + m.insertNextCell(NORM_QUAD4,[0,3,4,1]) + m.insertNextCell(NORM_QUAD4,[1,4,5,2]) + m.checkCoherency2() + # + t=(1.1,0,-1) + f=MEDCouplingFieldDouble(ON_GAUSS_PT) ; f.setTime(*t) ; f.setMesh(m) + f.setGaussLocalizationOnType(NORM_QUAD4,[-1.,-1.,1.,-1.,1.,1.,-1.,1.],[0.2,0.2,0.8,0.8],[0.7,0.3]) + f.setArray(DataArrayDouble([3.,5.,4.,6.])) ; f.getArray().setInfoOnComponents(["Smth"]) + f.setName(fieldName1) + f.checkCoherency() + MEDLoader.WriteField(fname,f,True) + f2=MEDCouplingFieldDouble(ON_CELLS) ; f2.setTime(*t) ; f2.setMesh(m) + f2.setArray(DataArrayDouble([7.,11.],2,1)) + f2.setName(fieldName2) + MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fname,f2) + f3=MEDCouplingFieldDouble(ON_NODES) ; f3.setTime(*t) ; f3.setMesh(m) + f3.setArray(DataArrayDouble([1.,2.,4.,1.,2.,4.],6,1)) + f3.setName(fieldName3) + MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fname,f3) + # + t=(2.1,1,-1) + f=MEDCouplingFieldDouble(ON_GAUSS_PT) ; f.setTime(*t) ; f.setMesh(m) + f.setGaussLocalizationOnType(NORM_QUAD4,[-1.,-1.,1.,-1.,1.,1.,-1.,1.],[0.2,0.2,0.8,0.8],[0.7,0.3]) + f.setArray(DataArrayDouble([5.,3.,6.,4.])) ; f.getArray().setInfoOnComponents(["Smth"]) + f.setName(fieldName1) + f.checkCoherency() + MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fname,f) + f2=MEDCouplingFieldDouble(ON_CELLS) ; f2.setTime(*t) ; f2.setMesh(m) + f2.setArray(DataArrayDouble([11.,7.],2,1)) + f2.setName(fieldName2) + MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fname,f2) + f3=MEDCouplingFieldDouble(ON_NODES) ; f3.setTime(*t) ; f3.setMesh(m) + f3.setArray(DataArrayDouble([4.,2.,1.,4.,2.,1.],6,1)) + f3.setName(fieldName3) + MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fname,f3) + ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values + ms=MEDFileMeshes(fname) + fields=MEDFileFields(fname,False) + fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()] + allFMTSLeavesToDisplay=[] + for fields in fields_per_mesh: + allFMTSLeavesToDisplay2=[] + for fmts in fields: + allFMTSLeavesToDisplay2+=fmts.splitDiscretizations() + pass + allFMTSLeavesToDisplay.append(allFMTSLeavesToDisplay2) + pass + self.assertEqual(len(allFMTSLeavesToDisplay),1) + self.assertEqual(len(allFMTSLeavesToDisplay[0]),3) + allFMTSLeavesPerTimeSeries=MEDFileAnyTypeFieldMultiTS.SplitIntoCommonTimeSeries(sum(allFMTSLeavesToDisplay,[])) + self.assertEqual(len(allFMTSLeavesPerTimeSeries),1) + self.assertEqual(len(allFMTSLeavesPerTimeSeries[0]),3) + allFMTSLeavesPerCommonSupport1=MEDFileAnyTypeFieldMultiTS.SplitPerCommonSupport(allFMTSLeavesToDisplay[0],ms[ms.getMeshesNames()[0]]) + self.assertEqual(len(allFMTSLeavesPerCommonSupport1),1) + self.assertEqual(len(allFMTSLeavesPerCommonSupport1[0][0]),3) + # + mst=MEDFileMeshStruct.New(ms[0]) + # + fcscp=allFMTSLeavesPerCommonSupport1[0][1] + mml=fcscp.buildFromScratchDataSetSupport(0,fields) + mml2=mml.prepare() + self.assertTrue(isinstance(mml2,MEDUMeshMultiLev)) + ncc,a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() + self.assertTrue(not ncc) # spaceDim 2 -> VTK wants 3D + self.assertTrue(a0.isEqual(DataArrayDouble([0.,0.,0.,1.,0.,0.,2.,0.,0.,0.,1.,0.,1.,1.,0.,2.,1.,0.],6,3),1e-12)) + self.assertTrue(a1.isEqual(DataArrayByte([9,9]))) + self.assertTrue(a2.isEqual(DataArrayInt([0,5]))) + self.assertTrue(a3.isEqual(DataArrayInt([4,0,3,4,1,4,1,4,5,2]))) + self.assertTrue(a4 is None) + self.assertTrue(a5 is None) + a6,a7=mml2.retrieveFamilyIdsOnCells() + self.assertTrue(a6.isEqual(DataArrayInt([0,0]))) + self.assertTrue(a7) # no copy here + a8,a9=mml2.retrieveNumberIdsOnCells() + self.assertTrue(a8.isEqual(DataArrayInt([0,1]))) + self.assertTrue(a9) # no copy here + for i in xrange(1,2): + self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))) + pass + vExp0=[DataArrayDouble([7.,11.]),DataArrayDouble([11.,7.])] + vExp1=[DataArrayDouble([3.,5.,4.,6.]),DataArrayDouble([5.,3.,6.,4.])] + for i in xrange(2): + f=allFMTSLeavesPerCommonSupport1[0][0][0][i] + fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst) + f.loadArraysIfNecessary() + v=mml.buildDataArray(fsst,fields,f.getUndergroundDataArray()) + self.assertEqual(f.getName(),fieldName2) + self.assertEqual(v.getHiddenCppPointer(),f.getUndergroundDataArray().getHiddenCppPointer()) + self.assertTrue(v.isEqual(vExp0[i],1e-12)) + # + f=allFMTSLeavesPerCommonSupport1[0][0][1][i] + fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst) + f.loadArraysIfNecessary() + v=mml.buildDataArray(fsst,fields,f.getUndergroundDataArray()) + self.assertEqual(f.getName(),fieldName1) + self.assertEqual(v.getHiddenCppPointer(),f.getUndergroundDataArray().getHiddenCppPointer()) + vExp1[i].setInfoOnComponents(["Smth"]) + self.assertTrue(v.isEqual(vExp1[i],1e-12)) + pass + ## Now same exercise but with a different load strategy. All is load directly. + ms=MEDFileMeshes(fname) + fields=MEDFileFields(fname) # here all is read, the SauvReader (or other Reader) is emulated + fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()] + allFMTSLeavesToDisplay=[] + for fields in fields_per_mesh: + allFMTSLeavesToDisplay2=[] + for fmts in fields: + allFMTSLeavesToDisplay2+=fmts.splitDiscretizations() + pass + allFMTSLeavesToDisplay.append(allFMTSLeavesToDisplay2) + pass + self.assertEqual(len(allFMTSLeavesToDisplay),1) + self.assertEqual(len(allFMTSLeavesToDisplay[0]),3) + allFMTSLeavesPerTimeSeries=MEDFileAnyTypeFieldMultiTS.SplitIntoCommonTimeSeries(sum(allFMTSLeavesToDisplay,[])) + self.assertEqual(len(allFMTSLeavesPerTimeSeries),1) + self.assertEqual(len(allFMTSLeavesPerTimeSeries[0]),3) + allFMTSLeavesPerCommonSupport1=MEDFileAnyTypeFieldMultiTS.SplitPerCommonSupport(allFMTSLeavesToDisplay[0],ms[ms.getMeshesNames()[0]]) + self.assertEqual(len(allFMTSLeavesPerCommonSupport1),1) + self.assertEqual(len(allFMTSLeavesPerCommonSupport1[0][0]),3) + # + mst=MEDFileMeshStruct.New(ms[0]) + # + fcscp=allFMTSLeavesPerCommonSupport1[0][1] + mml=fcscp.buildFromScratchDataSetSupport(0,fields) + mml2=mml.prepare() + self.assertTrue(isinstance(mml2,MEDUMeshMultiLev)) + ncc,a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() + self.assertTrue(not ncc) # spaceDim 2 -> VTK wants 3D + self.assertTrue(a0.isEqual(DataArrayDouble([0.,0.,0.,1.,0.,0.,2.,0.,0.,0.,1.,0.,1.,1.,0.,2.,1.,0.],6,3),1e-12)) + self.assertTrue(a1.isEqual(DataArrayByte([9,9]))) + self.assertTrue(a2.isEqual(DataArrayInt([0,5]))) + self.assertTrue(a3.isEqual(DataArrayInt([4,0,3,4,1,4,1,4,5,2]))) + self.assertTrue(a4 is None) + self.assertTrue(a5 is None) + a6,a7=mml2.retrieveFamilyIdsOnCells() + self.assertTrue(a6.isEqual(DataArrayInt([0,0]))) + self.assertTrue(a7) # no copy here + a8,a9=mml2.retrieveNumberIdsOnCells() + self.assertTrue(a8.isEqual(DataArrayInt([0,1]))) + self.assertTrue(a9) # no copy here + for i in xrange(1,2): + self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))) + pass + vExp0=[DataArrayDouble([7.,11.]),DataArrayDouble([11.,7.])] + vExp1=[DataArrayDouble([3.,5.,4.,6.]),DataArrayDouble([5.,3.,6.,4.])] + for i in xrange(2): + f=allFMTSLeavesPerCommonSupport1[0][0][0][i] + fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst) # no load needed here + v=mml.buildDataArray(fsst,fields,f.getUndergroundDataArray()) + self.assertEqual(f.getName(),fieldName2) + self.assertEqual(v.getHiddenCppPointer(),f.getUndergroundDataArray().getHiddenCppPointer()) + self.assertTrue(v.isEqual(vExp0[i],1e-12)) + # + f=allFMTSLeavesPerCommonSupport1[0][0][1][i] + fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst) # no load needed here + v=mml.buildDataArray(fsst,fields,f.getUndergroundDataArray()) + self.assertEqual(f.getName(),fieldName1) + self.assertEqual(v.getHiddenCppPointer(),f.getUndergroundDataArray().getHiddenCppPointer()) + vExp1[i].setInfoOnComponents(["Smth"]) + self.assertTrue(v.isEqual(vExp1[i],1e-12)) + pass + pass + + def test19(self): + """ + This test is a simple non profile CELL field but lying on cells of dimension -1 (not 0 as "usual"). + """ + fname="ForMEDReader19.med" + fieldName="ACellFieldOnDimM1" + coo=DataArrayDouble(3) ; coo.iota() + m=MEDCouplingCMesh() ; m.setCoords(coo,coo,coo) ; m.setName("mesh") + m0=m.buildUnstructured() ; del m + m1=m0.computeSkin() + # + mm=MEDFileUMesh() + mm.setMeshAtLevel(0,m0) + mm.setMeshAtLevel(-1,m1) + ff=MEDFileFieldMultiTS() + # time 0 + t=(1.1,1,-1) + f=MEDCouplingFieldDouble(ON_CELLS) ; f.setTime(*t) ; f.setMesh(m1) + f.setName(fieldName) + arr=DataArrayDouble(24) ; arr.iota() ; arr.setInfoOnComponents(["AStr"]) + f.setArray(arr) + f.checkCoherency() + f1ts=MEDFileField1TS() ; f1ts.setFieldNoProfileSBT(f) + ff.pushBackTimeStep(f1ts) + # time 1 + t=(2.1,2,-2) + f=MEDCouplingFieldDouble(ON_CELLS) ; f.setTime(*t) ; f.setMesh(m1) + f.setName(fieldName) + arr=DataArrayDouble(24) ; arr.iota() ; arr.reverse() ; arr.setInfoOnComponents(["AStr"]) + f.setArray(arr) + f.checkCoherency() + f1ts=MEDFileField1TS() ; f1ts.setFieldNoProfileSBT(f) + ff.pushBackTimeStep(f1ts) + # + mm.write(fname,2) + ff.write(fname,0) + ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values + ms=MEDFileMeshes(fname) + fields=MEDFileFields(fname,False) + fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()] + allFMTSLeavesToDisplay=[] + for fields in fields_per_mesh: + allFMTSLeavesToDisplay2=[] + for fmts in fields: + allFMTSLeavesToDisplay2+=fmts.splitDiscretizations() + pass + allFMTSLeavesToDisplay.append(allFMTSLeavesToDisplay2) + pass + self.assertEqual(len(allFMTSLeavesToDisplay),1) + self.assertEqual(len(allFMTSLeavesToDisplay[0]),1) + allFMTSLeavesPerTimeSeries=MEDFileAnyTypeFieldMultiTS.SplitIntoCommonTimeSeries(sum(allFMTSLeavesToDisplay,[])) + self.assertEqual(len(allFMTSLeavesPerTimeSeries),1) + self.assertEqual(len(allFMTSLeavesPerTimeSeries[0]),1) + allFMTSLeavesPerCommonSupport1=MEDFileAnyTypeFieldMultiTS.SplitPerCommonSupport(allFMTSLeavesToDisplay[0],ms[ms.getMeshesNames()[0]]) + self.assertEqual(len(allFMTSLeavesPerCommonSupport1),1) + self.assertEqual(len(allFMTSLeavesPerCommonSupport1[0][0]),1) + # + mst=MEDFileMeshStruct.New(ms[0]) + # + fcscp=allFMTSLeavesPerCommonSupport1[0][1] + mml=fcscp.buildFromScratchDataSetSupport(0,fields) + mml2=mml.prepare() + self.assertTrue(isinstance(mml2,MEDUMeshMultiLev)) + ncc,a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() + self.assertTrue(ncc) + self.assertTrue(a0.isEqual(DataArrayDouble([0.,0.,0.,1.,0.,0.,2.,0.,0.,0.,1.,0.,1.,1.,0.,2.,1.,0.,0.,2.,0.,1.,2.,0.,2.,2.,0.,0.,0.,1.,1.,0.,1.,2.,0.,1.,0.,1.,1.,1.,1.,1.,2.,1.,1.,0.,2.,1.,1.,2.,1.,2.,2.,1.,0.,0.,2.,1.,0.,2.,2.,0.,2.,0.,1.,2.,1.,1.,2.,2.,1.,2.,0.,2.,2.,1.,2.,2.,2.,2.,2.],27,3),1e-12)) + self.assertTrue(a1.isEqual(DataArrayByte([9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9]))) + self.assertTrue(a2.isEqual(DataArrayInt([0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100,105,110,115]))) + self.assertTrue(a3.isEqual(DataArrayInt([4,1,0,3,4,4,1,10,9,0,4,0,9,12,3,4,2,1,4,5,4,2,11,10,1,4,5,14,11,2,4,4,3,6,7,4,3,12,15,6,4,6,15,16,7,4,5,4,7,8,4,7,16,17,8,4,8,17,14,5,4,19,22,21,18,4,10,19,18,9,4,9,18,21,12,4,20,23,22,19,4,11,20,19,10,4,14,23,20,11,4,22,25,24,21,4,12,21,24,15,4,15,24,25,16,4,23,26,25,22,4,16,25,26,17,4,17,26,23,14]))) + self.assertTrue(a4 is None) + self.assertTrue(a5 is None) + a6,a7=mml2.retrieveFamilyIdsOnCells() + self.assertTrue(a6.isEqual(DataArrayInt([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]))) + self.assertTrue(a7) # no copy here + a8,a9=mml2.retrieveNumberIdsOnCells() + self.assertTrue(a8 is None) + self.assertTrue(a9) # no copy here + a10,a11=mml2.retrieveFamilyIdsOnNodes() + self.assertTrue(not a10) + self.assertTrue(a11) # no copy here + a12,a13=mml2.retrieveNumberIdsOnNodes() + self.assertTrue(not a12) + self.assertTrue(a13) # no copy here + for i in xrange(1,2): + self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))) + pass + for i in xrange(2): + f=allFMTSLeavesPerCommonSupport1[0][0][0][i] + fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst) + f.loadArraysIfNecessary() + v=mml.buildDataArray(fsst,fields,f.getUndergroundDataArray()) + self.assertEqual(f.getName(),fieldName) + self.assertEqual(v.getHiddenCppPointer(),f.getUndergroundDataArray().getHiddenCppPointer()) + vExp=DataArrayDouble(24) ; vExp.iota() + if i==1: vExp.reverse() + vExp.setInfoOnComponents(["AStr"]) + self.assertTrue(v.isEqual(vExp,1e-12)) + pass + pass + + def test20(self): + """ This test works with groups/families on cells AND on nodes. Here 4 fields each on same time steps (2). + 1 field on CELLS without profile, 1 field on CELLS with profile, 1 field on NODES without profile, 1 field on NODES with profile. + All of these 4 fields lies on a single mesh "mesh". The 2 fields on profile lies on a same support. + One drawback of this test : no multi geom type. Coming soon ! + """ + fname="ForMEDReader20.med" + fieldName0="ANodeField" + fieldName1="ACellField" + fieldName2="ANodeFieldPfl" + fieldName3="ACellFieldPfl" + pfl2=DataArrayInt([5,6,7,10,11,12,15,16,17,20,21,22]) ; pfl2.setName("pfl2") + pfl3=DataArrayInt([4,5,8,9,12,13]) ; pfl3.setName("pfl3") + # + arr=DataArrayDouble(5) ; arr.iota() + m=MEDCouplingCMesh("mesh") ; m.setCoords(arr,arr) + m=m.buildUnstructured() + mm=MEDFileUMesh() + mm.setMeshAtLevel(0,m) + fs=MEDFileFields() + fmts0=MEDFileFieldMultiTS() ; fs.pushField(fmts0) + fmts0.setDtUnit("s") + fmts1=MEDFileFieldMultiTS() ; fs.pushField(fmts1) + fmts1.setDtUnit("s") + fmts2=MEDFileFieldMultiTS() ; fs.pushField(fmts2) + fmts2.setDtUnit("s") + fmts3=MEDFileFieldMultiTS() ; fs.pushField(fmts3) + fmts3.setDtUnit("s") + #### + t=(1.1,0,-2) + f0=MEDCouplingFieldDouble(ON_NODES) ; f0.setMesh(m) + f0.setName(fieldName0) ; f0.setTime(*t) + da=m.getCoords().magnitude() ; da.setInfoOnComponents(["zeInfo"]) + f0.setArray(da) + f0.checkCoherency() + f1ts=MEDFileField1TS() + f1ts.setFieldNoProfileSBT(f0) + fmts0.pushBackTimeStep(f1ts) + # + f1=MEDCouplingFieldDouble(ON_CELLS) ; f1.setMesh(m) + f1.setName(fieldName1) ; f1.setTime(*t) + da=m.getBarycenterAndOwner().magnitude() ; da.setInfoOnComponents(["zeInfoCell"]) + f1.setArray(da) + f1.checkCoherency() + f1ts=MEDFileField1TS() + f1ts.setFieldNoProfileSBT(f1) + fmts1.pushBackTimeStep(f1ts) + # + f2=MEDCouplingFieldDouble(ON_NODES) ; mTmp=m[pfl3] ; mTmp.zipCoords() ; mTmp.setName(m.getName()) ; f2.setMesh(mTmp) + f2.setName(fieldName2) ; f2.setTime(*t) + da=m.getCoords().magnitude()[pfl2] ; da.setInfoOnComponents(["zzzz"]) + f2.setArray(da) + f2.checkCoherency() + f1ts=MEDFileField1TS() + f1ts.setFieldProfile(f2,mm,0,pfl2) + fmts2.pushBackTimeStep(f1ts) + # + f3=MEDCouplingFieldDouble(ON_CELLS) ; mTmp=m[pfl3] ; mTmp.setName(m.getName()) ; f3.setMesh(mTmp) + f3.setName(fieldName3) ; f3.setTime(*t) + da=mTmp.getBarycenterAndOwner().magnitude() ; da.setInfoOnComponents(["abcdefg"]) + f3.setArray(da) + f3.checkCoherency() + f1ts=MEDFileField1TS() + f1ts.setFieldProfile(f3,mm,0,pfl3) + fmts3.pushBackTimeStep(f1ts) + #### + t=(2.1,1,-3) + f0=MEDCouplingFieldDouble(ON_NODES) ; f0.setMesh(m) + f0.setName(fieldName0) ; f0.setTime(*t) + da=m.getCoords().magnitude() ; da.reverse() ; da.setInfoOnComponents(["zeInfo"]) + f0.setArray(da) + f0.checkCoherency() + f1ts=MEDFileField1TS() + f1ts.setFieldNoProfileSBT(f0) + fmts0.pushBackTimeStep(f1ts) + # + f1=MEDCouplingFieldDouble(ON_CELLS) ; f1.setMesh(m) + f1.setName(fieldName1) ; f1.setTime(*t) + da=m.getBarycenterAndOwner().magnitude() ; da.reverse() ; da.setInfoOnComponents(["zeInfoCell"]) + f1.setArray(da) + f1.checkCoherency() + f1ts=MEDFileField1TS() + f1ts.setFieldNoProfileSBT(f1) + fmts1.pushBackTimeStep(f1ts) + # + f2=MEDCouplingFieldDouble(ON_NODES) ; mTmp=m[pfl3] ; mTmp.zipCoords() ; mTmp.setName(m.getName()) ; f2.setMesh(mTmp) + f2.setName(fieldName2) ; f2.setTime(*t) + da=m.getCoords().magnitude()[pfl2] ; da.reverse() ; da.setInfoOnComponents(["zzzz"]) + f2.setArray(da) + f2.checkCoherency() + f1ts=MEDFileField1TS() + f1ts.setFieldProfile(f2,mm,0,pfl2) + fmts2.pushBackTimeStep(f1ts) + # + f3=MEDCouplingFieldDouble(ON_CELLS) ; mTmp=m[pfl3] ; mTmp.setName(m.getName()) ; f3.setMesh(mTmp) + f3.setName(fieldName3) ; f3.setTime(*t) + da=mTmp.getBarycenterAndOwner().magnitude() ; da.reverse() ; da.setInfoOnComponents(["abcdefg"]) + f3.setArray(da) + f3.checkCoherency() + f1ts=MEDFileField1TS() + f1ts.setFieldProfile(f3,mm,0,pfl3) + fmts3.pushBackTimeStep(f1ts) + #### + grp1=DataArrayInt([6,7,8,11,12,13,16,17,18]) ; grp1.setName("grp1") + grp2=DataArrayInt([10,11,15,16,20,21]) ; grp2.setName("grp2") + mm.setGroupsAtLevel(1,[grp1,grp2]) + grp3=DataArrayInt([4,5,6]) ; grp3.setName("grp3") + grp4=DataArrayInt([8,9,10]) ; grp4.setName("grp4") + mm.setGroupsAtLevel(0,[grp3,grp4]) + d=DataArrayInt(25) ; d.iota() ; d*=10 ; mm.setRenumFieldArr(1,d) + d=DataArrayInt(16) ; d.iota() ; d*=11 ; mm.setRenumFieldArr(0,d) + mm.write(fname,2) + fs.appendGlobs(fmts2,1e-12) + fs.appendGlobs(fmts3,1e-12) + fs.write(fname,0) + ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values + ms=MEDFileMeshes(fname) + fields=MEDFileFields(fname,False) + fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()] + allFMTSLeavesToDisplay=[] + for fields in fields_per_mesh: + allFMTSLeavesToDisplay2=[] + for fmts in fields: + allFMTSLeavesToDisplay2+=fmts.splitDiscretizations() + pass + allFMTSLeavesToDisplay.append(allFMTSLeavesToDisplay2) + pass + self.assertEqual(len(allFMTSLeavesToDisplay),1) + self.assertEqual(len(allFMTSLeavesToDisplay[0]),4) + allFMTSLeavesPerTimeSeries=MEDFileAnyTypeFieldMultiTS.SplitIntoCommonTimeSeries(sum(allFMTSLeavesToDisplay,[])) + self.assertEqual(len(allFMTSLeavesPerTimeSeries),1) + self.assertEqual(len(allFMTSLeavesPerTimeSeries[0]),4) + allFMTSLeavesPerCommonSupport1=MEDFileAnyTypeFieldMultiTS.SplitPerCommonSupport(allFMTSLeavesToDisplay[0],ms[ms.getMeshesNames()[0]]) + self.assertEqual(len(allFMTSLeavesPerCommonSupport1),2) + self.assertEqual(len(allFMTSLeavesPerCommonSupport1[0][0]),2) + self.assertEqual(len(allFMTSLeavesPerCommonSupport1[1][0]),2) + # + mst=MEDFileMeshStruct.New(ms[0]) + # + fcscp=allFMTSLeavesPerCommonSupport1[0][1] + mml=fcscp.buildFromScratchDataSetSupport(0,fields) + mml2=mml.prepare() + self.assertTrue(isinstance(mml2,MEDUMeshMultiLev)) + ncc,a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() + self.assertTrue(not ncc) + self.assertTrue(a0.isEqual(DataArrayDouble([0.,0.,0.,1.,0.,0.,2.,0.,0.,3.,0.,0.,4.,0.,0.,0.,1.,0.,1.,1.,0.,2.,1.,0.,3.,1.,0.,4.,1.,0.,0.,2.,0.,1.,2.,0.,2.,2.,0.,3.,2.,0.,4.,2.,0.,0.,3.,0.,1.,3.,0.,2.,3.,0.,3.,3.,0.,4.,3.,0.,0.,4.,0.,1.,4.,0.,2.,4.,0.,3.,4.,0.,4.,4.,0.],25,3),1e-12)) + self.assertTrue(a1.isEqual(DataArrayByte([9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9]))) + self.assertTrue(a2.isEqual(DataArrayInt([0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75]))) + self.assertTrue(a3.isEqual(DataArrayInt([4,1,0,5,6,4,2,1,6,7,4,3,2,7,8,4,4,3,8,9,4,6,5,10,11,4,7,6,11,12,4,8,7,12,13,4,9,8,13,14,4,11,10,15,16,4,12,11,16,17,4,13,12,17,18,4,14,13,18,19,4,16,15,20,21,4,17,16,21,22,4,18,17,22,23,4,19,18,23,24]))) + self.assertTrue(a4 is None) + self.assertTrue(a5 is None) + a6,a7=mml2.retrieveFamilyIdsOnCells() + self.assertTrue(a6.isEqual(DataArrayInt([-5,-5,-5,-5,-6,-6,-6,-5,-7,-7,-7,-5,-5,-5,-5,-5]))) + self.assertTrue(a7) # no copy here + a8,a9=mml2.retrieveNumberIdsOnCells() + self.assertTrue(a8.isEqual(DataArrayInt([0,11,22,33,44,55,66,77,88,99,110,121,132,143,154,165]))) + self.assertTrue(a9) # no copy here + a10,a11=mml2.retrieveFamilyIdsOnNodes() + self.assertTrue(a10.isEqual(DataArrayInt([1,1,1,1,1,1,2,2,2,1,3,4,2,2,1,3,4,2,2,1,3,3,1,1,1]))) + self.assertTrue(a11) # no copy here + a12,a13=mml2.retrieveNumberIdsOnNodes() + self.assertTrue(a12.isEqual(DataArrayInt([0,10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170,180,190,200,210,220,230,240]))) + self.assertTrue(a13) # no copy here + for i in xrange(1,2): + self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))) + pass + for i in xrange(2): + f=allFMTSLeavesPerCommonSupport1[0][0][0][i] + fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst) + f.loadArraysIfNecessary() + v=mml.buildDataArray(fsst,fields,f.getUndergroundDataArray()) + self.assertEqual(f.getName(),fieldName1) + self.assertEqual(v.getHiddenCppPointer(),f.getUndergroundDataArray().getHiddenCppPointer()) + vExp=DataArrayDouble([0.7071067811865476,1.5811388300841898,2.5495097567963922,3.5355339059327378,1.5811388300841898,2.1213203435596424,2.9154759474226504,3.8078865529319543,2.5495097567963922,2.9154759474226504,3.5355339059327378,4.301162633521313,3.5355339059327378,3.8078865529319543,4.301162633521313,4.949747468305833]) + if i==1: vExp.reverse() + vExp.setInfoOnComponents(["zeInfoCell"]) + self.assertTrue(v.isEqual(vExp,1e-12)) + # + f=allFMTSLeavesPerCommonSupport1[0][0][1][i] + fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst) + f.loadArraysIfNecessary() + v=mml.buildDataArray(fsst,fields,f.getUndergroundDataArray()) + self.assertEqual(f.getName(),fieldName0) + self.assertEqual(v.getHiddenCppPointer(),f.getUndergroundDataArray().getHiddenCppPointer()) + vExp=DataArrayDouble([0.,1.,2.,3.,4.,1.,1.4142135623730951,2.23606797749979,3.1622776601683795,4.123105625617661,2.,2.23606797749979,2.8284271247461903,3.605551275463989,4.47213595499958,3.,3.1622776601683795,3.605551275463989,4.242640687119285,5.,4.,4.123105625617661,4.47213595499958,5.,5.656854249492381]) + if i==1: vExp.reverse() + vExp.setInfoOnComponents(["zeInfo"]) + self.assertTrue(v.isEqual(vExp,1e-12)) + pass + ### Testing the 2nd support + fcscp=allFMTSLeavesPerCommonSupport1[1][1] + mml=fcscp.buildFromScratchDataSetSupport(0,fields) + mml2=mml.prepare() + self.assertTrue(isinstance(mml2,MEDUMeshMultiLev)) + ncc,a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() + self.assertTrue(not ncc) + self.assertTrue(not ncc) + self.assertTrue(a0.isEqual(DataArrayDouble([0.,1.,0.,1.,1.,0.,2.,1.,0.,0.,2.,0.,1.,2.,0.,2.,2.,0.,0.,3.,0.,1.,3.,0.,2.,3.,0.,0.,4.,0.,1.,4.,0.,2.,4.,0.],12,3),1e-12)) + self.assertTrue(a1.isEqual(DataArrayByte([9,9,9,9,9,9]))) + self.assertTrue(a2.isEqual(DataArrayInt([0,5,10,15,20,25]))) + self.assertTrue(a3.isEqual(DataArrayInt([4,1,0,3,4,4,2,1,4,5,4,4,3,6,7,4,5,4,7,8,4,7,6,9,10,4,8,7,10,11]))) + self.assertTrue(a4 is None) + self.assertTrue(a5 is None) + a6,a7=mml2.retrieveFamilyIdsOnCells() + self.assertTrue(a6.isEqual(DataArrayInt([-6,-6,-7,-7,-5,-5]))) + self.assertTrue(not a7) # copy here + a8,a9=mml2.retrieveNumberIdsOnCells() + self.assertTrue(a8.isEqual(DataArrayInt([44,55,88,99,132,143]))) + self.assertTrue(not a9) # copy here + a10,a11=mml2.retrieveFamilyIdsOnNodes() + self.assertTrue(a10.isEqual(DataArrayInt([1,2,2,3,4,2,3,4,2,3,3,1]))) + self.assertTrue(not a11) # copy here + a12,a13=mml2.retrieveNumberIdsOnNodes() + self.assertTrue(a12.isEqual(DataArrayInt([50,60,70,100,110,120,150,160,170,200,210,220]))) + self.assertTrue(not a13) # copy here + for i in xrange(2): + f=allFMTSLeavesPerCommonSupport1[1][0][0][i] + fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst) + f.loadArraysIfNecessary() + v=mml.buildDataArray(fsst,fields,f.getUndergroundDataArray()) + self.assertEqual(f.getName(),fieldName3) + self.assertEqual(v.getHiddenCppPointer(),f.getUndergroundDataArray().getHiddenCppPointer()) + vExp=DataArrayDouble([1.5811388300842,2.1213203435596,2.5495097567964,2.9154759474227,3.5355339059327,3.807886552932]) + if i==1: vExp.reverse() + vExp.setInfoOnComponents(["abcdefg"]) + self.assertTrue(v.isEqual(vExp,1e-12)) + # + f=allFMTSLeavesPerCommonSupport1[1][0][1][i] + fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst) + f.loadArraysIfNecessary() + v=mml.buildDataArray(fsst,fields,f.getUndergroundDataArray()) + self.assertEqual(f.getName(),fieldName2) + self.assertEqual(v.getHiddenCppPointer(),f.getUndergroundDataArray().getHiddenCppPointer()) + vExp=DataArrayDouble([1.,1.4142135623731,2.2360679774998,2.,2.2360679774998,2.8284271247462,3.,3.1622776601684,3.605551275464,4.,4.1231056256177,4.4721359549996]) + if i==1: vExp.reverse() + vExp.setInfoOnComponents(["zzzz"]) + self.assertTrue(v.isEqual(vExp,1e-12)) + pass + pass pass unittest.main() diff --git a/src/MEDLoader/Swig/SauvLoaderTest.py b/src/MEDLoader/Swig/SauvLoaderTest.py index 0da6104cd..c122256e9 100644 --- a/src/MEDLoader/Swig/SauvLoaderTest.py +++ b/src/MEDLoader/Swig/SauvLoaderTest.py @@ -34,7 +34,7 @@ class SauvLoaderTest(unittest.TestCase): # read SAUV and write MED medFile = "SauvLoaderTest.med" - sr=SauvReader.New(sauvFile); + sr=SauvReader(sauvFile); d2=sr.loadInMEDFileDS(); d2.write(medFile,0); @@ -95,7 +95,7 @@ class SauvLoaderTest(unittest.TestCase): # write pointeMed to SAUV sauvFile = "SauvLoaderTest.sauv" - sw=SauvWriter.New(); + sw=SauvWriter(); sw.setMEDFileDS(pointeMed); sw.write(sauvFile); @@ -321,9 +321,70 @@ class SauvLoaderTest(unittest.TestCase): self.assertTrue( f2.isEqual( f, 1e-12, 1e-12 )) del sr os.remove( sauvFile ) + pass + def testSauvWriterGroupWithOneFamily(self): + """ + This test checks an option for sauv writing. It is requested here to copy a group from a family if a group is lying on a single family. + """ + import re + mfd=MEDLoaderDataForTest.buildAMEDFileDataWithGroupOnOneFamilyForSauv() + sauvFile = "mesh.sauv" + sw=SauvWriter.New() + sw.setMEDFileDS(mfd) + self.assertTrue(not sw.getCpyGrpIfOnASingleFamilyStatus()) + sw.setCpyGrpIfOnASingleFamilyStatus(True) + self.assertTrue(sw.getCpyGrpIfOnASingleFamilyStatus()) + sw.write(sauvFile) + + f = open(sauvFile) + # String pattern for the header of the sub meshes record ("PILE" number, number of named objects, number of objects) + pattern_pile= re.compile(r'\sPILE\sNUMERO\s+(?P[0-9]+)NBRE\sOBJETS\sNOMMES\s+(?P[0-9]+)NBRE\sOBJETS\s+(?P[0-9]+)') + # String pattern for a sub mesh header (cell type, number of components and three numbers) + pattern_header=re.compile(r'\s+(?P[0-9]+)\s+(?P[0-9]+)\s+[0-9]+\s+[0-9]+\s+[0-9]+') + + nbobjects=0 + line = f.readline() + while(line): + match_pile = pattern_pile.match(line) + if match_pile: + number=int(match_pile.group("number")) + if number == 1: + nbnamed=int(match_pile.group("nbnamed")) + nbobjects=int(match_pile.group("nbobjects")) + break + pass + line=f.readline() + pass + + # Skipping the objects names + f.readline() + # Skipping the objects ids + f.readline() + # Looking for each sub-mesh header + line = f.readline() + cur_object=0 + while(line and cur_object < nbobjects): + match_header=pattern_header.match(line) + if match_header: + cell_type=int(match_header.group("type")) + nb_subs=int(match_header.group("nbsubs")) + # Looking for a compound object + if cell_type == 0: + # Testing if there is only one component + self.assertTrue(nb_subs > 1) + else: + f.readline() + f.readline() + cur_object = cur_object + 1 + pass + pass + line=f.readline() + pass + os.remove(sauvFile) pass + pass unittest.main() diff --git a/src/MEDLoader/Test/CMakeLists.txt b/src/MEDLoader/Test/CMakeLists.txt index ccc78ea8b..62cbd28ae 100644 --- a/src/MEDLoader/Test/CMakeLists.txt +++ b/src/MEDLoader/Test/CMakeLists.txt @@ -47,5 +47,7 @@ ADD_EXECUTABLE(TestSauvLoader ${TestSauvLoader_SOURCES}) TARGET_LINK_LIBRARIES(TestSauvLoader medloader ${CPPUNIT_LIBRARIES} ${PLATFORM_LIBS}) ADD_TEST(TestSauvLoader TestSauvLoader) +SALOME_GENERATE_TESTS_ENVIRONMENT(tests_env) +SET_TESTS_PROPERTIES(TestSauvLoader PROPERTIES ENVIRONMENT "${tests_env}") INSTALL(TARGETS TestMEDLoader TestSauvLoader DESTINATION ${SALOME_INSTALL_BINS}) diff --git a/src/MEDOP/doc/sphinx/conf.py.in b/src/MEDOP/doc/sphinx/conf.py.in index 9c8bdda8f..a5b52f77c 100644 --- a/src/MEDOP/doc/sphinx/conf.py.in +++ b/src/MEDOP/doc/sphinx/conf.py.in @@ -75,6 +75,11 @@ language = 'fr' # for source files. exclude_trees = ['.build','ref','images','CVS','.svn'] +# A list of glob-style patterns that should be excluded when looking for source +# files. They are matched against the source file names relative to the +# source directory, using slashes as directory separators on all platforms. +exclude_patterns = ['**/CVS'] + # The reST default role (used for this markup: `text`) to use for all documents. #default_role = None diff --git a/src/MEDOP/gui/MEDOP_msg_fr.ts b/src/MEDOP/gui/MEDOP_msg_fr.ts index 905d9fc6b..6c007facf 100644 --- a/src/MEDOP/gui/MEDOP_msg_fr.ts +++ b/src/MEDOP/gui/MEDOP_msg_fr.ts @@ -1,6 +1,30 @@ @default + + MEN_BUILDER3 + Load a python script + + + STS_BUILDER3 + Load a python script + + + TLT_BUILDER3 + Load a python script + + + STS_LOAD_DXF + Load DXF file + + + MEN_LOAD_DXF + Load DXF file + + + TLT_LOAD_DXF + Load DXF file + TLT_MY_NEW_ITEM My menu item diff --git a/src/MEDOP/gui/MEDOP_msg_ja.ts b/src/MEDOP/gui/MEDOP_msg_ja.ts index f43c267d4..3dc6b4f85 100644 --- a/src/MEDOP/gui/MEDOP_msg_ja.ts +++ b/src/MEDOP/gui/MEDOP_msg_ja.ts @@ -96,7 +96,7 @@ XMEDGUI_maquette BUT_OK - わかりました + OK QUE_XMED_LABEL @@ -104,7 +104,7 @@ QUE_XMED_NAME - あなたの名前を入力してください、 + あなたの名前を入力してください。 INF_XMED_BANNER @@ -112,7 +112,7 @@ INF_XMED_MENU - これはテストです。 + これはただのテストです。 diff --git a/src/MEDOP/gui/MED_msg_ja.ts b/src/MEDOP/gui/MED_msg_ja.ts index fe5e5519b..ab58eef65 100644 --- a/src/MEDOP/gui/MED_msg_ja.ts +++ b/src/MEDOP/gui/MED_msg_ja.ts @@ -6,67 +6,67 @@ LAB_ADD_DATA_SOURCE - LAB_ADD_DATA_SOURCE + データのインポート MED TIP_ADD_DATA_SOURCE - TIP_ADD_DATA_SOURCE + MED のファイルをインポートしたデータを追加します。 LAB_ADD_IMAGE_SOURCE - LAB_ADD_IMAGE_SOURCE + 画像を追加します。 TIP_ADD_IMAGE_SOURCE - TIP_ADD_IMAGE_SOURCE + イメージ ファイルのインポートを使用してデータを追加します。 LAB_EXPAND_FIELD - LAB_EXPAND_FIELD + 拡張フィールドの時系列 LAB_VISUALIZE - LAB_VISUALIZE + ビュー LAB_USE_IN_WORKSPACE - LAB_USE_IN_WORKSPACE + ワークスペースを使用します。 LAB_CHANGE_MESH - LAB_CHANGE_MESH + 基になるメッシュを変更します。 IMPORT_MED_FIELDS - IMPORT_MED_FIELDS + (MED のサイズ) フィールドをインポートします。 OPERATION_FAILED - OPERATION_FAILED + 操作が失敗しました CREATION_FAILED - CREATION_FAILED + イメージ ファイルの作成からの医学データに失敗しました OPERATION_NOT_ALLOWED - OPERATION_NOT_ALLOWED + 許可されていない操作 FIELD_ALREADY_DEFINED - FIELD_ALREADY_DEFINED + このフィールドは、ワークスペースで既に定義されて @@ -74,22 +74,22 @@ SELECT_AN_ALIAS_FOR_THE_FIELD - SELECT_AN_ALIAS_FOR_THE_FIELD + このフィールドのエイリアスを選択します DEFINE_AN_ALIAS - DEFINE_AN_ALIAS + コンソールでフィールドを操作するエイリアスを設定できます。 ALIAS - ALIAS + エイリアス MSG_OPERATION_DEFINES_VARIABLE - MSG_OPERATION_DEFINES_VARIABLE + (この操作はテキスト コンソールに<alias>という名前の変数を定義します。型 '<alias>. help()"利用可能な機能または単に「doc」参照する)</alias> </alias> @@ -97,32 +97,27 @@ FORM - FORM - - - - SELECT_MESH - SELECT_MESH + フォーム MESH_GT - MESH_GT + -> メッシュします。 MSG_EXPLORER - MSG_EXPLORER + (エクスプ ローラー データ空間で参照される MED (メッシュとフィールド) のデータのビューを提供します) DATA_VERIFICATION - DATA_VERIFICATION + データの検証 SELECT_MESH - SELECT_MESH + エクスプ ローラーでメッシュを選択し、メッシュをクリックする必要があります。 @@ -130,32 +125,32 @@ FORM - FORM + フォーム IMAGE_FILE - IMAGE_FILE + 画像ファイル: MED_FILE - MED_FILE + MED ファイル: SELECT_IMAGE_FILE - SELECT_IMAGE_FILE + イメージ ファイルを選択します。 SPECIFY_MED_FILE - SPECIFY_MED_FILE + MED ファイルを指定します。 LOAD_AUTOMATICALLY - LOAD_AUTOMATICALLY + 自動的に読み込む @@ -163,17 +158,17 @@ FORM - FORM + フォーム PRESSURE - PRESSURE + 圧力: TEMPERATURE - TEMPERATURE + 温度: @@ -181,7 +176,7 @@ DIALOG - DIALOG + ダイアログ @@ -189,17 +184,17 @@ IMPORT_FROM_FILE - IMPORT_FROM_FILE + ファイルからのインポートします。 IMPORT_MED_FILE - IMPORT_MED_FILE + MEDファイルをインポート MEN_FILE - MEN_FILE + ファイル(&F) @@ -207,67 +202,67 @@ VISUALIZE_SCALAR_MAP - VISUALIZE_SCALAR_MAP + ビュー (マップ スカラー) USE_IN_CONSOLE - USE_IN_CONSOLE + (コンソール) を使用してください。 EXPORT_TO_PARAVIS - EXPORT_TO_PARAVIS + エクスポート (にそこに) SAVE_AS_MED - SAVE_AS_MED + (MED ファイル) に保存します。 REMOVE_FROM_WORKSPACE - REMOVE_FROM_WORKSPACE + (ワークスペース) の削除します。 LAB_SAVE_WORKSPACE - LAB_SAVE_WORKSPACE + ワークスペースを保存します。 TIP_SAVE_WORKSPACE - TIP_SAVE_WORKSPACE + MED ファイル (フィールドおよびメッシュ) ワークスペースを保存します。 LAB_CLEAN_WORKSPACE - LAB_CLEAN_WORKSPACE + 作業領域をきれいに TIP_CLEAN_WORKSPACE - TIP_CLEAN_WORKSPACE + ワークスペースからすべてのデータを消去します。 SAVE_SELECTED_FIELDS - SAVE_SELECTED_FIELDS + 選択したフィールドを保存します。 SAVE_WORKSPACE_DATA - SAVE_WORKSPACE_DATA + ワークスペースからデータを保存します。 NOT_IMPLEMENTED_YET - NOT_IMPLEMENTED_YET + 実装されていません FUNCTION_NOT_IMPLEMENTED - FUNCTION_NOT_IMPLEMENTED + この機能はまだ実装されていません @@ -275,27 +270,27 @@ FILE_FILTER_MED - FILE_FILTER_MED + 音楽配信マック & ファイル (* .med) FILE_FILTER_PNG - FILE_FILTER_PNG + イメージ PNG (*.png) FILE_FILTER_JPG - FILE_FILTER_JPG + 画像 JPG (*.jpg) FILE_FILTER_PGM - FILE_FILTER_PGM + イメージ PGM (*.jpg) FILE_FILTER_ALL - FILE_FILTER_ALL + すべてのファイル (*. *) diff --git a/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionMedXmlDriver.cxx b/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionMedXmlDriver.cxx index 348f1be56..bf1ed9630 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionMedXmlDriver.cxx +++ b/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionMedXmlDriver.cxx @@ -200,7 +200,7 @@ void MeshCollectionMedXmlDriver::write(const char* filename, ParaDomainSelector* //Description tag time_t present; - char date[6]; + char date[20]; #ifndef WIN32 time( &present); struct tm *time_asc = localtime(&present); diff --git a/src/MEDPartitioner/Test/CMakeLists.txt b/src/MEDPartitioner/Test/CMakeLists.txt index f981249c8..301e159c0 100644 --- a/src/MEDPartitioner/Test/CMakeLists.txt +++ b/src/MEDPartitioner/Test/CMakeLists.txt @@ -51,4 +51,6 @@ INSTALL(TARGETS TestMEDPARTITIONER DESTINATION ${SALOME_INSTALL_BINS}) INSTALL(FILES ${MEDPARTITIONERTest_HEADERS_HXX} DESTINATION ${SALOME_INSTALL_HEADERS}) +SALOME_GENERATE_TESTS_ENVIRONMENT(tests_env) ADD_TEST(TestMEDPARTITIONER TestMEDPARTITIONER) +SET_TESTS_PROPERTIES(TestMEDPARTITIONER PROPERTIES ENVIRONMENT "${tests_env}") diff --git a/src/MEDPartitioner/Test/MEDPARTITIONERTest.cxx b/src/MEDPartitioner/Test/MEDPARTITIONERTest.cxx index 92143c936..fe91ce480 100644 --- a/src/MEDPartitioner/Test/MEDPARTITIONERTest.cxx +++ b/src/MEDPartitioner/Test/MEDPARTITIONERTest.cxx @@ -748,7 +748,7 @@ void MEDPARTITIONERTest::verifyTestMeshWithVecFieldOnNodes() string name=_file_name; name.replace(name.find(".med"),4,"_WithVecFieldOnNodes.med"); MEDCouplingUMesh * m=MEDLoader::ReadUMeshFromFile(name.c_str(),_mesh_name.c_str(),0); - const std::set& types=m->getAllTypes(); + std::set types(m->getAllGeoTypes()); if (_verbose) { cout<<"\n types in "<getMeshDimension()); CPPUNIT_ASSERT_EQUAL(16,mesh->getNumberOfCells()); CPPUNIT_ASSERT_EQUAL(19,mesh->getNumberOfNodes()); - CPPUNIT_ASSERT_EQUAL(3,(int)mesh->getAllTypes().size()); + CPPUNIT_ASSERT_EQUAL(3,(int)mesh->getAllGeoTypes().size()); for(int i=0;i<12;i++) CPPUNIT_ASSERT_EQUAL(NORM_TETRA4,mesh->getTypeOfCell(i)); CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,mesh->getTypeOfCell(12)); @@ -67,7 +67,7 @@ void ParaMEDMEMTest::testMEDLoaderRead1() CPPUNIT_ASSERT_EQUAL(3,mesh->getMeshDimension()); CPPUNIT_ASSERT_EQUAL(2,mesh->getNumberOfCells()); CPPUNIT_ASSERT_EQUAL(19,mesh->getNumberOfNodes()); - CPPUNIT_ASSERT_EQUAL(2,(int)mesh->getAllTypes().size()); + CPPUNIT_ASSERT_EQUAL(2,(int)mesh->getAllGeoTypes().size()); CPPUNIT_ASSERT_EQUAL(NORM_TETRA4,mesh->getTypeOfCell(0)); CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,mesh->getTypeOfCell(1)); CPPUNIT_ASSERT_EQUAL((std::size_t)11,mesh->getNodalConnectivity()->getNbOfElems()); @@ -90,7 +90,7 @@ void ParaMEDMEMTest::testMEDLoaderRead1() CPPUNIT_ASSERT_EQUAL(3,mesh->getMeshDimension()); CPPUNIT_ASSERT_EQUAL(7,mesh->getNumberOfCells()); CPPUNIT_ASSERT_EQUAL(19,mesh->getNumberOfNodes()); - CPPUNIT_ASSERT_EQUAL(2,(int)mesh->getAllTypes().size()); + CPPUNIT_ASSERT_EQUAL(2,(int)mesh->getAllGeoTypes().size()); for(int i=0;i<6;i++) CPPUNIT_ASSERT_EQUAL(NORM_TETRA4,mesh->getTypeOfCell(i)); CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,mesh->getTypeOfCell(6)); @@ -129,7 +129,7 @@ void ParaMEDMEMTest::testMEDLoaderRead1() CPPUNIT_ASSERT_EQUAL(3,constMesh->getMeshDimension()); CPPUNIT_ASSERT_EQUAL(16,constMesh->getNumberOfCells()); CPPUNIT_ASSERT_EQUAL(19,constMesh->getNumberOfNodes()); - CPPUNIT_ASSERT_EQUAL(3,(int)constMesh->getAllTypes().size()); + CPPUNIT_ASSERT_EQUAL(3,(int)constMesh->getAllGeoTypes().size()); for(int i=0;i<12;i++) CPPUNIT_ASSERT_EQUAL(NORM_TETRA4,constMesh->getTypeOfCell(i)); CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,constMesh->getTypeOfCell(12)); @@ -158,7 +158,7 @@ void ParaMEDMEMTest::testMEDLoaderRead1() CPPUNIT_ASSERT_EQUAL(3,constMesh->getMeshDimension()); CPPUNIT_ASSERT_EQUAL(16,constMesh->getNumberOfCells()); CPPUNIT_ASSERT_EQUAL(19,constMesh->getNumberOfNodes()); - CPPUNIT_ASSERT_EQUAL(3,(int)constMesh->getAllTypes().size()); + CPPUNIT_ASSERT_EQUAL(3,(int)constMesh->getAllGeoTypes().size()); for(int i=0;i<12;i++) CPPUNIT_ASSERT_EQUAL(NORM_TETRA4,constMesh->getTypeOfCell(i)); CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,constMesh->getTypeOfCell(12)); @@ -212,7 +212,7 @@ void ParaMEDMEMTest::testMEDLoaderRead1() CPPUNIT_ASSERT_EQUAL(3,constMesh->getMeshDimension()); CPPUNIT_ASSERT_EQUAL(16,constMesh->getNumberOfCells()); CPPUNIT_ASSERT_EQUAL(19,constMesh->getNumberOfNodes()); - CPPUNIT_ASSERT_EQUAL(3,(int)constMesh->getAllTypes().size()); + CPPUNIT_ASSERT_EQUAL(3,(int)constMesh->getAllGeoTypes().size()); for(int i=0;i<12;i++) CPPUNIT_ASSERT_EQUAL(NORM_TETRA4,constMesh->getTypeOfCell(i)); CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,constMesh->getTypeOfCell(12)); @@ -240,7 +240,7 @@ void ParaMEDMEMTest::testMEDLoaderRead1() CPPUNIT_ASSERT_EQUAL(3,constMesh->getMeshDimension()); CPPUNIT_ASSERT_EQUAL(16,constMesh->getNumberOfCells()); CPPUNIT_ASSERT_EQUAL(19,constMesh->getNumberOfNodes()); - CPPUNIT_ASSERT_EQUAL(3,(int)constMesh->getAllTypes().size()); + CPPUNIT_ASSERT_EQUAL(3,(int)constMesh->getAllGeoTypes().size()); for(int i=0;i<12;i++) CPPUNIT_ASSERT_EQUAL(NORM_TETRA4,constMesh->getTypeOfCell(i)); CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,constMesh->getTypeOfCell(12)); @@ -266,7 +266,7 @@ void ParaMEDMEMTest::testMEDLoaderPolygonRead() CPPUNIT_ASSERT_EQUAL(2,mesh->getMeshDimension()); CPPUNIT_ASSERT_EQUAL(538,mesh->getNumberOfCells()); CPPUNIT_ASSERT_EQUAL(579,mesh->getNumberOfNodes()); - CPPUNIT_ASSERT_EQUAL(2,(int)mesh->getAllTypes().size()); + CPPUNIT_ASSERT_EQUAL(2,(int)mesh->getAllGeoTypes().size()); for(int i=0;i<514;i++) CPPUNIT_ASSERT_EQUAL(NORM_QUAD4,mesh->getTypeOfCell(i)); for(int i=514;i<538;i++) @@ -300,7 +300,7 @@ void ParaMEDMEMTest::testMEDLoaderPolygonRead() CPPUNIT_ASSERT_EQUAL(2,constMesh->getMeshDimension()); CPPUNIT_ASSERT_EQUAL(538,constMesh->getNumberOfCells()); CPPUNIT_ASSERT_EQUAL(579,constMesh->getNumberOfNodes()); - CPPUNIT_ASSERT_EQUAL(2,(int)constMesh->getAllTypes().size()); + CPPUNIT_ASSERT_EQUAL(2,(int)constMesh->getAllGeoTypes().size()); for(int i=0;i<514;i++) CPPUNIT_ASSERT_EQUAL(NORM_QUAD4,constMesh->getTypeOfCell(i)); for(int i=514;i<538;i++) @@ -329,7 +329,7 @@ void ParaMEDMEMTest::testMEDLoaderPolyhedronRead() CPPUNIT_ASSERT_EQUAL(3,mesh->getMeshDimension()); CPPUNIT_ASSERT_EQUAL(3,mesh->getNumberOfCells()); CPPUNIT_ASSERT_EQUAL(19,mesh->getNumberOfNodes()); - CPPUNIT_ASSERT_EQUAL(2,(int)mesh->getAllTypes().size()); + CPPUNIT_ASSERT_EQUAL(2,(int)mesh->getAllGeoTypes().size()); CPPUNIT_ASSERT_EQUAL(NORM_TETRA4,mesh->getTypeOfCell(0)); CPPUNIT_ASSERT_EQUAL(NORM_POLYHED,mesh->getTypeOfCell(1)); CPPUNIT_ASSERT_EQUAL(NORM_POLYHED,mesh->getTypeOfCell(2)); @@ -345,7 +345,7 @@ void ParaMEDMEMTest::testMEDLoaderPolyhedronRead() CPPUNIT_ASSERT_EQUAL(2,mesh->getMeshDimension()); CPPUNIT_ASSERT_EQUAL(17,mesh->getNumberOfCells()); CPPUNIT_ASSERT_EQUAL(19,mesh->getNumberOfNodes()); - CPPUNIT_ASSERT_EQUAL(3,(int)mesh->getAllTypes().size()); + CPPUNIT_ASSERT_EQUAL(3,(int)mesh->getAllGeoTypes().size()); CPPUNIT_ASSERT_EQUAL(NORM_POLYGON,mesh->getTypeOfCell(0)); CPPUNIT_ASSERT_EQUAL(NORM_QUAD4,mesh->getTypeOfCell(1)); CPPUNIT_ASSERT_EQUAL(NORM_QUAD4,mesh->getTypeOfCell(2)); @@ -382,7 +382,7 @@ void ParaMEDMEMTest::testMEDLoaderPolyhedronRead() CPPUNIT_ASSERT_EQUAL(2,mesh->getMeshDimension()); CPPUNIT_ASSERT_EQUAL(3,mesh->getNumberOfCells()); CPPUNIT_ASSERT_EQUAL(19,mesh->getNumberOfNodes()); - CPPUNIT_ASSERT_EQUAL(1,(int)mesh->getAllTypes().size()); + CPPUNIT_ASSERT_EQUAL(1,(int)mesh->getAllGeoTypes().size()); for(int i=0;i<3;i++) CPPUNIT_ASSERT_EQUAL(NORM_POLYGON,mesh->getTypeOfCell(i)); CPPUNIT_ASSERT_EQUAL((std::size_t)19,mesh->getNodalConnectivity()->getNbOfElems()); @@ -394,6 +394,6 @@ void ParaMEDMEMTest::testMEDLoaderPolyhedronRead() CPPUNIT_ASSERT_EQUAL(0,mesh->getNumberOfCells()); CPPUNIT_ASSERT_EQUAL(19,mesh->getNumberOfNodes()); CPPUNIT_ASSERT_EQUAL(3,mesh->getMeshDimension()); - CPPUNIT_ASSERT_EQUAL(0,(int)mesh->getAllTypes().size()); + CPPUNIT_ASSERT_EQUAL(0,(int)mesh->getAllGeoTypes().size()); mesh->decrRef(); } diff --git a/src/RENUMBER_Swig/CMakeLists.txt b/src/RENUMBER_Swig/CMakeLists.txt index 128e365f5..3b36feefe 100644 --- a/src/RENUMBER_Swig/CMakeLists.txt +++ b/src/RENUMBER_Swig/CMakeLists.txt @@ -65,4 +65,6 @@ INSTALL_AND_COMPILE_PYTHON_FILE("${PYFILES_TO_INSTALL}" ${SALOME_INSTALL_SCRIPT_ INSTALL(FILES MEDRenumber.i MEDRenumberCommon.i DESTINATION ${SALOME_INSTALL_HEADERS}) INSTALL(FILES MEDRenumberTest.py DESTINATION ${SALOME_INSTALL_SCRIPT_PYTHON}) +SALOME_GENERATE_TESTS_ENVIRONMENT(tests_env) ADD_TEST(MEDRenumberTest ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/MEDRenumberTest.py) +SET_TESTS_PROPERTIES(MEDRenumberTest PROPERTIES ENVIRONMENT "${tests_env}")