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})
# !! 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
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)
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
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)
# and puts this variable into <output> 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<ModuleName>"
+ 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)
#########################################################################
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()
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);
_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;
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()<ref)
+ {
+ if((*iter4).getNodeOnly()->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(val<ref)
+ {
+ if((*iter4).getNodeOnly()->getLoc()==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);
// 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<ElementaryEdge *>::const_iterator iter4=_sub_edges.begin();iter4!=_sub_edges.end();iter4++)
{
ElementaryEdge *val=(*iter4);
//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()<ref)
- {
- if((*iter4).getNodeOnly()->getLoc()==ON_1)
- ret=!ret;
- }
- else
- break;
- }
- return ret;
+ return ref;
}
/*bool ComposedEdge::isInOrOut(Node *aNodeOn, Node *nodeToTest) const
#define __INTERPKERNELGEO2DCOMPOSEDNODE_HXX__
#include "INTERPKERNELDefines.hxx"
+#include "InterpKernelGeo2DEdge.hxx"
#include <set>
#include <list>
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);
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<ElementaryEdge *>* getListBehind() { return &_sub_edges; }
+ double isInOrOutAlg(Node *nodeToTest, std::set< IntersectElement >& inOutSwitch) const;
protected:
~ComposedEdge();
private:
#include "InterpKernelGeo2DEdgeInfLin.hxx"
//#include "EdgeParabol.hxx"
#include "InterpKernelGeo2DEdgeArcCircle.hxx"
+#include "InterpKernelGeo2DComposedEdge.hxx"
#include "InterpKernelException.hxx"
#include <algorithm>
#define __INTERPKERNELGEO2DEDGE_HXX__
#include "INTERPKERNELDefines.hxx"
-#include "InterpKernelGeo2DComposedEdge.hxx"
#include "InterpKernelException.hxx"
#include "InterpKernelGeo2DBounds.hxx"
#include "InterpKernelGeo2DNode.hxx"
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.
#include "InterpKernelGeo2DElementaryEdge.hxx"
#include "InterpKernelException.hxx"
#include "InterpKernelGeo2DEdge.hxx"
+#include "InterpKernelGeo2DComposedEdge.hxx"
using namespace INTERP_KERNEL;
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})
/*!
* 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<DataArrayDouble> ret(DataArrayDouble::New()); ret->alloc(nbOfCells,2*spaceDim);
/*!
* 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());
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);
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);
std::set<INTERP_KERNEL::NormalizedCellType> MEDCouplingExtrudedMesh::getAllGeoTypes() const
{
- const std::set<INTERP_KERNEL::NormalizedCellType>& ret2D=_mesh2D->getAllTypes();
+ std::set<INTERP_KERNEL::NormalizedCellType> ret2D(_mesh2D->getAllGeoTypes());
std::set<INTERP_KERNEL::NormalizedCellType> ret;
for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=ret2D.begin();it!=ret2D.end();it++)
ret.insert(INTERP_KERNEL::CellModel::GetCellModel(*it).getExtrudedType());
* 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
* 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<DataArrayInt> ret(DataArrayInt::New()); ret->alloc(0,1);
int nbOfTuples=getNumberOfTuples();
for(int i=0;i<nbOfTuples;i++,cptr++)
checkAllocated();
if(getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("DataArrayInt::getIdsNotEqual : the array must have only one component, you can call 'rearrange' method before !");
- const int *cptr=getConstPointer();
+ const int *cptr(getConstPointer());
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret(DataArrayInt::New()); ret->alloc(0,1);
int nbOfTuples=getNumberOfTuples();
for(int i=0;i<nbOfTuples;i++,cptr++)
return ret.retn();
}
+/*!
+ * Creates a new DataArrayInt containing IDs (indices) of tuples holding tuple equal to those defined by [ \a tupleBg , \a tupleEnd )
+ * This method is an extension of DataArrayInt::getIdsEqual method.
+ *
+ * \param [in] tupleBg - the begin (included) of the input tuple to find within \a this.
+ * \param [in] tupleEnd - the end (excluded) of the input tuple to find within \a this.
+ * \return DataArrayInt * - a new instance of DataArrayInt. The caller is to delete this
+ * array using decrRef() as it is no more needed.
+ * \throw If \a this is not allocated.
+ * \throw If \a this->getNumberOfComponents() != 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<DataArrayInt> 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
* 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
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<int>& tupl) const;
MEDCOUPLING_EXPORT int locateValue(int value) const;
MEDCOUPLING_EXPORT void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const;
MEDCOUPLING_EXPORT void unserialization(const std::vector<double>& tinyInfoD, const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2,
const std::vector<std::string>& littleStrings);
- MEDCOUPLING_EXPORT 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();
* Returns a set of all cell types available in \a this mesh.
* \return std::set<INTERP_KERNEL::NormalizedCellType> - 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<INTERP_KERNEL::NormalizedCellType> 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<INTERP_KERNEL::NormalizedCellType> MEDCouplingUMesh::getAllGeoTypesSorted() const
+{
+ std::vector<INTERP_KERNEL::NormalizedCellType> 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<nbOfCells;i++,ci++)
+ if(ret.back()!=((INTERP_KERNEL::NormalizedCellType)c[*ci]))
+ ret.push_back((INTERP_KERNEL::NormalizedCellType)c[*ci]);
+ return ret;
+}
+
/*!
* This method is a method that compares \a this and \a other.
* This method compares \b all attributes, even names and component names.
* describing the cell types.
* \throw If the coordinates array is not set.
* \throw If the nodal connectivity of cells is not defined.
- * \sa getAllTypes()
+ * \sa getAllGeoTypes()
*/
std::set<INTERP_KERNEL::NormalizedCellType> MEDCouplingUMesh::getTypesOfPart(const int *begin, const int *end) const
{
/*!
* 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.
/*!
* 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.
{
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<DataArrayDouble> bboxArr(getBoundingBoxForBBTree());
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> bboxArr(getBoundingBoxForBBTree(eps));
const double *bbox(bboxArr->begin());
int nbOfCells=getNumberOfCells();
const int *conn=_nodal_connec->getConstPointer();
myTree.getIntersectingElems(bb,candidates);
for(std::vector<int>::const_iterator iter=candidates.begin();iter!=candidates.end();iter++)
{
- int sz=connI[(*iter)+1]-connI[*iter]-1;
- if(INTERP_KERNEL::PointLocatorAlgos<DummyClsMCUG<SPACEDIM> >::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<DummyClsMCUG<SPACEDIM> >::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<INTERP_KERNEL::Node *> nodes(sz);
+ INTERP_KERNEL::QuadraticPolygon *pol(0);
+ for(int j=0;j<sz;j++)
+ {
+ int nodeId(conn[connI[*iter]+1+j]);
+ nodes[j]=new INTERP_KERNEL::Node(coords[nodeId*SPACEDIM],coords[nodeId*SPACEDIM+1]);
+ }
+ if(!INTERP_KERNEL::CellModel::GetCellModel(ct).isQuadratic())
+ pol=INTERP_KERNEL::QuadraticPolygon::BuildLinearPolygon(nodes);
+ else
+ pol=INTERP_KERNEL::QuadraticPolygon::BuildArcCirclePolygon(nodes);
+ INTERP_KERNEL::Node *n(new INTERP_KERNEL::Node(pos[i*SPACEDIM],pos[i*SPACEDIM+1]));
+ double a(0.),b(0.),c(0.);
+ a=pol->normalizeMe(b,c); n->applySimilarity(b,c,a);
+ status=pol->isInOrOut2(n);
+ delete pol; n->decrRef();
+ }
+ if(status)
{
eltsIndexPtr[i+1]++;
elts->pushBackSilent(*iter);
* 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
/*!
* 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<INTERP_KERNEL::NormalizedCellType>::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());
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<DataArrayDouble> 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<nbOfCells;i++,bbox+=4,connI++)
+ {
+ const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel((INTERP_KERNEL::NormalizedCellType)conn[*connI]));
+ int sz(connI[1]-connI[0]-1);
+ INTERP_KERNEL::QUADRATIC_PLANAR::_arc_detection_precision=1e-12;
+ std::vector<INTERP_KERNEL::Node *> nodes(sz);
+ INTERP_KERNEL::QuadraticPolygon *pol(0);
+ for(int j=0;j<sz;j++)
+ {
+ int nodeId(conn[*connI+1+j]);
+ nodes[j]=new INTERP_KERNEL::Node(coords[nodeId*2],coords[nodeId*2+1]);
+ }
+ if(!cm.isQuadratic())
+ pol=INTERP_KERNEL::QuadraticPolygon::BuildLinearPolygon(nodes);
+ else
+ pol=INTERP_KERNEL::QuadraticPolygon::BuildArcCirclePolygon(nodes);
+ INTERP_KERNEL::Bounds b; pol->fillBounds(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
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<int> ret(3*n,-1); //ret[3*k+2]==-1 because it has no sense here
std::set<INTERP_KERNEL::NormalizedCellType> types;
for(std::size_t i=0;work!=connI+nbOfCells;i++)
const int *conn=_nodal_connec->getConstPointer();
const int *connI=_nodal_connec_index->getConstPointer();
int nbOfCells=getNumberOfCells();
- std::set<INTERP_KERNEL::NormalizedCellType> types=getAllTypes();
+ std::set<INTERP_KERNEL::NormalizedCellType> types(getAllGeoTypes());
int *tmp=new int[nbOfCells];
for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator iter=types.begin();iter!=types.end();iter++)
{
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 << " <Piece NumberOfPoints=\"" << getNumberOfNodes() << "\" NumberOfCells=\"" << nbOfCells << "\">\n";
ofs << " <PointData>\n" << pointData << std::endl;
MEDCOUPLING_EXPORT void finishInsertingCells();
MEDCOUPLING_EXPORT MEDCouplingUMeshCellIterator *cellIterator();
MEDCOUPLING_EXPORT MEDCouplingUMeshCellByTypeEntry *cellsByType();
- MEDCOUPLING_EXPORT const std::set<INTERP_KERNEL::NormalizedCellType>& getAllTypes() const { return _types; }
MEDCOUPLING_EXPORT std::set<INTERP_KERNEL::NormalizedCellType> getAllGeoTypes() const;
+ MEDCOUPLING_EXPORT std::vector<INTERP_KERNEL::NormalizedCellType> getAllGeoTypesSorted() const;
MEDCOUPLING_EXPORT std::set<INTERP_KERNEL::NormalizedCellType> 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; }
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;
MEDCouplingUMesh *subMesh=dynamic_cast<MEDCouplingUMesh *>(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());
subMesh=dynamic_cast<MEDCouplingUMesh *>(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());
MEDCouplingPointSet *subMeshSimple=mesh->buildPartOfMySelfNode(tab1,tab1+4,true);
MEDCouplingUMesh *subMesh=dynamic_cast<MEDCouplingUMesh *>(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());
subMeshSimple=mesh->buildPartOfMySelfNode(tab1,tab1+2,false);
subMesh=dynamic_cast<MEDCouplingUMesh *>(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());
subMeshSimple=mesh->buildPartOfMySelfNode(tab2,tab2+7,true);
subMesh=dynamic_cast<MEDCouplingUMesh *>(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();
//
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());
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());
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};
subMeshPtSet=mesh->buildPartOfMySelf(tab1,tab1+2,false);
subMesh=dynamic_cast<MEDCouplingUMesh *>(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());
{
MEDCouplingUMesh *mesh=build2DTargetMesh_3();
mesh->checkCoherency();
- const std::set<INTERP_KERNEL::NormalizedCellType>& types=mesh->getAllTypes();
+ std::set<INTERP_KERNEL::NormalizedCellType> 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<INTERP_KERNEL::NormalizedCellType> expected1Bis(expected1,expected1+5);
MEDCouplingFieldDouble *f2=mesh->getMeasureField(false);
CPPUNIT_ASSERT(f1->getArray()->isEqual(*f2->getArray(),1e-12));
CPPUNIT_ASSERT_EQUAL(48,mesh->getMeshLength());
- const std::set<INTERP_KERNEL::NormalizedCellType>& types2=mesh->getAllTypes();
- CPPUNIT_ASSERT_EQUAL(3,(int)types.size());
+ std::set<INTERP_KERNEL::NormalizedCellType> 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<INTERP_KERNEL::NormalizedCellType> expected2Bis(expected2,expected2+3);
CPPUNIT_ASSERT(expected2Bis==types2);
MEDCouplingFieldDouble *f=m->getMeasureField(false);
for(int i=0;i<7;i++)
CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i]*sqrt(2.),f->getIJ(i,0),1e-10);
- std::set<INTERP_KERNEL::NormalizedCellType> types=m->getAllTypes();
+ std::set<INTERP_KERNEL::NormalizedCellType> 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())));
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())));
CPPUNIT_ASSERT_EQUAL(4,m->getNumberOfCells());
CPPUNIT_ASSERT_EQUAL(3,m->getSpaceDimension());
CPPUNIT_ASSERT_EQUAL(0,m->getMeshDimension());
- const std::set<INTERP_KERNEL::NormalizedCellType>& types=m->getAllTypes();
+ std::set<INTERP_KERNEL::NormalizedCellType> 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++)
// resize with explicit ids list
MEDCouplingUMesh *m=build2DTargetMesh_1();
std::set<INTERP_KERNEL::NormalizedCellType> 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<MEDCouplingUMesh *>(m->buildPartOfMySelf(ids1,ids1+3,true));
part->simplexize(0)->decrRef();
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();
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();
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();
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();
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();
}
m->unPolyze();
CPPUNIT_ASSERT_EQUAL(1,m->getNumberOfCells());
std::set<INTERP_KERNEL::NormalizedCellType> 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};
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)
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)
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];
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]
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());
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());
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());
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());
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]
#
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());
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]
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]
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();
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));
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);
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]]
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]
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]
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):
#
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()))
#
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.]
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)
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()
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
%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;
virtual void checkFullyDefined() const throw(INTERP_KERNEL::Exception);
virtual bool isEmptyMesh(const std::vector<int>& 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)
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);
{
return self->cellIterator();
}
+
+ PyObject *getAllGeoTypesSorted() const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<INTERP_KERNEL::NormalizedCellType> result=self->getAllGeoTypesSorted();
+ std::vector<INTERP_KERNEL::NormalizedCellType>::const_iterator iL=result.begin();
+ PyObject *res=PyList_New(result.size());
+ for(int i=0;iL!=result.end(); i++, iL++)
+ PyList_SetItem(res,i,PyInt_FromLong(*iL));
+ return res;
+ }
void setPartOfMySelf(PyObject *li, const MEDCouplingUMesh& otherOnSameCoordsThanThis) throw(INTERP_KERNEL::Exception)
{
ret->incrRef();
return ret;
}
- PyObject *getAllTypes() const throw(INTERP_KERNEL::Exception)
- {
- std::set<INTERP_KERNEL::NormalizedCellType> result=self->getAllTypes();
- std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator iL=result.begin();
- PyObject *res = PyList_New(result.size());
- for (int i=0;iL!=result.end(); i++, iL++)
- PyList_SetItem(res,i,PyInt_FromLong(*iL));
- return res;
- }
static PyObject *ComputeSpreadZoneGraduallyFromSeed(PyObject *seed, const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn, int nbOfDepthPeeling=-1) throw(INTERP_KERNEL::Exception)
{
%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;
return self->accumulatePerChunck(bg,bg+sz);
}
+ DataArrayInt *getIdsEqualTuple(PyObject *inputTuple) const throw(INTERP_KERNEL::Exception)
+ {
+ int sw,sz,val;
+ std::vector<int> 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<int,int> > slcs(self->splitInBalancedSlices(nbOfSlices));
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;
</message>
<message>
<source>MED_INF_FIELDNAME</source>
- <translation>èªã\81¿å\8f\96ã\82\8aã\81\99ã\82\8bã\83\95ã\82£ã\83¼ã\83«ã\83\89ã\81®å\90\8då\89\8dã\82\92æ\8c\87å®\9aã\81\97ã\81¦ä¸\8bã\81\95ã\81\84</translation>
+ <translation>èªã\81¿å\8f\96ã\82\8bã\83\95ã\82£ã\83¼ã\83«ã\83\89ã\81®å\90\8då\89\8dã\82\92å\85¥å\8a\9bã\81\97ã\81¦ã\81\8fã\81 ã\81\95ã\81\84ã\80\82</translation>
</message>
<message>
<source>MED_INF_MESHNAME</source>
- <translation>読み取りするメッシュの名前を指定して下さい</translation>
+ <translation>読みたいメッシュの名前を入力してください。</translation>
</message>
<message>
<source>MED_INF_NOIOR</source>
- <translation>オブジェクトは、IOR を持たない</translation>
+ <translation>Object has no IOR</translation>
</message>
<message>
<source>MED_INF_NOTIMPL</source>
- <translation>このオブジェクトは実装されない</translation>
+ <translation>Not Implemented for this Object</translation>
</message>
<message>
<source>MED_WRN_WARNING</source>
</message>
<message>
<source>MEN_DUMPMESH</source>
- <translation>メッシュリスト</translation>
+ <translation>Dump Mesh</translation>
</message>
<message>
<source>MEN_DUMPSUBMESH</source>
- <translation>サブメッシュリスト</translation>
+ <translation>Dump SubMesh</translation>
</message>
<message>
<source>MEN_HIDE</source>
</message>
<message>
<source>MEN_EXPLORE</source>
- <translation>MED ファイルを探索</translation>
+ <translation>Explore Med File</translation>
</message>
<message>
<source>MEN_FIELDSEL</source>
</message>
<message>
<source>MEN_POPUPTEST</source>
- <translation>ポップアップテスト</translation>
+ <translation>Popup Test</translation>
</message>
<message>
<source>STB_SHOW</source>
</message>
<message>
<source>STB_DUMPMESH</source>
- <translation>メッシュリスト</translation>
+ <translation>dump Mesh</translation>
</message>
<message>
<source>STB_DUMPSUBMESH</source>
- <translation>メッシュリスト</translation>
+ <translation>dump Mesh</translation>
</message>
<message>
<source>STB_HIDE</source>
- <translation>非表示</translation>
+ <translation>Hide</translation>
</message>
<message>
<source>STB_EXPLORE</source>
- <translation>MED ファイルを探索</translation>
+ <translation>Explore Med File</translation>
</message>
<message>
<source>STB_FIELDSEL</source>
- <translation>フィールドを読み取り</translation>
+ <translation>Read a field</translation>
</message>
<message>
<source>STB_MESHSEL</source>
- <translation>メッシュ読み込み</translation>
+ <translation>Read a mesh</translation>
</message>
<message>
<source>STB_POPUPTEST</source>
- <translation>ポップアップテスト</translation>
+ <translation>Popup test</translation>
</message>
<message>
<source>TB_MED</source>
</message>
<message>
<source>TOP_DUMPMESH</source>
- <translation>メッシュリスト</translation>
+ <translation>Dump Mesh</translation>
</message>
<message>
<source>TOP_DUMPSUBMESH</source>
- <translation>サブメッシュリスト</translation>
+ <translation>Dump SubMesh</translation>
</message>
<message>
<source>TOP_HIDE</source>
</message>
<message>
<source>TOP_EXPLORE</source>
- <translation>MED ファイルを探索</translation>
+ <translation>Explore Med File</translation>
</message>
<message>
<source>TOP_FIELDSEL</source>
</message>
<message>
<source>TOP_MESHSEL</source>
- <translation>メッシュの選択</translation>
+ <translation>Mesh selection</translation>
</message>
<message>
<source>TOP_POPUPTEST</source>
- <translation>ポップアップテスト</translation>
+ <translation>Popup test</translation>
</message>
</context>
</TS>
throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 1 !");
MEDCouplingAutoRefCountObjectPtr<DataArray> newArr=createNewEmptyDataArrayInstance();
newArr->alloc(newLgth,getNumberOfComponents());
+ if(oldArr)
+ newArr->copyStringInfoFrom(*oldArr);
int pos=0;
for(std::vector< std::pair<int,int> >::const_iterator it=oldStartStops.begin();it!=oldStartStops.end();it++)
{
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<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w);
std::size_t getHeapMemorySizeWithoutChildren() const;
std::vector<const BigMemoryObject *> 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<double>& getRefCoords() const { return _ref_coo; }
- const MEDLOADER_EXPORT std::vector<double>& getGaussCoords() const { return _gs_coo; }
- const MEDLOADER_EXPORT std::vector<double>& 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<double>& getRefCoords() const { return _ref_coo; }
+ MEDLOADER_EXPORT const std::vector<double>& getGaussCoords() const { return _gs_coo; }
+ MEDLOADER_EXPORT const std::vector<double>& 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);
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[]="???";
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<sz && !presenceOfPfls;i++)
+ {
+ const DataArrayInt *pfl(_pfls[i]);
+ if(pfl)
+ presenceOfPfls=true;
+ }
+ if(!presenceOfPfls)
+ { famIds=const_cast<DataArrayInt *>(fids); famIds->incrRef(); isWithoutCopy=_cell_fam_ids_nocpy; return ; }
+ //bad luck the slowest part
+ isWithoutCopy=false;
+ std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > retSafe(sz);
+ std::vector< const DataArrayInt *> ret(sz);
+ int start(0);
+ for(std::size_t i=0;i<sz;i++)
+ {
+ const DataArrayInt *pfl(_pfls[i]);
+ int lgth(_nb_entities[i]);
+ if(pfl)
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> 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<sz && !presenceOfPfls;i++)
+ {
+ const DataArrayInt *pfl(_pfls[i]);
+ if(pfl)
+ presenceOfPfls=true;
+ }
+ if(!presenceOfPfls)
+ { numIds=const_cast<DataArrayInt *>(nids); numIds->incrRef(); isWithoutCopy=_cell_num_ids_nocpy; return ; }
+ //bad luck the slowest part
+ isWithoutCopy=false;
+ std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > retSafe(sz);
+ std::vector< const DataArrayInt *> ret(sz);
+ int start(0);
+ for(std::size_t i=0;i<sz;i++)
+ {
+ const DataArrayInt *pfl(_pfls[i]);
+ int lgth(_nb_entities[i]);
+ if(pfl)
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> 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<DataArrayInt *>(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<DataArrayInt *>(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());
}
}
-MEDMeshMultiLev::MEDMeshMultiLev()
+MEDMeshMultiLev::MEDMeshMultiLev():_nb_nodes(0),_cell_fam_ids_nocpy(false)
{
}
-MEDMeshMultiLev::MEDMeshMultiLev(int nbNodes, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities):_geo_types(gts),_nb_entities(nbEntities),_nb_nodes(nbNodes)
+MEDMeshMultiLev::MEDMeshMultiLev(int nbNodes, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& 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())
}
}
-MEDMeshMultiLev::MEDMeshMultiLev(const MEDMeshMultiLev& other):RefCountObject(other),_pfls(other._pfls),_geo_types(other._geo_types),_nb_entities(other._nb_entities),_node_reduction(other._node_reduction),_nb_nodes(other._nb_nodes)
+MEDMeshMultiLev::MEDMeshMultiLev(const MEDMeshMultiLev& other):RefCountObject(other),_pfls(other._pfls),_geo_types(other._geo_types),_nb_entities(other._nb_entities),_node_reduction(other._node_reduction),_nb_nodes(other._nb_nodes),_cell_fam_ids(other._cell_fam_ids),_cell_fam_ids_nocpy(other._cell_fam_ids_nocpy),_cell_num_ids(other._cell_num_ids),_cell_num_ids_nocpy(other._cell_num_ids_nocpy),_node_fam_ids(other._node_fam_ids),_node_fam_ids_nocpy(other._node_fam_ids_nocpy),_node_num_ids(other._node_num_ids),_node_num_ids_nocpy(other._node_num_ids_nocpy)
{
}
_parts.resize(sz);
_pfls.resize(sz);
_geo_types.resize(sz);
+ _nb_entities.resize(sz);
for(std::size_t i=0;i<sz;i++)
{
MEDCoupling1GTUMesh *obj(v[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<DataArrayInt *>(tmp));
+ }
+ }
+ else
+ {
+ std::vector<const DataArrayInt *> tmps(levs.size());
+ bool f(true);
+ for(std::size_t i=0;i<levs.size();i++)
+ {
+ tmps[i]=m->getFamilyFieldAtLevel(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<DataArrayInt *>(tmp));
+ }
+ }
+ else
+ {
+ std::vector<const DataArrayInt *> tmps(levs.size());
+ bool n(true);
+ for(std::size_t i=0;i<levs.size();i++)
+ {
+ tmps[i]=m->getNumberFieldAtLevel(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<DataArrayInt *>(tmp));
+ }
+ }
+ _node_num_ids_nocpy=true;
+ {
+ const DataArrayInt *tmp(m->getNumberFieldAtLevel(1));
+ if(tmp)
+ {
+ tmp->incrRef();
+ _node_num_ids=(const_cast<DataArrayInt *>(tmp));
+ }
+ }
}
MEDUMeshMultiLev *MEDUMeshMultiLev::New(const MEDFileUMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities)
MEDUMeshMultiLev::MEDUMeshMultiLev(const MEDFileUMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& 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;i<sz;i++)
{
MEDCoupling1GTUMesh *elt(m->getDirectUndergroundSingleGeoTypeMesh(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<DataArrayInt*>(famIds); famIds->incrRef(); }
+ _cell_num_ids_nocpy=true;
+ const DataArrayInt *numIds(m->getNumberFieldAtLevel(lev));
+ if(numIds)
+ { _cell_num_ids=const_cast<DataArrayInt*>(numIds); numIds->incrRef(); }
+ _node_fam_ids_nocpy=true;
+ famIds=m->getFamilyFieldAtLevel(1);
+ if(famIds)
+ { _node_fam_ids=const_cast<DataArrayInt*>(famIds); famIds->incrRef(); }
+ _node_num_ids_nocpy=true;
+ numIds=m->getNumberFieldAtLevel(1);
+ if(numIds)
+ { _node_num_ids=const_cast<DataArrayInt*>(numIds); numIds->incrRef(); }
+ return ;
+ }
+ //
+ _cell_fam_ids_nocpy=false;
+ std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > famIdsSafe(sz);
+ std::vector<const DataArrayInt *> famIds(sz);
+ bool f(true);
+ for(std::size_t i=0;i<sz;i++)
+ {
+ famIdsSafe[i]=m->extractFamilyFieldOnGeoType(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<DataArrayInt> > numIdsSafe(sz);
+ std::vector<const DataArrayInt *> numIds(sz);
+ bool n(true);
+ for(std::size_t i=0;i<sz;i++)
+ {
+ numIdsSafe[i]=m->extractNumberFieldOnGeoType(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<DataArrayInt*>(nodeFamIds); nodeFamIds->incrRef(); }
+ _node_num_ids_nocpy=true;
+ const DataArrayInt *nodeNumIds(m->getNumberFieldAtLevel(1));
+ if(nodeNumIds)
+ { _node_num_ids=const_cast<DataArrayInt*>(nodeNumIds); nodeNumIds->incrRef(); }
}
void MEDUMeshMultiLev::selectPartOfNodes(const DataArrayInt *pflNodes)
{
*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; }
{
*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
std::set<int> 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)
{
}
-MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev(int nbOfNodes, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities):MEDMeshMultiLev(nbOfNodes,gts,pfls,nbEntities)
+MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev(const MEDFileStructuredMesh *m, const std::vector<int>& 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<DataArrayInt *>(tmp);
+ }
+ tmp=m->getNumberFieldAtLevel(0);
+ if(tmp)
+ {
+ tmp->incrRef();
+ _cell_num_ids=const_cast<DataArrayInt *>(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<DataArrayInt *>(tmp);
+ }
+ tmp=m->getNumberFieldAtLevel(1);
+ if(tmp)
+ {
+ tmp->incrRef();
+ _node_num_ids=const_cast<DataArrayInt *>(tmp);
+ }
+}
+
+MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev(const MEDFileStructuredMesh *m, int nbOfNodes, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& 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<DataArrayInt *>(tmp);
+ }
+ tmp=m->getNumberFieldAtLevel(0);
+ if(tmp)
+ {
+ tmp->incrRef();
+ _cell_num_ids=const_cast<DataArrayInt *>(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<DataArrayInt *>(tmp);
+ }
+ tmp=m->getNumberFieldAtLevel(1);
+ if(tmp)
+ {
+ tmp->incrRef();
+ _node_num_ids=const_cast<DataArrayInt *>(tmp);
+ }
}
void MEDStructuredMeshMultiLev::selectPartOfNodes(const DataArrayInt *pflNodes)
return new MEDCMeshMultiLev(m,gts,pfls,nbEntities);
}
-MEDCMeshMultiLev::MEDCMeshMultiLev(const MEDFileCMesh *m, const std::vector<int>& levs)
+MEDCMeshMultiLev::MEDCMeshMultiLev(const MEDFileCMesh *m, const std::vector<int>& levs):MEDStructuredMeshMultiLev(m,levs)
{
if(!m)
throw INTERP_KERNEL::Exception("MEDCMeshMultiLev constructor : null input pointer !");
}
}
-MEDCMeshMultiLev::MEDCMeshMultiLev(const MEDFileCMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities):MEDStructuredMeshMultiLev(m->getNumberOfNodes(),gts,pfls,nbEntities)
+MEDCMeshMultiLev::MEDCMeshMultiLev(const MEDFileCMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities):MEDStructuredMeshMultiLev(m,m->getNumberOfNodes(),gts,pfls,nbEntities)
{
if(!m)
throw INTERP_KERNEL::Exception("MEDCMeshMultiLev constructor 2 : null input pointer !");
if(pfl)
{
std::vector< std::pair<int,int> > cellParts;
+ MEDCouplingAutoRefCountObjectPtr<MEDMeshMultiLev> ret2;
if(MEDCouplingStructuredMesh::IsPartStructured(pfl->begin(),pfl->end(),cgs,cellParts))
{
MEDCouplingAutoRefCountObjectPtr<MEDCMeshMultiLev> ret(new MEDCMeshMultiLev(*this));
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
{
MEDCouplingAutoRefCountObjectPtr<MEDUMeshMultiLev> 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<DataArrayInt> tmp(famIds->selectByTupleIdSafe(pfl->begin(),pfl->end()));
+ ret2->setFamilyIdsOnCells(tmp,false);
}
+ if(numIds)
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp(numIds->selectByTupleIdSafe(pfl->begin(),pfl->end()));
+ ret2->setNumberIdsOnCells(tmp,false);
+ }
+ return ret2.retn();
+
}
else
{
return new MEDCurveLinearMeshMultiLev(m,gts,pfls,nbEntities);
}
-MEDCurveLinearMeshMultiLev::MEDCurveLinearMeshMultiLev(const MEDFileCurveLinearMesh *m, const std::vector<int>& levs)
+MEDCurveLinearMeshMultiLev::MEDCurveLinearMeshMultiLev(const MEDFileCurveLinearMesh *m, const std::vector<int>& levs):MEDStructuredMeshMultiLev(m,levs)
{
if(!m)
throw INTERP_KERNEL::Exception("MEDCurveLinearMeshMultiLev constructor : null input pointer !");
_structure=m->getMesh()->getNodeGridStructure();
}
-MEDCurveLinearMeshMultiLev::MEDCurveLinearMeshMultiLev(const MEDFileCurveLinearMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities):MEDStructuredMeshMultiLev(m->getNumberOfNodes(),gts,pfls,nbEntities)
+MEDCurveLinearMeshMultiLev::MEDCurveLinearMeshMultiLev(const MEDFileCurveLinearMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities):MEDStructuredMeshMultiLev(m,m->getNumberOfNodes(),gts,pfls,nbEntities)
{
if(!m)
throw INTERP_KERNEL::Exception("MEDCurveLinearMeshMultiLev constructor 2 : null input pointer !");
if(pfl)
{
std::vector< std::pair<int,int> > cellParts,nodeParts;
+ MEDCouplingAutoRefCountObjectPtr<MEDMeshMultiLev> ret2;
if(MEDCouplingStructuredMesh::IsPartStructured(pfl->begin(),pfl->end(),cgs,cellParts))
{
nodeParts=cellParts;
ret->_pfls[0]=0;
ret->_coords=_coords->selectByTupleIdSafe(p->begin(),p->end());
ret->_structure=st;
- return ret.retn();
+ ret2=(MEDCurveLinearMeshMultiLev *)ret; ret2->incrRef();
}
else
{
MEDCouplingAutoRefCountObjectPtr<MEDUMeshMultiLev> 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<DataArrayInt> tmp(famIds->selectByTupleIdSafe(pfl->begin(),pfl->end()));
+ ret2->setFamilyIdsOnCells(tmp,false);
+ }
+ if(numIds)
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp(numIds->selectByTupleIdSafe(pfl->begin(),pfl->end()));
+ ret2->setNumberIdsOnCells(tmp,false);
}
+ return ret2.retn();
}
else
{
class MEDFileMesh;
class MEDFileUMesh;
class MEDFileCMesh;
+ class MEDFileStructuredMesh;
class MEDFileCurveLinearMesh;
class MEDFileFieldGlobs;
class MEDFileFieldGlobsReal;
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;
std::vector<int> _nb_entities;
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _node_reduction;
int _nb_nodes;
+ //
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _cell_fam_ids;
+ bool _cell_fam_ids_nocpy;
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _cell_num_ids;
+ bool _cell_num_ids_nocpy;
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _node_fam_ids;
+ bool _node_fam_ids_nocpy;
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _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];
protected:
MEDStructuredMeshMultiLev();
MEDStructuredMeshMultiLev(const MEDStructuredMeshMultiLev& other);
- MEDStructuredMeshMultiLev(int nbOfNodes, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities);
+ MEDStructuredMeshMultiLev(const MEDFileStructuredMesh *m, const std::vector<int>& lev);
+ MEDStructuredMeshMultiLev(const MEDFileStructuredMesh *m, int nbOfNodes, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities);
};
class MEDCMeshMultiLev : public MEDStructuredMeshMultiLev
_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.
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<MEDFileUMeshSplitL1> >::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).
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<INTERP_KERNEL::NormalizedCellType> 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)
MEDLOADER_EXPORT void setFamilyInfo(const std::map<std::string,int>& info);
MEDLOADER_EXPORT void setGroupInfo(const std::map<std::string, std::vector<std::string> >&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<std::string,int>& getFamilyInfo() const { return _families; }
MEDLOADER_EXPORT const std::map<std::string, std::vector<std::string> >& getGroupInfo() const { return _groups; }
MEDLOADER_EXPORT std::vector<std::string> getFamiliesOnGroup(const char *name) const;
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<INTERP_KERNEL::NormalizedCellType> getGeoTypesAtLevel(int meshDimRelToMax) const;
MEDLOADER_EXPORT void whichAreNodesFetched(const MEDFileField1TSStructItem& st, const MEDFileFieldGlobsReal *globs, std::vector<bool>& nodesFetched) const;
MEDLOADER_EXPORT std::vector<int> getNonEmptyLevels() const;
MEDLOADER_EXPORT std::vector<int> getNonEmptyLevelsExt() const;
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<MEDCoupling1GTUMesh *> 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);
{
for(int i=0;i<sz;i++)
fams[i]=v[i]->getFam();
- _fam=DataArrayInt::Aggregate(fams);
+ if(sz!=1)
+ _fam=DataArrayInt::Aggregate(fams);
+ else
+ {
+ fams[0]->incrRef();
+ _fam=const_cast<DataArrayInt *>(fams[0]);
+ }
}
if(l2.isNumDefinedOnLev(id))
{
for(int i=0;i<sz;i++)
nums[i]=v[i]->getNum();
- _num=DataArrayInt::Aggregate(nums);
+ if(sz!=1)
+ _num=DataArrayInt::Aggregate(nums);
+ else
+ {
+ nums[0]->incrRef();
+ _num=const_cast<DataArrayInt *>(nums[0]);
+ }
computeRevNum();
}
if(l2.isNamesDefinedOnLev(id))
assignCommonPart();
}
+void MEDFileUMeshSplitL1::forceComputationOfParts() const
+{
+ _m_by_types.forceComputationOfPartsFromUMesh();
+}
+
void MEDFileUMeshSplitL1::assignParts(const std::vector< const MEDCoupling1GTUMesh * >& mParts)
{
_m_by_types.assignParts(mParts);
return da.retn();
}
+std::vector<INTERP_KERNEL::NormalizedCellType> MEDFileUMeshSplitL1::getGeoTypes() const
+{
+ return _m_by_types.getGeoTypes();
+}
+
MEDCouplingUMesh *MEDFileUMeshSplitL1::getWholeMesh(bool renum) const
{
MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> tmp;
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)
return _m;
}
+std::vector<INTERP_KERNEL::NormalizedCellType> MEDFileUMeshAggregateCompute::getGeoTypes() const
+{
+ if(_mp_time>=_m_time)
+ {
+ std::size_t sz(_m_parts.size());
+ std::vector<INTERP_KERNEL::NormalizedCellType> ret(sz);
+ for(std::size_t i=0;i<sz;i++)
+ ret[i]=_m_parts[i]->getCellModelEnum();
+ return ret;
+ }
+ else
+ return _m->getAllGeoTypesSorted();
+}
+
std::vector<MEDCoupling1GTUMesh *> MEDFileUMeshAggregateCompute::getPartsWithoutComputation() const
{
if(_mp_time<_m_time)
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<MEDCoupling1GTUMesh *> v(getPartsWithoutComputation());
+ std::size_t sz(v.size());
+ for(std::size_t i=0;i<sz;i++)
+ {
+ if(v[i])
+ {
+ if(v[i]->getCellModelEnum()==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);
void assignUMesh(MEDCouplingUMesh *m);
MEDCouplingUMesh *getUmesh() const;
std::vector<MEDCoupling1GTUMesh *> getParts() const;
+ std::vector<INTERP_KERNEL::NormalizedCellType> getGeoTypes() const;
std::vector<MEDCoupling1GTUMesh *> 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<const BigMemoryObject *> getDirectChildren() const;
std::vector<int> 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:
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<int>& ids) const;
int getMeshDimension() const;
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<INTERP_KERNEL::NormalizedCellType> getGeoTypes() const;
std::vector<MEDCoupling1GTUMesh *> 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<int> getDistributionOfTypes() const { return _m_by_types.getDistributionOfTypes(); }
DataArrayInt *getOrCreateAndGetFamilyField();
const DataArrayInt *getFamilyField() const;
/// @endcond
+void MEDLoader::AssignStaticWritePropertiesTo(ParaMEDMEM::MEDFileWritable& obj)
+{
+ obj.setTooLongStrPolicy(_TOO_LONG_STR);
+}
+
bool MEDLoader::HasXDR()
{
#ifdef HAS_XDR
ParaMEDMEM::MEDCouplingMesh *MEDLoader::ReadMeshFromFile(const char *fileName, const char *meshName, int meshDimRelToMax)
{
CheckFileForRead(fileName);
- MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm=MEDFileMesh::New(fileName,meshName);
+ MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm(MEDFileMesh::New(fileName,meshName));
MEDFileMesh *mmPtr(mm);
MEDFileUMesh *mmuPtr=dynamic_cast<MEDFileUMesh *>(mmPtr);
if(mmuPtr)
ParaMEDMEM::MEDCouplingMesh *MEDLoader::ReadMeshFromFile(const char *fileName, int meshDimRelToMax)
{
CheckFileForRead(fileName);
- MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm=MEDFileMesh::New(fileName);
+ MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm(MEDFileMesh::New(fileName));
MEDFileMesh *mmPtr(mm);
MEDFileUMesh *mmuPtr=dynamic_cast<MEDFileUMesh *>(mmPtr);
if(mmuPtr)
ParaMEDMEM::MEDCouplingUMesh *MEDLoader::ReadUMeshFromFile(const char *fileName, const char *meshName, int meshDimRelToMax)
{
CheckFileForRead(fileName);
- MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm=MEDFileMesh::New(fileName,meshName);
+ MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm(MEDFileMesh::New(fileName,meshName));
MEDFileMesh *mmPtr(mm);
MEDFileUMesh *mmuPtr=dynamic_cast<MEDFileUMesh *>(mmPtr);
if(!mmuPtr)
ParaMEDMEM::MEDCouplingUMesh *MEDLoader::ReadUMeshFromFile(const char *fileName, int meshDimRelToMax)
{
CheckFileForRead(fileName);
- MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm=MEDFileMesh::New(fileName);
+ MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm(MEDFileMesh::New(fileName));
MEDFileMesh *mmPtr(mm);
MEDFileUMesh *mmuPtr=dynamic_cast<MEDFileUMesh *>(mmPtr);
if(!mmuPtr)
ParaMEDMEM::MEDCouplingUMesh *MEDLoader::ReadUMeshFromFamilies(const char *fileName, const char *meshName, int meshDimRelToMax, const std::vector<std::string>& fams)
{
CheckFileForRead(fileName);
- MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm=MEDFileMesh::New(fileName,meshName);
+ MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm(MEDFileMesh::New(fileName,meshName));
MEDFileMesh *mmPtr(mm);
MEDFileUMesh *mmuPtr=dynamic_cast<MEDFileUMesh *>(mmPtr);
if(!mmuPtr)
const MEDCoupling1GTUMesh *um2(dynamic_cast<const MEDCoupling1GTUMesh *>(mesh));
if(um2)
{
- MEDCouplingAutoRefCountObjectPtr<MEDFileUMesh> mmu=MEDFileUMesh::New();
+ MEDCouplingAutoRefCountObjectPtr<MEDFileUMesh> mmu(MEDFileUMesh::New());
+ AssignStaticWritePropertiesTo(*mmu);
mmu->setMeshAtLevel(0,const_cast<MEDCoupling1GTUMesh *>(um2));
mmu->write(fileName,mod);
return ;
const MEDCouplingCMesh *um3(dynamic_cast<const MEDCouplingCMesh *>(mesh));
if(um3)
{
- MEDCouplingAutoRefCountObjectPtr<MEDFileCMesh> mmc=MEDFileCMesh::New();
+ MEDCouplingAutoRefCountObjectPtr<MEDFileCMesh> mmc(MEDFileCMesh::New());
+ AssignStaticWritePropertiesTo(*mmc);
mmc->setMesh(const_cast<MEDCouplingCMesh *>(um3));
mmc->write(fileName,mod);
return ;
const MEDCouplingCurveLinearMesh *um4(dynamic_cast<const MEDCouplingCurveLinearMesh *>(mesh));
if(um4)
{
- MEDCouplingAutoRefCountObjectPtr<MEDFileCurveLinearMesh> mmc=MEDFileCurveLinearMesh::New();
+ MEDCouplingAutoRefCountObjectPtr<MEDFileCurveLinearMesh> mmc(MEDFileCurveLinearMesh::New());
+ AssignStaticWritePropertiesTo(*mmc);
mmc->setMesh(const_cast<MEDCouplingCurveLinearMesh *>(um4));
mmc->write(fileName,mod);
return ;
if(!mesh)
throw INTERP_KERNEL::Exception("MEDLoader::WriteUMesh : input mesh is null !");
int mod=writeFromScratch?2:0;
- MEDCouplingAutoRefCountObjectPtr<MEDFileUMesh> m=MEDFileUMesh::New();
+ MEDCouplingAutoRefCountObjectPtr<MEDFileUMesh> m(MEDFileUMesh::New());
+ AssignStaticWritePropertiesTo(*m);
MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> mcpy(static_cast<MEDCouplingUMesh *>(mesh->deepCpy()));
m->setMeshAtLevel(0,mcpy,true);
m->write(fileName,mod);
std::ostringstream oss; oss << "File with name \'" << fileName << "\' has not valid permissions !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
- MEDCouplingAutoRefCountObjectPtr<MEDFileUMesh> m=MEDFileUMesh::New();
+ MEDCouplingAutoRefCountObjectPtr<MEDFileUMesh> m(MEDFileUMesh::New());
+ AssignStaticWritePropertiesTo(*m);
m->setGroupsFromScratch(0,meshes,true);
m->setName(meshNameC);
int mod=writeFromScratch?2:0;
void MEDLoader::WriteUMeshes(const char *fileName, const std::vector<const ParaMEDMEM::MEDCouplingUMesh *>& meshes, bool writeFromScratch)
{
int mod=writeFromScratch?2:0;
- MEDCouplingAutoRefCountObjectPtr<MEDFileUMesh> m=MEDFileUMesh::New();
+ MEDCouplingAutoRefCountObjectPtr<MEDFileUMesh> 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<MEDFileField1TS> ff=MEDFileField1TS::New();
+ MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ff(MEDFileField1TS::New());
+ MEDLoader::AssignStaticWritePropertiesTo(*ff);
MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> f2(f->deepCpy());
const MEDCouplingMesh *m(f2->getMesh());
const MEDCouplingUMesh *um(dynamic_cast<const MEDCouplingUMesh *>(m));
int mod=writeFromScratch?2:0;
if(um)
{
- MEDCouplingAutoRefCountObjectPtr<MEDFileUMesh> mmu=MEDFileUMesh::New();
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> o2n=um->getRenumArrForMEDFileFrmt();
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> n2o=o2n->invertArrayO2N2N2O(o2n->getNumberOfTuples());
+ MEDCouplingAutoRefCountObjectPtr<MEDFileUMesh> mmu(MEDFileUMesh::New());
+ MEDLoader::AssignStaticWritePropertiesTo(*mmu);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> o2n(um->getRenumArrForMEDFileFrmt());
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> n2o(o2n->invertArrayO2N2N2O(o2n->getNumberOfTuples()));
f2->renumberCells(o2n->begin(),false);
mmu->setMeshAtLevel(0,const_cast<MEDCouplingUMesh *>(static_cast<const MEDCouplingUMesh *>(f2->getMesh())));
mmu->setRenumFieldArr(0,n2o);
}
else if(um2)
{
- MEDCouplingAutoRefCountObjectPtr<MEDFileUMesh> mmu=MEDFileUMesh::New();
+ MEDCouplingAutoRefCountObjectPtr<MEDFileUMesh> mmu(MEDFileUMesh::New());
+ MEDLoader::AssignStaticWritePropertiesTo(*mmu);
mmu->setMeshAtLevel(0,const_cast<MEDCoupling1GTUMesh *>(um2));
ff->setFieldNoProfileSBT(f2);
mmu->write(fileName,mod);
}
else if(um3)
{
- MEDCouplingAutoRefCountObjectPtr<MEDFileCMesh> mmc=MEDFileCMesh::New();
+ MEDCouplingAutoRefCountObjectPtr<MEDFileCMesh> mmc(MEDFileCMesh::New());
+ MEDLoader::AssignStaticWritePropertiesTo(*mmc);
mmc->setMesh(const_cast<MEDCouplingCMesh *>(um3));
ff->setFieldNoProfileSBT(f2);
mmc->write(fileName,mod);
}
else if(um4)
{
- MEDCouplingAutoRefCountObjectPtr<MEDFileCurveLinearMesh> mmc=MEDFileCurveLinearMesh::New();
+ MEDCouplingAutoRefCountObjectPtr<MEDFileCurveLinearMesh> mmc(MEDFileCurveLinearMesh::New());
+ MEDLoader::AssignStaticWritePropertiesTo(*mmc);
mmc->setMesh(const_cast<MEDCouplingCurveLinearMesh *>(um4));
ff->setFieldNoProfileSBT(f2);
mmc->write(fileName,mod);
MEDLoaderNS::writeFieldWithoutReadingAndMappingOfMeshInFile(fileName,f,false);
else
{
- MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm=MEDFileMesh::New(fileName,f->getMesh()->getName().c_str());
+ MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm(MEDFileMesh::New(fileName,f->getMesh()->getName().c_str()));
+ AssignStaticWritePropertiesTo(*mm);
const MEDFileMesh *mmPtr(mm);
const MEDFileUMesh *mmuPtr=dynamic_cast<const MEDFileUMesh *>(mmPtr);
if(!mmuPtr)
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<MEDFileField1TS> f1ts=MEDFileField1TS::New();
+ MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> f1ts(MEDFileField1TS::New());
+ AssignStaticWritePropertiesTo(*f1ts);
if(part->isIdentity() && part->getNumberOfTuples()==mread->getNumberOfCells())
f1ts->setFieldNoProfileSBT(f2);
else
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<MEDFileField1TS> f1ts=MEDFileField1TS::New();
+ MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> f1ts(MEDFileField1TS::New());
+ AssignStaticWritePropertiesTo(*f1ts);
if(part->isIdentity() && part->getNumberOfTuples()==mread->getNumberOfNodes())
f1ts->setFieldNoProfileSBT(f2);
else
std::ostringstream oss; oss << "File with name \'" << fileName << "\' has not valid permissions or not exists !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
- MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> f1ts=MEDFileField1TS::New();
+ MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> f1ts(MEDFileField1TS::New());
+ AssignStaticWritePropertiesTo(*f1ts);
MEDCouplingUMesh *m=dynamic_cast<MEDCouplingUMesh *>(const_cast<MEDCouplingMesh *>(f->getMesh()));
if(!m)
throw INTERP_KERNEL::Exception("MEDLoader::WriteFieldUsingAlreadyWrittenMesh : only umesh in input field supported !");
class MEDCouplingMesh;
class MEDCouplingUMesh;
class MEDCouplingFieldDouble;
+ class MEDFileWritable;
}
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:
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;
*/
//================================================================================
-SauvUtilities::Group* SauvReader::getFieldSupport(const vector<SauvUtilities::Group*>& supports)
+void SauvReader::setFieldSupport(const vector<SauvUtilities::Group*>& supports,
+ SauvUtilities::DoubleField* field)
{
SauvUtilities::Group* group = NULL;
set<SauvUtilities::Group*> sup_set( supports.begin(), supports.end() );
}
else
{
- // try to find an existing composite group with the same sub-groups
- for ( size_t i = 0; i < _iMed->_groups.size() && !group; ++i )
+ // check if sub-components are on cells of different types
+ map<int,int> 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<int,int>::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<SauvUtilities::Group*> newGroups( supports.begin(),
group->_groups.swap( newGroups );
}
}
+ // sort field sub-components and supports by cell type
+ if ( group && !isSameCellType )
+ {
+ // sort groups
+ vector<SauvUtilities::Group*>& 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
*/
//================================================================================
// 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;
// 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;
void read_PILE_MODL (const int nbObjects, std::vector<std::string>& objectNames, std::vector<int>& nameIndices);
void read_PILE_FIELD (const int nbObjects, std::vector<std::string>& objectNames, std::vector<int>& nameIndices);
- SauvUtilities::Group* getFieldSupport(const std::vector<SauvUtilities::Group*>& fieldSupports);
+ void setFieldSupport(const std::vector<SauvUtilities::Group*>& supports,
+ SauvUtilities::DoubleField* field);
void setFieldNames(const std::vector<SauvUtilities::DoubleField*>& fields,
const std::vector<std::string>& objectNames,
const std::vector<int>& nameIndices);
}
}
-//================================================================================
-/*!
- * \brief Creates SauvWriter
- */
-//================================================================================
+SauvWriter::SauvWriter():_cpy_grp_if_on_single_family(false)
+{
+}
SauvWriter* SauvWriter::New()
{
return std::vector<const BigMemoryObject *>();
}
+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
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 );
+ }
}
}
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<const BigMemoryObject *> getDirectChildren() const;
/*!
std::vector<SauvUtilities::nameGIBItoMED> _longNames[ LN_NB ];
std::fstream* _sauvFile;
+ bool _cpy_grp_if_on_single_family;
};
}
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)
%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;
static std::vector<std::string> GetCellFieldNamesOnMesh(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
static std::vector<std::string> 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()
virtual void createGroupOnAll(int meshDimRelToMaxExt, const char *groupName) throw(INTERP_KERNEL::Exception);
virtual bool keepFamIdsOnlyOnLevs(const std::vector<int>& famIds, const std::vector<int>& 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<std::string,int>& getFamilyInfo() const throw(INTERP_KERNEL::Exception);
const std::map<std::string, std::vector<std::string> >& getGroupInfo() const throw(INTERP_KERNEL::Exception);
std::vector<std::string> getFamiliesOnGroup(const char *name) const throw(INTERP_KERNEL::Exception);
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);
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)
{
return MEDFileUMesh::New();
}
+
+ PyObject *getGeoTypesAtLevel(int meshDimRelToMax) const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<INTERP_KERNEL::NormalizedCellType> result(self->getGeoTypesAtLevel(meshDimRelToMax));
+ std::vector<INTERP_KERNEL::NormalizedCellType>::const_iterator iL=result.begin();
+ PyObject *res=PyList_New(result.size());
+ for(int i=0;iL!=result.end(); i++, iL++)
+ PyList_SetItem(res,i,PyInt_FromLong(*iL));
+ return res;
+ }
PyObject *getRevNumberFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception)
{
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
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();
+ }
+ }
};
///////////////
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
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;
}
}
from MEDLoader import *
from MEDCouplingRemapper import *
-import math
+import math, os
d=DataArrayDouble.New(6,2)
d[:,0]=3.
#
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)
buildVecFieldOnGauss_2_Simpler=classmethod(buildVecFieldOnGauss_2_Simpler)
buildVecFieldOnGaussNE_1=classmethod(buildVecFieldOnGaussNE_1)
buildACompleteMEDDataStructureWithFieldsOnCells_1=classmethod(buildACompleteMEDDataStructureWithFieldsOnCells_1)
+ buildAMEDFileDataWithGroupOnOneFamilyForSauv=classmethod(buildAMEDFileDataWithGroupOnOneFamilyForSauv)
pass
from MEDLoader import *
import unittest
+import os
class MEDLoaderBasicsTest(unittest.TestCase):
def testExampleReadFieldOnAllEntity1(self):
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()
#
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])))
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()
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()
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)
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
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)
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)
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
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]
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)
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
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)
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
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)
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
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
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
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)
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)
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)
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)
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)
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)
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])))
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])))
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])))
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)
"""
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()
#
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
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()
# read SAUV and write MED
medFile = "SauvLoaderTest.med"
- sr=SauvReader.New(sauvFile);
+ sr=SauvReader(sauvFile);
d2=sr.loadInMEDFileDS();
d2.write(medFile,0);
# write pointeMed to SAUV
sauvFile = "SauvLoaderTest.sauv"
- sw=SauvWriter.New();
+ sw=SauvWriter();
sw.setMEDFileDS(pointeMed);
sw.write(sauvFile);
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<number>[0-9]+)NBRE\sOBJETS\sNOMMES\s+(?P<nbnamed>[0-9]+)NBRE\sOBJETS\s+(?P<nbobjects>[0-9]+)')
+ # String pattern for a sub mesh header (cell type, number of components and three numbers)
+ pattern_header=re.compile(r'\s+(?P<type>[0-9]+)\s+(?P<nbsubs>[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()
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})
# 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
<!DOCTYPE TS><TS>
<context>
<name>@default</name>
+ <message>
+ <source>MEN_BUILDER3</source>
+ <translation type="unfinished">Load a python script</translation>
+ </message>
+ <message>
+ <source>STS_BUILDER3</source>
+ <translation type="unfinished">Load a python script</translation>
+ </message>
+ <message>
+ <source>TLT_BUILDER3</source>
+ <translation type="unfinished">Load a python script</translation>
+ </message>
+ <message>
+ <source>STS_LOAD_DXF</source>
+ <translation type="unfinished">Load DXF file</translation>
+ </message>
+ <message>
+ <source>MEN_LOAD_DXF</source>
+ <translation type="unfinished">Load DXF file</translation>
+ </message>
+ <message>
+ <source>TLT_LOAD_DXF</source>
+ <translation type="unfinished">Load DXF file</translation>
+ </message>
<message>
<source>TLT_MY_NEW_ITEM</source>
<translation>My menu item</translation>
<name>XMEDGUI_maquette</name>
<message>
<source>BUT_OK</source>
- <translation>わかりました</translation>
+ <translation>OK</translation>
</message>
<message>
<source>QUE_XMED_LABEL</source>
</message>
<message>
<source>QUE_XMED_NAME</source>
- <translation>ã\81\82ã\81ªã\81\9fã\81®å\90\8då\89\8dã\82\92å\85¥å\8a\9bã\81\97ã\81¦ã\81\8fã\81 ã\81\95ã\81\84ã\80\81</translation>
+ <translation>ã\81\82ã\81ªã\81\9fã\81®å\90\8då\89\8dã\82\92å\85¥å\8a\9bã\81\97ã\81¦ã\81\8fã\81 ã\81\95ã\81\84ã\80\82</translation>
</message>
<message>
<source>INF_XMED_BANNER</source>
</message>
<message>
<source>INF_XMED_MENU</source>
- <translation>これはテストです。</translation>
+ <translation>ã\81\93ã\82\8cã\81¯ã\81\9fã\81 ã\81®ã\83\86ã\82¹ã\83\88ã\81§ã\81\99ã\80\82</translation>
</message>
</context>
</TS>
<message>
<location filename="MEDOP/gui/DatasourceController.cxx" line="45"/>
<source>LAB_ADD_DATA_SOURCE</source>
- <translation>LAB_ADD_DATA_SOURCE</translation>
+ <translation>データのインポート MED</translation>
</message>
<message>
<location filename="MEDOP/gui/DatasourceController.cxx" line="46"/>
<source>TIP_ADD_DATA_SOURCE</source>
- <translation>TIP_ADD_DATA_SOURCE</translation>
+ <translation>MED のファイルをインポートしたデータを追加します。</translation>
</message>
<message>
<location filename="MEDOP/gui/DatasourceController.cxx" line="52"/>
<source>LAB_ADD_IMAGE_SOURCE</source>
- <translation>LAB_ADD_IMAGE_SOURCE</translation>
+ <translation>画像を追加します。</translation>
</message>
<message>
<location filename="MEDOP/gui/DatasourceController.cxx" line="53"/>
<source>TIP_ADD_IMAGE_SOURCE</source>
- <translation>TIP_ADD_IMAGE_SOURCE</translation>
+ <translation>イメージ ファイルのインポートを使用してデータを追加します。</translation>
</message>
<message>
<location filename="MEDOP/gui/DatasourceController.cxx" line="62"/>
<source>LAB_EXPAND_FIELD</source>
- <translation>LAB_EXPAND_FIELD</translation>
+ <translation>拡張フィールドの時系列</translation>
</message>
<message>
<location filename="MEDOP/gui/DatasourceController.cxx" line="69"/>
<source>LAB_VISUALIZE</source>
- <translation>LAB_VISUALIZE</translation>
+ <translation>ビュー</translation>
</message>
<message>
<location filename="MEDOP/gui/DatasourceController.cxx" line="75"/>
<source>LAB_USE_IN_WORKSPACE</source>
- <translation>LAB_USE_IN_WORKSPACE</translation>
+ <translation>ワークスペースを使用します。</translation>
</message>
<message>
<location filename="MEDOP/gui/DatasourceController.cxx" line="83"/>
<source>LAB_CHANGE_MESH</source>
- <translation>LAB_CHANGE_MESH</translation>
+ <translation>基になるメッシュを変更します。</translation>
</message>
<message>
<location filename="MEDOP/gui/DatasourceController.cxx" line="157"/>
<source>IMPORT_MED_FIELDS</source>
- <translation>IMPORT_MED_FIELDS</translation>
+ <translation>(MED のサイズ) フィールドをインポートします。</translation>
</message>
<message>
<location filename="MEDOP/gui/DatasourceController.cxx" line="191"/>
<source>OPERATION_FAILED</source>
- <translation>OPERATION_FAILED</translation>
+ <translation>操作が失敗しました</translation>
</message>
<message>
<location filename="MEDOP/gui/DatasourceController.cxx" line="192"/>
<source>CREATION_FAILED</source>
- <translation>CREATION_FAILED</translation>
+ <translation>イメージ ファイルの作成からの医学データに失敗しました</translation>
</message>
<message>
<location filename="MEDOP/gui/DatasourceController.cxx" line="283"/>
<source>OPERATION_NOT_ALLOWED</source>
- <translation>OPERATION_NOT_ALLOWED</translation>
+ <translation>許可されていない操作</translation>
</message>
<message>
<location filename="MEDOP/gui/DatasourceController.cxx" line="284"/>
<source>FIELD_ALREADY_DEFINED</source>
- <translation>FIELD_ALREADY_DEFINED</translation>
+ <translation>このフィールドは、ワークスペースで既に定義されて</translation>
</message>
</context>
<context>
<message>
<location filename="MEDOP/gui/dialogs/DlgAlias.ui" line="14"/>
<source>SELECT_AN_ALIAS_FOR_THE_FIELD</source>
- <translation>SELECT_AN_ALIAS_FOR_THE_FIELD</translation>
+ <translation>このフィールドのエイリアスを選択します</translation>
</message>
<message>
<location filename="MEDOP/gui/dialogs/DlgAlias.ui" line="401"/>
<source>DEFINE_AN_ALIAS</source>
- <translation>DEFINE_AN_ALIAS</translation>
+ <translation>コンソールでフィールドを操作するエイリアスを設定できます。</translation>
</message>
<message>
<location filename="MEDOP/gui/dialogs/DlgAlias.ui" line="419"/>
<source>ALIAS</source>
- <translation>ALIAS</translation>
+ <translation>エイリアス</translation>
</message>
<message>
<location filename="MEDOP/gui/dialogs/DlgAlias.ui" line="436"/>
<source>MSG_OPERATION_DEFINES_VARIABLE</source>
- <translation>MSG_OPERATION_DEFINES_VARIABLE</translation>
+ <translation>(この操作はテキスト コンソールに<alias>という名前の変数を定義します。型 '<alias>. help()"利用可能な機能または単に「doc」参照する)</alias> </alias></translation>
</message>
</context>
<context>
<message>
<location filename="MEDOP/gui/dialogs/DlgChangeUnderlyingMesh.ui" line="14"/>
<source>FORM</source>
- <translation>FORM</translation>
- </message>
- <message>
- <location filename="MEDOP/gui/dialogs/DlgChangeUnderlyingMesh.ui" line="391"/>
- <source>SELECT_MESH</source>
- <translation>SELECT_MESH</translation>
+ <translation>フォーム</translation>
</message>
<message>
<location filename="MEDOP/gui/dialogs/DlgChangeUnderlyingMesh.ui" line="403"/>
<source>MESH_GT</source>
- <translation>MESH_GT</translation>
+ <translation>-> メッシュします。</translation>
</message>
<message>
<location filename="MEDOP/gui/dialogs/DlgChangeUnderlyingMesh.ui" line="420"/>
<source>MSG_EXPLORER</source>
- <translation>MSG_EXPLORER</translation>
+ <translation>(エクスプ ローラー データ空間で参照される MED (メッシュとフィールド) のデータのビューを提供します)</translation>
</message>
<message>
<location filename="MEDOP/gui/dialogs/DlgChangeUnderlyingMesh.cxx" line="35"/>
<source>DATA_VERIFICATION</source>
- <translation>DATA_VERIFICATION</translation>
+ <translation>データの検証</translation>
</message>
<message>
<location filename="MEDOP/gui/dialogs/DlgChangeUnderlyingMesh.cxx" line="36"/>
<source>SELECT_MESH</source>
- <translation>SELECT_MESH</translation>
+ <translation>エクスプ ローラーでメッシュを選択し、メッシュをクリックする必要があります。</translation>
</message>
</context>
<context>
<message>
<location filename="MEDOP/gui/dialogs/DlgImageToMed.ui" line="14"/>
<source>FORM</source>
- <translation>FORM</translation>
+ <translation>フォーム</translation>
</message>
<message>
<location filename="MEDOP/gui/dialogs/DlgImageToMed.ui" line="28"/>
<source>IMAGE_FILE</source>
- <translation>IMAGE_FILE</translation>
+ <translation>画像ファイル:</translation>
</message>
<message>
<location filename="MEDOP/gui/dialogs/DlgImageToMed.ui" line="35"/>
<source>MED_FILE</source>
- <translation>MED_FILE</translation>
+ <translation>MED ファイル:</translation>
</message>
<message>
<location filename="MEDOP/gui/dialogs/DlgImageToMed.cxx" line="64"/>
<source>SELECT_IMAGE_FILE</source>
- <translation>SELECT_IMAGE_FILE</translation>
+ <translation>イメージ ファイルを選択します。</translation>
</message>
<message>
<location filename="MEDOP/gui/dialogs/DlgImageToMed.cxx" line="79"/>
<source>SPECIFY_MED_FILE</source>
- <translation>SPECIFY_MED_FILE</translation>
+ <translation>MED ファイルを指定します。</translation>
</message>
<message>
<location filename="MEDOP/gui/dialogs/DlgImageToMed.ui" line="82"/>
<source>LOAD_AUTOMATICALLY</source>
- <translation>LOAD_AUTOMATICALLY</translation>
+ <translation>自動的に読み込む</translation>
</message>
</context>
<context>
<message>
<location filename="MEDOP/gui/dialogs/DlgUseInWorkspace.ui" line="13"/>
<source>FORM</source>
- <translation>FORM</translation>
+ <translation>フォーム</translation>
</message>
<message>
<location filename="MEDOP/gui/dialogs/DlgUseInWorkspace.ui" line="49"/>
<source>PRESSURE</source>
- <translation>PRESSURE</translation>
+ <translation>圧力:</translation>
</message>
<message>
<location filename="MEDOP/gui/dialogs/DlgUseInWorkspace.ui" line="56"/>
<source>TEMPERATURE</source>
- <translation>TEMPERATURE</translation>
+ <translation>温度:</translation>
</message>
</context>
<context>
<message>
<location filename="MEDOP/gui/dialogs/GenericDialog.ui" line="13"/>
<source>DIALOG</source>
- <translation>DIALOG</translation>
+ <translation>ダイアログ</translation>
</message>
</context>
<context>
<message>
<location filename="MEDOP/gui/MEDOPModule.cxx" line="68"/>
<source>IMPORT_FROM_FILE</source>
- <translation>IMPORT_FROM_FILE</translation>
+ <translation>ファイルからのインポートします。</translation>
</message>
<message>
<location filename="MEDOP/gui/MEDOPModule.cxx" line="69"/>
<source>IMPORT_MED_FILE</source>
- <translation>IMPORT_MED_FILE</translation>
+ <translation>MEDファイルをインポート</translation>
</message>
<message>
<location filename="MEDOP/gui/MEDOPModule.cxx" line="72"/>
<source>MEN_FILE</source>
- <translation>MEN_FILE</translation>
+ <translation>ファイル(&F)</translation>
</message>
</context>
<context>
<message>
<location filename="MEDOP/gui/WorkspaceController.cxx" line="66"/>
<source>VISUALIZE_SCALAR_MAP</source>
- <translation>VISUALIZE_SCALAR_MAP</translation>
+ <translation>ビュー (マップ スカラー)</translation>
</message>
<message>
<location filename="MEDOP/gui/WorkspaceController.cxx" line="67"/>
<source>USE_IN_CONSOLE</source>
- <translation>USE_IN_CONSOLE</translation>
+ <translation>(コンソール) を使用してください。</translation>
</message>
<message>
<location filename="MEDOP/gui/WorkspaceController.cxx" line="68"/>
<source>EXPORT_TO_PARAVIS</source>
- <translation>EXPORT_TO_PARAVIS</translation>
+ <translation>エクスポート (にそこに)</translation>
</message>
<message>
<location filename="MEDOP/gui/WorkspaceController.cxx" line="69"/>
<source>SAVE_AS_MED</source>
- <translation>SAVE_AS_MED</translation>
+ <translation>(MED ファイル) に保存します。</translation>
</message>
<message>
<location filename="MEDOP/gui/WorkspaceController.cxx" line="70"/>
<source>REMOVE_FROM_WORKSPACE</source>
- <translation>REMOVE_FROM_WORKSPACE</translation>
+ <translation>(ワークスペース) の削除します。</translation>
</message>
<message>
<location filename="MEDOP/gui/WorkspaceController.cxx" line="91"/>
<source>LAB_SAVE_WORKSPACE</source>
- <translation>LAB_SAVE_WORKSPACE</translation>
+ <translation>ワークスペースを保存します。</translation>
</message>
<message>
<location filename="MEDOP/gui/WorkspaceController.cxx" line="92"/>
<source>TIP_SAVE_WORKSPACE</source>
- <translation>TIP_SAVE_WORKSPACE</translation>
+ <translation>MED ファイル (フィールドおよびメッシュ) ワークスペースを保存します。</translation>
</message>
<message>
<location filename="MEDOP/gui/WorkspaceController.cxx" line="97"/>
<source>LAB_CLEAN_WORKSPACE</source>
- <translation>LAB_CLEAN_WORKSPACE</translation>
+ <translation>作業領域をきれいに</translation>
</message>
<message>
<location filename="MEDOP/gui/WorkspaceController.cxx" line="98"/>
<source>TIP_CLEAN_WORKSPACE</source>
- <translation>TIP_CLEAN_WORKSPACE</translation>
+ <translation>ワークスペースからすべてのデータを消去します。</translation>
</message>
<message>
<location filename="MEDOP/gui/WorkspaceController.cxx" line="271"/>
<source>SAVE_SELECTED_FIELDS</source>
- <translation>SAVE_SELECTED_FIELDS</translation>
+ <translation>選択したフィールドを保存します。</translation>
</message>
<message>
<location filename="MEDOP/gui/WorkspaceController.cxx" line="425"/>
<source>SAVE_WORKSPACE_DATA</source>
- <translation>SAVE_WORKSPACE_DATA</translation>
+ <translation>ワークスペースからデータを保存します。</translation>
</message>
<message>
<location filename="MEDOP/gui/WorkspaceController.cxx" line="439"/>
<source>NOT_IMPLEMENTED_YET</source>
- <translation>NOT_IMPLEMENTED_YET</translation>
+ <translation>実装されていません</translation>
</message>
<message>
<location filename="MEDOP/gui/WorkspaceController.cxx" line="440"/>
<source>FUNCTION_NOT_IMPLEMENTED</source>
- <translation>FUNCTION_NOT_IMPLEMENTED</translation>
+ <translation>この機能はまだ実装されていません</translation>
</message>
</context>
<context>
<message>
<location filename="MEDOP/gui/MEDOPModule.cxx" line="151"/>
<source>FILE_FILTER_MED</source>
- <translation>FILE_FILTER_MED</translation>
+ <translation>音楽配信マック & ファイル (* .med)</translation>
</message>
<message>
<location filename="MEDOP/gui/dialogs/DlgImageToMed.cxx" line="57"/>
<source>FILE_FILTER_PNG</source>
- <translation>FILE_FILTER_PNG</translation>
+ <translation>イメージ PNG (*.png)</translation>
</message>
<message>
<location filename="MEDOP/gui/dialogs/DlgImageToMed.cxx" line="58"/>
<source>FILE_FILTER_JPG</source>
- <translation>FILE_FILTER_JPG</translation>
+ <translation>画像 JPG (*.jpg)</translation>
</message>
<message>
<location filename="MEDOP/gui/dialogs/DlgImageToMed.cxx" line="59"/>
<source>FILE_FILTER_PGM</source>
- <translation>FILE_FILTER_PGM</translation>
+ <translation>イメージ PGM (*.jpg)</translation>
</message>
<message>
<location filename="MEDOP/gui/dialogs/DlgImageToMed.cxx" line="60"/>
<source>FILE_FILTER_ALL</source>
- <translation>FILE_FILTER_ALL</translation>
+ <translation>すべてのファイル (*. *)</translation>
</message>
</context>
</TS>
//Description tag
time_t present;
- char date[6];
+ char date[20];
#ifndef WIN32
time( &present);
struct tm *time_asc = localtime(&present);
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}")
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<INTERP_KERNEL::NormalizedCellType>& types=m->getAllTypes();
+ std::set<INTERP_KERNEL::NormalizedCellType> types(m->getAllGeoTypes());
if (_verbose)
{
cout<<"\n types in "<<name<<" : ";
CPPUNIT_ASSERT_EQUAL(3,mesh->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));
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());
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));
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));
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));
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));
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));
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++)
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++)
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));
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));
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());
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();
}
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}")