ENDIF(WIN32)
ADD_SUBDIRECTORY(src)
-IF(NOT SALOME_MED_STANDALONE)
- ADD_SUBDIRECTORY(adm_local)
-ENDIF(NOT SALOME_MED_STANDALONE)
+ADD_SUBDIRECTORY(adm_local)
IF(SALOME_BUILD_DOC)
ADD_SUBDIRECTORY(doc)
IF(SALOME_MED_BUILD_GUI)
# Include GUI targets if they were not already loaded:
- IF(NOT (TARGET Event))
+ IF(NOT (TARGET Event) AND NOT SALOME_MED_STANDALONE)
INCLUDE("${GUI_ROOT_DIR_EXP}/${SALOME_INSTALL_CMAKE_LOCAL}/SalomeGUITargets.cmake")
ENDIF()
ELSE(SALOME_MED_BUILD_GUI)
#
MESSAGE(STATUS "Check for XDR ...")
-SET(XDR_ROOT_DIR $ENV{XDR_ROOT_DIR} CACHE PATH "Path to the XDR.")
-IF(XDR_ROOT_DIR)
- LIST(APPEND CMAKE_LIBRARY_PATH "${XDR_ROOT_DIR}/lib")
- LIST(APPEND CMAKE_INCLUDE_PATH "${XDR_ROOT_DIR}/include")
-ENDIF(XDR_ROOT_DIR)
-FIND_LIBRARY(XDR_LIBRARIES xdr)
FIND_PATH(XDR_INCLUDE_DIRS rpc/xdr.h)
SET(XDR_DEFINITIONS "-DHAS_XDR")
IF(WIN32)
- LIST(APPEND XDR_INCLUDE_DIRS "${XDR_ROOT_DIR}/include/src/msvc")
+ FIND_LIBRARY(XDR_LIBRARIES xdr) # To get the .lib file from XDR
+ FIND_PATH(XDR_INCLUDE_DIRS2 src/msvc/stdint.h) # To get the stdint.h from XDR (needed by types.h)
+ IF(XDR_INCLUDE_DIRS)
+ IF(XDR_INCLUDE_DIRS2)
+ LIST(APPEND XDR_INCLUDE_DIRS "${XDR_INCLUDE_DIRS2}")
+ ELSE()
+ SET(XDR_INCLUDE_DIRS "${XDR_INCLUDE_DIRS2}") # Make the detection fail
+ ENDIF()
+ ENDIF()
ENDIF(WIN32)
INCLUDE(FindPackageHandleStandardArgs)
MESSAGE(STATUS "Creation of ${output}")
CONFIGURE_FILE(${input} ${output})
INSTALL(FILES ${output} DESTINATION ${SALOME_INSTALL_HEADERS})
+
+FILE(GLOB CMAKE_CONFIG_FILES "${CMAKE_CURRENT_SOURCE_DIR}/cmake_files/*.cmake")
+INSTALL(FILES ${CMAKE_CONFIG_FILES} DESTINATION ${SALOME_INSTALL_CMAKE_LOCAL})
{
}
-ExprParser::ExprParser(const char *expr, ExprParser *father):_father(father),_is_parsed(false),_leaf(0),_is_parsing_ok(false),_expr(expr)
+ExprParser::ExprParser(const std::string& expr, ExprParser *father):_father(father),_is_parsed(false),_leaf(0),_is_parsing_ok(false),_expr(expr)
{
_expr=deleteWhiteSpaces(_expr);
}
class ExprParser
{
public:
- INTERPKERNEL_EXPORT ExprParser(const char *expr, ExprParser *father=0);
+ INTERPKERNEL_EXPORT ExprParser(const std::string& expr, ExprParser *father=0);
INTERPKERNEL_EXPORT ExprParser(const char *expr, int lgth, ExprParser *father=0);
INTERPKERNEL_EXPORT ~ExprParser();
INTERPKERNEL_EXPORT void parse();
return anIsSatisfy;
}
+std::vector<double> GaussInfo::NormalizeCoordinatesIfNecessary(NormalizedCellType ct, int inputDim, const std::vector<double>& inputArray)
+{
+ std::size_t sz(inputArray.size()),dim((std::size_t)inputDim);
+ if(dim==0)
+ throw INTERP_KERNEL::Exception("GaussInfo::NormalizeCoordinatesIfNecessary : invalid dimension ! Must be !=0 !");
+ if(sz%dim!=0)
+ throw INTERP_KERNEL::Exception("GaussInfo::NormalizeCoordinatesIfNecessary : invalid input array ! Inconsistent with the given dimension !");
+ const CellModel& cm(CellModel::GetCellModel(ct));
+ std::size_t baseDim((std::size_t)cm.getDimension());
+ if(baseDim==dim)
+ return inputArray;
+ std::size_t nbOfItems(sz/dim);
+ std::vector<double> ret(nbOfItems*baseDim);
+ if(baseDim>dim)
+ {
+ for(std::size_t i=0;i<nbOfItems;i++)
+ {
+ std::size_t j=0;
+ for(;j<dim;j++)
+ ret[i*baseDim+j]=inputArray[i*dim+j];
+ for(;j<baseDim;j++)
+ ret[i*baseDim+j]=0.;
+ }
+ }
+ else
+ {
+ for(std::size_t i=0;i<nbOfItems;i++)
+ {
+ std::size_t j=0;
+ for(;j<baseDim;j++)
+ ret[i*baseDim+j]=inputArray[i*dim+j];
+ }
+ }
+ return ret;
+}
+
+typedef void (*MapToShapeFunction)(GaussInfo& obj);
+
/*!
* Initialize the internal vectors
*/
void GaussInfo::initLocalInfo()
{
bool aSatify = false;
- const CellModel& cellModel=CellModel::GetCellModel(_my_geometry);
+ const CellModel& cellModel(CellModel::GetCellModel(_my_geometry));
switch( _my_geometry )
{
case NORM_SEG2:
break;
case NORM_QUAD4:
- _my_local_ref_dim = 2;
- _my_local_nb_ref = 4;
- quad4aInit();
- aSatify = isSatisfy();
-
- if(!aSatify)
- {
- quad4bInit();
- aSatify = isSatisfy();
- CHECK_MACRO;
- }
+ {
+ _my_local_ref_dim = 2;
+ _my_local_nb_ref = 4;
+ MapToShapeFunction QUAD4PTR[]={Quad4aInit,Quad4bInit,Quad4cInit,Quad4DegSeg2Init};
+ std::size_t NB_OF_QUAD4PTR(sizeof(QUAD4PTR)/sizeof(MapToShapeFunction));
+ for(std::size_t i=0;i<NB_OF_QUAD4PTR && !aSatify;i++)
+ {
+ (QUAD4PTR[i])(*this);
+ aSatify = isSatisfy();
+ }
+ CHECK_MACRO;
+ break;
+ }
break;
case NORM_QUAD8:
}
break;
+ case NORM_QUAD9:
+ _my_local_ref_dim = 2;
+ _my_local_nb_ref = 9;
+ quad9aInit();
+ aSatify = isSatisfy();
+ CHECK_MACRO;
+ break;
+
case NORM_TETRA4:
_my_local_ref_dim = 3;
_my_local_nb_ref = 4;
break;
case NORM_PENTA6:
+ {
+ _my_local_ref_dim = 3;
+ _my_local_nb_ref = 6;
+ MapToShapeFunction PENTA6PTR[]={Penta6aInit,Penta6bInit,Penta6DegTria3aInit,Penta6DegTria3bInit};
+ std::size_t NB_OF_PENTA6PTR(sizeof(PENTA6PTR)/sizeof(MapToShapeFunction));
+ for(std::size_t i=0;i<NB_OF_PENTA6PTR && !aSatify;i++)
+ {
+ (PENTA6PTR[i])(*this);
+ aSatify = isSatisfy();
+ }
+ CHECK_MACRO;
+ break;
+ }
+
+
_my_local_ref_dim = 3;
_my_local_nb_ref = 6;
penta6aInit();
break;
case NORM_HEXA8:
- _my_local_ref_dim = 3;
- _my_local_nb_ref = 8;
- hexa8aInit();
- aSatify = isSatisfy();
-
- if(!aSatify)
- {
- hexa8bInit();
- aSatify = isSatisfy();
- CHECK_MACRO;
- }
- break;
+ {
+ _my_local_ref_dim = 3;
+ _my_local_nb_ref = 8;
+ MapToShapeFunction HEXA8PTR[]={Hexa8aInit,Hexa8bInit,Hexa8DegQuad4aInit,Hexa8DegQuad4bInit,Hexa8DegQuad4cInit};
+ std::size_t NB_OF_HEXA8PTR(sizeof(HEXA8PTR)/sizeof(MapToShapeFunction));
+ for(std::size_t i=0;i<NB_OF_HEXA8PTR && !aSatify;i++)
+ {
+ (HEXA8PTR[i])(*this);
+ aSatify = isSatisfy();
+ }
+ CHECK_MACRO;
+ break;
+ }
case NORM_HEXA20:
_my_local_ref_dim = 3;
LOCAL_COORD_MACRO_END;
SHAPE_FUN_MACRO_BEGIN;
- funValue[0] = 0.5*(1.0 - gc[0])*gc[0];
+ funValue[0] = -0.5*(1.0 - gc[0])*gc[0];
funValue[1] = 0.5*(1.0 + gc[0])*gc[0];
funValue[2] = (1.0 + gc[0])*(1.0 - gc[0]);
SHAPE_FUN_MACRO_END;
SHAPE_FUN_MACRO_END;
}
+void GaussInfo::quad4cInit()
+{
+ LOCAL_COORD_MACRO_BEGIN;
+ case 0:
+ coords[0] = -1.0;
+ coords[1] = -1.0;
+ break;
+ case 1:
+ coords[0] = -1.0;
+ coords[1] = 1.0;
+ break;
+ case 2:
+ coords[0] = 1.0;
+ coords[1] = 1.0;
+ break;
+ case 3:
+ coords[0] = 1.0;
+ coords[1] = -1.0;
+ break;
+
+ LOCAL_COORD_MACRO_END;
+
+ SHAPE_FUN_MACRO_BEGIN;
+ funValue[0] = 0.25*(1.0 - gc[0])*(1.0 - gc[1]);
+ funValue[1] = 0.25*(1.0 - gc[0])*(1.0 + gc[1]);
+ funValue[2] = 0.25*(1.0 + gc[0])*(1.0 + gc[1]);
+ funValue[3] = 0.25*(1.0 + gc[0])*(1.0 - gc[1]);
+ SHAPE_FUN_MACRO_END;
+}
+
+/*!
+ * This shapefunc map is same as degenerated seg2Init
+ */
+void GaussInfo::quad4DegSeg2Init()
+{
+ LOCAL_COORD_MACRO_BEGIN;
+ case 0:
+ coords[0] = -1.0;
+ coords[1] = 0.0;
+ break;
+ case 1:
+ coords[0] = 1.0;
+ coords[1] = 0.0;
+ break;
+ case 2:
+ coords[0] = 0.0;
+ coords[1] = 0.0;
+ break;
+ case 3:
+ coords[0] = 0.0;
+ coords[1] = 0.0;
+ break;
+ LOCAL_COORD_MACRO_END;
+
+ SHAPE_FUN_MACRO_BEGIN;
+ funValue[0] = 0.5*(1.0 - gc[0]);
+ funValue[1] = 0.5*(1.0 + gc[0]);
+ funValue[2] = 0.;
+ funValue[3] = 0.;
+ SHAPE_FUN_MACRO_END;
+}
/*!
* Init Quadratic Quadrangle Reference coordinates ans Shape function.
SHAPE_FUN_MACRO_END;
}
+void GaussInfo::quad9aInit()
+{
+ LOCAL_COORD_MACRO_BEGIN;
+ case 0:
+ coords[0] = -1.0;
+ coords[1] = -1.0;
+ break;
+ case 1:
+ coords[0] = 1.0;
+ coords[1] = -1.0;
+ break;
+ case 2:
+ coords[0] = 1.0;
+ coords[1] = 1.0;
+ break;
+ case 3:
+ coords[0] = -1.0;
+ coords[1] = 1.0;
+ break;
+ case 4:
+ coords[0] = 0.0;
+ coords[1] = -1.0;
+ break;
+ case 5:
+ coords[0] = 1.0;
+ coords[1] = 0.0;
+ break;
+ case 6:
+ coords[0] = 0.0;
+ coords[1] = 1.0;
+ break;
+ case 7:
+ coords[0] = -1.0;
+ coords[1] = 0.0;
+ break;
+ case 8:
+ coords[0] = 0.0;
+ coords[1] = 0.0;
+ break;
+ LOCAL_COORD_MACRO_END;
+
+ SHAPE_FUN_MACRO_BEGIN;
+ funValue[0] = 0.25*gc[0]*gc[1]*(gc[0]-1.)*(gc[1]-1.);
+ funValue[1] = 0.25*gc[0]*gc[1]*(gc[0]+1.)*(gc[1]-1.);
+ funValue[2] = 0.25*gc[0]*gc[1]*(gc[0]+1.)*(gc[1]+1.);
+ funValue[3] = 0.25*gc[0]*gc[1]*(gc[0]-1.)*(gc[1]+1.);
+ funValue[4] = 0.5*(1.-gc[0]*gc[0])*gc[1]*(gc[1]-1.);
+ funValue[5] = 0.5*gc[0]*(gc[0]+1.)*(1.-gc[1]*gc[1]);
+ funValue[6] = 0.5*(1.-gc[0]*gc[0])*gc[1]*(gc[1]+1.);
+ funValue[7] = 0.5*gc[0]*(gc[0]-1.)*(1.-gc[1]*gc[1]);
+ funValue[8] = (1.-gc[0]*gc[0])*(1.-gc[1]*gc[1]);
+ SHAPE_FUN_MACRO_END;
+}
+
/*!
* Init Tetrahedron Reference coordinates ans Shape function.
* Case A.
funValue[4] = 0.5*(1.0 - gc[1] - gc[2])*(1.0 + gc[0]);
SHAPE_FUN_MACRO_END;
}
+
+/*!
+ * This shapefunc map is same as degenerated tria3aInit
+ */
+void GaussInfo::penta6DegTria3aInit()
+{
+ LOCAL_COORD_MACRO_BEGIN;
+ case 0:
+ coords[0] = -1.0;
+ coords[1] = 1.0;
+ coords[2] = 0.0;
+ break;
+ case 1:
+ coords[0] = -1.0;
+ coords[1] = -1.0;
+ coords[2] = 0.0;
+ break;
+ case 2:
+ coords[0] = 1.0;
+ coords[1] = -1.0;
+ coords[2] = 0.0;
+ break;
+ case 3:
+ coords[0] = 0.0;
+ coords[1] = 0.0;
+ coords[2] = 0.0;
+ break;
+ case 4:
+ coords[0] = 0.0;
+ coords[1] = 0.0;
+ coords[2] = 0.0;
+ break;
+ case 5:
+ coords[0] = 0.0;
+ coords[1] = 0.0;
+ coords[2] = 0.0;
+ break;
+ LOCAL_COORD_MACRO_END;
+
+ SHAPE_FUN_MACRO_BEGIN;
+ funValue[0] = 0.5*(1.0 + gc[1]);
+ funValue[1] = -0.5*(gc[0] + gc[1]);
+ funValue[2] = 0.5*(1.0 + gc[0]);
+ funValue[3] = 0.;
+ funValue[4] = 0.;
+ funValue[5] = 0.;
+ SHAPE_FUN_MACRO_END;
+}
+
+/*!
+ * This shapefunc map is same as degenerated tria3bInit
+ */
+void GaussInfo::penta6DegTria3bInit()
+{
+ LOCAL_COORD_MACRO_BEGIN;
+ case 0:
+ coords[0] = 0.0;
+ coords[1] = 0.0;
+ coords[2] = 0.0;
+ break;
+ case 1:
+ coords[0] = 1.0;
+ coords[1] = 0.0;
+ coords[2] = 0.0;
+ break;
+ case 2:
+ coords[0] = 0.0;
+ coords[1] = 1.0;
+ coords[2] = 0.0;
+ break;
+ case 3:
+ coords[0] = 0.0;
+ coords[1] = 0.0;
+ coords[2] = 0.0;
+ break;
+ case 4:
+ coords[0] = 0.0;
+ coords[1] = 0.0;
+ coords[2] = 0.0;
+ break;
+ case 5:
+ coords[0] = 0.0;
+ coords[1] = 0.0;
+ coords[2] = 0.0;
+ break;
+ LOCAL_COORD_MACRO_END;
+
+ SHAPE_FUN_MACRO_BEGIN;
+ funValue[0] = 1.0 - gc[0] - gc[1];
+ funValue[1] = gc[0];
+ funValue[2] = gc[1];
+ funValue[3] = 0.;
+ funValue[4] = 0.;
+ funValue[5] = 0.;
+ SHAPE_FUN_MACRO_END;
+}
+
/*!
* Init Pentahedron Reference coordinates and Shape function.
* Case A.
SHAPE_FUN_MACRO_END;
}
+/*!
+ * This shapefunc map is same as degenerated quad4bInit
+ */
+void GaussInfo::hexa8DegQuad4aInit()
+{
+ LOCAL_COORD_MACRO_BEGIN;
+ case 0:
+ coords[0] = -1.0;
+ coords[1] = 1.0;
+ coords[2] = 0.0;
+ break;
+ case 1:
+ coords[0] = -1.0;
+ coords[1] = -1.0;
+ coords[2] = 0.0;
+ break;
+ case 2:
+ coords[0] = 1.0;
+ coords[1] = -1.0;
+ coords[2] = 0.0;
+ break;
+ case 3:
+ coords[0] = 1.0;
+ coords[1] = 1.0;
+ coords[2] = 0.0;
+ break;
+ case 4:
+ coords[0] = 0.0;
+ coords[1] = 0.0;
+ coords[2] = 0.0;
+ break;
+ case 5:
+ coords[0] = 0.0;
+ coords[1] = 0.0;
+ coords[2] = 0.0;
+ break;
+ case 6:
+ coords[0] = 0.0;
+ coords[1] = 0.0;
+ coords[2] = 0.0;
+ break;
+ case 7:
+ coords[0] = 0.0;
+ coords[1] = 0.0;
+ coords[2] = 0.0;
+ break;
+ LOCAL_COORD_MACRO_END;
+
+ SHAPE_FUN_MACRO_BEGIN;
+ funValue[0] = 0.25*(1.0 + gc[1])*(1.0 - gc[0]);
+ funValue[1] = 0.25*(1.0 - gc[1])*(1.0 - gc[0]);
+ funValue[2] = 0.25*(1.0 - gc[1])*(1.0 + gc[0]);
+ funValue[3] = 0.25*(1.0 + gc[0])*(1.0 + gc[1]);
+ funValue[4] = 0.;
+ funValue[5] = 0.;
+ funValue[6] = 0.;
+ funValue[7] = 0.;
+ SHAPE_FUN_MACRO_END;
+}
+
+/*!
+ * This shapefunc map is same as degenerated quad4bInit
+ */
+void GaussInfo::hexa8DegQuad4bInit()
+{
+ LOCAL_COORD_MACRO_BEGIN;
+ case 0:
+ coords[0] = -1.0;
+ coords[1] = -1.0;
+ coords[2] = 0.0;
+ break;
+ case 1:
+ coords[0] = 1.0;
+ coords[1] = -1.0;
+ coords[2] = 0.0;
+ break;
+ case 2:
+ coords[0] = 1.0;
+ coords[1] = 1.0;
+ coords[2] = 0.0;
+ break;
+ case 3:
+ coords[0] = -1.0;
+ coords[1] = 1.0;
+ coords[2] = 0.0;
+ break;
+ case 4:
+ coords[0] = 0.0;
+ coords[1] = 0.0;
+ coords[2] = 0.0;
+ break;
+ case 5:
+ coords[0] = 0.0;
+ coords[1] = 0.0;
+ coords[2] = 0.0;
+ break;
+ case 6:
+ coords[0] = 0.0;
+ coords[1] = 0.0;
+ coords[2] = 0.0;
+ break;
+ case 7:
+ coords[0] = 0.0;
+ coords[1] = 0.0;
+ coords[2] = 0.0;
+ break;
+ LOCAL_COORD_MACRO_END;
+
+ SHAPE_FUN_MACRO_BEGIN;
+ funValue[0] = 0.25*(1.0 - gc[0])*(1.0 - gc[1]);
+ funValue[1] = 0.25*(1.0 + gc[0])*(1.0 - gc[1]);
+ funValue[2] = 0.25*(1.0 + gc[0])*(1.0 + gc[1]);
+ funValue[3] = 0.25*(1.0 - gc[0])*(1.0 + gc[1]);
+ funValue[4] = 0.;
+ funValue[5] = 0.;
+ funValue[6] = 0.;
+ funValue[7] = 0.;
+ SHAPE_FUN_MACRO_END;
+}
+
+/*!
+ * This shapefunc map is same as degenerated quad4cInit
+ */
+void GaussInfo::hexa8DegQuad4cInit()
+{
+ LOCAL_COORD_MACRO_BEGIN;
+ case 0:
+ coords[0] = -1.0;
+ coords[1] = -1.0;
+ coords[2] = 0.0;
+ break;
+ case 1:
+ coords[0] = -1.0;
+ coords[1] = 1.0;
+ coords[2] = 0.0;
+ break;
+ case 2:
+ coords[0] = 1.0;
+ coords[1] = 1.0;
+ coords[2] = 0.0;
+ break;
+ case 3:
+ coords[0] = 1.0;
+ coords[1] = -1.0;
+ coords[2] = 0.0;
+ break;
+ case 4:
+ coords[0] = 0.0;
+ coords[1] = 0.0;
+ coords[2] = 0.0;
+ break;
+ case 5:
+ coords[0] = 0.0;
+ coords[1] = 0.0;
+ coords[2] = 0.0;
+ break;
+ case 6:
+ coords[0] = 0.0;
+ coords[1] = 0.0;
+ coords[2] = 0.0;
+ break;
+ case 7:
+ coords[0] = 0.0;
+ coords[1] = 0.0;
+ coords[2] = 0.0;
+ break;
+
+ LOCAL_COORD_MACRO_END;
+
+ SHAPE_FUN_MACRO_BEGIN;
+ funValue[0] = 0.25*(1.0 - gc[0])*(1.0 - gc[1]);
+ funValue[1] = 0.25*(1.0 - gc[0])*(1.0 + gc[1]);
+ funValue[2] = 0.25*(1.0 + gc[0])*(1.0 + gc[1]);
+ funValue[3] = 0.25*(1.0 + gc[0])*(1.0 - gc[1]);
+ funValue[4] = 0. ;
+ funValue[5] = 0. ;
+ funValue[6] = 0. ;
+ funValue[7] = 0. ;
+ SHAPE_FUN_MACRO_END;
+}
+
/*!
* Init Qaudratic Hehahedron Reference coordinates and Shape function.
* Case A.
INTERPKERNEL_EXPORT const double* getFunctionValues( const int theGaussId ) const;
INTERPKERNEL_EXPORT void initLocalInfo();
+
+ INTERPKERNEL_EXPORT static std::vector<double> NormalizeCoordinatesIfNecessary(NormalizedCellType ct, int inputDim, const std::vector<double>& inputArray);
protected:
void tria6bInit();
void quad4aInit();
+ static void Quad4aInit(GaussInfo& obj) { obj.quad4aInit(); }
void quad4bInit();
+ static void Quad4bInit(GaussInfo& obj) { obj.quad4bInit(); }
+ void quad4cInit();
+ static void Quad4cInit(GaussInfo& obj) { obj.quad4cInit(); }
+ void quad4DegSeg2Init();
+ static void Quad4DegSeg2Init(GaussInfo& obj) { obj.quad4DegSeg2Init(); }
void quad8aInit();
void quad8bInit();
+ void quad9aInit();
//3D
void tetra4aInit();
void pyra13bInit();
void penta6aInit();
+ static void Penta6aInit(GaussInfo& obj) { obj.penta6aInit(); }
void penta6bInit();
+ static void Penta6bInit(GaussInfo& obj) { obj.penta6bInit(); }
+ void penta6DegTria3aInit();
+ static void Penta6DegTria3aInit(GaussInfo& obj) { obj.penta6DegTria3aInit(); }
+ void penta6DegTria3bInit();
+ static void Penta6DegTria3bInit(GaussInfo& obj) { obj.penta6DegTria3bInit(); }
+
void penta15aInit();
void penta15bInit();
void hexa8aInit();
+ static void Hexa8aInit(GaussInfo& obj) { obj.hexa8aInit(); }
void hexa8bInit();
+ static void Hexa8bInit(GaussInfo& obj) { obj.hexa8bInit(); }
+ void hexa8DegQuad4aInit();
+ static void Hexa8DegQuad4aInit(GaussInfo& obj) { obj.hexa8DegQuad4aInit(); }
+ void hexa8DegQuad4bInit();
+ static void Hexa8DegQuad4bInit(GaussInfo& obj) { obj.hexa8DegQuad4bInit(); }
+ void hexa8DegQuad4cInit();
+ static void Hexa8DegQuad4cInit(GaussInfo& obj) { obj.hexa8DegQuad4cInit(); }
void hexa20aInit();
void hexa20bInit();
(*iter)->initLocations();
}
+/**
+ * Reset the status of all edges (OUT, IN, ON) because they were potentially assignated
+ * by the previous candidate processing.
+ */
void ComposedEdge::initLocationsWithOther(const ComposedEdge& other) const
{
std::set<Edge *> s1,s2;
other.getAllNodes(allNodes);
for(std::set<Node *>::iterator iter=allNodes.begin();iter!=allNodes.end();iter++)
(*iter)->unApplySimilarity(xBary,yBary,fact);
+
+ // [Adrien] - same issue as in applyGlobalSimilarity() - see comments there
+ std::set<Edge *> allEdges;
for(std::list<ElementaryEdge *>::iterator iter=_sub_edges.begin();iter!=_sub_edges.end();iter++)
- (*iter)->unApplySimilarity(xBary,yBary,fact);
+ allEdges.insert((*iter)->getPtr());
for(std::list<ElementaryEdge *>::iterator iter=other._sub_edges.begin();iter!=other._sub_edges.end();iter++)
+ allEdges.insert((*iter)->getPtr());
+ for(std::set<Edge *>::iterator iter = allEdges.begin();iter != allEdges.end();iter++)
(*iter)->unApplySimilarity(xBary,yBary,fact);
}
allNodes.insert(allNodes2.begin(),allNodes2.end());
for(std::set<Node *>::iterator iter=allNodes.begin();iter!=allNodes.end();iter++)
(*iter)->applySimilarity(xBary,yBary,dimChar);
+ // [Adrien] many ElementaryEdge might reference the same Edge* - ensure we don'y scale twice!
+ std::set<Edge *> allEdges;
for(std::list<ElementaryEdge *>::iterator iter=_sub_edges.begin();iter!=_sub_edges.end();iter++)
- (*iter)->applySimilarity(xBary,yBary,dimChar);
+ allEdges.insert((*iter)->getPtr());
for(std::list<ElementaryEdge *>::iterator iter=other->_sub_edges.begin();iter!=other->_sub_edges.end();iter++)
- (*iter)->applySimilarity(xBary,yBary,dimChar);
+ allEdges.insert((*iter)->getPtr());
+ // Similarity only on set of unique underlying edges:
+ for(std::set<Edge *>::iterator iter = allEdges.begin();iter != allEdges.end();iter++)
+ (*iter)->applySimilarity(xBary,yBary,dimChar);
}
/*!
}
/*!
+ * This method makes the hypothesis that \a nodeToTest can be either IN or OUT.
+ *
* \sa ComposedEdge::isInOrOut2
*/
bool ComposedEdge::isInOrOut(Node *nodeToTest) const
{
+ Bounds b; b.prepareForAggregation();
+ fillBounds(b);
+ if(b.nearlyWhere((*nodeToTest)[0],(*nodeToTest)[1])==OUT)
+ return false;
std::set< IntersectElement > inOutSwitch;
double ref(isInOrOutAlg(nodeToTest,inOutSwitch));
- bool ret=false;
+ bool ret(false);
for(std::set< IntersectElement >::iterator iter4=inOutSwitch.begin();iter4!=inOutSwitch.end();iter4++)
{
if((*iter4).getVal1()<ref)
/*!
* 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
*/
{
std::set< IntersectElement > inOutSwitch;
double ref(isInOrOutAlg(nodeToTest,inOutSwitch));
- bool ret=false;
+ bool ret(false);
for(std::set< IntersectElement >::iterator iter4=inOutSwitch.begin();iter4!=inOutSwitch.end();iter4++)
{
double val((*iter4).getVal1());
double ComposedEdge::isInOrOutAlg(Node *nodeToTest, std::set< IntersectElement >& inOutSwitch) const
{
- Bounds b; b.prepareForAggregation();
- fillBounds(b);
- if(b.nearlyWhere((*nodeToTest)[0],(*nodeToTest)[1])==OUT)
- return false;
// searching for e1
std::set<Node *> nodes;
getAllNodes(nodes);
Edge *e=val->getPtr();
std::auto_ptr<EdgeIntersector> intersc(Edge::BuildIntersectorWith(e1,e));
bool obviousNoIntersection,areOverlapped;
- intersc->areOverlappedOrOnlyColinears(0,obviousNoIntersection,areOverlapped);
+ intersc->areOverlappedOrOnlyColinears(0,obviousNoIntersection,areOverlapped); // first parameter never used
if(obviousNoIntersection)
{
continue;
return fabs(p1.first-p2.first)<QUADRATIC_PLANAR::_precision;
}
-void Edge::sortIdsAbs(const std::vector<INTERP_KERNEL::Node *>& addNodes, const std::map<INTERP_KERNEL::Node *, int>& mapp1, const std::map<INTERP_KERNEL::Node *, int>& mapp2, std::vector<int>& edgesThis)
+/**
+ * Sort nodes so that they all lie consecutively on the edge that has been cut.
+ */
+void Edge::sortIdsAbs(const std::vector<INTERP_KERNEL::Node *>& addNodes, const std::map<INTERP_KERNEL::Node *, int>& mapp1,
+ const std::map<INTERP_KERNEL::Node *, int>& mapp2, std::vector<int>& edgesThis)
{
Bounds b;
b.prepareForAggregation();
/*!
* Deal with an oriented edge of a polygon.
- * An Edge is definied with a start node a end node and an equation of 1D curve.
+ * An Edge is defined with a start node, an end node and an equation of 1D curve.
* All other attributes are mutable because they don't impact these 3 invariant attributes.
- * To be exact start and end node can change (adress) but their location remain
+ * To be exact start and end nodes can change (address) but their location remain
* the same (at precision).
*/
class INTERPKERNEL_EXPORT Edge
void ArcCSegIntersector::areOverlappedOrOnlyColinears(const Bounds *whereToFind, bool& obviousNoIntersection, bool& areOverlapped)
{
- areOverlapped=false;//No overlapping by contruction
+ areOverlapped=false;//No overlapping by construction
const double *center=getE1().getCenter();
_dx=(*(_e2.getEndNode()))[0]-(*(_e2.getStartNode()))[0];
_dy=(*(_e2.getEndNode()))[1]-(*(_e2.getStartNode()))[1];
TypeOfEdgeLocInPolygon ElementaryEdge::locateFullyMySelfAbsolute(const ComposedEdge& pol) const
{
- Node *node=_ptr->buildRepresentantOfMySelf();
+ Node *node=_ptr->buildRepresentantOfMySelf(); // build barycenter used to detect if the edge is IN or OUT
if(pol.isInOrOut(node))
declareIn();
else
/*!
* WARNING different from 'computeAngle' method ! The returned value are not in the same interval !
- * Here in -Pi/2; Pi/2. Typically this method returns the same value by exchanging pt1 and pt2.
+ * Here in [0; Pi). Typically this method returns the same value by exchanging pt1 and pt2.
* Use in process of detection of a point in or not in polygon.
*/
double Node::computeSlope(const double *pt1, const double *pt2)
}
/*!
- * This method splits 'this' with 'other' into smaller pieces localizable. 'mapThis' is a map that gives the correspondance between nodes contained in 'this' and node ids in a global mesh.
- * In the same way, 'mapOther' gives the correspondance between nodes contained in 'other' and node ids in a global mesh from wich 'other' is extracted.
- * This method has 1 out paramater : 'edgesThis', After the call of this method contains nodal connectivity (including type) of 'this' into globlal "this mesh".
- * This method has 2 in/out parameters : 'subDivOther' and 'addCoo'.'otherEdgeIds' is useful to put values in 'edgesThis', 'subDivOther' and 'addCoo'.
+ * This method splits 'this' with 'other' into smaller pieces localizable. 'mapThis' is a map that gives the correspondance
+ * between nodes contained in 'this' and node ids in a global mesh.
+ * In the same way, 'mapOther' gives the correspondance between nodes contained in 'other' and node ids in a
+ * global mesh from wich 'other' is extracted.
+ * This method has 1 out paramater : 'edgesThis', After the call of this method, it contains the nodal connectivity (including type)
+ * of 'this' into globlal "this mesh".
+ * This method has 2 in/out parameters : 'subDivOther' and 'addCoo'.'otherEdgeIds' is useful to put values in
+ * 'edgesThis', 'subDivOther' and 'addCoo'.
* Size of 'otherEdgeIds' has to be equal to number of ElementaryEdges in 'other'. No check of that will be done.
+ * The term 'abs' in the name recalls that we normalize the mesh (spatially) so that node coordinates fit into [0;1].
* @param offset1 is the number of nodes contained in global mesh from which 'this' is extracted.
* @param offset2 is the sum of nodes contained in global mesh from which 'this' is extracted and 'other' is extracted.
* @param edgesInOtherColinearWithThis will be appended at the end of the vector with colinear edge ids of other (if any)
- * @otherEdgeIds is a vector with the same size than other before calling this method. It gives in the same order the cell id in global other mesh.
+ * @param otherEdgeIds is a vector with the same size than other before calling this method. It gives in the same order
+ * the cell id in global other mesh.
*/
-void QuadraticPolygon::splitAbs(QuadraticPolygon& other, const std::map<INTERP_KERNEL::Node *,int>& mapThis, const std::map<INTERP_KERNEL::Node *,int>& mapOther, int offset1, int offset2 , const std::vector<int>& otherEdgeIds,
- std::vector<int>& edgesThis, int cellIdThis, std::vector< std::vector<int> >& edgesInOtherColinearWithThis, std::vector< std::vector<int> >& subDivOther, std::vector<double>& addCoo)
+void QuadraticPolygon::splitAbs(QuadraticPolygon& other,
+ const std::map<INTERP_KERNEL::Node *,int>& mapThis, const std::map<INTERP_KERNEL::Node *,int>& mapOther,
+ int offset1, int offset2 ,
+ const std::vector<int>& otherEdgeIds,
+ std::vector<int>& edgesThis, int cellIdThis,
+ std::vector< std::vector<int> >& edgesInOtherColinearWithThis, std::vector< std::vector<int> >& subDivOther,
+ std::vector<double>& addCoo)
{
double xBaryBB, yBaryBB;
double fact=normalizeExt(&other, xBaryBB, yBaryBB);
}
/*!
- * This method builds from descending conn of a quadratic polygon stored in crude mode (MEDCoupling). Descending conn is in FORTRAN relative mode in order to give the
- * orientation of edge.
+ * This method builds 'this' from its descending conn stored in crude mode (MEDCoupling).
+ * Descending conn is in FORTRAN relative mode in order to give the
+ * orientation of edge (see buildDescendingConnectivity2() method).
+ * See appendEdgeFromCrudeDataArray() for params description.
*/
void QuadraticPolygon::buildFromCrudeDataArray(const std::map<int,INTERP_KERNEL::Node *>& mapp, bool isQuad, const int *nodalBg, const double *coords,
const int *descBg, const int *descEnd, const std::vector<std::vector<int> >& intersectEdges)
}
}
-void QuadraticPolygon::appendEdgeFromCrudeDataArray(std::size_t edgePos, const std::map<int,INTERP_KERNEL::Node *>& mapp, bool isQuad, const int *nodalBg, const double *coords,
- const int *descBg, const int *descEnd, const std::vector<std::vector<int> >& intersectEdges)
+void QuadraticPolygon::appendEdgeFromCrudeDataArray(std::size_t edgePos, const std::map<int,INTERP_KERNEL::Node *>& mapp, bool isQuad,
+ const int *nodalBg, const double *coords,
+ const int *descBg, const int *descEnd, const std::vector<std::vector<int> >& intersectEdges)
{
if(!isQuad)
{
bool direct=descBg[edgePos]>0;
- int edgeId=abs(descBg[edgePos])-1;
+ int edgeId=abs(descBg[edgePos])-1; // back to C indexing mode
const std::vector<int>& subEdge=intersectEdges[edgeId];
std::size_t nbOfSubEdges=subEdge.size()/2;
for(std::size_t j=0;j<nbOfSubEdges;j++)
/*!
* Method expected to be called on pol2. Every params not suffixed by numbered are supposed to refer to pol2 (this).
+ * Method to find edges that are ON.
*/
-void QuadraticPolygon::updateLocOfEdgeFromCrudeDataArray2(const int *descBg, const int *descEnd, const std::vector<std::vector<int> >& intersectEdges, const INTERP_KERNEL::QuadraticPolygon& pol1, const int *descBg1, const int *descEnd1, const std::vector<std::vector<int> >& intersectEdges1, const std::vector< std::vector<int> >& colinear1) const
+void QuadraticPolygon::updateLocOfEdgeFromCrudeDataArray2(const int *descBg, const int *descEnd, const std::vector<std::vector<int> >& intersectEdges,
+ const INTERP_KERNEL::QuadraticPolygon& pol1, const int *descBg1, const int *descEnd1,
+ const std::vector<std::vector<int> >& intersectEdges1, const std::vector< std::vector<int> >& colinear1) const
{
std::size_t nbOfSeg=std::distance(descBg,descEnd);
for(std::size_t i=0;i<nbOfSeg;i++)//loop over all edges of pol2
double xBaryBB, yBaryBB;
double fact=normalizeExt(&other, xBaryBB, yBaryBB);
//Locate 'this' relative to 'other'
- other.performLocatingOperationSlow(*this);
+ other.performLocatingOperationSlow(*this); // without any assumption
std::vector<QuadraticPolygon *> res=buildIntersectionPolygons(other,*this);
for(std::vector<QuadraticPolygon *>::iterator it=res.begin();it!=res.end();it++)
{
class Edge;
class MergePoints;
+ /**
+ * A set of quadratic or linear edges, not necessarily connected to form a closed polygon.
+ * Some methods however requires a closed form.
+ * Class ComposedEdge focuses more on connectivity aspect.
+ */
class QuadraticPolygon : public ComposedEdge
{
public:
int interpolateMeshes(const MyMeshType& meshS, const MyMeshType& meshT, MatrixType& result)
{ return asLeaf().interpolateMeshes(meshS,meshT,result); }
template<class MyMeshType, class MatrixType>
- int fromIntegralUniform(const MyMeshType& meshT, MatrixType& result, const char *method) { return fromToIntegralUniform(false,meshT,result,method); }
+ int fromIntegralUniform(const MyMeshType& meshT, MatrixType& result, const std::string& method) { return fromToIntegralUniform(false,meshT,result,method); }
template<class MyMeshType, class MatrixType>
- int toIntegralUniform(const MyMeshType& meshS, MatrixType& result, const char *method) { return fromToIntegralUniform(true,meshS,result,method); }
+ int toIntegralUniform(const MyMeshType& meshS, MatrixType& result, const std::string& method) { return fromToIntegralUniform(true,meshS,result,method); }
template<class MyMeshType>
static double CalculateCharacteristicSizeOfMeshes(const MyMeshType& myMeshS, const MyMeshType& myMeshT, const int printLevel);
protected:
template<class MyMeshType, class MatrixType>
- int fromToIntegralUniform(bool fromTo, const MyMeshType& mesh, MatrixType& result, const char *method);
+ int fromToIntegralUniform(bool fromTo, const MyMeshType& mesh, MatrixType& result, const std::string& method);
protected:
TrueMainInterpolator& asLeaf() { return static_cast<TrueMainInterpolator&>(*this); }
};
{
template<class TrueMainInterpolator>
template<class MyMeshType, class MatrixType>
- int Interpolation<TrueMainInterpolator>::fromToIntegralUniform(bool fromTo, const MyMeshType& mesh, MatrixType& result, const char *method)
+ int Interpolation<TrueMainInterpolator>::fromToIntegralUniform(bool fromTo, const MyMeshType& mesh, MatrixType& result, const std::string& method)
{
typedef typename MyMeshType::MyConnType ConnType;
- std::string methodCPP(method);
int ret=-1;
- if(methodCPP=="P0")
+ if(method=="P0")
{
IntegralUniformIntersectorP0<MyMeshType,MatrixType> intersector(mesh,InterpolationOptions::getMeasureAbsStatus());
intersector.setFromTo(fromTo);
intersector.intersectCells(0,tmp,result);
ret=intersector.getNumberOfColsOfResMatrix();
}
- else if(methodCPP=="P1")
+ else if(method=="P1")
{
IntegralUniformIntersectorP1<MyMeshType,MatrixType> intersector(mesh,InterpolationOptions::getMeasureAbsStatus());
intersector.setFromTo(fromTo);
// Main function to interpolate triangular and quadratic meshes
template<class MyMeshType, class MatrixType>
- int interpolateMeshes(const MyMeshType& meshS, const MyMeshType& meshT, MatrixType& result, const char *method);
+ int interpolateMeshes(const MyMeshType& meshS, const MyMeshType& meshT, MatrixType& result, const std::string& method);
DuplicateFacesType retrieveDuplicateFaces() const
{
return _duplicate_faces;
*
*/
template<class MyMeshType, class MatrixType>
- int Interpolation2D1D::interpolateMeshes(const MyMeshType& myMeshS, const MyMeshType& myMeshT, MatrixType& result, const char *method)
+ int Interpolation2D1D::interpolateMeshes(const MyMeshType& myMeshS, const MyMeshType& myMeshT, MatrixType& result, const std::string& method)
{
static const int SPACEDIM=MyMeshType::MY_SPACEDIM;
typedef typename MyMeshType::MyConnType ConnType;
Interpolation3D();
Interpolation3D(const InterpolationOptions& io);
template<class MyMeshType, class MatrixType>
- int interpolateMeshes(const MyMeshType& srcMesh, const MyMeshType& targetMesh, MatrixType& result, const char *method);
+ int interpolateMeshes(const MyMeshType& srcMesh, const MyMeshType& targetMesh, MatrixType& result, const std::string& method);
private:
SplittingPolicy _splitting_policy;
};
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// Author : Anthony Geay (CEA/DEN)
+
#ifndef __INTERPOLATION3D_TXX__
#define __INTERPOLATION3D_TXX__
*
*/
template<class MyMeshType, class MatrixType>
- int Interpolation3D::interpolateMeshes(const MyMeshType& srcMesh, const MyMeshType& targetMesh, MatrixType& result, const char *method)
+ int Interpolation3D::interpolateMeshes(const MyMeshType& srcMesh, const MyMeshType& targetMesh, MatrixType& result, const std::string& method)
{
typedef typename MyMeshType::MyConnType ConnType;
// create MeshElement objects corresponding to each element of the two meshes
int interpolateMeshes(const MyMeshType& srcMesh,
const MyMeshType& targetMesh,
MyMatrixType& matrix,
- const char *method);
+ const std::string& method);
INTERPKERNEL_EXPORT DuplicateFacesType retrieveDuplicateFaces() const { return _duplicate_faces; }
private:
SplittingPolicy _splitting_policy;
int Interpolation3D2D::interpolateMeshes(const MyMeshType& srcMesh,
const MyMeshType& targetMesh,
MyMatrixType& matrix,
- const char *method)
+ const std::string& method)
{
typedef typename MyMeshType::MyConnType ConnType;
// create MeshElement objects corresponding to each element of the two meshes
// Main function to interpolate
template<class MyMeshType, class MatrixType>
int interpolateMeshes(const MyMeshType& meshS, const MyMeshType& meshT,
- MatrixType& result, const char *method);
+ MatrixType& result, const std::string& method);
};
}
*/
template<class RealCurve>
template<class MyMeshType, class MatrixType>
- int InterpolationCurve<RealCurve>::interpolateMeshes (const MyMeshType& myMeshS,
- const MyMeshType& myMeshT,
- MatrixType& result,
- const char * method)
+ int InterpolationCurve<RealCurve>::interpolateMeshes (const MyMeshType& myMeshS,
+ const MyMeshType& myMeshT,
+ MatrixType& result,
+ const std::string& method)
{
static const int SPACEDIM=MyMeshType::MY_SPACEDIM;
typedef typename MyMeshType::MyConnType ConnType;
long nbMailleT = myMeshT.getNumberOfElements();
CurveIntersector<MyMeshType,MatrixType>* intersector=0;
- std::string meth(method);
- if(meth=="P0P0")
+ if(method=="P0P0")
{
intersector = new CurveIntersectorP0P0<MyMeshType,MatrixType>
(myMeshT, myMeshS,
InterpolationOptions::getMedianPlane(),
InterpolationOptions::getPrintLevel());
}
- else if(meth=="P0P1")
+ else if(method=="P0P1")
{
intersector = new CurveIntersectorP0P1<MyMeshType,MatrixType>
(myMeshT, myMeshS,
InterpolationOptions::getMedianPlane(),
InterpolationOptions::getPrintLevel());
}
- else if(meth=="P1P0")
+ else if(method=="P1P0")
{
intersector = new CurveIntersectorP1P0<MyMeshType,MatrixType>
(myMeshT, myMeshS,
InterpolationOptions::getMedianPlane(),
InterpolationOptions::getPrintLevel());
}
- else if(meth=="P1P1")
+ else if(method=="P1P1")
{
intersector = new CurveIntersectorP1P1<MyMeshType,MatrixType>
(myMeshT, myMeshS,
return oss.str();
}
-void INTERP_KERNEL::InterpolationOptions::CheckAndSplitInterpolationMethod(const char *method, std::string& srcMeth, std::string& trgMeth)
+void INTERP_KERNEL::InterpolationOptions::CheckAndSplitInterpolationMethod(const std::string& method, std::string& srcMeth, std::string& trgMeth)
{
const int NB_OF_METH_MANAGED=4;
const char *METH_MANAGED[NB_OF_METH_MANAGED]={"P0P0","P0P1","P1P0","P1P1"};
- std::string methodC(method);
bool found=false;
for(int i=0;i<NB_OF_METH_MANAGED && !found;i++)
- found=(methodC==METH_MANAGED[i]);
+ found=(method==METH_MANAGED[i]);
if(!found)
{
std::string msg("The interpolation method : \'"); msg+=method; msg+="\' not managed by INTERP_KERNEL interpolators ! Supported are \"P0P0\", \"P0P1\", \"P1P0\" and \"P1P1\".";
throw INTERP_KERNEL::Exception(msg.c_str());
}
- srcMeth=methodC.substr(0,2);
- trgMeth=methodC.substr(2);
+ srcMeth=method.substr(0,2);
+ trgMeth=method.substr(2);
}
bool setOptionString(const std::string& key, const std::string& value);
std::string printOptions() const;
public:
- static void CheckAndSplitInterpolationMethod(const char *method, std::string& srcMeth, std::string& trgMeth);
+ static void CheckAndSplitInterpolationMethod(const std::string& method, std::string& srcMeth, std::string& trgMeth);
private:
static const double DFT_MEDIAN_PLANE;
static const double DFT_SURF3D_ADJ_EPS;
// Main function to interpolate triangular and quadratic meshes
template<class MyMeshType, class MatrixType>
- int interpolateMeshes(const MyMeshType& meshS, const MyMeshType& meshT, MatrixType& result, const char *method);
+ int interpolateMeshes(const MyMeshType& meshS, const MyMeshType& meshT, MatrixType& result, const std::string& method);
public:
bool doRotate() const { return asLeafInterpPlanar().doRotate(); }
double medianPlane() const { return asLeafInterpPlanar().medianPlane(); }
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// Author : Anthony Geay (CEA/DEN)
+
#ifndef __INTERPOLATIONPLANAR_TXX__
#define __INTERPOLATIONPLANAR_TXX__
*/
template<class RealPlanar>
template<class MyMeshType, class MatrixType>
- int InterpolationPlanar<RealPlanar>::interpolateMeshes(const MyMeshType& myMeshS, const MyMeshType& myMeshT, MatrixType& result, const char *method)
+ int InterpolationPlanar<RealPlanar>::interpolateMeshes(const MyMeshType& myMeshS, const MyMeshType& myMeshT, MatrixType& result, const std::string& method)
{
static const int SPACEDIM=MyMeshType::MY_SPACEDIM;
typedef typename MyMeshType::MyConnType ConnType;
#include <algorithm>
#include <iostream>
#include <limits>
+#include <functional>
namespace INTERP_KERNEL
{
//
CPPUNIT_TEST( checkNormalize );
CPPUNIT_TEST( checkMakePartitionAbs1 );
+ //
+ CPPUNIT_TEST( checkIsInOrOut );
CPPUNIT_TEST_SUITE_END();
public:
void setUp();
//
void checkNormalize();
void checkMakePartitionAbs1();
+ // From Adrien:
+ void checkIsInOrOut();
+
private:
INTERP_KERNEL::QuadraticPolygon *buildQuadraticPolygonCoarseInfo(const double *coords, const int *conn, int lgth);
INTERP_KERNEL::EdgeArcCircle *buildArcOfCircle(const double *center, double radius, double alphaStart, double alphaEnd);
delete pol2;
}
+void QuadraticPlanarInterpTest::checkIsInOrOut()
+{
+ double coords[8]={ 0.30662641093707971, -0.47819928619088981,
+ -0.47819928619088964, 0.30662641093707987,
+ 0.0, 0.0,
+ 0.4, 0.4
+ };
+ coords[4] = (coords[0] + coords[2]) / 2.0;
+ coords[5] = (coords[1] + coords[3]) / 2.0;
+
+ int tab4[4]={ 0, 1, 2, 3};
+ QuadraticPolygon *pol1=buildQuadraticPolygonCoarseInfo(coords,tab4,4);
+ Node * n = new Node(0.3175267678416348, -0.4890996430954449);
+
+ CPPUNIT_ASSERT(! pol1->isInOrOut(n)); // node should be out
+ n->decrRef();
+ delete pol1;
+}
+
+
}
{
}
-MEDCoupling1GTUMesh::MEDCoupling1GTUMesh(const char *name, const INTERP_KERNEL::CellModel& cm):_cm(&cm)
+MEDCoupling1GTUMesh::MEDCoupling1GTUMesh(const std::string& name, const INTERP_KERNEL::CellModel& cm):_cm(&cm)
{
setName(name);
}
{
}
-MEDCoupling1GTUMesh *MEDCoupling1GTUMesh::New(const char *name, INTERP_KERNEL::NormalizedCellType type)
+MEDCoupling1GTUMesh *MEDCoupling1GTUMesh::New(const std::string& name, INTERP_KERNEL::NormalizedCellType type)
{
if(type==INTERP_KERNEL::NORM_ERROR)
throw INTERP_KERNEL::Exception("MEDCoupling1GTUMesh::New : NORM_ERROR is not a valid type to be used as base geometric type for a mesh !");
throw INTERP_KERNEL::Exception("MEDCoupling1GTUMesh::AggregateOnSameCoordsToUMesh : the first instance in input parts is null !");
const DataArrayDouble *coords(firstPart->getCoords());
int meshDim(firstPart->getMeshDimension());
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> ret(MEDCouplingUMesh::New(firstPart->getName().c_str(),meshDim)); ret->setDescription(firstPart->getDescription().c_str());
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> ret(MEDCouplingUMesh::New(firstPart->getName(),meshDim)); ret->setDescription(firstPart->getDescription());
ret->setCoords(coords);
int nbOfCells(0),connSize(0);
for(std::vector< const MEDCoupling1GTUMesh *>::const_iterator it=parts.begin();it!=parts.end();it++)
}
}
-MEDCoupling1SGTUMesh::MEDCoupling1SGTUMesh(const char *name, const INTERP_KERNEL::CellModel& cm):MEDCoupling1GTUMesh(name,cm)
+MEDCoupling1SGTUMesh::MEDCoupling1SGTUMesh(const std::string& name, const INTERP_KERNEL::CellModel& cm):MEDCoupling1GTUMesh(name,cm)
{
}
return new MEDCoupling1SGTUMesh;
}
-MEDCoupling1SGTUMesh *MEDCoupling1SGTUMesh::New(const char *name, INTERP_KERNEL::NormalizedCellType type)
+MEDCoupling1SGTUMesh *MEDCoupling1SGTUMesh::New(const std::string& name, INTERP_KERNEL::NormalizedCellType type)
{
if(type==INTERP_KERNEL::NORM_ERROR)
throw INTERP_KERNEL::Exception("MEDCoupling1SGTUMesh::New : NORM_ERROR is not a valid type to be used as base geometric type for a mesh !");
if(gts.size()!=1)
throw INTERP_KERNEL::Exception("MEDCoupling1SGTUMesh::New : input mesh must have exactly one geometric type !");
int geoType((int)*gts.begin());
- MEDCouplingAutoRefCountObjectPtr<MEDCoupling1SGTUMesh> ret(MEDCoupling1SGTUMesh::New(m->getName().c_str(),*gts.begin()));
- ret->setCoords(m->getCoords()); ret->setDescription(m->getDescription().c_str());
+ MEDCouplingAutoRefCountObjectPtr<MEDCoupling1SGTUMesh> ret(MEDCoupling1SGTUMesh::New(m->getName(),*gts.begin()));
+ ret->setCoords(m->getCoords()); ret->setDescription(m->getDescription());
int nbCells(m->getNumberOfCells());
int nbOfNodesPerCell(ret->getNumberOfNodesPerCell());
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> conn(DataArrayInt::New()); conn->alloc(nbCells*nbOfNodesPerCell,1);
MEDCouplingUMesh *MEDCoupling1SGTUMesh::buildUnstructured() const
{
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> ret=MEDCouplingUMesh::New(getName().c_str(),getMeshDimension());
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> ret=MEDCouplingUMesh::New(getName(),getMeshDimension());
ret->setCoords(getCoords());
const int *nodalConn=_conn->begin();
int nbCells=getNumberOfCells();
MEDCouplingPointSet *MEDCoupling1SGTUMesh::buildPartOfMySelfKeepCoords(const int *begin, const int *end) const
{
int ncell=getNumberOfCells();
- MEDCouplingAutoRefCountObjectPtr<MEDCoupling1SGTUMesh> ret(new MEDCoupling1SGTUMesh(getName().c_str(),*_cm));
+ MEDCouplingAutoRefCountObjectPtr<MEDCoupling1SGTUMesh> ret(new MEDCoupling1SGTUMesh(getName(),*_cm));
ret->setCoords(_coords);
std::size_t nbOfElemsRet=std::distance(begin,end);
const int *inConn=_conn->getConstPointer();
{
int ncell=getNumberOfCells();
int nbOfElemsRet=DataArray::GetNumberOfItemGivenBESRelative(start,end,step,"MEDCoupling1SGTUMesh::buildPartOfMySelfKeepCoords2 : ");
- MEDCouplingAutoRefCountObjectPtr<MEDCoupling1SGTUMesh> ret(new MEDCoupling1SGTUMesh(getName().c_str(),*_cm));
+ MEDCouplingAutoRefCountObjectPtr<MEDCoupling1SGTUMesh> ret(new MEDCoupling1SGTUMesh(getName(),*_cm));
ret->setCoords(_coords);
const int *inConn=_conn->getConstPointer();
int sz=getNumberOfNodesPerCell();
MEDCoupling1SGTUMesh *MEDCoupling1SGTUMesh::buildSetInstanceFromThis(int spaceDim) const
{
- MEDCouplingAutoRefCountObjectPtr<MEDCoupling1SGTUMesh> ret(new MEDCoupling1SGTUMesh(getName().c_str(),*_cm));
+ MEDCouplingAutoRefCountObjectPtr<MEDCoupling1SGTUMesh> ret(new MEDCoupling1SGTUMesh(getName(),*_cm));
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp1;
const DataArrayInt *nodalConn(_conn);
if(!nodalConn)
{
INTERP_KERNEL::NormalizedCellType gt((INTERP_KERNEL::NormalizedCellType)tinyInfo[0]);
_cm=&INTERP_KERNEL::CellModel::GetCellModel(gt);
- setName(littleStrings[0].c_str());
- setDescription(littleStrings[1].c_str());
- setTimeUnit(littleStrings[2].c_str());
+ setName(littleStrings[0]);
+ setDescription(littleStrings[1]);
+ setTimeUnit(littleStrings[2]);
setTime(tinyInfoD[0],tinyInfo[1],tinyInfo[2]);
int sz0(tinyInfo[3]),sz1(tinyInfo[4]),sz2(tinyInfo[5]),sz3(tinyInfo[6]);
//
throw INTERP_KERNEL::Exception("MEDCoupling1SGTUMesh::explodeEachHexa8To6Quad4 : this method can be applied only on HEXA8 mesh !");
int nbHexa8(getNumberOfCells());
const int *inConnPtr(getNodalConnectivity()->begin());
- MEDCouplingAutoRefCountObjectPtr<MEDCoupling1SGTUMesh> ret(MEDCoupling1SGTUMesh::New(getName().c_str(),INTERP_KERNEL::NORM_QUAD4));
+ MEDCouplingAutoRefCountObjectPtr<MEDCoupling1SGTUMesh> ret(MEDCoupling1SGTUMesh::New(getName(),INTERP_KERNEL::NORM_QUAD4));
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> c(DataArrayInt::New()); c->alloc(nbHexa8*6*4,1);
int *cPtr(c->getPointer());
for(int i=0;i<nbHexa8;i++,inConnPtr+=8)
std::vector<const DataArrayDouble *> v(4); v[0]=getCoords(); v[1]=facesBaryArr; v[2]=edgesBaryArr; v[3]=baryArr;
MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> zeArr(DataArrayDouble::Aggregate(v)); baryArr=0; edgesBaryArr=0; facesBaryArr=0;
std::string name("DualOf_"); name+=getName();
- MEDCouplingAutoRefCountObjectPtr<MEDCoupling1DGTUMesh> ret(MEDCoupling1DGTUMesh::New(name.c_str(),INTERP_KERNEL::NORM_POLYHED)); ret->setCoords(zeArr);
+ MEDCouplingAutoRefCountObjectPtr<MEDCoupling1DGTUMesh> ret(MEDCoupling1DGTUMesh::New(name,INTERP_KERNEL::NORM_POLYHED)); ret->setCoords(zeArr);
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cArr(DataArrayInt::New()),ciArr(DataArrayInt::New()); ciArr->alloc(nbOfNodes+1,1); ciArr->setIJ(0,0,0); cArr->alloc(0,1);
for(int i=0;i<nbOfNodes;i++,revNodI++)
{
std::vector<const DataArrayDouble *> v(3); v[0]=getCoords(); v[1]=edgesBaryArr; v[2]=baryArr;
MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> zeArr(DataArrayDouble::Aggregate(v)); baryArr=0; edgesBaryArr=0;
std::string name("DualOf_"); name+=getName();
- MEDCouplingAutoRefCountObjectPtr<MEDCoupling1DGTUMesh> ret(MEDCoupling1DGTUMesh::New(name.c_str(),INTERP_KERNEL::NORM_POLYGON)); ret->setCoords(zeArr);
+ MEDCouplingAutoRefCountObjectPtr<MEDCoupling1DGTUMesh> ret(MEDCoupling1DGTUMesh::New(name,INTERP_KERNEL::NORM_POLYGON)); ret->setCoords(zeArr);
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cArr(DataArrayInt::New()),ciArr(DataArrayInt::New()); ciArr->alloc(nbOfNodes+1,1); ciArr->setIJ(0,0,0); cArr->alloc(0,1);
for(int i=0;i<nbOfNodes;i++,revNodI++)
{
return new MEDCoupling1DGTUMesh;
}
-MEDCoupling1DGTUMesh *MEDCoupling1DGTUMesh::New(const char *name, INTERP_KERNEL::NormalizedCellType type)
+MEDCoupling1DGTUMesh *MEDCoupling1DGTUMesh::New(const std::string& name, INTERP_KERNEL::NormalizedCellType type)
{
if(type==INTERP_KERNEL::NORM_ERROR)
throw INTERP_KERNEL::Exception("MEDCoupling1DGTUMesh::New : NORM_ERROR is not a valid type to be used as base geometric type for a mesh !");
{
}
-MEDCoupling1DGTUMesh::MEDCoupling1DGTUMesh(const char *name, const INTERP_KERNEL::CellModel& cm):MEDCoupling1GTUMesh(name,cm)
+MEDCoupling1DGTUMesh::MEDCoupling1DGTUMesh(const std::string& name, const INTERP_KERNEL::CellModel& cm):MEDCoupling1GTUMesh(name,cm)
{
}
MEDCouplingUMesh *MEDCoupling1DGTUMesh::buildUnstructured() const
{
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> ret=MEDCouplingUMesh::New(getName().c_str(),getMeshDimension());
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> ret=MEDCouplingUMesh::New(getName(),getMeshDimension());
ret->setCoords(getCoords());
const int *nodalConn=_conn->begin(),*nodalConnI=_conn_indx->begin();
int nbCells=getNumberOfCells();//checkCoherency
MEDCouplingPointSet *MEDCoupling1DGTUMesh::buildPartOfMySelfKeepCoords(const int *begin, const int *end) const
{
checkCoherency();
- MEDCouplingAutoRefCountObjectPtr<MEDCoupling1DGTUMesh> ret(new MEDCoupling1DGTUMesh(getName().c_str(),*_cm));
+ MEDCouplingAutoRefCountObjectPtr<MEDCoupling1DGTUMesh> ret(new MEDCoupling1DGTUMesh(getName(),*_cm));
ret->setCoords(_coords);
DataArrayInt *c=0,*ci=0;
MEDCouplingUMesh::ExtractFromIndexedArrays(begin,end,_conn,_conn_indx,c,ci);
MEDCouplingPointSet *MEDCoupling1DGTUMesh::buildPartOfMySelfKeepCoords2(int start, int end, int step) const
{
checkCoherency();
- MEDCouplingAutoRefCountObjectPtr<MEDCoupling1DGTUMesh> ret(new MEDCoupling1DGTUMesh(getName().c_str(),*_cm));
+ MEDCouplingAutoRefCountObjectPtr<MEDCoupling1DGTUMesh> ret(new MEDCoupling1DGTUMesh(getName(),*_cm));
ret->setCoords(_coords);
DataArrayInt *c=0,*ci=0;
MEDCouplingUMesh::ExtractFromIndexedArrays2(start,end,step,_conn,_conn_indx,c,ci);
{
INTERP_KERNEL::NormalizedCellType gt((INTERP_KERNEL::NormalizedCellType)tinyInfo[0]);
_cm=&INTERP_KERNEL::CellModel::GetCellModel(gt);
- setName(littleStrings[0].c_str());
- setDescription(littleStrings[1].c_str());
- setTimeUnit(littleStrings[2].c_str());
+ setName(littleStrings[0]);
+ setDescription(littleStrings[1]);
+ setTimeUnit(littleStrings[2]);
setTime(tinyInfoD[0],tinyInfo[1],tinyInfo[2]);
int sz0(tinyInfo[3]),sz1(tinyInfo[4]),sz2(tinyInfo[5]),sz3(tinyInfo[6]),sz4(tinyInfo[7]),sz5(tinyInfo[8]);
//
*/
MEDCoupling1DGTUMesh *MEDCoupling1DGTUMesh::copyWithNodalConnectivityPacked(bool& isShallowCpyOfNodalConnn) const
{
- MEDCouplingAutoRefCountObjectPtr<MEDCoupling1DGTUMesh> ret(new MEDCoupling1DGTUMesh(getName().c_str(),*_cm));
+ MEDCouplingAutoRefCountObjectPtr<MEDCoupling1DGTUMesh> ret(new MEDCoupling1DGTUMesh(getName(),*_cm));
DataArrayInt *nc=0,*nci=0;
isShallowCpyOfNodalConnn=retrievePackedNodalConnectivity(nc,nci);
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ncs(nc),ncis(nci);
MEDCoupling1DGTUMesh *MEDCoupling1DGTUMesh::buildSetInstanceFromThis(int spaceDim) const
{
- MEDCouplingAutoRefCountObjectPtr<MEDCoupling1DGTUMesh> ret(new MEDCoupling1DGTUMesh(getName().c_str(),*_cm));
+ MEDCouplingAutoRefCountObjectPtr<MEDCoupling1DGTUMesh> ret(new MEDCoupling1DGTUMesh(getName(),*_cm));
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp1,tmp2;
const DataArrayInt *nodalConn(_conn),*nodalConnI(_conn_indx);
if(!nodalConn)
if(gts.size()!=1)
throw INTERP_KERNEL::Exception("MEDCoupling1DGTUMesh::New : input mesh must have exactly one geometric type !");
int geoType((int)*gts.begin());
- MEDCouplingAutoRefCountObjectPtr<MEDCoupling1DGTUMesh> ret(MEDCoupling1DGTUMesh::New(m->getName().c_str(),*gts.begin()));
- ret->setCoords(m->getCoords()); ret->setDescription(m->getDescription().c_str());
+ MEDCouplingAutoRefCountObjectPtr<MEDCoupling1DGTUMesh> ret(MEDCoupling1DGTUMesh::New(m->getName(),*gts.begin()));
+ ret->setCoords(m->getCoords()); ret->setDescription(m->getDescription());
int nbCells(m->getNumberOfCells());
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> conn(DataArrayInt::New()),connI(DataArrayInt::New());
conn->alloc(m->getMeshLength()-nbCells,1); connI->alloc(nbCells+1,1);
class MEDCoupling1GTUMesh : public MEDCouplingPointSet
{
public:
- MEDCOUPLING_EXPORT static MEDCoupling1GTUMesh *New(const char *name, INTERP_KERNEL::NormalizedCellType type);
+ MEDCOUPLING_EXPORT static MEDCoupling1GTUMesh *New(const std::string& name, INTERP_KERNEL::NormalizedCellType type);
MEDCOUPLING_EXPORT static MEDCoupling1GTUMesh *New(const MEDCouplingUMesh *m);
MEDCOUPLING_EXPORT const INTERP_KERNEL::CellModel& getCellModel() const;
MEDCOUPLING_EXPORT INTERP_KERNEL::NormalizedCellType getCellModelEnum() const;
MEDCOUPLING_EXPORT virtual DataArrayInt *getNodalConnectivity() const = 0;
MEDCOUPLING_EXPORT virtual void checkCoherencyOfConnectivity() const = 0;
protected:
- MEDCoupling1GTUMesh(const char *name, const INTERP_KERNEL::CellModel& cm);
+ MEDCoupling1GTUMesh(const std::string& name, const INTERP_KERNEL::CellModel& cm);
MEDCoupling1GTUMesh(const MEDCoupling1GTUMesh& other, bool recDeepCpy);
MEDCoupling1GTUMesh();
protected:
class MEDCoupling1SGTUMesh : public MEDCoupling1GTUMesh
{
public:
- MEDCOUPLING_EXPORT static MEDCoupling1SGTUMesh *New(const char *name, INTERP_KERNEL::NormalizedCellType type);
+ MEDCOUPLING_EXPORT static MEDCoupling1SGTUMesh *New(const std::string& name, INTERP_KERNEL::NormalizedCellType type);
MEDCOUPLING_EXPORT static MEDCoupling1SGTUMesh *New(const MEDCouplingUMesh *m);
//! useless constructor only for CORBA -> not swigged
MEDCOUPLING_EXPORT static MEDCoupling1SGTUMesh *New();
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);
private:
- MEDCoupling1SGTUMesh(const char *name, const INTERP_KERNEL::CellModel& cm);
+ MEDCoupling1SGTUMesh(const std::string& name, const INTERP_KERNEL::CellModel& cm);
MEDCoupling1SGTUMesh(const MEDCoupling1SGTUMesh& other, bool recDeepCpy);
MEDCoupling1SGTUMesh();
private:
class MEDCoupling1DGTUMesh : public MEDCoupling1GTUMesh
{
public:
- MEDCOUPLING_EXPORT static MEDCoupling1DGTUMesh *New(const char *name, INTERP_KERNEL::NormalizedCellType type);
+ MEDCOUPLING_EXPORT static MEDCoupling1DGTUMesh *New(const std::string& name, INTERP_KERNEL::NormalizedCellType type);
MEDCOUPLING_EXPORT static MEDCoupling1DGTUMesh *New(const MEDCouplingUMesh *m);
//! useless constructor only for CORBA -> not swigged
MEDCOUPLING_EXPORT static MEDCoupling1DGTUMesh *New();
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);
private:
- MEDCoupling1DGTUMesh(const char *name, const INTERP_KERNEL::CellModel& cm);
+ MEDCoupling1DGTUMesh(const std::string& name, const INTERP_KERNEL::CellModel& cm);
MEDCoupling1DGTUMesh(const MEDCoupling1DGTUMesh& other, bool recDeepCpy);
MEDCoupling1DGTUMesh();
private:
return new MEDCouplingCMesh;
}
-MEDCouplingCMesh *MEDCouplingCMesh::New(const char *meshName)
+MEDCouplingCMesh *MEDCouplingCMesh::New(const std::string& meshName)
{
MEDCouplingCMesh *ret=new MEDCouplingCMesh;
ret->setName(meshName);
const char msg0[]="Invalid ";
const char msg1[]=" array ! Must contain more than 1 element.";
const char msg2[]=" array ! Must be with only one component.";
+ getSpaceDimension();// here to check that no holes in arrays !
if(_x_array)
{
if(_x_array->getNbOfElems()<2)
void MEDCouplingCMesh::getSplitCellValues(int *res) const
{
- int spaceDim=getSpaceDimension();
- for(int l=0;l<spaceDim;l++)
+ int meshDim(getMeshDimension());
+ for(int l=0;l<meshDim;l++)
{
int val=1;
- for(int p=0;p<spaceDim-l-1;p++)
+ for(int p=0;p<meshDim-l-1;p++)
val*=getCoordsAt(p)->getNbOfElems()-1;
- res[spaceDim-l-1]=val;
+ res[meshDim-l-1]=val;
}
}
void MEDCouplingCMesh::getSplitNodeValues(int *res) const
{
- int spaceDim=getSpaceDimension();
+ int spaceDim(getSpaceDimension());
for(int l=0;l<spaceDim;l++)
{
int val=1;
void MEDCouplingCMesh::getNodeGridStructure(int *res) const
{
- int meshDim=getMeshDimension();
- for(int i=0;i<meshDim;i++)
+ int spaceDim(getSpaceDimension());
+ for(int i=0;i<spaceDim;i++)
res[i]=getCoordsAt(i)->getNbOfElems();
}
std::vector<int> MEDCouplingCMesh::getNodeGridStructure() const
{
- std::vector<int> ret(getMeshDimension());
+ std::vector<int> ret(getSpaceDimension());
getNodeGridStructure(&ret[0]);
return ret;
}
return ret.retn();
}
+/*!
+ * Return the space dimension of \a this. It only considers the arrays along X, Y and Z to deduce that.
+ * This method throws exceptions if the not null arrays defining this are not contiguouly at the end. For example X!=0,Y==0,Z!=0 will throw.
+ */
int MEDCouplingCMesh::getSpaceDimension() const
{
- int ret=0;
+ static const char MSG[]="MEDCouplingCMesh::getSpaceDimension : mesh is invalid ! null vectors (X, Y or Z) must be put contiguously at the end !";
+ int ret(0);
+ bool isOK(true);
if(_x_array)
ret++;
+ else
+ isOK=false;
if(_y_array)
- ret++;
+ {
+ if(!isOK)
+ throw INTERP_KERNEL::Exception(MSG);
+ ret++;
+ }
+ else
+ isOK=false;
if(_z_array)
- ret++;
+ {
+ if(!isOK)
+ throw INTERP_KERNEL::Exception(MSG);
+ ret++;
+ }
return ret;
}
+/*!
+ * This method returns the mesh dimension of \a this. It can be different from space dimension in case of a not null dimension contains only one node.
+ */
int MEDCouplingCMesh::getMeshDimension() const
{
- return getSpaceDimension();
+ int ret(getSpaceDimension());
+ if(_x_array)
+ {
+ if(_x_array->isAllocated())
+ if(_x_array->getNumberOfTuples()==1)
+ ret--;
+ }
+ if(_y_array)
+ {
+ if(_y_array->isAllocated())
+ if(_y_array->getNumberOfTuples()==1)
+ ret--;
+ }
+ if(_z_array)
+ {
+ if(_z_array->isAllocated())
+ if(_z_array->getNumberOfTuples()==1)
+ ret--;
+ }
+ return ret;
}
void MEDCouplingCMesh::getCoordinatesOfNode(int nodeId, std::vector<double>& coo) const
name+=getName();
int nbelem=getNumberOfCells();
MEDCouplingFieldDouble *field=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
- field->setName(name.c_str());
+ field->setName(name);
DataArrayDouble* array=DataArrayDouble::New();
array->alloc(nbelem,1);
double *area_vol=array->getPointer();
for(int j=0;j<spaceDim;j++)
{
tabsPtr[j]=tabs[j]->getConstPointer();
- ret->setInfoOnComponent(j,tabs[j]->getInfoOnComponent(0).c_str());
+ ret->setInfoOnComponent(j,tabs[j]->getInfoOnComponent(0));
}
int tmp2[3];
for(int i=0;i<nbNodes;i++)
for(int j=0;j<spaceDim;j++)
{
int sz=tabs[j]->getNbOfElems()-1;
- ret->setInfoOnComponent(j,tabs[j]->getInfoOnComponent(0).c_str());
+ ret->setInfoOnComponent(j,tabs[j]->getInfoOnComponent(0));
const double *srcPtr=tabs[j]->getConstPointer();
tabsPtr[j].insert(tabsPtr[j].end(),srcPtr,srcPtr+sz);
std::transform(tabsPtr[j].begin(),tabsPtr[j].end(),srcPtr+1,tabsPtr[j].begin(),std::plus<double>());
void MEDCouplingCMesh::unserialization(const std::vector<double>& tinyInfoD, const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2,
const std::vector<std::string>& littleStrings)
{
- setName(littleStrings[0].c_str());
- setDescription(littleStrings[1].c_str());
- setTimeUnit(littleStrings[2].c_str());
+ setName(littleStrings[0]);
+ setDescription(littleStrings[1]);
+ setTimeUnit(littleStrings[2]);
DataArrayDouble **thisArr[3]={&_x_array,&_y_array,&_z_array};
const double *data=a2->getConstPointer();
for(int i=0;i<3;i++)
{
(*(thisArr[i]))=DataArrayDouble::New();
(*(thisArr[i]))->alloc(tinyInfo[i],1);
- (*(thisArr[i]))->setInfoOnComponent(0,littleStrings[i+3].c_str());
+ (*(thisArr[i]))->setInfoOnComponent(0,littleStrings[i+3]);
std::copy(data,data+tinyInfo[i],(*(thisArr[i]))->getPointer());
data+=tinyInfo[i];
}
{
public:
MEDCOUPLING_EXPORT static MEDCouplingCMesh *New();
- MEDCOUPLING_EXPORT static MEDCouplingCMesh *New(const char *meshName);
+ MEDCOUPLING_EXPORT static MEDCouplingCMesh *New(const std::string& meshName);
MEDCOUPLING_EXPORT MEDCouplingMesh *deepCpy() const;
MEDCOUPLING_EXPORT MEDCouplingCMesh *clone(bool recDeepCpy) const;
MEDCOUPLING_EXPORT void updateTime() const;
return new MEDCouplingCurveLinearMesh;
}
-MEDCouplingCurveLinearMesh *MEDCouplingCurveLinearMesh::New(const char *meshName)
+MEDCouplingCurveLinearMesh *MEDCouplingCurveLinearMesh::New(const std::string& meshName)
{
MEDCouplingCurveLinearMesh *ret=new MEDCouplingCurveLinearMesh;
ret->setName(meshName);
int meshDim=getMeshDimension();
std::string name="MeasureOfMesh_"; name+=getName();
MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> field=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
- field->setName(name.c_str()); field->setMesh(const_cast<MEDCouplingCurveLinearMesh *>(this)); field->synchronizeTimeWithMesh();
+ field->setName(name); field->setMesh(const_cast<MEDCouplingCurveLinearMesh *>(this)); field->synchronizeTimeWithMesh();
switch(meshDim)
{
case 3:
void MEDCouplingCurveLinearMesh::unserialization(const std::vector<double>& tinyInfoD, const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2,
const std::vector<std::string>& littleStrings)
{
- setName(littleStrings[0].c_str());
- setDescription(littleStrings[1].c_str());
- setTimeUnit(littleStrings[2].c_str());
+ setName(littleStrings[0]);
+ setDescription(littleStrings[1]);
+ setTimeUnit(littleStrings[2]);
setTime(tinyInfoD[0],tinyInfo[0],tinyInfo[1]);
int sz=tinyInfo[2];
_structure.resize(sz);
{
public:
MEDCOUPLING_EXPORT static MEDCouplingCurveLinearMesh *New();
- MEDCOUPLING_EXPORT static MEDCouplingCurveLinearMesh *New(const char *meshName);
+ MEDCOUPLING_EXPORT static MEDCouplingCurveLinearMesh *New(const std::string& meshName);
MEDCOUPLING_EXPORT MEDCouplingMesh *deepCpy() const;
MEDCOUPLING_EXPORT MEDCouplingCurveLinearMesh *clone(bool recDeepCpy) const;
MEDCOUPLING_EXPORT void updateTime() const;
if(_mesh2D!=0)
_mesh2D->incrRef();
computeExtrusion(mesh3D);
- setName(mesh3D->getName().c_str());
+ setName(mesh3D->getName());
}
catch(INTERP_KERNEL::Exception& e)
{
MEDCouplingUMesh *ret=_mesh2D->buildExtrudedMesh(_mesh1D,0);
const int *renum=_mesh3D_ids->getConstPointer();
ret->renumberCells(renum,false);
- ret->setName(getName().c_str());
+ ret->setName(getName());
return ret;
}
retPtr[renum[i*nbOf2DCells+j]]=ret2DPtr[j]*ret1DPtr[i];
ret->setArray(da);
da->decrRef();
- ret->setName(name.c_str());
+ ret->setName(name);
ret2D->decrRef();
ret1D->decrRef();
return ret;
throw INTERP_KERNEL::Exception("MEDCouplingExtrudedMesh::computeIsoBarycenterOfNodesPerCell: not yet implemented !");
}
+void MEDCouplingExtrudedMesh::getReverseNodalConnectivity(DataArrayInt *revNodal, DataArrayInt *revNodalIndx) const
+{
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> m(buildUnstructured());
+ m->getReverseNodalConnectivity(revNodal,revNodalIndx);
+}
+
void MEDCouplingExtrudedMesh::computeExtrusionAlg(const MEDCouplingUMesh *mesh3D)
{
_mesh3D_ids->alloc(mesh3D->getNumberOfCells(),1);
void MEDCouplingExtrudedMesh::unserialization(const std::vector<double>& tinyInfoD, const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, const std::vector<std::string>& littleStrings)
{
- setName(littleStrings[littleStrings.size()-2].c_str());
- setDescription(littleStrings.back().c_str());
+ setName(littleStrings[littleStrings.size()-2]);
+ setDescription(littleStrings.back());
std::size_t sz=tinyInfo.size();
int sz1=tinyInfo[sz-2];
_cell_2D_id=tinyInfo[sz-3];
MEDCOUPLING_EXPORT DataArrayDouble *getCoordinatesAndOwner() const;
MEDCOUPLING_EXPORT DataArrayDouble *getBarycenterAndOwner() const;
MEDCOUPLING_EXPORT DataArrayDouble *computeIsoBarycenterOfNodesPerCell() const;
+ MEDCOUPLING_EXPORT void getReverseNodalConnectivity(DataArrayInt *revNodal, DataArrayInt *revNodalIndx) const;
//Serialization unserialisation
MEDCOUPLING_EXPORT void getTinySerializationInformation(std::vector<double>& tinyInfoD, std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const;
MEDCOUPLING_EXPORT void resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings) const;
{
if(other)
{
- setName(other->_name.c_str());
- setDescription(other->_desc.c_str());
+ setName(other->_name);
+ setDescription(other->_desc);
}
}
MEDCOUPLING_EXPORT virtual void copyTinyStringsFrom(const MEDCouplingField *other);
MEDCOUPLING_EXPORT void setMesh(const ParaMEDMEM::MEDCouplingMesh *mesh);
MEDCOUPLING_EXPORT const ParaMEDMEM::MEDCouplingMesh *getMesh() const { return _mesh; }
- MEDCOUPLING_EXPORT void setName(const char *name) { _name=name; }
+ MEDCOUPLING_EXPORT void setName(const std::string& name) { _name=name; }
MEDCOUPLING_EXPORT std::string getDescription() const { return _desc; }
- MEDCOUPLING_EXPORT void setDescription(const char *desc) { _desc=desc; }
+ MEDCOUPLING_EXPORT void setDescription(const std::string& desc) { _desc=desc; }
MEDCOUPLING_EXPORT std::string getName() const { return _name; }
MEDCOUPLING_EXPORT TypeOfField getTypeOfField() const;
MEDCOUPLING_EXPORT NatureOfField getNature() const;
// doc is here http://www.code-aster.org/V2/doc/default/fr/man_r/r3/r3.01.01.pdf
const double MEDCouplingFieldDiscretizationGaussNE::FGP_SEG2[2]={1.,1.};
-const double MEDCouplingFieldDiscretizationGaussNE::FGP_SEG3[3]={0.5555555555555556,0.5555555555555556,0.8888888888888888};
+const double MEDCouplingFieldDiscretizationGaussNE::FGP_SEG3[3]={0.5555555555555556,0.8888888888888888,0.5555555555555556};
const double MEDCouplingFieldDiscretizationGaussNE::FGP_SEG4[4]={0.347854845137454,0.347854845137454,0.652145154862546,0.652145154862546};
const double MEDCouplingFieldDiscretizationGaussNE::FGP_TRI3[3]={0.16666666666666666,0.16666666666666666,0.16666666666666666};
const double MEDCouplingFieldDiscretizationGaussNE::FGP_TRI6[6]={0.0549758718227661,0.0549758718227661,0.0549758718227661,0.11169079483905,0.11169079483905,0.11169079483905};
const double MEDCouplingFieldDiscretizationGaussNE::FGP_TRI7[7]={0.062969590272413,0.062969590272413,0.062969590272413,0.066197076394253,0.066197076394253,0.066197076394253,0.1125};
const double MEDCouplingFieldDiscretizationGaussNE::FGP_QUAD4[4]={1.,1.,1.,1.};
+const double MEDCouplingFieldDiscretizationGaussNE::FGP_QUAD8[8]={1.,1.,1.,1.,1.,1.,1.,1.};
const double MEDCouplingFieldDiscretizationGaussNE::FGP_QUAD9[9]={0.30864197530864196,0.30864197530864196,0.30864197530864196,0.30864197530864196,0.49382716049382713,0.49382716049382713,0.49382716049382713,0.49382716049382713,0.7901234567901234};
const double MEDCouplingFieldDiscretizationGaussNE::FGP_TETRA4[4]={0.041666666666666664,0.041666666666666664,0.041666666666666664,0.041666666666666664};
const double MEDCouplingFieldDiscretizationGaussNE::FGP_PENTA6[6]={0.16666666666666666,0.16666666666666666,0.16666666666666666,0.16666666666666666,0.16666666666666666,0.16666666666666666};
const double MEDCouplingFieldDiscretizationGaussNE::FGP_HEXA27[27]={0.1714677640603567,0.1714677640603567,0.1714677640603567,0.1714677640603567,0.1714677640603567,0.1714677640603567,0.1714677640603567,0.1714677640603567,0.27434842249657065,0.27434842249657065,0.27434842249657065,0.27434842249657065,0.27434842249657065,0.27434842249657065,0.27434842249657065,0.27434842249657065,0.27434842249657065,0.27434842249657065,0.27434842249657065,0.27434842249657065,0.43895747599451296,0.43895747599451296,0.43895747599451296,0.43895747599451296,0.43895747599451296,0.43895747599451296,0.7023319615912208};
const double MEDCouplingFieldDiscretizationGaussNE::FGP_PYRA5[5]={0.13333333333333333,0.13333333333333333,0.13333333333333333,0.13333333333333333,0.13333333333333333};
const double MEDCouplingFieldDiscretizationGaussNE::REF_SEG2[2]={-1.,1.};
-const double MEDCouplingFieldDiscretizationGaussNE::REF_SEG3[3]={-1.,0.,1.};
+const double MEDCouplingFieldDiscretizationGaussNE::REF_SEG3[3]={-1.,1.,0.};
const double MEDCouplingFieldDiscretizationGaussNE::REF_SEG4[4]={-1.,1.,-0.3333333333333333,0.3333333333333333};
const double MEDCouplingFieldDiscretizationGaussNE::REF_TRI3[6]={0.,0.,1.,0.,0.,1.};
const double MEDCouplingFieldDiscretizationGaussNE::REF_TRI6[12]={0.,0.,1.,0.,0.,1.,0.5,0.,0.5,0.5,0.,0.5};
const double MEDCouplingFieldDiscretizationGaussNE::REF_HEXA27[81]={-1.,-1.,-1.,1.,-1.,-1.,1.,1.,-1.,-1.,1.,-1.,-1.,-1.,1.,1.,-1.,1.,1.,1.,1.,-1.,1.,1.,0.,-1.,-1.,1.,0.,-1.,0.,1.,-1.,-1.,0.,-1.,-1.,-1.,0.,1.,-1.,0.,1.,1.,0.,-1.,1.,0.,0.,-1.,1.,1.,0.,1.,0.,1.,1.,-1.,0.,1.,0.,0.,-1.,0.,-1.,0.,1.,0.,0.,0.,1.,0.,-1.,0.,0.,0.,0.,1.,0.,0.,0.};
const double MEDCouplingFieldDiscretizationGaussNE::REF_PYRA5[15]={1.,0.,0.,0.,1.,0.,-1.,0.,0.,0.,-1.,0.,0.,0.,1.};
const double MEDCouplingFieldDiscretizationGaussNE::REF_PYRA13[39]={1.,0.,0.,0.,1.,0.,-1.,0.,0.,0.,-1.,0.,0.,0.,1.,0.5,0.5,0.,-0.5,0.5,0.,-0.5,-0.5,0.,0.5,-0.5,0.,0.5,0.,0.5,0.,0.5,0.5,-0.5,0.,0.5,0.,-0.5,0.5};
+const double MEDCouplingFieldDiscretizationGaussNE::LOC_SEG2[2]={0.577350269189626,-0.577350269189626};
+const double MEDCouplingFieldDiscretizationGaussNE::LOC_SEG3[3]={-0.774596669241,0.,0.774596669241};
+const double MEDCouplingFieldDiscretizationGaussNE::LOC_SEG4[4]={0.339981043584856,-0.339981043584856,0.861136311594053,-0.861136311594053};
+const double MEDCouplingFieldDiscretizationGaussNE::LOC_TRI3[6]={0.16666666666666667,0.16666666666666667,0.6666666666666667,0.16666666666666667,0.16666666666666667,0.6666666666666667};
+const double MEDCouplingFieldDiscretizationGaussNE::LOC_TRI6[12]={0.091576213509771,0.091576213509771,0.816847572980458,0.091576213509771,0.091576213509771,0.816847572980458,0.445948490915965,0.10810301816807,0.445948490915965,0.445948490915965,0.10810301816807,0.445948490915965};
+const double MEDCouplingFieldDiscretizationGaussNE::LOC_TRI7[14]={0.3333333333333333,0.3333333333333333,0.470142064105115,0.470142064105115,0.05971587178977,0.470142064105115,0.470142064105115,0.05971587178977,0.101286507323456,0.101286507323456,0.797426985353088,0.101286507323456,0.101286507323456,0.797426985353088};
+const double MEDCouplingFieldDiscretizationGaussNE::LOC_QUAD4[8]={-0.774596669241483,-0.774596669241483,0.774596669241483,-0.774596669241483,0.774596669241483,0.774596669241483,-0.774596669241483,0.774596669241483};
+const double MEDCouplingFieldDiscretizationGaussNE::LOC_QUAD8[16]={-0.774596669241483,-0.774596669241483,0.774596669241483,-0.774596669241483,0.774596669241483,0.774596669241483,-0.774596669241483,0.774596669241483,0.,-0.774596669241483,0.774596669241483,0.,0.,0.774596669241483,-0.774596669241483,0.};
+const double MEDCouplingFieldDiscretizationGaussNE::LOC_QUAD9[18]={-0.774596669241483,-0.774596669241483,0.774596669241483,-0.774596669241483,0.774596669241483,0.774596669241483,-0.774596669241483,0.774596669241483,0.,-0.774596669241483,0.774596669241483,0.,0.,0.774596669241483,-0.774596669241483,0.,0.,0.};
+const double MEDCouplingFieldDiscretizationGaussNE::LOC_TETRA4[12]={0.1381966011250105,0.1381966011250105,0.1381966011250105,0.1381966011250105,0.1381966011250105,0.5854101966249685,0.1381966011250105,0.5854101966249685,0.1381966011250105,0.5854101966249685,0.1381966011250105,0.1381966011250105};
+const double MEDCouplingFieldDiscretizationGaussNE::LOC_PENTA6[18]={-0.5773502691896258,0.5,0.5,-0.5773502691896258,0.,0.5,-0.5773502691896258,0.5,0.,0.5773502691896258,0.5,0.5,0.5773502691896258,0.,0.5,0.5773502691896258,0.5,0.};
+const double MEDCouplingFieldDiscretizationGaussNE::LOC_HEXA8[24]={-0.5773502691896258,-0.5773502691896258,-0.5773502691896258,-0.5773502691896258,-0.5773502691896258,0.5773502691896258,-0.5773502691896258,0.5773502691896258,-0.5773502691896258,-0.5773502691896258,0.5773502691896258,0.5773502691896258,0.5773502691896258,-0.5773502691896258,-0.5773502691896258,0.5773502691896258,-0.5773502691896258,0.5773502691896258,0.5773502691896258,0.5773502691896258,-0.5773502691896258,0.5773502691896258,0.5773502691896258,0.5773502691896258};
+const double MEDCouplingFieldDiscretizationGaussNE::LOC_HEXA27[81]={-0.7745966692414834,-0.7745966692414834,-0.7745966692414834,-0.7745966692414834,-0.7745966692414834,0.,-0.7745966692414834,-0.7745966692414834,0.7745966692414834,-0.7745966692414834,0.,-0.7745966692414834,-0.7745966692414834,0.,0.,-0.7745966692414834,0.,0.7745966692414834,-0.7745966692414834,0.7745966692414834,-0.7745966692414834,-0.7745966692414834,0.7745966692414834,0.,-0.7745966692414834,0.7745966692414834,0.7745966692414834,0.,-0.7745966692414834,-0.7745966692414834,0,-0.7745966692414834,0.,0.,-0.7745966692414834,0.7745966692414834,0.,0.,-0.7745966692414834,0.,0.,0.,0.,0.,0.7745966692414834,0.,0.7745966692414834,-0.7745966692414834,0.,0.7745966692414834,0.,0.,0.7745966692414834,0.7745966692414834,0.7745966692414834,-0.7745966692414834,-0.7745966692414834,0.7745966692414834,-0.7745966692414834,0.,0.7745966692414834,-0.7745966692414834,0.7745966692414834,0.7745966692414834,0,-0.7745966692414834,0.7745966692414834,0.,0.,0.7745966692414834,0.,0.7745966692414834,0.7745966692414834,0.7745966692414834,-0.7745966692414834,0.7745966692414834,0.7745966692414834,0.,0.7745966692414834,0.7745966692414834,0.7745966692414834};
+const double MEDCouplingFieldDiscretizationGaussNE::LOC_PYRA5[15]={0.5,0.,0.1531754163448146,0.,0.5,0.1531754163448146,-0.5,0.,0.1531754163448146,0.,-0.5,0.1531754163448146,0.,0.,0.6372983346207416};
MEDCouplingFieldDiscretization::MEDCouplingFieldDiscretization():_precision(DFLT_PRECISION)
{
}
}
-TypeOfField MEDCouplingFieldDiscretization::GetTypeOfFieldFromStringRepr(const char *repr)
+TypeOfField MEDCouplingFieldDiscretization::GetTypeOfFieldFromStringRepr(const std::string& repr)
{
- std::string reprCpp(repr);
- if(reprCpp==MEDCouplingFieldDiscretizationP0::REPR)
+ if(repr==MEDCouplingFieldDiscretizationP0::REPR)
return MEDCouplingFieldDiscretizationP0::TYPE;
- if(reprCpp==MEDCouplingFieldDiscretizationP1::REPR)
+ if(repr==MEDCouplingFieldDiscretizationP1::REPR)
return MEDCouplingFieldDiscretizationP1::TYPE;
- if(reprCpp==MEDCouplingFieldDiscretizationGauss::REPR)
+ if(repr==MEDCouplingFieldDiscretizationGauss::REPR)
return MEDCouplingFieldDiscretizationGauss::TYPE;
- if(reprCpp==MEDCouplingFieldDiscretizationGaussNE::REPR)
+ if(repr==MEDCouplingFieldDiscretizationGaussNE::REPR)
return MEDCouplingFieldDiscretizationGaussNE::TYPE;
- if(reprCpp==MEDCouplingFieldDiscretizationKriging::REPR)
+ if(repr==MEDCouplingFieldDiscretizationKriging::REPR)
return MEDCouplingFieldDiscretizationKriging::TYPE;
throw INTERP_KERNEL::Exception("Representation does not match with any field discretization !");
}
throw INTERP_KERNEL::Exception("Invalid method for the corresponding field discretization : available only for GaussPoint discretization !");
}
-void MEDCouplingFieldDiscretization::RenumberEntitiesFromO2NArr(double eps, const int *old2NewPtr, int newNbOfEntity, DataArrayDouble *arr, const char *msg)
+void MEDCouplingFieldDiscretization::RenumberEntitiesFromO2NArr(double eps, const int *old2NewPtr, int newNbOfEntity, DataArrayDouble *arr, const std::string& msg)
{
if(!arr)
throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretization::RenumberEntitiesFromO2NArr : input array is NULL !");
}
}
-void MEDCouplingFieldDiscretization::RenumberEntitiesFromN2OArr(const int *new2OldPtr, int new2OldSz, DataArrayDouble *arr, const char *msg)
+void MEDCouplingFieldDiscretization::RenumberEntitiesFromN2OArr(const int *new2OldPtr, int new2OldSz, DataArrayDouble *arr, const std::string& msg)
{
int nbOfComp=arr->getNumberOfComponents();
MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arrCpy=arr->deepCpy();
case INTERP_KERNEL::NORM_QUAD4:
lgth=(int)sizeof(FGP_QUAD4)/sizeof(double);
return FGP_QUAD4;
+ case INTERP_KERNEL::NORM_QUAD8:
+ lgth=(int)sizeof(FGP_QUAD8)/sizeof(double);
+ return FGP_QUAD8;
case INTERP_KERNEL::NORM_QUAD9:
lgth=(int)sizeof(FGP_QUAD9)/sizeof(double);
return FGP_QUAD9;
}
}
+const double *MEDCouplingFieldDiscretizationGaussNE::GetLocsFromGeometricType(INTERP_KERNEL::NormalizedCellType geoType, std::size_t& lgth)
+{
+ switch(geoType)
+ {
+ case INTERP_KERNEL::NORM_SEG2:
+ {
+ lgth=(int)sizeof(LOC_SEG2)/sizeof(double);
+ return LOC_SEG2;
+ }
+ case INTERP_KERNEL::NORM_SEG3:
+ {
+ lgth=(int)sizeof(LOC_SEG3)/sizeof(double);
+ return LOC_SEG3;
+ }
+ case INTERP_KERNEL::NORM_SEG4:
+ {
+ lgth=(int)sizeof(LOC_SEG4)/sizeof(double);
+ return LOC_SEG4;
+ }
+ case INTERP_KERNEL::NORM_TRI3:
+ {
+ lgth=(int)sizeof(LOC_TRI3)/sizeof(double);
+ return LOC_TRI3;
+ }
+ case INTERP_KERNEL::NORM_TRI6:
+ {
+ lgth=(int)sizeof(LOC_TRI6)/sizeof(double);
+ return LOC_TRI6;
+ }
+ case INTERP_KERNEL::NORM_TRI7:
+ {
+ lgth=(int)sizeof(LOC_TRI7)/sizeof(double);
+ return LOC_TRI7;
+ }
+ case INTERP_KERNEL::NORM_QUAD4:
+ {
+ lgth=(int)sizeof(LOC_QUAD4)/sizeof(double);
+ return LOC_QUAD4;
+ }
+ case INTERP_KERNEL::NORM_QUAD8:
+ {
+ lgth=(int)sizeof(LOC_QUAD8)/sizeof(double);
+ return LOC_QUAD8;
+ }
+ case INTERP_KERNEL::NORM_QUAD9:
+ {
+ lgth=(int)sizeof(LOC_QUAD9)/sizeof(double);
+ return LOC_QUAD9;
+ }
+ case INTERP_KERNEL::NORM_TETRA4:
+ {
+ lgth=(int)sizeof(LOC_TETRA4)/sizeof(double);
+ return LOC_TETRA4;
+ }
+ case INTERP_KERNEL::NORM_PENTA6:
+ {
+ lgth=(int)sizeof(LOC_PENTA6)/sizeof(double);
+ return LOC_PENTA6;
+ }
+ case INTERP_KERNEL::NORM_HEXA8:
+ {
+ lgth=(int)sizeof(LOC_HEXA8)/sizeof(double);
+ return LOC_HEXA8;
+ }
+ case INTERP_KERNEL::NORM_HEXA27:
+ {
+ lgth=(int)sizeof(LOC_HEXA27)/sizeof(double);
+ return LOC_HEXA27;
+ }
+ case INTERP_KERNEL::NORM_PYRA5:
+ {
+ lgth=(int)sizeof(LOC_PYRA5)/sizeof(double);
+ return LOC_PYRA5;
+ }
+ default:
+ throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGaussNE::GetLocsFromGeometricType : only SEG[2,3,4], TRI[3,6,7], QUAD[4,8,9], TETRA[4,10], PENTA[6,15], HEXA[8,20,27], PYRA[5,13] supported !");
+ }
+}
+
void MEDCouplingFieldDiscretizationGaussNE::computeMeshRestrictionFromTupleIds(const MEDCouplingMesh *mesh, const int *tupleIdsBg, const int *tupleIdsEnd,
DataArrayInt *&cellRestriction, DataArrayInt *&trueTupleRestriction) const throw(INTERP_KERNEL::Exception)
{
MEDCOUPLING_EXPORT void updateTime() const;
MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
MEDCOUPLING_EXPORT std::vector<const BigMemoryObject *> getDirectChildren() const;
- MEDCOUPLING_EXPORT static TypeOfField GetTypeOfFieldFromStringRepr(const char *repr);
+ MEDCOUPLING_EXPORT static TypeOfField GetTypeOfFieldFromStringRepr(const std::string& repr);
MEDCOUPLING_EXPORT virtual TypeOfField getEnum() const = 0;
MEDCOUPLING_EXPORT virtual bool isEqual(const MEDCouplingFieldDiscretization *other, double eps) const;
MEDCOUPLING_EXPORT virtual bool isEqualIfNotWhy(const MEDCouplingFieldDiscretization *other, double eps, std::string& reason) const = 0;
MEDCOUPLING_EXPORT virtual ~MEDCouplingFieldDiscretization();
protected:
MEDCOUPLING_EXPORT MEDCouplingFieldDiscretization();
- MEDCOUPLING_EXPORT static void RenumberEntitiesFromO2NArr(double epsOnVals, const int *old2NewPtr, int newNbOfEntity, DataArrayDouble *arr, const char *msg);
- MEDCOUPLING_EXPORT static void RenumberEntitiesFromN2OArr(const int *new2OldPtr, int new2OldSz, DataArrayDouble *arr, const char *msg);
+ MEDCOUPLING_EXPORT static void RenumberEntitiesFromO2NArr(double epsOnVals, const int *old2NewPtr, int newNbOfEntity, DataArrayDouble *arr, const std::string& msg);
+ MEDCOUPLING_EXPORT static void RenumberEntitiesFromN2OArr(const int *new2OldPtr, int new2OldSz, DataArrayDouble *arr, const std::string& msg);
protected:
double _precision;
static const double DFLT_PRECISION;
MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const;
MEDCOUPLING_EXPORT static const double *GetWeightArrayFromGeometricType(INTERP_KERNEL::NormalizedCellType geoType, std::size_t& lgth);
MEDCOUPLING_EXPORT static const double *GetRefCoordsFromGeometricType(INTERP_KERNEL::NormalizedCellType geoType, std::size_t& lgth);
+ MEDCOUPLING_EXPORT static const double *GetLocsFromGeometricType(INTERP_KERNEL::NormalizedCellType geoType, std::size_t& lgth);
protected:
MEDCOUPLING_EXPORT MEDCouplingFieldDiscretizationGaussNE(const MEDCouplingFieldDiscretizationGaussNE& other);
public:
static const double FGP_TRI6[6];
static const double FGP_TRI7[7];
static const double FGP_QUAD4[4];
- //static const double FGP_QUAD8[8];
+ static const double FGP_QUAD8[8];
static const double FGP_QUAD9[9];
static const double FGP_TETRA4[4];
//static const double FGP_TETRA10[10];
static const double REF_HEXA27[81];
static const double REF_PYRA5[15];
static const double REF_PYRA13[39];
+ static const double LOC_SEG2[2];
+ static const double LOC_SEG3[3];
+ static const double LOC_SEG4[4];
+ static const double LOC_TRI3[6];
+ static const double LOC_TRI6[12];
+ static const double LOC_TRI7[14];
+ static const double LOC_QUAD4[8];
+ static const double LOC_QUAD8[16];
+ static const double LOC_QUAD9[18];
+ static const double LOC_TETRA4[12];
+ //static const double LOC_TETRA10[30];
+ static const double LOC_PENTA6[18];
+ //static const double LOC_PENTA15[45];
+ static const double LOC_HEXA8[24];
+ static const double LOC_HEXA27[81];
+ static const double LOC_PYRA5[15];
+ //static const double LOC_PYRA13[39];
};
class MEDCouplingFieldDiscretizationKriging : public MEDCouplingFieldDiscretizationOnNodes
* Sets a time \a unit of \a this field. For more info, see \ref MEDCouplingFirstSteps3.
* \param [in] unit \a unit (string) in which time is measured.
*/
-void MEDCouplingFieldDouble::setTimeUnit(const char *unit)
+void MEDCouplingFieldDouble::setTimeUnit(const std::string& unit)
{
_time_discr->setTimeUnit(unit);
}
* Returns a time unit of \a this field.
* \return a string describing units in which time is measured.
*/
-const char *MEDCouplingFieldDouble::getTimeUnit() const
+std::string MEDCouplingFieldDouble::getTimeUnit() const
{
return _time_discr->getTimeUnit();
}
disc=_type->clone();
MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(getNature(),tdo,disc.retn());
ret->setMesh(getMesh());
- ret->setName(getName().c_str());
- ret->setDescription(getDescription().c_str());
+ ret->setName(getName());
+ ret->setDescription(getDescription());
return ret.retn();
}
return ret.retn();
}
+/*!
+ * This method converts a field on cell (\a this) to a node field (returned field). The convertion is a \b non \b conservative remapping !
+ * This method is useful only for users that need a fast convertion from cell to node spatial discretization. The algorithm applied is simply to attach
+ * to each node the average of values on cell sharing this node. If \a this lies on a mesh having orphan nodes the values applied on them will be NaN (division by 0.).
+ *
+ * \return MEDCouplingFieldDouble* - a new instance of MEDCouplingFieldDouble. The
+ * caller is to delete this field using decrRef() as it is no more needed. The returned field will share the same mesh object object than those in \a this.
+ * \throw If \a this spatial discretization is empty or not ON_CELLS.
+ * \throw If \a this is not coherent (see MEDCouplingFieldDouble::checkCoherency).
+ *
+ * \warning This method is a \b non \b conservative method of remapping from cell spatial discretization to node spatial discretization.
+ * If a conservative method of interpolation is required ParaMEDMEM::MEDCouplingRemapper class should be used instead with "P0P1" method.
+ */
+MEDCouplingFieldDouble *MEDCouplingFieldDouble::cellToNodeDiscretization() const
+{
+ checkCoherency();
+ TypeOfField tf(getTypeOfField());
+ if(tf!=ON_CELLS)
+ throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::cellToNodeDiscretization : this field is expected to be on ON_CELLS !");
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret(clone(false));
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDiscretizationP1> nsp(new MEDCouplingFieldDiscretizationP1);
+ ret->setDiscretization(nsp);
+ const MEDCouplingMesh *m(getMesh());//m is non empty thanks to checkCoherency call
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> rn(DataArrayInt::New()),rni(DataArrayInt::New());
+ m->getReverseNodalConnectivity(rn,rni);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> rni2(rni->deltaShiftIndex());
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> rni3(rni2->convertToDblArr()); rni2=0;
+ std::vector<DataArrayDouble *> arrs(getArrays());
+ std::size_t sz(arrs.size());
+ std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > outArrsSafe(sz); std::vector<DataArrayDouble *> outArrs(sz);
+ for(std::size_t j=0;j<sz;j++)
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> tmp(arrs[j]->selectByTupleIdSafe(rn->begin(),rn->end()));
+ outArrsSafe[j]=(tmp->accumulatePerChunck(rni->begin(),rni->end())); tmp=0;
+ outArrsSafe[j]->divideEqual(rni3);
+ outArrsSafe[j]->copyStringInfoFrom(*arrs[j]);
+ outArrs[j]=outArrsSafe[j];
+ }
+ ret->setArrays(outArrs);
+ return ret.retn();
+}
+
/*!
* Copies tiny info (component names, name and description) from an \a other field to
* \a this one.
return ret.str();
}
-void MEDCouplingFieldDouble::writeVTK(const char *fileName, bool isBinary) const
+void MEDCouplingFieldDouble::writeVTK(const std::string& fileName, bool isBinary) const
{
std::vector<const MEDCouplingFieldDouble *> fs(1,this);
MEDCouplingFieldDouble::WriteVTK(fileName,fs,isBinary);
* \ref cpp_mcfielddouble_fillFromAnalytic "Here is a C++ example".<br>
* \ref py_mcfielddouble_fillFromAnalytic "Here is a Python example".
*/
-void MEDCouplingFieldDouble::fillFromAnalytic(int nbOfComp, const char *func)
+void MEDCouplingFieldDouble::fillFromAnalytic(int nbOfComp, const std::string& func)
{
if(!_mesh)
throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::fillFromAnalytic : no mesh defined !");
* The function is applied to coordinates of value location points. For example, if
* \a this field is on cells, the function is applied to cell barycenters.<br>
* This method differs from
- * \ref ParaMEDMEM::MEDCouplingFieldDouble::fillFromAnalytic(int nbOfComp, const char *func) "fillFromAnalytic()"
+ * \ref ParaMEDMEM::MEDCouplingFieldDouble::fillFromAnalytic(int nbOfComp, const std::string& func) "fillFromAnalytic()"
* by the way how variable
* names, used in the function, are associated with components of coordinates of field
* location points; here, a variable name corresponding to a component is retrieved from
* \ref cpp_mcfielddouble_fillFromAnalytic2 "Here is a C++ example".<br>
* \ref py_mcfielddouble_fillFromAnalytic2 "Here is a Python example".
*/
-void MEDCouplingFieldDouble::fillFromAnalytic2(int nbOfComp, const char *func)
+void MEDCouplingFieldDouble::fillFromAnalytic2(int nbOfComp, const std::string& func)
{
if(!_mesh)
throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::fillFromAnalytic2 : no mesh defined !");
* The function is applied to coordinates of value location points. For example, if
* \a this field is on cells, the function is applied to cell barycenters.<br>
* This method differs from
- * \ref ParaMEDMEM::MEDCouplingFieldDouble::fillFromAnalytic(int nbOfComp, const char *func) "fillFromAnalytic()"
+ * \ref ParaMEDMEM::MEDCouplingFieldDouble::fillFromAnalytic(int nbOfComp, const std::string& func) "fillFromAnalytic()"
* by the way how variable
* names, used in the function, are associated with components of coordinates of field
* location points; here, a component index of a variable is defined by a
* \ref cpp_mcfielddouble_fillFromAnalytic3 "Here is a C++ example".<br>
* \ref py_mcfielddouble_fillFromAnalytic3 "Here is a Python example".
*/
-void MEDCouplingFieldDouble::fillFromAnalytic3(int nbOfComp, const std::vector<std::string>& varsOrder, const char *func)
+void MEDCouplingFieldDouble::fillFromAnalytic3(int nbOfComp, const std::vector<std::string>& varsOrder, const std::string& func)
{
if(!_mesh)
throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::fillFromAnalytic2 : no mesh defined !");
* \ref cpp_mcfielddouble_applyFunc "Here is a C++ example".<br>
* \ref py_mcfielddouble_applyFunc "Here is a Python example".
*/
-void MEDCouplingFieldDouble::applyFunc(int nbOfComp, const char *func)
+void MEDCouplingFieldDouble::applyFunc(int nbOfComp, const std::string& func)
{
_time_discr->applyFunc(nbOfComp,func);
}
* For more info on supported expressions that can be used in the function, see \ref
* MEDCouplingArrayApplyFuncExpr. <br>
* This method differs from
- * \ref ParaMEDMEM::MEDCouplingFieldDouble::applyFunc(int nbOfComp, const char *func) "applyFunc()"
+ * \ref ParaMEDMEM::MEDCouplingFieldDouble::applyFunc(int nbOfComp, const std::string& func) "applyFunc()"
* by the way how variable
* names, used in the function, are associated with components of field values;
* here, a variable name corresponding to a component is retrieved from
* \ref cpp_mcfielddouble_applyFunc2 "Here is a C++ example".<br>
* \ref py_mcfielddouble_applyFunc2 "Here is a Python example".
*/
-void MEDCouplingFieldDouble::applyFunc2(int nbOfComp, const char *func)
+void MEDCouplingFieldDouble::applyFunc2(int nbOfComp, const std::string& func)
{
_time_discr->applyFunc2(nbOfComp,func);
}
* Modifies values of \a this field by applying a function to each tuple of all
* data arrays.
* This method differs from
- * \ref ParaMEDMEM::MEDCouplingFieldDouble::applyFunc(int nbOfComp, const char *func) "applyFunc()"
+ * \ref ParaMEDMEM::MEDCouplingFieldDouble::applyFunc(int nbOfComp, const std::string& func) "applyFunc()"
* by the way how variable
* names, used in the function, are associated with components of field values;
* here, a component index of a variable is defined by a
* \ref cpp_mcfielddouble_applyFunc3 "Here is a C++ example".<br>
* \ref py_mcfielddouble_applyFunc3 "Here is a Python example".
*/
-void MEDCouplingFieldDouble::applyFunc3(int nbOfComp, const std::vector<std::string>& varsOrder, const char *func)
+void MEDCouplingFieldDouble::applyFunc3(int nbOfComp, const std::vector<std::string>& varsOrder, const std::string& func)
{
_time_discr->applyFunc3(nbOfComp,varsOrder,func);
}
* \ref cpp_mcfielddouble_applyFunc_same_nb_comp "Here is a C++ example".<br>
* \ref py_mcfielddouble_applyFunc_same_nb_comp "Here is a Python example".
*/
-void MEDCouplingFieldDouble::applyFunc(const char *func)
+void MEDCouplingFieldDouble::applyFunc(const std::string& func)
{
_time_discr->applyFunc(func);
}
* The field will contain exactly the same number of components after the call.
* Use is not warranted for the moment !
*/
-void MEDCouplingFieldDouble::applyFuncFast32(const char *func)
+void MEDCouplingFieldDouble::applyFuncFast32(const std::string& func)
{
_time_discr->applyFuncFast32(func);
}
* The field will contain exactly the same number of components after the call.
* Use is not warranted for the moment !
*/
-void MEDCouplingFieldDouble::applyFuncFast64(const char *func)
+void MEDCouplingFieldDouble::applyFuncFast64(const std::string& func)
{
_time_discr->applyFuncFast64(func);
}
double val=_mesh->getTime(it,ordr);
std::string timeUnit(_mesh->getTimeUnit());
setTime(val,it,ordr);
- setTimeUnit(timeUnit.c_str());
+ setTimeUnit(timeUnit);
}
/*!
int nbOfElemS=(int)tinyInfoS.size();
_name=tinyInfoS[nbOfElemS-3];
_desc=tinyInfoS[nbOfElemS-2];
- setTimeUnit(tinyInfoS[nbOfElemS-1].c_str());
+ setTimeUnit(tinyInfoS[nbOfElemS-1]);
}
/*!
MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone());
std::ostringstream oss;
oss << "Max_" << getName();
- ret->setName(oss.str().c_str());
+ ret->setName(oss.str());
ret->setMesh(getMesh());
return ret.retn();
}
MEDCouplingTimeDiscretization *td=_time_discr->keepSelectedComponents(compoIds);
td->copyTinyAttrFrom(*_time_discr);
MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone());
- ret->setName(getName().c_str());
+ ret->setName(getName());
ret->setMesh(getMesh());
return ret.retn();
}
MEDCouplingTimeDiscretization *td=f1->_time_discr->aggregate(f2->_time_discr);
td->copyTinyAttrFrom(*f1->_time_discr);
MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone());
- ret->setName(f1->getName().c_str());
- ret->setDescription(f1->getDescription().c_str());
+ ret->setName(f1->getName());
+ ret->setDescription(f1->getDescription());
if(m1)
{
MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=m1->mergeMyselfWith(m2);
MEDCouplingTimeDiscretization *td=tds[0]->aggregate(tds);
td->copyTinyAttrFrom(*(a[0]->_time_discr));
MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=new MEDCouplingFieldDouble(a[0]->getNature(),td,a[0]->_type->clone());
- ret->setName(a[0]->getName().c_str());
- ret->setDescription(a[0]->getDescription().c_str());
+ ret->setName(a[0]->getName());
+ ret->setDescription(a[0]->getDescription());
if(ms2[0])
{
MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> m=MEDCouplingUMesh::MergeUMeshes(ms2);
* \ref cpp_mcfielddouble_WriteVTK "Here is a C++ example".<br>
* \ref py_mcfielddouble_WriteVTK "Here is a Python example".
*/
-void MEDCouplingFieldDouble::WriteVTK(const char *fileName, const std::vector<const MEDCouplingFieldDouble *>& fs, bool isBinary)
+void MEDCouplingFieldDouble::WriteVTK(const std::string& fileName, const std::vector<const MEDCouplingFieldDouble *>& fs, bool isBinary)
{
if(fs.empty())
return;
}
TypeOfField typ=cur->getTypeOfField();
if(typ==ON_CELLS)
- cur->getArray()->writeVTK(coss,8,cur->getName().c_str(),byteArr);
+ cur->getArray()->writeVTK(coss,8,cur->getName(),byteArr);
else if(typ==ON_NODES)
- cur->getArray()->writeVTK(noss,8,cur->getName().c_str(),byteArr);
+ cur->getArray()->writeVTK(noss,8,cur->getName(),byteArr);
else
throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::WriteVTK : only node and cell fields supported for the moment !");
}
public:
MEDCOUPLING_EXPORT static MEDCouplingFieldDouble *New(TypeOfField type, TypeOfTimeDiscretization td=ONE_TIME);
MEDCOUPLING_EXPORT static MEDCouplingFieldDouble *New(const MEDCouplingFieldTemplate& ft, TypeOfTimeDiscretization td=ONE_TIME);
- MEDCOUPLING_EXPORT void setTimeUnit(const char *unit);
- MEDCOUPLING_EXPORT const char *getTimeUnit() const;
+ MEDCOUPLING_EXPORT void setTimeUnit(const std::string& unit);
+ MEDCOUPLING_EXPORT std::string getTimeUnit() const;
MEDCOUPLING_EXPORT void synchronizeTimeWithSupport();
MEDCOUPLING_EXPORT void copyTinyStringsFrom(const MEDCouplingField *other);
MEDCOUPLING_EXPORT void copyTinyAttrFrom(const MEDCouplingFieldDouble *other);
MEDCOUPLING_EXPORT void copyAllTinyAttrFrom(const MEDCouplingFieldDouble *other);
MEDCOUPLING_EXPORT std::string simpleRepr() const;
MEDCOUPLING_EXPORT std::string advancedRepr() const;
- MEDCOUPLING_EXPORT void writeVTK(const char *fileName, bool isBinary=true) const;
+ MEDCOUPLING_EXPORT void writeVTK(const std::string& fileName, bool isBinary=true) const;
MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingField *other, double meshPrec, double valsPrec, std::string& reason) const;
MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingField *other, double meshPrec, double valsPrec) const;
MEDCOUPLING_EXPORT bool areCompatibleForMerge(const MEDCouplingField *other) const;
MEDCOUPLING_EXPORT MEDCouplingFieldDouble *cloneWithMesh(bool recDeepCpy) const;
MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildNewTimeReprFromThis(TypeOfTimeDiscretization td, bool deepCopy) const;
MEDCOUPLING_EXPORT MEDCouplingFieldDouble *nodeToCellDiscretization() const;
+ MEDCOUPLING_EXPORT MEDCouplingFieldDouble *cellToNodeDiscretization() const;
MEDCOUPLING_EXPORT TypeOfTimeDiscretization getTimeDiscretization() const;
MEDCOUPLING_EXPORT void checkCoherency() const;
MEDCOUPLING_EXPORT void setNature(NatureOfField nat);
MEDCOUPLING_EXPORT void applyLin(double a, double b, int compoId);
MEDCOUPLING_EXPORT MEDCouplingFieldDouble &operator=(double value) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void fillFromAnalytic(int nbOfComp, FunctionToEvaluate func);
- MEDCOUPLING_EXPORT void fillFromAnalytic(int nbOfComp, const char *func);
- MEDCOUPLING_EXPORT void fillFromAnalytic2(int nbOfComp, const char *func);
- MEDCOUPLING_EXPORT void fillFromAnalytic3(int nbOfComp, const std::vector<std::string>& varsOrder, const char *func);
+ MEDCOUPLING_EXPORT void fillFromAnalytic(int nbOfComp, const std::string& func);
+ MEDCOUPLING_EXPORT void fillFromAnalytic2(int nbOfComp, const std::string& func);
+ MEDCOUPLING_EXPORT void fillFromAnalytic3(int nbOfComp, const std::vector<std::string>& varsOrder, const std::string& func);
MEDCOUPLING_EXPORT void applyFunc(int nbOfComp, FunctionToEvaluate func);
MEDCOUPLING_EXPORT void applyFunc(int nbOfComp, double val);
- MEDCOUPLING_EXPORT void applyFunc(int nbOfComp, const char *func);
- MEDCOUPLING_EXPORT void applyFunc2(int nbOfComp, const char *func);
- MEDCOUPLING_EXPORT void applyFunc3(int nbOfComp, const std::vector<std::string>& varsOrder, const char *func);
- MEDCOUPLING_EXPORT void applyFunc(const char *func);
- MEDCOUPLING_EXPORT void applyFuncFast32(const char *func);
- MEDCOUPLING_EXPORT void applyFuncFast64(const char *func);
+ MEDCOUPLING_EXPORT void applyFunc(int nbOfComp, const std::string& func);
+ MEDCOUPLING_EXPORT void applyFunc2(int nbOfComp, const std::string& func);
+ MEDCOUPLING_EXPORT void applyFunc3(int nbOfComp, const std::vector<std::string>& varsOrder, const std::string& func);
+ MEDCOUPLING_EXPORT void applyFunc(const std::string& func);
+ MEDCOUPLING_EXPORT void applyFuncFast32(const std::string& func);
+ MEDCOUPLING_EXPORT void applyFuncFast64(const std::string& func);
MEDCOUPLING_EXPORT int getNumberOfComponents() const;
MEDCOUPLING_EXPORT int getNumberOfTuples() const;
MEDCOUPLING_EXPORT int getNumberOfValues() const;
MEDCOUPLING_EXPORT MEDCouplingFieldDouble *operator^(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT const MEDCouplingFieldDouble &operator^=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT static MEDCouplingFieldDouble *PowFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2);
- MEDCOUPLING_EXPORT static void WriteVTK(const char *fileName, const std::vector<const MEDCouplingFieldDouble *>& fs, bool isBinary=true);
+ MEDCOUPLING_EXPORT static void WriteVTK(const std::string& fileName, const std::vector<const MEDCouplingFieldDouble *>& fs, bool isBinary=true);
public:
MEDCOUPLING_EXPORT const MEDCouplingTimeDiscretization *getTimeDiscretizationUnderGround() const { return _time_discr; }
MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *getTimeDiscretizationUnderGround() { return _time_discr; }
* See \ref MEDCouplingArrayBasicsName "DataArrays infos" for more information.
* \param [in] name - new array name
*/
-void DataArray::setName(const char *name)
+void DataArray::setName(const std::string& name)
{
_name=name;
}
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
for(std::size_t i=0;i<newNbOfCompo;i++)
- setInfoOnComponent((int)i,other.getInfoOnComponent(compoIds[i]).c_str());
+ setInfoOnComponent((int)i,other.getInfoOnComponent(compoIds[i]));
}
void DataArray::copyPartOfStringInfoFrom2(const std::vector<int>& compoIds, const DataArray& other)
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
for(std::size_t i=0;i<partOfCompoToSet;i++)
- setInfoOnComponent(compoIds[i],other.getInfoOnComponent((int)i).c_str());
+ setInfoOnComponent(compoIds[i],other.getInfoOnComponent((int)i));
}
bool DataArray::areInfoEqualsIfNotWhy(const DataArray& other, std::string& reason) const
stream << "\n";
}
-std::string DataArray::cppRepr(const char *varName) const
+std::string DataArray::cppRepr(const std::string& varName) const
{
std::ostringstream ret;
reprCppStream(varName,ret);
* \param [in] info - the string containing the information.
* \throw If \a i is not a valid component index.
*/
-void DataArray::setInfoOnComponent(int i, const char *info)
+void DataArray::setInfoOnComponent(int i, const std::string& info)
{
if(i<(int)_info_on_compo.size() && i>=0)
_info_on_compo[i]=info;
_info_on_compo=info;
}
-void DataArray::checkNbOfTuples(int nbOfTuples, const char *msg) const
+void DataArray::checkNbOfTuples(int nbOfTuples, const std::string& msg) const
{
if(getNumberOfTuples()!=nbOfTuples)
{
}
}
-void DataArray::checkNbOfComps(int nbOfCompo, const char *msg) const
+void DataArray::checkNbOfComps(int nbOfCompo, const std::string& msg) const
{
if(getNumberOfComponents()!=nbOfCompo)
{
}
}
-void DataArray::checkNbOfElems(std::size_t nbOfElems, const char *msg) const
+void DataArray::checkNbOfElems(std::size_t nbOfElems, const std::string& msg) const
{
if(getNbOfElems()!=nbOfElems)
{
}
}
-void DataArray::checkNbOfTuplesAndComp(const DataArray& other, const char *msg) const
+void DataArray::checkNbOfTuplesAndComp(const DataArray& other, const std::string& msg) const
{
if(getNumberOfTuples()!=other.getNumberOfTuples())
{
}
}
-void DataArray::checkNbOfTuplesAndComp(int nbOfTuples, int nbOfCompo, const char *msg) const
+void DataArray::checkNbOfTuplesAndComp(int nbOfTuples, int nbOfCompo, const std::string& msg) const
{
checkNbOfTuples(nbOfTuples,msg);
checkNbOfComps(nbOfCompo,msg);
/*!
* Simply this method checks that \b value is in [0,\b ref).
*/
-void DataArray::CheckValueInRange(int ref, int value, const char *msg)
+void DataArray::CheckValueInRange(int ref, int value, const std::string& msg)
{
if(value<0 || value>=ref)
{
* This method checks that [\b start, \b end) is compliant with ref length \b value.
* typicaly start in [0,\b value) and end in [0,\b value). If value==start and start==end, it is supported.
*/
-void DataArray::CheckValueInRangeEx(int value, int start, int end, const char *msg)
+void DataArray::CheckValueInRangeEx(int value, int start, int end, const std::string& msg)
{
if(start<0 || start>=value)
{
}
}
-void DataArray::CheckClosingParInRange(int ref, int value, const char *msg)
+void DataArray::CheckClosingParInRange(int ref, int value, const std::string& msg)
{
if(value<0 || value>ref)
{
stopSlice=stop;
}
-int DataArray::GetNumberOfItemGivenBES(int begin, int end, int step, const char *msg)
+int DataArray::GetNumberOfItemGivenBES(int begin, int end, int step, const std::string& msg)
{
if(end<begin)
{
return (end-1-begin)/step+1;
}
-int DataArray::GetNumberOfItemGivenBESRelative(int begin, int end, int step, const char *msg)
+int DataArray::GetNumberOfItemGivenBESRelative(int begin, int end, int step, const std::string& msg)
{
if(step==0)
throw INTERP_KERNEL::Exception("DataArray::GetNumberOfItemGivenBES : step=0 is not allowed !");
return ret.str();
}
-void DataArrayDouble::writeVTK(std::ostream& ofs, int indent, const char *nameInFile, DataArrayByte *byteArr) const
+void DataArrayDouble::writeVTK(std::ostream& ofs, int indent, const std::string& nameInFile, DataArrayByte *byteArr) const
{
static const char SPACE[4]={' ',' ',' ',' '};
checkAllocated();
_mem.reprZip(getNumberOfComponents(),stream);
}
-void DataArrayDouble::reprCppStream(const char *varName, std::ostream& stream) const
+void DataArrayDouble::reprCppStream(const std::string& varName, std::ostream& stream) const
{
int nbTuples=getNumberOfTuples(),nbComp=getNumberOfComponents();
const double *data=getConstPointer();
for(;j<newNbOfComp;j++)
nc[newNbOfComp*i+j]=dftValue;
}
- ret->setName(getName().c_str());
+ ret->setName(getName());
for(int i=0;i<dim;i++)
- ret->setInfoOnComponent(i,getInfoOnComponent(i).c_str());
- ret->setName(getName().c_str());
+ ret->setInfoOnComponent(i,getInfoOnComponent(i));
+ ret->setName(getName());
return ret.retn();
}
w[1]=wIn[0]*sin(wIn[1]);
w[2]=wIn[2];
}
- ret->setInfoOnComponent(2,getInfoOnComponent(2).c_str());
+ ret->setInfoOnComponent(2,getInfoOnComponent(2));
return ret;
}
* \throw If \a this is not allocated.
* \throw If computing \a func fails.
*/
-DataArrayDouble *DataArrayDouble::applyFunc(int nbOfComp, const char *func) const
+DataArrayDouble *DataArrayDouble::applyFunc(int nbOfComp, const std::string& func) const
{
checkAllocated();
INTERP_KERNEL::ExprParser expr(func);
* \throw If \a this is not allocated.
* \throw If computing \a func fails.
*/
-DataArrayDouble *DataArrayDouble::applyFunc(const char *func) const
+DataArrayDouble *DataArrayDouble::applyFunc(const std::string& func) const
{
checkAllocated();
INTERP_KERNEL::ExprParser expr(func);
* \throw If \a func contains vars that are not in \a this->getInfoOnComponent().
* \throw If computing \a func fails.
*/
-DataArrayDouble *DataArrayDouble::applyFunc2(int nbOfComp, const char *func) const
+DataArrayDouble *DataArrayDouble::applyFunc2(int nbOfComp, const std::string& func) const
{
checkAllocated();
INTERP_KERNEL::ExprParser expr(func);
* \throw If \a func contains vars not in \a varsOrder.
* \throw If computing \a func fails.
*/
-DataArrayDouble *DataArrayDouble::applyFunc3(int nbOfComp, const std::vector<std::string>& varsOrder, const char *func) const
+DataArrayDouble *DataArrayDouble::applyFunc3(int nbOfComp, const std::vector<std::string>& varsOrder, const std::string& func) const
{
checkAllocated();
INTERP_KERNEL::ExprParser expr(func);
return newArr;
}
-void DataArrayDouble::applyFuncFast32(const char *func)
+void DataArrayDouble::applyFuncFast32(const std::string& func)
{
checkAllocated();
INTERP_KERNEL::ExprParser expr(func);
declareAsNew();
}
-void DataArrayDouble::applyFuncFast64(const char *func)
+void DataArrayDouble::applyFuncFast64(const std::string& func)
{
checkAllocated();
INTERP_KERNEL::ExprParser expr(func);
int k=0;
for(int i=0;i<(int)a.size();i++)
for(int j=0;j<nbc[i];j++,k++)
- ret->setInfoOnComponent(k,a[i]->getInfoOnComponent(j).c_str());
+ ret->setInfoOnComponent(k,a[i]->getInfoOnComponent(j));
return ret;
}
sum+=a1Ptr[i*nbOfComp+j]*a2Ptr[i*nbOfComp+j];
retPtr[i]=sum;
}
- ret->setInfoOnComponent(0,a1->getInfoOnComponent(0).c_str());
- ret->setName(a1->getName().c_str());
+ ret->setInfoOnComponent(0,a1->getInfoOnComponent(0));
+ ret->setName(a1->getName());
return ret;
}
*/
void DataArrayDouble::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<std::string>& tinyInfoS)
{
- setName(tinyInfoS[0].c_str());
+ setName(tinyInfoS[0]);
if(isAllocated())
{
int nbOfCompo=getNumberOfComponents();
for(int i=0;i<nbOfCompo;i++)
- setInfoOnComponent(i,tinyInfoS[i+1].c_str());
+ setInfoOnComponent(i,tinyInfoS[i+1]);
}
}
return ret.str();
}
-void DataArrayInt::writeVTK(std::ostream& ofs, int indent, const char *type, const char *nameInFile, DataArrayByte *byteArr) const
+void DataArrayInt::writeVTK(std::ostream& ofs, int indent, const std::string& type, const std::string& nameInFile, DataArrayByte *byteArr) const
{
static const char SPACE[4]={' ',' ',' ',' '};
checkAllocated();
_mem.reprZip(getNumberOfComponents(),stream);
}
-void DataArrayInt::reprCppStream(const char *varName, std::ostream& stream) const
+void DataArrayInt::reprCppStream(const std::string& varName, std::ostream& stream) const
{
int nbTuples=getNumberOfTuples(),nbComp=getNumberOfComponents();
const int *data=getConstPointer();
for(;j<newNbOfComp;j++)
nc[newNbOfComp*i+j]=dftValue;
}
- ret->setName(getName().c_str());
+ ret->setName(getName());
for(int i=0;i<dim;i++)
- ret->setInfoOnComponent(i,getInfoOnComponent(i).c_str());
- ret->setName(getName().c_str());
+ ret->setInfoOnComponent(i,getInfoOnComponent(i));
+ ret->setName(getName());
return ret.retn();
}
int k=0;
for(int i=0;i<(int)a.size();i++)
for(int j=0;j<nbc[i];j++,k++)
- ret->setInfoOnComponent(k,a[i]->getInfoOnComponent(j).c_str());
+ ret->setInfoOnComponent(k,a[i]->getInfoOnComponent(j));
return ret;
}
*/
void DataArrayInt::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<std::string>& tinyInfoS)
{
- setName(tinyInfoS[0].c_str());
+ setName(tinyInfoS[0]);
if(isAllocated())
{
int nbOfCompo=tinyInfoI[1];
for(int i=0;i<nbOfCompo;i++)
- setInfoOnComponent(i,tinyInfoS[i+1].c_str());
+ setInfoOnComponent(i,tinyInfoS[i+1]);
}
}
public:
MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
MEDCOUPLING_EXPORT std::vector<const BigMemoryObject *> getDirectChildren() const;
- MEDCOUPLING_EXPORT void setName(const char *name);
+ MEDCOUPLING_EXPORT void setName(const std::string& name);
MEDCOUPLING_EXPORT void copyStringInfoFrom(const DataArray& other);
MEDCOUPLING_EXPORT void copyPartOfStringInfoFrom(const DataArray& other, const std::vector<int>& compoIds);
MEDCOUPLING_EXPORT void copyPartOfStringInfoFrom2(const std::vector<int>& compoIds, const DataArray& other);
MEDCOUPLING_EXPORT bool areInfoEqualsIfNotWhy(const DataArray& other, std::string& reason) const;
MEDCOUPLING_EXPORT bool areInfoEquals(const DataArray& other) const;
- MEDCOUPLING_EXPORT std::string cppRepr(const char *varName) const;
+ MEDCOUPLING_EXPORT std::string cppRepr(const std::string& varName) const;
MEDCOUPLING_EXPORT std::string getName() const { return _name; }
MEDCOUPLING_EXPORT const std::vector<std::string> &getInfoOnComponents() const { return _info_on_compo; }
MEDCOUPLING_EXPORT std::vector<std::string> &getInfoOnComponents() { return _info_on_compo; }
MEDCOUPLING_EXPORT std::string getInfoOnComponent(int i) const;
MEDCOUPLING_EXPORT std::string getVarOnComponent(int i) const;
MEDCOUPLING_EXPORT std::string getUnitOnComponent(int i) const;
- MEDCOUPLING_EXPORT void setInfoOnComponent(int i, const char *info);
+ MEDCOUPLING_EXPORT void setInfoOnComponent(int i, const std::string& info);
MEDCOUPLING_EXPORT int getNumberOfComponents() const { return (int)_info_on_compo.size(); }
MEDCOUPLING_EXPORT void setPartOfValuesBase3(const DataArray *aBase, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare=true);
MEDCOUPLING_EXPORT virtual DataArray *deepCpy() const = 0;
MEDCOUPLING_EXPORT virtual DataArray *selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const = 0;
MEDCOUPLING_EXPORT virtual DataArray *selectByTupleId2(int bg, int end2, int step) const = 0;
MEDCOUPLING_EXPORT virtual void rearrange(int newNbOfCompo) = 0;
- MEDCOUPLING_EXPORT void checkNbOfTuples(int nbOfTuples, const char *msg) const;
- MEDCOUPLING_EXPORT void checkNbOfComps(int nbOfCompo, const char *msg) const;
- MEDCOUPLING_EXPORT void checkNbOfTuplesAndComp(const DataArray& other, const char *msg) const;
- MEDCOUPLING_EXPORT void checkNbOfTuplesAndComp(int nbOfTuples, int nbOfCompo, const char *msg) const;
- MEDCOUPLING_EXPORT void checkNbOfElems(std::size_t nbOfElems, const char *msg) const;
+ MEDCOUPLING_EXPORT void checkNbOfTuples(int nbOfTuples, const std::string& msg) const;
+ MEDCOUPLING_EXPORT void checkNbOfComps(int nbOfCompo, const std::string& msg) const;
+ MEDCOUPLING_EXPORT void checkNbOfTuplesAndComp(const DataArray& other, const std::string& msg) const;
+ MEDCOUPLING_EXPORT void checkNbOfTuplesAndComp(int nbOfTuples, int nbOfCompo, const std::string& msg) const;
+ MEDCOUPLING_EXPORT void checkNbOfElems(std::size_t nbOfElems, const std::string& msg) const;
MEDCOUPLING_EXPORT static void GetSlice(int start, int stop, int step, int sliceId, int nbOfSlices, int& startSlice, int& stopSlice);
- MEDCOUPLING_EXPORT static int GetNumberOfItemGivenBES(int begin, int end, int step, const char *msg);
- MEDCOUPLING_EXPORT static int GetNumberOfItemGivenBESRelative(int begin, int end, int step, const char *msg);
+ MEDCOUPLING_EXPORT static int GetNumberOfItemGivenBES(int begin, int end, int step, const std::string& msg);
+ MEDCOUPLING_EXPORT static int GetNumberOfItemGivenBESRelative(int begin, int end, int step, const std::string& msg);
MEDCOUPLING_EXPORT static int GetPosOfItemGivenBESRelativeNoThrow(int value, int begin, int end, int step);
MEDCOUPLING_EXPORT static std::string GetVarNameFromInfo(const std::string& info);
MEDCOUPLING_EXPORT static std::string GetUnitFromInfo(const std::string& info);
MEDCOUPLING_EXPORT virtual void reprZipStream(std::ostream& stream) const = 0;
MEDCOUPLING_EXPORT virtual void reprWithoutNameStream(std::ostream& stream) const;
MEDCOUPLING_EXPORT virtual void reprZipWithoutNameStream(std::ostream& stream) const = 0;
- MEDCOUPLING_EXPORT virtual void reprCppStream(const char *varName, std::ostream& stream) const = 0;
+ MEDCOUPLING_EXPORT virtual void reprCppStream(const std::string& varName, std::ostream& stream) const = 0;
MEDCOUPLING_EXPORT virtual void reprQuickOverview(std::ostream& stream) const = 0;
MEDCOUPLING_EXPORT virtual void reprQuickOverviewData(std::ostream& stream, std::size_t maxNbOfByteInRepr) const = 0;
protected:
DataArray() { }
~DataArray() { }
protected:
- static void CheckValueInRange(int ref, int value, const char *msg);
- static void CheckValueInRangeEx(int value, int start, int end, const char *msg);
- static void CheckClosingParInRange(int ref, int value, const char *msg);
+ static void CheckValueInRange(int ref, int value, const std::string& msg);
+ static void CheckValueInRangeEx(int value, int start, int end, const std::string& msg);
+ static void CheckClosingParInRange(int ref, int value, const std::string& msg);
protected:
std::string _name;
std::vector<std::string> _info_on_compo;
MEDCOUPLING_EXPORT bool isMonotonic(bool increasing, double eps) const;
MEDCOUPLING_EXPORT std::string repr() const;
MEDCOUPLING_EXPORT std::string reprZip() const;
- MEDCOUPLING_EXPORT void writeVTK(std::ostream& ofs, int indent, const char *nameInFile, DataArrayByte *byteArr) const;
+ MEDCOUPLING_EXPORT void writeVTK(std::ostream& ofs, int indent, const std::string& nameInFile, DataArrayByte *byteArr) const;
MEDCOUPLING_EXPORT void reprStream(std::ostream& stream) const;
MEDCOUPLING_EXPORT void reprZipStream(std::ostream& stream) const;
MEDCOUPLING_EXPORT void reprWithoutNameStream(std::ostream& stream) const;
MEDCOUPLING_EXPORT void reprZipWithoutNameStream(std::ostream& stream) const;
- MEDCOUPLING_EXPORT void reprCppStream(const char *varName, std::ostream& stream) const;
+ MEDCOUPLING_EXPORT void reprCppStream(const std::string& varName, std::ostream& stream) const;
MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const;
MEDCOUPLING_EXPORT void reprQuickOverviewData(std::ostream& stream, std::size_t maxNbOfByteInRepr) const;
MEDCOUPLING_EXPORT bool isEqual(const DataArrayDouble& other, double prec) const;
MEDCOUPLING_EXPORT void applyRPow(double val);
MEDCOUPLING_EXPORT DataArrayDouble *negate() const;
MEDCOUPLING_EXPORT DataArrayDouble *applyFunc(int nbOfComp, FunctionToEvaluate func) const;
- MEDCOUPLING_EXPORT DataArrayDouble *applyFunc(int nbOfComp, const char *func) const;
- MEDCOUPLING_EXPORT DataArrayDouble *applyFunc(const char *func) const;
- MEDCOUPLING_EXPORT DataArrayDouble *applyFunc2(int nbOfComp, const char *func) const;
- MEDCOUPLING_EXPORT DataArrayDouble *applyFunc3(int nbOfComp, const std::vector<std::string>& varsOrder, const char *func) const;
- MEDCOUPLING_EXPORT void applyFuncFast32(const char *func);
- MEDCOUPLING_EXPORT void applyFuncFast64(const char *func);
+ MEDCOUPLING_EXPORT DataArrayDouble *applyFunc(int nbOfComp, const std::string& func) const;
+ MEDCOUPLING_EXPORT DataArrayDouble *applyFunc(const std::string& func) const;
+ MEDCOUPLING_EXPORT DataArrayDouble *applyFunc2(int nbOfComp, const std::string& func) const;
+ MEDCOUPLING_EXPORT DataArrayDouble *applyFunc3(int nbOfComp, const std::vector<std::string>& varsOrder, const std::string& func) const;
+ MEDCOUPLING_EXPORT void applyFuncFast32(const std::string& func);
+ MEDCOUPLING_EXPORT void applyFuncFast64(const std::string& func);
MEDCOUPLING_EXPORT DataArrayInt *getIdsInRange(double vmin, double vmax) const;
MEDCOUPLING_EXPORT DataArrayInt *getIdsNotInRange(double vmin, double vmax) const;
MEDCOUPLING_EXPORT static DataArrayDouble *Aggregate(const DataArrayDouble *a1, const DataArrayDouble *a2);
MEDCOUPLING_EXPORT void iota(int init=0);
MEDCOUPLING_EXPORT std::string repr() const;
MEDCOUPLING_EXPORT std::string reprZip() const;
- MEDCOUPLING_EXPORT void writeVTK(std::ostream& ofs, int indent, const char *type, const char *nameInFile, DataArrayByte *byteArr) const;
+ MEDCOUPLING_EXPORT void writeVTK(std::ostream& ofs, int indent, const std::string& type, const std::string& nameInFile, DataArrayByte *byteArr) const;
MEDCOUPLING_EXPORT void reprStream(std::ostream& stream) const;
MEDCOUPLING_EXPORT void reprZipStream(std::ostream& stream) const;
MEDCOUPLING_EXPORT void reprWithoutNameStream(std::ostream& stream) const;
MEDCOUPLING_EXPORT void reprZipWithoutNameStream(std::ostream& stream) const;
- MEDCOUPLING_EXPORT void reprCppStream(const char *varName, std::ostream& stream) const;
+ MEDCOUPLING_EXPORT void reprCppStream(const std::string& varName, std::ostream& stream) const;
MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const;
MEDCOUPLING_EXPORT void reprQuickOverviewData(std::ostream& stream, std::size_t maxNbOfByteInRepr) const;
MEDCOUPLING_EXPORT void transformWithIndArr(const int *indArrBg, const int *indArrEnd);
MEDCOUPLING_EXPORT void reprZipStream(std::ostream& stream) const;
MEDCOUPLING_EXPORT void reprWithoutNameStream(std::ostream& stream) const;
MEDCOUPLING_EXPORT void reprZipWithoutNameStream(std::ostream& stream) const;
- MEDCOUPLING_EXPORT void reprCppStream(const char *varName, std::ostream& stream) const;
+ MEDCOUPLING_EXPORT void reprCppStream(const std::string& varName, std::ostream& stream) const;
MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const;
MEDCOUPLING_EXPORT void reprQuickOverviewData(std::ostream& stream, std::size_t maxNbOfByteInRepr) const;
MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const DataArrayChar& other, std::string& reason) const;
MEDCOUPLING_EXPORT void reprZipStream(std::ostream& stream) const;
MEDCOUPLING_EXPORT void reprWithoutNameStream(std::ostream& stream) const;
MEDCOUPLING_EXPORT void reprZipWithoutNameStream(std::ostream& stream) const;
- MEDCOUPLING_EXPORT void reprCppStream(const char *varName, std::ostream& stream) const;
+ MEDCOUPLING_EXPORT void reprCppStream(const std::string& varName, std::ostream& stream) const;
MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const;
MEDCOUPLING_EXPORT void reprQuickOverviewData(std::ostream& stream, std::size_t maxNbOfByteInRepr) const;
MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const DataArrayChar& other, std::string& reason) const;
for(;j<newNbOfComp;j++)
nc[newNbOfComp*i+j]=dftValue;
}
- ret->setName(getName().c_str());
+ ret->setName(getName());
for(int i=0;i<dim;i++)
- ret->setInfoOnComponent(i,getInfoOnComponent(i).c_str());
- ret->setName(getName().c_str());
+ ret->setInfoOnComponent(i,getInfoOnComponent(i));
+ ret->setName(getName());
return ret.retn();
}
int k=0;
for(int i=0;i<(int)a.size();i++)
for(int j=0;j<nbc[i];j++,k++)
- ret->setInfoOnComponent(k,a[i]->getInfoOnComponent(j).c_str());
+ ret->setInfoOnComponent(k,a[i]->getInfoOnComponent(j));
return ret;
}
_mem.reprZip(getNumberOfComponents(),stream);
}
-void DataArrayByte::reprCppStream(const char *varName, std::ostream& stream) const
+void DataArrayByte::reprCppStream(const std::string& varName, std::ostream& stream) const
{
int nbTuples=getNumberOfTuples(),nbComp=getNumberOfComponents();
const char *data=getConstPointer();
reprWithoutNameStream(stream);
}
-void DataArrayAsciiChar::reprCppStream(const char *varName, std::ostream& stream) const
+void DataArrayAsciiChar::reprCppStream(const std::string& varName, std::ostream& stream) const
{
int nbTuples=getNumberOfTuples(),nbComp=getNumberOfComponents();
const char *data=getConstPointer();
* \ref cpp_mcmesh_fillFromAnalytic "Here is a C++ example".<br>
* \ref py_mcmesh_fillFromAnalytic "Here is a Python example".
*/
-MEDCouplingFieldDouble *MEDCouplingMesh::fillFromAnalytic(TypeOfField t, int nbOfComp, const char *func) const
+MEDCouplingFieldDouble *MEDCouplingMesh::fillFromAnalytic(TypeOfField t, int nbOfComp, const std::string& func) const
{
MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(t,ONE_TIME);
ret->setMesh(this);
* function to coordinates of field location points (defined by the given field type).
* For example, if \a t == ParaMEDMEM::ON_CELLS, the function is applied to cell
* barycenters. This method differs from
- * \ref MEDCouplingMesh::fillFromAnalytic(TypeOfField t, int nbOfComp, const char *func) const "fillFromAnalytic()"
+ * \ref MEDCouplingMesh::fillFromAnalytic(TypeOfField t, int nbOfComp, const std::string& func) const "fillFromAnalytic()"
* by the way how variable
* names, used in the function, are associated with components of coordinates of field
* location points; here, a variable name corresponding to a component is retrieved from
* \ref cpp_mcmesh_fillFromAnalytic2 "Here is a C++ example".<br>
* \ref py_mcmesh_fillFromAnalytic2 "Here is a Python example".
*/
-MEDCouplingFieldDouble *MEDCouplingMesh::fillFromAnalytic2(TypeOfField t, int nbOfComp, const char *func) const
+MEDCouplingFieldDouble *MEDCouplingMesh::fillFromAnalytic2(TypeOfField t, int nbOfComp, const std::string& func) const
{
MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(t,ONE_TIME);
ret->setMesh(this);
* \ref cpp_mcmesh_fillFromAnalytic3 "Here is a C++ example".<br>
* \ref py_mcmesh_fillFromAnalytic3 "Here is a Python example".
*/
-MEDCouplingFieldDouble *MEDCouplingMesh::fillFromAnalytic3(TypeOfField t, int nbOfComp, const std::vector<std::string>& varsOrder, const char *func) const
+MEDCouplingFieldDouble *MEDCouplingMesh::fillFromAnalytic3(TypeOfField t, int nbOfComp, const std::vector<std::string>& varsOrder, const std::string& func) const
{
MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(t,ONE_TIME);
ret->setMesh(this);
* \param [in] fileName - the name of the file to write in.
* \throw If \a fileName is not a writable file.
*/
-void MEDCouplingMesh::writeVTK(const char *fileName, bool isBinary) const
+void MEDCouplingMesh::writeVTK(const std::string& fileName, bool isBinary) const
{
std::string cda,pda;
MEDCouplingAutoRefCountObjectPtr<DataArrayByte> byteArr;
writeVTKAdvanced(fileName,cda,pda,byteArr);
}
-void MEDCouplingMesh::writeVTKAdvanced(const char *fileName, const std::string& cda, const std::string& pda, DataArrayByte *byteData) const
+void MEDCouplingMesh::writeVTKAdvanced(const std::string& fileName, const std::string& cda, const std::string& pda, DataArrayByte *byteData) const
{
- std::ofstream ofs(fileName);
+ std::ofstream ofs(fileName.c_str());
ofs << "<VTKFile type=\"" << getVTKDataSetType() << "\" version=\"0.1\" byte_order=\"" << MEDCouplingByteOrderStr() << "\">\n";
writeVTKLL(ofs,cda,pda,byteData);
if(byteData)
{
ofs << "<AppendedData encoding=\"raw\">\n_1234";
ofs << std::flush; ofs.close();
- std::ofstream ofs2(fileName,std::ios_base::binary | std::ios_base::app);
+ std::ofstream ofs2(fileName.c_str(),std::ios_base::binary | std::ios_base::app);
ofs2.write(byteData->begin(),byteData->getNbOfElems()); ofs2 << std::flush; ofs2.close();
- std::ofstream ofs3(fileName,std::ios_base::app); ofs3 << "\n</AppendedData>\n</VTKFile>\n"; ofs3.close();
+ std::ofstream ofs3(fileName.c_str(),std::ios_base::app); ofs3 << "\n</AppendedData>\n</VTKFile>\n"; ofs3.close();
}
else
{
{
public:
MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
- MEDCOUPLING_EXPORT void setName(const char *name) { _name=name; }
+ MEDCOUPLING_EXPORT void setName(const std::string& name) { _name=name; }
MEDCOUPLING_EXPORT std::string getName() const { return _name; }
- MEDCOUPLING_EXPORT void setDescription(const char *descr) { _description=descr; }
+ MEDCOUPLING_EXPORT void setDescription(const std::string& descr) { _description=descr; }
MEDCOUPLING_EXPORT std::string getDescription() const { return _description; }
MEDCOUPLING_EXPORT double getTime(int& iteration, int& order) const { iteration=_iteration; order=_order; return _time; }
MEDCOUPLING_EXPORT void setTime(double val, int iteration, int order) { _time=val; _iteration=iteration; _order=order; }
- MEDCOUPLING_EXPORT void setTimeUnit(const char *unit) { _time_unit=unit; }
- MEDCOUPLING_EXPORT const char *getTimeUnit() const { return _time_unit.c_str(); }
+ MEDCOUPLING_EXPORT void setTimeUnit(const std::string& unit) { _time_unit=unit; }
+ MEDCOUPLING_EXPORT std::string getTimeUnit() const { return _time_unit; }
MEDCOUPLING_EXPORT virtual MEDCouplingMesh *deepCpy() const = 0;
MEDCOUPLING_EXPORT virtual MEDCouplingMeshType getType() const = 0;
MEDCOUPLING_EXPORT bool isStructured() const;
MEDCOUPLING_EXPORT virtual void getCellsContainingPoint(const double *pos, double eps, std::vector<int>& elts) const;
MEDCOUPLING_EXPORT virtual void getCellsContainingPoints(const double *pos, int nbOfPoints, double eps, MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& elts, MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& eltsIndex) const;
MEDCOUPLING_EXPORT virtual MEDCouplingFieldDouble *fillFromAnalytic(TypeOfField t, int nbOfComp, FunctionToEvaluate func) const;
- MEDCOUPLING_EXPORT virtual MEDCouplingFieldDouble *fillFromAnalytic(TypeOfField t, int nbOfComp, const char *func) const;
- MEDCOUPLING_EXPORT virtual MEDCouplingFieldDouble *fillFromAnalytic2(TypeOfField t, int nbOfComp, const char *func) const;
- MEDCOUPLING_EXPORT virtual MEDCouplingFieldDouble *fillFromAnalytic3(TypeOfField t, int nbOfComp, const std::vector<std::string>& varsOrder, const char *func) const;
+ MEDCOUPLING_EXPORT virtual MEDCouplingFieldDouble *fillFromAnalytic(TypeOfField t, int nbOfComp, const std::string& func) const;
+ MEDCOUPLING_EXPORT virtual MEDCouplingFieldDouble *fillFromAnalytic2(TypeOfField t, int nbOfComp, const std::string& func) const;
+ MEDCOUPLING_EXPORT virtual MEDCouplingFieldDouble *fillFromAnalytic3(TypeOfField t, int nbOfComp, const std::vector<std::string>& varsOrder, const std::string& func) const;
MEDCOUPLING_EXPORT virtual MEDCouplingFieldDouble *buildOrthogonalField() const = 0;
MEDCOUPLING_EXPORT virtual void rotate(const double *center, const double *vector, double angle) = 0;
MEDCOUPLING_EXPORT virtual void translate(const double *vector) = 0;
MEDCOUPLING_EXPORT virtual MEDCouplingMesh *buildPartRangeAndReduceNodes(int beginCellIds, int endCellIds, int stepCellIds, int& beginOut, int& endOut, int& stepOut, DataArrayInt*& arr) const;
MEDCOUPLING_EXPORT virtual MEDCouplingUMesh *buildUnstructured() const = 0;
MEDCOUPLING_EXPORT virtual DataArrayInt *simplexize(int policy) = 0;
+ MEDCOUPLING_EXPORT virtual void getReverseNodalConnectivity(DataArrayInt *revNodal, DataArrayInt *revNodalIndx) const = 0;
MEDCOUPLING_EXPORT virtual bool areCompatibleForMerge(const MEDCouplingMesh *other) const;
MEDCOUPLING_EXPORT static MEDCouplingMesh *MergeMeshes(const MEDCouplingMesh *mesh1, const MEDCouplingMesh *mesh2);
MEDCOUPLING_EXPORT static MEDCouplingMesh *MergeMeshes(std::vector<const MEDCouplingMesh *>& meshes);
MEDCOUPLING_EXPORT virtual void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const = 0;
MEDCOUPLING_EXPORT virtual void unserialization(const std::vector<double>& tinyInfoD, const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2,
const std::vector<std::string>& littleStrings) = 0;
- MEDCOUPLING_EXPORT void writeVTK(const char *fileName, bool isBinary=true) const;
+ MEDCOUPLING_EXPORT void writeVTK(const std::string& fileName, bool isBinary=true) const;
/// @cond INTERNAL
- MEDCOUPLING_EXPORT void writeVTKAdvanced(const char *fileName, const std::string& cda, const std::string& pda, DataArrayByte *byteData) const;
+ MEDCOUPLING_EXPORT void writeVTKAdvanced(const std::string& fileName, const std::string& cda, const std::string& pda, DataArrayByte *byteData) const;
/// @endcond
MEDCOUPLING_EXPORT virtual void writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData, DataArrayByte *byteData) const = 0;
MEDCOUPLING_EXPORT virtual void reprQuickOverview(std::ostream& stream) const = 0;
if(tinyInfo[2]>=0 && tinyInfo[1]>=1)
{
setCoords(a2);
- setName(littleStrings[0].c_str());
- setDescription(littleStrings[1].c_str());
- a2->setName(littleStrings[2].c_str());
- setTimeUnit(littleStrings[3].c_str());
+ setName(littleStrings[0]);
+ setDescription(littleStrings[1]);
+ a2->setName(littleStrings[2]);
+ setTimeUnit(littleStrings[3]);
for(int i=0;i<tinyInfo[1];i++)
- getCoords()->setInfoOnComponent(i,littleStrings[i+4].c_str());
+ getCoords()->setInfoOnComponent(i,littleStrings[i+4]);
setTime(tinyInfoD[0],tinyInfo[3],tinyInfo[4]);
}
else
{
- setName(littleStrings[0].c_str());
- setDescription(littleStrings[1].c_str());
- setTimeUnit(littleStrings[2].c_str());
+ setName(littleStrings[0]);
+ setDescription(littleStrings[1]);
+ setTimeUnit(littleStrings[2]);
setTime(tinyInfoD[0],tinyInfo[3],tinyInfo[4]);
}
}
{
DataArrayInt *cellIdsKept=0;
fillCellIdsToKeepFromNodeIds(begin,end,fullyIn,cellIdsKept);
- cellIdsKept->setName(getName().c_str());
+ cellIdsKept->setName(getName());
return cellIdsKept;
}
MEDCOUPLING_EXPORT virtual DataArrayInt *getCellsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bbox, double eps) = 0;
MEDCOUPLING_EXPORT virtual DataArrayInt *zipCoordsTraducer();
MEDCOUPLING_EXPORT virtual DataArrayInt *zipConnectivityTraducer(int compType, int startCellId=0);
- MEDCOUPLING_EXPORT virtual void getReverseNodalConnectivity(DataArrayInt *revNodal, DataArrayInt *revNodalIndx) const = 0;
//tools
public:
MEDCOUPLING_EXPORT bool areCellsFrom2MeshEqual(const MEDCouplingPointSet *other, int cellId, double prec) const;
releaseData(false);
}
-int MEDCouplingRemapper::prepare(const MEDCouplingMesh *srcMesh, const MEDCouplingMesh *targetMesh, const char *method)
+int MEDCouplingRemapper::prepare(const MEDCouplingMesh *srcMesh, const MEDCouplingMesh *targetMesh, const std::string& method)
{
if(!srcMesh || !targetMesh)
throw INTERP_KERNEL::Exception("MEDCouplingRemapper::prepare : presence of NULL input pointer !");
std::string srcMethod,targetMethod;
INTERP_KERNEL::Interpolation<INTERP_KERNEL::Interpolation3D>::CheckAndSplitInterpolationMethod(method,srcMethod,targetMethod);
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldTemplate> src=MEDCouplingFieldTemplate::New(MEDCouplingFieldDiscretization::GetTypeOfFieldFromStringRepr(srcMethod.c_str()));
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldTemplate> src=MEDCouplingFieldTemplate::New(MEDCouplingFieldDiscretization::GetTypeOfFieldFromStringRepr(srcMethod));
src->setMesh(srcMesh);
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldTemplate> target=MEDCouplingFieldTemplate::New(MEDCouplingFieldDiscretization::GetTypeOfFieldFromStringRepr(targetMethod.c_str()));
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldTemplate> target=MEDCouplingFieldTemplate::New(MEDCouplingFieldDiscretization::GetTypeOfFieldFromStringRepr(targetMethod));
target->setMesh(targetMesh);
return prepareEx(src,target);
}
MEDCouplingNormalizedUnstructuredMesh<1,1> source_mesh_wrapper(src_mesh);
MEDCouplingNormalizedUnstructuredMesh<1,1> target_mesh_wrapper(target_mesh);
INTERP_KERNEL::Interpolation1D interpolation(*this);
- nbCols=interpolation.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,_matrix,method.c_str());
+ nbCols=interpolation.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,_matrix,method);
}
else if(srcMeshDim==1 && trgMeshDim==1 && srcSpaceDim==2)
{
MEDCouplingNormalizedUnstructuredMesh<2,1> source_mesh_wrapper(src_mesh);
MEDCouplingNormalizedUnstructuredMesh<2,1> target_mesh_wrapper(target_mesh);
INTERP_KERNEL::Interpolation2DCurve interpolation(*this);
- nbCols=interpolation.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,_matrix,method.c_str());
+ nbCols=interpolation.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,_matrix,method);
}
else if(srcMeshDim==2 && trgMeshDim==2 && srcSpaceDim==2)
{
MEDCouplingNormalizedUnstructuredMesh<2,2> source_mesh_wrapper(src_mesh);
MEDCouplingNormalizedUnstructuredMesh<2,2> target_mesh_wrapper(target_mesh);
INTERP_KERNEL::Interpolation2D interpolation(*this);
- nbCols=interpolation.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,_matrix,method.c_str());
+ nbCols=interpolation.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,_matrix,method);
}
else if(srcMeshDim==3 && trgMeshDim==3 && srcSpaceDim==3)
{
MEDCouplingNormalizedUnstructuredMesh<3,3> source_mesh_wrapper(src_mesh);
MEDCouplingNormalizedUnstructuredMesh<3,3> target_mesh_wrapper(target_mesh);
INTERP_KERNEL::Interpolation3D interpolation(*this);
- nbCols=interpolation.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,_matrix,method.c_str());
+ nbCols=interpolation.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,_matrix,method);
}
else if(srcMeshDim==2 && trgMeshDim==2 && srcSpaceDim==3)
{
MEDCouplingNormalizedUnstructuredMesh<3,2> source_mesh_wrapper(src_mesh);
MEDCouplingNormalizedUnstructuredMesh<3,2> target_mesh_wrapper(target_mesh);
INTERP_KERNEL::Interpolation3DSurf interpolation(*this);
- nbCols=interpolation.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,_matrix,method.c_str());
+ nbCols=interpolation.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,_matrix,method);
}
else if(srcMeshDim==3 && trgMeshDim==1 && srcSpaceDim==3)
{
MEDCouplingNormalizedUnstructuredMesh<3,3> source_mesh_wrapper(src_mesh);
MEDCouplingNormalizedUnstructuredMesh<3,3> target_mesh_wrapper(target_mesh);
INTERP_KERNEL::Interpolation3D interpolation(*this);
- nbCols=interpolation.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,_matrix,method.c_str());
+ nbCols=interpolation.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,_matrix,method);
}
else if(srcMeshDim==1 && trgMeshDim==3 && srcSpaceDim==3)
{
MEDCouplingNormalizedUnstructuredMesh<3,3> target_mesh_wrapper(target_mesh);
INTERP_KERNEL::Interpolation3D interpolation(*this);
std::vector<std::map<int,double> > matrixTmp;
- nbCols=interpolation.interpolateMeshes(target_mesh_wrapper,source_mesh_wrapper,matrixTmp,method.c_str());
+ nbCols=interpolation.interpolateMeshes(target_mesh_wrapper,source_mesh_wrapper,matrixTmp,method);
ReverseMatrix(matrixTmp,nbCols,_matrix);
nbCols=matrixTmp.size();
}
MEDCouplingNormalizedUnstructuredMesh<2,2> source_mesh_wrapper(src_mesh);
MEDCouplingNormalizedUnstructuredMesh<2,2> target_mesh_wrapper(target_mesh);
INTERP_KERNEL::Interpolation2D interpolation(*this);
- nbCols=interpolation.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,_matrix,method.c_str());
+ nbCols=interpolation.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,_matrix,method);
}
else
{
MEDCouplingNormalizedUnstructuredMesh<2,2> target_mesh_wrapper(target_mesh);
INTERP_KERNEL::Interpolation2D1D interpolation(*this);
std::vector<std::map<int,double> > matrixTmp;
- nbCols=interpolation.interpolateMeshes(target_mesh_wrapper,source_mesh_wrapper,matrixTmp,method.c_str());
+ nbCols=interpolation.interpolateMeshes(target_mesh_wrapper,source_mesh_wrapper,matrixTmp,method);
ReverseMatrix(matrixTmp,nbCols,_matrix);
nbCols=matrixTmp.size();
INTERP_KERNEL::Interpolation2D1D::DuplicateFacesType duplicateFaces=interpolation.retrieveDuplicateFaces();
MEDCouplingNormalizedUnstructuredMesh<2,2> target_mesh_wrapper(target_mesh);
INTERP_KERNEL::Interpolation2D interpolation(*this);
std::vector<std::map<int,double> > matrixTmp;
- nbCols=interpolation.interpolateMeshes(target_mesh_wrapper,source_mesh_wrapper,matrixTmp,method.c_str());
+ nbCols=interpolation.interpolateMeshes(target_mesh_wrapper,source_mesh_wrapper,matrixTmp,method);
ReverseMatrix(matrixTmp,nbCols,_matrix);
nbCols=matrixTmp.size();
}
MEDCouplingNormalizedUnstructuredMesh<2,2> source_mesh_wrapper(src_mesh);
MEDCouplingNormalizedUnstructuredMesh<2,2> target_mesh_wrapper(target_mesh);
INTERP_KERNEL::Interpolation2D1D interpolation(*this);
- nbCols=interpolation.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,_matrix,method.c_str());
+ nbCols=interpolation.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,_matrix,method);
INTERP_KERNEL::Interpolation2D1D::DuplicateFacesType duplicateFaces=interpolation.retrieveDuplicateFaces();
if(!duplicateFaces.empty())
{
MEDCouplingNormalizedUnstructuredMesh<3,3> source_mesh_wrapper(src_mesh);
MEDCouplingNormalizedUnstructuredMesh<3,3> target_mesh_wrapper(target_mesh);
INTERP_KERNEL::Interpolation3D2D interpolation(*this);
- nbCols=interpolation.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,_matrix,method.c_str());
+ nbCols=interpolation.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,_matrix,method);
INTERP_KERNEL::Interpolation3D2D::DuplicateFacesType duplicateFaces=interpolation.retrieveDuplicateFaces();
if(!duplicateFaces.empty())
{
MEDCouplingNormalizedUnstructuredMesh<3,3> target_mesh_wrapper(target_mesh);
INTERP_KERNEL::Interpolation3D2D interpolation(*this);
std::vector<std::map<int,double> > matrixTmp;
- nbCols=interpolation.interpolateMeshes(target_mesh_wrapper,source_mesh_wrapper,matrixTmp,method.c_str());
+ nbCols=interpolation.interpolateMeshes(target_mesh_wrapper,source_mesh_wrapper,matrixTmp,method);
ReverseMatrix(matrixTmp,nbCols,_matrix);
nbCols=matrixTmp.size();
INTERP_KERNEL::Interpolation3D2D::DuplicateFacesType duplicateFaces=interpolation.retrieveDuplicateFaces();
{
MEDCouplingNormalizedUnstructuredMesh<2,2> source_mesh_wrapper(src_mesh);
INTERP_KERNEL::Interpolation2D interpolation(*this);
- nbCols=interpolation.toIntegralUniform(source_mesh_wrapper,_matrix,srcMeth.c_str());
+ nbCols=interpolation.toIntegralUniform(source_mesh_wrapper,_matrix,srcMeth);
}
else if(srcMeshDim==3 && srcSpaceDim==3)
{
MEDCouplingNormalizedUnstructuredMesh<3,3> source_mesh_wrapper(src_mesh);
INTERP_KERNEL::Interpolation3D interpolation(*this);
- nbCols=interpolation.toIntegralUniform(source_mesh_wrapper,_matrix,srcMeth.c_str());
+ nbCols=interpolation.toIntegralUniform(source_mesh_wrapper,_matrix,srcMeth);
}
else if(srcMeshDim==2 && srcSpaceDim==3)
{
MEDCouplingNormalizedUnstructuredMesh<3,2> source_mesh_wrapper(src_mesh);
INTERP_KERNEL::Interpolation3DSurf interpolation(*this);
- nbCols=interpolation.toIntegralUniform(source_mesh_wrapper,_matrix,srcMeth.c_str());
+ nbCols=interpolation.toIntegralUniform(source_mesh_wrapper,_matrix,srcMeth);
}
else
throw INTERP_KERNEL::Exception("No interpolation available for the given mesh and space dimension of source mesh to -1D targetMesh");
{
MEDCouplingNormalizedUnstructuredMesh<2,2> source_mesh_wrapper(target_mesh);
INTERP_KERNEL::Interpolation2D interpolation(*this);
- nbCols=interpolation.fromIntegralUniform(source_mesh_wrapper,_matrix,trgMeth.c_str());
+ nbCols=interpolation.fromIntegralUniform(source_mesh_wrapper,_matrix,trgMeth);
}
else if(trgMeshDim==3 && trgSpaceDim==3)
{
MEDCouplingNormalizedUnstructuredMesh<3,3> source_mesh_wrapper(target_mesh);
INTERP_KERNEL::Interpolation3D interpolation(*this);
- nbCols=interpolation.fromIntegralUniform(source_mesh_wrapper,_matrix,trgMeth.c_str());
+ nbCols=interpolation.fromIntegralUniform(source_mesh_wrapper,_matrix,trgMeth);
}
else if(trgMeshDim==2 && trgSpaceDim==3)
{
MEDCouplingNormalizedUnstructuredMesh<3,2> source_mesh_wrapper(target_mesh);
INTERP_KERNEL::Interpolation3DSurf interpolation(*this);
- nbCols=interpolation.fromIntegralUniform(source_mesh_wrapper,_matrix,trgMeth.c_str());
+ nbCols=interpolation.fromIntegralUniform(source_mesh_wrapper,_matrix,trgMeth);
}
else
throw INTERP_KERNEL::Exception("No interpolation available for the given mesh and space dimension of source mesh from -1D sourceMesh");
MEDCouplingNormalizedUnstructuredMesh<3,2> target_mesh_wrapper(target_mesh->getMesh2D());
INTERP_KERNEL::Interpolation3DSurf interpolation2D(*this);
std::vector<std::map<int,double> > matrix2D;
- int nbCols2D=interpolation2D.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,matrix2D,methC.c_str());
+ int nbCols2D=interpolation2D.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,matrix2D,methC);
MEDCouplingUMesh *s1D,*t1D;
double v[3];
MEDCouplingExtrudedMesh::Project1DMeshes(src_mesh->getMesh1D(),target_mesh->getMesh1D(),getPrecision(),s1D,t1D,v);
MEDCouplingNormalizedUnstructuredMesh<1,1> t1DWrapper(t1D);
std::vector<std::map<int,double> > matrix1D;
INTERP_KERNEL::Interpolation1D interpolation1D(*this);
- int nbCols1D=interpolation1D.interpolateMeshes(s1DWrapper,t1DWrapper,matrix1D,methC.c_str());
+ int nbCols1D=interpolation1D.interpolateMeshes(s1DWrapper,t1DWrapper,matrix1D,methC);
s1D->decrRef();
t1D->decrRef();
buildFinalInterpolationMatrixByConvolution(matrix1D,matrix2D,src_mesh->getMesh3DIds()->getConstPointer(),nbCols2D,nbCols1D,
try
{
std::string tmp1,tmp2;
- INTERP_KERNEL::Interpolation<INTERP_KERNEL::Interpolation3D>::CheckAndSplitInterpolationMethod(method.c_str(),tmp1,tmp2);
+ INTERP_KERNEL::Interpolation<INTERP_KERNEL::Interpolation3D>::CheckAndSplitInterpolationMethod(method,tmp1,tmp2);
return true;
}
catch(INTERP_KERNEL::Exception& /*e*/)
public:
MEDCOUPLINGREMAPPER_EXPORT MEDCouplingRemapper();
MEDCOUPLINGREMAPPER_EXPORT ~MEDCouplingRemapper();
- MEDCOUPLINGREMAPPER_EXPORT int prepare(const MEDCouplingMesh *srcMesh, const MEDCouplingMesh *targetMesh, const char *method);
+ MEDCOUPLINGREMAPPER_EXPORT int prepare(const MEDCouplingMesh *srcMesh, const MEDCouplingMesh *targetMesh, const std::string& method);
MEDCOUPLINGREMAPPER_EXPORT int prepareEx(const MEDCouplingFieldTemplate *src, const MEDCouplingFieldTemplate *target);
MEDCOUPLINGREMAPPER_EXPORT void transfer(const MEDCouplingFieldDouble *srcField, MEDCouplingFieldDouble *targetField, double dftValue);
MEDCOUPLINGREMAPPER_EXPORT void partialTransfer(const MEDCouplingFieldDouble *srcField, MEDCouplingFieldDouble *targetField);
return INTERP_KERNEL::NORM_QUAD4;
case 1:
return INTERP_KERNEL::NORM_SEG2;
+ case 0:
+ return INTERP_KERNEL::NORM_POINT1;
default:
throw INTERP_KERNEL::Exception("Unexpected dimension for MEDCouplingStructuredMesh::GetGeoTypeGivenMeshDimension !");
}
int ns[3];
getNodeGridStructure(ns);
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> conn(Build1GTNodalConnectivity(ns,ns+meshDim));
- MEDCouplingAutoRefCountObjectPtr<MEDCoupling1SGTUMesh> ret(MEDCoupling1SGTUMesh::New(getName().c_str(),GetGeoTypeGivenMeshDimension(meshDim)));
+ MEDCouplingAutoRefCountObjectPtr<MEDCoupling1SGTUMesh> ret(MEDCoupling1SGTUMesh::New(getName(),GetGeoTypeGivenMeshDimension(meshDim)));
ret->setNodalConnectivity(conn); ret->setCoords(coords);
return ret.retn();
}
return ret;
}
+void MEDCouplingStructuredMesh::getReverseNodalConnectivity(DataArrayInt *revNodal, DataArrayInt *revNodalIndx) const
+{
+ std::vector<int> ngs(getNodeGridStructure());
+ int dim(getSpaceDimension());
+ switch(dim)
+ {
+ case 1:
+ return GetReverseNodalConnectivity1(ngs,revNodal,revNodalIndx);
+ case 2:
+ return GetReverseNodalConnectivity2(ngs,revNodal,revNodalIndx);
+ case 3:
+ return GetReverseNodalConnectivity3(ngs,revNodal,revNodalIndx);
+ default:
+ throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::getReverseNodalConnectivity : only dimensions 1, 2 and 3 are supported !");
+ }
+}
+
+void MEDCouplingStructuredMesh::GetReverseNodalConnectivity1(const std::vector<int>& ngs, DataArrayInt *revNodal, DataArrayInt *revNodalIndx)
+{
+ int nbNodes(ngs[0]);
+ revNodalIndx->alloc(nbNodes+1,1);
+ if(nbNodes==0)
+ { revNodal->alloc(0,1); revNodalIndx->setIJ(0,0,0); return ; }
+ if(nbNodes==1)
+ { revNodal->alloc(1,1); revNodal->setIJ(0,0,0); revNodalIndx->setIJ(0,0,0); revNodalIndx->setIJ(1,0,1); return ; }
+ revNodal->alloc(2*(nbNodes-1),1);
+ int *rn(revNodal->getPointer()),*rni(revNodalIndx->getPointer());
+ *rni++=0; *rni=1; *rn++=0;
+ for(int i=1;i<nbNodes-1;i++,rni++)
+ {
+ rn[0]=i-1; rn[1]=i;
+ rni[1]=rni[0]+2;
+ rn+=2;
+ }
+ rn[0]=nbNodes-2; rni[1]=rni[0]+1;
+}
+
+void MEDCouplingStructuredMesh::GetReverseNodalConnectivity2(const std::vector<int>& ngs, DataArrayInt *revNodal, DataArrayInt *revNodalIndx)
+{
+ int nbNodesX(ngs[0]),nbNodesY(ngs[1]);
+ int nbNodes(nbNodesX*nbNodesY);
+ if(nbNodesX==0 || nbNodesY==0)
+ { revNodal->alloc(0,1); revNodalIndx->setIJ(0,0,0); return ; }
+ if(nbNodesX==1 || nbNodesY==1)
+ { std::vector<int> ngs2(1); ngs2[0]=std::max(nbNodesX,nbNodesY); return GetReverseNodalConnectivity1(ngs2,revNodal,revNodalIndx); }
+ revNodalIndx->alloc(nbNodes+1,1);
+ int nbCellsX(nbNodesX-1),nbCellsY(nbNodesY-1);
+ revNodal->alloc(4*(nbNodesX-2)*(nbNodesY-2)+2*2*(nbNodesX-2)+2*2*(nbNodesY-2)+4,1);
+ int *rn(revNodal->getPointer()),*rni(revNodalIndx->getPointer());
+ *rni++=0; *rni=1; *rn++=0;
+ for(int i=1;i<nbNodesX-1;i++,rni++,rn+=2)
+ {
+ rn[0]=i-1; rn[1]=i;
+ rni[1]=rni[0]+2;
+ }
+ rni[1]=rni[0]+1; *rn++=nbCellsX-1;
+ rni++;
+ for(int j=1;j<nbNodesY-1;j++)
+ {
+ int off(nbCellsX*(j-1)),off2(nbCellsX*j);
+ rni[1]=rni[0]+2; rn[0]=off; rn[1]=off2;
+ rni++; rn+=2;
+ for(int i=1;i<nbNodesX-1;i++,rni++,rn+=4)
+ {
+ rn[0]=i-1+off; rn[1]=i+off; rn[2]=i-1+off2; rn[3]=i+off2;
+ rni[1]=rni[0]+4;
+ }
+ rni[1]=rni[0]+2; rn[0]=off+nbCellsX-1; rn[1]=off2+nbCellsX-1;
+ rni++; rn+=2;
+ }
+ int off3(nbCellsX*(nbCellsY-1));
+ rni[1]=rni[0]+1;
+ rni++; *rn++=off3;
+ for(int i=1;i<nbNodesX-1;i++,rni++,rn+=2)
+ {
+ rn[0]=i-1+off3; rn[1]=i+off3;
+ rni[1]=rni[0]+2;
+ }
+ rni[1]=rni[0]+1; rn[0]=nbCellsX*nbCellsY-1;
+}
+
+void MEDCouplingStructuredMesh::GetReverseNodalConnectivity3(const std::vector<int>& ngs, DataArrayInt *revNodal, DataArrayInt *revNodalIndx)
+{
+ int nbNodesX(ngs[0]),nbNodesY(ngs[1]),nbNodesZ(ngs[2]);
+ int nbNodes(nbNodesX*nbNodesY*nbNodesZ);
+ if(nbNodesX==0 || nbNodesY==0 || nbNodesZ==0)
+ { revNodal->alloc(0,1); revNodalIndx->setIJ(0,0,0); return ; }
+ if(nbNodesX==1 || nbNodesY==1 || nbNodesZ==1)
+ {
+ std::vector<int> ngs2(2);
+ int pos(0);
+ bool pass(false);
+ for(int i=0;i<3;i++)
+ {
+ if(pass)
+ { ngs2[pos++]=ngs[i]; }
+ else
+ {
+ pass=ngs[i]==1;
+ if(!pass)
+ { ngs2[pos++]=ngs[i]; }
+ }
+ }
+ return GetReverseNodalConnectivity2(ngs2,revNodal,revNodalIndx);
+ }
+ revNodalIndx->alloc(nbNodes+1,1);
+ int nbCellsX(nbNodesX-1),nbCellsY(nbNodesY-1),nbCellsZ(nbNodesZ-1);
+ revNodal->alloc(8*(nbNodesX-2)*(nbNodesY-2)*(nbNodesZ-2)+4*(2*(nbNodesX-2)*(nbNodesY-2)+2*(nbNodesX-2)*(nbNodesZ-2)+2*(nbNodesY-2)*(nbNodesZ-2))+2*4*(nbNodesX-2)+2*4*(nbNodesY-2)+2*4*(nbNodesZ-2)+8,1);
+ int *rn(revNodal->getPointer()),*rni(revNodalIndx->getPointer());
+ *rni=0;
+ for(int k=0;k<nbNodesZ;k++)
+ {
+ bool factZ(k!=0 && k!=nbNodesZ-1);
+ int offZ0((k-1)*nbCellsX*nbCellsY),offZ1(k*nbCellsX*nbCellsY);
+ for(int j=0;j<nbNodesY;j++)
+ {
+ bool factYZ(factZ && (j!=0 && j!=nbNodesY-1));
+ int off00((j-1)*nbCellsX+offZ0),off01(j*nbCellsX+offZ0),off10((j-1)*nbCellsX+offZ1),off11(j*nbCellsX+offZ1);
+ for(int i=0;i<nbNodesX;i++,rni++)
+ {
+ int fact(factYZ && (i!=0 && i!=nbNodesX-1));
+ if(fact)
+ {//most of points fall in this part of code
+ rn[0]=off00+i-1; rn[1]=off00+i; rn[2]=off01+i-1; rn[3]=off01+i;
+ rn[4]=off10+i-1; rn[5]=off10+i; rn[6]=off11+i-1; rn[7]=off11+i;
+ rni[1]=rni[0]+8;
+ rn+=8;
+ }
+ else
+ {
+ int *rnRef(rn);
+ if(k>=1 && j>=1 && i>=1)
+ *rn++=off00+i-1;
+ if(k>=1 && j>=1 && i<nbCellsX)
+ *rn++=off00+i;
+ if(k>=1 && j<nbCellsY && i>=1)
+ *rn++=off01+i-1;
+ if(k>=1 && j<nbCellsY && i<nbCellsX)
+ *rn++=off01+i;
+ //
+ if(k<nbCellsZ && j>=1 && i>=1)
+ *rn++=off10+i-1;
+ if(k<nbCellsZ && j>=1 && i<nbCellsX)
+ *rn++=off10+i;
+ if(k<nbCellsZ && j<nbCellsY && i>=1)
+ *rn++=off11+i-1;
+ if(k<nbCellsZ && j<nbCellsY && i<nbCellsX)
+ *rn++=off11+i;
+ rni[1]=rni[0]+(int)(std::distance(rnRef,rn));
+ }
+ }
+ }
+ }
+}
+
/*!
* \return DataArrayInt * - newly allocated instance of nodal connectivity compatible for MEDCoupling1SGTMesh instance
*/
std::size_t dim=std::distance(nodeStBg,nodeStEnd);
switch(dim)
{
+ case 0:
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> conn(DataArrayInt::New());
+ conn->alloc(1,1); conn->setIJ(0,0,0);
+ return conn.retn();
+ }
case 1:
return Build1GTNodalConnectivity1D(nodeStBg);
case 2:
case 3:
return Build1GTNodalConnectivity3D(nodeStBg);
default:
- throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::Build1GTNodalConnectivity : only dimension in [1,2,3] supported !");
+ throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::Build1GTNodalConnectivity : only dimension in [0,1,2,3] supported !");
}
}
{
int tmp[3]={i,j,k};
int tmp2[3];
- int meshDim=getMeshDimension();
+ int meshDim(getMeshDimension());
getSplitCellValues(tmp2);
std::transform(tmp,tmp+meshDim,tmp2,tmp,std::multiplies<int>());
return std::accumulate(tmp,tmp+meshDim,0);
{
int tmp[3]={i,j,k};
int tmp2[3];
- int meshDim=getMeshDimension();
+ int spaceDim(getSpaceDimension());
getSplitNodeValues(tmp2);
- std::transform(tmp,tmp+meshDim,tmp2,tmp,std::multiplies<int>());
- return std::accumulate(tmp,tmp+meshDim,0);
+ std::transform(tmp,tmp+spaceDim,tmp2,tmp,std::multiplies<int>());
+ return std::accumulate(tmp,tmp+spaceDim,0);
}
void MEDCouplingStructuredMesh::GetPosFromId(int nodeId, int meshDim, const int *split, int *res)
MEDCOUPLING_EXPORT MEDCouplingMesh *buildPartAndReduceNodes(const int *start, const int *end, DataArrayInt*& arr) const;
MEDCOUPLING_EXPORT DataArrayInt *simplexize(int policy);
MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildOrthogonalField() const;
+ MEDCOUPLING_EXPORT void getReverseNodalConnectivity(DataArrayInt *revNodal, DataArrayInt *revNodalIndx) const;
//some useful methods
MEDCOUPLING_EXPORT int getCellIdFromPos(int i, int j, int k) const;
MEDCOUPLING_EXPORT int getNodeIdFromPos(int i, int j, int k) const;
MEDCOUPLING_EXPORT static DataArrayInt *BuildExplicitIdsFrom(const std::vector<int>& st, const std::vector< std::pair<int,int> >& partCompactFormat);
MEDCOUPLING_EXPORT static DataArrayInt *Build1GTNodalConnectivity(const int *nodeStBg, const int *nodeStEnd);
private:
+ static void GetReverseNodalConnectivity1(const std::vector<int>& ngs, DataArrayInt *revNodal, DataArrayInt *revNodalIndx);
+ static void GetReverseNodalConnectivity2(const std::vector<int>& ngs, DataArrayInt *revNodal, DataArrayInt *revNodalIndx);
+ static void GetReverseNodalConnectivity3(const std::vector<int>& ngs, DataArrayInt *revNodal, DataArrayInt *revNodalIndx);
static DataArrayInt *Build1GTNodalConnectivity1D(const int *nodeStBg);
static DataArrayInt *Build1GTNodalConnectivity2D(const int *nodeStBg);
static DataArrayInt *Build1GTNodalConnectivity3D(const int *nodeStBg);
_time_tolerance=tinyInfoD[0];
int nbOfCompo=_array->getNumberOfComponents();
for(int i=0;i<nbOfCompo;i++)
- _array->setInfoOnComponent(i,tinyInfoS[i].c_str());
+ _array->setInfoOnComponent(i,tinyInfoS[i]);
}
void MEDCouplingTimeDiscretization::getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const
setArrays(arrays3,0);
}
-void MEDCouplingTimeDiscretization::applyFunc(int nbOfComp, const char *func)
+void MEDCouplingTimeDiscretization::applyFunc(int nbOfComp, const std::string& func)
{
std::vector<DataArrayDouble *> arrays;
getArrays(arrays);
setArrays(arrays3,0);
}
-void MEDCouplingTimeDiscretization::applyFunc2(int nbOfComp, const char *func)
+void MEDCouplingTimeDiscretization::applyFunc2(int nbOfComp, const std::string& func)
{
std::vector<DataArrayDouble *> arrays;
getArrays(arrays);
setArrays(arrays3,0);
}
-void MEDCouplingTimeDiscretization::applyFunc3(int nbOfComp, const std::vector<std::string>& varsOrder, const char *func)
+void MEDCouplingTimeDiscretization::applyFunc3(int nbOfComp, const std::vector<std::string>& varsOrder, const std::string& func)
{
std::vector<DataArrayDouble *> arrays;
getArrays(arrays);
setArrays(arrays3,0);
}
-void MEDCouplingTimeDiscretization::applyFunc(const char *func)
+void MEDCouplingTimeDiscretization::applyFunc(const std::string& func)
{
std::vector<DataArrayDouble *> arrays;
getArrays(arrays);
setArrays(arrays3,0);
}
-void MEDCouplingTimeDiscretization::applyFuncFast32(const char *func)
+void MEDCouplingTimeDiscretization::applyFuncFast32(const std::string& func)
{
std::vector<DataArrayDouble *> arrays;
getArrays(arrays);
}
}
-void MEDCouplingTimeDiscretization::applyFuncFast64(const char *func)
+void MEDCouplingTimeDiscretization::applyFuncFast64(const std::string& func)
{
std::vector<DataArrayDouble *> arrays;
getArrays(arrays);
setArrays(arrays3,0);
}
-void MEDCouplingTimeDiscretization::fillFromAnalytic(const DataArrayDouble *loc, int nbOfComp, const char *func)
+void MEDCouplingTimeDiscretization::fillFromAnalytic(const DataArrayDouble *loc, int nbOfComp, const std::string& func)
{
std::vector<DataArrayDouble *> arrays;
getArrays(arrays);
setArrays(arrays3,0);
}
-void MEDCouplingTimeDiscretization::fillFromAnalytic2(const DataArrayDouble *loc, int nbOfComp, const char *func)
+void MEDCouplingTimeDiscretization::fillFromAnalytic2(const DataArrayDouble *loc, int nbOfComp, const std::string& func)
{
std::vector<DataArrayDouble *> arrays;
getArrays(arrays);
setArrays(arrays3,0);
}
-void MEDCouplingTimeDiscretization::fillFromAnalytic3(const DataArrayDouble *loc, int nbOfComp, const std::vector<std::string>& varsOrder, const char *func)
+void MEDCouplingTimeDiscretization::fillFromAnalytic3(const DataArrayDouble *loc, int nbOfComp, const std::vector<std::string>& varsOrder, const std::string& func)
{
std::vector<DataArrayDouble *> arrays;
getArrays(arrays);
MEDCOUPLING_EXPORT virtual std::size_t getHeapMemorySizeWithoutChildren() const;
MEDCOUPLING_EXPORT virtual std::vector<const BigMemoryObject *> getDirectChildren() const;
MEDCOUPLING_EXPORT static MEDCouplingTimeDiscretization *New(TypeOfTimeDiscretization type);
- MEDCOUPLING_EXPORT void setTimeUnit(const char *unit) { _time_unit=unit; }
- MEDCOUPLING_EXPORT const char *getTimeUnit() const { return _time_unit.c_str(); }
+ MEDCOUPLING_EXPORT void setTimeUnit(const std::string& unit) { _time_unit=unit; }
+ MEDCOUPLING_EXPORT std::string getTimeUnit() const { return _time_unit; }
MEDCOUPLING_EXPORT virtual void copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other);
MEDCOUPLING_EXPORT virtual void copyTinyStringsFrom(const MEDCouplingTimeDiscretization& other);
MEDCOUPLING_EXPORT virtual void checkCoherency() const;
MEDCOUPLING_EXPORT virtual void setOrCreateUniformValueOnAllComponents(int nbOfTuple, double value);
MEDCOUPLING_EXPORT virtual void applyLin(double a, double b, int compoId);
MEDCOUPLING_EXPORT virtual void applyFunc(int nbOfComp, FunctionToEvaluate func);
- MEDCOUPLING_EXPORT virtual void applyFunc(int nbOfComp, const char *func);
- MEDCOUPLING_EXPORT virtual void applyFunc2(int nbOfComp, const char *func);
- MEDCOUPLING_EXPORT virtual void applyFunc3(int nbOfComp, const std::vector<std::string>& varsOrder, const char *func);
- MEDCOUPLING_EXPORT virtual void applyFunc(const char *func);
- MEDCOUPLING_EXPORT virtual void applyFuncFast32(const char *func);
- MEDCOUPLING_EXPORT virtual void applyFuncFast64(const char *func);
+ MEDCOUPLING_EXPORT virtual void applyFunc(int nbOfComp, const std::string& func);
+ MEDCOUPLING_EXPORT virtual void applyFunc2(int nbOfComp, const std::string& func);
+ MEDCOUPLING_EXPORT virtual void applyFunc3(int nbOfComp, const std::vector<std::string>& varsOrder, const std::string& func);
+ MEDCOUPLING_EXPORT virtual void applyFunc(const std::string& func);
+ MEDCOUPLING_EXPORT virtual void applyFuncFast32(const std::string& func);
+ MEDCOUPLING_EXPORT virtual void applyFuncFast64(const std::string& func);
MEDCOUPLING_EXPORT virtual void fillFromAnalytic(const DataArrayDouble *loc, int nbOfComp, FunctionToEvaluate func);
- MEDCOUPLING_EXPORT virtual void fillFromAnalytic(const DataArrayDouble *loc, int nbOfComp, const char *func);
- MEDCOUPLING_EXPORT virtual void fillFromAnalytic2(const DataArrayDouble *loc, int nbOfComp, const char *func);
- MEDCOUPLING_EXPORT virtual void fillFromAnalytic3(const DataArrayDouble *loc, int nbOfComp, const std::vector<std::string>& varsOrder, const char *func);
+ MEDCOUPLING_EXPORT virtual void fillFromAnalytic(const DataArrayDouble *loc, int nbOfComp, const std::string& func);
+ MEDCOUPLING_EXPORT virtual void fillFromAnalytic2(const DataArrayDouble *loc, int nbOfComp, const std::string& func);
+ MEDCOUPLING_EXPORT virtual void fillFromAnalytic3(const DataArrayDouble *loc, int nbOfComp, const std::vector<std::string>& varsOrder, const std::string& func);
//
MEDCOUPLING_EXPORT virtual ~MEDCouplingTimeDiscretization();
protected:
return new MEDCouplingUMesh;
}
-MEDCouplingUMesh *MEDCouplingUMesh::New(const char *meshName, int meshDim)
+MEDCouplingUMesh *MEDCouplingUMesh::New(const std::string& meshName, int meshDim)
{
MEDCouplingUMesh *ret=new MEDCouplingUMesh;
ret->setName(meshName);
const int *conn=_nodal_connec->getConstPointer();
const int *connIndex=_nodal_connec_index->getConstPointer();
std::string name="Mesh constituent of "; name+=getName();
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> ret=MEDCouplingUMesh::New(name.c_str(),getMeshDimension()-SonsGenerator::DELTA);
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> ret=MEDCouplingUMesh::New(name,getMeshDimension()-SonsGenerator::DELTA);
ret->setCoords(getCoords());
ret->allocateCells(2*nbOfCells);
descIndx->alloc(nbOfCells+1,1);
}
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> o2n=mesh->zipConnectivityTraducer(compType,nbOfCells);
arr=o2n->substr(nbOfCells);
- arr->setName(other->getName().c_str());
+ arr->setName(other->getName());
int tmp;
if(other->getNumberOfCells()==0)
return true;
}
}
}
- arr2->setName(other->getName().c_str());
+ arr2->setName(other->getName());
if(arr2->presenceOfValue(0))
return false;
arr=arr2.retn();
int mdim=getMeshDimension();
if(mdim<0)
throw INTERP_KERNEL::Exception("MEDCouplingUMesh::buildSetInstanceFromThis : invalid mesh dimension ! Should be >= 0 !");
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> ret=MEDCouplingUMesh::New(getName().c_str(),mdim);
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> ret=MEDCouplingUMesh::New(getName(),mdim);
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp1,tmp2;
bool needToCpyCT=true;
if(!_nodal_connec)
name+=getName();
int nbelem=getNumberOfCells();
MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> field=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
- field->setName(name.c_str());
+ field->setName(name);
MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> array=DataArrayDouble::New();
array->alloc(nbelem,1);
double *area_vol=array->getPointer();
name+=getName();
int nbelem=(int)std::distance(begin,end);
MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> array=DataArrayDouble::New();
- array->setName(name.c_str());
+ array->setName(name);
array->alloc(nbelem,1);
double *area_vol=array->getPointer();
if(getMeshDimension()!=-1)
INTERP_KERNEL::EdgeLin *e1=new INTERP_KERNEL::EdgeLin(mapp2[bg[0]].first,mapp2[bg[2]].first);
INTERP_KERNEL::EdgeLin *e2=new INTERP_KERNEL::EdgeLin(mapp2[bg[2]].first,mapp2[bg[1]].first);
INTERP_KERNEL::SegSegIntersector inters(*e1,*e2);
+ // is the SEG3 degenerated, and thus can be reduced to a SEG2?
bool colinearity=inters.areColinears();
delete e1; delete e2;
if(colinearity)
}
/*!
- * This method creates a sub mesh in Geometric2D DS. The sub mesh is composed be the sub set of cells in 'candidates' and the global mesh 'mDesc'.
- * The input meth 'mDesc' must be so that mDim==1 et spaceDim==3.
- * 'mapp' contains a mapping between local numbering in submesh and the global node numbering in 'mDesc'.
+ * This method creates a sub mesh in Geometric2D DS. The sub mesh is composed by the sub set of cells in 'candidates' taken from
+ * the global mesh 'mDesc'.
+ * The input mesh 'mDesc' must be so that mDim==1 and spaceDim==2.
+ * 'mapp' returns a mapping between local numbering in submesh (represented by a Node*) and the global node numbering in 'mDesc'.
*/
- INTERP_KERNEL::QuadraticPolygon *MEDCouplingUMeshBuildQPFromMesh(const MEDCouplingUMesh *mDesc, const std::vector<int>& candidates, std::map<INTERP_KERNEL::Node *,int>& mapp) throw(INTERP_KERNEL::Exception)
+ INTERP_KERNEL::QuadraticPolygon *MEDCouplingUMeshBuildQPFromMesh(const MEDCouplingUMesh *mDesc, const std::vector<int>& candidates,
+ std::map<INTERP_KERNEL::Node *,int>& mapp)
+ throw(INTERP_KERNEL::Exception)
{
mapp.clear();
std::map<int, std::pair<INTERP_KERNEL::Node *,bool> > mapp2;//bool is for a flag specifying if node is boundary (true) or only a middle for SEG3.
return new INTERP_KERNEL::Node(coo1[2*nodeId],coo1[2*nodeId+1]);
}
+ /**
+ * Construct a mapping between set of Nodes and the standart MEDCoupling connectivity format (c, cI).
+ */
void MEDCouplingUMeshBuildQPFromMesh3(const double *coo1, int offset1, const double *coo2, int offset2, const std::vector<double>& addCoo,
const int *desc1Bg, const int *desc1End, const std::vector<std::vector<int> >& intesctEdges1,
/*output*/std::map<INTERP_KERNEL::Node *,int>& mapp, std::map<int,INTERP_KERNEL::Node *>& mappRev)
if(_types.size()!=1)
throw INTERP_KERNEL::Exception("MEDCouplingUMesh::convertIntoSingleGeoTypeMesh : current mesh does not contain exactly one geometric type !");
INTERP_KERNEL::NormalizedCellType typ=*_types.begin();
- MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> ret=MEDCoupling1GTUMesh::New(getName().c_str(),typ);
+ MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> ret=MEDCoupling1GTUMesh::New(getName(),typ);
ret->setCoords(getCoords());
MEDCoupling1SGTUMesh *retC=dynamic_cast<MEDCoupling1SGTUMesh *>((MEDCoupling1GTUMesh*)ret);
if(retC)
if(!da)
throw INTERP_KERNEL::Exception("MEDCouplingUMesh::Build0DMeshFromCoords : instance of DataArrayDouble must be not null !");
da->checkAllocated();
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> ret=MEDCouplingUMesh::New(da->getName().c_str(),0);
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> ret=MEDCouplingUMesh::New(da->getName(),0);
ret->setCoords(da);
int nbOfTuples=da->getNumberOfTuples();
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> c=DataArrayInt::New();
tmp->alloc(curNbOfCells,1);
std::copy(o2nPtr+offset,o2nPtr+offset+curNbOfCells,tmp->getPointer());
offset+=curNbOfCells;
- tmp->setName(meshes[i]->getName().c_str());
+ tmp->setName(meshes[i]->getName());
corr[i]=tmp;
}
return ret.retn();
/*!
* Partitions the first given 2D mesh using the second given 2D mesh as a tool, and
- * returns a result mesh constituted by polygons. The meshes should be in 2D space. In
+ * returns a result mesh constituted by polygons.
+ * Thus the final result contains all nodes from m1 plus new nodes. However it doesn't necessarily contains
+ * all nodes from m2.
+ * The meshes should be in 2D space. In
* addition, returns two arrays mapping cells of the result mesh to cells of the input
* meshes.
* \param [in] m1 - the first input mesh which is a partitioned object.
* \throw If the nodal connectivity of cells is not defined in any of the meshes.
* \throw If any of the meshes is not a 2D mesh in 2D space.
*/
-MEDCouplingUMesh *MEDCouplingUMesh::Intersect2DMeshes(const MEDCouplingUMesh *m1, const MEDCouplingUMesh *m2, double eps, DataArrayInt *&cellNb1, DataArrayInt *&cellNb2)
+MEDCouplingUMesh *MEDCouplingUMesh::Intersect2DMeshes(const MEDCouplingUMesh *m1, const MEDCouplingUMesh *m2,
+ double eps, DataArrayInt *&cellNb1, DataArrayInt *&cellNb2)
{
m1->checkFullyDefined();
m2->checkFullyDefined();
if(m1->getMeshDimension()!=2 || m1->getSpaceDimension()!=2 || m2->getMeshDimension()!=2 || m2->getSpaceDimension()!=2)
throw INTERP_KERNEL::Exception("MEDCouplingUMesh::Intersect2DMeshes works on umeshes m1 AND m2 with meshdim equal to 2 and spaceDim equal to 2 too!");
+
+ // Step 1: compute all edge intersections (new nodes)
std::vector< std::vector<int> > intersectEdge1, colinear2, subDiv2;
- MEDCouplingUMesh *m1Desc=0,*m2Desc=0;
+ MEDCouplingUMesh *m1Desc=0,*m2Desc=0; // descending connec. meshes
DataArrayInt *desc1=0,*descIndx1=0,*revDesc1=0,*revDescIndx1=0,*desc2=0,*descIndx2=0,*revDesc2=0,*revDescIndx2=0;
- std::vector<double> addCoo,addCoordsQuadratic;
+ std::vector<double> addCoo,addCoordsQuadratic; // coordinates of newly created nodes
INTERP_KERNEL::QUADRATIC_PLANAR::_precision=eps;
INTERP_KERNEL::QUADRATIC_PLANAR::_arc_detection_precision=eps;
- IntersectDescending2DMeshes(m1,m2,eps,intersectEdge1,colinear2, subDiv2,m1Desc,desc1,descIndx1,revDesc1,revDescIndx1,
- m2Desc,desc2,descIndx2,revDesc2,revDescIndx2,addCoo);
+ IntersectDescending2DMeshes(m1,m2,eps,intersectEdge1,colinear2, subDiv2,
+ m1Desc,desc1,descIndx1,revDesc1,revDescIndx1,
+ addCoo, m2Desc,desc2,descIndx2,revDesc2,revDescIndx2);
revDesc1->decrRef(); revDescIndx1->decrRef(); revDesc2->decrRef(); revDescIndx2->decrRef();
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> dd1(desc1),dd2(descIndx1),dd3(desc2),dd4(descIndx2);
MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> dd5(m1Desc),dd6(m2Desc);
+
+ // Step 2: re-order newly created nodes according to the ordering found in m2
std::vector< std::vector<int> > intersectEdge2;
BuildIntersectEdges(m1Desc,m2Desc,addCoo,subDiv2,intersectEdge2);
subDiv2.clear(); dd5=0; dd6=0;
+
+ // Step 3:
std::vector<int> cr,crI; //no DataArrayInt because interface with Geometric2D
std::vector<int> cNb1,cNb2; //no DataArrayInt because interface with Geometric2D
BuildIntersecting2DCellsFromEdges(eps,m1,desc1->getConstPointer(),descIndx1->getConstPointer(),intersectEdge1,colinear2,m2,desc2->getConstPointer(),descIndx2->getConstPointer(),intersectEdge2,addCoo,
/* outputs -> */addCoordsQuadratic,cr,crI,cNb1,cNb2);
- //
+
+ // Step 4: Prepare final result:
MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> addCooDa=DataArrayDouble::New();
addCooDa->alloc((int)(addCoo.size())/2,2);
std::copy(addCoo.begin(),addCoo.end(),addCooDa->getPointer());
return ret.retn();
}
+
+/**
+ * Private. Third step of the partitioning algorithm (Intersect2DMeshes): reconstruct full 2D cells from the
+ * (newly created) nodes corresponding to the edge intersections.
+ * Output params:
+ * @param[out] cr, crI connectivity of the resulting mesh
+ * @param[out] cNb1, cNb2 correspondance arrays giving for the merged mesh the initial cells IDs in m1 / m2
+ * TODO: describe input parameters
+ */
void MEDCouplingUMesh::BuildIntersecting2DCellsFromEdges(double eps, const MEDCouplingUMesh *m1, const int *desc1, const int *descIndx1,
const std::vector<std::vector<int> >& intesctEdges1, const std::vector< std::vector<int> >& colinear2,
const MEDCouplingUMesh *m2, const int *desc2, const int *descIndx2, const std::vector<std::vector<int> >& intesctEdges2,
int offset3=offset2+((int)addCoords.size())/2;
MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> bbox1Arr(m1->getBoundingBoxForBBTree()),bbox2Arr(m2->getBoundingBoxForBBTree());
const double *bbox1(bbox1Arr->begin()),*bbox2(bbox2Arr->begin());
+ // Here a BBTree on 2D-cells, not on segments:
BBTree<SPACEDIM,int> myTree(bbox2,0,0,m2->getNumberOfCells(),eps);
int ncell1=m1->getNumberOfCells();
crI.push_back(0);
INTERP_KERNEL::QuadraticPolygon pol1;
INTERP_KERNEL::NormalizedCellType typ=(INTERP_KERNEL::NormalizedCellType)conn1[connI1[i]];
const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
+ // Populate mapp and mappRev with nodes from the current cell (i) from mesh1 - this also builds the Node* objects:
MEDCouplingUMeshBuildQPFromMesh3(coo1,offset1,coo2,offset2,addCoords,desc1+descIndx1[i],desc1+descIndx1[i+1],intesctEdges1,/* output */mapp,mappRev);
+ // pol1 is the full cell from mesh2, in QP format, with all the additional intersecting nodes.
pol1.buildFromCrudeDataArray(mappRev,cm.isQuadratic(),conn1+connI1[i]+1,coo1,
desc1+descIndx1[i],desc1+descIndx1[i+1],intesctEdges1);
//
for(it1.first();!it1.finished();it1.next())
edges1.insert(it1.current()->getPtr());
//
- std::map<int,std::vector<INTERP_KERNEL::ElementaryEdge *> > edgesIn2ForShare;
+ std::map<int,std::vector<INTERP_KERNEL::ElementaryEdge *> > edgesIn2ForShare; // common edges
std::vector<INTERP_KERNEL::QuadraticPolygon> pol2s(candidates2.size());
int ii=0;
for(std::vector<int>::const_iterator it2=candidates2.begin();it2!=candidates2.end();it2++,ii++)
{
INTERP_KERNEL::NormalizedCellType typ2=(INTERP_KERNEL::NormalizedCellType)conn2[connI2[*it2]];
const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel(typ2);
+ // Complete mapping with elements coming from the current cell it2 in mesh2:
MEDCouplingUMeshBuildQPFromMesh3(coo1,offset1,coo2,offset2,addCoords,desc2+descIndx2[*it2],desc2+descIndx2[*it2+1],intesctEdges2,/* output */mapp,mappRev);
+ // pol2 is the new QP in the final merged result.
pol2s[ii].buildFromCrudeDataArray2(mappRev,cm2.isQuadratic(),conn2+connI2[*it2]+1,coo2,desc2+descIndx2[*it2],desc2+descIndx2[*it2+1],intesctEdges2,
- pol1,desc1+descIndx1[i],desc1+descIndx1[i+1],intesctEdges1,colinear2,edgesIn2ForShare);
+ pol1,desc1+descIndx1[i],desc1+descIndx1[i+1],intesctEdges1,colinear2, /* output */ edgesIn2ForShare);
}
ii=0;
for(std::vector<int>::const_iterator it2=candidates2.begin();it2!=candidates2.end();it2++,ii++)
//MEDCouplingUMeshAssignOnLoc(pol1,pol2,desc1+descIndx1[i],desc1+descIndx1[i+1],intesctEdges1,desc2+descIndx2[*it2],desc2+descIndx2[*it2+1],intesctEdges2,colinear2);
pol1.buildPartitionsAbs(pol2s[ii],edges1,edgesBoundary2,mapp,i,*it2,offset3,addCoordsQuadratic,cr,crI,cNb1,cNb2);
}
+ // Deals with remaining (non-consumed) edges from m1: these are the edges that were never touched
+ // by m2 but that we still want to keep in the final result.
if(!edges1.empty())
{
try
/*!
* This method is private and is the first step of Partition of 2D mesh (spaceDim==2 and meshDim==2).
- *
+ * It builds the descending connectivity of the two meshes, and then using a binary tree
+ * it computes the edge intersections. This results in new points being created : they're stored in addCoo.
+ * Documentation about parameters colinear2 and subDiv2 can be found in method QuadraticPolygon::splitAbs().
*/
void MEDCouplingUMesh::IntersectDescending2DMeshes(const MEDCouplingUMesh *m1, const MEDCouplingUMesh *m2, double eps,
std::vector< std::vector<int> >& intersectEdge1, std::vector< std::vector<int> >& colinear2, std::vector< std::vector<int> >& subDiv2,
MEDCouplingUMesh *& m1Desc, DataArrayInt *&desc1, DataArrayInt *&descIndx1, DataArrayInt *&revDesc1, DataArrayInt *&revDescIndx1,
- MEDCouplingUMesh *& m2Desc, DataArrayInt *&desc2, DataArrayInt *&descIndx2, DataArrayInt *&revDesc2, DataArrayInt *&revDescIndx2,
- std::vector<double>& addCoo) throw(INTERP_KERNEL::Exception)
+ std::vector<double>& addCoo,
+ MEDCouplingUMesh *& m2Desc, DataArrayInt *&desc2, DataArrayInt *&descIndx2, DataArrayInt *&revDesc2, DataArrayInt *&revDescIndx2)
+ throw(INTERP_KERNEL::Exception)
{
static const int SPACEDIM=2;
+ // Build desc connectivity
desc1=DataArrayInt::New(); descIndx1=DataArrayInt::New(); revDesc1=DataArrayInt::New(); revDescIndx1=DataArrayInt::New();
desc2=DataArrayInt::New();
descIndx2=DataArrayInt::New();
MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> dd9(m1Desc),dd10(m2Desc);
const int *c1=m1Desc->getNodalConnectivity()->getConstPointer();
const int *ci1=m1Desc->getNodalConnectivityIndex()->getConstPointer();
+
+ // Build BB tree of all edges in the tool mesh (second mesh)
MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> bbox1Arr(m1Desc->getBoundingBoxForBBTree()),bbox2Arr(m2Desc->getBoundingBoxForBBTree());
const double *bbox1(bbox1Arr->begin()),*bbox2(bbox2Arr->begin());
- int ncell1=m1Desc->getNumberOfCells();
- int ncell2=m2Desc->getNumberOfCells();
- intersectEdge1.resize(ncell1);
- colinear2.resize(ncell2);
- subDiv2.resize(ncell2);
+ int nDescCell1=m1Desc->getNumberOfCells();
+ int nDescCell2=m2Desc->getNumberOfCells();
+ intersectEdge1.resize(nDescCell1);
+ colinear2.resize(nDescCell2);
+ subDiv2.resize(nDescCell2);
BBTree<SPACEDIM,int> myTree(bbox2,0,0,m2Desc->getNumberOfCells(),-eps);
+
std::vector<int> candidates1(1);
int offset1=m1->getNumberOfNodes();
int offset2=offset1+m2->getNumberOfNodes();
- for(int i=0;i<ncell1;i++)
+ for(int i=0;i<nDescCell1;i++) // for all edges in the first mesh
{
- std::vector<int> candidates2;
+ std::vector<int> candidates2; // edges of mesh2 candidate for intersection
myTree.getIntersectingElems(bbox1+i*2*SPACEDIM,candidates2);
- if(!candidates2.empty())
+ if(!candidates2.empty()) // candidates2 holds edges from the second mesh potentially intersecting current edge i in mesh1
{
std::map<INTERP_KERNEL::Node *,int> map1,map2;
+ // pol2 is not necessarily a closed polygon: just a set of (quadratic) edges (same as candidates2) in the Geometric DS format
INTERP_KERNEL::QuadraticPolygon *pol2=MEDCouplingUMeshBuildQPFromMesh(m2Desc,candidates2,map2);
candidates1[0]=i;
INTERP_KERNEL::QuadraticPolygon *pol1=MEDCouplingUMeshBuildQPFromMesh(m1Desc,candidates1,map1);
- // this following part is to avoid that a some remove nodes (for example due to a merge between pol1 and pol2) can be replaced by a newlt created one
- // This trick garanties that Node * are discriminant
+ // This following part is to avoid that some removed nodes (for example due to a merge between pol1 and pol2) are replaced by a newly created one
+ // This trick guarantees that Node * are discriminant (i.e. form a unique identifier)
std::set<INTERP_KERNEL::Node *> nodes;
pol1->getAllNodes(nodes); pol2->getAllNodes(nodes);
std::size_t szz(nodes.size());
for(std::size_t iii=0;iii<szz;iii++,itt++)
{ (*itt)->incrRef(); nodesSafe[iii]=*itt; }
// end of protection
+ // Performs egde cutting:
pol1->splitAbs(*pol2,map1,map2,offset1,offset2,candidates2,intersectEdge1[i],i,colinear2,subDiv2,addCoo);
delete pol2;
delete pol1;
* This method has 4 inputs :
* - a mesh 'm1' with meshDim==1 and a SpaceDim==2
* - a mesh 'm2' with meshDim==1 and a SpaceDim==2
- * - subDiv of size 'm2->getNumberOfCells()' that lists for each seg cell in 'm' the splitting node ids in randomly sorted.
- * The aim of this method is to sort the splitting nodes, if any, and to put in 'intersectEdge' output paramter based on edges of mesh 'm2'
- * \param m1 is expected to be a mesh of meshDimension equal to 1 and spaceDim equal to 2. No check of that is performed by this method. Only present for its coords in case of 'subDiv' shares some nodes of 'm1'
+ * - subDiv of size 'm2->getNumberOfCells()' that lists for each seg cell in 'm' the splitting node ids randomly sorted.
+ * The aim of this method is to sort the splitting nodes, if any, and to put them in 'intersectEdge' output parameter based on edges of mesh 'm2'
+ * Nodes end up lying consecutively on a cutted edge.
+ * \param m1 is expected to be a mesh of meshDimension equal to 1 and spaceDim equal to 2. No check of that is performed by this method.
+ * (Only present for its coords in case of 'subDiv' shares some nodes of 'm1')
* \param m2 is expected to be a mesh of meshDimension equal to 1 and spaceDim equal to 2. No check of that is performed by this method.
- * \param addCoo input parameter with additionnal nodes linked to intersection of the 2 meshes.
+ * \param addCoo input parameter with additional nodes linked to intersection of the 2 meshes.
+ * \param[out] intersectEdge the same content as subDiv, but correclty oriented.
*/
-void MEDCouplingUMesh::BuildIntersectEdges(const MEDCouplingUMesh *m1, const MEDCouplingUMesh *m2, const std::vector<double>& addCoo, const std::vector< std::vector<int> >& subDiv, std::vector< std::vector<int> >& intersectEdge)
+void MEDCouplingUMesh::BuildIntersectEdges(const MEDCouplingUMesh *m1, const MEDCouplingUMesh *m2,
+ const std::vector<double>& addCoo,
+ const std::vector< std::vector<int> >& subDiv, std::vector< std::vector<int> >& intersectEdge)
{
int offset1=m1->getNumberOfNodes();
int ncell=m2->getNumberOfCells();
std::vector<DataArrayInt *> partition=partitionBySpreadZone();
std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > partitionAuto; partitionAuto.reserve(partition.size());
std::copy(partition.begin(),partition.end(),std::back_insert_iterator<std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > >(partitionAuto));
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> ret=MEDCouplingUMesh::New(getName().c_str(),mdim);
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> ret=MEDCouplingUMesh::New(getName(),mdim);
ret->setCoords(getCoords());
ret->allocateCells((int)partition.size());
//
if(getMeshDimension()!=3 || getSpaceDimension()!=3)
throw INTERP_KERNEL::Exception("MEDCouplingUMesh::tetrahedrize : only available for mesh with meshdim == 3 and spacedim == 3 !");
int nbOfCells(getNumberOfCells()),nbNodes(getNumberOfNodes());
- MEDCouplingAutoRefCountObjectPtr<MEDCoupling1SGTUMesh> ret0(MEDCoupling1SGTUMesh::New(getName().c_str(),INTERP_KERNEL::NORM_TETRA4));
+ MEDCouplingAutoRefCountObjectPtr<MEDCoupling1SGTUMesh> ret0(MEDCoupling1SGTUMesh::New(getName(),INTERP_KERNEL::NORM_TETRA4));
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret(DataArrayInt::New()); ret->alloc(nbOfCells,1);
int *retPt(ret->getPointer());
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newConn(DataArrayInt::New()); newConn->alloc(0,1);
{
public:
MEDCOUPLING_EXPORT static MEDCouplingUMesh *New();
- MEDCOUPLING_EXPORT static MEDCouplingUMesh *New(const char *meshName, int meshDim);
+ MEDCOUPLING_EXPORT static MEDCouplingUMesh *New(const std::string& meshName, int meshDim);
MEDCOUPLING_EXPORT MEDCouplingMesh *deepCpy() const;
MEDCOUPLING_EXPORT MEDCouplingUMesh *clone(bool recDeepCpy) const;
MEDCOUPLING_EXPORT MEDCouplingPointSet *deepCpyConnectivityOnly() const;
static void IntersectDescending2DMeshes(const MEDCouplingUMesh *m1, const MEDCouplingUMesh *m2, double eps,
std::vector< std::vector<int> >& intersectEdge1, std::vector< std::vector<int> >& colinear2, std::vector< std::vector<int> >& subDiv2,
MEDCouplingUMesh *& m1Desc, DataArrayInt *&desc1, DataArrayInt *&descIndx1, DataArrayInt *&revDesc1, DataArrayInt *&revDescIndx1,
- MEDCouplingUMesh *& m2Desc, DataArrayInt *&desc2, DataArrayInt *&descIndx2, DataArrayInt *&revDesc2, DataArrayInt *&revDescIndx2,
- std::vector<double>& addCoo) throw(INTERP_KERNEL::Exception);
+ std::vector<double>& addCoo,
+ MEDCouplingUMesh *& m2Desc, DataArrayInt *&desc2, DataArrayInt *&descIndx2, DataArrayInt *&revDesc2, DataArrayInt *&revDescIndx2)
+ throw(INTERP_KERNEL::Exception);
static void BuildIntersectEdges(const MEDCouplingUMesh *m1, const MEDCouplingUMesh *m2, const std::vector<double>& addCoo, const std::vector< std::vector<int> >& subDiv, std::vector< std::vector<int> >& intersectEdge);
static void BuildIntersecting2DCellsFromEdges(double eps, const MEDCouplingUMesh *m1, const int *desc1, const int *descIndx1, const std::vector<std::vector<int> >& intesctEdges1, const std::vector< std::vector<int> >& colinear2,
const MEDCouplingUMesh *m2, const int *desc2, const int *descIndx2, const std::vector<std::vector<int> >& intesctEdges2,
std::copy(a2Data,a2Data+6,a2->getPointer());
//
targetMesh->setCoordsAt(0,a1);
- targetMesh->setCoordsAt(2,a2);
+ targetMesh->setCoordsAt(1,a2);
//
a1->decrRef();
a2->decrRef();
std::string MEDCouplingCorbaServBasicsTest::buildFileNameForIOR()
{
- std::string ret;
- ret+=getenv("TMP");
- ret+="/entryPointMEDCouplingCorba.ior";
+ std::string tmpdir;
+ if (getenv("TMP"))
+ tmpdir = getenv("TMP");
+ if (tmpdir == "")
+ tmpdir = "/tmp";
+
+ std::string username;
+ if ( getenv("USERNAME") )
+ username = std::string(getenv("USERNAME"))+"_";
+ else if ( getenv("USER") )
+ username = std::string(getenv("USER"))+"_";
+
+ std::string ret = tmpdir+"/"+username+"entryPointMEDCouplingCorba.ior";
return ret;
}
}
a2.setInfoOnComponent(0,"SmthZ");
#
targetMesh.setCoordsAt(0,a1);
- targetMesh.setCoordsAt(2,a2);
+ targetMesh.setCoordsAt(1,a2);
#
#
targetMesh.checkCoherency();
return ret;
def buildFileNameForIOR(self):
- ret=os.getenv("TMP");
- ret+="/entryPointMEDCouplingCorba.ior";
+ tmpdir=os.getenv("TMP", "/tmp");
+ username="";
+ if os.getenv("USERNAME"):
+ username = os.getenv("USERNAME")+"_";
+ elif os.getenv("USER"):
+ username = os.getenv("USER")+"_";
+ ret=tmpdir+"/"+username+"entryPointMEDCouplingCorba.ior";
return ret;
pass
self.assertEqual(expected2,d2.getValues())
pass
+ def testSwig2Intersect2DMeshesQuadra1(self):
+ import cmath
+ def createDiagCircle(lX, lY, R, cells=[0,1]):
+ """ A circle in a square box, cut along the diagonal.
+ """
+ c = []
+ for i in range(8):
+ c.append(cmath.rect(R, i*pi/4))
+
+ coords = [0.0,0.0, c[3].real,c[3].imag, -lX/2.0, lY/2.0,
+ 0.0, lY/2.0, lX/2.0,lY/2.0, lX/2.0,0.0,
+ # 6 7 8
+ lX/2.0,-lY/2.0, c[7].real,c[7].imag, c[1].real,c[1].imag,
+ # 9 10 11
+ c[5].real,c[5].imag, -lX/2.0,-lY/2.0, 0.0, -lY/2.0,
+ # 12 13 14
+ -lX/2.0,0.0, 0.0,0.0, 0.0, 0.0]
+ # Points 13 (reps. 14) are average of points (6,7) (resp (1,2))
+ coords[13*2] = 0.5*(coords[6*2]+coords[7*2])
+ coords[13*2+1] = 0.5*(coords[6*2+1]+coords[7*2+1])
+ coords[14*2] = 0.5*(coords[1*2]+coords[2*2])
+ coords[14*2+1] = 0.5*(coords[1*2+1]+coords[2*2+1])
+ connec = [1,7,8,0] # half circle up right
+ connec3 = [6,7,1,2,4,13,8,14,3,5]
+
+ baseMesh = MEDCouplingUMesh.New("box_circle", 2)
+ baseMesh.allocateCells(2)
+ meshCoords = DataArrayDouble.New(coords, len(coords)/2, 2)
+ meshCoords.setInfoOnComponents(["X [au]", "Y [au]"])
+ baseMesh.setCoords(meshCoords)
+
+ if 0 in cells:
+ baseMesh.insertNextCell(NORM_QPOLYG, connec)
+ if 1 in cells:
+ baseMesh.insertNextCell(NORM_QPOLYG, connec3)
+ baseMesh.finishInsertingCells()
+ baseMesh.checkCoherency()
+ return baseMesh
+
+ eps = 1.0e-7
+ m1 = createDiagCircle(1.0, 1.0, 0.5*0.90, cells=[0,1])
+ m2 = createDiagCircle(1.0, 1.0, 0.5*0.95, cells=[0])
+ m3, _, _= MEDCouplingUMesh.Intersect2DMeshes(m1, m2, eps)
+ m3.mergeNodes(eps)
+ m3.convertDegeneratedCells()
+ m3.zipCoords()
+ m4 = m3.deepCpy()
+ m5, _, _ = MEDCouplingUMesh.Intersect2DMeshes(m3, m4, eps)
+ m5.mergeNodes(eps)
+ # Check coordinates:
+ self.assertTrue(m3.getCoords().isEqual(m5.getCoords(), eps))
+
def testDAIBuildUnique1(self):
d=DataArrayInt([1,2,2,3,3,3,3,4,5,5,7,7,7,19])
e=d.buildUnique()
self.assertTrue(da.getIdsEqualTuple(2).isEqual(da.getIdsEqual(2)))
pass
+ def testSwig2GaussNEStaticInfo1(self):
+ self.assertTrue(DataArrayDouble(MEDCouplingFieldDiscretizationGaussNE.GetWeightArrayFromGeometricType(NORM_TRI3)).isEqual(DataArrayDouble([0.16666666666666666,0.16666666666666666,0.16666666666666666]),1e-12))
+ self.assertTrue(DataArrayDouble(MEDCouplingFieldDiscretizationGaussNE.GetRefCoordsFromGeometricType(NORM_TRI3)).isEqual(DataArrayDouble([0.,0.,1.,0.,0.,1.]),1e-12))
+ self.assertTrue(DataArrayDouble(MEDCouplingFieldDiscretizationGaussNE.GetLocsFromGeometricType(NORM_TRI3)).isEqual(DataArrayDouble([0.16666666666666666,0.16666666666666666,0.6666666666666667,0.16666666666666666,0.16666666666666666,0.6666666666666667]),1e-12))
+ pass
+
+ def testSwigReverseNodalConnOnStructuredMesh(self):
+ # 1D - standard
+ c=MEDCouplingCMesh() ; arr=DataArrayDouble(10) ; arr.iota()
+ c.setCoordsAt(0,arr)
+ rn,rni=c.getReverseNodalConnectivity()
+ rn2,rni2=c.buildUnstructured().getReverseNodalConnectivity()
+ self.assertTrue(rn.isEqual(DataArrayInt([0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8])))
+ self.assertTrue(rni.isEqual(DataArrayInt([0,1,3,5,7,9,11,13,15,17,18])))
+ self.assertTrue(rn.isEqual(rn2)) ; self.assertTrue(rni.isEqual(rni2))
+ # 1D - limit
+ c=MEDCouplingCMesh() ; arr=DataArrayDouble(1) ; arr.iota()
+ c.setCoordsAt(0,arr)
+ rn,rni=c.getReverseNodalConnectivity()
+ rn2,rni2=c.buildUnstructured().getReverseNodalConnectivity()
+ self.assertTrue(rn.isEqual(DataArrayInt([0])))
+ self.assertTrue(rni.isEqual(DataArrayInt([0,1])))
+ self.assertTrue(rn.isEqual(rn2)) ; self.assertTrue(rni.isEqual(rni2))
+ # 1D - limit
+ c=MEDCouplingCMesh() ; arr=DataArrayDouble(0) ; arr.iota()
+ c.setCoordsAt(0,arr)
+ rn,rni=c.getReverseNodalConnectivity()
+ rn.isEqual(DataArrayInt([]))
+ rni.isEqual(DataArrayInt([0]))
+ # 2D - standard
+ c=MEDCouplingCMesh() ; arr=DataArrayDouble(5) ; arr.iota() ; arr2=DataArrayDouble(4) ; arr.iota()
+ c.setCoords(arr,arr2)
+ rn,rni=c.getReverseNodalConnectivity()
+ rn2,rni2=c.buildUnstructured().getReverseNodalConnectivity()
+ self.assertTrue(rn.isEqual(DataArrayInt([0,0,1,1,2,2,3,3,0,4,0,1,4,5,1,2,5,6,2,3,6,7,3,7,4,8,4,5,8,9,5,6,9,10,6,7,10,11,7,11,8,8,9,9,10,10,11,11])))
+ self.assertTrue(rni.isEqual(DataArrayInt([0,1,3,5,7,8,10,14,18,22,24,26,30,34,38,40,41,43,45,47,48])))
+ self.assertTrue(rn.isEqual(rn2)) ; self.assertTrue(rni.isEqual(rni2))
+ # 2D - limit
+ c=MEDCouplingCMesh() ; arr=DataArrayDouble(10) ; arr.iota() ; arr2=DataArrayDouble(1) ; arr.iota()
+ c.setCoords(arr,arr2)
+ rn,rni=c.getReverseNodalConnectivity()
+ self.assertTrue(rn.isEqual(DataArrayInt([0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8])))
+ self.assertTrue(rni.isEqual(DataArrayInt([0,1,3,5,7,9,11,13,15,17,18])))
+ # 2D - limit
+ c=MEDCouplingCMesh() ; arr=DataArrayDouble(10) ; arr.iota() ; arr2=DataArrayDouble(1) ; arr.iota()
+ c.setCoords(arr2,arr)
+ rn,rni=c.getReverseNodalConnectivity()
+ self.assertTrue(rn.isEqual(DataArrayInt([0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8])))
+ self.assertTrue(rni.isEqual(DataArrayInt([0,1,3,5,7,9,11,13,15,17,18])))
+ # 3D - standard
+ c=MEDCouplingCMesh() ; arr0=DataArrayDouble(5) ; arr0.iota() ; arr1=DataArrayDouble(3) ; arr1.iota() ; arr2=DataArrayDouble(4) ; arr2.iota()
+ c.setCoords(arr0,arr1,arr2)
+ rn,rni=c.getReverseNodalConnectivity()
+ self.assertTrue(rn.isEqual(DataArrayInt([0,0,1,1,2,2,3,3,0,4,0,1,4,5,1,2,5,6,2,3,6,7,3,7,4,4,5,5,6,6,7,7,0,8,0,1,8,9,1,2,9,10,2,3,10,11,3,11,0,4,8,12,0,1,4,5,8,9,12,13,1,2,5,6,9,10,13,14,2,3,6,7,10,11,14,15,3,7,11,15,4,12,4,5,12,13,5,6,13,14,6,7,14,15,7,15,8,16,8,9,16,17,9,10,17,18,10,11,18,19,11,19,8,12,16,20,8,9,12,13,16,17,20,21,9,10,13,14,17,18,21,22,10,11,14,15,18,19,22,23,11,15,19,23,12,20,12,13,20,21,13,14,21,22,14,15,22,23,15,23,16,16,17,17,18,18,19,19,16,20,16,17,20,21,17,18,21,22,18,19,22,23,19,23,20,20,21,21,22,22,23,23])))
+ self.assertTrue(rni.isEqual(DataArrayInt([0,1,3,5,7,8,10,14,18,22,24,25,27,29,31,32,34,38,42,46,48,52,60,68,76,80,82,86,90,94,96,98,102,106,110,112,116,124,132,140,144,146,150,154,158,160,161,163,165,167,168,170,174,178,182,184,185,187,189,191,192])))
+ rn2,rni2=c.buildUnstructured().getReverseNodalConnectivity()
+ self.assertTrue(rn.isEqual(rn2)) ; self.assertTrue(rni.isEqual(rni2))
+ pass
+
+ def testSwig2CellToNodeDiscretization1(self):
+ m=MEDCouplingCMesh() ; arr0=DataArrayDouble(5) ; arr0.iota() ; arr1=DataArrayDouble(4) ; arr1.iota() ; m.setCoords(arr0,arr1)
+ f=MEDCouplingFieldDouble(ON_CELLS) ; f.setMesh(m) ; f.setTime(1.1,5,6)
+ arr=DataArrayDouble(12) ; arr.iota()
+ arr=DataArrayDouble.Meld(arr,arr+100.) ; arr.setInfoOnComponents(["aaa","bbb"])
+ f.setArray(arr)
+ f.checkCoherency()
+ #
+ ref=DataArrayDouble([0.,0.5,1.5,2.5,3.,2.,2.5,3.5,4.5,5.,6.,6.5,7.5,8.5,9.,8.,8.5,9.5,10.5,11.])
+ ref=DataArrayDouble.Meld(ref,ref+100.) ; ref.setInfoOnComponents(["aaa","bbb"])
+ f2=f.cellToNodeDiscretization()
+ f2.checkCoherency()
+ self.assertEqual(f2.getTime()[1:],[5,6])
+ self.assertAlmostEqual(f2.getTime()[0],1.1,15)
+ self.assertEqual(f2.getMesh().getHiddenCppPointer(),m.getHiddenCppPointer())
+ self.assertTrue(f2.getArray().isEqual(ref,1e-12))
+ rn,rni=m.getReverseNodalConnectivity()
+ rni2=(rni.deltaShiftIndex()).convertToDblArr()
+ arr2=(f.getArray()[rn]).accumulatePerChunck(rni)/rni2
+ self.assertTrue(f2.getArray().isEqual(arr2,1e-12))
+ del f2
+ #
+ u=m.buildUnstructured() ; f.setMesh(u) ; del m
+ f3=f.cellToNodeDiscretization()
+ f3.checkCoherency()
+ self.assertEqual(f3.getTime()[1:],[5,6])
+ self.assertAlmostEqual(f3.getTime()[0],1.1,15)
+ self.assertEqual(f3.getMesh().getHiddenCppPointer(),u.getHiddenCppPointer())
+ self.assertTrue(f3.getArray().isEqual(ref,1e-12))
+ pass
+
+ def testSwig2GetMeshSpaceDimensionCMesh1(self):
+ c=MEDCouplingCMesh()
+ arr0=DataArrayDouble([0,1,2])
+ arr1=DataArrayDouble([0])
+ c.setCoords(arr0,arr0,arr0)
+ self.assertEqual(c.getMeshDimension(),3)
+ self.assertEqual(c.getSpaceDimension(),3)
+ #
+ c.setCoords(arr0,arr0,arr1)
+ self.assertEqual(c.getMeshDimension(),2)
+ self.assertEqual(c.getSpaceDimension(),3)
+ #
+ c.setCoords(arr0,arr0)
+ self.assertEqual(c.getMeshDimension(),2)
+ self.assertEqual(c.getSpaceDimension(),2)
+ #
+ c.setCoords(arr0,arr1)
+ self.assertEqual(c.getMeshDimension(),1)
+ self.assertEqual(c.getSpaceDimension(),2)
+ #
+ c.setCoords(arr0)
+ self.assertEqual(c.getMeshDimension(),1)
+ self.assertEqual(c.getSpaceDimension(),1)
+ #
+ c.setCoords(arr1)
+ self.assertEqual(c.getMeshDimension(),0)
+ self.assertEqual(c.getSpaceDimension(),1)
+ pass
+
def setUp(self):
pass
pass
-unittest.main()
+if __name__ == '__main__':
+ unittest.main()
%newobject ParaMEDMEM::MEDCouplingFieldDouble::deepCpy;
%newobject ParaMEDMEM::MEDCouplingFieldDouble::buildNewTimeReprFromThis;
%newobject ParaMEDMEM::MEDCouplingFieldDouble::nodeToCellDiscretization;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::cellToNodeDiscretization;
%newobject ParaMEDMEM::MEDCouplingFieldDouble::getValueOnMulti;
%newobject ParaMEDMEM::MEDCouplingFieldTemplate::New;
%newobject ParaMEDMEM::MEDCouplingMesh::deepCpy;
class MEDCouplingMesh : public RefCountObject, public TimeLabel
{
public:
- void setName(const char *name);
+ void setName(const std::string& name);
std::string getName() const;
- void setDescription(const char *descr);
+ void setDescription(const std::string& descr);
std::string getDescription() const;
void setTime(double val, int iteration, int order);
- void setTimeUnit(const char *unit);
- const char *getTimeUnit() const;
+ void setTimeUnit(const std::string& unit);
+ std::string getTimeUnit() const;
virtual MEDCouplingMeshType getType() const throw(INTERP_KERNEL::Exception);
bool isStructured() const throw(INTERP_KERNEL::Exception);
virtual MEDCouplingMesh *deepCpy() const;
virtual INTERP_KERNEL::NormalizedCellType getTypeOfCell(int cellId) const throw(INTERP_KERNEL::Exception);
virtual std::string simpleRepr() const throw(INTERP_KERNEL::Exception);
virtual std::string advancedRepr() const throw(INTERP_KERNEL::Exception);
- void writeVTK(const char *fileName, bool isBinary=true) const throw(INTERP_KERNEL::Exception);
+ void writeVTK(const std::string& fileName, bool isBinary=true) const throw(INTERP_KERNEL::Exception);
// tools
virtual MEDCouplingFieldDouble *getMeasureField(bool isAbs) const throw(INTERP_KERNEL::Exception);
virtual MEDCouplingFieldDouble *getMeasureFieldOnNode(bool isAbs) const throw(INTERP_KERNEL::Exception);
- virtual MEDCouplingFieldDouble *fillFromAnalytic(TypeOfField t, int nbOfComp, const char *func) const throw(INTERP_KERNEL::Exception);
- virtual MEDCouplingFieldDouble *fillFromAnalytic2(TypeOfField t, int nbOfComp, const char *func) const throw(INTERP_KERNEL::Exception);
- virtual MEDCouplingFieldDouble *fillFromAnalytic3(TypeOfField t, int nbOfComp, const std::vector<std::string>& varsOrder, const char *func) const throw(INTERP_KERNEL::Exception);
+ virtual MEDCouplingFieldDouble *fillFromAnalytic(TypeOfField t, int nbOfComp, const std::string& func) const throw(INTERP_KERNEL::Exception);
+ virtual MEDCouplingFieldDouble *fillFromAnalytic2(TypeOfField t, int nbOfComp, const std::string& func) const throw(INTERP_KERNEL::Exception);
+ virtual MEDCouplingFieldDouble *fillFromAnalytic3(TypeOfField t, int nbOfComp, const std::vector<std::string>& varsOrder, const std::string& func) const throw(INTERP_KERNEL::Exception);
virtual MEDCouplingFieldDouble *buildOrthogonalField() const throw(INTERP_KERNEL::Exception);
virtual MEDCouplingUMesh *buildUnstructured() const throw(INTERP_KERNEL::Exception);
virtual MEDCouplingMesh *mergeMyselfWith(const MEDCouplingMesh *other) const throw(INTERP_KERNEL::Exception);
return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 );
}
+ virtual PyObject *getReverseNodalConnectivity() const throw(INTERP_KERNEL::Exception)
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> d0=DataArrayInt::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> d1=DataArrayInt::New();
+ self->getReverseNodalConnectivity(d0,d1);
+ PyObject *ret=PyTuple_New(2);
+ PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(d0.retn()),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(d1.retn()),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ return ret;
+ }
+
void renumberCells(PyObject *li, bool check=true) throw(INTERP_KERNEL::Exception)
{
int sw,sz(-1);
}
}
- virtual PyObject *getReverseNodalConnectivity() const throw(INTERP_KERNEL::Exception)
- {
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> d0=DataArrayInt::New();
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> d1=DataArrayInt::New();
- self->getReverseNodalConnectivity(d0,d1);
- PyObject *ret=PyTuple_New(2);
- PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(d0.retn()),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
- PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(d1.retn()),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
- return ret;
- }
-
virtual PyObject *findCommonCells(int compType, int startCellId=0) const throw(INTERP_KERNEL::Exception)
{
DataArrayInt *v0=0,*v1=0;
MEDCouplingUMesh *explode3DMeshTo1D(DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *revDesc, DataArrayInt *revDescIndx) const throw(INTERP_KERNEL::Exception);
void orientCorrectlyPolyhedrons() throw(INTERP_KERNEL::Exception);
bool isPresenceOfQuadratic() const throw(INTERP_KERNEL::Exception);
+ bool isFullyQuadratic() const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *buildDirectionVectorField() const throw(INTERP_KERNEL::Exception);
bool isContiguous1D() const throw(INTERP_KERNEL::Exception);
void tessellate2D(double eps) throw(INTERP_KERNEL::Exception);
class MEDCoupling1GTUMesh : public ParaMEDMEM::MEDCouplingPointSet
{
public:
- static MEDCoupling1GTUMesh *New(const char *name, INTERP_KERNEL::NormalizedCellType type) throw(INTERP_KERNEL::Exception);
+ static MEDCoupling1GTUMesh *New(const std::string& name, INTERP_KERNEL::NormalizedCellType type) throw(INTERP_KERNEL::Exception);
static MEDCoupling1GTUMesh *New(const MEDCouplingUMesh *m) throw(INTERP_KERNEL::Exception);
INTERP_KERNEL::NormalizedCellType getCellModelEnum() const throw(INTERP_KERNEL::Exception);
int getNodalConnectivityLength() const throw(INTERP_KERNEL::Exception);
class MEDCoupling1SGTUMesh : public ParaMEDMEM::MEDCoupling1GTUMesh
{
public:
- static MEDCoupling1SGTUMesh *New(const char *name, INTERP_KERNEL::NormalizedCellType type) throw(INTERP_KERNEL::Exception);
+ static MEDCoupling1SGTUMesh *New(const std::string& name, INTERP_KERNEL::NormalizedCellType type) throw(INTERP_KERNEL::Exception);
static MEDCoupling1SGTUMesh *New(const MEDCouplingUMesh *m) throw(INTERP_KERNEL::Exception);
void setNodalConnectivity(DataArrayInt *nodalConn) throw(INTERP_KERNEL::Exception);
int getNumberOfNodesPerCell() const throw(INTERP_KERNEL::Exception);
DataArrayInt *sortHexa8EachOther() throw(INTERP_KERNEL::Exception);
%extend
{
- MEDCoupling1SGTUMesh(const char *name, INTERP_KERNEL::NormalizedCellType type) throw(INTERP_KERNEL::Exception)
+ MEDCoupling1SGTUMesh(const std::string& name, INTERP_KERNEL::NormalizedCellType type) throw(INTERP_KERNEL::Exception)
{
return MEDCoupling1SGTUMesh::New(name,type);
}
class MEDCoupling1DGTUMesh : public ParaMEDMEM::MEDCoupling1GTUMesh
{
public:
- static MEDCoupling1DGTUMesh *New(const char *name, INTERP_KERNEL::NormalizedCellType type) throw(INTERP_KERNEL::Exception);
+ static MEDCoupling1DGTUMesh *New(const std::string& name, INTERP_KERNEL::NormalizedCellType type) throw(INTERP_KERNEL::Exception);
static MEDCoupling1DGTUMesh *New(const MEDCouplingUMesh *m) throw(INTERP_KERNEL::Exception);
void setNodalConnectivity(DataArrayInt *nodalConn, DataArrayInt *nodalConnIndex) throw(INTERP_KERNEL::Exception);
MEDCoupling1DGTUMesh *buildSetInstanceFromThis(int spaceDim) const throw(INTERP_KERNEL::Exception);
bool isPacked() const throw(INTERP_KERNEL::Exception);
%extend
{
- MEDCoupling1DGTUMesh(const char *name, INTERP_KERNEL::NormalizedCellType type) throw(INTERP_KERNEL::Exception)
+ MEDCoupling1DGTUMesh(const std::string& name, INTERP_KERNEL::NormalizedCellType type) throw(INTERP_KERNEL::Exception)
{
return MEDCoupling1DGTUMesh::New(name,type);
}
{
public:
static MEDCouplingCMesh *New();
- static MEDCouplingCMesh *New(const char *meshName);
+ static MEDCouplingCMesh *New(const std::string& meshName);
MEDCouplingCMesh *clone(bool recDeepCpy) const;
void setCoords(const DataArrayDouble *coordsX,
const DataArrayDouble *coordsY=0,
{
return MEDCouplingCMesh::New();
}
- MEDCouplingCMesh(const char *meshName)
+ MEDCouplingCMesh(const std::string& meshName)
{
return MEDCouplingCMesh::New(meshName);
}
{
public:
static MEDCouplingCurveLinearMesh *New();
- static MEDCouplingCurveLinearMesh *New(const char *meshName);
+ static MEDCouplingCurveLinearMesh *New(const std::string& meshName);
MEDCouplingCurveLinearMesh *clone(bool recDeepCpy) const;
void setCoords(const DataArrayDouble *coords) throw(INTERP_KERNEL::Exception);
%extend {
{
return MEDCouplingCurveLinearMesh::New();
}
- MEDCouplingCurveLinearMesh(const char *meshName)
+ MEDCouplingCurveLinearMesh(const std::string& meshName)
{
return MEDCouplingCurveLinearMesh::New(meshName);
}
public:
static MEDCouplingFieldDouble *New(TypeOfField type, TypeOfTimeDiscretization td=ONE_TIME);
static MEDCouplingFieldDouble *New(const MEDCouplingFieldTemplate& ft, TypeOfTimeDiscretization td=ONE_TIME);
- void setTimeUnit(const char *unit);
- const char *getTimeUnit() const;
+ void setTimeUnit(const std::string& unit);
+ std::string getTimeUnit() const;
void synchronizeTimeWithSupport() throw(INTERP_KERNEL::Exception);
void copyTinyAttrFrom(const MEDCouplingFieldDouble *other) throw(INTERP_KERNEL::Exception);
void copyAllTinyAttrFrom(const MEDCouplingFieldDouble *other) throw(INTERP_KERNEL::Exception);
std::string simpleRepr() const throw(INTERP_KERNEL::Exception);
std::string advancedRepr() const throw(INTERP_KERNEL::Exception);
- void writeVTK(const char *fileName, bool isBinary=true) const throw(INTERP_KERNEL::Exception);
+ void writeVTK(const std::string& fileName, bool isBinary=true) const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *clone(bool recDeepCpy) const;
MEDCouplingFieldDouble *cloneWithMesh(bool recDeepCpy) const;
MEDCouplingFieldDouble *deepCpy() const;
MEDCouplingFieldDouble *buildNewTimeReprFromThis(TypeOfTimeDiscretization td, bool deepCpy) const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *nodeToCellDiscretization() const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *cellToNodeDiscretization() const throw(INTERP_KERNEL::Exception);
TypeOfTimeDiscretization getTimeDiscretization() const throw(INTERP_KERNEL::Exception);
double getIJ(int tupleId, int compoId) const throw(INTERP_KERNEL::Exception);
double getIJK(int cellId, int nodeIdInCell, int compoId) const throw(INTERP_KERNEL::Exception);
void changeNbOfComponents(int newNbOfComp, double dftValue=0.) throw(INTERP_KERNEL::Exception);
void sortPerTuple(bool asc) throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble &operator=(double value) throw(INTERP_KERNEL::Exception);
- void fillFromAnalytic(int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception);
- void fillFromAnalytic2(int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception);
- void fillFromAnalytic3(int nbOfComp, const std::vector<std::string>& varsOrder, const char *func) throw(INTERP_KERNEL::Exception);
- void applyFunc(int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception);
- void applyFunc2(int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception);
- void applyFunc3(int nbOfComp, const std::vector<std::string>& varsOrder, const char *func) throw(INTERP_KERNEL::Exception);
+ void fillFromAnalytic(int nbOfComp, const std::string& func) throw(INTERP_KERNEL::Exception);
+ void fillFromAnalytic2(int nbOfComp, const std::string& func) throw(INTERP_KERNEL::Exception);
+ void fillFromAnalytic3(int nbOfComp, const std::vector<std::string>& varsOrder, const std::string& func) throw(INTERP_KERNEL::Exception);
+ void applyFunc(int nbOfComp, const std::string& func) throw(INTERP_KERNEL::Exception);
+ void applyFunc2(int nbOfComp, const std::string& func) throw(INTERP_KERNEL::Exception);
+ void applyFunc3(int nbOfComp, const std::vector<std::string>& varsOrder, const std::string& func) throw(INTERP_KERNEL::Exception);
void applyFunc(int nbOfComp, double val) throw(INTERP_KERNEL::Exception);
- void applyFunc(const char *func) throw(INTERP_KERNEL::Exception);
- void applyFuncFast32(const char *func) throw(INTERP_KERNEL::Exception);
- void applyFuncFast64(const char *func) throw(INTERP_KERNEL::Exception);
+ void applyFunc(const std::string& func) throw(INTERP_KERNEL::Exception);
+ void applyFuncFast32(const std::string& func) throw(INTERP_KERNEL::Exception);
+ void applyFuncFast64(const std::string& func) throw(INTERP_KERNEL::Exception);
double accumulate(int compId) const throw(INTERP_KERNEL::Exception);
double getMaxValue() const throw(INTERP_KERNEL::Exception);
double getMinValue() const throw(INTERP_KERNEL::Exception);
static MEDCouplingFieldDiscretization *New(TypeOfField type) throw(INTERP_KERNEL::Exception);
double getPrecision() const throw(INTERP_KERNEL::Exception);
void setPrecision(double val) throw(INTERP_KERNEL::Exception);
- static TypeOfField GetTypeOfFieldFromStringRepr(const char *repr) throw(INTERP_KERNEL::Exception);
+ static TypeOfField GetTypeOfFieldFromStringRepr(const std::string& repr) throw(INTERP_KERNEL::Exception);
virtual TypeOfField getEnum() const throw(INTERP_KERNEL::Exception);
virtual bool isEqual(const MEDCouplingFieldDiscretization *other, double eps) const throw(INTERP_KERNEL::Exception);
virtual bool isEqualIfNotWhy(const MEDCouplingFieldDiscretization *other, double eps, std::string& reason) const throw(INTERP_KERNEL::Exception);
class MEDCouplingFieldDiscretizationGaussNE : public MEDCouplingFieldDiscretization
{
+ public:
+ %extend
+ {
+ static PyObject *GetWeightArrayFromGeometricType(INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception)
+ {
+ std::size_t sz(0);
+ const double *ret(MEDCouplingFieldDiscretizationGaussNE::GetWeightArrayFromGeometricType(geoType,sz));
+ return convertDblArrToPyList(ret,sz);
+ }
+
+ static PyObject *GetRefCoordsFromGeometricType(INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception)
+ {
+ std::size_t sz(0);
+ const double *ret(MEDCouplingFieldDiscretizationGaussNE::GetRefCoordsFromGeometricType(geoType,sz));
+ return convertDblArrToPyList(ret,sz);
+ }
+
+ static PyObject *GetLocsFromGeometricType(INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception)
+ {
+ std::size_t sz(0);
+ const double *ret(MEDCouplingFieldDiscretizationGaussNE::GetLocsFromGeometricType(geoType,sz));
+ return convertDblArrToPyList(ret,sz);
+ }
+ }
};
class MEDCouplingFieldDiscretizationKriging : public MEDCouplingFieldDiscretizationOnNodes
class DataArray : public RefCountObject, public TimeLabel
{
public:
- void setName(const char *name);
+ void setName(const std::string& name);
void copyStringInfoFrom(const DataArray& other) throw(INTERP_KERNEL::Exception);
void copyPartOfStringInfoFrom(const DataArray& other, const std::vector<int>& compoIds) throw(INTERP_KERNEL::Exception);
void copyPartOfStringInfoFrom2(const std::vector<int>& compoIds, const DataArray& other) throw(INTERP_KERNEL::Exception);
bool areInfoEqualsIfNotWhy(const DataArray& other, std::string& reason) const throw(INTERP_KERNEL::Exception);
bool areInfoEquals(const DataArray& other) const throw(INTERP_KERNEL::Exception);
- std::string cppRepr(const char *varName) const throw(INTERP_KERNEL::Exception);
+ std::string cppRepr(const std::string& varName) const throw(INTERP_KERNEL::Exception);
std::string getName() const;
void setInfoOnComponents(const std::vector<std::string>& info) throw(INTERP_KERNEL::Exception);
void setInfoAndChangeNbOfCompo(const std::vector<std::string>& info) throw(INTERP_KERNEL::Exception);
std::string getInfoOnComponent(int i) const throw(INTERP_KERNEL::Exception);
std::string getVarOnComponent(int i) const throw(INTERP_KERNEL::Exception);
std::string getUnitOnComponent(int i) const throw(INTERP_KERNEL::Exception);
- void setInfoOnComponent(int i, const char *info) throw(INTERP_KERNEL::Exception);
+ void setInfoOnComponent(int i, const std::string& info) throw(INTERP_KERNEL::Exception);
int getNumberOfComponents() const;
virtual void alloc(int nbOfTuple, int nbOfCompo=1) throw(INTERP_KERNEL::Exception);
virtual void reAlloc(int nbOfTuples) throw(INTERP_KERNEL::Exception);
virtual DataArray *deepCpy() const throw(INTERP_KERNEL::Exception);
virtual DataArray *selectByTupleId2(int bg, int end2, int step) const throw(INTERP_KERNEL::Exception);
virtual void rearrange(int newNbOfCompo) throw(INTERP_KERNEL::Exception);
- void checkNbOfTuples(int nbOfTuples, const char *msg) const throw(INTERP_KERNEL::Exception);
- void checkNbOfComps(int nbOfCompo, const char *msg) const throw(INTERP_KERNEL::Exception);
- void checkNbOfTuplesAndComp(const DataArray& other, const char *msg) const throw(INTERP_KERNEL::Exception);
- void checkNbOfTuplesAndComp(int nbOfTuples, int nbOfCompo, const char *msg) const throw(INTERP_KERNEL::Exception);
- void checkNbOfElems(std::size_t nbOfElems, const char *msg) const throw(INTERP_KERNEL::Exception);
- static int GetNumberOfItemGivenBES(int begin, int end, int step, const char *msg) throw(INTERP_KERNEL::Exception);
- static int GetNumberOfItemGivenBESRelative(int begin, int end, int step, const char *msg) throw(INTERP_KERNEL::Exception);
+ void checkNbOfTuples(int nbOfTuples, const std::string& msg) const throw(INTERP_KERNEL::Exception);
+ void checkNbOfComps(int nbOfCompo, const std::string& msg) const throw(INTERP_KERNEL::Exception);
+ void checkNbOfTuplesAndComp(const DataArray& other, const std::string& msg) const throw(INTERP_KERNEL::Exception);
+ void checkNbOfTuplesAndComp(int nbOfTuples, int nbOfCompo, const std::string& msg) const throw(INTERP_KERNEL::Exception);
+ void checkNbOfElems(std::size_t nbOfElems, const std::string& msg) const throw(INTERP_KERNEL::Exception);
+ static int GetNumberOfItemGivenBES(int begin, int end, int step, const std::string& msg) throw(INTERP_KERNEL::Exception);
+ static int GetNumberOfItemGivenBESRelative(int begin, int end, int step, const std::string& msg) throw(INTERP_KERNEL::Exception);
static int GetPosOfItemGivenBESRelativeNoThrow(int value, int begin, int end, int step) throw(INTERP_KERNEL::Exception);
static std::string GetVarNameFromInfo(const std::string& info) throw(INTERP_KERNEL::Exception);
static std::string GetUnitFromInfo(const std::string& info) throw(INTERP_KERNEL::Exception);
void applyRPow(double val) throw(INTERP_KERNEL::Exception);
DataArrayDouble *negate() const throw(INTERP_KERNEL::Exception);
DataArrayDouble *applyFunc(int nbOfComp, FunctionToEvaluate func) const throw(INTERP_KERNEL::Exception);
- DataArrayDouble *applyFunc(int nbOfComp, const char *func) const throw(INTERP_KERNEL::Exception);
- DataArrayDouble *applyFunc(const char *func) const throw(INTERP_KERNEL::Exception);
- DataArrayDouble *applyFunc2(int nbOfComp, const char *func) const throw(INTERP_KERNEL::Exception);
- DataArrayDouble *applyFunc3(int nbOfComp, const std::vector<std::string>& varsOrder, const char *func) const throw(INTERP_KERNEL::Exception);
- void applyFuncFast32(const char *func) throw(INTERP_KERNEL::Exception);
- void applyFuncFast64(const char *func) throw(INTERP_KERNEL::Exception);
+ DataArrayDouble *applyFunc(int nbOfComp, const std::string& func) const throw(INTERP_KERNEL::Exception);
+ DataArrayDouble *applyFunc(const std::string& func) const throw(INTERP_KERNEL::Exception);
+ DataArrayDouble *applyFunc2(int nbOfComp, const std::string& func) const throw(INTERP_KERNEL::Exception);
+ DataArrayDouble *applyFunc3(int nbOfComp, const std::vector<std::string>& varsOrder, const std::string& func) const throw(INTERP_KERNEL::Exception);
+ void applyFuncFast32(const std::string& func) throw(INTERP_KERNEL::Exception);
+ void applyFuncFast64(const std::string& func) throw(INTERP_KERNEL::Exception);
DataArrayInt *getIdsInRange(double vmin, double vmax) const throw(INTERP_KERNEL::Exception);
DataArrayInt *getIdsNotInRange(double vmin, double vmax) const throw(INTERP_KERNEL::Exception);
static DataArrayDouble *Aggregate(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception);
public:
MEDCouplingRemapper();
~MEDCouplingRemapper();
- int prepare(const MEDCouplingMesh *srcMesh, const MEDCouplingMesh *targetMesh, const char *method) throw(INTERP_KERNEL::Exception);
+ int prepare(const MEDCouplingMesh *srcMesh, const MEDCouplingMesh *targetMesh, const std::string& method) throw(INTERP_KERNEL::Exception);
int prepareEx(const MEDCouplingFieldTemplate *src, const MEDCouplingFieldTemplate *target) throw(INTERP_KERNEL::Exception);
void transfer(const MEDCouplingFieldDouble *srcField, MEDCouplingFieldDouble *targetField, double dftValue) throw(INTERP_KERNEL::Exception);
void partialTransfer(const MEDCouplingFieldDouble *srcField, MEDCouplingFieldDouble *targetField) throw(INTERP_KERNEL::Exception);
using namespace ParaMEDMEM;
-MEDFileData *MEDFileData::New(const char *fileName)
+MEDFileData *MEDFileData::New(const std::string& fileName)
{
return new MEDFileData(fileName);
}
return ret;
}
-bool MEDFileData::changeMeshName(const char *oldMeshName, const char *newMeshName)
+bool MEDFileData::changeMeshName(const std::string& oldMeshName, const std::string& newMeshName)
{
std::string oldName(oldMeshName);
std::vector< std::pair<std::string,std::string> > v(1);
MEDFileFields *fs=_fields;
if(fs)
for(std::size_t i=0;i<meshesImpacted.size();i++)
- fs->renumberEntitiesLyingOnMesh(meshesImpacted[i]->getName().c_str(),oldCodeOfMeshImpacted[i],newCodeOfMeshImpacted[i],renumParamsOfMeshImpacted[i]);
+ fs->renumberEntitiesLyingOnMesh(meshesImpacted[i]->getName(),oldCodeOfMeshImpacted[i],newCodeOfMeshImpacted[i],renumParamsOfMeshImpacted[i]);
}
return !meshesImpacted.empty();
}
{
}
-MEDFileData::MEDFileData(const char *fileName)
+MEDFileData::MEDFileData(const std::string& fileName)
try
{
_fields=MEDFileFields::New(fileName);
throw e;
}
-void MEDFileData::write(const char *fileName, int mode) const
+void MEDFileData::write(const std::string& fileName, int mode) const
{
med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod);
const MEDFileMeshes *ms=_meshes;
if(ms)
ms->write(fid);
class MEDFileData : public RefCountObject, public MEDFileWritable
{
public:
- MEDLOADER_EXPORT static MEDFileData *New(const char *fileName);
+ MEDLOADER_EXPORT static MEDFileData *New(const std::string& fileName);
MEDLOADER_EXPORT static MEDFileData *New();
MEDLOADER_EXPORT MEDFileData *deepCpy() const;
MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
MEDLOADER_EXPORT std::string simpleRepr() const;
//
MEDLOADER_EXPORT bool changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab);
- MEDLOADER_EXPORT bool changeMeshName(const char *oldMeshName, const char *newMeshName);
+ MEDLOADER_EXPORT bool changeMeshName(const std::string& oldMeshName, const std::string& newMeshName);
MEDLOADER_EXPORT bool unPolyzeMeshes();
//
- MEDLOADER_EXPORT void write(const char *fileName, int mode) const;
+ MEDLOADER_EXPORT void write(const std::string& fileName, int mode) const;
private:
MEDFileData();
- MEDFileData(const char *fileName);
+ MEDFileData(const std::string& fileName);
private:
MEDCouplingAutoRefCountObjectPtr<MEDFileFields> _fields;
MEDCouplingAutoRefCountObjectPtr<MEDFileMeshes> _meshes;
const char MEDFileField1TSWithoutSDA::TYPE_STR[]="FLOAT64";
const char MEDFileIntField1TSWithoutSDA::TYPE_STR[]="INT32";
-MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, const char *locName)
+MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, const std::string& locName)
{
return new MEDFileFieldLoc(fid,locName);
}
return new MEDFileFieldLoc(fid,id);
}
-MEDFileFieldLoc *MEDFileFieldLoc::New(const char *locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w)
+MEDFileFieldLoc *MEDFileFieldLoc::New(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w)
{
return new MEDFileFieldLoc(locName,geoType,refCoo,gsCoo,w);
}
-MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, const char *locName):_name(locName)
+MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, const std::string& locName):_name(locName)
{
med_geometry_type geotype;
med_geometry_type sectiongeotype;
int nsectionmeshcell;
INTERP_KERNEL::AutoPtr<char> geointerpname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
INTERP_KERNEL::AutoPtr<char> sectionmeshname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
- MEDlocalizationInfoByName(fid,locName,&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
+ MEDlocalizationInfoByName(fid,locName.c_str(),&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
_geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype)));
const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
_nb_node_per_cell=cm.getNumberOfNodes();
_ref_coo.resize(_dim*_nb_node_per_cell);
_gs_coo.resize(_dim*_nb_gauss_pt);
_w.resize(_nb_gauss_pt);
- MEDlocalizationRd(fid,locName,MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
+ MEDlocalizationRd(fid,locName.c_str(),MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
}
MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, int id)
MEDlocalizationRd(fid,locName,MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
}
-MEDFileFieldLoc::MEDFileFieldLoc(const char *locName, INTERP_KERNEL::NormalizedCellType geoType,
+MEDFileFieldLoc::MEDFileFieldLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType,
const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w):_name(locName),_geo_type(geoType),_ref_coo(refCoo),_gs_coo(gsCoo),
_w(w)
{
oss << "GaussPtsCoords="; std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," ")); oss << std::endl;
}
-void MEDFileFieldLoc::setName(const char *name)
+void MEDFileFieldLoc::setName(const std::string& name)
{
_name=name;
}
return _profile;
}
-void MEDFileFieldPerMeshPerTypePerDisc::setProfile(const char *newPflName)
+void MEDFileFieldPerMeshPerTypePerDisc::setProfile(const std::string& newPflName)
{
_profile=newPflName;
}
return _localization;
}
-void MEDFileFieldPerMeshPerTypePerDisc::setLocalization(const char *newLocName)
+void MEDFileFieldPerMeshPerTypePerDisc::setLocalization(const std::string& newLocName)
{
_localization=newLocName;
}
return false;
}
-bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
+bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
MEDFileFieldGlobsReal& glob)
{
if(_mesh_name!=meshName)
copyTinyInfoFrom(mesh);
}
-void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const char *pflName)
+void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
{
if(id>=(int)_pfls.size())
_pfls.resize(id+1);
_pfls[id]=DataArrayInt::New();
- int lgth=MEDprofileSizeByName(fid,pflName);
+ int lgth=MEDprofileSizeByName(fid,pflName.c_str());
_pfls[id]->setName(pflName);
_pfls[id]->alloc(lgth,1);
- MEDprofileRd(fid,pflName,_pfls[id]->getPointer());
+ MEDprofileRd(fid,pflName.c_str(),_pfls[id]->getPointer());
_pfls[id]->applyLin(1,-1,0);//Converting into C format
}
}
}
-MEDFileFieldGlobs *MEDFileFieldGlobs::New(const char *fname)
+MEDFileFieldGlobs *MEDFileFieldGlobs::New(const std::string& fname)
{
return new MEDFileFieldGlobs(fname);
}
return ret.retn();
}
-MEDFileFieldGlobs::MEDFileFieldGlobs(const char *fname):_file_name(fname)
+MEDFileFieldGlobs::MEDFileFieldGlobs(const std::string& fname):_file_name(fname)
{
}
}
}
-void MEDFileFieldGlobs::setFileName(const char *fileName)
+void MEDFileFieldGlobs::setFileName(const std::string& fileName)
{
_file_name=fileName;
}
return _locs[locId]->getNbOfGaussPtPerCell();
}
-const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const char *locName) const
+const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName) const
{
return getLocalizationFromId(getLocalizationId(locName));
}
class LocFinder
{
public:
- LocFinder(const char *loc):_loc(loc) { }
+ LocFinder(const std::string& loc):_loc(loc) { }
bool operator() (const MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
private:
- const char *_loc;
+ const std::string &_loc;
};
class PflFinder
};
}
-int MEDFileFieldGlobs::getLocalizationId(const char *loc) const
+int MEDFileFieldGlobs::getLocalizationId(const std::string& loc) const
{
std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),ParaMEDMEMImpl::LocFinder(loc));
if(it==_locs.end())
/*!
* The returned value is never null.
*/
-const DataArrayInt *MEDFileFieldGlobs::getProfile(const char *pflName) const
+const DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName) const
{
std::string pflNameCpp(pflName);
std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
return *_locs[locId];
}
-MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const char *locName)
+MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName)
{
return getLocalizationFromId(getLocalizationId(locName));
}
/*!
* The returned value is never null.
*/
-DataArrayInt *MEDFileFieldGlobs::getProfile(const char *pflName)
+DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName)
{
std::string pflNameCpp(pflName);
std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
return ret;
}
-bool MEDFileFieldGlobs::existsPfl(const char *pflName) const
+bool MEDFileFieldGlobs::existsPfl(const std::string& pflName) const
{
std::vector<std::string> v=getPfls();
std::string s(pflName);
return std::find(v.begin(),v.end(),s)!=v.end();
}
-bool MEDFileFieldGlobs::existsLoc(const char *locName) const
+bool MEDFileFieldGlobs::existsLoc(const std::string& locName) const
{
std::vector<std::string> v=getLocs();
std::string s(locName);
_pfls.push_back(pfl);
}
-void MEDFileFieldGlobs::appendLoc(const char *locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w)
+void MEDFileFieldGlobs::appendLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w)
{
std::string name(locName);
if(name.empty())
return CreateNewNameNotIn("NewLoc_",names);
}
-std::string MEDFileFieldGlobs::CreateNewNameNotIn(const char *prefix, const std::vector<std::string>& namesToAvoid)
+std::string MEDFileFieldGlobs::CreateNewNameNotIn(const std::string& prefix, const std::vector<std::string>& namesToAvoid)
{
for(std::size_t sz=0;sz<100000;sz++)
{
* Creates a MEDFileFieldGlobsReal on a given file name. Nothing is read here.
* \param [in] fname - the file name.
*/
-MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(const char *fname):_globals(MEDFileFieldGlobs::New(fname))
+MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(const std::string& fname):_globals(MEDFileFieldGlobs::New(fname))
{
}
contentNotNull()->checkGlobsLocsPartCoherency(getLocsReallyUsed());
}
-void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const char *pflName)
+void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
{
contentNotNull()->loadProfileInFile(fid,id,pflName);
}
* \param [in] pflName - the profile name of interest.
* \return bool - \c true if the profile named \a pflName exists.
*/
-bool MEDFileFieldGlobsReal::existsPfl(const char *pflName) const
+bool MEDFileFieldGlobsReal::existsPfl(const std::string& pflName) const
{
return contentNotNull()->existsPfl(pflName);
}
* \param [in] locName - the localization name of interest.
* \return bool - \c true if the localization named \a locName exists.
*/
-bool MEDFileFieldGlobsReal::existsLoc(const char *locName) const
+bool MEDFileFieldGlobsReal::existsLoc(const std::string& locName) const
{
return contentNotNull()->existsLoc(locName);
}
* Sets the name of a MED file.
* \param [inout] fileName - the file name.
*/
-void MEDFileFieldGlobsReal::setFileName(const char *fileName)
+void MEDFileFieldGlobsReal::setFileName(const std::string& fileName)
{
contentNotNull()->setFileName(fileName);
}
* \param [in] newName - a new name of the profile.
* \sa changePflsNames().
*/
-void MEDFileFieldGlobsReal::changePflName(const char *oldName, const char *newName)
+void MEDFileFieldGlobsReal::changePflName(const std::string& oldName, const std::string& newName)
{
std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
* \param [in] newName - a new name of the localization.
* \sa changeLocsNames().
*/
-void MEDFileFieldGlobsReal::changeLocName(const char *oldName, const char *newName)
+void MEDFileFieldGlobsReal::changeLocName(const std::string& oldName, const std::string& newName)
{
std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
* \return int - the id of the localization.
* \throw If there is no a localization named \a loc.
*/
-int MEDFileFieldGlobsReal::getLocalizationId(const char *loc) const
+int MEDFileFieldGlobsReal::getLocalizationId(const std::string& loc) const
{
return contentNotNull()->getLocalizationId(loc);
}
/*!
* Returns the name of the MED file.
- * \return const char * - the MED file name.
+ * \return const std::string& - the MED file name.
*/
-const char *MEDFileFieldGlobsReal::getFileName() const
+std::string MEDFileFieldGlobsReal::getFileName() const
{
return contentNotNull()->getFileName();
}
* \return const MEDFileFieldLoc& - the localization object having the name \a locName.
* \throw If there is no a localization named \a locName.
*/
-const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const char *locName) const
+const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName) const
{
return contentNotNull()->getLocalization(locName);
}
* \return const DataArrayInt * - the profile array having the name \a pflName.
* \throw If there is no a profile named \a pflName.
*/
-const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const char *pflName) const
+const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName) const
{
return contentNotNull()->getProfile(pflName);
}
* having the name \a locName.
* \throw If there is no a localization named \a locName.
*/
-MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const char *locName)
+MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName)
{
return contentNotNull()->getLocalization(locName);
}
* \return DataArrayInt * - a non-const pointer to the profile array having the name \a pflName.
* \throw If there is no a profile named \a pflName.
*/
-DataArrayInt *MEDFileFieldGlobsReal::getProfile(const char *pflName)
+DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName)
{
return contentNotNull()->getProfile(pflName);
}
* \throw If a localization with the name \a locName already exists but is
* different form the new one.
*/
-void MEDFileFieldGlobsReal::appendLoc(const char *locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w)
+void MEDFileFieldGlobsReal::appendLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w)
{
contentNotNull()->appendLoc(locName,geoType,refCoo,gsCoo,w);
}
{
}
-MEDFileFieldNameScope::MEDFileFieldNameScope(const char *fieldName):_name(fieldName)
+MEDFileFieldNameScope::MEDFileFieldNameScope(const std::string& fieldName):_name(fieldName)
{
}
* Sets name of \a this field
* \param [in] name - the new field name.
*/
-void MEDFileFieldNameScope::setName(const char *fieldName)
+void MEDFileFieldNameScope::setName(const std::string& fieldName)
{
_name=fieldName;
}
return _dt_unit;
}
-void MEDFileFieldNameScope::setDtUnit(const char *dtUnit)
+void MEDFileFieldNameScope::setDtUnit(const std::string& dtUnit)
{
_dt_unit=dtUnit;
}
return ret;
}
-MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA(const char *fieldName, int csit, int iteration, int order):MEDFileFieldNameScope(fieldName),_iteration(iteration),_order(order),_csit(csit),_nb_of_tuples_to_be_allocated(-2)
+MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order):MEDFileFieldNameScope(fieldName),_iteration(iteration),_order(order),_csit(csit),_nb_of_tuples_to_be_allocated(-2)
{
}
return _field_per_mesh[0]->getMeshName();
}
-void MEDFileAnyTypeField1TSWithoutSDA::setMeshName(const char *newMeshName)
+void MEDFileAnyTypeField1TSWithoutSDA::setMeshName(const std::string& newMeshName)
{
std::string oldName(getMeshName());
std::vector< std::pair<std::string,std::string> > v(1);
* Length of this and of nested sequences is the same as that of \a typesF.
* \throw If no field is lying on \a mname.
*/
-std::vector< std::vector< std::pair<int,int> > > MEDFileAnyTypeField1TSWithoutSDA::getFieldSplitedByType(const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
+std::vector< std::vector< std::pair<int,int> > > MEDFileAnyTypeField1TSWithoutSDA::getFieldSplitedByType(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
{
int meshId=0;
- if(mname)
+ if(!mname.empty())
meshId=getMeshIdFromMeshName(mname);
else
if(_field_per_mesh.empty())
* \return int - the maximal absolute dimension of elements \a this fields lies on.
* \throw If no field is lying on \a mname.
*/
-int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const char *mname, std::vector<int>& levs) const
+int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
{
levs.clear();
int meshId=getMeshIdFromMeshName(mname);
* \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
* \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
*/
-MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
+MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
{
int mid=getMeshIdFromMeshName(mName);
return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
* \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
* \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
*/
-const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
+const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
{
int mid=getMeshIdFromMeshName(mName);
return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
/*!
* \param [in] mName specifies the underlying mesh name. This value can be pointer 0 for users that do not deal with fields on multi mesh.
*/
-int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const char *mName) const
+int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const std::string& mName) const
{
if(_field_per_mesh.empty())
throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
- if(mName==0)
+ if(mName.empty())
return 0;
std::string mName2(mName);
int ret=0;
return sz;
}
-bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
+bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
MEDFileFieldGlobsReal& glob)
{
bool ret=false;
if(_nb_of_tuples_to_be_allocated>=0)
{
_nb_of_tuples_to_be_allocated=newLgth;
+ const DataArray *oldArr(getUndergroundDataArray());
+ if(oldArr)
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArray> newArr(createNewEmptyDataArrayInstance());
+ newArr->setInfoAndChangeNbOfCompo(oldArr->getInfoOnComponents());
+ setArray(newArr);
+ _nb_of_tuples_to_be_allocated=newLgth;//force the _nb_of_tuples_to_be_allocated because setArray has been used specialy
+ }
return ;
}
if(_nb_of_tuples_to_be_allocated==-1)
return ;
if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
{
- const DataArray *oldArr=getUndergroundDataArray();
+ const DataArray *oldArr(getUndergroundDataArray());
if(!oldArr || !oldArr->isAllocated())
throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 1 !");
- MEDCouplingAutoRefCountObjectPtr<DataArray> newArr=createNewEmptyDataArrayInstance();
+ MEDCouplingAutoRefCountObjectPtr<DataArray> newArr(createNewEmptyDataArrayInstance());
newArr->alloc(newLgth,getNumberOfComponents());
if(oldArr)
newArr->copyStringInfoFrom(*oldArr);
* \throw If no field of \a this is lying on the mesh \a mName.
* \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
*/
-MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const char *mName, int renumPol, const MEDFileFieldGlobsReal *glob, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
+MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
{
MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
- if(mName==0)
+ if(mName.empty())
mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
else
mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
* \throw If there are no mesh entities in the mesh.
* \throw If no field values of the given \a type are available.
*/
-MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const char *mName, int renumPol, const MEDFileFieldGlobsReal *glob, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
+MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
{
- MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
- if(mName==0)
+ MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
+ if(mName.empty())
mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
else
mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, const DataArrayInt *cellRenum, const DataArrayInt *nodeRenum, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
{
static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
- int meshId=getMeshIdFromMeshName(mesh->getName().c_str());
+ int meshId=getMeshIdFromMeshName(mesh->getName());
bool isPfl=false;
MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
switch(renumPol)
return code;
}
-MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const char *fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
+MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
{
return new MEDFileField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
}
* Length of this and of nested sequences is the same as that of \a typesF.
* \throw If no field is lying on \a mname.
*/
-std::vector< std::vector<DataArrayDouble *> > MEDFileField1TSWithoutSDA::getFieldSplitedByType2(const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
+std::vector< std::vector<DataArrayDouble *> > MEDFileField1TSWithoutSDA::getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
{
int meshId=0;
- if(mname)
+ if(!mname.empty())
meshId=getMeshIdFromMeshName(mname);
else
if(_field_per_mesh.empty())
return getUndergroundDataArrayDoubleExt(entries);
}
-MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const char *fieldName, int csit, int iteration, int order,
+MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order,
const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
{
DataArrayDouble *arr=getOrCreateAndGetArrayDouble();
//= MEDFileIntField1TSWithoutSDA
-MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const char *fieldName, int csit, int iteration, int order,
+MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order,
const std::vector<std::string>& infos)
{
return new MEDFileIntField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
{
}
-MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const char *fieldName, int csit, int iteration, int order,
+MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order,
const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
{
DataArrayInt *arr=getOrCreateAndGetArrayInt();
//= MEDFileAnyTypeField1TS
-MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const char *fileName, bool loadAll)
+MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, bool loadAll)
{
med_field_type typcha;
//
return ret.retn();
}
-MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const char *fileName, bool loadAll)
+MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, bool loadAll)
try:MEDFileFieldGlobsReal(fileName)
{
MEDFileUtilities::CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
_content=BuildContentFrom(fid,fileName,loadAll);
loadGlobals(fid);
}
throw e;
}
-MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const char *fileName, const char *fieldName, bool loadAll)
+MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, bool loadAll)
{
med_field_type typcha;
std::vector<std::string> infos;
//
med_int numdt,numit;
med_float dt;
- MEDfieldComputingStepInfo(fid,fieldName,1,&numdt,&numit,&dt);
+ MEDfieldComputingStepInfo(fid,fieldName.c_str(),1,&numdt,&numit,&dt);
ret->setTime(numdt,numit,dt);
ret->_csit=1;
if(loadAll)
return ret.retn();
}
-MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const char *fileName, const char *fieldName, bool loadAll)
+MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll)
try:MEDFileFieldGlobsReal(fileName)
{
MEDFileUtilities::CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
_content=BuildContentFrom(fid,fileName,fieldName,loadAll);
loadGlobals(fid);
}
throw e;
}
-MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, const char *fileName)
+MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, const std::string& fileName)
{
if(!c)
throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
}
-MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const char *fileName, bool loadAll)
+MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, bool loadAll)
{
MEDFileUtilities::CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,loadAll);
MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
ret->loadGlobals(fid);
return ret.retn();
}
-MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const char *fileName, const char *fieldName, bool loadAll)
+MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
{
MEDFileUtilities::CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,loadAll);
MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
ret->loadGlobals(fid);
return ret.retn();
}
-MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll)
+MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
{
MEDFileUtilities::CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,iteration,order,loadAll);
MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
ret->loadGlobals(fid);
return ret.retn();
}
-MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const char *fileName, const char *fieldName, int iteration, int order, bool loadAll)
+MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
{
med_field_type typcha;
std::vector<std::string> infos;
{
med_int numdt,numit;
med_float dt;
- MEDfieldComputingStepInfo(fid,fieldName,i+1,&numdt,&numit,&dt);
+ MEDfieldComputingStepInfo(fid,fieldName.c_str(),i+1,&numdt,&numit,&dt);
if(numdt==iteration && numit==order)
{
found=true;
return ret.retn();
}
-MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll)
+MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
try:MEDFileFieldGlobsReal(fileName)
{
MEDFileUtilities::CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
- _content=BuildContentFrom(fid,fileName,fieldName,iteration,order,loadAll);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
+ _content=BuildContentFrom(fid,fileName.c_str(),fieldName.c_str(),iteration,order,loadAll);
loadGlobals(fid);
}
catch(INTERP_KERNEL::Exception& e)
}
}
-int MEDFileAnyTypeField1TS::LocateField2(med_idt fid, const char *fileName, int fieldIdCFormat, bool checkFieldId, std::string& fieldName, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut)
+int MEDFileAnyTypeField1TS::LocateField2(med_idt fid, const std::string& fileName, int fieldIdCFormat, bool checkFieldId, std::string& fieldName, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut)
{
if(checkFieldId)
{
* \param [out]
* \return in case of success the number of time steps available for the field with name \a fieldName.
*/
-int MEDFileAnyTypeField1TS::LocateField(med_idt fid, const char *fileName, const char *fieldName, int& posCFormat, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut)
+int MEDFileAnyTypeField1TS::LocateField(med_idt fid, const std::string& fileName, const std::string& fieldName, int& posCFormat, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut)
{
int nbFields=MEDnField(fid);
bool found=false;
* \param [in] forceRenameOnGlob specifies the behaviour in case of profile \b newPflName already exists. If true, the renaming is done without check. It can lead to major bug.
* If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
*/
-void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newPflName, bool forceRenameOnGlob)
+void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob)
{
MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
std::string oldPflName=disc->getProfile();
* \param [in] forceRenameOnGlob specifies the behaviour in case of profile \b newLocName already exists. If true, the renaming is done without check. It can lead to major bug.
* If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
*/
-void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newLocName, bool forceRenameOnGlob)
+void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob)
{
MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
std::string oldLocName=disc->getLocalization();
* \throw If no field data is set.
* \throw If \a mode == 1 and the same data is present in an existing file.
*/
-void MEDFileAnyTypeField1TS::write(const char *fileName, int mode) const
+void MEDFileAnyTypeField1TS::write(const std::string& fileName, int mode) const
{
med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod);
writeLL(fid);
}
*/
void MEDFileAnyTypeField1TS::loadArrays()
{
- MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
+ if(getFileName().empty())
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::loadArrays : the structure does not come from a file !");
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
}
/*!
* This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
- * But once data loaded once, this method does nothing.
+ * But once data loaded once, this method does nothing. Contrary to MEDFileAnyTypeField1TS::loadArrays and MEDFileAnyTypeField1TS::unloadArrays
+ * this method does not throw if \a this does not come from file read.
*
- * \throw If the fileName is not set or points to a non readable MED file.
* \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::unloadArrays
*/
void MEDFileAnyTypeField1TS::loadArraysIfNecessary()
{
- MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
- contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
+ if(!getFileName().empty())
+ {
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
+ contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
+ }
}
/*!
return contentNotNullBase()->getName();
}
-void MEDFileAnyTypeField1TS::setName(const char *name)
+void MEDFileAnyTypeField1TS::setName(const std::string& name)
{
contentNotNullBase()->setName(name);
}
return contentNotNullBase()->getDtUnit();
}
-void MEDFileAnyTypeField1TS::setDtUnit(const char *dtUnit)
+void MEDFileAnyTypeField1TS::setDtUnit(const std::string& dtUnit)
{
contentNotNullBase()->setDtUnit(dtUnit);
}
return contentNotNullBase()->getMeshName();
}
-void MEDFileAnyTypeField1TS::setMeshName(const char *newMeshName)
+void MEDFileAnyTypeField1TS::setMeshName(const std::string& newMeshName)
{
contentNotNullBase()->setMeshName(newMeshName);
}
return contentNotNullBase()->getInfo();
}
-MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
+MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
{
return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
}
-const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
+const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
{
return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
}
-int MEDFileAnyTypeField1TS::getNonEmptyLevels(const char *mname, std::vector<int>& levs) const
+int MEDFileAnyTypeField1TS::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
{
return contentNotNullBase()->getNonEmptyLevels(mname,levs);
}
return contentNotNullBase()->getTypesOfFieldAvailable();
}
-std::vector< std::vector<std::pair<int,int> > > MEDFileAnyTypeField1TS::getFieldSplitedByType(const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
+std::vector< std::vector<std::pair<int,int> > > MEDFileAnyTypeField1TS::getFieldSplitedByType(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
{
return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
* is to delete this field using decrRef() as it is no more needed.
* \throw If reading the file fails.
*/
-MEDFileField1TS *MEDFileField1TS::New(const char *fileName, bool loadAll)
+MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, bool loadAll)
{
MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(fileName,loadAll);
ret->contentNotNull();
* \throw If reading the file fails.
* \throw If there is no field named \a fieldName in the file.
*/
-MEDFileField1TS *MEDFileField1TS::New(const char *fileName, const char *fieldName, bool loadAll)
+MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
{
MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(fileName,fieldName,loadAll);
ret->contentNotNull();
* \throw If there is no field named \a fieldName in the file.
* \throw If the required time step is missing from the file.
*/
-MEDFileField1TS *MEDFileField1TS::New(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll)
+MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
{
MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(fileName,fieldName,iteration,order,loadAll);
ret->contentNotNull();
return arrOutC;
}
-MEDFileField1TS::MEDFileField1TS(const char *fileName, bool loadAll)
+MEDFileField1TS::MEDFileField1TS(const std::string& fileName, bool loadAll)
try:MEDFileAnyTypeField1TS(fileName,loadAll)
{
}
catch(INTERP_KERNEL::Exception& e)
{ throw e; }
-MEDFileField1TS::MEDFileField1TS(const char *fileName, const char *fieldName, bool loadAll)
+MEDFileField1TS::MEDFileField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll)
try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll)
{
}
catch(INTERP_KERNEL::Exception& e)
{ throw e; }
-MEDFileField1TS::MEDFileField1TS(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll)
+MEDFileField1TS::MEDFileField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll)
{
}
if(getFileName2().empty())
throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arrOut,*contentNotNull());
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull());
MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
return ret.retn();
}
if(getFileName2().empty())
throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,0,renumPol,this,arrOut,*contentNotNull());
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull());
MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
return ret.retn();
}
* \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
* \sa getFieldAtLevel()
*/
-MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const char *mname, int meshDimRelToMax, int renumPol) const
+MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
{
if(getFileName2().empty())
throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
return contentNotNull()->getUndergroundDataArrayDoubleExt(entries);
}
-std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
+std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
{
return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
return ret.retn();
}
-MEDFileIntField1TS *MEDFileIntField1TS::New(const char *fileName, bool loadAll)
+MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, bool loadAll)
{
MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(fileName,loadAll);
ret->contentNotNull();
return ret.retn();
}
-MEDFileIntField1TS *MEDFileIntField1TS::New(const char *fileName, const char *fieldName, bool loadAll)
+MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
{
MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(fileName,fieldName,loadAll);
ret->contentNotNull();
return ret.retn();
}
-MEDFileIntField1TS *MEDFileIntField1TS::New(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll)
+MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
{
MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(fileName,fieldName,iteration,order,loadAll);
ret->contentNotNull();
_content=new MEDFileIntField1TSWithoutSDA;
}
-MEDFileIntField1TS::MEDFileIntField1TS(const char *fileName, bool loadAll)
+MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, bool loadAll)
try:MEDFileAnyTypeField1TS(fileName,loadAll)
{
}
catch(INTERP_KERNEL::Exception& e)
{ throw e; }
-MEDFileIntField1TS::MEDFileIntField1TS(const char *fileName, const char *fieldName, bool loadAll)
+MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll)
try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll)
{
}
catch(INTERP_KERNEL::Exception& e)
{ throw e; }
-MEDFileIntField1TS::MEDFileIntField1TS(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll)
+MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll)
{
}
if(getFileName2().empty())
throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut2;
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arrOut2,*contentNotNull());
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut2,*contentNotNull());
DataArrayInt *arrOutC=dynamic_cast<DataArrayInt *>((DataArray *)arrOut2);
if(!arrOutC)
throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : mismatch between dataArrays type and MEDFileIntField1TS ! Expected int32 !");
if(getFileName2().empty())
throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,0,renumPol,this,arr,*contentNotNull());
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNull());
arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
return ret.retn();
}
* \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
* \sa getFieldAtLevel()
*/
-MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const char *mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
+MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
{
if(getFileName2().empty())
throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
{
}
-MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const char *fieldName):MEDFileFieldNameScope(fieldName)
+MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileFieldNameScope(fieldName)
{
}
loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll);
}
-MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll)
+MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll)
try:MEDFileFieldNameScope(fieldName),_infos(infos)
{
setDtUnit(dtunit.c_str());
return _time_steps[0]->getMeshName();
}
-void MEDFileAnyTypeFieldMultiTSWithoutSDA::setMeshName(const char *newMeshName)
+void MEDFileAnyTypeFieldMultiTSWithoutSDA::setMeshName(const std::string& newMeshName)
{
std::string oldName(getMeshName());
std::vector< std::pair<std::string,std::string> > v(1);
return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
}
-bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
+bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
MEDFileFieldGlobsReal& glob)
{
bool ret=false;
* To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
* To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
*/
-int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const char *mname, std::vector<int>& levs) const
+int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
{
return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
}
/*!
* entry point for users that want to iterate into MEDFile DataStructure without any overhead.
*/
-std::vector< std::vector< std::pair<int,int> > > MEDFileAnyTypeFieldMultiTSWithoutSDA::getFieldSplitedByType(int iteration, int order, const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
+std::vector< std::vector< std::pair<int,int> > > MEDFileAnyTypeFieldMultiTSWithoutSDA::getFieldSplitedByType(int iteration, int order, const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
{
return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
}
//= MEDFileFieldMultiTSWithoutSDA
-MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::New(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll)
+MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::New(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll)
{
return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll);
}
{
}
-MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const char *fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
+MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
{
}
catch(INTERP_KERNEL::Exception& e)
{ throw e; }
-MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll)
+MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll)
try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll)
{
}
* entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
* for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
*/
-std::vector< std::vector<DataArrayDouble *> > MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2(int iteration, int order, const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
+std::vector< std::vector<DataArrayDouble *> > MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2(int iteration, int order, const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
{
const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
{
}
-MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const char *fileName, bool loadAll)
+MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const std::string& fileName, bool loadAll)
try:MEDFileFieldGlobsReal(fileName)
{
MEDFileUtilities::CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
_content=BuildContentFrom(fid,fileName,loadAll);
loadGlobals(fid);
}
throw e;
}
-MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const char *fileName, const char *fieldName, bool loadAll)
+MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, bool loadAll)
{
med_field_type typcha;
std::vector<std::string> infos;
return ret.retn();
}
-MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const char *fileName, bool loadAll)
+MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fileName, bool loadAll)
{
med_field_type typcha;
//
return ret.retn();
}
-MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, const char *fileName)
+MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, const std::string& fileName)
{
if(!c)
throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
}
-MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const char *fileName, const char *fieldName, bool loadAll)
+MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll)
try:MEDFileFieldGlobsReal(fileName)
{
MEDFileUtilities::CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
_content=BuildContentFrom(fid,fileName,fieldName,loadAll);
loadGlobals(fid);
}
//= MEDFileIntFieldMultiTSWithoutSDA
-MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::New(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll)
+MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::New(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll)
{
return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll);
}
{
}
-MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const char *fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
+MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
{
}
-MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll)
+MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll)
try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll)
{
}
* is to delete this field using decrRef() as it is no more needed.
* \throw If reading the file fails.
*/
-MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const char *fileName, bool loadAll)
+MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, bool loadAll)
{
MEDFileUtilities::CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName,loadAll);
MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
ret->loadGlobals(fid);
* \throw If reading the file fails.
* \throw If there is no field named \a fieldName in the file.
*/
-MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const char *fileName, const char *fieldName, bool loadAll)
+MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
{
MEDFileUtilities::CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,loadAll);
MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
ret->loadGlobals(fid);
return contentNotNullBase()->getPosGivenTime(time,eps);
}
-int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const char *mname, std::vector<int>& levs) const
+int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
{
return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
}
return contentNotNullBase()->getTypesOfFieldAvailable();
}
-std::vector< std::vector< std::pair<int,int> > > MEDFileAnyTypeFieldMultiTS::getFieldSplitedByType(int iteration, int order, const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
+std::vector< std::vector< std::pair<int,int> > > MEDFileAnyTypeFieldMultiTS::getFieldSplitedByType(int iteration, int order, const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
{
return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
}
return contentNotNullBase()->getName();
}
-void MEDFileAnyTypeFieldMultiTS::setName(const char *name)
+void MEDFileAnyTypeFieldMultiTS::setName(const std::string& name)
{
contentNotNullBase()->setName(name);
}
return contentNotNullBase()->getDtUnit();
}
-void MEDFileAnyTypeFieldMultiTS::setDtUnit(const char *dtUnit)
+void MEDFileAnyTypeFieldMultiTS::setDtUnit(const std::string& dtUnit)
{
contentNotNullBase()->setDtUnit(dtUnit);
}
return contentNotNullBase()->getMeshName();
}
-void MEDFileAnyTypeFieldMultiTS::setMeshName(const char *newMeshName)
+void MEDFileAnyTypeFieldMultiTS::setMeshName(const std::string& newMeshName)
{
contentNotNullBase()->setMeshName(newMeshName);
}
* \throw If no field data is set.
* \throw If \a mode == 1 and the same data is present in an existing file.
*/
-void MEDFileAnyTypeFieldMultiTS::write(const char *fileName, int mode) const
+void MEDFileAnyTypeFieldMultiTS::write(const std::string& fileName, int mode) const
{
med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod);
writeLL(fid);
}
*/
void MEDFileAnyTypeFieldMultiTS::loadArrays()
{
- MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
+ if(getFileName().empty())
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::loadArrays : the structure does not come from a file !");
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
}
*/
void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary()
{
- MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
- contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
+ if(!getFileName().empty())
+ {
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
+ contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
+ }
}
/*!
* is to delete this field using decrRef() as it is no more needed.
* \throw If reading the file fails.
*/
-MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const char *fileName, bool loadAll)
+MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, bool loadAll)
{
MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,loadAll);
ret->contentNotNull();//to check that content type matches with \a this type.
* \throw If reading the file fails.
* \throw If there is no field named \a fieldName in the file.
*/
-MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const char *fileName, const char *fieldName, bool loadAll)
+MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
{
MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,fieldName,loadAll);
ret->contentNotNull();//to check that content type matches with \a this type.
if(!myF1TSC)
throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !");
MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arrOut,*contentNotNullBase());
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNullBase());
MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
return ret.retn();
}
if(!myF1TSC)
throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !");
MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,0,renumPol,this,arrOut,*contentNotNullBase());
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNullBase());
MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
return ret.retn();
}
* This method is called 'old' because the user should give the mesh name he wants to use for it's field.
* This method is useful for MED2 file format when field on different mesh was autorized.
*/
-MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const char *mname, int iteration, int order, int meshDimRelToMax, int renumPol) const
+MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int iteration, int order, int meshDimRelToMax, int renumPol) const
{
const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
_content=new MEDFileFieldMultiTSWithoutSDA;
}
-MEDFileFieldMultiTS::MEDFileFieldMultiTS(const char *fileName, bool loadAll)
+MEDFileFieldMultiTS::MEDFileFieldMultiTS(const std::string& fileName, bool loadAll)
try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll)
{
}
catch(INTERP_KERNEL::Exception& e)
{ throw e; }
-MEDFileFieldMultiTS::MEDFileFieldMultiTS(const char *fileName, const char *fieldName, bool loadAll)
+MEDFileFieldMultiTS::MEDFileFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll)
try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll)
{
}
{
}
-std::vector< std::vector<DataArrayDouble *> > MEDFileFieldMultiTS::getFieldSplitedByType2(int iteration, int order, const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
+std::vector< std::vector<DataArrayDouble *> > MEDFileFieldMultiTS::getFieldSplitedByType2(int iteration, int order, const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
{
return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
}
* is to delete this field using decrRef() as it is no more needed.
* \throw If reading the file fails.
*/
-MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const char *fileName, bool loadAll)
+MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, bool loadAll)
{
MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,loadAll);
ret->contentNotNull();//to check that content type matches with \a this type.
* \throw If reading the file fails.
* \throw If there is no field named \a fieldName in the file.
*/
-MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const char *fileName, const char *fieldName, bool loadAll)
+MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
{
MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,fieldName,loadAll);
ret->contentNotNull();//to check that content type matches with \a this type.
if(!myF1TSC)
throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting INT32 !");
MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arr,*contentNotNullBase());
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arr,*contentNotNullBase());
arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
return ret.retn();
}
if(!myF1TSC)
throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtTopLevel : mismatch of type of field ! INT32 expected !");
MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,0,renumPol,this,arr,*contentNotNullBase());
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNullBase());
arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
return ret.retn();
}
* This method is called 'old' because the user should give the mesh name he wants to use for it's field.
* This method is useful for MED2 file format when field on different mesh was autorized.
*/
-MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const char *mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
+MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
{
const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
{
}
-MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const char *fileName, bool loadAll)
+MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const std::string& fileName, bool loadAll)
try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll)
{
}
catch(INTERP_KERNEL::Exception& e)
{ throw e; }
-MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const char *fileName, const char *fieldName, bool loadAll)
+MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll)
try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll)
{
}
return new MEDFileFields;
}
-MEDFileFields *MEDFileFields::New(const char *fileName, bool loadAll)
+MEDFileFields *MEDFileFields::New(const std::string& fileName, bool loadAll)
{
return new MEDFileFields(fileName,loadAll);
}
{
}
-MEDFileFields::MEDFileFields(const char *fileName, bool loadAll)
+MEDFileFields::MEDFileFields(const std::string& fileName, bool loadAll)
try:MEDFileFieldGlobsReal(fileName)
{
MEDFileUtilities::CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
int nbFields=MEDnField(fid);
_fields.resize(nbFields);
med_field_type typcha;
}
}
-void MEDFileFields::write(const char *fileName, int mode) const
+void MEDFileFields::write(const std::string& fileName, int mode) const
{
med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
+ MEDFileUtilities::AutoFid fid(MEDfileOpen(fileName.c_str(),medmod));
writeLL(fid);
}
*/
void MEDFileFields::loadArrays()
{
- MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
+ if(getFileName().empty())
+ throw INTERP_KERNEL::Exception("MEDFileFields::loadArrays : the structure does not come from a file !");
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
{
MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
*/
void MEDFileFields::loadArraysIfNecessary()
{
- MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
- for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
+ if(!getFileName().empty())
{
- MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
- if(elt)
- elt->loadBigArraysRecursivelyIfNecessary(fid,*elt);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
+ {
+ MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
+ if(elt)
+ elt->loadBigArraysRecursivelyIfNecessary(fid,*elt);
+ }
}
}
*/
void MEDFileFields::unloadArrays()
{
- MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
{
MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
* \return If true a renumbering has been performed. The structure in \a this has been modified. If false, nothing has been done: it is typically the case if \a meshName is not refered by any
* field in \a this.
*/
-bool MEDFileFields::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N)
+bool MEDFileFields::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N)
{
bool ret=false;
for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
return ret.retn();
}
-MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const char *fieldName) const
+MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const std::string& fieldName) const
{
return getFieldAtPos(getPosFromFieldName(fieldName));
}
* \param [in] meshName - the name of the mesh on w
* \return a new object that the caller should deal with.
*/
-MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const char *meshName) const
+MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const
{
MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
return new MEDFileFieldsIterator(this);
}
-int MEDFileFields::getPosFromFieldName(const char *fieldName) const
+int MEDFileFields::getPosFromFieldName(const std::string& fieldName) const
{
std::string tmp(fieldName);
std::vector<std::string> poss;
public:
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);
+ MEDLOADER_EXPORT void setName(const std::string& name);
+ static MEDFileFieldLoc *New(med_idt fid, const std::string& 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);
+ static MEDFileFieldLoc *New(const std::string& 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;
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 bool isName(const std::string& 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 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, const std::string& locName);
MEDFileFieldLoc(med_idt fid, int id);
- MEDFileFieldLoc(const char *locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w);
+ MEDFileFieldLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w);
private:
int _dim;
int _nb_gauss_pt;
const DataArray *getOrCreateAndGetArray() const;
const std::vector<std::string>& getInfo() const;
std::string getProfile() const;
- void setProfile(const char *newPflName);
+ void setProfile(const std::string& newPflName);
std::string getLocalization() const;
- void setLocalization(const char *newLocName);
+ void setLocalization(const std::string& newLocName);
int getLocId() const { return _loc_id; }
void setLocId(int newId) const { _loc_id=newId; }
void setFather(MEDFileFieldPerMeshPerType *newFather) { _father=newFather; }
std::vector<std::string> getPflsReallyUsedMulti() const;
std::vector<std::string> getLocsReallyUsedMulti() const;
bool changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab);
- bool renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N, MEDFileFieldGlobsReal& glob);
+ bool renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N, MEDFileFieldGlobsReal& glob);
void keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its);
void changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
void changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
class MEDFileFieldGlobs : public RefCountObject
{
public:
- static MEDFileFieldGlobs *New(const char *fname);
+ static MEDFileFieldGlobs *New(const std::string& fname);
static MEDFileFieldGlobs *New();
std::size_t getHeapMemorySizeWithoutChildren() const;
std::vector<const BigMemoryObject *> getDirectChildren() const;
void appendGlobs(const MEDFileFieldGlobs& other, double eps);
void checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const;
void checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const;
- void loadProfileInFile(med_idt fid, int id, const char *pflName);
+ void loadProfileInFile(med_idt fid, int id, const std::string& pflName);
void loadProfileInFile(med_idt fid, int id);
void loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real);
void loadAllGlobals(med_idt fid);
void writeGlobals(med_idt fid, const MEDFileWritable& opt) const;
std::vector<std::string> getPfls() const;
std::vector<std::string> getLocs() const;
- bool existsPfl(const char *pflName) const;
- bool existsLoc(const char *locName) const;
+ bool existsPfl(const std::string& pflName) const;
+ bool existsLoc(const std::string& locName) const;
std::string createNewNameOfPfl() const;
std::string createNewNameOfLoc() const;
std::vector< std::vector<int> > whichAreEqualProfiles() const;
std::vector< std::vector<int> > whichAreEqualLocs(double eps) const;
- void setFileName(const char *fileName);
+ void setFileName(const std::string& fileName);
void changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
void changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
int getNbOfGaussPtPerCell(int locId) const;
- int getLocalizationId(const char *loc) const;
- const char *getFileName() const { return _file_name.c_str(); }
+ int getLocalizationId(const std::string& loc) const;
+ std::string getFileName() const { return _file_name; }
std::string getFileName2() const { return _file_name; }
const MEDFileFieldLoc& getLocalizationFromId(int locId) const;
- const MEDFileFieldLoc& getLocalization(const char *locName) const;
+ const MEDFileFieldLoc& getLocalization(const std::string& locName) const;
const DataArrayInt *getProfileFromId(int pflId) const;
- const DataArrayInt *getProfile(const char *pflName) const;
+ const DataArrayInt *getProfile(const std::string& pflName) const;
MEDFileFieldLoc& getLocalizationFromId(int locId);
- MEDFileFieldLoc& getLocalization(const char *locName);
- DataArrayInt *getProfile(const char *pflName);
+ MEDFileFieldLoc& getLocalization(const std::string& locName);
+ DataArrayInt *getProfile(const std::string& pflName);
DataArrayInt *getProfileFromId(int pflId);
void killProfileIds(const std::vector<int>& pflIds);
void killLocalizationIds(const std::vector<int>& locIds);
//
void appendProfile(DataArrayInt *pfl);
- void appendLoc(const char *locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w);
+ void appendLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w);
//
- static std::string CreateNewNameNotIn(const char *prefix, const std::vector<std::string>& namesToAvoid);
+ static std::string CreateNewNameNotIn(const std::string& prefix, const std::vector<std::string>& namesToAvoid);
protected:
- MEDFileFieldGlobs(const char *fname);
+ MEDFileFieldGlobs(const std::string& fname);
MEDFileFieldGlobs();
~MEDFileFieldGlobs();
protected:
class MEDFileFieldGlobsReal
{
public:
- MEDLOADER_EXPORT MEDFileFieldGlobsReal(const char *fname);
+ MEDLOADER_EXPORT MEDFileFieldGlobsReal(const std::string& fname);
MEDLOADER_EXPORT MEDFileFieldGlobsReal();
MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildren() const;
MEDLOADER_EXPORT virtual void changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) = 0;
MEDLOADER_EXPORT virtual ~MEDFileFieldGlobsReal();
//
- MEDLOADER_EXPORT void loadProfileInFile(med_idt fid, int id, const char *pflName);
+ MEDLOADER_EXPORT void loadProfileInFile(med_idt fid, int id, const std::string& pflName);
MEDLOADER_EXPORT void loadProfileInFile(med_idt fid, int id);
MEDLOADER_EXPORT void loadGlobals(med_idt fid);
MEDLOADER_EXPORT void loadAllGlobals(med_idt fid);
MEDLOADER_EXPORT void writeGlobals(med_idt fid, const MEDFileWritable& opt) const;
MEDLOADER_EXPORT std::vector<std::string> getPfls() const;
MEDLOADER_EXPORT std::vector<std::string> getLocs() const;
- MEDLOADER_EXPORT bool existsPfl(const char *pflName) const;
- MEDLOADER_EXPORT bool existsLoc(const char *locName) const;
+ MEDLOADER_EXPORT bool existsPfl(const std::string& pflName) const;
+ MEDLOADER_EXPORT bool existsLoc(const std::string& locName) const;
MEDLOADER_EXPORT std::string createNewNameOfPfl() const;
MEDLOADER_EXPORT std::string createNewNameOfLoc() const;
MEDLOADER_EXPORT std::vector< std::vector<int> > whichAreEqualProfiles() const;
MEDLOADER_EXPORT std::vector< std::vector<int> > whichAreEqualLocs(double eps) const;
- MEDLOADER_EXPORT void setFileName(const char *fileName);
+ MEDLOADER_EXPORT void setFileName(const std::string& fileName);
MEDLOADER_EXPORT void changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
MEDLOADER_EXPORT void changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
MEDLOADER_EXPORT void changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
MEDLOADER_EXPORT void changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
- MEDLOADER_EXPORT void changePflName(const char *oldName, const char *newName);
- MEDLOADER_EXPORT void changeLocName(const char *oldName, const char *newName);
+ MEDLOADER_EXPORT void changePflName(const std::string& oldName, const std::string& newName);
+ MEDLOADER_EXPORT void changeLocName(const std::string& oldName, const std::string& newName);
MEDLOADER_EXPORT std::vector< std::pair<std::vector<std::string>, std::string > > zipPflsNames();
MEDLOADER_EXPORT std::vector< std::pair<std::vector<std::string>, std::string > > zipLocsNames(double eps);
MEDLOADER_EXPORT int getNbOfGaussPtPerCell(int locId) const;
- MEDLOADER_EXPORT int getLocalizationId(const char *loc) const;
- MEDLOADER_EXPORT const char *getFileName() const;
+ MEDLOADER_EXPORT int getLocalizationId(const std::string& loc) const;
+ MEDLOADER_EXPORT std::string getFileName() const;
MEDLOADER_EXPORT std::string getFileName2() const;
MEDLOADER_EXPORT const MEDFileFieldLoc& getLocalizationFromId(int locId) const;
- MEDLOADER_EXPORT const MEDFileFieldLoc& getLocalization(const char *locName) const;
+ MEDLOADER_EXPORT const MEDFileFieldLoc& getLocalization(const std::string& locName) const;
MEDLOADER_EXPORT MEDFileFieldLoc& getLocalizationFromId(int locId);
- MEDLOADER_EXPORT MEDFileFieldLoc& getLocalization(const char *locName);
- MEDLOADER_EXPORT const DataArrayInt *getProfile(const char *pflName) const;
+ MEDLOADER_EXPORT MEDFileFieldLoc& getLocalization(const std::string& locName);
+ MEDLOADER_EXPORT const DataArrayInt *getProfile(const std::string& pflName) const;
MEDLOADER_EXPORT const DataArrayInt *getProfileFromId(int pflId) const;
- MEDLOADER_EXPORT DataArrayInt *getProfile(const char *pflName);
+ MEDLOADER_EXPORT DataArrayInt *getProfile(const std::string& pflName);
MEDLOADER_EXPORT DataArrayInt *getProfileFromId(int pflId);
MEDLOADER_EXPORT void killProfileIds(const std::vector<int>& pflIds);
MEDLOADER_EXPORT void killLocalizationIds(const std::vector<int>& locIds);
//
MEDLOADER_EXPORT void appendProfile(DataArrayInt *pfl);
- MEDLOADER_EXPORT void appendLoc(const char *locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w);
+ MEDLOADER_EXPORT void appendLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w);
protected:
MEDFileFieldGlobs *contentNotNull();
const MEDFileFieldGlobs *contentNotNull() const;
{
public:
MEDLOADER_EXPORT MEDFileFieldNameScope();
- MEDLOADER_EXPORT MEDFileFieldNameScope(const char *fieldName);
+ MEDLOADER_EXPORT MEDFileFieldNameScope(const std::string& fieldName);
MEDLOADER_EXPORT std::string getName() const;
- MEDLOADER_EXPORT void setName(const char *fieldName);
+ MEDLOADER_EXPORT void setName(const std::string& fieldName);
MEDLOADER_EXPORT std::string getDtUnit() const;
- MEDLOADER_EXPORT void setDtUnit(const char *dtUnit);
+ MEDLOADER_EXPORT void setDtUnit(const std::string& dtUnit);
MEDLOADER_EXPORT void copyNameScope(const MEDFileFieldNameScope& other);
protected:
std::string _name;
{
public:
MEDLOADER_EXPORT MEDFileAnyTypeField1TSWithoutSDA();
- MEDLOADER_EXPORT MEDFileAnyTypeField1TSWithoutSDA(const char *fieldName, int csit, int iteration, int order);
+ MEDLOADER_EXPORT MEDFileAnyTypeField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order);
MEDLOADER_EXPORT int getIteration() const { return _iteration; }
MEDLOADER_EXPORT int getOrder() const { return _order; }
MEDLOADER_EXPORT double getTime(int& iteration, int& order) const { iteration=_iteration; order=_order; return _dt; }
MEDLOADER_EXPORT void setTime(int iteration, int order, double val) { _dt=val; _iteration=iteration; _order=order; }
MEDLOADER_EXPORT int getDimension() const;
MEDLOADER_EXPORT std::string getMeshName() const;
- MEDLOADER_EXPORT void setMeshName(const char *newMeshName);
+ MEDLOADER_EXPORT void setMeshName(const std::string& newMeshName);
MEDLOADER_EXPORT bool changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab);
MEDLOADER_EXPORT int getMeshIteration() const;
MEDLOADER_EXPORT int getMeshOrder() const;
MEDLOADER_EXPORT void changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
MEDLOADER_EXPORT void changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
//
- MEDLOADER_EXPORT int getNonEmptyLevels(const char *mname, std::vector<int>& levs) const;
- MEDLOADER_EXPORT std::vector< std::vector<std::pair<int,int> > > getFieldSplitedByType(const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const;
+ MEDLOADER_EXPORT int getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const;
+ MEDLOADER_EXPORT std::vector< std::vector<std::pair<int,int> > > getFieldSplitedByType(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const;
//
- MEDLOADER_EXPORT MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId);
- MEDLOADER_EXPORT const MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const;
+ MEDLOADER_EXPORT MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId);
+ MEDLOADER_EXPORT const MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const;
MEDLOADER_EXPORT void deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other);
public:
MEDLOADER_EXPORT int getNumberOfComponents() const;
MEDLOADER_EXPORT virtual DataArray *getOrCreateAndGetArray() = 0;
MEDLOADER_EXPORT virtual const DataArray *getOrCreateAndGetArray() const = 0;
public:
- MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const char *mName, int renumPol, const MEDFileFieldGlobsReal *glob, MEDCouplingAutoRefCountObjectPtr<DataArray> &arrOut, const MEDFileFieldNameScope& nasc) const;
+ MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MEDCouplingAutoRefCountObjectPtr<DataArray> &arrOut, const MEDFileFieldNameScope& nasc) const;
MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MEDCouplingAutoRefCountObjectPtr<DataArray> &arrOut, const MEDFileFieldNameScope& nasc) const;
- MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, const char *mName, int renumPol, const MEDFileFieldGlobsReal *glob, MEDCouplingAutoRefCountObjectPtr<DataArray> &arrOut, const MEDFileFieldNameScope& nasc) const;
+ MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MEDCouplingAutoRefCountObjectPtr<DataArray> &arrOut, const MEDFileFieldNameScope& nasc) const;
MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, const DataArrayInt *cellRenum, const DataArrayInt *nodeRenum, MEDCouplingAutoRefCountObjectPtr<DataArray> &arrOut, const MEDFileFieldNameScope& nasc) const;
DataArray *getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const;
public:
- MEDLOADER_EXPORT bool renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N, MEDFileFieldGlobsReal& glob);
+ MEDLOADER_EXPORT bool renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N, MEDFileFieldGlobsReal& glob);
MEDLOADER_EXPORT std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > splitDiscretizations() const;
MEDLOADER_EXPORT int keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair<int,int> >& its);
public:
MEDLOADER_EXPORT void unloadArrays();
MEDLOADER_EXPORT void writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const;
protected:
- int getMeshIdFromMeshName(const char *mName) const;
+ int getMeshIdFromMeshName(const std::string& mName) const;
int addNewEntryIfNecessary(const MEDCouplingMesh *mesh);
void updateData(int newLgth, const std::vector< std::pair<int,int> >& oldStartStops);
protected:
MEDLOADER_EXPORT DataArray *getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const;
MEDLOADER_EXPORT DataArrayDouble *getUndergroundDataArrayDouble() const;
MEDLOADER_EXPORT DataArrayDouble *getUndergroundDataArrayDoubleExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const;
- MEDLOADER_EXPORT std::vector< std::vector<DataArrayDouble *> > getFieldSplitedByType2(const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const;
+ MEDLOADER_EXPORT std::vector< std::vector<DataArrayDouble *> > getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const;
MEDLOADER_EXPORT static void CheckMeshDimRel(int meshDimRelToMax);
MEDLOADER_EXPORT static std::vector<int> CheckSBTMesh(const MEDCouplingMesh *mesh);
- MEDLOADER_EXPORT static MEDFileField1TSWithoutSDA *New(const char *fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos);
+ MEDLOADER_EXPORT static MEDFileField1TSWithoutSDA *New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos);
public:
MEDLOADER_EXPORT MEDFileField1TSWithoutSDA();
- MEDLOADER_EXPORT MEDFileField1TSWithoutSDA(const char *fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos);
+ MEDLOADER_EXPORT MEDFileField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos);
MEDLOADER_EXPORT MEDFileAnyTypeField1TSWithoutSDA *shallowCpy() const;
MEDLOADER_EXPORT MEDFileAnyTypeField1TSWithoutSDA *deepCpy() const;
MEDLOADER_EXPORT void setArray(DataArray *arr);
{
public:
MEDLOADER_EXPORT MEDFileIntField1TSWithoutSDA();
- MEDLOADER_EXPORT static MEDFileIntField1TSWithoutSDA *New(const char *fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos);
+ MEDLOADER_EXPORT static MEDFileIntField1TSWithoutSDA *New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos);
MEDLOADER_EXPORT MEDFileAnyTypeField1TSWithoutSDA *deepCpy() const;
MEDLOADER_EXPORT MEDFileAnyTypeField1TSWithoutSDA *shallowCpy() const;
MEDLOADER_EXPORT const char *getTypeStr() const;
MEDLOADER_EXPORT DataArrayInt *getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const;
MEDLOADER_EXPORT MEDFileField1TSWithoutSDA *convertToDouble() const;
protected:
- MEDFileIntField1TSWithoutSDA(const char *fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos);
+ MEDFileIntField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos);
protected:
MEDCouplingAutoRefCountObjectPtr< DataArrayInt > _arr;
public:
{
protected:
MEDLOADER_EXPORT MEDFileAnyTypeField1TS();
- MEDLOADER_EXPORT MEDFileAnyTypeField1TS(const char *fileName, bool loadAll);
- MEDLOADER_EXPORT MEDFileAnyTypeField1TS(const char *fileName, const char *fieldName, bool loadAll);
- MEDLOADER_EXPORT MEDFileAnyTypeField1TS(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll);
+ MEDLOADER_EXPORT MEDFileAnyTypeField1TS(const std::string& fileName, bool loadAll);
+ MEDLOADER_EXPORT MEDFileAnyTypeField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll);
+ MEDLOADER_EXPORT MEDFileAnyTypeField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll);
MEDLOADER_EXPORT MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent);
- MEDLOADER_EXPORT static MEDFileAnyTypeField1TS *BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, const char *fileName);
- MEDLOADER_EXPORT static MEDFileAnyTypeField1TSWithoutSDA *BuildContentFrom(med_idt fid, const char *fileName, bool loadAll);
- MEDLOADER_EXPORT static MEDFileAnyTypeField1TSWithoutSDA *BuildContentFrom(med_idt fid, const char *fileName, const char *fieldName, bool loadAll);
- MEDLOADER_EXPORT static MEDFileAnyTypeField1TSWithoutSDA *BuildContentFrom(med_idt fid, const char *fileName, const char *fieldName, int iteration, int order, bool loadAll);
+ MEDLOADER_EXPORT static MEDFileAnyTypeField1TS *BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, const std::string& fileName);
+ MEDLOADER_EXPORT static MEDFileAnyTypeField1TSWithoutSDA *BuildContentFrom(med_idt fid, const std::string& fileName, bool loadAll);
+ MEDLOADER_EXPORT static MEDFileAnyTypeField1TSWithoutSDA *BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, bool loadAll);
+ MEDLOADER_EXPORT static MEDFileAnyTypeField1TSWithoutSDA *BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll);
MEDLOADER_EXPORT void writeLL(med_idt fid) const;
// direct forwarding to MEDFileAnyTypeField1TSWithoutSDA instance _content
public:
- MEDLOADER_EXPORT static MEDFileAnyTypeField1TS *New(const char *fileName, bool loadAll=true);
- MEDLOADER_EXPORT static MEDFileAnyTypeField1TS *New(const char *fileName, const char *fieldName, bool loadAll=true);
- MEDLOADER_EXPORT static MEDFileAnyTypeField1TS *New(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll=true);
+ MEDLOADER_EXPORT static MEDFileAnyTypeField1TS *New(const std::string& fileName, bool loadAll=true);
+ MEDLOADER_EXPORT static MEDFileAnyTypeField1TS *New(const std::string& fileName, const std::string& fieldName, bool loadAll=true);
+ MEDLOADER_EXPORT static MEDFileAnyTypeField1TS *New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll=true);
MEDLOADER_EXPORT int getDimension() const;
MEDLOADER_EXPORT int getIteration() const;
MEDLOADER_EXPORT int getOrder() const;
MEDLOADER_EXPORT double getTime(int& iteration, int& order) const;
MEDLOADER_EXPORT void setTime(int iteration, int order, double val);
MEDLOADER_EXPORT std::string getName() const;
- MEDLOADER_EXPORT void setName(const char *name);
+ MEDLOADER_EXPORT void setName(const std::string& name);
MEDLOADER_EXPORT std::string simpleRepr() const;
MEDLOADER_EXPORT void simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const;
MEDLOADER_EXPORT std::string getDtUnit() const;
- MEDLOADER_EXPORT void setDtUnit(const char *dtUnit);
+ MEDLOADER_EXPORT void setDtUnit(const std::string& dtUnit);
MEDLOADER_EXPORT std::string getMeshName() const;
- MEDLOADER_EXPORT void setMeshName(const char *newMeshName);
+ MEDLOADER_EXPORT void setMeshName(const std::string& newMeshName);
MEDLOADER_EXPORT bool changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab);
MEDLOADER_EXPORT int getMeshIteration() const;
MEDLOADER_EXPORT int getMeshOrder() const;
MEDLOADER_EXPORT const std::vector<std::string>& getInfo() const;
MEDLOADER_EXPORT std::vector<std::string>& getInfo();
MEDLOADER_EXPORT std::vector<TypeOfField> getTypesOfFieldAvailable() const;
- MEDLOADER_EXPORT std::vector< std::vector<std::pair<int,int> > > getFieldSplitedByType(const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
+ MEDLOADER_EXPORT std::vector< std::vector<std::pair<int,int> > > getFieldSplitedByType(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception);
- MEDLOADER_EXPORT MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId);
- MEDLOADER_EXPORT const MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const;
- MEDLOADER_EXPORT int getNonEmptyLevels(const char *mname, std::vector<int>& levs) const;
+ MEDLOADER_EXPORT MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId);
+ MEDLOADER_EXPORT const MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const;
+ MEDLOADER_EXPORT int getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const;
public:
- MEDLOADER_EXPORT void write(const char *fileName, int mode) const;
+ MEDLOADER_EXPORT void write(const std::string& fileName, int mode) const;
MEDLOADER_EXPORT void loadArrays();
MEDLOADER_EXPORT void loadArraysIfNecessary();
MEDLOADER_EXPORT void unloadArrays();
MEDLOADER_EXPORT virtual MEDFileAnyTypeField1TS *shallowCpy() const = 0;
public:
//! underground method see MEDFileField1TSWithoutSDA::setProfileNameOnLeaf
- MEDLOADER_EXPORT void setProfileNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newPflName, bool forceRenameOnGlob=false);
+ MEDLOADER_EXPORT void setProfileNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob=false);
//! underground method see MEDFileField1TSWithoutSDA::setLocNameOnLeaf
- MEDLOADER_EXPORT void setLocNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newLocName, bool forceRenameOnGlob=false);
+ MEDLOADER_EXPORT void setLocNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob=false);
MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildren() const;
MEDLOADER_EXPORT std::vector<std::string> getPflsReallyUsed() const;
MEDLOADER_EXPORT void changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
MEDLOADER_EXPORT void changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
public:
- MEDLOADER_EXPORT static int LocateField2(med_idt fid, const char *fileName, int fieldIdCFormat, bool checkFieldId, std::string& fieldName, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut);
- MEDLOADER_EXPORT static int LocateField(med_idt fid, const char *fileName, const char *fieldName, int& posCFormat, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut);
+ MEDLOADER_EXPORT static int LocateField2(med_idt fid, const std::string& fileName, int fieldIdCFormat, bool checkFieldId, std::string& fieldName, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut);
+ MEDLOADER_EXPORT static int LocateField(med_idt fid, const std::string& fileName, const std::string& fieldName, int& posCFormat, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut);
public:
MEDLOADER_EXPORT virtual med_field_type getMEDFileFieldType() const = 0;
MEDLOADER_EXPORT MEDFileAnyTypeField1TSWithoutSDA *contentNotNullBase();
class MEDFileField1TS : public MEDFileAnyTypeField1TS
{
public:
- MEDLOADER_EXPORT static MEDFileField1TS *New(const char *fileName, bool loadAll=true);
- MEDLOADER_EXPORT static MEDFileField1TS *New(const char *fileName, const char *fieldName, bool loadAll=true);
- MEDLOADER_EXPORT static MEDFileField1TS *New(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll=true);
+ MEDLOADER_EXPORT static MEDFileField1TS *New(const std::string& fileName, bool loadAll=true);
+ MEDLOADER_EXPORT static MEDFileField1TS *New(const std::string& fileName, const std::string& fieldName, bool loadAll=true);
+ MEDLOADER_EXPORT static MEDFileField1TS *New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll=true);
MEDLOADER_EXPORT static MEDFileField1TS *New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent);
MEDLOADER_EXPORT static MEDFileField1TS *New();
MEDLOADER_EXPORT MEDFileIntField1TS *convertToInt(bool isDeepCpyGlobs=true) const;
MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, int renumPol=0) const;
MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const;
MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol=0) const;
- MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtLevelOld(TypeOfField type, const char *mname, int meshDimRelToMax, int renumPol=0) const;
+ MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol=0) const;
MEDLOADER_EXPORT DataArrayDouble *getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const;
//
MEDLOADER_EXPORT void setFieldNoProfileSBT(const MEDCouplingFieldDouble *field);
MEDLOADER_EXPORT DataArrayDouble *getUndergroundDataArray() const;
MEDLOADER_EXPORT DataArrayDouble *getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const;
- MEDLOADER_EXPORT std::vector< std::vector<DataArrayDouble *> > getFieldSplitedByType2(const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
+ MEDLOADER_EXPORT std::vector< std::vector<DataArrayDouble *> > getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception);
public:
MEDLOADER_EXPORT static void SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MEDCouplingAutoRefCountObjectPtr<DataArray>& arr);
const MEDFileField1TSWithoutSDA *contentNotNull() const;
MEDFileField1TSWithoutSDA *contentNotNull();
private:
- MEDFileField1TS(const char *fileName, bool loadAll);
- MEDFileField1TS(const char *fileName, const char *fieldName, bool loadAll);
- MEDFileField1TS(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll);
+ MEDFileField1TS(const std::string& fileName, bool loadAll);
+ MEDFileField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll);
+ MEDFileField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll);
MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent);
MEDFileField1TS();
};
{
public:
MEDLOADER_EXPORT static MEDFileIntField1TS *New();
- MEDLOADER_EXPORT static MEDFileIntField1TS *New(const char *fileName, bool loadAll=true);
- MEDLOADER_EXPORT static MEDFileIntField1TS *New(const char *fileName, const char *fieldName, bool loadAll=true);
- MEDLOADER_EXPORT static MEDFileIntField1TS *New(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll=true);
+ MEDLOADER_EXPORT static MEDFileIntField1TS *New(const std::string& fileName, bool loadAll=true);
+ MEDLOADER_EXPORT static MEDFileIntField1TS *New(const std::string& fileName, const std::string& fieldName, bool loadAll=true);
+ MEDLOADER_EXPORT static MEDFileIntField1TS *New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll=true);
MEDLOADER_EXPORT static MEDFileIntField1TS *New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent);
MEDLOADER_EXPORT MEDFileField1TS *convertToDouble(bool isDeepCpyGlobs=true) const;
MEDLOADER_EXPORT MEDFileAnyTypeField1TS *shallowCpy() const;
MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, DataArrayInt* &arrOut, int renumPol=0) const;
MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol=0) const;
MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol=0) const;
- MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtLevelOld(TypeOfField type, const char *mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol=0) const;
+ MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol=0) const;
MEDLOADER_EXPORT DataArrayInt *getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const;
//
MEDLOADER_EXPORT void setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals);
MEDFileIntField1TSWithoutSDA *contentNotNull();
private:
MEDFileIntField1TS();
- MEDFileIntField1TS(const char *fileName, bool loadAll);
- MEDFileIntField1TS(const char *fileName, const char *fieldName, bool loadAll);
- MEDFileIntField1TS(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll);
+ MEDFileIntField1TS(const std::string& fileName, bool loadAll);
+ MEDFileIntField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll);
+ MEDFileIntField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll);
MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent);
};
{
protected:
MEDFileAnyTypeFieldMultiTSWithoutSDA();
- MEDFileAnyTypeFieldMultiTSWithoutSDA(const char *fieldName);
+ MEDFileAnyTypeFieldMultiTSWithoutSDA(const std::string& fieldName);
MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll);
- MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll);
+ MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll);
public:
MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildren() const;
MEDLOADER_EXPORT const MEDFileAnyTypeField1TSWithoutSDA& getTimeStepEntry(int iteration, int order) const;
MEDLOADER_EXPORT MEDFileAnyTypeField1TSWithoutSDA& getTimeStepEntry(int iteration, int order);
MEDLOADER_EXPORT std::string getMeshName() const;
- MEDLOADER_EXPORT void setMeshName(const char *newMeshName);
+ MEDLOADER_EXPORT void setMeshName(const std::string& newMeshName);
MEDLOADER_EXPORT bool changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab);
MEDLOADER_EXPORT int getNumberOfTS() const;
MEDLOADER_EXPORT void eraseEmptyTS();
MEDLOADER_EXPORT void pushBackTimeStep(MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA>& tse);
MEDLOADER_EXPORT void synchronizeNameScope();
MEDLOADER_EXPORT void simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const;
- MEDLOADER_EXPORT int getNonEmptyLevels(int iteration, int order, const char *mname, std::vector<int>& levs) const;
+ MEDLOADER_EXPORT int getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const;
MEDLOADER_EXPORT void appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob);
MEDLOADER_EXPORT void appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob);
- MEDLOADER_EXPORT std::vector< std::vector< std::pair<int,int> > > getFieldSplitedByType(int iteration, int order, const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const;
+ MEDLOADER_EXPORT std::vector< std::vector< std::pair<int,int> > > getFieldSplitedByType(int iteration, int order, const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const;
MEDLOADER_EXPORT std::vector< std::vector<TypeOfField> > getTypesOfFieldAvailable() const;
MEDLOADER_EXPORT DataArray *getUndergroundDataArray(int iteration, int order) const;
MEDLOADER_EXPORT DataArray *getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const;
- MEDLOADER_EXPORT bool renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N, MEDFileFieldGlobsReal& glob);
+ MEDLOADER_EXPORT bool renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N, MEDFileFieldGlobsReal& glob);
MEDLOADER_EXPORT void loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll);
MEDLOADER_EXPORT void writeLL(med_idt fid, const MEDFileWritable& opts) const;
MEDLOADER_EXPORT void loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc);
class MEDFileFieldMultiTSWithoutSDA : public MEDFileAnyTypeFieldMultiTSWithoutSDA
{
public:
- MEDLOADER_EXPORT static MEDFileFieldMultiTSWithoutSDA *New(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll);
+ MEDLOADER_EXPORT static MEDFileFieldMultiTSWithoutSDA *New(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll);
MEDLOADER_EXPORT MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll);
MEDLOADER_EXPORT const char *getTypeStr() const;
MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTSWithoutSDA *shallowCpy() const;
MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTSWithoutSDA *createNew() const;
- MEDLOADER_EXPORT std::vector< std::vector<DataArrayDouble *> > getFieldSplitedByType2(int iteration, int order, const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const;
+ MEDLOADER_EXPORT std::vector< std::vector<DataArrayDouble *> > getFieldSplitedByType2(int iteration, int order, const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const;
MEDLOADER_EXPORT MEDFileIntFieldMultiTSWithoutSDA *convertToInt() const;
protected:
- MEDFileFieldMultiTSWithoutSDA(const char *fieldName);
- MEDFileFieldMultiTSWithoutSDA(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll);
+ MEDFileFieldMultiTSWithoutSDA(const std::string& fieldName);
+ MEDFileFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll);
med_field_type getMEDFileFieldType() const { return MED_FLOAT64; }
MEDFileAnyTypeField1TSWithoutSDA *createNew1TSWithoutSDAEmptyInstance() const;
void checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const;
class MEDFileIntFieldMultiTSWithoutSDA : public MEDFileAnyTypeFieldMultiTSWithoutSDA
{
public:
- MEDLOADER_EXPORT static MEDFileIntFieldMultiTSWithoutSDA *New(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll);
+ MEDLOADER_EXPORT static MEDFileIntFieldMultiTSWithoutSDA *New(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll);
MEDLOADER_EXPORT MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll);
MEDLOADER_EXPORT const char *getTypeStr() const;
MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTSWithoutSDA *shallowCpy() const;
MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTSWithoutSDA *createNew() const;
MEDLOADER_EXPORT MEDFileFieldMultiTSWithoutSDA *convertToDouble() const;
protected:
- MEDFileIntFieldMultiTSWithoutSDA(const char *fieldName);
- MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll);
+ MEDFileIntFieldMultiTSWithoutSDA(const std::string& fieldName);
+ MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll);
med_field_type getMEDFileFieldType() const { return MED_INT32; }
MEDFileAnyTypeField1TSWithoutSDA *createNew1TSWithoutSDAEmptyInstance() const;
void checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const;
{
protected:
MEDFileAnyTypeFieldMultiTS();
- MEDFileAnyTypeFieldMultiTS(const char *fileName, bool loadAll);
- MEDFileAnyTypeFieldMultiTS(const char *fileName, const char *fieldName, bool loadAll);
+ MEDFileAnyTypeFieldMultiTS(const std::string& fileName, bool loadAll);
+ MEDFileAnyTypeFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll);
MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent);
- static MEDFileAnyTypeFieldMultiTS *BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, const char *fileName);
- static MEDFileAnyTypeFieldMultiTSWithoutSDA *BuildContentFrom(med_idt fid, const char *fileName, bool loadAll);
- static MEDFileAnyTypeFieldMultiTSWithoutSDA *BuildContentFrom(med_idt fid, const char *fileName, const char *fieldName, bool loadAll);
+ static MEDFileAnyTypeFieldMultiTS *BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, const std::string& fileName);
+ static MEDFileAnyTypeFieldMultiTSWithoutSDA *BuildContentFrom(med_idt fid, const std::string& fileName, bool loadAll);
+ static MEDFileAnyTypeFieldMultiTSWithoutSDA *BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, bool loadAll);
public:
- MEDLOADER_EXPORT static MEDFileAnyTypeFieldMultiTS *New(const char *fileName, bool loadAll=true);
- MEDLOADER_EXPORT static MEDFileAnyTypeFieldMultiTS *New(const char *fileName, const char *fieldName, bool loadAll=true);
+ MEDLOADER_EXPORT static MEDFileAnyTypeFieldMultiTS *New(const std::string& fileName, bool loadAll=true);
+ MEDLOADER_EXPORT static MEDFileAnyTypeFieldMultiTS *New(const std::string& fileName, const std::string& fieldName, bool loadAll=true);
MEDLOADER_EXPORT void loadArrays();
MEDLOADER_EXPORT void loadArraysIfNecessary();
MEDLOADER_EXPORT void unloadArrays();
- MEDLOADER_EXPORT void write(const char *fileName, int mode) const;
+ MEDLOADER_EXPORT void write(const std::string& fileName, int mode) const;
MEDLOADER_EXPORT void writeLL(med_idt fid) const;
MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildren() const;
MEDLOADER_EXPORT static int CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1);
public:// direct forwarding to MEDFileField1TSWithoutSDA instance _content
MEDLOADER_EXPORT std::string getName() const;
- MEDLOADER_EXPORT void setName(const char *name);
+ MEDLOADER_EXPORT void setName(const std::string& name);
MEDLOADER_EXPORT std::string getDtUnit() const;
- MEDLOADER_EXPORT void setDtUnit(const char *dtUnit);
+ MEDLOADER_EXPORT void setDtUnit(const std::string& dtUnit);
MEDLOADER_EXPORT std::string getMeshName() const;
- MEDLOADER_EXPORT void setMeshName(const char *newMeshName);
+ MEDLOADER_EXPORT void setMeshName(const std::string& newMeshName);
MEDLOADER_EXPORT std::string simpleRepr() const;
MEDLOADER_EXPORT void simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const;
MEDLOADER_EXPORT int getNumberOfTS() const;
MEDLOADER_EXPORT const std::vector<std::string>& getInfo() const;
MEDLOADER_EXPORT void setInfo(const std::vector<std::string>& info);
MEDLOADER_EXPORT int getNumberOfComponents() const;
- MEDLOADER_EXPORT int getNonEmptyLevels(int iteration, int order, const char *mname, std::vector<int>& levs) const;
+ MEDLOADER_EXPORT int getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const;
MEDLOADER_EXPORT std::vector< std::vector<TypeOfField> > getTypesOfFieldAvailable() const;
- MEDLOADER_EXPORT std::vector< std::vector< std::pair<int,int> > > getFieldSplitedByType(int iteration, int order, const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const;
+ MEDLOADER_EXPORT std::vector< std::vector< std::pair<int,int> > > getFieldSplitedByType(int iteration, int order, const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const;
MEDLOADER_EXPORT MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> getContent();
public:
MEDLOADER_EXPORT std::vector<std::string> getPflsReallyUsed() const;
{
public:
MEDLOADER_EXPORT static MEDFileFieldMultiTS *New();
- MEDLOADER_EXPORT static MEDFileFieldMultiTS *New(const char *fileName, bool loadAll=true);
- MEDLOADER_EXPORT static MEDFileFieldMultiTS *New(const char *fileName, const char *fieldName, bool loadAll=true);
+ MEDLOADER_EXPORT static MEDFileFieldMultiTS *New(const std::string& fileName, bool loadAll=true);
+ MEDLOADER_EXPORT static MEDFileFieldMultiTS *New(const std::string& fileName, const std::string& fieldName, bool loadAll=true);
MEDLOADER_EXPORT static MEDFileFieldMultiTS *New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent);
MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTS *shallowCpy() const;
MEDLOADER_EXPORT void checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const;
MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol=0) const;
MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const;
MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol=0) const;
- MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtLevelOld(TypeOfField type, const char *mname, int iteration, int order, int meshDimRelToMax, int renumPol=0) const;
+ MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtLevelOld(TypeOfField type, const std::string& mname, int iteration, int order, int meshDimRelToMax, int renumPol=0) const;
MEDLOADER_EXPORT DataArrayDouble *getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const;
//
MEDLOADER_EXPORT void appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field);
MEDLOADER_EXPORT void appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile);
- MEDLOADER_EXPORT std::vector< std::vector<DataArrayDouble *> > getFieldSplitedByType2(int iteration, int order, const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const;
+ MEDLOADER_EXPORT std::vector< std::vector<DataArrayDouble *> > getFieldSplitedByType2(int iteration, int order, const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const;
MEDLOADER_EXPORT DataArrayDouble *getUndergroundDataArray(int iteration, int order) const;
MEDLOADER_EXPORT DataArrayDouble *getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const;
private:
private:
MEDFileFieldMultiTS();
MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent);
- MEDFileFieldMultiTS(const char *fileName, bool loadAll);
- MEDFileFieldMultiTS(const char *fileName, const char *fieldName, bool loadAll);
+ MEDFileFieldMultiTS(const std::string& fileName, bool loadAll);
+ MEDFileFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll);
};
/*!
{
public:
MEDLOADER_EXPORT static MEDFileIntFieldMultiTS *New();
- MEDLOADER_EXPORT static MEDFileIntFieldMultiTS *New(const char *fileName, bool loadAll=true);
- MEDLOADER_EXPORT static MEDFileIntFieldMultiTS *New(const char *fileName, const char *fieldName, bool loadAll=true);
+ MEDLOADER_EXPORT static MEDFileIntFieldMultiTS *New(const std::string& fileName, bool loadAll=true);
+ MEDLOADER_EXPORT static MEDFileIntFieldMultiTS *New(const std::string& fileName, const std::string& fieldName, bool loadAll=true);
MEDLOADER_EXPORT static MEDFileIntFieldMultiTS *New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent);
MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTS *shallowCpy() const;
MEDLOADER_EXPORT void checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const;
MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, int iteration, int order, DataArrayInt* &arrOut, int renumPol=0) const;
MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol=0) const;
MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol=0) const;
- MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtLevelOld(TypeOfField type, int iteration, int order, const char *mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol=0) const;
+ MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol=0) const;
MEDLOADER_EXPORT DataArrayInt *getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const;
//
MEDLOADER_EXPORT void appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals);
private:
MEDFileIntFieldMultiTS();
MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent);
- MEDFileIntFieldMultiTS(const char *fileName, bool loadAll);
- MEDFileIntFieldMultiTS(const char *fileName, const char *fieldName, bool loadAll);
+ MEDFileIntFieldMultiTS(const std::string& fileName, bool loadAll);
+ MEDFileIntFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll);
};
class MEDFileAnyTypeFieldMultiTSIterator
{
public:
MEDLOADER_EXPORT static MEDFileFields *New();
- MEDLOADER_EXPORT static MEDFileFields *New(const char *fileName, bool loadAll=true);
+ MEDLOADER_EXPORT static MEDFileFields *New(const std::string& fileName, bool loadAll=true);
MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildren() const;
MEDLOADER_EXPORT MEDFileFields *deepCpy() const;
MEDLOADER_EXPORT MEDFileFields *shallowCpy() const;
- MEDLOADER_EXPORT void write(const char *fileName, int mode) const;
+ MEDLOADER_EXPORT void write(const std::string& fileName, int mode) const;
MEDLOADER_EXPORT void writeLL(med_idt fid) const;
MEDLOADER_EXPORT void loadArrays();
MEDLOADER_EXPORT void loadArraysIfNecessary();
MEDLOADER_EXPORT void pushField(MEDFileAnyTypeFieldMultiTS *field);
MEDLOADER_EXPORT void pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields);
MEDLOADER_EXPORT void setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field);
- MEDLOADER_EXPORT int getPosFromFieldName(const char *fieldName) const;
+ MEDLOADER_EXPORT int getPosFromFieldName(const std::string& fieldName) const;
MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTS *getFieldAtPos(int i) const;
- MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTS *getFieldWithName(const char *fieldName) const;
+ MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTS *getFieldWithName(const std::string& fieldName) const;
MEDLOADER_EXPORT MEDFileFields *buildSubPart(const int *startIds, const int *endIds) const;
- MEDLOADER_EXPORT MEDFileFields *partOfThisLyingOnSpecifiedMeshName(const char *meshName) const;
+ MEDLOADER_EXPORT MEDFileFields *partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const;
MEDLOADER_EXPORT MEDFileFields *partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const;
MEDLOADER_EXPORT MEDFileFields *partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const;
MEDLOADER_EXPORT MEDFileFieldsIterator *iterator();
MEDLOADER_EXPORT void destroyFieldsAtPos(const int *startIds, const int *endIds);
MEDLOADER_EXPORT void destroyFieldsAtPos2(int bg, int end, int step);
MEDLOADER_EXPORT bool changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab);
- MEDLOADER_EXPORT bool renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N);
+ MEDLOADER_EXPORT bool renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N);
public:
MEDLOADER_EXPORT std::vector<std::string> getPflsReallyUsed() const;
MEDLOADER_EXPORT std::vector<std::string> getLocsReallyUsed() const;
MEDLOADER_EXPORT void changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
private:
MEDFileFields();
- MEDFileFields(const char *fileName, bool loadAll);
+ MEDFileFields(const std::string& fileName, bool loadAll);
private:
std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > _fields;
};
MEDFileMeshStruct::MEDFileMeshStruct(const MEDFileMesh *mesh):_mesh(mesh)
{
- std::vector<int> levs=mesh->getNonEmptyLevels();
+ std::vector<int> levs(mesh->getNonEmptyLevels());
_name=mesh->getName();
_nb_nodes=mesh->getNumberOfNodes();
- _geo_types_distrib.resize(levs.size());
- for(std::vector<int>::const_iterator lev=levs.begin();lev!=levs.end();lev++)
- _geo_types_distrib[-(*lev)]=mesh->getDistributionOfTypes(*lev);
+ if(!levs.empty())
+ {
+ _geo_types_distrib.resize(-(*std::min_element(levs.begin(),levs.end()))+1);
+ for(std::vector<int>::const_iterator lev=levs.begin();lev!=levs.end();lev++)
+ _geo_types_distrib[-(*lev)]=mesh->getDistributionOfTypes(*lev);
+ }
}
int MEDFileMeshStruct::getLevelOfGeoType(INTERP_KERNEL::NormalizedCellType t) const
MEDMeshMultiLev *MEDMeshMultiLev::NewOnlyOnNode(const MEDFileMesh *m, const DataArrayInt *pflOnNode)
{
- std::vector<int> levs(1,0);
- MEDCouplingAutoRefCountObjectPtr<MEDMeshMultiLev> ret(MEDMeshMultiLev::New(m,levs));
+ MEDCouplingAutoRefCountObjectPtr<MEDMeshMultiLev> ret(MEDMeshMultiLev::New(m,m->getNonEmptyLevels()));
ret->selectPartOfNodes(pflOnNode);
return ret.retn();
}
const DataArrayInt *nr(_node_reduction);
if(pflName.empty() && !nr)
return true;
+ if(!pflName.empty() && !nr)
+ return false;
if(pflName==nr->getName())
return true;
return false;
}
}
+std::vector< INTERP_KERNEL::NormalizedCellType > MEDMeshMultiLev::getGeoTypes() const
+{
+ return _geo_types;
+}
+
void MEDMeshMultiLev::setFamilyIdsOnCells(DataArrayInt *famIds, bool isNoCopy)
{
_cell_fam_ids=famIds;
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> p2(nr->deepCpy());
p1->sort(true); p2->sort(true);
if(!p1->isEqualWithoutConsideringStr(*p2))
- throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for nodes 3 !");
+ throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : it appears that a profile on nodes does not cover the cells correctly !");
p1=DataArrayInt::FindPermutationFromFirstToSecond(globs->getProfile(pflName.c_str()),nr);
MEDCouplingAutoRefCountObjectPtr<DataArray> ret(vals->deepCpy());
ret->renumberInPlace(p1->begin());
}
}
+/*!
+ * This method is called to add NORM_POINT1 cells in \a this so that orphan nodes in \a verticesToAdd will be fetched.
+ */
+void MEDMeshMultiLev::appendVertices(const DataArrayInt *verticesToAdd, DataArrayInt *nr)
+{
+ int nbOfVertices(verticesToAdd->getNumberOfTuples());
+ std::size_t sz(_pfls.size());
+ _pfls.resize(sz+1);
+ _geo_types.resize(sz+1,INTERP_KERNEL::NORM_POINT1);
+ _nb_entities.resize(sz+1,nbOfVertices);
+ _node_reduction=nr; nr->incrRef();
+ _nb_nodes+=nbOfVertices;
+ const DataArrayInt *cf(_cell_fam_ids),*cn(_cell_num_ids),*nf(_node_fam_ids),*nn(_node_num_ids);
+ if(cf)
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp;
+ std::vector<const DataArrayInt *> a(2);
+ a[0]=cf;
+ if(nf)
+ tmp=nf->selectByTupleIdSafe(verticesToAdd->begin(),verticesToAdd->end());
+ else
+ {
+ tmp=DataArrayInt::New(); tmp->alloc(nbOfVertices,1); tmp->fillWithZero();
+ }
+ a[1]=tmp;
+ _cell_fam_ids=DataArrayInt::Aggregate(a);
+ _cell_fam_ids_nocpy=false;
+ }
+ if(cn)
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp;
+ std::vector<const DataArrayInt *> a(2);
+ a[0]=cn;
+ if(nn)
+ tmp=nn->selectByTupleIdSafe(verticesToAdd->begin(),verticesToAdd->end());
+ else
+ {
+ tmp=DataArrayInt::New(); tmp->alloc(nbOfVertices,1); tmp->fillWithZero();
+ }
+ a[1]=tmp;
+ _cell_num_ids=DataArrayInt::Aggregate(a);
+ _cell_num_ids_nocpy=false;
+ }
+}
+
MEDMeshMultiLev::MEDMeshMultiLev():_nb_nodes(0),_cell_fam_ids_nocpy(false)
{
}
v.insert(v.end(),vTmp.begin(),vTmp.end());
}
std::size_t sz(v.size());
+ if(v.empty())
+ {
+ _coords=m->getCoords(); _coords->incrRef();
+ }
_parts.resize(sz);
_pfls.resize(sz);
_geo_types.resize(sz);
if(!tmps[i])
f=false;
}
- if(f)
+ if(f && !tmps.empty())
_cell_fam_ids=DataArrayInt::Aggregate(tmps);
}
_cell_num_ids_nocpy=(levs.size()==1);
if(!tmps[i])
n=false;
}
- if(n)
+ if(n && !tmps.empty())
_cell_num_ids=DataArrayInt::Aggregate(tmps);
}
// node part
std::vector< const DataArrayInt *> aa(sz);
for(std::size_t i=0;i<sz;i++)
{
-
const DataArrayInt *pfl(_pfls[i]);
MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> m(_parts[i]);
if(pfl)
else
_pfls[i]=cellIdsSafe;
}
- _node_reduction=DataArrayInt::Aggregate(aa);
+ if(!aa.empty())
+ _node_reduction=DataArrayInt::Aggregate(aa);//general case
+ else
+ _node_reduction=pflNodes->deepCpy();//case where no cells in read mesh.
_node_reduction->sort(true);
_node_reduction=_node_reduction->buildUnique();
+ if(_node_reduction->getNumberOfTuples()==pflNodes->getNumberOfTuples())
+ return ;//This is the classical case where the input node profile corresponds perfectly to a subset of cells in _parts
+ if(_node_reduction->getNumberOfTuples()>pflNodes->getNumberOfTuples())
+ throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::selectPartOfNodes : internal error in MEDCoupling during cell select from a list of nodes !");
+ // Here the cells available in _parts is not enough to cover all the nodes in pflNodes. So adding vertices cells in _parts...
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pflNodes2(pflNodes->deepCpy());
+ pflNodes2->sort(true);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> diff(pflNodes2->buildSubstractionOptimized(_node_reduction));
+ appendVertices(diff,pflNodes2);
}
MEDMeshMultiLev *MEDUMeshMultiLev::prepare() const
return new MEDUMeshMultiLev(*this);
}
-MEDUMeshMultiLev::MEDUMeshMultiLev(const MEDUMeshMultiLev& other):MEDMeshMultiLev(other),_parts(other._parts)
+MEDUMeshMultiLev::MEDUMeshMultiLev(const MEDUMeshMultiLev& other):MEDMeshMultiLev(other),_parts(other._parts),_coords(other._coords)
{
}
*/
bool MEDUMeshMultiLev::buildVTUArrays(DataArrayDouble *& coords, DataArrayByte *&types, DataArrayInt *&cellLocations, DataArrayInt *& cells, DataArrayInt *&faceLocations, DataArrayInt *&faces) const
{
+ const DataArrayDouble *tmp(0);
if(_parts.empty())
- throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::getVTUArrays : empty array !");
- if(!(const MEDCoupling1GTUMesh *)_parts[0])
- throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::getVTUArrays : first part is null !");
- const DataArrayDouble *tmp(_parts[0]->getCoords());
+ tmp=_coords;
+ else
+ tmp=_parts[0]->getCoords();
if(!tmp)
throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::getVTUArrays : the coordinates are null !");
MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> a(const_cast<DataArrayDouble *>(tmp)); tmp->incrRef();
const DataArrayInt *nr(_node_reduction);
if(!nr)
return ;
+ if(nodalConnVTK->empty() && !polyhedNodalConnVTK)
+ {
+ coords=(coords->selectByTupleIdSafe(nr->begin(),nr->end()));
+ return ;
+ }
int sz(coords->getNumberOfTuples());
std::vector<bool> b(sz,false);
const int *work(nodalConnVTK->begin()),*endW(nodalConnVTK->end());
coords=(coords->selectByTupleIdSafe(nr->begin(),nr->end()));
}
+
+void MEDUMeshMultiLev::appendVertices(const DataArrayInt *verticesToAdd, DataArrayInt *nr)
+{
+ int nbOfCells(verticesToAdd->getNumberOfTuples());//it is not a bug cells are NORM_POINT1
+ MEDMeshMultiLev::appendVertices(verticesToAdd,nr);
+ MEDCouplingAutoRefCountObjectPtr<MEDCoupling1SGTUMesh> elt(MEDCoupling1SGTUMesh::New("",INTERP_KERNEL::NORM_POINT1));
+ elt->allocateCells(nbOfCells);
+ for(int i=0;i<nbOfCells;i++)
+ {
+ int pt(verticesToAdd->getIJ(i,0));
+ elt->insertNextCell(&pt,&pt+1);
+ }
+ if(_parts.empty())
+ throw INTERP_KERNEL::Exception("MEDUMeshMultiLev::appendVertices : parts are empty !");
+ elt->setCoords(_parts[0]->getCoords());
+ MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> elt2((MEDCoupling1SGTUMesh *)elt); elt2->incrRef();
+ _parts.push_back(elt2);
+}
+
//=
-MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev()
+MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev():_is_internal(true)
{
}
-MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev(const MEDFileStructuredMesh *m, const std::vector<int>& lev)
+MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev(const MEDFileStructuredMesh *m, const std::vector<int>& lev):_is_internal(true)
{
// ids fields management
_cell_fam_ids_nocpy=true; _cell_num_ids_nocpy=true;
}
}
-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)
+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),_is_internal(true)
{
// ids fields management
_cell_fam_ids_nocpy=true; _cell_num_ids_nocpy=true;
}
}
+MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev(const MEDStructuredMeshMultiLev& other):MEDMeshMultiLev(other),_is_internal(true)
+{
+}
+
void MEDStructuredMeshMultiLev::selectPartOfNodes(const DataArrayInt *pflNodes)
{
if(!pflNodes || !pflNodes->isAllocated())
_pfls[0]=cellIdsSafe;
}
-MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev(const MEDStructuredMeshMultiLev& other):MEDMeshMultiLev(other)
-{
-}
-
//=
MEDCMeshMultiLev *MEDCMeshMultiLev::New(const MEDFileCMesh *m, const std::vector<int>& levs)
throw INTERP_KERNEL::Exception("MEDCMeshMultiLev constructor : null input pointer !");
if(levs.size()!=1 || levs[0]!=0)
throw INTERP_KERNEL::Exception("MEDCMeshMultiLev constructor : levels supported is 0 only !");
- int mdim(MEDCouplingStructuredMesh::GetGeoTypeGivenMeshDimension(m->getMeshDimension()));
- _coords.resize(mdim);
- for(int i=0;i<mdim;i++)
+ int sdim(m->getSpaceDimension());
+ _coords.resize(sdim);
+ for(int i=0;i<sdim;i++)
{
DataArrayDouble *elt(const_cast<DataArrayDouble *>(m->getMesh()->getCoordsAt(i)));
if(!elt)
throw INTERP_KERNEL::Exception("MEDCMeshMultiLev constructor 2 : presence of null pointer for an vector of double along an axis !");
+ elt->incrRef();
_coords[i]=elt;
}
}
MEDMeshMultiLev *MEDCMeshMultiLev::prepare() const
{
- const DataArrayInt *pfl(_pfls[0]),*nr(_node_reduction);
+ const DataArrayInt *pfl(0),*nr(_node_reduction);
+ if(!_pfls.empty())
+ pfl=_pfls[0];
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> nnr;
std::vector<int> cgs,ngs(getNodeGridStructure());
cgs.resize(ngs.size());
if(MEDCouplingStructuredMesh::IsPartStructured(pfl->begin(),pfl->end(),cgs,cellParts))
{
MEDCouplingAutoRefCountObjectPtr<MEDCMeshMultiLev> ret(new MEDCMeshMultiLev(*this));
+ ret->_is_internal=false;
if(nr)
{ nnr=nr->deepCpy(); nnr->sort(true); ret->setNodeReduction(nnr); }
ret->_nb_entities[0]=pfl->getNumberOfTuples();
}
}
-std::vector< DataArrayDouble * > MEDCMeshMultiLev::buildVTUArrays() const
+/*!
+ * \a param [out] isInternal if true the returned pointers are those in main data structure. If false those pointers have been built espacially for that method.
+ */
+std::vector< DataArrayDouble * > MEDCMeshMultiLev::buildVTUArrays(bool& isInternal) const
{
+ isInternal=_is_internal;
std::size_t sz(_coords.size());
std::vector< DataArrayDouble * > ret(sz);
for(std::size_t i=0;i<sz;i++)
MEDMeshMultiLev *MEDCurveLinearMeshMultiLev::prepare() const
{
- const DataArrayInt *pfl(_pfls[0]),*nr(_node_reduction);
+ const DataArrayInt *pfl(0),*nr(_node_reduction);
+ if(!_pfls.empty())
+ pfl=_pfls[0];
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> nnr;
std::vector<int> cgs,ngs(getNodeGridStructure());
cgs.resize(ngs.size());
}
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> p(MEDCouplingStructuredMesh::BuildExplicitIdsFrom(ngs,nodeParts));
MEDCouplingAutoRefCountObjectPtr<MEDCurveLinearMeshMultiLev> ret(new MEDCurveLinearMeshMultiLev(*this));
+ ret->_is_internal=false;
if(nr)
{ nnr=nr->deepCpy(); nnr->sort(true); ret->setNodeReduction(nnr); }
ret->_nb_entities[0]=pfl->getNumberOfTuples();
}
}
-void MEDCurveLinearMeshMultiLev::buildVTUArrays(DataArrayDouble *&coords, std::vector<int>& nodeStrct) const
+void MEDCurveLinearMeshMultiLev::buildVTUArrays(DataArrayDouble *&coords, std::vector<int>& nodeStrct, bool& isInternal) const
{
+ isInternal=_is_internal;
nodeStrct=_structure;
const DataArrayDouble *coo(_coords);
if(!coo)
}
}
-bool MEDFileField1TSStructItem2::isFastlyEqual(int& startExp, INTERP_KERNEL::NormalizedCellType gt, const char *pflName) const
+bool MEDFileField1TSStructItem2::isFastlyEqual(int& startExp, INTERP_KERNEL::NormalizedCellType gt, const std::string& pflName) const
{
if(startExp!=_start_end.first)
return false;
return MEDMeshMultiLev::New(mst->getTheMesh(),a0,a1,a2);
}
+std::vector<INTERP_KERNEL::NormalizedCellType> MEDFileField1TSStructItem::getGeoTypes(const MEDFileMesh *m) const
+{
+ std::vector<INTERP_KERNEL::NormalizedCellType> ret;
+ if(_type==ON_NODES)
+ {
+ if(!_items.empty() && _items[0].getPflName().empty())
+ {
+ if(m)
+ return m->getAllGeoTypes();
+ else
+ return ret;
+ }
+ else
+ return ret;
+ }
+ for(std::vector< MEDFileField1TSStructItem2 >::const_iterator it=_items.begin();it!=_items.end();it++)
+ {
+ INTERP_KERNEL::NormalizedCellType elt((*it).getGeo());
+ std::vector<INTERP_KERNEL::NormalizedCellType>::iterator it2(std::find(ret.begin(),ret.end(),elt));
+ if(it2==ret.end())
+ ret.push_back(elt);
+ }
+ return ret;
+}
+
MEDFileField1TSStructItem MEDFileField1TSStructItem::BuildItemFrom(const MEDFileAnyTypeField1TS *ref, const MEDFileMeshStruct *meshSt)
{
TypeOfField atype;
std::vector< std::vector<std::string> > pfls,locs;
std::vector< std::vector<TypeOfField> > typesF;
std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
- std::vector< std::vector<std::pair<int,int> > > strtEnds=ref->getFieldSplitedByType(0,geoTypes,typesF,pfls,locs);
+ std::vector< std::vector<std::pair<int,int> > > strtEnds=ref->getFieldSplitedByType(std::string(),geoTypes,typesF,pfls,locs);
std::size_t nbOfGeoTypes(geoTypes.size());
if(nbOfGeoTypes==0)
throw INTERP_KERNEL::Exception("MEDFileField1TSStruct : not null by empty ref !");
else
{
if(!presenceOfPartialNodeDiscr(pos1))
- {//we have only all nodes, no cell definition info -> level 0;
- std::vector<int> levs(1,0);
- return MEDMeshMultiLev::New(mst->getTheMesh(),levs);
+ {//we have only all nodes, no cell definition info -> all existing levels !;
+ return MEDMeshMultiLev::New(mst->getTheMesh(),mst->getTheMesh()->getNonEmptyLevels());
}
else
return MEDMeshMultiLev::NewOnlyOnNode(mst->getTheMesh(),_already_checked[pos1][0].getPfl(globs));
return true;
}
+std::vector<INTERP_KERNEL::NormalizedCellType> MEDFileField1TSStruct::getGeoTypes(const MEDFileMesh *m) const
+{
+ std::vector<INTERP_KERNEL::NormalizedCellType> ret;
+ for(std::vector<MEDFileField1TSStructItem>::const_iterator it=_already_checked.begin();it!=_already_checked.end();it++)
+ {
+ std::vector<INTERP_KERNEL::NormalizedCellType> ret2((*it).getGeoTypes(m));
+ for(std::vector<INTERP_KERNEL::NormalizedCellType>::const_iterator it2=ret2.begin();it2!=ret2.end();it2++)
+ {
+ if(*it2==INTERP_KERNEL::NORM_ERROR)
+ continue;
+ std::vector<INTERP_KERNEL::NormalizedCellType>::iterator it3(std::find(ret.begin(),ret.end(),*it2));
+ if(it3==ret.end())
+ ret.push_back(*it2);
+ }
+ }
+ return ret;
+}
+
/*!
* Returns true if presence in \a this of discretization ON_CELLS, ON_GAUSS_PT, ON_GAUSS_NE.
* If true is returned the pos of the easiest is returned. The easiest is the first element in \a this having the less splitted subparts.
const MEDFileField1TSStruct *objRef(_f1ts_cmps[timeStepId-1]);
return objRef->isDataSetSupportFastlyEqualTo(*obj,globs);
}
+
+int MEDFileFastCellSupportComparator::getNumberOfTS() const
+{
+ return _f1ts_cmps.size();
+}
+
+std::vector<INTERP_KERNEL::NormalizedCellType> MEDFileFastCellSupportComparator::getGeoTypesAt(int timeStepId, const MEDFileMesh *m) const
+{
+ if(timeStepId<0 || timeStepId>=(int)_f1ts_cmps.size())
+ {
+ std::ostringstream oss; oss << "MEDFileFastCellSupportComparator::getGeoTypesAt : requested time step id #" << timeStepId << " is not in [0," << _f1ts_cmps.size() << ") !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ const MEDFileField1TSStruct *elt(_f1ts_cmps[timeStepId]);
+ if(!elt)
+ {
+ std::ostringstream oss; oss << "MEDFileFastCellSupportComparator::getGeoTypesAt : requested time step id #" << timeStepId << " points to a NULL pointer !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ return elt->getGeoTypes(m);
+}
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;
+ MEDLOADER_EXPORT std::vector< INTERP_KERNEL::NormalizedCellType > getGeoTypes() const;
void setFamilyIdsOnCells(DataArrayInt *famIds, bool isNoCopy);
void setNumberIdsOnCells(DataArrayInt *numIds, bool isNoCopy);
void setFamilyIdsOnNodes(DataArrayInt *famIds, bool isNoCopy);
protected:
std::string getPflNameOfId(int id) const;
DataArray *constructDataArray(const MEDFileField1TSStructItem& fst, const MEDFileFieldGlobsReal *globs, const DataArray *vals) const;
+ virtual void appendVertices(const DataArrayInt *verticesToAdd, DataArrayInt *nr);
protected:
MEDMeshMultiLev();
MEDMeshMultiLev(const MEDMeshMultiLev& other);
MEDMeshMultiLev *prepare() const;
MEDUMeshMultiLev(const MEDStructuredMeshMultiLev& other, const MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh>& part);
MEDLOADER_EXPORT bool buildVTUArrays(DataArrayDouble *& coords, DataArrayByte *&types, DataArrayInt *&cellLocations, DataArrayInt *& cells, DataArrayInt *&faceLocations, DataArrayInt *&faces) const;
+ protected:
+ void appendVertices(const DataArrayInt *verticesToAdd, DataArrayInt *nr);
private:
void reorderNodesIfNecessary(MEDCouplingAutoRefCountObjectPtr<DataArrayDouble>& coords, DataArrayInt *nodalConnVTK, DataArrayInt *polyhedNodalConnVTK) const;
private:
MEDUMeshMultiLev(const MEDFileUMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities);
private:
std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> > _parts;
+ //! this attribute is used only for mesh with no cells but having coordinates. For classical umeshes those pointer is equal to pointer of coordinates of instances in this->_parts.
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> _coords;
};
class MEDStructuredMeshMultiLev : public MEDMeshMultiLev
MEDStructuredMeshMultiLev(const MEDStructuredMeshMultiLev& other);
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);
+ protected:
+ bool _is_internal;
};
class MEDCMeshMultiLev : public MEDStructuredMeshMultiLev
static MEDCMeshMultiLev *New(const MEDFileCMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities);
std::vector<int> getNodeGridStructure() const;
MEDMeshMultiLev *prepare() const;
- MEDLOADER_EXPORT std::vector< DataArrayDouble * > buildVTUArrays() const;
+ MEDLOADER_EXPORT std::vector< DataArrayDouble * > buildVTUArrays(bool& isInternal) const;
private:
MEDCMeshMultiLev(const MEDCMeshMultiLev& other);
MEDCMeshMultiLev(const MEDFileCMesh *m, const std::vector<int>& levs);
static MEDCurveLinearMeshMultiLev *New(const MEDFileCurveLinearMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls , const std::vector<int>& nbEntities);
std::vector<int> getNodeGridStructure() const;
MEDMeshMultiLev *prepare() const;
- MEDLOADER_EXPORT void buildVTUArrays(DataArrayDouble *&coords, std::vector<int>& nodeStrct) const;
+ MEDLOADER_EXPORT void buildVTUArrays(DataArrayDouble *&coords, std::vector<int>& nodeStrct, bool& isInternal) const;
private:
MEDCurveLinearMeshMultiLev(const MEDCurveLinearMeshMultiLev& other);
MEDCurveLinearMeshMultiLev(const MEDFileCurveLinearMesh *m, const std::vector<int>& levs);
int getNbOfIntegrationPts(const MEDFileFieldGlobsReal *globs) const;
//! warning this method also set _nb_of_entity attribute !
void checkInRange(int nbOfEntity, int nip, const MEDFileFieldGlobsReal *globs);
- bool isFastlyEqual(int& startExp, INTERP_KERNEL::NormalizedCellType gt, const char *pflName) const;
+ bool isFastlyEqual(int& startExp, INTERP_KERNEL::NormalizedCellType gt, const std::string& pflName) const;
bool operator==(const MEDFileField1TSStructItem2& other) const throw(INTERP_KERNEL::Exception);
bool isCellSupportEqual(const MEDFileField1TSStructItem2& other, const MEDFileFieldGlobsReal *globs) const;
bool isNodeSupportEqual(const MEDFileField1TSStructItem2& other, const MEDFileFieldGlobsReal *globs) const;
MEDFileField1TSStructItem simplifyMeOnCellEntity(const MEDFileFieldGlobsReal *globs) const;
bool isCompatibleWithNodesDiscr(const MEDFileField1TSStructItem& other, const MEDFileMeshStruct *meshSt, const MEDFileFieldGlobsReal *globs) const;
bool isFullyOnOneLev(const MEDFileMeshStruct *meshSt, int& theFirstLevFull) const;
+ std::vector<INTERP_KERNEL::NormalizedCellType> getGeoTypes(const MEDFileMesh *m) const;
MEDLOADER_EXPORT MEDMeshMultiLev *buildFromScratchDataSetSupportOnCells(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs) const;
MEDLOADER_EXPORT static MEDFileField1TSStructItem BuildItemFrom(const MEDFileAnyTypeField1TS *ref, const MEDFileMeshStruct *meshSt);
private:
bool isCompatibleWithNodesDiscr(const MEDFileAnyTypeField1TS *other, const MEDFileMeshStruct *meshSt);
MEDLOADER_EXPORT MEDMeshMultiLev *buildFromScratchDataSetSupport(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs) const;
bool isDataSetSupportFastlyEqualTo(const MEDFileField1TSStruct& other, const MEDFileFieldGlobsReal *globs) const;
+ std::vector<INTERP_KERNEL::NormalizedCellType> getGeoTypes(const MEDFileMesh *m) const;
private:
MEDFileField1TSStruct(const MEDFileAnyTypeField1TS *ref, MEDFileMeshStruct *mst);
bool presenceOfCellDiscr(int& pos) const;
MEDLOADER_EXPORT static MEDFileFastCellSupportComparator *New(const MEDFileMeshStruct *m, const MEDFileAnyTypeFieldMultiTS *ref);
MEDLOADER_EXPORT MEDMeshMultiLev *buildFromScratchDataSetSupport(int timeStepId, const MEDFileFieldGlobsReal *globs) const;
MEDLOADER_EXPORT bool isDataSetSupportEqualToThePreviousOne(int timeStepId, const MEDFileFieldGlobsReal *globs) const;
+ MEDLOADER_EXPORT int getNumberOfTS() const;
+ MEDLOADER_EXPORT std::vector<INTERP_KERNEL::NormalizedCellType> getGeoTypesAt(int timeStepId, const MEDFileMesh *m) const;
bool isEqual(const MEDFileAnyTypeFieldMultiTS *other);
bool isCompatibleWithNodesDiscr(const MEDFileAnyTypeFieldMultiTS *other);
std::size_t getHeapMemorySizeWithoutChildren() const;
* \throw If there is no meshes in the file.
* \throw If the mesh in the file is of a not supported type.
*/
-MEDFileMesh *MEDFileMesh::New(const char *fileName, MEDFileMeshReadSelector *mrs)
+MEDFileMesh *MEDFileMesh::New(const std::string& fileName, MEDFileMeshReadSelector *mrs)
{
std::vector<std::string> ms=MEDLoader::GetMeshNames(fileName);
if(ms.empty())
}
MEDFileUtilities::CheckFileForRead(fileName);
ParaMEDMEM::MEDCouplingMeshType meshType;
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
int dt,it;
std::string dummy2;
- MEDFileMeshL2::GetMeshIdFromName(fid,ms.front().c_str(),meshType,dt,it,dummy2);
+ MEDFileMeshL2::GetMeshIdFromName(fid,ms.front(),meshType,dt,it,dummy2);
switch(meshType)
{
case UNSTRUCTURED:
{
MEDCouplingAutoRefCountObjectPtr<MEDFileUMesh> ret=MEDFileUMesh::New();
- ret->loadUMeshFromFile(fid,ms.front().c_str(),dt,it,mrs);
+ ret->loadUMeshFromFile(fid,ms.front(),dt,it,mrs);
return (MEDFileUMesh *)ret.retn();
}
case CARTESIAN:
{
MEDCouplingAutoRefCountObjectPtr<MEDFileCMesh> ret=MEDFileCMesh::New();
- ret->loadCMeshFromFile(fid,ms.front().c_str(),dt,it,mrs);
+ ret->loadCMeshFromFile(fid,ms.front(),dt,it,mrs);
return (MEDFileCMesh *)ret.retn();
}
case CURVE_LINEAR:
{
MEDCouplingAutoRefCountObjectPtr<MEDFileCurveLinearMesh> ret=MEDFileCurveLinearMesh::New();
- ret->loadCLMeshFromFile(fid,ms.front().c_str(),dt,it,mrs);
+ ret->loadCLMeshFromFile(fid,ms.front(),dt,it,mrs);
return (MEDFileCurveLinearMesh *)ret.retn();
}
default:
* \throw If there is no mesh with given attributes in the file.
* \throw If the mesh in the file is of a not supported type.
*/
-MEDFileMesh *MEDFileMesh::New(const char *fileName, const char *mName, int dt, int it, MEDFileMeshReadSelector *mrs)
+MEDFileMesh *MEDFileMesh::New(const std::string& fileName, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs)
{
MEDFileUtilities::CheckFileForRead(fileName);
ParaMEDMEM::MEDCouplingMeshType meshType;
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
int dummy0,dummy1;
std::string dummy2;
MEDFileMeshL2::GetMeshIdFromName(fid,mName,meshType,dummy0,dummy1,dummy2);
* \throw If the mesh name is not set.
* \throw If \a mode == 1 and the same data is present in an existing file.
*/
-void MEDFileMesh::write(const char *fileName, int mode) const
+void MEDFileMesh::write(const std::string& fileName, int mode) const
{
med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod);
std::ostringstream oss; oss << "MEDFileMesh : error on attempt to write in file : \"" << fileName << "\"";
- MEDFileUtilities::CheckMEDCode(fid,fid,oss.str().c_str());
+ MEDFileUtilities::CheckMEDCode(fid,fid,oss.str());
write(fid);
}
return true;
}
+void MEDFileMesh::setName(const std::string& name)
+{
+ _name=name;
+}
+
/*!
* Clears redundant attributes of incorporated data arrays.
*/
* \return std::vector<std::string> - a sequence of names of the families.
* \throw If the name of a nonexistent group is specified.
*/
-std::vector<std::string> MEDFileMesh::getFamiliesOnGroup(const char *name) const
+std::vector<std::string> MEDFileMesh::getFamiliesOnGroup(const std::string& name) const
{
std::string oname(name);
std::map<std::string, std::vector<std::string> >::const_iterator it=_groups.find(oname);
* \return std::vector<int> - sequence of ids of the families.
* \throw If the name of a nonexistent group is specified.
*/
-std::vector<int> MEDFileMesh::getFamiliesIdsOnGroup(const char *name) const
+std::vector<int> MEDFileMesh::getFamiliesIdsOnGroup(const std::string& name) const
{
std::string oname(name);
std::map<std::string, std::vector<std::string> >::const_iterator it=_groups.find(oname);
* \param [in] name - the name of the group of interest.
* \param [in] fams - a sequence of names of families constituting the group.
*/
-void MEDFileMesh::setFamiliesOnGroup(const char *name, const std::vector<std::string>& fams)
+void MEDFileMesh::setFamiliesOnGroup(const std::string& name, const std::vector<std::string>& fams)
{
std::string oname(name);
_groups[oname]=fams;
* \param [in] famIds - a sequence of ids of families constituting the group.
* \throw If a family name is not found by its id.
*/
-void MEDFileMesh::setFamiliesIdsOnGroup(const char *name, const std::vector<int>& famIds)
+void MEDFileMesh::setFamiliesIdsOnGroup(const std::string& name, const std::vector<int>& famIds)
{
std::string oname(name);
std::vector<std::string> fams(famIds.size());
* \param [in] name - the name of the family of interest.
* \return std::vector<std::string> - a sequence of names of groups including the family.
*/
-std::vector<std::string> MEDFileMesh::getGroupsOnFamily(const char *name) const
+std::vector<std::string> MEDFileMesh::getGroupsOnFamily(const std::string& name) const
{
std::vector<std::string> ret;
for(std::map<std::string, std::vector<std::string> >::const_iterator it1=_groups.begin();it1!=_groups.end();it1++)
* \param [in] grps - a sequence of group names to add the family in.
* \throw If a family named \a famName not yet exists.
*/
-void MEDFileMesh::setGroupsOnFamily(const char *famName, const std::vector<std::string>& grps)
+void MEDFileMesh::setGroupsOnFamily(const std::string& famName, const std::vector<std::string>& grps)
{
std::string fName(famName);
const std::map<std::string,int>::const_iterator it=_families.find(fName);
std::map<std::string,int> newFams;
for(std::map<std::string,int>::const_iterator it=_families.begin();it!=_families.end();it++)
{
- std::vector<std::string> grps=getGroupsOnFamily((*it).first.c_str());
+ std::vector<std::string> grps=getGroupsOnFamily((*it).first);
if(grps.size()==1 && groups[grps[0]].size()==1)
{
if(newFams.find(grps[0])!=newFams.end())
* \param [in] name - the name of the group to remove.
* \throw If no group with such a \a name exists.
*/
-void MEDFileMesh::removeGroup(const char *name)
+void MEDFileMesh::removeGroup(const std::string& name)
{
std::string oname(name);
std::map<std::string, std::vector<std::string> >::iterator it=_groups.find(oname);
* \param [in] name - the name of the family to remove.
* \throw If no family with such a \a name exists.
*/
-void MEDFileMesh::removeFamily(const char *name)
+void MEDFileMesh::removeFamily(const std::string& name)
{
std::string oname(name);
std::map<std::string, int >::iterator it=_families.find(oname);
else
{
ret.push_back((*it).first);
- std::vector<std::string> grpsOnEraseFam=getGroupsOnFamily((*it).first.c_str());
+ std::vector<std::string> grpsOnEraseFam=getGroupsOnFamily((*it).first);
for(std::vector<std::string>::const_iterator it2=grpsOnEraseFam.begin();it2!=grpsOnEraseFam.end();it2++)
{
std::map<std::string, std::vector<std::string> >::iterator it3=grps.find(*it2);//it3!=grps.empty() thanks to copy
* \throw If no group named \a oldName exists in \a this mesh.
* \throw If a group named \a newName already exists.
*/
-void MEDFileMesh::changeGroupName(const char *oldName, const char *newName)
+void MEDFileMesh::changeGroupName(const std::string& oldName, const std::string& newName)
{
std::string oname(oldName);
std::map<std::string, std::vector<std::string> >::iterator it=_groups.find(oname);
* \throw If no family named \a oldName exists in \a this mesh.
* \throw If a family named \a newName already exists.
*/
-void MEDFileMesh::changeFamilyName(const char *oldName, const char *newName)
+void MEDFileMesh::changeFamilyName(const std::string& oldName, const std::string& newName)
{
std::string oname(oldName);
std::map<std::string, int >::iterator it=_families.find(oname);
* \param [in] groupName - the group name.
* \return bool - \c true the group \a groupName exists in \a this mesh.
*/
-bool MEDFileMesh::existsGroup(const char *groupName) const
+bool MEDFileMesh::existsGroup(const std::string& groupName) const
{
std::string grpName(groupName);
return _groups.find(grpName)!=_groups.end();
* \param [in] familyName - the family name.
* \return bool - \c true the family \a familyName exists in \a this mesh.
*/
-bool MEDFileMesh::existsFamily(const char *familyName) const
+bool MEDFileMesh::existsFamily(const std::string& familyName) const
{
std::string fname(familyName);
return _families.find(fname)!=_families.end();
* \param [in] familyName - the family name.
* \param [in] id - a new id of the family.
*/
-void MEDFileMesh::setFamilyId(const char *familyName, int id)
+void MEDFileMesh::setFamilyId(const std::string& familyName, int id)
{
std::string fname(familyName);
_families[fname]=id;
}
-void MEDFileMesh::setFamilyIdUnique(const char *familyName, int id)
+void MEDFileMesh::setFamilyIdUnique(const std::string& familyName, int id)
{
std::string fname(familyName);
for(std::map<std::string,int>::const_iterator it=_families.begin();it!=_families.end();it++)
* \param [in] famId - an id of the family.
* \throw If a family with the same name or id already exists in \a this mesh.
*/
-void MEDFileMesh::addFamily(const char *familyName, int famId)
+void MEDFileMesh::addFamily(const std::string& familyName, int famId)
{
std::string fname(familyName);
std::map<std::string,int>::const_iterator it=_families.find(fname);
* \throw If no mesh entities of dimension \a meshDimRelToMaxExt exist in \a this mesh.
* \throw If no family field of dimension \a meshDimRelToMaxExt is present in \a this mesh.
*/
-void MEDFileMesh::createGroupOnAll(int meshDimRelToMaxExt, const char *groupName)
+void MEDFileMesh::createGroupOnAll(int meshDimRelToMaxExt, const std::string& groupName)
{
std::string grpName(groupName);
std::vector<int> levs=getNonEmptyLevelsExt();
std::string famName=getFamilyNameGivenId(*it2);
std::ostringstream oss; oss << "Family_" << maxFamId;
std::string zeName=CreateNameNotIn(oss.str(),allFams);
- addFamilyOnAllGroupsHaving(famName.c_str(),zeName.c_str());
+ addFamilyOnAllGroupsHaving(famName,zeName);
_families[zeName]=maxFamId;
(const_cast<DataArrayInt *>(fieldFamIds))->changeValue(*it2,maxFamId);
maxFamId++;
* \throw If \a grpName or \a famName is an empty string.
* \throw If no family named \a famName is present in \a this mesh.
*/
-void MEDFileMesh::addFamilyOnGrp(const char *grpName, const char *famName)
+void MEDFileMesh::addFamilyOnGrp(const std::string& grpName, const std::string& famName)
{
std::string grpn(grpName);
std::string famn(famName);
* This method is quite underground because it can lead to unconsistency because family 'otherFamName' is \b not added into _families.
* This method is used by MEDFileMesh::keepFamIdsOnlyOnLevs method.
*/
-void MEDFileMesh::addFamilyOnAllGroupsHaving(const char *famName, const char *otherFamName)
+void MEDFileMesh::addFamilyOnAllGroupsHaving(const std::string& famName, const std::string& otherFamName)
{
std::string famNameCpp(famName);
std::string otherCpp(otherFamName);
}
}
-void MEDFileMesh::changeAllGroupsContainingFamily(const char *familyNameToChange, const std::vector<std::string>& newFamiliesNames)
+void MEDFileMesh::changeAllGroupsContainingFamily(const std::string& familyNameToChange, const std::vector<std::string>& newFamiliesNames)
{
ChangeAllGroupsContainingFamily(_groups,familyNameToChange,newFamiliesNames);
}
-void MEDFileMesh::ChangeAllGroupsContainingFamily(std::map<std::string, std::vector<std::string> >& groups, const char *familyNameToChange, const std::vector<std::string>& newFamiliesNames)
+void MEDFileMesh::ChangeAllGroupsContainingFamily(std::map<std::string, std::vector<std::string> >& groups, const std::string& familyNameToChange, const std::vector<std::string>& newFamiliesNames)
{
std::string fam(familyNameToChange);
for(std::map<std::string, std::vector<std::string> >::iterator it=groups.begin();it!=groups.end();it++)
* \return int - the id of the family of interest.
* \throw If no family with such a \a name exists.
*/
-int MEDFileMesh::getFamilyId(const char *name) const
+int MEDFileMesh::getFamilyId(const std::string& name) const
{
std::string oname(name);
std::map<std::string, int>::const_iterator it=_families.find(oname);
if(allIds->presenceOfValue(*it3))
{
std::string famName=getFamilyNameGivenId(*it3);
- std::vector<std::string> grps=getGroupsOnFamily(famName.c_str());
+ std::vector<std::string> grps=getGroupsOnFamily(famName);
ren[*it3]=maxId;
bool dummy;
std::string newFam=findOrCreateAndGiveFamilyWithId(maxId,dummy);
for(std::vector<std::string>::const_iterator it4=grps.begin();it4!=grps.end();it4++)
- addFamilyOnGrp((*it4).c_str(),newFam.c_str());
+ addFamilyOnGrp((*it4),newFam);
}
}
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=fam->getIdsEqualList(&(*it2).second[0],&(*it2).second[0]+(*it2).second.size());
* \throw If the name of a nonexistent group is specified.
* \throw If the family field is missing for \a meshDimRelToMaxExt.
*/
-DataArrayInt *MEDFileMesh::getGroupArr(int meshDimRelToMaxExt, const char *grp, bool renum) const
+DataArrayInt *MEDFileMesh::getGroupArr(int meshDimRelToMaxExt, const std::string& grp, bool renum) const
{
std::vector<std::string> tmp(1);
tmp[0]=grp;
* is to delete this array using decrRef() as it is no more needed.
* \throw If the family field is missing for \a meshDimRelToMaxExt.
*/
-DataArrayInt *MEDFileMesh::getFamilyArr(int meshDimRelToMaxExt, const char *fam, bool renum) const
+DataArrayInt *MEDFileMesh::getFamilyArr(int meshDimRelToMaxExt, const std::string& fam, bool renum) const
{
std::vector<std::string> tmp(1);
tmp[0]=fam;
* \throw If the name of a nonexistent group is specified.
* \throw If the family field is missing for nodes.
*/
-DataArrayInt *MEDFileMesh::getNodeGroupArr(const char *grp, bool renum) const
+DataArrayInt *MEDFileMesh::getNodeGroupArr(const std::string& grp, bool renum) const
{
std::vector<std::string> tmp(1);
tmp[0]=grp;
* \throw If the name of a nonexistent group is specified.
* \throw If the family field is missing for nodes.
*/
-DataArrayInt *MEDFileMesh::getNodeFamilyArr(const char *fam, bool renum) const
+DataArrayInt *MEDFileMesh::getNodeFamilyArr(const std::string& fam, bool renum) const
{
std::vector<std::string> tmp(1);
tmp[0]=fam;
for(unsigned int ii=0;ii<grps.size();ii++)
{
grps2[ii]=MEDFileUMeshSplitL1::Renumber(getRevNumberFieldAtLevel(meshDimRelToMaxExt),grps[ii]);
- grps2[ii]->setName(grps[ii]->getName().c_str());
+ grps2[ii]->setName(grps[ii]->getName());
}
std::vector<const DataArrayInt *> grps3(grps2.begin(),grps2.end());
fam=DataArrayInt::MakePartition(grps3,sz,fidsOfGroups);
}
}
+std::vector<INTERP_KERNEL::NormalizedCellType> MEDFileMesh::getAllGeoTypes() const
+{
+ std::vector<int> levs(getNonEmptyLevels());
+ std::vector<INTERP_KERNEL::NormalizedCellType> ret;
+ for(std::vector<int>::const_iterator it=levs.begin();it!=levs.end();it++)
+ {
+ std::vector<INTERP_KERNEL::NormalizedCellType> elts(getGeoTypesAtLevel(*it));
+ ret.insert(ret.end(),elts.begin(),elts.end());
+ }
+ return ret;
+}
+
std::vector<int> MEDFileMesh::getDistributionOfTypes(int meshDimRelToMax) const
{
MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mLev(getGenMeshAtLevel(meshDimRelToMax));
{
oss << "- Family with name \"" << (*it).first << "\" with number " << (*it).second << std::endl;
oss << " - Groups lying on this family : ";
- std::vector<std::string> grps=getGroupsOnFamily((*it).first.c_str());
+ std::vector<std::string> grps=getGroupsOnFamily((*it).first);
std::copy(grps.begin(),grps.end(),std::ostream_iterator<std::string>(oss," "));
oss << std::endl << std::endl;
}
* \throw If there is no mesh with given attributes in the file.
* \throw If the mesh in the file is not an unstructured one.
*/
-MEDFileUMesh *MEDFileUMesh::New(const char *fileName, const char *mName, int dt, int it, MEDFileMeshReadSelector *mrs)
+MEDFileUMesh *MEDFileUMesh::New(const std::string& fileName, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs)
{
MEDFileUtilities::CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
return new MEDFileUMesh(fid,mName,dt,it,mrs);
}
* \throw If there is no meshes in the file.
* \throw If the mesh in the file is not an unstructured one.
*/
-MEDFileUMesh *MEDFileUMesh::New(const char *fileName, MEDFileMeshReadSelector *mrs)
+MEDFileUMesh *MEDFileUMesh::New(const std::string& fileName, MEDFileMeshReadSelector *mrs)
{
std::vector<std::string> ms=MEDLoader::GetMeshNames(fileName);
if(ms.empty())
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
MEDFileUtilities::CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
int dt,it;
ParaMEDMEM::MEDCouplingMeshType meshType;
std::string dummy2;
- MEDFileMeshL2::GetMeshIdFromName(fid,ms.front().c_str(),meshType,dt,it,dummy2);
- return new MEDFileUMesh(fid,ms.front().c_str(),dt,it,mrs);
+ MEDFileMeshL2::GetMeshIdFromName(fid,ms.front(),meshType,dt,it,dummy2);
+ return new MEDFileUMesh(fid,ms.front(),dt,it,mrs);
}
/*!
}
}
+void MEDFileUMesh::setName(const std::string& name)
+{
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1> >::iterator it=_ms.begin();it!=_ms.end();it++)
+ if((MEDFileUMeshSplitL1 *)(*it)!=0)
+ (*it)->setName(name);
+ MEDFileMesh::setName(name);
+}
+
MEDFileUMesh::MEDFileUMesh()
{
}
-MEDFileUMesh::MEDFileUMesh(med_idt fid, const char *mName, int dt, int it, MEDFileMeshReadSelector *mrs)
+MEDFileUMesh::MEDFileUMesh(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs)
try
{
loadUMeshFromFile(fid,mName,dt,it,mrs);
throw e;
}
-void MEDFileUMesh::loadUMeshFromFile(med_idt fid, const char *mName, int dt, int it, MEDFileMeshReadSelector *mrs)
+void MEDFileUMesh::loadUMeshFromFile(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs)
{
MEDFileUMeshL2 loaderl2;
ParaMEDMEM::MEDCouplingMeshType meshType;
}
MEDmeshCr(fid,maa,spaceDim,mdim,MED_UNSTRUCTURED_MESH,desc,"",MED_SORT_DTIT,MED_CARTESIAN,comp,unit);
MEDmeshUniversalNameWr(fid,maa);
- MEDFileUMeshL2::WriteCoords(fid,maa,_iteration,_order,_time,_coords,_fam_coords,_num_coords,_name_coords);
+ std::string meshName(MEDLoaderBase::buildStringFromFortran(maa,MED_NAME_SIZE));
+ MEDFileUMeshL2::WriteCoords(fid,meshName,_iteration,_order,_time,_coords,_fam_coords,_num_coords,_name_coords);
for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1> >::const_iterator it=_ms.begin();it!=_ms.end();it++)
if((const MEDFileUMeshSplitL1 *)(*it)!=0)
- (*it)->write(fid,maa,mdim);
- MEDFileUMeshL2::WriteFamiliesAndGrps(fid,maa,_families,_groups,_too_long_str);
+ (*it)->write(fid,meshName,mdim);
+ MEDFileUMeshL2::WriteFamiliesAndGrps(fid,meshName,_families,_groups,_too_long_str);
}
/*!
* \param [in] grp - the name of the group of interest.
* \return std::vector<int> - a sequence of the relative dimensions.
*/
-std::vector<int> MEDFileUMesh::getGrpNonEmptyLevels(const char *grp) const
+std::vector<int> MEDFileUMesh::getGrpNonEmptyLevels(const std::string& grp) const
{
std::vector<std::string> fams=getFamiliesOnGroup(grp);
return getFamsNonEmptyLevels(fams);
* \param [in] grp - the name of the group of interest.
* \return std::vector<int> - a sequence of the relative dimensions.
*/
-std::vector<int> MEDFileUMesh::getGrpNonEmptyLevelsExt(const char *grp) const
+std::vector<int> MEDFileUMesh::getGrpNonEmptyLevelsExt(const std::string& grp) const
{
std::vector<std::string> fams=getFamiliesOnGroup(grp);
return getFamsNonEmptyLevelsExt(fams);
* \param [in] fam - the name of the family of interest.
* \return std::vector<int> - a sequence of the relative dimensions.
*/
-std::vector<int> MEDFileUMesh::getFamNonEmptyLevels(const char *fam) const
+std::vector<int> MEDFileUMesh::getFamNonEmptyLevels(const std::string& fam) const
{
std::vector<std::string> fams(1,std::string(fam));
return getFamsNonEmptyLevels(fams);
* \param [in] fam - the name of the family of interest.
* \return std::vector<int> - a sequence of the relative dimensions.
*/
-std::vector<int> MEDFileUMesh::getFamNonEmptyLevelsExt(const char *fam) const
+std::vector<int> MEDFileUMesh::getFamNonEmptyLevelsExt(const std::string& fam) const
{
std::vector<std::string> fams(1,std::string(fam));
return getFamsNonEmptyLevelsExt(fams);
std::vector<std::string> allGrps=getGroupsNames();
for(std::vector<std::string>::const_iterator it=allGrps.begin();it!=allGrps.end();it++)
{
- std::vector<int> levs=getGrpNonEmptyLevelsExt((*it).c_str());
+ std::vector<int> levs=getGrpNonEmptyLevelsExt((*it));
if(std::find(levs.begin(),levs.end(),meshDimRelToMaxExt)!=levs.end())
ret.push_back(*it);
}
m->computeNodeIdsAlg(nodesFetched);
else
{
- const DataArrayInt *arr(globs->getProfile(st[i].getPflName().c_str()));
+ const DataArrayInt *arr(globs->getProfile(st[i].getPflName()));
MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> m2(dynamic_cast<MEDCoupling1GTUMesh *>(m->buildPartOfMySelf(arr->begin(),arr->end(),true)));
m2->computeNodeIdsAlg(nodesFetched);
}
* \throw If the name of a nonexistent group is specified.
* \throw If there are no mesh entities of \a meshDimRelToMaxExt dimension in \a this mesh.
*/
-MEDCouplingUMesh *MEDFileUMesh::getGroup(int meshDimRelToMaxExt, const char *grp, bool renum) const
+MEDCouplingUMesh *MEDFileUMesh::getGroup(int meshDimRelToMaxExt, const std::string& grp, bool renum) const
{
synchronizeTinyInfoOnLeaves();
std::vector<std::string> tmp(1);
std::vector<std::string> fams2=getFamiliesOnGroups(grps);
MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> zeRet=getFamilies(meshDimRelToMaxExt,fams2,renum);
if(grps.size()==1 && ((MEDCouplingUMesh *)zeRet))
- zeRet->setName(grps[0].c_str());
+ zeRet->setName(grps[0]);
return zeRet.retn();
}
* \throw If a name of a nonexistent family is present in \a grps.
* \throw If there are no mesh entities of \a meshDimRelToMaxExt dimension in \a this mesh.
*/
-MEDCouplingUMesh *MEDFileUMesh::getFamily(int meshDimRelToMaxExt, const char *fam, bool renum) const
+MEDCouplingUMesh *MEDFileUMesh::getFamily(int meshDimRelToMaxExt, const std::string& fam, bool renum) const
{
synchronizeTinyInfoOnLeaves();
std::vector<std::string> tmp(1);
else
zeRet=l1->getFamilyPart(0,0,renum);
if(fams.size()==1 && ((MEDCouplingUMesh *)zeRet))
- zeRet->setName(fams[0].c_str());
+ zeRet->setName(fams[0]);
return zeRet.retn();
}
MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> cc=_coords->deepCpy();
umesh->setCoords(cc);
MEDFileUMeshSplitL1::ClearNonDiscrAttributes(umesh);
- umesh->setName(getName().c_str());
+ umesh->setName(getName());
return umesh;
}
}
_groups.erase(*it);
}
-void MEDFileUMesh::duplicateNodesOnM1Group(const char *grpNameM1, DataArrayInt *&nodesDuplicated, DataArrayInt *&cellsModified, DataArrayInt *&cellsNotModified)
+void MEDFileUMesh::duplicateNodesOnM1Group(const std::string& grpNameM1, DataArrayInt *&nodesDuplicated, DataArrayInt *&cellsModified, DataArrayInt *&cellsNotModified)
{
std::vector<int> levs=getNonEmptyLevels();
if(std::find(levs.begin(),levs.end(),0)==levs.end() || std::find(levs.begin(),levs.end(),-1)==levs.end())
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> szOfCellGrpOfSameType(tmp00);
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> idInMsOfCellGrpOfSameType(tmp11);
//
- newm1->setName(getName().c_str());
+ newm1->setName(getName());
const DataArrayInt *fam=getFamilyFieldAtLevel(-1);
if(!fam)
throw INTERP_KERNEL::Exception("MEDFileUMesh::duplicateNodesOnM1Group : internal problem !");
setMeshAtLevel(-1,newm1);
setFamilyFieldArr(-1,newFam);
std::string grpName2(grpNameM1); grpName2+="_dup";
- addFamily(grpName2.c_str(),idd);
- addFamilyOnGrp(grpName2.c_str(),grpName2.c_str());
+ addFamily(grpName2,idd);
+ addFamilyOnGrp(grpName2,grpName2);
//
fam=_fam_coords;
if(fam)
if(existsFamily(*famId))
{
std::string locFamName2=getFamilyNameGivenId(*famId); std::vector<std::string> v(2); v[0]=locFamName2; v[1]=locFamName;
- ChangeAllGroupsContainingFamily(groups,getFamilyNameGivenId(*famId).c_str(),v);
+ ChangeAllGroupsContainingFamily(groups,getFamilyNameGivenId(*famId),v);
}
maxVal++;
} // modifying all other groups on *famId to lie on maxVal and lie the grp on maxVal
if(existsFamily(*famId))
{
std::string n1(FindOrCreateAndGiveFamilyWithId(families,isNodeGroup?maxVal:-maxVal,created)); std::vector<std::string> v(2); v[0]=n1; v[1]=n2;
- ChangeAllGroupsContainingFamily(groups,getFamilyNameGivenId(*famId).c_str(),v);
+ ChangeAllGroupsContainingFamily(groups,getFamilyNameGivenId(*famId),v);
}
maxVal+=2;
}
for(std::vector<const MEDCouplingUMesh *>::const_iterator it=ms.begin();it!=ms.end();it++)
{
int mdim=(*it)->getMeshDimension();
- setName((*it)->getName().c_str());
+ setName((*it)->getName());
setMeshAtLevel(mdim-zeDim,const_cast<MEDCouplingUMesh *>(*it),renum);
}
- setName(name.c_str());
+ setName(name);
}
/*!
int MEDFileStructuredMesh::getNumberOfNodes() const
{
- const MEDCouplingStructuredMesh *cmesh=getStructuredMesh();
+ const MEDCouplingStructuredMesh *cmesh(getStructuredMesh());
if(!cmesh)
throw INTERP_KERNEL::Exception("MEDFileStructuredMesh::getNumberOfNodes : no cartesian mesh set !");
return cmesh->getNumberOfNodes();
}
+std::vector<INTERP_KERNEL::NormalizedCellType> MEDFileStructuredMesh::getGeoTypesAtLevel(int meshDimRelToMax) const
+{
+ if(meshDimRelToMax!=0)
+ throw INTERP_KERNEL::Exception("MEDFileStructuredMesh::getGeoTypesAtLevel : only one level available for structured meshes ! Input 0 is mandatory !");
+ const MEDCouplingStructuredMesh *cmesh(getStructuredMesh());
+ std::vector<INTERP_KERNEL::NormalizedCellType> ret(1,cmesh->getTypeOfCell(0));
+ return ret;
+}
+
void MEDFileStructuredMesh::whichAreNodesFetched(const MEDFileField1TSStructItem& st, const MEDFileFieldGlobsReal *globs, std::vector<bool>& nodesFetched) const
{
if(st.getNumberOfItems()!=1)
std::fill(nodesFetched.begin(),nodesFetched.end(),true);
return ;
}
- const DataArrayInt *arr(globs->getProfile(st[0].getPflName().c_str()));
+ const DataArrayInt *arr(globs->getProfile(st[0].getPflName()));
const MEDCouplingStructuredMesh *cmesh=getStructuredMesh();//cmesh not null because getNumberOfNodes called before
int sz(nodesFetched.size());
for(const int *work=arr->begin();work!=arr->end();work++)
return geoTypeReq;
}
-void MEDFileStructuredMesh::loadStrMeshFromFile(MEDFileStrMeshL2 *strm, med_idt fid, const char *mName, int dt, int it, MEDFileMeshReadSelector *mrs)
+void MEDFileStructuredMesh::loadStrMeshFromFile(MEDFileStrMeshL2 *strm, med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs)
{
setName(strm->getName());
setDescription(strm->getDescription());
setTimeUnit(strm->getTimeUnit());
MEDFileMeshL2::ReadFamiliesAndGrps(fid,mName,_families,_groups,mrs);
med_bool chgt=MED_FALSE,trsf=MED_FALSE;
- int nbOfElt=MEDmeshnEntity(fid,mName,dt,it,MED_NODE,MED_NONE,MED_FAMILY_NUMBER,MED_NODAL,&chgt,&trsf);
+ int nbOfElt=MEDmeshnEntity(fid,mName.c_str(),dt,it,MED_NODE,MED_NONE,MED_FAMILY_NUMBER,MED_NODAL,&chgt,&trsf);
if(nbOfElt>0)
{
if(!mrs || mrs->isNodeFamilyFieldReading())
{
_fam_nodes=DataArrayInt::New();
_fam_nodes->alloc(nbOfElt,1);
- MEDmeshEntityFamilyNumberRd(fid,mName,dt,it,MED_NODE,MED_NONE,_fam_nodes->getPointer());
+ MEDmeshEntityFamilyNumberRd(fid,mName.c_str(),dt,it,MED_NODE,MED_NONE,_fam_nodes->getPointer());
}
}
- nbOfElt=MEDmeshnEntity(fid,mName,dt,it,MED_NODE,MED_NONE,MED_NUMBER,MED_NODAL,&chgt,&trsf);
+ nbOfElt=MEDmeshnEntity(fid,mName.c_str(),dt,it,MED_NODE,MED_NONE,MED_NUMBER,MED_NODAL,&chgt,&trsf);
if(nbOfElt>0)
{
if(!mrs || mrs->isNodeNumFieldReading())
{
_num_nodes=DataArrayInt::New();
_num_nodes->alloc(nbOfElt,1);
- MEDmeshEntityNumberRd(fid,mName,dt,it,MED_NODE,MED_NONE,_num_nodes->getPointer());
+ MEDmeshEntityNumberRd(fid,mName.c_str(),dt,it,MED_NODE,MED_NONE,_num_nodes->getPointer());
}
}
int meshDim=getStructuredMesh()->getMeshDimension();
med_geometry_type geoTypeReq=GetGeoTypeFromMeshDim(meshDim);
- nbOfElt=MEDmeshnEntity(fid,mName,dt,it,MED_CELL,geoTypeReq,MED_FAMILY_NUMBER,MED_NODAL,&chgt,&trsf);
+ nbOfElt=MEDmeshnEntity(fid,mName.c_str(),dt,it,MED_CELL,geoTypeReq,MED_FAMILY_NUMBER,MED_NODAL,&chgt,&trsf);
if(nbOfElt>0)
{
if(!mrs || mrs->isCellFamilyFieldReading())
{
_fam_cells=DataArrayInt::New();
_fam_cells->alloc(nbOfElt,1);
- MEDmeshEntityFamilyNumberRd(fid,mName,dt,it,MED_CELL,geoTypeReq,_fam_cells->getPointer());
+ MEDmeshEntityFamilyNumberRd(fid,mName.c_str(),dt,it,MED_CELL,geoTypeReq,_fam_cells->getPointer());
}
}
- nbOfElt=MEDmeshnEntity(fid,mName,dt,it,MED_CELL,geoTypeReq,MED_NUMBER,MED_NODAL,&chgt,&trsf);
+ nbOfElt=MEDmeshnEntity(fid,mName.c_str(),dt,it,MED_CELL,geoTypeReq,MED_NUMBER,MED_NODAL,&chgt,&trsf);
if(nbOfElt>0)
{
if(!mrs || mrs->isCellNumFieldReading())
{
_num_cells=DataArrayInt::New();
_num_cells->alloc(nbOfElt,1);
- MEDmeshEntityNumberRd(fid,mName,dt,it,MED_CELL,geoTypeReq,_num_cells->getPointer());
+ MEDmeshEntityNumberRd(fid,mName.c_str(),dt,it,MED_CELL,geoTypeReq,_num_cells->getPointer());
}
}
- nbOfElt=MEDmeshnEntity(fid,mName,dt,it,MED_CELL,geoTypeReq,MED_NAME,MED_NODAL,&chgt,&trsf);
+ nbOfElt=MEDmeshnEntity(fid,mName.c_str(),dt,it,MED_CELL,geoTypeReq,MED_NAME,MED_NODAL,&chgt,&trsf);
if(nbOfElt>0)
{
if(!mrs || mrs->isCellNameFieldReading())
{
_names_cells=DataArrayAsciiChar::New();
_names_cells->alloc(nbOfElt+1,MED_SNAME_SIZE);//not a bug to avoid the memory corruption due to last \0 at the end
- MEDmeshEntityNameRd(fid,mName,dt,it,MED_CELL,geoTypeReq,_names_cells->getPointer());
+ MEDmeshEntityNameRd(fid,mName.c_str(),dt,it,MED_CELL,geoTypeReq,_names_cells->getPointer());
_names_cells->reAlloc(nbOfElt);//not a bug to avoid the memory corruption due to last \0 at the end
}
}
- nbOfElt=MEDmeshnEntity(fid,mName,dt,it,MED_NODE,MED_NONE,MED_NAME,MED_NODAL,&chgt,&trsf);
+ nbOfElt=MEDmeshnEntity(fid,mName.c_str(),dt,it,MED_NODE,MED_NONE,MED_NAME,MED_NODAL,&chgt,&trsf);
if(nbOfElt>0)
{
if(!mrs || mrs->isNodeNameFieldReading())
{
_names_nodes=DataArrayAsciiChar::New();
_names_nodes->alloc(nbOfElt+1,MED_SNAME_SIZE);//not a bug to avoid the memory corruption due to last \0 at the end
- MEDmeshEntityNameRd(fid,mName,dt,it,MED_NODE,MED_NONE,_names_nodes->getPointer());
+ MEDmeshEntityNameRd(fid,mName.c_str(),dt,it,MED_NODE,MED_NONE,_names_nodes->getPointer());
_names_nodes->reAlloc(nbOfElt);//not a bug to avoid the memory corruption due to last \0 at the end
}
}
}
-void MEDFileStructuredMesh::writeStructuredLL(med_idt fid, const char *maa) const
+void MEDFileStructuredMesh::writeStructuredLL(med_idt fid, const std::string& maa) const
{
int meshDim=getStructuredMesh()->getMeshDimension();
med_geometry_type geoTypeReq=GetGeoTypeFromMeshDim(meshDim);
//
if((const DataArrayInt *)_fam_cells)
- MEDmeshEntityFamilyNumberWr(fid,maa,_iteration,_order,MED_CELL,geoTypeReq,_fam_cells->getNumberOfTuples(),_fam_cells->getConstPointer());
+ MEDmeshEntityFamilyNumberWr(fid,maa.c_str(),_iteration,_order,MED_CELL,geoTypeReq,_fam_cells->getNumberOfTuples(),_fam_cells->getConstPointer());
if((const DataArrayInt *)_fam_nodes)
- MEDmeshEntityFamilyNumberWr(fid,maa,_iteration,_order,MED_NODE,MED_NONE,_fam_nodes->getNumberOfTuples(),_fam_nodes->getConstPointer());
+ MEDmeshEntityFamilyNumberWr(fid,maa.c_str(),_iteration,_order,MED_NODE,MED_NONE,_fam_nodes->getNumberOfTuples(),_fam_nodes->getConstPointer());
if((const DataArrayInt *)_num_cells)
- MEDmeshEntityNumberWr(fid,maa,_iteration,_order,MED_CELL,geoTypeReq,_num_cells->getNumberOfTuples(),_num_cells->getConstPointer());
+ MEDmeshEntityNumberWr(fid,maa.c_str(),_iteration,_order,MED_CELL,geoTypeReq,_num_cells->getNumberOfTuples(),_num_cells->getConstPointer());
if((const DataArrayInt *)_num_nodes)
- MEDmeshEntityNumberWr(fid,maa,_iteration,_order,MED_NODE,MED_NONE,_num_nodes->getNumberOfTuples(),_num_nodes->getConstPointer());
+ MEDmeshEntityNumberWr(fid,maa.c_str(),_iteration,_order,MED_NODE,MED_NONE,_num_nodes->getNumberOfTuples(),_num_nodes->getConstPointer());
if((const DataArrayAsciiChar *)_names_cells)
{
if(_names_cells->getNumberOfComponents()!=MED_SNAME_SIZE)
oss << " ! The array has " << _names_cells->getNumberOfComponents() << " components !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
- MEDmeshEntityNameWr(fid,maa,_iteration,_order,MED_CELL,geoTypeReq,_names_cells->getNumberOfTuples(),_names_cells->getConstPointer());
+ MEDmeshEntityNameWr(fid,maa.c_str(),_iteration,_order,MED_CELL,geoTypeReq,_names_cells->getNumberOfTuples(),_names_cells->getConstPointer());
}
if((const DataArrayAsciiChar *)_names_nodes)
{
oss << " ! The array has " << _names_cells->getNumberOfComponents() << " components !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
- MEDmeshEntityNameWr(fid,maa,_iteration,_order,MED_NODE,MED_NONE,_names_nodes->getNumberOfTuples(),_names_nodes->getConstPointer());
+ MEDmeshEntityNameWr(fid,maa.c_str(),_iteration,_order,MED_NODE,MED_NONE,_names_nodes->getNumberOfTuples(),_names_nodes->getConstPointer());
}
//
- MEDFileUMeshL2::WriteFamiliesAndGrps(fid,maa,_families,_groups,_too_long_str);
+ MEDFileUMeshL2::WriteFamiliesAndGrps(fid,maa.c_str(),_families,_groups,_too_long_str);
}
/*!
* \throw If there is no meshes in the file.
* \throw If the mesh in the file is not a Cartesian one.
*/
-MEDFileCMesh *MEDFileCMesh::New(const char *fileName, MEDFileMeshReadSelector *mrs)
+MEDFileCMesh *MEDFileCMesh::New(const std::string& fileName, MEDFileMeshReadSelector *mrs)
{
std::vector<std::string> ms=MEDLoader::GetMeshNames(fileName);
if(ms.empty())
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
MEDFileUtilities::CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
int dt,it;
ParaMEDMEM::MEDCouplingMeshType meshType;
std::string dummy2;
- MEDFileMeshL2::GetMeshIdFromName(fid,ms.front().c_str(),meshType,dt,it,dummy2);
- return new MEDFileCMesh(fid,ms.front().c_str(),dt,it,mrs);
+ MEDFileMeshL2::GetMeshIdFromName(fid,ms.front(),meshType,dt,it,dummy2);
+ return new MEDFileCMesh(fid,ms.front(),dt,it,mrs);
}
/*!
* \throw If there is no mesh with given attributes in the file.
* \throw If the mesh in the file is not a Cartesian one.
*/
-MEDFileCMesh *MEDFileCMesh::New(const char *fileName, const char *mName, int dt, int it, MEDFileMeshReadSelector *mrs)
+MEDFileCMesh *MEDFileCMesh::New(const std::string& fileName, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs)
{
MEDFileUtilities::CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
return new MEDFileCMesh(fid,mName,dt,it,mrs);
}
return _cmesh->getMeshDimension();
}
+/*!
+ * Returns the dimension on nodes in \a this mesh.
+ * \return int - the space dimension.
+ * \throw If there are no cells in this mesh.
+ */
+int MEDFileCMesh::getSpaceDimension() const
+{
+ if(!((const MEDCouplingCMesh*)_cmesh))
+ throw INTERP_KERNEL::Exception("MEDFileCMesh::getSpaceDimension : unable to get spacedimension because no mesh set !");
+ return _cmesh->getSpaceDimension();
+}
+
/*!
* Returns a string describing \a this mesh.
* \return std::string - the mesh information string.
{
}
-MEDFileCMesh::MEDFileCMesh(med_idt fid, const char *mName, int dt, int it, MEDFileMeshReadSelector *mrs)
+MEDFileCMesh::MEDFileCMesh(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs)
try
{
loadCMeshFromFile(fid,mName,dt,it,mrs);
throw e;
}
-void MEDFileCMesh::loadCMeshFromFile(med_idt fid, const char *mName, int dt, int it, MEDFileMeshReadSelector *mrs)
+void MEDFileCMesh::loadCMeshFromFile(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs)
{
ParaMEDMEM::MEDCouplingMeshType meshType;
int dummy0,dummy1;
MEDLoaderBase::safeStrCpy(_name.c_str(),MED_NAME_SIZE,maa,_too_long_str);
MEDLoaderBase::safeStrCpy(_desc_name.c_str(),MED_COMMENT_SIZE,desc,_too_long_str);
MEDLoaderBase::safeStrCpy(_dt_unit.c_str(),MED_LNAME_SIZE,dtunit,_too_long_str);
- int spaceDim=_cmesh->getSpaceDimension();
- int meshDim=_cmesh->getMeshDimension();
+ int spaceDim(_cmesh->getSpaceDimension());
INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(spaceDim*MED_SNAME_SIZE);
INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(spaceDim*MED_SNAME_SIZE);
for(int i=0;i<spaceDim;i++)
MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE-1,comp+i*MED_SNAME_SIZE,_too_long_str);//MED_TAILLE_PNOM-1 to avoid to write '\0' on next compo
MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE-1,unit+i*MED_SNAME_SIZE,_too_long_str);//MED_TAILLE_PNOM-1 to avoid to write '\0' on next compo
}
- MEDmeshCr(fid,maa,spaceDim,meshDim,MED_STRUCTURED_MESH,desc,dtunit,MED_SORT_DTIT,MED_CARTESIAN,comp,unit);
+ MEDmeshCr(fid,maa,spaceDim,spaceDim,MED_STRUCTURED_MESH,desc,dtunit,MED_SORT_DTIT,MED_CARTESIAN,comp,unit);
MEDmeshUniversalNameWr(fid,maa);
MEDmeshGridTypeWr(fid,maa,MED_CARTESIAN_GRID);
for(int i=0;i<spaceDim;i++)
MEDmeshGridIndexCoordinateWr(fid,maa,_iteration,_order,_time,i+1,da->getNumberOfTuples(),da->getConstPointer());
}
//
- MEDFileStructuredMesh::writeStructuredLL(fid,maa);
+ std::string meshName(MEDLoaderBase::buildStringFromFortran(maa,MED_NAME_SIZE));
+ MEDFileStructuredMesh::writeStructuredLL(fid,meshName);
}
void MEDFileCMesh::synchronizeTinyInfoOnLeaves() const
const MEDCouplingCMesh *cmesh=_cmesh;
if(!cmesh)
return;
- (const_cast<MEDCouplingCMesh *>(cmesh))->setName(_name.c_str());
- (const_cast<MEDCouplingCMesh *>(cmesh))->setDescription(_desc_name.c_str());
+ (const_cast<MEDCouplingCMesh *>(cmesh))->setName(_name);
+ (const_cast<MEDCouplingCMesh *>(cmesh))->setDescription(_desc_name);
(const_cast<MEDCouplingCMesh *>(cmesh))->setTime(_time,_iteration,_order);
- (const_cast<MEDCouplingCMesh *>(cmesh))->setTimeUnit(_dt_unit.c_str());
+ (const_cast<MEDCouplingCMesh *>(cmesh))->setTimeUnit(_dt_unit);
}
MEDFileCurveLinearMesh *MEDFileCurveLinearMesh::New()
return new MEDFileCurveLinearMesh;
}
-MEDFileCurveLinearMesh *MEDFileCurveLinearMesh::New(const char *fileName, MEDFileMeshReadSelector *mrs)
+MEDFileCurveLinearMesh *MEDFileCurveLinearMesh::New(const std::string& fileName, MEDFileMeshReadSelector *mrs)
{
std::vector<std::string> ms=MEDLoader::GetMeshNames(fileName);
if(ms.empty())
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
MEDFileUtilities::CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
int dt,it;
ParaMEDMEM::MEDCouplingMeshType meshType;
std::string dummy2;
- MEDFileMeshL2::GetMeshIdFromName(fid,ms.front().c_str(),meshType,dt,it,dummy2);
- return new MEDFileCurveLinearMesh(fid,ms.front().c_str(),dt,it,mrs);
+ MEDFileMeshL2::GetMeshIdFromName(fid,ms.front(),meshType,dt,it,dummy2);
+ return new MEDFileCurveLinearMesh(fid,ms.front(),dt,it,mrs);
}
-MEDFileCurveLinearMesh *MEDFileCurveLinearMesh::New(const char *fileName, const char *mName, int dt, int it, MEDFileMeshReadSelector *mrs)
+MEDFileCurveLinearMesh *MEDFileCurveLinearMesh::New(const std::string& fileName, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs)
{
MEDFileUtilities::CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
return new MEDFileCurveLinearMesh(fid,mName,dt,it,mrs);
}
const MEDCouplingCurveLinearMesh *clmesh=_clmesh;
if(!clmesh)
return;
- (const_cast<MEDCouplingCurveLinearMesh *>(clmesh))->setName(_name.c_str());
- (const_cast<MEDCouplingCurveLinearMesh *>(clmesh))->setDescription(_desc_name.c_str());
+ (const_cast<MEDCouplingCurveLinearMesh *>(clmesh))->setName(_name);
+ (const_cast<MEDCouplingCurveLinearMesh *>(clmesh))->setDescription(_desc_name);
(const_cast<MEDCouplingCurveLinearMesh *>(clmesh))->setTime(_time,_iteration,_order);
- (const_cast<MEDCouplingCurveLinearMesh *>(clmesh))->setTimeUnit(_dt_unit.c_str());
+ (const_cast<MEDCouplingCurveLinearMesh *>(clmesh))->setTimeUnit(_dt_unit);
}
const MEDCouplingCurveLinearMesh *MEDFileCurveLinearMesh::getMesh() const
{
}
-MEDFileCurveLinearMesh::MEDFileCurveLinearMesh(med_idt fid, const char *mName, int dt, int it, MEDFileMeshReadSelector *mrs)
+MEDFileCurveLinearMesh::MEDFileCurveLinearMesh(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs)
try
{
loadCLMeshFromFile(fid,mName,dt,it,mrs);
MEDmeshNodeCoordinateWr(fid,maa,_iteration,_order,_time,MED_FULL_INTERLACE,coords->getNumberOfTuples(),coords->begin());
//
- MEDFileStructuredMesh::writeStructuredLL(fid,maa);
+ std::string meshName(MEDLoaderBase::buildStringFromFortran(maa,MED_NAME_SIZE));
+ MEDFileStructuredMesh::writeStructuredLL(fid,meshName);
}
-void MEDFileCurveLinearMesh::loadCLMeshFromFile(med_idt fid, const char *mName, int dt, int it, MEDFileMeshReadSelector *mrs)
+void MEDFileCurveLinearMesh::loadCLMeshFromFile(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs)
{
ParaMEDMEM::MEDCouplingMeshType meshType;
int dummy0,dummy1;
return new MEDFileMeshMultiTS;
}
-MEDFileMeshMultiTS *MEDFileMeshMultiTS::New(const char *fileName)
+MEDFileMeshMultiTS *MEDFileMeshMultiTS::New(const std::string& fileName)
{
return new MEDFileMeshMultiTS(fileName);
}
-MEDFileMeshMultiTS *MEDFileMeshMultiTS::New(const char *fileName, const char *mName)
+MEDFileMeshMultiTS *MEDFileMeshMultiTS::New(const std::string& fileName, const std::string& mName)
{
return new MEDFileMeshMultiTS(fileName,mName);
}
return _mesh_one_ts[0]->getName();
}
-void MEDFileMeshMultiTS::setName(const char *newMeshName)
+void MEDFileMeshMultiTS::setName(const std::string& newMeshName)
{
std::string oldName(getName());
std::vector< std::pair<std::string,std::string> > v(1);
}
}
-void MEDFileMeshMultiTS::write(const char *fileName, int mode) const
+void MEDFileMeshMultiTS::write(const std::string& fileName, int mode) const
{
med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod);
std::ostringstream oss; oss << "MEDFileMesh : error on attempt to write in file : \"" << fileName << "\"";
- MEDFileUtilities::CheckMEDCode(fid,fid,oss.str().c_str());
+ MEDFileUtilities::CheckMEDCode(fid,fid,oss.str());
write(fid);
}
-void MEDFileMeshMultiTS::loadFromFile(const char *fileName, const char *mName)
+void MEDFileMeshMultiTS::loadFromFile(const std::string& fileName, const std::string& mName)
{//for the moment to be improved
_mesh_one_ts.resize(1);
_mesh_one_ts[0]=MEDFileMesh::New(fileName,mName,-1,-1);
{
}
-MEDFileMeshMultiTS::MEDFileMeshMultiTS(const char *fileName)
+MEDFileMeshMultiTS::MEDFileMeshMultiTS(const std::string& fileName)
try
{
std::vector<std::string> ms=MEDLoader::GetMeshNames(fileName);
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
MEDFileUtilities::CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
int dt,it;
ParaMEDMEM::MEDCouplingMeshType meshType;
std::string dummy2;
- MEDFileMeshL2::GetMeshIdFromName(fid,ms.front().c_str(),meshType,dt,it,dummy2);
- loadFromFile(fileName,ms.front().c_str());
+ MEDFileMeshL2::GetMeshIdFromName(fid,ms.front(),meshType,dt,it,dummy2);
+ loadFromFile(fileName,ms.front());
}
catch(INTERP_KERNEL::Exception& e)
{
throw e;
}
-MEDFileMeshMultiTS::MEDFileMeshMultiTS(const char *fileName, const char *mName)
+MEDFileMeshMultiTS::MEDFileMeshMultiTS(const std::string& fileName, const std::string& mName)
try
{
loadFromFile(fileName,mName);
return new MEDFileMeshes;
}
-MEDFileMeshes *MEDFileMeshes::New(const char *fileName)
+MEDFileMeshes *MEDFileMeshes::New(const std::string& fileName)
{
return new MEDFileMeshes(fileName);
}
}
}
-void MEDFileMeshes::write(const char *fileName, int mode) const
+void MEDFileMeshes::write(const std::string& fileName, int mode) const
{
med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod);
std::ostringstream oss; oss << "MEDFileMesh : error on attempt to write in file : \"" << fileName << "\"";
- MEDFileUtilities::CheckMEDCode(fid,fid,oss.str().c_str());
+ MEDFileUtilities::CheckMEDCode(fid,fid,oss.str());
checkCoherency();
write(fid);
}
return _meshes[i]->getOneTimeStep();
}
-MEDFileMesh *MEDFileMeshes::getMeshWithName(const char *mname) const
+MEDFileMesh *MEDFileMeshes::getMeshWithName(const std::string& mname) const
{
std::vector<std::string> ms=getMeshesNames();
std::vector<std::string>::iterator it=std::find(ms.begin(),ms.end(),mname);
_meshes.erase(_meshes.begin()+i);
}
-void MEDFileMeshes::loadFromFile(const char *fileName)
+void MEDFileMeshes::loadFromFile(const std::string& fileName)
{
std::vector<std::string> ms=MEDLoader::GetMeshNames(fileName);
int i=0;
_meshes.resize(ms.size());
for(std::vector<std::string>::const_iterator it=ms.begin();it!=ms.end();it++,i++)
- _meshes[i]=MEDFileMeshMultiTS::New(fileName,(*it).c_str());
+ _meshes[i]=MEDFileMeshMultiTS::New(fileName,(*it));
}
MEDFileMeshes::MEDFileMeshes()
{
}
-MEDFileMeshes::MEDFileMeshes(const char *fileName)
+MEDFileMeshes::MEDFileMeshes(const std::string& fileName)
try
{
loadFromFile(fileName);
class MEDFileMesh : public RefCountObject, public MEDFileWritable
{
public:
- MEDLOADER_EXPORT static MEDFileMesh *New(const char *fileName, MEDFileMeshReadSelector *mrs=0);
- MEDLOADER_EXPORT static MEDFileMesh *New(const char *fileName, const char *mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0);
+ MEDLOADER_EXPORT static MEDFileMesh *New(const std::string& fileName, MEDFileMeshReadSelector *mrs=0);
+ MEDLOADER_EXPORT static MEDFileMesh *New(const std::string& fileName, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0);
MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildren() const;
MEDLOADER_EXPORT virtual MEDFileMesh *createNewEmpty() const = 0;
MEDLOADER_EXPORT virtual MEDFileMesh *shallowCpy() const = 0;
MEDLOADER_EXPORT virtual bool isEqual(const MEDFileMesh *other, double eps, std::string& what) const;
MEDLOADER_EXPORT virtual void clearNonDiscrAttributes() const;
- MEDLOADER_EXPORT void setName(const char *name) { _name=name; }
+ MEDLOADER_EXPORT virtual void setName(const std::string& name);
MEDLOADER_EXPORT bool changeNames(const std::vector< std::pair<std::string,std::string> >& modifTab);
MEDLOADER_EXPORT std::string getName() const { return _name; }
- MEDLOADER_EXPORT const char *getUnivName() const { return _univ_name.c_str(); }
+ MEDLOADER_EXPORT std::string getUnivName() const { return _univ_name; }
MEDLOADER_EXPORT bool getUnivNameWrStatus() const { return _univ_wr_status; }
MEDLOADER_EXPORT void setUnivNameWrStatus(bool newStatus) { _univ_wr_status=newStatus; }
- MEDLOADER_EXPORT void setDescription(const char *name) { _desc_name=name; }
+ MEDLOADER_EXPORT void setDescription(const std::string& name) { _desc_name=name; }
MEDLOADER_EXPORT std::string getDescription() const { return _desc_name; }
MEDLOADER_EXPORT void setOrder(int order) { _order=order; }
MEDLOADER_EXPORT int getOrder() const { return _order; }
MEDLOADER_EXPORT void setTime(int dt, int it, double time) { _time=time; _iteration=dt; _order=it; }
MEDLOADER_EXPORT double getTime(int& dt, int& it) { dt=_iteration; it=_order; return _time; }
MEDLOADER_EXPORT double getTimeValue() const { return _time; }
- MEDLOADER_EXPORT void setTimeUnit(const char *unit) { _dt_unit=unit; }
- MEDLOADER_EXPORT const char *getTimeUnit() const { return _dt_unit.c_str(); }
+ MEDLOADER_EXPORT void setTimeUnit(const std::string& unit) { _dt_unit=unit; }
+ MEDLOADER_EXPORT std::string getTimeUnit() const { return _dt_unit; }
+ MEDLOADER_EXPORT std::vector<INTERP_KERNEL::NormalizedCellType> getAllGeoTypes() const;
MEDLOADER_EXPORT virtual int getNumberOfNodes() const = 0;
+ MEDLOADER_EXPORT virtual std::vector<INTERP_KERNEL::NormalizedCellType> getGeoTypesAtLevel(int meshDimRelToMax) const = 0;
MEDLOADER_EXPORT virtual std::vector<int> getNonEmptyLevels() const = 0;
MEDLOADER_EXPORT virtual std::vector<int> getNonEmptyLevelsExt() const = 0;
MEDLOADER_EXPORT virtual std::vector<int> getFamArrNonEmptyLevelsExt() const = 0;
MEDLOADER_EXPORT virtual std::vector<int> getNumArrNonEmptyLevelsExt() const = 0;
MEDLOADER_EXPORT virtual std::vector<int> getNameArrNonEmptyLevelsExt() const = 0;
- MEDLOADER_EXPORT virtual void write(const char *fileName, int mode) const;
+ MEDLOADER_EXPORT virtual void write(const std::string& fileName, int mode) const;
MEDLOADER_EXPORT virtual void write(med_idt fid) const;
MEDLOADER_EXPORT virtual int getSizeAtLevel(int meshDimRelToMaxExt) const = 0;
MEDLOADER_EXPORT virtual MEDCouplingMesh *getGenMeshAtLevel(int meshDimRelToMax, bool renum=false) const = 0;
//
MEDLOADER_EXPORT bool areFamsEqual(const MEDFileMesh *other, std::string& what) const;
MEDLOADER_EXPORT bool areGrpsEqual(const MEDFileMesh *other, std::string& what) const;
- MEDLOADER_EXPORT bool existsGroup(const char *groupName) const;
+ MEDLOADER_EXPORT bool existsGroup(const std::string& groupName) const;
MEDLOADER_EXPORT bool existsFamily(int famId) const;
- MEDLOADER_EXPORT bool existsFamily(const char *familyName) const;
- MEDLOADER_EXPORT void setFamilyId(const char *familyName, int id);
- MEDLOADER_EXPORT void setFamilyIdUnique(const char *familyName, int id);
- MEDLOADER_EXPORT virtual void addFamily(const char *familyName, int id);
- MEDLOADER_EXPORT virtual void createGroupOnAll(int meshDimRelToMaxExt, const char *groupName);
+ MEDLOADER_EXPORT bool existsFamily(const std::string& familyName) const;
+ MEDLOADER_EXPORT void setFamilyId(const std::string& familyName, int id);
+ MEDLOADER_EXPORT void setFamilyIdUnique(const std::string& familyName, int id);
+ MEDLOADER_EXPORT virtual void addFamily(const std::string& familyName, int id);
+ MEDLOADER_EXPORT virtual void createGroupOnAll(int meshDimRelToMaxExt, const std::string& groupName);
MEDLOADER_EXPORT virtual bool keepFamIdsOnlyOnLevs(const std::vector<int>& famIds, const std::vector<int>& levs);
- MEDLOADER_EXPORT void addFamilyOnGrp(const char *grpName, const char *famName);
+ MEDLOADER_EXPORT void addFamilyOnGrp(const std::string& grpName, const std::string& famName);
MEDLOADER_EXPORT std::string findOrCreateAndGiveFamilyWithId(int id, bool& created);
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 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 std::vector<std::string> getFamiliesOnGroup(const std::string& name) const;
MEDLOADER_EXPORT std::vector<std::string> getFamiliesOnGroups(const std::vector<std::string>& grps) const;
- MEDLOADER_EXPORT std::vector<int> getFamiliesIdsOnGroup(const char *name) const;
- MEDLOADER_EXPORT void setFamiliesOnGroup(const char *name, const std::vector<std::string>& fams);
- MEDLOADER_EXPORT void setFamiliesIdsOnGroup(const char *name, const std::vector<int>& famIds);
- MEDLOADER_EXPORT std::vector<std::string> getGroupsOnFamily(const char *name) const;
- MEDLOADER_EXPORT void setGroupsOnFamily(const char *famName, const std::vector<std::string>& grps);
+ MEDLOADER_EXPORT std::vector<int> getFamiliesIdsOnGroup(const std::string& name) const;
+ MEDLOADER_EXPORT void setFamiliesOnGroup(const std::string& name, const std::vector<std::string>& fams);
+ MEDLOADER_EXPORT void setFamiliesIdsOnGroup(const std::string& name, const std::vector<int>& famIds);
+ MEDLOADER_EXPORT std::vector<std::string> getGroupsOnFamily(const std::string& name) const;
+ MEDLOADER_EXPORT void setGroupsOnFamily(const std::string& famName, const std::vector<std::string>& grps);
MEDLOADER_EXPORT std::vector<std::string> getGroupsNames() const;
MEDLOADER_EXPORT std::vector<std::string> getFamiliesNames() const;
MEDLOADER_EXPORT void assignFamilyNameWithGroupName();
MEDLOADER_EXPORT std::vector<std::string> removeEmptyGroups();
- MEDLOADER_EXPORT void removeGroup(const char *name);
- MEDLOADER_EXPORT void removeFamily(const char *name);
+ MEDLOADER_EXPORT void removeGroup(const std::string& name);
+ MEDLOADER_EXPORT void removeFamily(const std::string& name);
MEDLOADER_EXPORT std::vector<std::string> removeOrphanGroups();
MEDLOADER_EXPORT std::vector<std::string> removeOrphanFamilies();
- MEDLOADER_EXPORT void changeGroupName(const char *oldName, const char *newName);
- MEDLOADER_EXPORT void changeFamilyName(const char *oldName, const char *newName);
+ MEDLOADER_EXPORT void changeGroupName(const std::string& oldName, const std::string& newName);
+ MEDLOADER_EXPORT void changeFamilyName(const std::string& oldName, const std::string& newName);
MEDLOADER_EXPORT void changeFamilyId(int oldId, int newId);
- MEDLOADER_EXPORT void changeAllGroupsContainingFamily(const char *familyNameToChange, const std::vector<std::string>& newFamiliesNames);
- MEDLOADER_EXPORT int getFamilyId(const char *name) const;
+ MEDLOADER_EXPORT void changeAllGroupsContainingFamily(const std::string& familyNameToChange, const std::vector<std::string>& newFamiliesNames);
+ MEDLOADER_EXPORT int getFamilyId(const std::string& name) const;
MEDLOADER_EXPORT int getMaxAbsFamilyId() const;
MEDLOADER_EXPORT int getMaxFamilyId() const;
MEDLOADER_EXPORT int getMinFamilyId() const;
MEDLOADER_EXPORT virtual const DataArrayAsciiChar *getNameFieldAtLevel(int meshDimRelToMaxExt) const = 0;
MEDLOADER_EXPORT virtual DataArrayInt *getFamiliesArr(int meshDimRelToMaxExt, const std::vector<std::string>& fams, bool renum=false) const = 0;
MEDLOADER_EXPORT virtual DataArrayInt *getGroupsArr(int meshDimRelToMaxExt, const std::vector<std::string>& grps, bool renum=false) const;
- MEDLOADER_EXPORT virtual DataArrayInt *getGroupArr(int meshDimRelToMaxExt, const char *grp, bool renum=false) const;
- MEDLOADER_EXPORT virtual DataArrayInt *getFamilyArr(int meshDimRelToMaxExt, const char *fam, bool renum=false) const;
- MEDLOADER_EXPORT virtual DataArrayInt *getNodeGroupArr(const char *grp, bool renum=false) const;
+ MEDLOADER_EXPORT virtual DataArrayInt *getGroupArr(int meshDimRelToMaxExt, const std::string& grp, bool renum=false) const;
+ MEDLOADER_EXPORT virtual DataArrayInt *getFamilyArr(int meshDimRelToMaxExt, const std::string& fam, bool renum=false) const;
+ MEDLOADER_EXPORT virtual DataArrayInt *getNodeGroupArr(const std::string& grp, bool renum=false) const;
MEDLOADER_EXPORT virtual DataArrayInt *getNodeGroupsArr(const std::vector<std::string>& grps, bool renum=false) const;
- MEDLOADER_EXPORT virtual DataArrayInt *getNodeFamilyArr(const char *fam, bool renum=false) const;
+ MEDLOADER_EXPORT virtual DataArrayInt *getNodeFamilyArr(const std::string& fam, bool renum=false) const;
MEDLOADER_EXPORT virtual DataArrayInt *getNodeFamiliesArr(const std::vector<std::string>& fams, bool renum=false) const;
// tools
MEDLOADER_EXPORT virtual bool unPolyze(std::vector<int>& oldCode, std::vector<int>& newCode, DataArrayInt *& o2nRenumCell) = 0;
protected:
MEDFileMesh();
//! protected because no way in MED file API to specify this name
- void setUnivName(const char *name) { _univ_name=name; }
- void addFamilyOnAllGroupsHaving(const char *famName, const char *otherFamName);
+ void setUnivName(const std::string& name) { _univ_name=name; }
+ void addFamilyOnAllGroupsHaving(const std::string& famName, const std::string& otherFamName);
virtual void writeLL(med_idt fid) const = 0;
void dealWithTinyInfo(const MEDCouplingMesh *m);
virtual void synchronizeTinyInfoOnLeaves() const = 0;
virtual void appendFamilyEntries(const DataArrayInt *famIds, const std::vector< std::vector<int> >& fidsOfGrps, const std::vector<std::string>& grpNames);
virtual void changeFamilyIdArr(int oldId, int newId) = 0;
static void TranslateFamilyIds(int offset, DataArrayInt *famArr, std::vector< std::vector<int> >& famIdsPerGrp);
- static void ChangeAllGroupsContainingFamily(std::map<std::string, std::vector<std::string> >& groups, const char *familyNameToChange, const std::vector<std::string>& newFamiliesNames);
+ static void ChangeAllGroupsContainingFamily(std::map<std::string, std::vector<std::string> >& groups, const std::string& familyNameToChange, const std::vector<std::string>& newFamiliesNames);
static std::string FindOrCreateAndGiveFamilyWithId(std::map<std::string,int>& families, int id, bool& created);
static std::string CreateNameNotIn(const std::string& nameTry, const std::vector<std::string>& namesToAvoid);
static int PutInThirdComponentOfCodeOffset(std::vector<int>& code, int strt);
{
friend class MEDFileMesh;
public:
- MEDLOADER_EXPORT static MEDFileUMesh *New(const char *fileName, const char *mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0);
- MEDLOADER_EXPORT static MEDFileUMesh *New(const char *fileName, MEDFileMeshReadSelector *mrs=0);
+ MEDLOADER_EXPORT static MEDFileUMesh *New(const std::string& fileName, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0);
+ MEDLOADER_EXPORT static MEDFileUMesh *New(const std::string& fileName, MEDFileMeshReadSelector *mrs=0);
MEDLOADER_EXPORT static MEDFileUMesh *New();
MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildren() const;
MEDLOADER_EXPORT MEDFileMesh *shallowCpy() const;
MEDLOADER_EXPORT bool isEqual(const MEDFileMesh *other, double eps, std::string& what) const;
MEDLOADER_EXPORT void clearNonDiscrAttributes() const;
+ MEDLOADER_EXPORT void setName(const std::string& name);
MEDLOADER_EXPORT ~MEDFileUMesh();
//
MEDLOADER_EXPORT int getMaxAbsFamilyIdInArrays() const;
MEDLOADER_EXPORT std::vector<int> getFamArrNonEmptyLevelsExt() const;
MEDLOADER_EXPORT std::vector<int> getNumArrNonEmptyLevelsExt() const;
MEDLOADER_EXPORT std::vector<int> getNameArrNonEmptyLevelsExt() const;
- MEDLOADER_EXPORT std::vector<int> getGrpNonEmptyLevels(const char *grp) const;
- MEDLOADER_EXPORT std::vector<int> getGrpNonEmptyLevelsExt(const char *grp) const;
- MEDLOADER_EXPORT std::vector<int> getFamNonEmptyLevels(const char *fam) const;
- MEDLOADER_EXPORT std::vector<int> getFamNonEmptyLevelsExt(const char *fam) const;
+ MEDLOADER_EXPORT std::vector<int> getGrpNonEmptyLevels(const std::string& grp) const;
+ MEDLOADER_EXPORT std::vector<int> getGrpNonEmptyLevelsExt(const std::string& grp) const;
+ MEDLOADER_EXPORT std::vector<int> getFamNonEmptyLevels(const std::string& fam) const;
+ MEDLOADER_EXPORT std::vector<int> getFamNonEmptyLevelsExt(const std::string& fam) const;
MEDLOADER_EXPORT std::vector<int> getGrpsNonEmptyLevels(const std::vector<std::string>& grps) const;
MEDLOADER_EXPORT std::vector<int> getGrpsNonEmptyLevelsExt(const std::vector<std::string>& grps) const;
MEDLOADER_EXPORT std::vector<int> getFamsNonEmptyLevels(const std::vector<std::string>& fams) const;
MEDLOADER_EXPORT std::vector<int> getFamsNonEmptyLevelsExt(const std::vector<std::string>& fams) const;
MEDLOADER_EXPORT std::vector<std::string> getGroupsOnSpecifiedLev(int meshDimRelToMaxExt) const;
MEDLOADER_EXPORT DataArrayDouble *getCoords() const;
- MEDLOADER_EXPORT MEDCouplingUMesh *getGroup(int meshDimRelToMaxExt, const char *grp, bool renum=false) const;
+ MEDLOADER_EXPORT MEDCouplingUMesh *getGroup(int meshDimRelToMaxExt, const std::string& grp, bool renum=false) const;
MEDLOADER_EXPORT MEDCouplingUMesh *getGroups(int meshDimRelToMaxExt, const std::vector<std::string>& grps, bool renum=false) const;
- MEDLOADER_EXPORT MEDCouplingUMesh *getFamily(int meshDimRelToMaxExt, const char *fam, bool renum=false) const;
+ MEDLOADER_EXPORT MEDCouplingUMesh *getFamily(int meshDimRelToMaxExt, const std::string& fam, bool renum=false) const;
MEDLOADER_EXPORT MEDCouplingUMesh *getFamilies(int meshDimRelToMaxExt, const std::vector<std::string>& fams, bool renum=false) const;
MEDLOADER_EXPORT DataArrayInt *getFamiliesArr(int meshDimRelToMaxExt, const std::vector<std::string>& fams, bool renum=false) const;
MEDLOADER_EXPORT MEDCouplingUMesh *getMeshAtLevel(int meshDimRelToMaxExt, bool renum=false) const;
MEDLOADER_EXPORT void setGroupsOnSetMesh(int meshDimRelToMax, const std::vector<const MEDCouplingUMesh *>& ms, bool renum=false);
MEDLOADER_EXPORT void optimizeFamilies();
// tools
- MEDLOADER_EXPORT void duplicateNodesOnM1Group(const char *grpNameM1, DataArrayInt *&nodesDuplicated, DataArrayInt *&cellsModified, DataArrayInt *&cellsNotModified);
+ MEDLOADER_EXPORT void duplicateNodesOnM1Group(const std::string& grpNameM1, DataArrayInt *&nodesDuplicated, DataArrayInt *&cellsModified, DataArrayInt *&cellsNotModified);
MEDLOADER_EXPORT bool unPolyze(std::vector<int>& oldCode, std::vector<int>& newCode, DataArrayInt *& o2nRenumCell);
MEDLOADER_EXPORT DataArrayInt *zipCoords();
private:
void writeLL(med_idt fid) const;
MEDFileUMesh();
- MEDFileUMesh(med_idt fid, const char *mName, int dt, int it, MEDFileMeshReadSelector *mrs);
- void loadUMeshFromFile(med_idt fid, const char *mName, int dt, int it, MEDFileMeshReadSelector *mrs);
+ MEDFileUMesh(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs);
+ void loadUMeshFromFile(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs);
const MEDFileUMeshSplitL1 *getMeshAtLevSafe(int meshDimRelToMaxExt) const;
MEDFileUMeshSplitL1 *getMeshAtLevSafe(int meshDimRelToMaxExt);
void checkMeshDimCoherency(int meshDim, int meshDimRelToMax) const;
MEDCouplingMesh *getGenMeshAtLevel(int meshDimRelToMax, bool renum=false) const;
MEDLOADER_EXPORT int getSizeAtLevel(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;
// tools
MEDLOADER_EXPORT bool unPolyze(std::vector<int>& oldCode, std::vector<int>& newCode, DataArrayInt *& o2nRenumCell);
protected:
void changeFamilyIdArr(int oldId, int newId);
void deepCpyAttributes();
- void loadStrMeshFromFile(MEDFileStrMeshL2 *strm, med_idt fid, const char *mName, int dt, int it, MEDFileMeshReadSelector *mrs);
- void writeStructuredLL(med_idt fid, const char *maa) const;
+ void loadStrMeshFromFile(MEDFileStrMeshL2 *strm, med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs);
+ void writeStructuredLL(med_idt fid, const std::string& maa) const;
virtual const MEDCouplingStructuredMesh *getStructuredMesh() const = 0;
static med_geometry_type GetGeoTypeFromMeshDim(int meshDim);
private:
friend class MEDFileMesh;
public:
MEDLOADER_EXPORT static MEDFileCMesh *New();
- MEDLOADER_EXPORT static MEDFileCMesh *New(const char *fileName, MEDFileMeshReadSelector *mrs=0);
- MEDLOADER_EXPORT static MEDFileCMesh *New(const char *fileName, const char *mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0);
+ MEDLOADER_EXPORT static MEDFileCMesh *New(const std::string& fileName, MEDFileMeshReadSelector *mrs=0);
+ MEDLOADER_EXPORT static MEDFileCMesh *New(const std::string& fileName, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0);
MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildren() const;
MEDLOADER_EXPORT MEDFileMesh *createNewEmpty() const;
MEDLOADER_EXPORT MEDFileMesh *shallowCpy() const;
MEDLOADER_EXPORT bool isEqual(const MEDFileMesh *other, double eps, std::string& what) const;
MEDLOADER_EXPORT int getMeshDimension() const;
+ MEDLOADER_EXPORT int getSpaceDimension() const;
MEDLOADER_EXPORT std::string simpleRepr() const;
MEDLOADER_EXPORT std::string advancedRepr() const;
MEDLOADER_EXPORT void clearNonDiscrAttributes() const;
void writeLL(med_idt fid) const;
MEDFileCMesh();
void synchronizeTinyInfoOnLeaves() const;
- MEDFileCMesh(med_idt fid, const char *mName, int dt, int it, MEDFileMeshReadSelector *mrs);
- void loadCMeshFromFile(med_idt fid, const char *mName, int dt, int it, MEDFileMeshReadSelector *mrs);
+ MEDFileCMesh(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs);
+ void loadCMeshFromFile(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs);
private:
MEDCouplingAutoRefCountObjectPtr<MEDCouplingCMesh> _cmesh;
};
friend class MEDFileMesh;
public:
MEDLOADER_EXPORT static MEDFileCurveLinearMesh *New();
- MEDLOADER_EXPORT static MEDFileCurveLinearMesh *New(const char *fileName, MEDFileMeshReadSelector *mrs=0);
- MEDLOADER_EXPORT static MEDFileCurveLinearMesh *New(const char *fileName, const char *mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0);
+ MEDLOADER_EXPORT static MEDFileCurveLinearMesh *New(const std::string& fileName, MEDFileMeshReadSelector *mrs=0);
+ MEDLOADER_EXPORT static MEDFileCurveLinearMesh *New(const std::string& fileName, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0);
MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildren() const;
MEDLOADER_EXPORT MEDFileMesh *createNewEmpty() const;
MEDLOADER_EXPORT void setMesh(MEDCouplingCurveLinearMesh *m);
private:
MEDFileCurveLinearMesh();
- MEDFileCurveLinearMesh(med_idt fid, const char *mName, int dt, int it, MEDFileMeshReadSelector *mrs);
+ MEDFileCurveLinearMesh(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs);
const MEDCouplingStructuredMesh *getStructuredMesh() const;
void synchronizeTinyInfoOnLeaves() const;
void writeLL(med_idt fid) const;
- void loadCLMeshFromFile(med_idt fid, const char *mName, int dt, int it, MEDFileMeshReadSelector *mrs);//to imp
+ void loadCLMeshFromFile(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs);//to imp
private:
MEDCouplingAutoRefCountObjectPtr<MEDCouplingCurveLinearMesh> _clmesh;
};
{
public:
MEDLOADER_EXPORT static MEDFileMeshMultiTS *New();
- MEDLOADER_EXPORT static MEDFileMeshMultiTS *New(const char *fileName);
- MEDLOADER_EXPORT static MEDFileMeshMultiTS *New(const char *fileName, const char *mName);
+ MEDLOADER_EXPORT static MEDFileMeshMultiTS *New(const std::string& fileName);
+ MEDLOADER_EXPORT static MEDFileMeshMultiTS *New(const std::string& fileName, const std::string& mName);
MEDLOADER_EXPORT MEDFileMeshMultiTS *deepCpy() const;
MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildren() const;
MEDLOADER_EXPORT std::string getName() const;
- MEDLOADER_EXPORT void setName(const char *newMeshName);
+ MEDLOADER_EXPORT void setName(const std::string& newMeshName);
MEDLOADER_EXPORT bool changeNames(const std::vector< std::pair<std::string,std::string> >& modifTab);
MEDLOADER_EXPORT MEDFileMesh *getOneTimeStep() const;
MEDLOADER_EXPORT void write(med_idt fid) const;
- MEDLOADER_EXPORT void write(const char *fileName, int mode) const;
+ MEDLOADER_EXPORT void write(const std::string& fileName, int mode) const;
MEDLOADER_EXPORT void setOneTimeStep(MEDFileMesh *mesh1TimeStep);
private:
- void loadFromFile(const char *fileName, const char *mName);
+ void loadFromFile(const std::string& fileName, const std::string& mName);
MEDFileMeshMultiTS();
- MEDFileMeshMultiTS(const char *fileName);
- MEDFileMeshMultiTS(const char *fileName, const char *mName);
+ MEDFileMeshMultiTS(const std::string& fileName);
+ MEDFileMeshMultiTS(const std::string& fileName, const std::string& mName);
private:
std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> > _mesh_one_ts;
};
{
public:
MEDLOADER_EXPORT static MEDFileMeshes *New();
- MEDLOADER_EXPORT static MEDFileMeshes *New(const char *fileName);
+ MEDLOADER_EXPORT static MEDFileMeshes *New(const std::string& fileName);
MEDLOADER_EXPORT MEDFileMeshes *deepCpy() const;
MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildren() const;
MEDLOADER_EXPORT std::string simpleRepr() const;
MEDLOADER_EXPORT void simpleReprWithoutHeader(std::ostream& oss) const;
- MEDLOADER_EXPORT void write(const char *fileName, int mode) const;
+ MEDLOADER_EXPORT void write(const std::string& fileName, int mode) const;
MEDLOADER_EXPORT void write(med_idt fid) const;
MEDLOADER_EXPORT int getNumberOfMeshes() const;
MEDLOADER_EXPORT MEDFileMeshesIterator *iterator();
MEDLOADER_EXPORT MEDFileMesh *getMeshAtPos(int i) const;
- MEDLOADER_EXPORT MEDFileMesh *getMeshWithName(const char *mname) const;
+ MEDLOADER_EXPORT MEDFileMesh *getMeshWithName(const std::string& mname) const;
MEDLOADER_EXPORT std::vector<std::string> getMeshesNames() const;
MEDLOADER_EXPORT bool changeNames(const std::vector< std::pair<std::string,std::string> >& modifTab);
//
MEDLOADER_EXPORT void destroyMeshAtPos(int i);
private:
void checkCoherency() const;
- void loadFromFile(const char *fileName);
+ void loadFromFile(const std::string& fileName);
MEDFileMeshes();
- MEDFileMeshes(const char *fileName);
+ MEDFileMeshes(const std::string& fileName);
private:
std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileMeshMultiTS> > _meshes;
};
loadCommonPart(fid,mName,dt,it,mdim,curNbOfElem,MED_POLYHEDRON,entity,mrs);
}
-void MEDFileUMeshPerType::Write(med_idt fid, const char *mname, int mdim, const MEDCoupling1GTUMesh *m, const DataArrayInt *fam, const DataArrayInt *num, const DataArrayAsciiChar *names)
+void MEDFileUMeshPerType::Write(med_idt fid, const std::string& mname, int mdim, const MEDCoupling1GTUMesh *m, const DataArrayInt *fam, const DataArrayInt *num, const DataArrayAsciiChar *names)
{
int nbOfCells=m->getNumberOfCells();
if(nbOfCells<1)
throw INTERP_KERNEL::Exception("MEDFileUMeshPerType::Write : internal error #1 !");
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr(m0->getNodalConnectivity()->deepCpy());
std::transform(arr->begin(),arr->end(),arr->getPointer(),std::bind2nd(std::plus<int>(),1));
- MEDmeshElementConnectivityWr(fid,mname,dt,it,timm,MED_CELL,curMedType,MED_NODAL,MED_FULL_INTERLACE,nbOfCells,arr->begin());
+ MEDmeshElementConnectivityWr(fid,mname.c_str(),dt,it,timm,MED_CELL,curMedType,MED_NODAL,MED_FULL_INTERLACE,nbOfCells,arr->begin());
}
else
{
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr(m0->getNodalConnectivity()->deepCpy()),arrI(m0->getNodalConnectivityIndex()->deepCpy());
std::transform(arr->begin(),arr->end(),arr->getPointer(),std::bind2nd(std::plus<int>(),1));
std::transform(arrI->begin(),arrI->end(),arrI->getPointer(),std::bind2nd(std::plus<int>(),1));
- MEDmeshPolygon2Wr(fid,mname,dt,it,timm,MED_CELL,ikt==INTERP_KERNEL::NORM_POLYGON?MED_POLYGON:MED_POLYGON2,MED_NODAL,nbOfCells+1,arrI->begin(),arr->begin());
+ MEDmeshPolygon2Wr(fid,mname.c_str(),dt,it,timm,MED_CELL,ikt==INTERP_KERNEL::NORM_POLYGON?MED_POLYGON:MED_POLYGON2,MED_NODAL,nbOfCells+1,arrI->begin(),arr->begin());
}
else
{
}
w1[1]=w1[0]+nbOfFaces2;
}
- MEDmeshPolyhedronWr(fid,mname,dt,it,timm,MED_CELL,MED_NODAL,nbOfCells+1,tab1,nbOfFaces+1,tab2,bigtab);
+ MEDmeshPolyhedronWr(fid,mname.c_str(),dt,it,timm,MED_CELL,MED_NODAL,nbOfCells+1,tab1,nbOfFaces+1,tab2,bigtab);
}
}
if(fam)
- MEDmeshEntityFamilyNumberWr(fid,mname,dt,it,MED_CELL,curMedType,nbOfCells,fam->getConstPointer());
+ MEDmeshEntityFamilyNumberWr(fid,mname.c_str(),dt,it,MED_CELL,curMedType,nbOfCells,fam->getConstPointer());
if(num)
- MEDmeshEntityNumberWr(fid,mname,dt,it,MED_CELL,curMedType,nbOfCells,num->getConstPointer());
+ MEDmeshEntityNumberWr(fid,mname.c_str(),dt,it,MED_CELL,curMedType,nbOfCells,num->getConstPointer());
if(names)
{
if(names->getNumberOfComponents()!=MED_SNAME_SIZE)
oss << " ! The array has " << names->getNumberOfComponents() << " components !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
- MEDmeshEntityNameWr(fid,mname,dt,it,MED_CELL,curMedType,nbOfCells,names->getConstPointer());
+ MEDmeshEntityNameWr(fid,mname.c_str(),dt,it,MED_CELL,curMedType,nbOfCells,names->getConstPointer());
}
}
const DataArrayInt *getFam() const { return _fam; }
const DataArrayInt *getNum() const { return _num; }
const DataArrayAsciiChar *getNames() const { return _names; }
- static void Write(med_idt fid, const char *mname, int mdim, const MEDCoupling1GTUMesh *m, const DataArrayInt *fam, const DataArrayInt *num, const DataArrayAsciiChar *names);
+ static void Write(med_idt fid, const std::string& mname, int mdim, const MEDCoupling1GTUMesh *m, const DataArrayInt *fam, const DataArrayInt *num, const DataArrayAsciiChar *names);
private:
MEDFileUMeshPerType(med_idt fid, const char *mName, int dt, int it, int mdim, med_geometry_type geoElt, INTERP_KERNEL::NormalizedCellType type,
med_entity_type entity, MEDFileMeshReadSelector *mrs);
return std::vector<const BigMemoryObject *>();
}
-int MEDFileMeshL2::GetMeshIdFromName(med_idt fid, const char *mname, ParaMEDMEM::MEDCouplingMeshType& meshType, int& dt, int& it, std::string& dtunit1)
+int MEDFileMeshL2::GetMeshIdFromName(med_idt fid, const std::string& mname, ParaMEDMEM::MEDCouplingMeshType& meshType, int& dt, int& it, std::string& dtunit1)
{
med_mesh_type type_maillage;
char maillage_description[MED_COMMENT_SIZE+1];
case MED_STRUCTURED_MESH:
{
med_grid_type gt;
- MEDmeshGridTypeRd(fid,mname,>);
+ MEDmeshGridTypeRd(fid,mname.c_str(),>);
switch(gt)
{
case MED_CARTESIAN_GRID:
}
med_int numdt,numit;
med_float dtt;
- MEDmeshComputationStepInfo(fid,mname,1,&numdt,&numit,&dtt);
+ MEDmeshComputationStepInfo(fid,mname.c_str(),1,&numdt,&numit,&dtt);
dt=numdt; it=numit;
return ret;
}
-double MEDFileMeshL2::CheckMeshTimeStep(med_idt fid, const char *mName, int nstep, int dt, int it)
+double MEDFileMeshL2::CheckMeshTimeStep(med_idt fid, const std::string& mName, int nstep, int dt, int it)
{
bool found=false;
med_int numdt,numit;
std::vector< std::pair<int,int> > p(nstep);
for(int i=0;i<nstep;i++)
{
- MEDmeshComputationStepInfo(fid,mName,i+1,&numdt,&numit,&dtt);
+ MEDmeshComputationStepInfo(fid,mName.c_str(),i+1,&numdt,&numit,&dtt);
p[i]=std::make_pair<int,int>(numdt,numit);
found=(numdt==dt) && (numit==numit);
}
return dtt;
}
-std::vector<std::string> MEDFileMeshL2::getAxisInfoOnMesh(med_idt fid, int mId, const char *mName, ParaMEDMEM::MEDCouplingMeshType& meshType, int& nstep, int& Mdim)
+std::vector<std::string> MEDFileMeshL2::getAxisInfoOnMesh(med_idt fid, int mId, const std::string& mName, ParaMEDMEM::MEDCouplingMeshType& meshType, int& nstep, int& Mdim)
{
med_mesh_type type_maillage;
med_int spaceDim;
case MED_STRUCTURED_MESH:
{
med_grid_type gt;
- MEDmeshGridTypeRd(fid,mName,>);
+ MEDmeshGridTypeRd(fid,mName.c_str(),>);
switch(gt)
{
case MED_CARTESIAN_GRID:
return infosOnComp;
}
-void MEDFileMeshL2::ReadFamiliesAndGrps(med_idt fid, const char *meshName, std::map<std::string,int>& fams, std::map<std::string, std::vector<std::string> >& grps, MEDFileMeshReadSelector *mrs)
+void MEDFileMeshL2::ReadFamiliesAndGrps(med_idt fid, const std::string& meshName, std::map<std::string,int>& fams, std::map<std::string, std::vector<std::string> >& grps, MEDFileMeshReadSelector *mrs)
{
if(mrs && !(mrs->isCellFamilyFieldReading() || mrs->isNodeFamilyFieldReading()))
return ;
char nomfam[MED_NAME_SIZE+1];
med_int numfam;
- int nfam=MEDnFamily(fid,meshName);
+ int nfam=MEDnFamily(fid,meshName.c_str());
for(int i=0;i<nfam;i++)
{
- int ngro=MEDnFamilyGroup(fid,meshName,i+1);
- med_int natt=MEDnFamily23Attribute(fid,meshName,i+1);
+ int ngro=MEDnFamilyGroup(fid,meshName.c_str(),i+1);
+ med_int natt=MEDnFamily23Attribute(fid,meshName.c_str(),i+1);
INTERP_KERNEL::AutoPtr<med_int> attide=new med_int[natt];
INTERP_KERNEL::AutoPtr<med_int> attval=new med_int[natt];
INTERP_KERNEL::AutoPtr<char> attdes=new char[MED_COMMENT_SIZE*natt+1];
INTERP_KERNEL::AutoPtr<char> gro=new char[MED_LNAME_SIZE*ngro+1];
- MEDfamily23Info(fid,meshName,i+1,nomfam,attide,attval,attdes,&numfam,gro);
+ MEDfamily23Info(fid,meshName.c_str(),i+1,nomfam,attide,attval,attdes,&numfam,gro);
std::string famName=MEDLoaderBase::buildStringFromFortran(nomfam,MED_NAME_SIZE);
fams[famName]=numfam;
for(int j=0;j<ngro;j++)
}
}
-void MEDFileMeshL2::WriteFamiliesAndGrps(med_idt fid, const char *mname, const std::map<std::string,int>& fams, const std::map<std::string, std::vector<std::string> >& grps, int tooLongStrPol)
+void MEDFileMeshL2::WriteFamiliesAndGrps(med_idt fid, const std::string& mname, const std::map<std::string,int>& fams, const std::map<std::string, std::vector<std::string> >& grps, int tooLongStrPol)
{
for(std::map<std::string,int>::const_iterator it=fams.begin();it!=fams.end();it++)
{
MEDLoaderBase::safeStrCpy2((*it2).c_str(),MED_LNAME_SIZE-1,groName+i*MED_LNAME_SIZE,tooLongStrPol);
INTERP_KERNEL::AutoPtr<char> famName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
MEDLoaderBase::safeStrCpy((*it).first.c_str(),MED_NAME_SIZE,famName,tooLongStrPol);
- int ret=MEDfamilyCr(fid,mname,famName,(*it).second,ngro,groName);
+ int ret=MEDfamilyCr(fid,mname.c_str(),famName,(*it).second,ngro,groName);
ret++;
}
}
{
}
-void MEDFileUMeshL2::loadAll(med_idt fid, int mId, const char *mName, int dt, int it, MEDFileMeshReadSelector *mrs)
+void MEDFileUMeshL2::loadAll(med_idt fid, int mId, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs)
{
- _name.set(mName);
+ _name.set(mName.c_str());
int nstep;
int Mdim;
ParaMEDMEM::MEDCouplingMeshType meshType;
- std::vector<std::string> infosOnComp=getAxisInfoOnMesh(fid,mId,mName,meshType,nstep,Mdim);
+ std::vector<std::string> infosOnComp=getAxisInfoOnMesh(fid,mId,mName.c_str(),meshType,nstep,Mdim);
if(meshType!=UNSTRUCTURED)
throw INTERP_KERNEL::Exception("Invalid mesh type ! You are expected an unstructured one whereas in file it is not an unstructured !");
_time=CheckMeshTimeStep(fid,mName,nstep,dt,it);
loadCoords(fid,mId,infosOnComp,mName,dt,it);
}
-void MEDFileUMeshL2::loadConnectivity(med_idt fid, int mdim, const char *mName, int dt, int it, MEDFileMeshReadSelector *mrs)
+void MEDFileUMeshL2::loadConnectivity(med_idt fid, int mdim, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs)
{
_per_type_mesh.resize(1);
_per_type_mesh[0].clear();
for(int j=0;j<MED_N_CELL_FIXED_GEO;j++)
{
- MEDFileUMeshPerType *tmp=MEDFileUMeshPerType::New(fid,mName,dt,it,mdim,typmai[j],typmai2[j],mrs);
+ MEDFileUMeshPerType *tmp=MEDFileUMeshPerType::New(fid,mName.c_str(),dt,it,mdim,typmai[j],typmai2[j],mrs);
if(tmp)
_per_type_mesh[0].push_back(tmp);
}
sortTypes();
}
-void MEDFileUMeshL2::loadCoords(med_idt fid, int mId, const std::vector<std::string>& infosOnComp, const char *mName, int dt, int it)
+void MEDFileUMeshL2::loadCoords(med_idt fid, int mId, const std::vector<std::string>& infosOnComp, const std::string& mName, int dt, int it)
{
int spaceDim=infosOnComp.size();
med_bool changement,transformation;
- int nCoords=MEDmeshnEntity(fid,mName,dt,it,MED_NODE,MED_NONE,MED_COORDINATE,MED_NO_CMODE,&changement,&transformation);
+ int nCoords=MEDmeshnEntity(fid,mName.c_str(),dt,it,MED_NODE,MED_NONE,MED_COORDINATE,MED_NO_CMODE,&changement,&transformation);
_coords=DataArrayDouble::New();
_coords->alloc(nCoords,spaceDim);
double *coordsPtr=_coords->getPointer();
- MEDmeshNodeCoordinateRd(fid,mName,dt,it,MED_FULL_INTERLACE,coordsPtr);
- if(MEDmeshnEntity(fid,mName,dt,it,MED_NODE,MED_NO_GEOTYPE,MED_FAMILY_NUMBER,MED_NODAL,&changement,&transformation)>0)
+ MEDmeshNodeCoordinateRd(fid,mName.c_str(),dt,it,MED_FULL_INTERLACE,coordsPtr);
+ if(MEDmeshnEntity(fid,mName.c_str(),dt,it,MED_NODE,MED_NO_GEOTYPE,MED_FAMILY_NUMBER,MED_NODAL,&changement,&transformation)>0)
{
_fam_coords=DataArrayInt::New();
_fam_coords->alloc(nCoords,1);
- MEDmeshEntityFamilyNumberRd(fid,mName,dt,it,MED_NODE,MED_NO_GEOTYPE,_fam_coords->getPointer());
+ MEDmeshEntityFamilyNumberRd(fid,mName.c_str(),dt,it,MED_NODE,MED_NO_GEOTYPE,_fam_coords->getPointer());
}
else
_fam_coords=0;
- if(MEDmeshnEntity(fid,mName,dt,it,MED_NODE,MED_NO_GEOTYPE,MED_NUMBER,MED_NODAL,&changement,&transformation)>0)
+ if(MEDmeshnEntity(fid,mName.c_str(),dt,it,MED_NODE,MED_NO_GEOTYPE,MED_NUMBER,MED_NODAL,&changement,&transformation)>0)
{
_num_coords=DataArrayInt::New();
_num_coords->alloc(nCoords,1);
- MEDmeshEntityNumberRd(fid,mName,dt,it,MED_NODE,MED_NO_GEOTYPE,_num_coords->getPointer());
+ MEDmeshEntityNumberRd(fid,mName.c_str(),dt,it,MED_NODE,MED_NO_GEOTYPE,_num_coords->getPointer());
}
else
_num_coords=0;
- if(MEDmeshnEntity(fid,mName,dt,it,MED_NODE,MED_NO_GEOTYPE,MED_NAME,MED_NODAL,&changement,&transformation)>0)
+ if(MEDmeshnEntity(fid,mName.c_str(),dt,it,MED_NODE,MED_NO_GEOTYPE,MED_NAME,MED_NODAL,&changement,&transformation)>0)
{
_name_coords=DataArrayAsciiChar::New();
_name_coords->alloc(nCoords+1,MED_SNAME_SIZE);//not a bug to avoid the memory corruption due to last \0 at the end
- MEDmeshEntityNameRd(fid,mName,dt,it,MED_NODE,MED_NO_GEOTYPE,_name_coords->getPointer());
+ MEDmeshEntityNameRd(fid,mName.c_str(),dt,it,MED_NODE,MED_NO_GEOTYPE,_name_coords->getPointer());
_name_coords->reAlloc(nCoords);//not a bug to avoid the memory corruption due to last \0 at the end
}
else
_name_coords=0;
for(int i=0;i<spaceDim;i++)
- _coords->setInfoOnComponent(i,infosOnComp[i].c_str());
+ _coords->setInfoOnComponent(i,infosOnComp[i]);
}
void MEDFileUMeshL2::sortTypes()
_per_type_mesh.resize(_per_type_mesh.size()-nbOfUselessLev);
}
-void MEDFileUMeshL2::WriteCoords(med_idt fid, const char *mname, int dt, int it, double time, const DataArrayDouble *coords, const DataArrayInt *famCoords, const DataArrayInt *numCoords, const DataArrayAsciiChar *nameCoords)
+void MEDFileUMeshL2::WriteCoords(med_idt fid, const std::string& mname, int dt, int it, double time, const DataArrayDouble *coords, const DataArrayInt *famCoords, const DataArrayInt *numCoords, const DataArrayAsciiChar *nameCoords)
{
if(!coords)
return ;
- MEDmeshNodeCoordinateWr(fid,mname,dt,it,time,MED_FULL_INTERLACE,coords->getNumberOfTuples(),coords->getConstPointer());
+ MEDmeshNodeCoordinateWr(fid,mname.c_str(),dt,it,time,MED_FULL_INTERLACE,coords->getNumberOfTuples(),coords->getConstPointer());
if(famCoords)
- MEDmeshEntityFamilyNumberWr(fid,mname,dt,it,MED_NODE,MED_NO_GEOTYPE,famCoords->getNumberOfTuples(),famCoords->getConstPointer());
+ MEDmeshEntityFamilyNumberWr(fid,mname.c_str(),dt,it,MED_NODE,MED_NO_GEOTYPE,famCoords->getNumberOfTuples(),famCoords->getConstPointer());
if(numCoords)
- MEDmeshEntityNumberWr(fid,mname,dt,it,MED_NODE,MED_NO_GEOTYPE,numCoords->getNumberOfTuples(),numCoords->getConstPointer());
+ MEDmeshEntityNumberWr(fid,mname.c_str(),dt,it,MED_NODE,MED_NO_GEOTYPE,numCoords->getNumberOfTuples(),numCoords->getConstPointer());
if(nameCoords)
{
if(nameCoords->getNumberOfComponents()!=MED_SNAME_SIZE)
oss << " ! The array has " << nameCoords->getNumberOfComponents() << " components !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
- MEDmeshEntityNameWr(fid,mname,dt,it,MED_NODE,MED_NO_GEOTYPE,nameCoords->getNumberOfTuples(),nameCoords->getConstPointer());
+ MEDmeshEntityNameWr(fid,mname.c_str(),dt,it,MED_NODE,MED_NO_GEOTYPE,nameCoords->getNumberOfTuples(),nameCoords->getConstPointer());
}
}
{
}
-void MEDFileCMeshL2::loadAll(med_idt fid, int mId, const char *mName, int dt, int it)
+void MEDFileCMeshL2::loadAll(med_idt fid, int mId, const std::string& mName, int dt, int it)
{
- _name.set(mName);
+ _name.set(mName.c_str());
int nstep;
int Mdim;
ParaMEDMEM::MEDCouplingMeshType meshType;
- std::vector<std::string> infosOnComp=getAxisInfoOnMesh(fid,mId,mName,meshType,nstep,Mdim);
+ std::vector<std::string> infosOnComp=getAxisInfoOnMesh(fid,mId,mName.c_str(),meshType,nstep,Mdim);
if(meshType!=CARTESIAN)
throw INTERP_KERNEL::Exception("Invalid mesh type ! You are expected a structured one whereas in file it is not a structured !");
_time=CheckMeshTimeStep(fid,mName,nstep,dt,it);
_order=it;
//
med_grid_type gridtype;
- MEDmeshGridTypeRd(fid,mName,&gridtype);
+ MEDmeshGridTypeRd(fid,mName.c_str(),&gridtype);
if(gridtype!=MED_CARTESIAN_GRID)
throw INTERP_KERNEL::Exception("Invalid structured mesh ! Expected cartesian mesh type !");
_cmesh=MEDCouplingCMesh::New();
{
med_data_type dataTypeReq=GetDataTypeCorrespondingToSpaceId(i);
med_bool chgt=MED_FALSE,trsf=MED_FALSE;
- int nbOfElt=MEDmeshnEntity(fid,mName,dt,it,MED_NODE,MED_NONE,dataTypeReq,MED_NO_CMODE,&chgt,&trsf);
+ int nbOfElt=MEDmeshnEntity(fid,mName.c_str(),dt,it,MED_NODE,MED_NONE,dataTypeReq,MED_NO_CMODE,&chgt,&trsf);
MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> da=DataArrayDouble::New();
da->alloc(nbOfElt,1);
- da->setInfoOnComponent(0,infosOnComp[i].c_str());
- MEDmeshGridIndexCoordinateRd(fid,mName,dt,it,i+1,da->getPointer());
+ da->setInfoOnComponent(0,infosOnComp[i]);
+ MEDmeshGridIndexCoordinateRd(fid,mName.c_str(),dt,it,i+1,da->getPointer());
_cmesh->setCoordsAt(i,da);
}
}
{
}
-void MEDFileCLMeshL2::loadAll(med_idt fid, int mId, const char *mName, int dt, int it)
+void MEDFileCLMeshL2::loadAll(med_idt fid, int mId, const std::string& mName, int dt, int it)
{
- _name.set(mName);
+ _name.set(mName.c_str());
int nstep;
int Mdim;
ParaMEDMEM::MEDCouplingMeshType meshType;
//
_clmesh=MEDCouplingCurveLinearMesh::New();
INTERP_KERNEL::AutoPtr<int> stGrid=new int[Mdim];
- MEDmeshGridStructRd(fid,mName,dt,it,stGrid);
+ MEDmeshGridStructRd(fid,mName.c_str(),dt,it,stGrid);
_clmesh->setNodeGridStructure(stGrid,((int *)stGrid)+Mdim);
med_bool chgt=MED_FALSE,trsf=MED_FALSE;
- int nbNodes=MEDmeshnEntity(fid,mName,dt,it,MED_NODE,MED_NONE,MED_COORDINATE,MED_NO_CMODE,&chgt,&trsf);
+ int nbNodes=MEDmeshnEntity(fid,mName.c_str(),dt,it,MED_NODE,MED_NONE,MED_COORDINATE,MED_NO_CMODE,&chgt,&trsf);
MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> da=DataArrayDouble::New();
da->alloc(nbNodes,infosOnComp.size());
da->setInfoOnComponents(infosOnComp);
- MEDmeshNodeCoordinateRd(fid,mName,dt,it,MED_FULL_INTERLACE,da->getPointer());
+ MEDmeshNodeCoordinateRd(fid,mName.c_str(),dt,it,MED_FULL_INTERLACE,da->getPointer());
_clmesh->setCoords(da);
}
{
}
-MEDFileUMeshSplitL1::MEDFileUMeshSplitL1(const MEDFileUMeshL2& l2, const char *mName, int id):_m(this)
+MEDFileUMeshSplitL1::MEDFileUMeshSplitL1(const MEDFileUMeshL2& l2, const std::string& mName, int id):_m(this)
{
const std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> >& v=l2.getLev(id);
if(v.empty())
assignMesh(m,newOrOld);
}
+void MEDFileUMeshSplitL1::setName(const std::string& name)
+{
+ _m_by_types.setName(name);
+}
+
std::size_t MEDFileUMeshSplitL1::getHeapMemorySizeWithoutChildren() const
{
return 0;
*w=famIdTrad[*w];
}
-void MEDFileUMeshSplitL1::write(med_idt fid, const char *mName, int mdim) const
+void MEDFileUMeshSplitL1::write(med_idt fid, const std::string& mName, int mdim) const
{
std::vector<MEDCoupling1GTUMesh *> ms(_m_by_types.getParts());
int start=0;
{
}
+void MEDFileUMeshAggregateCompute::setName(const std::string& name)
+{
+ if(_m_time>=_mp_time)
+ {
+ MEDCouplingUMesh *um(_m);
+ if(um)
+ um->setName(name);
+ }
+ if(_mp_time>=_m_time)
+ {
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> >::iterator it=_m_parts.begin();it!=_m_parts.end();it++)
+ {
+ MEDCoupling1GTUMesh *tmp(*it);
+ if(tmp)
+ tmp->setName(name);
+ }
+ }
+}
+
void MEDFileUMeshAggregateCompute::assignParts(const std::vector< const MEDCoupling1GTUMesh * >& mParts)
{
std::size_t sz(mParts.size());
_m_parts.resize(sz);
for(std::size_t i=0;i<sz;i++)
_m_parts[i]=MEDCoupling1GTUMesh::New(ms[i]);
- _mp_time=std::max(_mp_time,_m_time)+1;
+ _mp_time=std::max(_mp_time,_m_time);
}
std::size_t MEDFileUMeshAggregateCompute::getTimeOfThis() const
int getIteration() const { return _iteration; }
int getOrder() const { return _order; }
double getTime() { return _time; }
- std::vector<std::string> getAxisInfoOnMesh(med_idt fid, int mId, const char *mName, ParaMEDMEM::MEDCouplingMeshType& meshType, int& nstep, int& Mdim);
- static int GetMeshIdFromName(med_idt fid, const char *mName, ParaMEDMEM::MEDCouplingMeshType& meshType, int& dt, int& it, std::string& dtunit1);
- static double CheckMeshTimeStep(med_idt fid, const char *mname, int nstep, int dt, int it);
- static void ReadFamiliesAndGrps(med_idt fid, const char *mname, std::map<std::string,int>& fams, std::map<std::string, std::vector<std::string> >& grps, MEDFileMeshReadSelector *mrs);
- static void WriteFamiliesAndGrps(med_idt fid, const char *mname, const std::map<std::string,int>& fams, const std::map<std::string, std::vector<std::string> >& grps, int tooLongStrPol);
+ std::vector<std::string> getAxisInfoOnMesh(med_idt fid, int mId, const std::string& mName, ParaMEDMEM::MEDCouplingMeshType& meshType, int& nstep, int& Mdim);
+ static int GetMeshIdFromName(med_idt fid, const std::string& mName, ParaMEDMEM::MEDCouplingMeshType& meshType, int& dt, int& it, std::string& dtunit1);
+ static double CheckMeshTimeStep(med_idt fid, const std::string& mname, int nstep, int dt, int it);
+ static void ReadFamiliesAndGrps(med_idt fid, const std::string& mname, std::map<std::string,int>& fams, std::map<std::string, std::vector<std::string> >& grps, MEDFileMeshReadSelector *mrs);
+ static void WriteFamiliesAndGrps(med_idt fid, const std::string& mname, const std::map<std::string,int>& fams, const std::map<std::string, std::vector<std::string> >& grps, int tooLongStrPol);
protected:
MEDFileString _name;
MEDFileString _description;
{
public:
MEDFileUMeshL2();
- void loadAll(med_idt fid, int mId, const char *mName, int dt, int it, MEDFileMeshReadSelector *mrs);
- void loadConnectivity(med_idt fid, int mdim, const char *mName, int dt, int it, MEDFileMeshReadSelector *mrs);
- void loadCoords(med_idt fid, int mId, const std::vector<std::string>& infosOnComp, const char *mName, int dt, int it);
+ void loadAll(med_idt fid, int mId, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs);
+ void loadConnectivity(med_idt fid, int mdim, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs);
+ void loadCoords(med_idt fid, int mId, const std::vector<std::string>& infosOnComp, const std::string& mName, int dt, int it);
int getNumberOfLevels() const { return _per_type_mesh.size(); }
bool emptyLev(int levId) const { return _per_type_mesh[levId].empty(); }
const std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> >& getLev(int levId) const { return _per_type_mesh[levId]; }
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> getCoordsFamily() const { return _fam_coords; }
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> getCoordsNum() const { return _num_coords; }
MEDCouplingAutoRefCountObjectPtr<DataArrayAsciiChar> getCoordsName() const { return _name_coords; }
- static void WriteCoords(med_idt fid, const char *mname, int dt, int it, double time, const DataArrayDouble *coords, const DataArrayInt *famCoords, const DataArrayInt *numCoords, const DataArrayAsciiChar *nameCoords);
+ static void WriteCoords(med_idt fid, const std::string& mname, int dt, int it, double time, const DataArrayDouble *coords, const DataArrayInt *famCoords, const DataArrayInt *numCoords, const DataArrayAsciiChar *nameCoords);
private:
void sortTypes();
private:
{
public:
MEDFileCMeshL2();
- void loadAll(med_idt fid, int mId, const char *mName, int dt, int it);
+ void loadAll(med_idt fid, int mId, const std::string& mName, int dt, int it);
MEDCouplingCMesh *getMesh() { return _cmesh; }
private:
static med_data_type GetDataTypeCorrespondingToSpaceId(int id);
{
public:
MEDFileCLMeshL2();
- void loadAll(med_idt fid, int mId, const char *mName, int dt, int it);
+ void loadAll(med_idt fid, int mId, const std::string& mName, int dt, int it);
MEDCouplingCurveLinearMesh *getMesh() { return _clmesh; }
private:
MEDCouplingAutoRefCountObjectPtr<MEDCouplingCurveLinearMesh> _clmesh;
{
public:
MEDFileUMeshAggregateCompute();
+ void setName(const std::string& name);
void assignParts(const std::vector< const MEDCoupling1GTUMesh * >& mParts);
void assignUMesh(MEDCouplingUMesh *m);
MEDCouplingUMesh *getUmesh() const;
friend class MEDFileUMeshPermCompute;
public:
MEDFileUMeshSplitL1(const MEDFileUMeshSplitL1& other);
- MEDFileUMeshSplitL1(const MEDFileUMeshL2& l2, const char *mName, int id);
+ MEDFileUMeshSplitL1(const MEDFileUMeshL2& l2, const std::string& mName, int id);
MEDFileUMeshSplitL1(MEDCoupling1GTUMesh *m);
MEDFileUMeshSplitL1(MEDCouplingUMesh *m);
MEDFileUMeshSplitL1(MEDCouplingUMesh *m, bool newOrOld);
+ void setName(const std::string& name);
std::size_t getHeapMemorySizeWithoutChildren() const;
std::vector<const BigMemoryObject *> getDirectChildren() const;
MEDFileUMeshSplitL1 *deepCpy(DataArrayDouble *coords) const;
void eraseFamilyField();
void setGroupsFromScratch(const std::vector<const MEDCouplingUMesh *>& ms, std::map<std::string,int>& familyIds,
std::map<std::string, std::vector<std::string> >& groups) throw(INTERP_KERNEL::Exception);
- void write(med_idt fid, const char *mName, int mdim) const;
+ void write(med_idt fid, const std::string& mName, int mdim) const;
//
void setFamilyArr(DataArrayInt *famArr);
void setRenumArr(DataArrayInt *renumArr);
return new MEDFileParameterDouble1TS;
}
-MEDFileParameterDouble1TS *MEDFileParameterDouble1TS::New(const char *fileName)
+MEDFileParameterDouble1TS *MEDFileParameterDouble1TS::New(const std::string& fileName)
{
return new MEDFileParameterDouble1TS(fileName);
}
-MEDFileParameterDouble1TS *MEDFileParameterDouble1TS::New(const char *fileName, const char *paramName)
+MEDFileParameterDouble1TS *MEDFileParameterDouble1TS::New(const std::string& fileName, const std::string& paramName)
{
return new MEDFileParameterDouble1TS(fileName,paramName);
}
-MEDFileParameterDouble1TS *MEDFileParameterDouble1TS::New(const char *fileName, const char *paramName, int dt, int it)
+MEDFileParameterDouble1TS *MEDFileParameterDouble1TS::New(const std::string& fileName, const std::string& paramName, int dt, int it)
{
return new MEDFileParameterDouble1TS(fileName,paramName,dt,it);
}
{
}
-MEDFileParameterDouble1TS::MEDFileParameterDouble1TS(const char *fileName, const char *paramName, int dt, int it)
+MEDFileParameterDouble1TS::MEDFileParameterDouble1TS(const std::string& fileName, const std::string& paramName, int dt, int it)
{
MEDFileUtilities::CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
int nbPar=MEDnParameter(fid);
std::ostringstream oss; oss << "MEDFileParameterDouble1TS : no double param name \"" << paramName << "\" ! Double Parameters available are : ";
INTERP_KERNEL::AutoPtr<char> pName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
-MEDFileParameterDouble1TS::MEDFileParameterDouble1TS(const char *fileName, const char *paramName)
+MEDFileParameterDouble1TS::MEDFileParameterDouble1TS(const std::string& fileName, const std::string& paramName)
{
MEDFileUtilities::CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
int nbPar=MEDnParameter(fid);
std::ostringstream oss; oss << "MEDFileParameterDouble1TS : no double param name \"" << paramName << "\" ! Double Parameters available are : ";
INTERP_KERNEL::AutoPtr<char> pName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
-MEDFileParameterDouble1TS::MEDFileParameterDouble1TS(const char *fileName)
+MEDFileParameterDouble1TS::MEDFileParameterDouble1TS(const std::string& fileName)
{
MEDFileUtilities::CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
int nbPar=MEDnParameter(fid);
if(nbPar<1)
{
return std::vector<const BigMemoryObject *>();
}
-void MEDFileParameterDouble1TS::write(const char *fileName, int mode) const
+void MEDFileParameterDouble1TS::write(const std::string& fileName, int mode) const
{
med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod);
MEDFileParameterTinyInfo::writeLLHeader(fid,MED_FLOAT64);
MEDFileParameterDouble1TSWTI::writeLL(fid,_name,*this);
}
return new MEDFileParameterMultiTS;
}
-MEDFileParameterMultiTS *MEDFileParameterMultiTS::New(const char *fileName)
+MEDFileParameterMultiTS *MEDFileParameterMultiTS::New(const std::string& fileName)
{
return new MEDFileParameterMultiTS(fileName);
}
-MEDFileParameterMultiTS *MEDFileParameterMultiTS::New(const char *fileName, const char *paramName)
+MEDFileParameterMultiTS *MEDFileParameterMultiTS::New(const std::string& fileName, const std::string& paramName)
{
return new MEDFileParameterMultiTS(fileName,paramName);
}
}
}
-MEDFileParameterMultiTS::MEDFileParameterMultiTS(const char *fileName)
+MEDFileParameterMultiTS::MEDFileParameterMultiTS(const std::string& fileName)
{
MEDFileUtilities::CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
int nbPar=MEDnParameter(fid);
if(nbPar<1)
{
finishLoading(fid,paramType,nbOfSteps);
}
-MEDFileParameterMultiTS::MEDFileParameterMultiTS(const char *fileName, const char *paramName)
+MEDFileParameterMultiTS::MEDFileParameterMultiTS(const std::string& fileName, const std::string& paramName)
{
MEDFileUtilities::CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
int nbPar=MEDnParameter(fid);
std::ostringstream oss; oss << "MEDFileParameterDouble1TS : no double param name \"" << paramName << "\" ! Double Parameters available are : ";
INTERP_KERNEL::AutoPtr<char> pName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
return true;
}
-void MEDFileParameterMultiTS::write(const char *fileName, int mode) const
+void MEDFileParameterMultiTS::write(const std::string& fileName, int mode) const
{
med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod);
writeLL(fid,*this);
}
return new MEDFileParameters;
}
-MEDFileParameters *MEDFileParameters::New(const char *fileName)
+MEDFileParameters *MEDFileParameters::New(const std::string& fileName)
{
return new MEDFileParameters(fileName);
}
-MEDFileParameters::MEDFileParameters(const char *fileName)
+MEDFileParameters::MEDFileParameters(const std::string& fileName)
{
MEDFileUtilities::CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
int nbPar=MEDnParameter(fid);
_params.resize(nbPar);
INTERP_KERNEL::AutoPtr<char> pName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
int nbOfSteps;
MEDparameterInfo(fid,i+1,pName,¶mType,descName,unitName,&nbOfSteps);
std::string paramNameCpp=MEDLoaderBase::buildStringFromFortran(pName,MED_NAME_SIZE);
- _params[i]=MEDFileParameterMultiTS::New(fileName,paramNameCpp.c_str());
+ _params[i]=MEDFileParameterMultiTS::New(fileName,paramNameCpp);
}
}
}
}
-void MEDFileParameters::write(const char *fileName, int mode) const
+void MEDFileParameters::write(const std::string& fileName, int mode) const
{
med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod);
writeLL(fid);
}
/*!
* \return an internal pointer that can be null. Warning the caller is \b not responsible of the returned pointer.
*/
-MEDFileParameterMultiTS *MEDFileParameters::getParamWithName(const char *paramName) const
+MEDFileParameterMultiTS *MEDFileParameters::getParamWithName(const std::string& paramName) const
{
int pos=getPosFromParamName(paramName);
return getParamAtPos(pos);
_params[i]=MEDCouplingAutoRefCountObjectPtr<MEDFileParameterMultiTS>(0);
}
-int MEDFileParameters::getPosFromParamName(const char *paramName) const
+int MEDFileParameters::getPosFromParamName(const std::string& paramName) const
{
std::ostringstream oss; oss << "MEDFileParameters::getPosFromParamName : no such name=" << paramName << " ! Possibilities are :";
int ret=0;
class MEDFileParameterTinyInfo : public MEDFileWritable
{
public:
- MEDLOADER_EXPORT void setDescription(const char *name) { _desc_name=name; }
+ MEDLOADER_EXPORT void setDescription(const std::string& name) { _desc_name=name; }
MEDLOADER_EXPORT std::string getDescription() const { return _desc_name; }
- MEDLOADER_EXPORT void setTimeUnit(const char *unit) { _dt_unit=unit; }
+ MEDLOADER_EXPORT void setTimeUnit(const std::string& unit) { _dt_unit=unit; }
MEDLOADER_EXPORT std::string getTimeUnit() const { return _dt_unit; }
MEDLOADER_EXPORT std::size_t getHeapMemSizeOfStrings() const;
MEDLOADER_EXPORT bool isEqualStrings(const MEDFileParameterTinyInfo& other, std::string& what) const;
{
public:
MEDLOADER_EXPORT static MEDFileParameterDouble1TS *New();
- MEDLOADER_EXPORT static MEDFileParameterDouble1TS *New(const char *fileName);
- MEDLOADER_EXPORT static MEDFileParameterDouble1TS *New(const char *fileName, const char *paramName);
- MEDLOADER_EXPORT static MEDFileParameterDouble1TS *New(const char *fileName, const char *paramName, int dt, int it);
+ MEDLOADER_EXPORT static MEDFileParameterDouble1TS *New(const std::string& fileName);
+ MEDLOADER_EXPORT static MEDFileParameterDouble1TS *New(const std::string& fileName, const std::string& paramName);
+ MEDLOADER_EXPORT static MEDFileParameterDouble1TS *New(const std::string& fileName, const std::string& paramName, int dt, int it);
MEDLOADER_EXPORT virtual MEDFileParameter1TS *deepCpy() const;
MEDLOADER_EXPORT virtual bool isEqual(const MEDFileParameter1TS *other, double eps, std::string& what) const;
MEDLOADER_EXPORT virtual std::string simpleRepr() const;
MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildren() const;
- MEDLOADER_EXPORT void setName(const char *name) { _name=name; }
+ MEDLOADER_EXPORT void setName(const std::string& name) { _name=name; }
MEDLOADER_EXPORT std::string getName() const { return _name; }
- MEDLOADER_EXPORT void write(const char *fileName, int mode) const;
+ MEDLOADER_EXPORT void write(const std::string& fileName, int mode) const;
private:
MEDFileParameterDouble1TS();
- MEDFileParameterDouble1TS(const char *fileName);
- MEDFileParameterDouble1TS(const char *fileName, const char *paramName);
- MEDFileParameterDouble1TS(const char *fileName, const char *paramName, int dt, int it);
+ MEDFileParameterDouble1TS(const std::string& fileName);
+ MEDFileParameterDouble1TS(const std::string& fileName, const std::string& paramName);
+ MEDFileParameterDouble1TS(const std::string& fileName, const std::string& paramName, int dt, int it);
};
class MEDFileParameterMultiTS : public RefCountObject, public MEDFileParameterTinyInfo
{
public:
MEDLOADER_EXPORT static MEDFileParameterMultiTS *New();
- MEDLOADER_EXPORT static MEDFileParameterMultiTS *New(const char *fileName);
- MEDLOADER_EXPORT static MEDFileParameterMultiTS *New(const char *fileName, const char *paramName);
+ MEDLOADER_EXPORT static MEDFileParameterMultiTS *New(const std::string& fileName);
+ MEDLOADER_EXPORT static MEDFileParameterMultiTS *New(const std::string& fileName, const std::string& paramName);
MEDLOADER_EXPORT std::string getName() const { return _name; }
- MEDLOADER_EXPORT void setName(const char *name) { _name=name; }
+ MEDLOADER_EXPORT void setName(const std::string& name) { _name=name; }
MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildren() const;
MEDLOADER_EXPORT MEDFileParameterMultiTS *deepCpy() const;
MEDLOADER_EXPORT bool isEqual(const MEDFileParameterMultiTS *other, double eps, std::string& what) const;
- MEDLOADER_EXPORT void write(const char *fileName, int mode) const;
+ MEDLOADER_EXPORT void write(const std::string& fileName, int mode) const;
MEDLOADER_EXPORT void writeLL(med_idt fid, const MEDFileWritable& mw) const;
MEDLOADER_EXPORT std::string simpleRepr() const;
MEDLOADER_EXPORT void appendValue(int dt, int it, double time, double val);
protected:
MEDFileParameterMultiTS();
MEDFileParameterMultiTS(const MEDFileParameterMultiTS& other, bool deepCopy);
- MEDFileParameterMultiTS(const char *fileName);
- MEDFileParameterMultiTS(const char *fileName, const char *paramName);
+ MEDFileParameterMultiTS(const std::string& fileName);
+ MEDFileParameterMultiTS(const std::string& fileName, const std::string& paramName);
void finishLoading(med_idt fid, med_parameter_type typ, int nbOfSteps);
protected:
std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileParameter1TS> > _param_per_ts;
{
public:
MEDLOADER_EXPORT static MEDFileParameters *New();
- MEDLOADER_EXPORT static MEDFileParameters *New(const char *fileName);
+ MEDLOADER_EXPORT static MEDFileParameters *New(const std::string& fileName);
MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildren() const;
MEDLOADER_EXPORT MEDFileParameters *deepCpy() const;
MEDLOADER_EXPORT bool isEqual(const MEDFileParameters *other, double eps, std::string& what) const;
- MEDLOADER_EXPORT void write(const char *fileName, int mode) const;
+ MEDLOADER_EXPORT void write(const std::string& fileName, int mode) const;
MEDLOADER_EXPORT void writeLL(med_idt fid) const;
MEDLOADER_EXPORT std::vector<std::string> getParamsNames() const;
MEDLOADER_EXPORT std::string simpleRepr() const;
MEDLOADER_EXPORT void pushParam(MEDFileParameterMultiTS *param);
MEDLOADER_EXPORT void setParamAtPos(int i, MEDFileParameterMultiTS *param);
MEDLOADER_EXPORT MEDFileParameterMultiTS *getParamAtPos(int i) const;
- MEDLOADER_EXPORT MEDFileParameterMultiTS *getParamWithName(const char *paramName) const;
+ MEDLOADER_EXPORT MEDFileParameterMultiTS *getParamWithName(const std::string& paramName) const;
MEDLOADER_EXPORT void destroyParamAtPos(int i);
- MEDLOADER_EXPORT int getPosFromParamName(const char *paramName) const;
+ MEDLOADER_EXPORT int getPosFromParamName(const std::string& paramName) const;
MEDLOADER_EXPORT int getNumberOfParams() const;
protected:
void simpleRepr2(int bkOffset, std::ostream& oss) const;
- MEDFileParameters(const char *fileName);
+ MEDFileParameters(const std::string& fileName);
MEDFileParameters(const MEDFileParameters& other, bool deepCopy);
MEDFileParameters();
protected:
}
}
-void MEDFileUtilities::CheckMEDCode(int code, med_idt fid, const char *msg)
+void MEDFileUtilities::CheckMEDCode(int code, med_idt fid, const std::string& msg)
{
if(code<0)
{
}
}
-void MEDFileUtilities::CheckFileForRead(const char *fileName)
+void MEDFileUtilities::CheckFileForRead(const std::string& fileName)
{
int status=MEDLoaderBase::getStatusOfFile(fileName);
std::ostringstream oss;
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
}
- AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
if(fid<0)
{
oss << " has been detected as unreadable by MED file : impossible to read anything !";
{
med_access_mode TraduceWriteMode(int medloaderwritemode);
const char *GetReadableMEDFieldType(med_field_type ft);
- void CheckMEDCode(int code, med_idt fid, const char *msg);
- void CheckFileForRead(const char *fileName);
+ void CheckMEDCode(int code, med_idt fid, const std::string& msg);
+ void CheckFileForRead(const std::string& fileName);
class AutoFid
{
namespace MEDLoaderNS
{
- int readUMeshDimFromFile(const char *fileName, const char *meshName, std::vector<int>& possibilities);
+ int readUMeshDimFromFile(const std::string& fileName, const std::string& meshName, std::vector<int>& possibilities);
void dispatchElems(int nbOfElemCell, int nbOfElemFace, int& nbOfElem, med_entity_type& whichEntity);
- void writeFieldWithoutReadingAndMappingOfMeshInFile(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f, bool writeFromScratch);
- med_int getIdFromMeshName(med_idt fid, const char *meshName, std::string& trueMeshName) throw(INTERP_KERNEL::Exception);
+ void writeFieldWithoutReadingAndMappingOfMeshInFile(const std::string& fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f, bool writeFromScratch);
+ med_int getIdFromMeshName(med_idt fid, const std::string& meshName, std::string& trueMeshName) throw(INTERP_KERNEL::Exception);
std::vector<std::string> getMeshNamesFid(med_idt fid);
}
/// @cond INTERNAL
/*!
- * This method returns a first quick overview of mesh with name 'meshName' into the file 'fileName'.
+ * This method returns a first quick overview of mesh with name \a meshName into the file \a fileName.
* @param possibilities the relativeToMeshDim authorized to returned maxdim. This vector is systematically cleared at the begin of this method.
* @return the maximal mesh dimension of specified mesh. If nothing found -1 is returned.
*/
-int MEDLoaderNS::readUMeshDimFromFile(const char *fileName, const char *meshName, std::vector<int>& possibilities)
+int MEDLoaderNS::readUMeshDimFromFile(const std::string& fileName, const std::string& meshName, std::vector<int>& possibilities)
{
possibilities.clear();
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
int ret;
std::set<int> poss;
char nommaa[MED_NAME_SIZE+1];
return ret;
}
-med_int MEDLoaderNS::getIdFromMeshName(med_idt fid, const char *meshName, std::string& trueMeshName) throw(INTERP_KERNEL::Exception)
+med_int MEDLoaderNS::getIdFromMeshName(med_idt fid, const std::string& meshName, std::string& trueMeshName) throw(INTERP_KERNEL::Exception)
{
- if(meshName==0)
+ if(meshName.empty())
{
std::vector<std::string> meshes=getMeshNamesFid(fid);
if(meshes.empty())
* - the space dimension
* - the number of nodes
*/
-std::vector< std::vector< std::pair<INTERP_KERNEL::NormalizedCellType,int> > > MEDLoader::GetUMeshGlobalInfo(const char *fileName, const char *meshName, int &meshDim, int& spaceDim, int& numberOfNodes)
+std::vector< std::vector< std::pair<INTERP_KERNEL::NormalizedCellType,int> > > MEDLoader::GetUMeshGlobalInfo(const std::string& fileName, const std::string& meshName, int &meshDim, int& spaceDim, int& numberOfNodes)
{
CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
std::set<int> poss;
char nommaa[MED_NAME_SIZE+1];
char maillage_description[MED_COMMENT_SIZE+1];
return ret;
}
-void MEDLoader::CheckFileForRead(const char *fileName)
+void MEDLoader::CheckFileForRead(const std::string& fileName)
{
MEDFileUtilities::CheckFileForRead(fileName);
}
-std::vector<std::string> MEDLoader::GetMeshNames(const char *fileName)
+std::vector<std::string> MEDLoader::GetMeshNames(const std::string& fileName)
{
CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
std::vector<std::string> ret=MEDLoaderNS::getMeshNamesFid(fid);
return ret;
}
-std::vector< std::pair<std::string,std::string> > MEDLoader::GetComponentsNamesOfField(const char *fileName, const char *fieldName)
+std::vector< std::pair<std::string,std::string> > MEDLoader::GetComponentsNamesOfField(const std::string& fileName, const std::string& fieldName)
{
CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
med_int nbFields=MEDnField(fid);
std::vector<std::string> fields(nbFields);
med_field_type typcha;
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
-std::vector<std::string> MEDLoader::GetMeshNamesOnField(const char *fileName, const char *fieldName)
+std::vector<std::string> MEDLoader::GetMeshNamesOnField(const std::string& fileName, const std::string& fieldName)
{
CheckFileForRead(fileName);
std::vector<std::string> ret;
//
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
med_int nbFields=MEDnField(fid);
//
med_field_type typcha;
return ret;
}
-std::vector<std::string> MEDLoader::GetMeshFamiliesNames(const char *fileName, const char *meshName)
+std::vector<std::string> MEDLoader::GetMeshFamiliesNames(const std::string& fileName, const std::string& meshName)
{
CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
- med_int nfam=MEDnFamily(fid,meshName);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
+ med_int nfam=MEDnFamily(fid,meshName.c_str());
std::vector<std::string> ret(nfam);
char nomfam[MED_NAME_SIZE+1];
med_int numfam;
for(int i=0;i<nfam;i++)
{
- int ngro=MEDnFamilyGroup(fid,meshName,i+1);
- med_int natt=MEDnFamily23Attribute(fid,meshName,i+1);
+ int ngro=MEDnFamilyGroup(fid,meshName.c_str(),i+1);
+ med_int natt=MEDnFamily23Attribute(fid,meshName.c_str(),i+1);
INTERP_KERNEL::AutoPtr<med_int> attide=new med_int[natt];
INTERP_KERNEL::AutoPtr<med_int> attval=new med_int[natt];
INTERP_KERNEL::AutoPtr<char> attdes=new char[MED_COMMENT_SIZE*natt+1];
INTERP_KERNEL::AutoPtr<char> gro=new char[MED_LNAME_SIZE*ngro+1];
- MEDfamily23Info(fid,meshName,i+1,nomfam,attide,attval,attdes,&numfam,gro);
+ MEDfamily23Info(fid,meshName.c_str(),i+1,nomfam,attide,attval,attdes,&numfam,gro);
std::string cur=MEDLoaderBase::buildStringFromFortran(nomfam,sizeof(nomfam));
ret[i]=cur;
}
}
-std::vector<std::string> MEDLoader::GetMeshFamiliesNamesOnGroup(const char *fileName, const char *meshName, const char *grpName)
+std::vector<std::string> MEDLoader::GetMeshFamiliesNamesOnGroup(const std::string& fileName, const std::string& meshName, const std::string& grpName)
{
CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
- med_int nfam=MEDnFamily(fid,meshName);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
+ med_int nfam=MEDnFamily(fid,meshName.c_str());
std::vector<std::string> ret;
char nomfam[MED_NAME_SIZE+1];
med_int numfam;
for(int i=0;i<nfam;i++)
{
- int ngro=MEDnFamilyGroup(fid,meshName,i+1);
- med_int natt=MEDnFamily23Attribute(fid,meshName,i+1);
+ int ngro=MEDnFamilyGroup(fid,meshName.c_str(),i+1);
+ med_int natt=MEDnFamily23Attribute(fid,meshName.c_str(),i+1);
INTERP_KERNEL::AutoPtr<med_int> attide=new med_int[natt];
INTERP_KERNEL::AutoPtr<med_int> attval=new med_int[natt];
INTERP_KERNEL::AutoPtr<char> attdes=new char[MED_COMMENT_SIZE*natt+1];
INTERP_KERNEL::AutoPtr<char> gro=new char[MED_LNAME_SIZE*ngro+1];
- MEDfamily23Info(fid,meshName,i+1,nomfam,attide,attval,attdes,&numfam,gro);
+ MEDfamily23Info(fid,meshName.c_str(),i+1,nomfam,attide,attval,attdes,&numfam,gro);
std::string cur=MEDLoaderBase::buildStringFromFortran(nomfam,sizeof(nomfam));
for(int j=0;j<ngro;j++)
{
return ret;
}
-std::vector<std::string> MEDLoader::GetMeshGroupsNamesOnFamily(const char *fileName, const char *meshName, const char *famName)
+std::vector<std::string> MEDLoader::GetMeshGroupsNamesOnFamily(const std::string& fileName, const std::string& meshName, const std::string& famName)
{
CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
- med_int nfam=MEDnFamily(fid,meshName);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
+ med_int nfam=MEDnFamily(fid,meshName.c_str());
std::vector<std::string> ret;
char nomfam[MED_NAME_SIZE+1];
med_int numfam;
bool found=false;
for(int i=0;i<nfam && !found;i++)
{
- int ngro=MEDnFamilyGroup(fid,meshName,i+1);
- med_int natt=MEDnFamily23Attribute(fid,meshName,i+1);
+ int ngro=MEDnFamilyGroup(fid,meshName.c_str(),i+1);
+ med_int natt=MEDnFamily23Attribute(fid,meshName.c_str(),i+1);
INTERP_KERNEL::AutoPtr<med_int> attide=new med_int[natt];
INTERP_KERNEL::AutoPtr<med_int> attval=new med_int[natt];
INTERP_KERNEL::AutoPtr<char> attdes=new char[MED_COMMENT_SIZE*natt+1];
INTERP_KERNEL::AutoPtr<char> gro=new char[MED_LNAME_SIZE*ngro+1];
- MEDfamily23Info(fid,meshName,i+1,nomfam,attide,attval,attdes,&numfam,gro);
+ MEDfamily23Info(fid,meshName.c_str(),i+1,nomfam,attide,attval,attdes,&numfam,gro);
std::string cur=MEDLoaderBase::buildStringFromFortran(nomfam,sizeof(nomfam));
found=(cur==famName);
if(found)
}
-std::vector<std::string> MEDLoader::GetMeshGroupsNames(const char *fileName, const char *meshName)
+std::vector<std::string> MEDLoader::GetMeshGroupsNames(const std::string& fileName, const std::string& meshName)
{
CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
- med_int nfam=MEDnFamily(fid,meshName);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
+ med_int nfam=MEDnFamily(fid,meshName.c_str());
std::vector<std::string> ret;
char nomfam[MED_NAME_SIZE+1];
med_int numfam;
for(int i=0;i<nfam;i++)
{
- int ngro=MEDnFamilyGroup(fid,meshName,i+1);
- med_int natt=MEDnFamily23Attribute(fid,meshName,i+1);
+ int ngro=MEDnFamilyGroup(fid,meshName.c_str(),i+1);
+ med_int natt=MEDnFamily23Attribute(fid,meshName.c_str(),i+1);
INTERP_KERNEL::AutoPtr<med_int> attide=new med_int[natt];
INTERP_KERNEL::AutoPtr<med_int> attval=new med_int[natt];
INTERP_KERNEL::AutoPtr<char> attdes=new char[MED_COMMENT_SIZE*natt+1];
INTERP_KERNEL::AutoPtr<char> gro=new char[MED_LNAME_SIZE*ngro+1];
- MEDfamily23Info(fid,meshName,i+1,nomfam,attide,attval,attdes,&numfam,gro);
+ MEDfamily23Info(fid,meshName.c_str(),i+1,nomfam,attide,attval,attdes,&numfam,gro);
for(int j=0;j<ngro;j++)
{
std::string cur=MEDLoaderBase::buildStringFromFortran(gro+j*MED_LNAME_SIZE,MED_LNAME_SIZE);
}
return ret;
}
-std::vector<ParaMEDMEM::TypeOfField> MEDLoader::GetTypesOfField(const char *fileName, const char *meshName, const char *fieldName)
+std::vector<ParaMEDMEM::TypeOfField> MEDLoader::GetTypesOfField(const std::string& fileName, const std::string& meshName, const std::string& fieldName)
{
CheckFileForRead(fileName);
std::vector<ParaMEDMEM::TypeOfField> ret;
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
med_int nbFields=MEDnField(fid);
//
med_field_type typcha;
return ret;
}
-std::vector<std::string> MEDLoader::GetAllFieldNames(const char *fileName)
+std::vector<std::string> MEDLoader::GetAllFieldNames(const std::string& fileName)
{
CheckFileForRead(fileName);
std::vector<std::string> ret;
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
med_int nbFields=MEDnField(fid);
med_field_type typcha;
for(int i=0;i<nbFields;i++)
return ret;
}
-std::vector<std::string> MEDLoader::GetAllFieldNamesOnMesh(const char *fileName, const char *meshName)
+std::vector<std::string> MEDLoader::GetAllFieldNamesOnMesh(const std::string& fileName, const std::string& meshName)
{
CheckFileForRead(fileName);
std::vector<std::string> ret;
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
med_int nbFields=MEDnField(fid);
//
med_field_type typcha;
return ret;
}
-std::vector<std::string> MEDLoader::GetFieldNamesOnMesh(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName)
+std::vector<std::string> MEDLoader::GetFieldNamesOnMesh(ParaMEDMEM::TypeOfField type, const std::string& fileName, const std::string& meshName)
{
CheckFileForRead(fileName);
switch(type)
}
}
-std::vector<std::string> MEDLoader::GetCellFieldNamesOnMesh(const char *fileName, const char *meshName)
+std::vector<std::string> MEDLoader::GetCellFieldNamesOnMesh(const std::string& fileName, const std::string& meshName)
{
CheckFileForRead(fileName);
std::vector<std::string> ret;
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
med_int nbFields=MEDnField(fid);
//
med_field_type typcha;
return ret;
}
-std::vector<std::string> MEDLoader::GetNodeFieldNamesOnMesh(const char *fileName, const char *meshName)
+std::vector<std::string> MEDLoader::GetNodeFieldNamesOnMesh(const std::string& fileName, const std::string& meshName)
{
CheckFileForRead(fileName);
std::vector<std::string> ret;
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
med_int nbFields=MEDnField(fid);
char pflname[MED_NAME_SIZE+1]="";
char locname[MED_NAME_SIZE+1]="";
return ret;
}
-std::vector< std::pair< std::pair<int,int>, double> > MEDLoader::GetAllFieldIterations(const char *fileName, const char *fieldName)
+std::vector< std::pair< std::pair<int,int>, double> > MEDLoader::GetAllFieldIterations(const std::string& fileName, const std::string& fieldName)
{
CheckFileForRead(fileName);
std::vector< std::pair< std::pair<int,int>, double > > ret;
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
med_int nbFields=MEDnField(fid);
//
med_field_type typcha;
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
-double MEDLoader::GetTimeAttachedOnFieldIteration(const char *fileName, const char *fieldName, int iteration, int order)
+double MEDLoader::GetTimeAttachedOnFieldIteration(const std::string& fileName, const std::string& fieldName, int iteration, int order)
{
CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
med_int nbFields=MEDnField(fid);
//
med_field_type typcha;
return ret;
}
-std::vector< std::pair<int,int> > MEDLoader::GetFieldIterations(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName, const char *fieldName)
+std::vector< std::pair<int,int> > MEDLoader::GetFieldIterations(ParaMEDMEM::TypeOfField type, const std::string& fileName, const std::string& meshName, const std::string& fieldName)
{
CheckFileForRead(fileName);
switch(type)
}
}
-std::vector< std::pair<int,int> > MEDLoader::GetCellFieldIterations(const char *fileName, const char *meshName, const char *fieldName)
+std::vector< std::pair<int,int> > MEDLoader::GetCellFieldIterations(const std::string& fileName, const std::string& meshName, const std::string& fieldName)
{
CheckFileForRead(fileName);
std::string meshNameCpp(meshName);
std::vector< std::pair<int,int> > ret;
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
med_int nbFields=MEDnField(fid);
//
med_field_type typcha;
return ret;
}
-std::vector< std::pair<int,int> > MEDLoader::GetNodeFieldIterations(const char *fileName, const char *meshName, const char *fieldName)
+std::vector< std::pair<int,int> > MEDLoader::GetNodeFieldIterations(const std::string& fileName, const std::string& meshName, const std::string& fieldName)
{
CheckFileForRead(fileName);
std::string meshNameCpp(meshName);
std::vector< std::pair<int,int> > ret;
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
med_int nbFields=MEDnField(fid);
//
med_field_type typcha;
return ret;
}
-ParaMEDMEM::MEDCouplingMesh *MEDLoader::ReadMeshFromFile(const char *fileName, const char *meshName, int meshDimRelToMax)
+ParaMEDMEM::MEDCouplingMesh *MEDLoader::ReadMeshFromFile(const std::string& fileName, const std::string& meshName, int meshDimRelToMax)
{
CheckFileForRead(fileName);
MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm(MEDFileMesh::New(fileName,meshName));
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
-ParaMEDMEM::MEDCouplingMesh *MEDLoader::ReadMeshFromFile(const char *fileName, int meshDimRelToMax)
+ParaMEDMEM::MEDCouplingMesh *MEDLoader::ReadMeshFromFile(const std::string& fileName, int meshDimRelToMax)
{
CheckFileForRead(fileName);
MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm(MEDFileMesh::New(fileName));
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
-ParaMEDMEM::MEDCouplingUMesh *MEDLoader::ReadUMeshFromFile(const char *fileName, const char *meshName, int meshDimRelToMax)
+ParaMEDMEM::MEDCouplingUMesh *MEDLoader::ReadUMeshFromFile(const std::string& fileName, const std::string& meshName, int meshDimRelToMax)
{
CheckFileForRead(fileName);
MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm(MEDFileMesh::New(fileName,meshName));
return mmuPtr->getMeshAtLevel(meshDimRelToMax,true);
}
-ParaMEDMEM::MEDCouplingUMesh *MEDLoader::ReadUMeshFromFile(const char *fileName, int meshDimRelToMax)
+ParaMEDMEM::MEDCouplingUMesh *MEDLoader::ReadUMeshFromFile(const std::string& fileName, int meshDimRelToMax)
{
CheckFileForRead(fileName);
MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm(MEDFileMesh::New(fileName));
return mmuPtr->getMeshAtLevel(meshDimRelToMax,true);
}
-int MEDLoader::ReadUMeshDimFromFile(const char *fileName, const char *meshName)
+int MEDLoader::ReadUMeshDimFromFile(const std::string& fileName, const std::string& meshName)
{
CheckFileForRead(fileName);
std::vector<int> poss;
return MEDLoaderNS::readUMeshDimFromFile(fileName,meshName,poss);
}
-ParaMEDMEM::MEDCouplingUMesh *MEDLoader::ReadUMeshFromFamilies(const char *fileName, const char *meshName, int meshDimRelToMax, const std::vector<std::string>& fams)
+ParaMEDMEM::MEDCouplingUMesh *MEDLoader::ReadUMeshFromFamilies(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::vector<std::string>& fams)
{
CheckFileForRead(fileName);
MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm(MEDFileMesh::New(fileName,meshName));
return mmuPtr->getFamilies(meshDimRelToMax,fams,true);
}
-ParaMEDMEM::MEDCouplingUMesh *MEDLoader::ReadUMeshFromGroups(const char *fileName, const char *meshName, int meshDimRelToMax, const std::vector<std::string>& grps)
+ParaMEDMEM::MEDCouplingUMesh *MEDLoader::ReadUMeshFromGroups(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::vector<std::string>& grps)
{
CheckFileForRead(fileName);
MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm=MEDFileMesh::New(fileName,meshName);
return mmuPtr->getGroups(meshDimRelToMax,grps,true);
}
-ParaMEDMEM::MEDCouplingFieldDouble *MEDLoader::ReadField(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order)
+ParaMEDMEM::MEDCouplingFieldDouble *MEDLoader::ReadField(ParaMEDMEM::TypeOfField type, const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order)
{
CheckFileForRead(fileName);
switch(type)
}
}
-std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> MEDLoader::ReadFieldsOnSameMesh(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName,
+std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> MEDLoader::ReadFieldsOnSameMesh(ParaMEDMEM::TypeOfField type, const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName,
const std::vector<std::pair<int,int> >& its) throw(INTERP_KERNEL::Exception)
{
if(its.empty())
return ret;
}
-std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> MEDLoader::ReadFieldsCellOnSameMesh(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName,
+std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> MEDLoader::ReadFieldsCellOnSameMesh(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName,
const std::vector<std::pair<int,int> >& its) throw(INTERP_KERNEL::Exception)
{
return ReadFieldsOnSameMesh(ON_CELLS,fileName,meshName,meshDimRelToMax,fieldName,its);
}
-std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> MEDLoader::ReadFieldsNodeOnSameMesh(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName,
+std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> MEDLoader::ReadFieldsNodeOnSameMesh(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName,
const std::vector<std::pair<int,int> >& its) throw(INTERP_KERNEL::Exception)
{
return ReadFieldsOnSameMesh(ON_NODES,fileName,meshName,meshDimRelToMax,fieldName,its);
}
-std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> MEDLoader::ReadFieldsGaussOnSameMesh(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName,
+std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> MEDLoader::ReadFieldsGaussOnSameMesh(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName,
const std::vector<std::pair<int,int> >& its) throw(INTERP_KERNEL::Exception)
{
return ReadFieldsOnSameMesh(ON_GAUSS_PT,fileName,meshName,meshDimRelToMax,fieldName,its);
}
-std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> MEDLoader::ReadFieldsGaussNEOnSameMesh(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName,
+std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> MEDLoader::ReadFieldsGaussNEOnSameMesh(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName,
const std::vector<std::pair<int,int> >& its) throw(INTERP_KERNEL::Exception)
{
return ReadFieldsOnSameMesh(ON_GAUSS_NE,fileName,meshName,meshDimRelToMax,fieldName,its);
}
-ParaMEDMEM::MEDCouplingFieldDouble *MEDLoader::ReadFieldCell(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order)
+ParaMEDMEM::MEDCouplingFieldDouble *MEDLoader::ReadFieldCell(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order)
{
MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ff=MEDFileField1TS::New(fileName,fieldName,iteration,order);
MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm=MEDFileMesh::New(fileName,meshName);
return ret.retn();
}
-ParaMEDMEM::MEDCouplingFieldDouble *MEDLoader::ReadFieldNode(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order)
+ParaMEDMEM::MEDCouplingFieldDouble *MEDLoader::ReadFieldNode(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order)
{
MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ff=MEDFileField1TS::New(fileName,fieldName,iteration,order);
MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm=MEDFileMesh::New(fileName,meshName);
return ret.retn();
}
-ParaMEDMEM::MEDCouplingFieldDouble *MEDLoader::ReadFieldGauss(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order)
+ParaMEDMEM::MEDCouplingFieldDouble *MEDLoader::ReadFieldGauss(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order)
{
MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ff=MEDFileField1TS::New(fileName,fieldName,iteration,order);
MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm=MEDFileMesh::New(fileName,meshName);
return ret.retn();
}
-ParaMEDMEM::MEDCouplingFieldDouble *MEDLoader::ReadFieldGaussNE(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order)
+ParaMEDMEM::MEDCouplingFieldDouble *MEDLoader::ReadFieldGaussNE(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order)
{
MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ff=MEDFileField1TS::New(fileName,fieldName,iteration,order);
MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm=MEDFileMesh::New(fileName,meshName);
return ret.retn();
}
-void MEDLoader::WriteMesh(const char *fileName, const ParaMEDMEM::MEDCouplingMesh *mesh, bool writeFromScratch)
+void MEDLoader::WriteMesh(const std::string& fileName, const ParaMEDMEM::MEDCouplingMesh *mesh, bool writeFromScratch)
{
if(!mesh)
throw INTERP_KERNEL::Exception("MEDLoader::WriteMesh : input mesh is null !");
throw INTERP_KERNEL::Exception("MEDLoader::WriteMesh : only MEDCouplingUMesh, MEDCoupling1GTUMesh, MEDCouplingCMesh, MEDCouplingCurveLinear are dealed in this API for the moment !");
}
-void MEDLoader::WriteUMesh(const char *fileName, const ParaMEDMEM::MEDCouplingUMesh *mesh, bool writeFromScratch)
+void MEDLoader::WriteUMesh(const std::string& fileName, const ParaMEDMEM::MEDCouplingUMesh *mesh, bool writeFromScratch)
{
if(!mesh)
throw INTERP_KERNEL::Exception("MEDLoader::WriteUMesh : input mesh is null !");
m->write(fileName,mod);
}
-void MEDLoader::WriteUMeshDep(const char *fileName, const ParaMEDMEM::MEDCouplingUMesh *mesh, bool writeFromScratch)
+void MEDLoader::WriteUMeshDep(const std::string& fileName, const ParaMEDMEM::MEDCouplingUMesh *mesh, bool writeFromScratch)
{
MEDLoader::WriteUMesh(fileName,mesh,writeFromScratch);
}
-void MEDLoader::WriteUMeshesPartition(const char *fileName, const char *meshNameC, const std::vector<const ParaMEDMEM::MEDCouplingUMesh *>& meshes, bool writeFromScratch)
+void MEDLoader::WriteUMeshesPartition(const std::string& fileName, const std::string& meshNameC, const std::vector<const ParaMEDMEM::MEDCouplingUMesh *>& meshes, bool writeFromScratch)
{
std::string meshName(meshNameC);
if(meshName.empty())
m->write(fileName,mod);
}
-void MEDLoader::WriteUMeshesPartitionDep(const char *fileName, const char *meshNameC, const std::vector<const ParaMEDMEM::MEDCouplingUMesh *>& meshes, bool writeFromScratch)
+void MEDLoader::WriteUMeshesPartitionDep(const std::string& fileName, const std::string& meshNameC, const std::vector<const ParaMEDMEM::MEDCouplingUMesh *>& meshes, bool writeFromScratch)
{
WriteUMeshesPartition(fileName,meshNameC,meshes,writeFromScratch);
}
-void MEDLoader::WriteUMeshes(const char *fileName, const std::vector<const ParaMEDMEM::MEDCouplingUMesh *>& meshes, bool writeFromScratch)
+void MEDLoader::WriteUMeshes(const std::string& fileName, const std::vector<const ParaMEDMEM::MEDCouplingUMesh *>& meshes, bool writeFromScratch)
{
int mod=writeFromScratch?2:0;
MEDCouplingAutoRefCountObjectPtr<MEDFileUMesh> m(MEDFileUMesh::New());
m->write(fileName,mod);
}
-void MEDLoaderNS::writeFieldWithoutReadingAndMappingOfMeshInFile(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f, bool writeFromScratch)
+void MEDLoaderNS::writeFieldWithoutReadingAndMappingOfMeshInFile(const std::string& fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f, bool writeFromScratch)
{
MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ff(MEDFileField1TS::New());
MEDLoader::AssignStaticWritePropertiesTo(*ff);
ff->write(fileName,0);
}
-void MEDLoader::WriteField(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f, bool writeFromScratch)
+void MEDLoader::WriteField(const std::string& fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f, bool writeFromScratch)
{
if(!f)
throw INTERP_KERNEL::Exception("MEDLoader::WriteField : input field is NULL !");
}
}
-void MEDLoader::WriteFieldDep(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f, bool writeFromScratch)
+void MEDLoader::WriteFieldDep(const std::string& fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f, bool writeFromScratch)
{
WriteField(fileName,f,writeFromScratch);
}
-void MEDLoader::WriteFieldUsingAlreadyWrittenMesh(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f)
+void MEDLoader::WriteFieldUsingAlreadyWrittenMesh(const std::string& fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f)
{
if(!f)
throw INTERP_KERNEL::Exception("MEDLoader::WriteFieldUsingAlreadyWrittenMesh : input field is null !");
}
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 !");
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> o2n=m->getRenumArrForMEDFileFrmt();
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> f2(f->deepCpy());
- f2->renumberCells(o2n->begin(),false);
- f1ts->setFieldNoProfileSBT(f2);
+ MEDCouplingUMesh *m(dynamic_cast<MEDCouplingUMesh *>(const_cast<MEDCouplingMesh *>(f->getMesh())));
+ if(m)
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> o2n(m->getRenumArrForMEDFileFrmt());
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> f2(f->deepCpy());
+ f2->renumberCells(o2n->begin(),false);
+ f1ts->setFieldNoProfileSBT(f2);
+ }
+ else
+ f1ts->setFieldNoProfileSBT(f);
f1ts->write(fileName,0);
}
static bool HasXDR();
static std::string MEDFileVersionStr();
static void MEDFileVersion(int& major, int& minor, int& release);
- static void CheckFileForRead(const char *fileName);
- static std::vector<std::string> GetMeshNames(const char *fileName);
- static std::vector< std::vector< std::pair<INTERP_KERNEL::NormalizedCellType,int> > > GetUMeshGlobalInfo(const char *fileName, const char *meshName, int &meshDim, int& spaceDim, int& numberOfNodes);
- static std::vector< std::pair<std::string,std::string> > GetComponentsNamesOfField(const char *fileName, const char *fieldName);
- static std::vector<std::string> GetMeshNamesOnField(const char *fileName, const char *fieldName);
- static std::vector<std::string> GetMeshGroupsNames(const char *fileName, const char *meshName);
- static std::vector<std::string> GetMeshFamiliesNames(const char *fileName, const char *meshName);
- static std::vector<std::string> GetMeshFamiliesNamesOnGroup(const char *fileName, const char *meshName, const char *grpName);
- static std::vector<std::string> GetMeshGroupsNamesOnFamily(const char *fileName, const char *meshName, const char *famName);
- static std::vector<std::string> GetAllFieldNames(const char *fileName);
- static std::vector<std::string> GetAllFieldNamesOnMesh(const char *fileName, const char *meshName);
- static std::vector<ParaMEDMEM::TypeOfField> GetTypesOfField(const char *fileName, const char *meshName, const char *fieldName);
- static std::vector<std::string> GetFieldNamesOnMesh(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName);
- static std::vector<std::string> GetCellFieldNamesOnMesh(const char *fileName, const char *meshName);
- static std::vector<std::string> GetNodeFieldNamesOnMesh(const char *fileName, const char *meshName);
- static std::vector< std::pair<int,int> > GetFieldIterations(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName, const char *fieldName);
- static std::vector< std::pair<int,int> > GetCellFieldIterations(const char *fileName, const char *meshName, const char *fieldName);
- static std::vector< std::pair<int,int> > GetNodeFieldIterations(const char *fileName, const char *meshName, const char *fieldName);
- static std::vector< std::pair< std::pair<int,int>, double> > GetAllFieldIterations(const char *fileName, const char *fieldName);
- static double GetTimeAttachedOnFieldIteration(const char *fileName, const char *fieldName, int iteration, int order);
- static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFamilies(const char *fileName, const char *meshName, int meshDimRelToMax, const std::vector<std::string>& fams);
- static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromGroups(const char *fileName, const char *meshName, int meshDimRelToMax, const std::vector<std::string>& grps);
- static ParaMEDMEM::MEDCouplingMesh *ReadMeshFromFile(const char *fileName, const char *meshName, int meshDimRelToMax=0);
- static ParaMEDMEM::MEDCouplingMesh *ReadMeshFromFile(const char *fileName, int meshDimRelToMax=0);
- static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFile(const char *fileName, const char *meshName, int meshDimRelToMax=0);
- static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFile(const char *fileName, int meshDimRelToMax=0);
- static int ReadUMeshDimFromFile(const char *fileName, const char *meshName);
- static ParaMEDMEM::MEDCouplingFieldDouble *ReadField(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order);
- static std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> ReadFieldsOnSameMesh(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName,
+ static void CheckFileForRead(const std::string& fileName);
+ static std::vector<std::string> GetMeshNames(const std::string& fileName);
+ static std::vector< std::vector< std::pair<INTERP_KERNEL::NormalizedCellType,int> > > GetUMeshGlobalInfo(const std::string& fileName, const std::string& meshName, int &meshDim, int& spaceDim, int& numberOfNodes);
+ static std::vector< std::pair<std::string,std::string> > GetComponentsNamesOfField(const std::string& fileName, const std::string& fieldName);
+ static std::vector<std::string> GetMeshNamesOnField(const std::string& fileName, const std::string& fieldName);
+ static std::vector<std::string> GetMeshGroupsNames(const std::string& fileName, const std::string& meshName);
+ static std::vector<std::string> GetMeshFamiliesNames(const std::string& fileName, const std::string& meshName);
+ static std::vector<std::string> GetMeshFamiliesNamesOnGroup(const std::string& fileName, const std::string& meshName, const std::string& grpName);
+ static std::vector<std::string> GetMeshGroupsNamesOnFamily(const std::string& fileName, const std::string& meshName, const std::string& famName);
+ static std::vector<std::string> GetAllFieldNames(const std::string& fileName);
+ static std::vector<std::string> GetAllFieldNamesOnMesh(const std::string& fileName, const std::string& meshName);
+ static std::vector<ParaMEDMEM::TypeOfField> GetTypesOfField(const std::string& fileName, const std::string& meshName, const std::string& fieldName);
+ static std::vector<std::string> GetFieldNamesOnMesh(ParaMEDMEM::TypeOfField type, const std::string& fileName, const std::string& meshName);
+ static std::vector<std::string> GetCellFieldNamesOnMesh(const std::string& fileName, const std::string& meshName);
+ static std::vector<std::string> GetNodeFieldNamesOnMesh(const std::string& fileName, const std::string& meshName);
+ static std::vector< std::pair<int,int> > GetFieldIterations(ParaMEDMEM::TypeOfField type, const std::string& fileName, const std::string& meshName, const std::string& fieldName);
+ static std::vector< std::pair<int,int> > GetCellFieldIterations(const std::string& fileName, const std::string& meshName, const std::string& fieldName);
+ static std::vector< std::pair<int,int> > GetNodeFieldIterations(const std::string& fileName, const std::string& meshName, const std::string& fieldName);
+ static std::vector< std::pair< std::pair<int,int>, double> > GetAllFieldIterations(const std::string& fileName, const std::string& fieldName);
+ static double GetTimeAttachedOnFieldIteration(const std::string& fileName, const std::string& fieldName, int iteration, int order);
+ static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFamilies(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::vector<std::string>& fams);
+ static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromGroups(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::vector<std::string>& grps);
+ static ParaMEDMEM::MEDCouplingMesh *ReadMeshFromFile(const std::string& fileName, const std::string& meshName, int meshDimRelToMax=0);
+ static ParaMEDMEM::MEDCouplingMesh *ReadMeshFromFile(const std::string& fileName, int meshDimRelToMax=0);
+ static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFile(const std::string& fileName, const std::string& meshName, int meshDimRelToMax=0);
+ static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFile(const std::string& fileName, int meshDimRelToMax=0);
+ static int ReadUMeshDimFromFile(const std::string& fileName, const std::string& meshName);
+ static ParaMEDMEM::MEDCouplingFieldDouble *ReadField(ParaMEDMEM::TypeOfField type, const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order);
+ static std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> ReadFieldsOnSameMesh(ParaMEDMEM::TypeOfField type, const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName,
const std::vector<std::pair<int,int> >& its) throw(INTERP_KERNEL::Exception);
- static std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> ReadFieldsCellOnSameMesh(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName,
+ static std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> ReadFieldsCellOnSameMesh(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName,
const std::vector<std::pair<int,int> >& its) throw(INTERP_KERNEL::Exception);
- static std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> ReadFieldsNodeOnSameMesh(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName,
+ static std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> ReadFieldsNodeOnSameMesh(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName,
const std::vector<std::pair<int,int> >& its) throw(INTERP_KERNEL::Exception);
- static std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> ReadFieldsGaussOnSameMesh(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName,
+ static std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> ReadFieldsGaussOnSameMesh(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName,
const std::vector<std::pair<int,int> >& its) throw(INTERP_KERNEL::Exception);
- static std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> ReadFieldsGaussNEOnSameMesh(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName,
+ static std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> ReadFieldsGaussNEOnSameMesh(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName,
const std::vector<std::pair<int,int> >& its) throw(INTERP_KERNEL::Exception);
- static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldCell(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order);
- static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldNode(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order);
- static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldGauss(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order);
- static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldGaussNE(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order);
- static void WriteMesh(const char *fileName, const ParaMEDMEM::MEDCouplingMesh *mesh, bool writeFromScratch);
- static void WriteUMesh(const char *fileName, const ParaMEDMEM::MEDCouplingUMesh *mesh, bool writeFromScratch);
- static void WriteUMeshDep(const char *fileName, const ParaMEDMEM::MEDCouplingUMesh *mesh, bool writeFromScratch);
- static void WriteUMeshesPartition(const char *fileName, const char *meshName, const std::vector<const ParaMEDMEM::MEDCouplingUMesh *>& meshes, bool writeFromScratch);
- static void WriteUMeshesPartitionDep(const char *fileName, const char *meshName, const std::vector<const ParaMEDMEM::MEDCouplingUMesh *>& meshes, bool writeFromScratch);
- static void WriteUMeshes(const char *fileName, const std::vector<const ParaMEDMEM::MEDCouplingUMesh *>& meshes, bool writeFromScratch);
- 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);
+ static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldCell(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order);
+ static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldNode(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order);
+ static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldGauss(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order);
+ static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldGaussNE(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order);
+ static void WriteMesh(const std::string& fileName, const ParaMEDMEM::MEDCouplingMesh *mesh, bool writeFromScratch);
+ static void WriteUMesh(const std::string& fileName, const ParaMEDMEM::MEDCouplingUMesh *mesh, bool writeFromScratch);
+ static void WriteUMeshDep(const std::string& fileName, const ParaMEDMEM::MEDCouplingUMesh *mesh, bool writeFromScratch);
+ static void WriteUMeshesPartition(const std::string& fileName, const std::string& meshName, const std::vector<const ParaMEDMEM::MEDCouplingUMesh *>& meshes, bool writeFromScratch);
+ static void WriteUMeshesPartitionDep(const std::string& fileName, const std::string& meshName, const std::vector<const ParaMEDMEM::MEDCouplingUMesh *>& meshes, bool writeFromScratch);
+ static void WriteUMeshes(const std::string& fileName, const std::vector<const ParaMEDMEM::MEDCouplingUMesh *>& meshes, bool writeFromScratch);
+ static void WriteField(const std::string& fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f, bool writeFromScratch);
+ static void WriteFieldDep(const std::string& fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f, bool writeFromScratch);
+ static void WriteFieldUsingAlreadyWrittenMesh(const std::string& fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f);
public:
static void AssignStaticWritePropertiesTo(ParaMEDMEM::MEDFileWritable& obj);
private:
const char MEDLoaderBase::WHITE_SPACES[]=" \n";
-int MEDLoaderBase::getStatusOfFile(const char *fileName)
+int MEDLoaderBase::getStatusOfFile(const std::string& fileName)
{
std::ifstream ifs;
- ifs.open(fileName);
+ ifs.open(fileName.c_str());
if((ifs.rdstate() & std::ifstream::failbit)!=0)
{
ifs.close();
return NOT_EXIST;
}
- std::ofstream ofs(fileName,std::ios_base::app);
+ std::ofstream ofs(fileName.c_str(),std::ios_base::app);
if((ofs.rdstate() & std::ofstream::failbit)!=0)
{
return EXIST_RDONLY;
* This method given the target size to respect 'sizeToRespect' tries to reduce size of 'src' string.
* This method uses several soft methods to do its job. But if it fails a simple cut of string will be performed.
*/
-std::string MEDLoaderBase::zipString(const char *src, int sizeToRespect)
+std::string MEDLoaderBase::zipString(const std::string& src, int sizeToRespect)
{
std::string s(src);
strip(s);
class MEDLOADER_EXPORT MEDLoaderBase
{
public:
- static int getStatusOfFile(const char *fileName);
+ static int getStatusOfFile(const std::string& fileName);
static char *buildEmptyString(int lgth);
static void getDirAndBaseName(const std::string& fullName, std::string& dirName, std::string& baseName);
static std::string getPathSep();
static void safeStrCpy2(const char *src, int maxLgth, char *dest, int behaviour);
static std::string buildStringFromFortran(const char *expr, int lgth);
static void zipEqualConsChar(std::string& s, int minConsSmChar);
- static std::string zipString(const char *src, int sizeToRespect);
+ static std::string zipString(const std::string& src, int sizeToRespect);
public:
static const int EXIST_RW=0;
static const int NOT_EXIST=1;
THROW_IK_EXCEPTION("Nodes and coordinates mismatch");
}
+//================================================================================
+/*!
+ * \brief Safely adds a new Group
+ */
+//================================================================================
+
+Group* IntermediateMED::addNewGroup(std::vector<SauvUtilities::Group*>* groupsToFix)
+{
+ if ( _groups.size() == _groups.capacity() ) // re-allocation would occure
+ {
+ std::vector<Group> newGroups( _groups.size() );
+ newGroups.push_back( Group() );
+
+ for ( size_t i = 0; i < _groups.size(); ++i )
+ {
+ // avoid copying _cells
+ std::vector<const Cell*> cells;
+ cells.swap( _groups[i]._cells );
+ newGroups[i] = _groups[i];
+ newGroups[i]._cells.swap( cells );
+
+ // correct pointers to sub-groups
+ for ( size_t j = 0; j < _groups[i]._groups.size(); ++j )
+ {
+ int iG = _groups[i]._groups[j] - &_groups[0];
+ newGroups[i]._groups[j] = & newGroups[ iG ];
+ }
+ }
+
+ // fix given groups
+ if ( groupsToFix )
+ for ( size_t i = 0; i < groupsToFix->size(); ++i )
+ if ( (*groupsToFix)[i] )
+ {
+ int iG = (*groupsToFix)[i] - &_groups[0];
+ (*groupsToFix)[i] = & newGroups[ iG ];
+ }
+
+ // fix field supports
+ for ( int isNode = 0; isNode < 2; ++isNode )
+ {
+ std::vector<DoubleField* >& fields = isNode ? _nodeFields : _cellFields;
+ for ( size_t i = 0; i < fields.size(); ++i )
+ {
+ if ( !fields[i] ) continue;
+ for ( size_t j = 0; j < fields[i]->_sub.size(); ++j )
+ if ( fields[i]->_sub[j]._support )
+ {
+ int iG = fields[i]->_sub[j]._support - &_groups[0];
+ fields[i]->_sub[j]._support = & newGroups[ iG ];
+ }
+ if ( fields[i]->_group )
+ {
+ int iG = fields[i]->_group - &_groups[0];
+ fields[i]->_group = & newGroups[ iG ];
+ }
+ }
+ }
+
+ _groups.swap( newGroups );
+ }
+ else
+ {
+ _groups.push_back( Group() );
+ }
+ return &_groups.back();
+}
+
//================================================================================
/*!
* \brief Makes ParaMEDMEM::MEDFileData from self
std::string _name;
std::vector<const Cell*> _cells;
std::vector< Group* > _groups; // des sous-groupes composant le Group
- //bool _isShared; // true if any Cell was added to the mesh from other Group
bool _isProfile; // is a field support or not
std::vector<std::string> _refNames; /* names of groups referring this one;
_refNames is resized according to nb of references
Node* getNode( TID nID ) { return _points.getNode( nID ); }
int getNbCellsOfType( TCellType type ) const { return _cellsByType[type].size(); }
const Cell* insert(TCellType type, const Cell& ma) { return &( *_cellsByType[type].insert( ma ).first ); }
+ Group* addNewGroup(std::vector<SauvUtilities::Group*>* groupsToFix=0);
ParaMEDMEM::MEDFileData* convertInMEDFileDS();
private:
*/
//================================================================================
-SauvReader* SauvReader::New(const char *fileName)
+SauvReader* SauvReader::New(const std::string& fileName)
{
- if ( !fileName || strlen(fileName) < 1 ) THROW_IK_EXCEPTION("Invalid file name");
+ if ( fileName.empty() ) THROW_IK_EXCEPTION("Invalid file name");
ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr< SauvUtilities::FileReader> parser;
// try to open as XRD
- parser = new XDRReader( fileName );
+ parser = new XDRReader( fileName.c_str() );
if ( parser->open() )
{
SauvReader* reader = new SauvReader;
}
// try to open as ASCII
- parser = new ASCIIReader( fileName );
+ parser = new ASCIIReader( fileName.c_str() );
if ( parser->open() )
{
SauvReader* reader = new SauvReader;
SauvUtilities::Group & grp = _iMed->_groups[ grpID-1 ];
if ( !grp._name.empty() ) // a group has several names
{ // create a group with subgroup grp and named grp.name
- _iMed->_groups.push_back(Group());
- _iMed->_groups.back()._groups.push_back( &_iMed->_groups[ grpID-1 ]);
- _iMed->_groups.back()._name = grp._name;
+ SauvUtilities::Group* newGroup = _iMed->addNewGroup();
+ newGroup->_groups.push_back( &_iMed->_groups[ grpID-1 ]);
+ newGroup->_name = grp._name;
}
grp._name=objectNames[i];
#ifdef _DEBUG
sameOrder = ( supports[j] == newGroups[ j % newGroups.size() ]);
if ( sameOrder )
{
- _iMed->_groups.push_back( SauvUtilities::Group() );
- group = & _iMed->_groups.back();
+ group = _iMed->addNewGroup( & newGroups );
group->_groups.swap( newGroups );
}
}
class SauvReader : public ParaMEDMEM::RefCountObject
{
public:
- MEDLOADER_EXPORT static SauvReader* New(const char *fileName);
+ MEDLOADER_EXPORT static SauvReader* New(const std::string& fileName);
MEDLOADER_EXPORT ParaMEDMEM::MEDFileData * loadInMEDFileDS();
MEDLOADER_EXPORT ~SauvReader();
*/
//================================================================================
-void SauvWriter::write(const char* fileName)
+void SauvWriter::write(const std::string& fileName)
{
std::fstream fileStream;
- fileStream.open( fileName, ios::out);
+ fileStream.open( fileName.c_str(), ios::out);
if
#ifdef WIN32
( !fileStream || !fileStream.is_open() )
public:
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 write(const std::string& fileName);
MEDLOADER_EXPORT void setCpyGrpIfOnASingleFamilyStatus(bool status);
MEDLOADER_EXPORT bool getCpyGrpIfOnASingleFamilyStatus() const;
private:
#
# Author Anthony GEAY (CEA/DEN/DM2S/STMF/LGLS)
+# http://www-vis.lbl.gov/NERSC/Software/ensight/doc/OnlineHelp/UM-C11.pdf
import numpy as np
from MEDLoader import *
from CaseIO import CaseIO
cI=DataArrayInt(len(cells)+1) ; cI.iota() ; cI*=nbNodesPerCell+1
#
cells2=cells.reshape(len(cells),nbNodesPerCell)
- c2=DataArrayInt(cells2)
+ if cells2.dtype=='int32':
+ c2=DataArrayInt(cells2)
+ else:
+ c2=DataArrayInt(np.array(cells2,dtype="int32"))
+ pass
c=DataArrayInt(len(cells),nbNodesPerCell+1) ; c[:,0]=ct ; c[:,1:]=c2-1 ; c.rearrange(1)
m.setConnectivity(c,cI,True)
m.checkCoherency2()
def __convertGeo2MED(self,geoFileName):
""" Convert all the geometry (all the meshes) contained in teh CASE file into MEDCouplingUMesh'es. """
- fd=open(os.path.join(self._dirName,geoFileName),"r+b") ; fd.seek(0,2) ; end=fd.tell() ; fd.seek(0) ; fd.readline() ; fd.readline()
+ fd=open(os.path.join(self._dirName,geoFileName),"r+b") ; fd.seek(0,2) ; end=fd.tell() ; fd.seek(0) ; title=fd.read(80)
+ title=title.strip().lower()
+ if "binary" not in title:
+ raise Exception("Error only binary geo files are supported for the moment !")
+ pass
+ zeType=True
+ if "fortran" in title:
+ mcmeshes=self.__convertGeo2MEDFortran(fd,end) ; zeType=False
+ else:
+ mcmeshes=self.__convertGeo2MEDC(fd,end)
+ #
+ ms=MEDFileMeshes()
+ ms.resize(len(mcmeshes))
+ for i,m in enumerate(mcmeshes):
+ mlm=MEDFileUMesh()
+ mlm.setMeshAtLevel(0,m)
+ ms.setMeshAtPos(i,mlm)
+ pass
+ return mcmeshes,ms,zeType
+
+ def __convertGeo2MEDFortran(self,fd,end):
+ mcmeshes=[]
+ fd.read(80) # comment 1
+ fd.read(80) # comment 2
+ fd.read(80) # node id
+ fd.read(80) # element id
+ pos=fd.tell()
+ elt=fd.read(80) ; elt=elt.strip() ; pos=fd.tell()
+ mcmeshes2=[]
+ typ="part"
+ nbOfTurn=0
+ while abs(pos-end)>8 and "part" in typ:
+ if "part" not in elt:
+ raise Exception("Error on reading mesh fortran #1 !")
+ fd.seek(fd.tell()+4)# skip #
+ tmp=fd.read(80) ; meshName=tmp.split("P")[-1]
+ tmp=fd.read(80)
+ if "coordinates" not in tmp:
+ raise Exception("Error on reading mesh fortran #2 !")
+ pos=fd.tell() # 644
+ if nbOfTurn==0:
+ pos+=76 # what else ?
+ else:
+ pos+=40
+ pass
+ nbNodes=np.memmap(fd,dtype='>i4',mode='r',offset=int(pos),shape=(1,)).tolist()[0]
+ pos+=12 # what else ?
+ a=np.memmap(fd,dtype='>f4',mode='r',offset=int(pos),shape=(nbNodes))
+ b=np.memmap(fd,dtype='>f4',mode='r',offset=int(pos+nbNodes*4+2*4),shape=(nbNodes))
+ c=np.memmap(fd,dtype='>f4',mode='r',offset=int(pos+nbNodes*2*4+4*4),shape=(nbNodes))
+ coo=np.zeros(dtype=">f4",shape=(nbNodes*3))
+ coo[:nbNodes]=a ; coo[nbNodes:2*nbNodes]=b ; coo[2*nbNodes:]=c
+ coo=coo.reshape(nbNodes,3)
+ pos+=nbNodes*3*4 ; fd.seek(pos)#np.array(0,dtype='float%i'%(typeOfCoo)).nbytes
+ typ=fd.read(80).strip() ; pos=fd.tell()
+ zeK=""
+ for k in self.dictMCTyp2.keys():
+ if k in typ:
+ zeK=k
+ break
+ pass
+ pass
+ pos+=8*4 # yeh man !
+ nbCellsOfType=np.memmap(fd,dtype='>i4',mode='r',offset=int(pos),shape=(1,)).tolist()[0]
+ pos+=4 # for the number of cells
+ pos+=2*4 # because it's great !
+ nbNodesPerCell=MEDCouplingMesh.GetNumberOfNodesOfGeometricType(self.dictMCTyp2[zeK])
+ nodalConn=np.memmap(fd,dtype='>i4',mode='r',offset=pos,shape=(nbCellsOfType,nbNodesPerCell))
+ meshName=meshName.strip()
+ mcmeshes2.append(self.__traduceMesh(meshName,zeK,coo,nodalConn))
+ pos+=nbNodesPerCell*nbCellsOfType*4
+ if abs(pos-end)>8:
+ fd.seek(pos) ;elt=fd.read(80) ; typ=elt[:] ; pos+=80
+ pass
+ nbOfTurn+=1
+ pass
+ #coo=mcmeshes2[0].getCoords() ; name=mcmeshes2[0].getName()
+ #for itmesh in mcmeshes2: itmesh.setCoords(coo)
+ #m=MEDCouplingUMesh.MergeUMeshesOnSameCoords(mcmeshes2) ; m.setName(name)
+ #mcmeshes.append(m)
+ return mcmeshes2
+
+ def __convertGeo2MEDC(self,fd,end):
+ fd.readline()
name=fd.readline().strip() ; fd.readline() ; fd.readline()
pos=fd.tell()
mcmeshes=[]
elt=fd.read(80) ; elt=elt.strip() ; pos+=80
while pos!=end:
- if elt!="part":
+ if "part" not in elt:
raise Exception("Error on reading mesh #1 !")
fd.seek(fd.tell()+4)
meshName=fd.read(80).strip()
m=MEDCouplingUMesh.MergeUMeshesOnSameCoords(mcmeshes2) ; m.setName(name)
mcmeshes.append(m)
pass
- #
- ms=MEDFileMeshes()
- ms.resize(len(mcmeshes))
- for i,m in enumerate(mcmeshes):
- mlm=MEDFileUMesh()
- mlm.setMeshAtLevel(0,m)
- ms.setMeshAtPos(i,mlm)
- pass
- return mcmeshes,ms
+ return mcmeshes
+
def __convertField(self,mlfields, mcmeshes, fileName, fieldName, discr, nbCompo, locId, it):
""" Convert the fields. """
f.checkCoherency()
mlfields[locId+meshId].appendFieldNoProfileSBT(f)
pass
+
+ def __convertFieldFortran(self,mlfields, mcmeshes, fileName, fieldName, discr, nbCompo, locId, it):
+ """ Convert the fields. """
+ if re.search("[\*]+",fileName):
+ stars=re.search("[\*]+",fileName).group()
+ st="%0"+str(len(stars))+"i"
+ trueFileName=fileName.replace(stars,st%(it))
+ pass
+ else:
+ trueFileName=fileName
+ pass
+ fd=open(os.path.join(self._dirName,trueFileName),"r+b") ; fd.seek(0,2) ; end=fd.tell() ; fd.seek(0)
+ name=fd.read(80)
+ if fieldName not in name:
+ raise Exception("ConvertField : mismatch")
+ pos=fd.tell()
+ st=fd.read(80) ; st=st.strip() ; pos=fd.tell()
+ if "part" not in st:
+ raise Exception("ConvertField : mismatch #2")
+ st=fd.read(80).strip() ; pos=fd.tell()
+ pos+=12 # I love it
+ offset=0
+ nbTurn=0
+ while pos!=end and "part" not in st:
+ fdisc=MEDCouplingFieldDiscretization.New(self.discSpatial2[discr])
+ nbOfValues=fdisc.getNumberOfTuples(mcmeshes[nbTurn])
+ vals2=DataArrayDouble(nbOfValues,nbCompo)
+ pos+=24 # I love it again !
+ nbOfValsOfTyp=np.memmap(fd,dtype='>i4',mode='r',offset=pos,shape=(1)).tolist()[0]/4
+ pos+=4
+ vals=np.zeros(dtype=">f4",shape=(nbOfValsOfTyp*nbCompo))
+ for iii in xrange(nbCompo):
+ valsTmp=np.memmap(fd,dtype='>f4',mode='r',offset=int(pos),shape=(nbOfValsOfTyp))
+ vals[iii*nbOfValsOfTyp:(iii+1)*nbOfValsOfTyp]=valsTmp
+ pos+=nbOfValsOfTyp*4
+ pos+=2*4 ## hey hey, that is the ultimate class !
+ vals2.setInfoOnComponent(iii,chr(ord('X')+iii))
+ pass
+ if pos>end:
+ pos=end
+ pass
+ vals=vals.reshape(nbOfValsOfTyp,nbCompo)
+ vals2[offset:offset+nbOfValsOfTyp]=DataArrayDouble(np.array(vals,dtype='float64')).fromNoInterlace()
+ if pos!=end:
+ fd.seek(pos)
+ st=fd.read(80) ; st=st.strip() ; pos=fd.tell()
+ st=fd.read(80) ; st=st.strip() ; pos=fd.tell()
+ pass
+ f=MEDCouplingFieldDouble(self.discSpatial2[discr],ONE_TIME) ; f.setName("%s_%s"%(fieldName,mcmeshes[nbTurn].getName()))
+ f.setMesh(mcmeshes[nbTurn]) ; f.setArray(vals2) ; f.setTime(float(it),it,-1)
+ f.checkCoherency()
+ mlfields[locId+nbTurn].appendFieldNoProfileSBT(f)
+ nbTurn+=1
+ pass
pass
def loadInMEDFileDS(self):
if ind==-1:
raise Exception("Error with file %s"%(fname))
geoName=re.match("model:([\W]*)([\w\.]+)",lines[ind+1]).group(2)
- m1,m2=self.__convertGeo2MED(geoName)
- ind=lines.index("VARIABLE\n")
+ m1,m2,typeOfFile=self.__convertGeo2MED(geoName)
fieldsInfo=[]
- for i in xrange(ind+1,lines.index("TIME\n")):
+ ind=lines.index("VARIABLE\n")
+ end=len(lines)-1
+ if "TIME\n" in lines:
+ end=lines.index("TIME\n")
+ pass
+ for i in xrange(ind+1,end):
m=re.match("^([\w]+)[\s]+\per[\s]+([\w]+)[\s]*\:[\s]*([\w]+)[\s]+([\S]+)$",lines[i])
if m:
+ if m.groups()[0]=="constant":
+ continue
spatialDisc=m.groups()[1] ; fieldName=m.groups()[2] ; nbOfCompo=self.dictCompo2[m.groups()[0]] ; fieldFileName=m.groups()[3]
fieldsInfo.append((fieldName,spatialDisc,nbOfCompo,fieldFileName))
pass
pass
expr=re.compile("number[\s]+of[\s]+steps[\s]*\:[\s]*([\d]+)")
- nbOfTimeSteps=int(expr.search(filter(expr.search,lines)[0]).group(1))
-
- expr=re.compile("filename[\s]+start[\s]+number[\s]*\:[\s]*([\d]+)")
- startIt=int(expr.search(filter(expr.search,lines)[0]).group(1))
-
- expr=re.compile("filename[\s]+increment[\s]*\:[\s]*([\d]+)")
- incrIt=int(expr.search(filter(expr.search,lines)[0]).group(1))
-
+ tmp=filter(expr.search,lines)
+ if len(tmp)!=0:
+ nbOfTimeSteps=int(expr.search(filter(expr.search,lines)[0]).group(1))
+ expr=re.compile("filename[\s]+start[\s]+number[\s]*\:[\s]*([\d]+)")
+ startIt=int(expr.search(filter(expr.search,lines)[0]).group(1))
+ expr=re.compile("filename[\s]+increment[\s]*\:[\s]*([\d]+)")
+ incrIt=int(expr.search(filter(expr.search,lines)[0]).group(1))
+ else:
+ nbOfTimeSteps=1
+ startIt=0
+ incrIt=1
+ pass
curIt=startIt
mlfields=MEDFileFields()
mlfields.resize(len(fieldsInfo)*len(m1))
for ts in xrange(nbOfTimeSteps):
i=0
for field in fieldsInfo:
- self.__convertField(mlfields,m1,field[3],field[0],field[1],field[2],i,curIt)
+ if typeOfFile:
+ self.__convertField(mlfields,m1,field[3],field[0],field[1],field[2],i,curIt);
+ else:
+ self.__convertFieldFortran(mlfields,m1,field[3],field[0],field[1],field[2],i,curIt)
+ pass
i+=len(m1)
pass
curIt+=incrIt
static void SetEpsilonForNodeComp(double val) throw(INTERP_KERNEL::Exception);
static void SetCompPolicyForCell(int val) throw(INTERP_KERNEL::Exception);
static void SetTooLongStrPolicy(int val) throw(INTERP_KERNEL::Exception);
- static void CheckFileForRead(const char *fileName) throw(INTERP_KERNEL::Exception);
- static std::vector<std::string> GetMeshNames(const char *fileName) throw(INTERP_KERNEL::Exception);
- static std::vector<std::string> GetMeshNamesOnField(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception);
- static std::vector<std::string> GetMeshGroupsNames(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
- static std::vector<std::string> GetMeshFamiliesNames(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
- static std::vector<std::string> GetMeshFamiliesNamesOnGroup(const char *fileName, const char *meshName, const char *grpName) throw(INTERP_KERNEL::Exception);
- static std::vector<std::string> GetMeshGroupsNamesOnFamily(const char *fileName, const char *meshName, const char *famName) throw(INTERP_KERNEL::Exception);
- static std::vector<std::string> GetAllFieldNamesOnMesh(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
- static std::vector<std::string> GetAllFieldNames(const char *fileName) throw(INTERP_KERNEL::Exception);
- static std::vector<std::string> GetFieldNamesOnMesh(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
- 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 CheckFileForRead(const std::string& fileName) throw(INTERP_KERNEL::Exception);
+ static std::vector<std::string> GetMeshNames(const std::string& fileName) throw(INTERP_KERNEL::Exception);
+ static std::vector<std::string> GetMeshNamesOnField(const std::string& fileName, const std::string& fieldName) throw(INTERP_KERNEL::Exception);
+ static std::vector<std::string> GetMeshGroupsNames(const std::string& fileName, const std::string& meshName) throw(INTERP_KERNEL::Exception);
+ static std::vector<std::string> GetMeshFamiliesNames(const std::string& fileName, const std::string& meshName) throw(INTERP_KERNEL::Exception);
+ static std::vector<std::string> GetMeshFamiliesNamesOnGroup(const std::string& fileName, const std::string& meshName, const std::string& grpName) throw(INTERP_KERNEL::Exception);
+ static std::vector<std::string> GetMeshGroupsNamesOnFamily(const std::string& fileName, const std::string& meshName, const std::string& famName) throw(INTERP_KERNEL::Exception);
+ static std::vector<std::string> GetAllFieldNamesOnMesh(const std::string& fileName, const std::string& meshName) throw(INTERP_KERNEL::Exception);
+ static std::vector<std::string> GetAllFieldNames(const std::string& fileName) throw(INTERP_KERNEL::Exception);
+ static std::vector<std::string> GetFieldNamesOnMesh(ParaMEDMEM::TypeOfField type, const std::string& fileName, const std::string& meshName) throw(INTERP_KERNEL::Exception);
+ static std::vector<std::string> GetCellFieldNamesOnMesh(const std::string& fileName, const std::string& meshName) throw(INTERP_KERNEL::Exception);
+ static std::vector<std::string> GetNodeFieldNamesOnMesh(const std::string& fileName, const std::string& meshName) throw(INTERP_KERNEL::Exception);
+ static double GetTimeAttachedOnFieldIteration(const std::string& fileName, const std::string& fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
static void AssignStaticWritePropertiesTo(ParaMEDMEM::MEDFileWritable& obj) throw(INTERP_KERNEL::Exception);
%extend
{
return ret;
}
- static PyObject *GetFieldIterations(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName, const char *fieldName) throw(INTERP_KERNEL::Exception)
+ static PyObject *GetFieldIterations(ParaMEDMEM::TypeOfField type, const std::string& fileName, const std::string& meshName, const std::string& fieldName) throw(INTERP_KERNEL::Exception)
{
std::vector< std::pair<int,int> > res=MEDLoader::GetFieldIterations(type,fileName,meshName,fieldName);
PyObject *ret=PyList_New(res.size());
return ret;
}
- static PyObject *GetAllFieldIterations(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
+ static PyObject *GetAllFieldIterations(const std::string& fileName, const std::string& fieldName) throw(INTERP_KERNEL::Exception)
{
std::vector< std::pair< std::pair<int,int>, double> > res=MEDLoader::GetAllFieldIterations(fileName,fieldName);
PyObject *ret=PyList_New(res.size());
return ret;
}
- static PyObject *GetCellFieldIterations(const char *fileName, const char *meshName, const char *fieldName) throw(INTERP_KERNEL::Exception)
+ static PyObject *GetCellFieldIterations(const std::string& fileName, const std::string& meshName, const std::string& fieldName) throw(INTERP_KERNEL::Exception)
{
std::vector< std::pair<int,int> > res=MEDLoader::GetCellFieldIterations(fileName,meshName,fieldName);
PyObject *ret=PyList_New(res.size());
}
return ret;
}
- static PyObject *GetNodeFieldIterations(const char *fileName, const char *meshName, const char *fieldName) throw(INTERP_KERNEL::Exception)
+ static PyObject *GetNodeFieldIterations(const std::string& fileName, const std::string& meshName, const std::string& fieldName) throw(INTERP_KERNEL::Exception)
{
std::vector< std::pair<int,int> > res=MEDLoader::GetNodeFieldIterations(fileName,meshName,fieldName);
PyObject *ret=PyList_New(res.size());
}
return ret;
}
- static PyObject *GetComponentsNamesOfField(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
+ static PyObject *GetComponentsNamesOfField(const std::string& fileName, const std::string& fieldName) throw(INTERP_KERNEL::Exception)
{
std::vector< std::pair<std::string,std::string> > res=MEDLoader::GetComponentsNamesOfField(fileName,fieldName);
PyObject *ret=PyList_New(res.size());
}
return ret;
}
- static PyObject *GetUMeshGlobalInfo(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception)
+ static PyObject *GetUMeshGlobalInfo(const std::string& fileName, const std::string& meshName) throw(INTERP_KERNEL::Exception)
{
int meshDim,spaceDim,numberOfNodes;
std::vector< std::vector< std::pair<INTERP_KERNEL::NormalizedCellType,int> > > res=MEDLoader::GetUMeshGlobalInfo(fileName,meshName,meshDim,spaceDim,numberOfNodes);
PyTuple_SetItem(ret,3,SWIG_From_int(numberOfNodes));
return ret;
}
- static PyObject *ReadFieldsOnSameMesh(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName, int meshDimRelToMax,
- const char *fieldName, PyObject *liIts) throw(INTERP_KERNEL::Exception)
+ static PyObject *ReadFieldsOnSameMesh(ParaMEDMEM::TypeOfField type, const std::string& fileName, const std::string& meshName, int meshDimRelToMax,
+ const std::string& fieldName, PyObject *liIts) throw(INTERP_KERNEL::Exception)
{
std::vector<std::pair<int,int> > its=convertTimePairIdsFromPy(liIts);
std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> res=MEDLoader::ReadFieldsOnSameMesh(type,fileName,meshName,meshDimRelToMax,fieldName,its);
return convertFieldDoubleVecToPy(res);
}
- static void WriteUMeshesPartition(const char *fileName, const char *meshName, PyObject *li, bool writeFromScratch) throw(INTERP_KERNEL::Exception)
+ static void WriteUMeshesPartition(const std::string& fileName, const std::string& meshName, PyObject *li, bool writeFromScratch) throw(INTERP_KERNEL::Exception)
{
std::vector<const ParaMEDMEM::MEDCouplingUMesh *> v;
convertFromPyObjVectorOfObj<const ParaMEDMEM::MEDCouplingUMesh *>(li,SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh,"MEDCouplingUMesh",v);
MEDLoader::WriteUMeshesPartition(fileName,meshName,v,writeFromScratch);
}
- static void WriteUMeshesPartitionDep(const char *fileName, const char *meshName, PyObject *li, bool writeFromScratch) throw(INTERP_KERNEL::Exception)
+ static void WriteUMeshesPartitionDep(const std::string& fileName, const std::string& meshName, PyObject *li, bool writeFromScratch) throw(INTERP_KERNEL::Exception)
{
std::vector<const ParaMEDMEM::MEDCouplingUMesh *> v;
convertFromPyObjVectorOfObj<const ParaMEDMEM::MEDCouplingUMesh *>(li,SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh,"MEDCouplingUMesh",v);
MEDLoader::WriteUMeshesPartitionDep(fileName,meshName,v,writeFromScratch);
}
- static void WriteUMeshes(const char *fileName, PyObject *li, bool writeFromScratch) throw(INTERP_KERNEL::Exception)
+ static void WriteUMeshes(const std::string& fileName, PyObject *li, bool writeFromScratch) throw(INTERP_KERNEL::Exception)
{
std::vector<const ParaMEDMEM::MEDCouplingUMesh *> v;
convertFromPyObjVectorOfObj<const ParaMEDMEM::MEDCouplingUMesh *>(li,SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh,"MEDCouplingUMesh",v);
MEDLoader::WriteUMeshes(fileName,v,writeFromScratch);
}
- static PyObject *GetTypesOfField(const char *fileName, const char *meshName, const char *fieldName) throw(INTERP_KERNEL::Exception)
+ static PyObject *GetTypesOfField(const std::string& fileName, const std::string& meshName, const std::string& fieldName) throw(INTERP_KERNEL::Exception)
{
std::vector< ParaMEDMEM::TypeOfField > v=MEDLoader::GetTypesOfField(fileName,meshName,fieldName);
int size=v.size();
PyList_SetItem(ret,i,PyInt_FromLong((int)v[i]));
return ret;
}
- static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromGroups(const char *fileName, const char *meshName, int meshDimRelToMax, PyObject *li) throw(INTERP_KERNEL::Exception)
+ static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromGroups(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, PyObject *li) throw(INTERP_KERNEL::Exception)
{
std::vector<std::string> grps;
converPyListToVecString(li,grps);
return MEDLoader::ReadUMeshFromGroups(fileName,meshName,meshDimRelToMax,grps);
}
- static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFamilies(const char *fileName, const char *meshName, int meshDimRelToMax, PyObject *li) throw(INTERP_KERNEL::Exception)
+ static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFamilies(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, PyObject *li) throw(INTERP_KERNEL::Exception)
{
std::vector<std::string> fams;
converPyListToVecString(li,fams);
return MEDLoader::ReadUMeshFromFamilies(fileName,meshName,meshDimRelToMax,fams);
}
}
- static ParaMEDMEM::MEDCouplingMesh *ReadMeshFromFile(const char *fileName, const char *meshName, int meshDimRelToMax=0) throw(INTERP_KERNEL::Exception);
- static ParaMEDMEM::MEDCouplingMesh *ReadMeshFromFile(const char *fileName, int meshDimRelToMax=0) throw(INTERP_KERNEL::Exception);
- static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFile(const char *fileName, const char *meshName, int meshDimRelToMax=0) throw(INTERP_KERNEL::Exception);
- static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFile(const char *fileName, int meshDimRelToMax=0) throw(INTERP_KERNEL::Exception);
- static int ReadUMeshDimFromFile(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
- static ParaMEDMEM::MEDCouplingFieldDouble *ReadField(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
- static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldCell(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
- static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldNode(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
- static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldGauss(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
- static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldGaussNE(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
- static void WriteMesh(const char *fileName, const ParaMEDMEM::MEDCouplingMesh *mesh, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
- static void WriteUMesh(const char *fileName, const ParaMEDMEM::MEDCouplingUMesh *mesh, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
- static void WriteUMeshDep(const char *fileName, const ParaMEDMEM::MEDCouplingUMesh *mesh, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
- static void WriteField(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
- static void WriteFieldDep(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
- static void WriteFieldUsingAlreadyWrittenMesh(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f) throw(INTERP_KERNEL::Exception);
+ static ParaMEDMEM::MEDCouplingMesh *ReadMeshFromFile(const std::string& fileName, const std::string& meshName, int meshDimRelToMax=0) throw(INTERP_KERNEL::Exception);
+ static ParaMEDMEM::MEDCouplingMesh *ReadMeshFromFile(const std::string& fileName, int meshDimRelToMax=0) throw(INTERP_KERNEL::Exception);
+ static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFile(const std::string& fileName, const std::string& meshName, int meshDimRelToMax=0) throw(INTERP_KERNEL::Exception);
+ static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFile(const std::string& fileName, int meshDimRelToMax=0) throw(INTERP_KERNEL::Exception);
+ static int ReadUMeshDimFromFile(const std::string& fileName, const std::string& meshName) throw(INTERP_KERNEL::Exception);
+ static ParaMEDMEM::MEDCouplingFieldDouble *ReadField(ParaMEDMEM::TypeOfField type, const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
+ static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldCell(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
+ static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldNode(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
+ static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldGauss(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
+ static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldGaussNE(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
+ static void WriteMesh(const std::string& fileName, const ParaMEDMEM::MEDCouplingMesh *mesh, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
+ static void WriteUMesh(const std::string& fileName, const ParaMEDMEM::MEDCouplingUMesh *mesh, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
+ static void WriteUMeshDep(const std::string& fileName, const ParaMEDMEM::MEDCouplingUMesh *mesh, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
+ static void WriteField(const std::string& fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
+ static void WriteFieldDep(const std::string& fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
+ static void WriteFieldUsingAlreadyWrittenMesh(const std::string& fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f) throw(INTERP_KERNEL::Exception);
};
namespace ParaMEDMEM
class MEDFileMesh : public RefCountObject, public MEDFileWritable
{
public:
- static MEDFileMesh *New(const char *fileName, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception);
- static MEDFileMesh *New(const char *fileName, const char *mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception);
+ static MEDFileMesh *New(const std::string& fileName, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception);
+ static MEDFileMesh *New(const std::string& fileName, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception);
virtual MEDFileMesh *createNewEmpty() const throw(INTERP_KERNEL::Exception);
virtual MEDFileMesh *deepCpy() const throw(INTERP_KERNEL::Exception);
virtual MEDFileMesh *shallowCpy() const throw(INTERP_KERNEL::Exception);
virtual void clearNonDiscrAttributes() const throw(INTERP_KERNEL::Exception);
- void setName(const char *name);
+ void setName(const std::string& name);
std::string getName();
- const char *getUnivName() const;
+ std::string getUnivName() const;
bool getUnivNameWrStatus() const;
void setUnivNameWrStatus(bool newStatus);
- void setDescription(const char *name);
+ void setDescription(const std::string& name);
std::string getDescription() const;
void setOrder(int order);
int getOrder() const;
void setTimeValue(double time);
void setTime(int dt, int it, double time);
double getTimeValue() const;
- void setTimeUnit(const char *unit);
- const char *getTimeUnit() const;
+ void setTimeUnit(const std::string& unit);
+ std::string getTimeUnit() const;
virtual int getNumberOfNodes() const throw(INTERP_KERNEL::Exception);
virtual std::vector<int> getFamArrNonEmptyLevelsExt() const throw(INTERP_KERNEL::Exception);
virtual std::vector<int> getNumArrNonEmptyLevelsExt() const throw(INTERP_KERNEL::Exception);
virtual std::vector<int> getDistributionOfTypes(int meshDimRelToMax) const throw(INTERP_KERNEL::Exception);
std::vector<int> getNonEmptyLevels() const throw(INTERP_KERNEL::Exception);
std::vector<int> getNonEmptyLevelsExt() const throw(INTERP_KERNEL::Exception);
- void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
+ void write(const std::string& fileName, int mode) const throw(INTERP_KERNEL::Exception);
int getSizeAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception);
//
- bool existsGroup(const char *groupName) const throw(INTERP_KERNEL::Exception);
+ bool existsGroup(const std::string& groupName) const throw(INTERP_KERNEL::Exception);
bool existsFamily(int famId) const throw(INTERP_KERNEL::Exception);
- bool existsFamily(const char *familyName) const throw(INTERP_KERNEL::Exception);
- void setFamilyId(const char *familyName, int id) throw(INTERP_KERNEL::Exception);
- void setFamilyIdUnique(const char *familyName, int id) throw(INTERP_KERNEL::Exception);
- void addFamily(const char *familyName, int id) throw(INTERP_KERNEL::Exception);
- void addFamilyOnGrp(const char *grpName, const char *famName) throw(INTERP_KERNEL::Exception);
- virtual void createGroupOnAll(int meshDimRelToMaxExt, const char *groupName) throw(INTERP_KERNEL::Exception);
+ bool existsFamily(const std::string& familyName) const throw(INTERP_KERNEL::Exception);
+ void setFamilyId(const std::string& familyName, int id) throw(INTERP_KERNEL::Exception);
+ void setFamilyIdUnique(const std::string& familyName, int id) throw(INTERP_KERNEL::Exception);
+ void addFamily(const std::string& familyName, int id) throw(INTERP_KERNEL::Exception);
+ void addFamilyOnGrp(const std::string& grpName, const std::string& famName) throw(INTERP_KERNEL::Exception);
+ virtual void createGroupOnAll(int meshDimRelToMaxExt, const std::string& 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 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);
+ std::vector<std::string> getFamiliesOnGroup(const std::string& name) const throw(INTERP_KERNEL::Exception);
std::vector<std::string> getFamiliesOnGroups(const std::vector<std::string>& grps) const throw(INTERP_KERNEL::Exception);
- std::vector<int> getFamiliesIdsOnGroup(const char *name) const throw(INTERP_KERNEL::Exception);
- void setFamiliesOnGroup(const char *name, const std::vector<std::string>& fams) throw(INTERP_KERNEL::Exception);
- void setFamiliesIdsOnGroup(const char *name, const std::vector<int>& famIds) throw(INTERP_KERNEL::Exception);
- std::vector<std::string> getGroupsOnFamily(const char *name) const throw(INTERP_KERNEL::Exception);
- void setGroupsOnFamily(const char *famName, const std::vector<std::string>& grps) throw(INTERP_KERNEL::Exception);
+ std::vector<int> getFamiliesIdsOnGroup(const std::string& name) const throw(INTERP_KERNEL::Exception);
+ void setFamiliesOnGroup(const std::string& name, const std::vector<std::string>& fams) throw(INTERP_KERNEL::Exception);
+ void setFamiliesIdsOnGroup(const std::string& name, const std::vector<int>& famIds) throw(INTERP_KERNEL::Exception);
+ std::vector<std::string> getGroupsOnFamily(const std::string& name) const throw(INTERP_KERNEL::Exception);
+ void setGroupsOnFamily(const std::string& famName, const std::vector<std::string>& grps) throw(INTERP_KERNEL::Exception);
std::vector<std::string> getGroupsNames() const throw(INTERP_KERNEL::Exception);
std::vector<std::string> getFamiliesNames() const throw(INTERP_KERNEL::Exception);
void assignFamilyNameWithGroupName() throw(INTERP_KERNEL::Exception);
std::vector<std::string> removeEmptyGroups() throw(INTERP_KERNEL::Exception);
- void removeGroup(const char *name) throw(INTERP_KERNEL::Exception);
- void removeFamily(const char *name) throw(INTERP_KERNEL::Exception);
+ void removeGroup(const std::string& name) throw(INTERP_KERNEL::Exception);
+ void removeFamily(const std::string& name) throw(INTERP_KERNEL::Exception);
std::vector<std::string> removeOrphanGroups() throw(INTERP_KERNEL::Exception);
std::vector<std::string> removeOrphanFamilies() throw(INTERP_KERNEL::Exception);
- void changeGroupName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception);
- void changeFamilyName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception);
+ void changeGroupName(const std::string& oldName, const std::string& newName) throw(INTERP_KERNEL::Exception);
+ void changeFamilyName(const std::string& oldName, const std::string& newName) throw(INTERP_KERNEL::Exception);
void changeFamilyId(int oldId, int newId) throw(INTERP_KERNEL::Exception);
- void changeAllGroupsContainingFamily(const char *familyNameToChange, const std::vector<std::string>& newFamiliesNames) throw(INTERP_KERNEL::Exception);
+ void changeAllGroupsContainingFamily(const std::string& familyNameToChange, const std::vector<std::string>& newFamiliesNames) throw(INTERP_KERNEL::Exception);
void setFamilyInfo(const std::map<std::string,int>& info);
void setGroupInfo(const std::map<std::string, std::vector<std::string> >&info);
- int getFamilyId(const char *name) const throw(INTERP_KERNEL::Exception);
+ int getFamilyId(const std::string& name) const throw(INTERP_KERNEL::Exception);
int getMaxAbsFamilyId() const throw(INTERP_KERNEL::Exception);
int getMaxFamilyId() const throw(INTERP_KERNEL::Exception);
int getMinFamilyId() const throw(INTERP_KERNEL::Exception);
virtual void setNameFieldAtLevel(int meshDimRelToMaxExt, DataArrayAsciiChar *nameArr) throw(INTERP_KERNEL::Exception);
virtual DataArrayInt *getFamiliesArr(int meshDimRelToMaxExt, const std::vector<std::string>& fams, bool renum=false) const throw(INTERP_KERNEL::Exception);
virtual DataArrayInt *getGroupsArr(int meshDimRelToMaxExt, const std::vector<std::string>& grps, bool renum=false) const throw(INTERP_KERNEL::Exception);
- virtual DataArrayInt *getGroupArr(int meshDimRelToMaxExt, const char *grp, bool renum=false) const throw(INTERP_KERNEL::Exception);
- virtual DataArrayInt *getFamilyArr(int meshDimRelToMaxExt, const char *fam, bool renum=false) const throw(INTERP_KERNEL::Exception);
- virtual DataArrayInt *getNodeGroupArr(const char *grp, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ virtual DataArrayInt *getGroupArr(int meshDimRelToMaxExt, const std::string& grp, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ virtual DataArrayInt *getFamilyArr(int meshDimRelToMaxExt, const std::string& fam, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ virtual DataArrayInt *getNodeGroupArr(const std::string& grp, bool renum=false) const throw(INTERP_KERNEL::Exception);
virtual DataArrayInt *getNodeGroupsArr(const std::vector<std::string>& grps, bool renum=false) const throw(INTERP_KERNEL::Exception);
- virtual DataArrayInt *getNodeFamilyArr(const char *fam, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ virtual DataArrayInt *getNodeFamilyArr(const std::string& fam, bool renum=false) const throw(INTERP_KERNEL::Exception);
virtual DataArrayInt *getNodeFamiliesArr(const std::vector<std::string>& fams, bool renum=false) const throw(INTERP_KERNEL::Exception);
%extend
{
return res;
}
+ PyObject *getAllGeoTypes() const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<INTERP_KERNEL::NormalizedCellType> result(self->getAllGeoTypes());
+ 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 *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 *getFamilyFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception)
{
const DataArrayInt *tmp=self->getFamilyFieldAtLevel(meshDimRelToMaxExt);
class MEDFileUMesh : public MEDFileMesh
{
public:
- static MEDFileUMesh *New(const char *fileName, const char *mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception);
- static MEDFileUMesh *New(const char *fileName, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception);
+ static MEDFileUMesh *New(const std::string& fileName, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception);
+ static MEDFileUMesh *New(const std::string& fileName, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception);
static MEDFileUMesh *New();
~MEDFileUMesh();
int getSpaceDimension() const throw(INTERP_KERNEL::Exception);
//
- std::vector<int> getGrpNonEmptyLevels(const char *grp) const throw(INTERP_KERNEL::Exception);
- std::vector<int> getGrpNonEmptyLevelsExt(const char *grp) const throw(INTERP_KERNEL::Exception);
- std::vector<int> getFamNonEmptyLevels(const char *fam) const throw(INTERP_KERNEL::Exception);
- std::vector<int> getFamNonEmptyLevelsExt(const char *fam) const throw(INTERP_KERNEL::Exception);
+ std::vector<int> getGrpNonEmptyLevels(const std::string& grp) const throw(INTERP_KERNEL::Exception);
+ std::vector<int> getGrpNonEmptyLevelsExt(const std::string& grp) const throw(INTERP_KERNEL::Exception);
+ std::vector<int> getFamNonEmptyLevels(const std::string& fam) const throw(INTERP_KERNEL::Exception);
+ std::vector<int> getFamNonEmptyLevelsExt(const std::string& fam) const throw(INTERP_KERNEL::Exception);
std::vector<int> getGrpsNonEmptyLevels(const std::vector<std::string>& grps) const throw(INTERP_KERNEL::Exception);
std::vector<int> getGrpsNonEmptyLevelsExt(const std::vector<std::string>& grps) const throw(INTERP_KERNEL::Exception);
std::vector<int> getFamsNonEmptyLevels(const std::vector<std::string>& fams) const throw(INTERP_KERNEL::Exception);
std::vector<int> getFamsNonEmptyLevelsExt(const std::vector<std::string>& fams) const throw(INTERP_KERNEL::Exception);
std::vector<std::string> getGroupsOnSpecifiedLev(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception);
- MEDCouplingUMesh *getGroup(int meshDimRelToMaxExt, const char *grp, bool renum=false) const throw(INTERP_KERNEL::Exception);
- DataArrayInt *getGroupArr(int meshDimRelToMaxExt, const char *grp, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingUMesh *getGroup(int meshDimRelToMaxExt, const std::string& grp, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ DataArrayInt *getGroupArr(int meshDimRelToMaxExt, const std::string& grp, bool renum=false) const throw(INTERP_KERNEL::Exception);
MEDCouplingUMesh *getGroups(int meshDimRelToMaxExt, const std::vector<std::string>& grps, bool renum=false) const throw(INTERP_KERNEL::Exception);
DataArrayInt *getGroupsArr(int meshDimRelToMaxExt, const std::vector<std::string>& grps, bool renum=false) const throw(INTERP_KERNEL::Exception);
- MEDCouplingUMesh *getFamily(int meshDimRelToMaxExt, const char *fam, bool renum=false) const throw(INTERP_KERNEL::Exception);
- DataArrayInt *getFamilyArr(int meshDimRelToMaxExt, const char *fam, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingUMesh *getFamily(int meshDimRelToMaxExt, const std::string& fam, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ DataArrayInt *getFamilyArr(int meshDimRelToMaxExt, const std::string& fam, bool renum=false) const throw(INTERP_KERNEL::Exception);
MEDCouplingUMesh *getFamilies(int meshDimRelToMaxExt, const std::vector<std::string>& fams, bool renum=false) const throw(INTERP_KERNEL::Exception);
DataArrayInt *getFamiliesArr(int meshDimRelToMaxExt, const std::vector<std::string>& fams, bool renum=false) const throw(INTERP_KERNEL::Exception);
- DataArrayInt *getNodeGroupArr(const char *grp, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ DataArrayInt *getNodeGroupArr(const std::string& grp, bool renum=false) const throw(INTERP_KERNEL::Exception);
DataArrayInt *getNodeGroupsArr(const std::vector<std::string>& grps, bool renum=false) const throw(INTERP_KERNEL::Exception);
- DataArrayInt *getNodeFamilyArr(const char *fam, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ DataArrayInt *getNodeFamilyArr(const std::string& fam, bool renum=false) const throw(INTERP_KERNEL::Exception);
DataArrayInt *getNodeFamiliesArr(const std::vector<std::string>& fams, bool renum=false) const throw(INTERP_KERNEL::Exception);
MEDCouplingUMesh *getMeshAtLevel(int meshDimRelToMaxExt, bool renum=false) const throw(INTERP_KERNEL::Exception);
MEDCouplingUMesh *getLevel0Mesh(bool renum=false) 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)
+ MEDFileUMesh(const std::string& fileName, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception)
{
return MEDFileUMesh::New(fileName,mName,dt,it,mrs);
}
- MEDFileUMesh(const char *fileName, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception)
+ MEDFileUMesh(const std::string& fileName, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception)
{
return MEDFileUMesh::New(fileName,mrs);
}
{
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)
{
return ret;
}
- PyObject *duplicateNodesOnM1Group(const char *grpNameM1) throw(INTERP_KERNEL::Exception)
+ PyObject *duplicateNodesOnM1Group(const std::string& grpNameM1) throw(INTERP_KERNEL::Exception)
{
DataArrayInt *ret0=0,*ret1=0,*ret2=0;
self->duplicateNodesOnM1Group(grpNameM1,ret0,ret1,ret2);
{
public:
static MEDFileCMesh *New();
- static MEDFileCMesh *New(const char *fileName, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception);
- static MEDFileCMesh *New(const char *fileName, const char *mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception);
+ static MEDFileCMesh *New(const std::string& fileName, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception);
+ static MEDFileCMesh *New(const std::string& fileName, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception);
void setMesh(MEDCouplingCMesh *m) throw(INTERP_KERNEL::Exception);
+ int getSpaceDimension() const throw(INTERP_KERNEL::Exception);
%extend
{
MEDFileCMesh()
return MEDFileCMesh::New();
}
- MEDFileCMesh(const char *fileName, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception)
+ MEDFileCMesh(const std::string& fileName, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception)
{
return MEDFileCMesh::New(fileName,mrs);
}
- MEDFileCMesh(const char *fileName, const char *mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception)
+ MEDFileCMesh(const std::string& fileName, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception)
{
return MEDFileCMesh::New(fileName,mName,dt,it,mrs);
}
{
public:
static MEDFileCurveLinearMesh *New();
- static MEDFileCurveLinearMesh *New(const char *fileName, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception);
- static MEDFileCurveLinearMesh *New(const char *fileName, const char *mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception);
+ static MEDFileCurveLinearMesh *New(const std::string& fileName, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception);
+ static MEDFileCurveLinearMesh *New(const std::string& fileName, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception);
void setMesh(MEDCouplingCurveLinearMesh *m) throw(INTERP_KERNEL::Exception);
%extend
{
return MEDFileCurveLinearMesh::New();
}
- MEDFileCurveLinearMesh(const char *fileName, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception)
+ MEDFileCurveLinearMesh(const std::string& fileName, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception)
{
return MEDFileCurveLinearMesh::New(fileName,mrs);
}
- MEDFileCurveLinearMesh(const char *fileName, const char *mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception)
+ MEDFileCurveLinearMesh(const std::string& fileName, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception)
{
return MEDFileCurveLinearMesh::New(fileName,mName,dt,it,mrs);
}
{
public:
static MEDFileMeshMultiTS *New();
- static MEDFileMeshMultiTS *New(const char *fileName) throw(INTERP_KERNEL::Exception);
- static MEDFileMeshMultiTS *New(const char *fileName, const char *mName) throw(INTERP_KERNEL::Exception);
+ static MEDFileMeshMultiTS *New(const std::string& fileName) throw(INTERP_KERNEL::Exception);
+ static MEDFileMeshMultiTS *New(const std::string& fileName, const std::string& mName) throw(INTERP_KERNEL::Exception);
MEDFileMeshMultiTS *deepCpy() const throw(INTERP_KERNEL::Exception);
std::string getName() const throw(INTERP_KERNEL::Exception);
- void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
+ void write(const std::string& fileName, int mode) const throw(INTERP_KERNEL::Exception);
void setOneTimeStep(MEDFileMesh *mesh1TimeStep) throw(INTERP_KERNEL::Exception);
%extend
{
return MEDFileMeshMultiTS::New();
}
- MEDFileMeshMultiTS(const char *fileName) throw(INTERP_KERNEL::Exception)
+ MEDFileMeshMultiTS(const std::string& fileName) throw(INTERP_KERNEL::Exception)
{
return MEDFileMeshMultiTS::New(fileName);
}
- MEDFileMeshMultiTS(const char *fileName, const char *mName) throw(INTERP_KERNEL::Exception)
+ MEDFileMeshMultiTS(const std::string& fileName, const std::string& mName) throw(INTERP_KERNEL::Exception)
{
return MEDFileMeshMultiTS::New(fileName,mName);
}
{
public:
static MEDFileMeshes *New();
- static MEDFileMeshes *New(const char *fileName) throw(INTERP_KERNEL::Exception);
+ static MEDFileMeshes *New(const std::string& fileName) throw(INTERP_KERNEL::Exception);
MEDFileMeshes *deepCpy() const throw(INTERP_KERNEL::Exception);
- void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
+ void write(const std::string& fileName, int mode) const throw(INTERP_KERNEL::Exception);
int getNumberOfMeshes() const throw(INTERP_KERNEL::Exception);
std::vector<std::string> getMeshesNames() const throw(INTERP_KERNEL::Exception);
//
return MEDFileMeshes::New();
}
- MEDFileMeshes(const char *fileName) throw(INTERP_KERNEL::Exception)
+ MEDFileMeshes(const std::string& fileName) throw(INTERP_KERNEL::Exception)
{
return MEDFileMeshes::New(fileName);
}
ret->incrRef();
return ret;
}
- MEDFileMesh *getMeshWithName(const char *mname) const throw(INTERP_KERNEL::Exception)
+ MEDFileMesh *getMeshWithName(const std::string& mname) const throw(INTERP_KERNEL::Exception)
{
MEDFileMesh *ret=self->getMeshWithName(mname);
if(ret)
void checkGlobsLocsPartCoherency() const throw(INTERP_KERNEL::Exception);
std::vector<std::string> getPfls() const throw(INTERP_KERNEL::Exception);
std::vector<std::string> getLocs() const throw(INTERP_KERNEL::Exception);
- bool existsPfl(const char *pflName) const throw(INTERP_KERNEL::Exception);
- bool existsLoc(const char *locName) const throw(INTERP_KERNEL::Exception);
+ bool existsPfl(const std::string& pflName) const throw(INTERP_KERNEL::Exception);
+ bool existsLoc(const std::string& locName) const throw(INTERP_KERNEL::Exception);
std::string createNewNameOfPfl() const throw(INTERP_KERNEL::Exception);
std::string createNewNameOfLoc() const throw(INTERP_KERNEL::Exception);
std::vector< std::vector<int> > whichAreEqualProfiles() const throw(INTERP_KERNEL::Exception);
virtual std::vector<std::string> getLocsReallyUsedMulti() const throw(INTERP_KERNEL::Exception);
void killProfileIds(const std::vector<int>& pflIds) throw(INTERP_KERNEL::Exception);
void killLocalizationIds(const std::vector<int>& locIds) throw(INTERP_KERNEL::Exception);
- void changePflName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception);
- void changeLocName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception);
+ void changePflName(const std::string& oldName, const std::string& newName) throw(INTERP_KERNEL::Exception);
+ void changeLocName(const std::string& oldName, const std::string& newName) throw(INTERP_KERNEL::Exception);
int getNbOfGaussPtPerCell(int locId) const throw(INTERP_KERNEL::Exception);
- int getLocalizationId(const char *loc) const throw(INTERP_KERNEL::Exception);
+ int getLocalizationId(const std::string& loc) const throw(INTERP_KERNEL::Exception);
%extend
{
- PyObject *getProfile(const char *pflName) const throw(INTERP_KERNEL::Exception)
+ PyObject *getProfile(const std::string& pflName) const throw(INTERP_KERNEL::Exception)
{
const DataArrayInt *ret=self->getProfile(pflName);
if(ret)
return SWIG_NewPointerObj(SWIG_as_voidptr(loc),SWIGTYPE_p_ParaMEDMEM__MEDFileFieldLoc, SWIG_POINTER_OWN | 0 );
}
- PyObject *getLocalization(const char *locName) const throw(INTERP_KERNEL::Exception)
+ PyObject *getLocalization(const std::string& locName) const throw(INTERP_KERNEL::Exception)
{
const MEDFileFieldLoc *loc=&self->getLocalization(locName);
if(loc)
class MEDFileAnyTypeField1TS : public RefCountObject, public MEDFileFieldGlobsReal, public MEDFileWritable
{
public:
- static MEDFileAnyTypeField1TS *New(const char *fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception);
- static MEDFileAnyTypeField1TS *New(const char *fileName, const char *fieldName, bool loadAll=true) throw(INTERP_KERNEL::Exception);
- static MEDFileAnyTypeField1TS *New(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll=true) throw(INTERP_KERNEL::Exception);
- void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
+ static MEDFileAnyTypeField1TS *New(const std::string& fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception);
+ static MEDFileAnyTypeField1TS *New(const std::string& fileName, const std::string& fieldName, bool loadAll=true) throw(INTERP_KERNEL::Exception);
+ static MEDFileAnyTypeField1TS *New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll=true) throw(INTERP_KERNEL::Exception);
+ void write(const std::string& fileName, int mode) const throw(INTERP_KERNEL::Exception);
void loadArrays() throw(INTERP_KERNEL::Exception);
void loadArraysIfNecessary() throw(INTERP_KERNEL::Exception);
void unloadArrays() throw(INTERP_KERNEL::Exception);
int getIteration() const throw(INTERP_KERNEL::Exception);
int getOrder() const throw(INTERP_KERNEL::Exception);
std::string getName() throw(INTERP_KERNEL::Exception);
- void setName(const char *name) throw(INTERP_KERNEL::Exception);
+ void setName(const std::string& name) throw(INTERP_KERNEL::Exception);
std::string getMeshName() throw(INTERP_KERNEL::Exception);
- void setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception);
+ void setMeshName(const std::string& newMeshName) throw(INTERP_KERNEL::Exception);
int getMeshIteration() const throw(INTERP_KERNEL::Exception);
int getMeshOrder() const throw(INTERP_KERNEL::Exception);
int getNumberOfComponents() const throw(INTERP_KERNEL::Exception);
virtual MEDFileAnyTypeField1TS *shallowCpy() const throw(INTERP_KERNEL::Exception);
MEDFileAnyTypeField1TS *deepCpy() const throw(INTERP_KERNEL::Exception);
std::string getDtUnit() const throw(INTERP_KERNEL::Exception);
- void setDtUnit(const char *dtUnit) throw(INTERP_KERNEL::Exception);
+ void setDtUnit(const std::string& dtUnit) throw(INTERP_KERNEL::Exception);
%extend
{
PyObject *getTime() throw(INTERP_KERNEL::Exception)
return elt;
}
- void setProfileNameOnLeaf(INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newPflName, bool forceRenameOnGlob=false) throw(INTERP_KERNEL::Exception)
+ void setProfileNameOnLeaf(INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob=false) throw(INTERP_KERNEL::Exception)
{
self->setProfileNameOnLeaf(0,typ,locId,newPflName,forceRenameOnGlob);
}
- void setLocNameOnLeaf(INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newLocName, bool forceRenameOnGlob=false) throw(INTERP_KERNEL::Exception)
+ void setLocNameOnLeaf(INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob=false) throw(INTERP_KERNEL::Exception)
{
self->setLocNameOnLeaf(0,typ,locId,newLocName,forceRenameOnGlob);
}
return ret2;
}
- PyObject *getNonEmptyLevels(const char *mname=0) const throw(INTERP_KERNEL::Exception)
+ PyObject *getNonEmptyLevels(const std::string& mname=std::string()) const throw(INTERP_KERNEL::Exception)
{
std::vector<int> ret1;
int ret0=self->getNonEmptyLevels(mname,ret1);
return elt;
}
- PyObject *getFieldSplitedByType(const char *mname=0) const throw(INTERP_KERNEL::Exception)
+ PyObject *getFieldSplitedByType(const std::string& mname=std::string()) const throw(INTERP_KERNEL::Exception)
{
std::vector<INTERP_KERNEL::NormalizedCellType> types;
std::vector< std::vector<TypeOfField> > typesF;
class MEDFileField1TS : public MEDFileAnyTypeField1TS
{
public:
- static MEDFileField1TS *New(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll=true) throw(INTERP_KERNEL::Exception);
- static MEDFileField1TS *New(const char *fileName, const char *fieldName, bool loadAll=true) throw(INTERP_KERNEL::Exception);
- static MEDFileField1TS *New(const char *fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception);
+ static MEDFileField1TS *New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll=true) throw(INTERP_KERNEL::Exception);
+ static MEDFileField1TS *New(const std::string& fileName, const std::string& fieldName, bool loadAll=true) throw(INTERP_KERNEL::Exception);
+ static MEDFileField1TS *New(const std::string& fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception);
static MEDFileField1TS *New();
ParaMEDMEM::MEDFileIntField1TS *convertToInt(bool isDeepCpyGlobs=true) const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, int renumPol=0) const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *getFieldAtLevelOld(TypeOfField type, const char *mname, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
//
void setFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception);
void setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception);
- void setProfileNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newPflName, bool forceRenameOnGlob=false) throw(INTERP_KERNEL::Exception);
- void setLocNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newLocName, bool forceRenameOnGlob=false) throw(INTERP_KERNEL::Exception);
+ void setProfileNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob=false) throw(INTERP_KERNEL::Exception);
+ void setLocNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob=false) throw(INTERP_KERNEL::Exception);
%extend
{
- MEDFileField1TS(const char *fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception)
+ MEDFileField1TS(const std::string& fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception)
{
return MEDFileField1TS::New(fileName,loadAll);
}
- MEDFileField1TS(const char *fileName, const char *fieldName, bool loadAll=true) throw(INTERP_KERNEL::Exception)
+ MEDFileField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll=true) throw(INTERP_KERNEL::Exception)
{
return MEDFileField1TS::New(fileName,fieldName,loadAll);
}
- MEDFileField1TS(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll=true) throw(INTERP_KERNEL::Exception)
+ MEDFileField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll=true) throw(INTERP_KERNEL::Exception)
{
return MEDFileField1TS::New(fileName,fieldName,iteration,order,loadAll);
}
return ret;
}
- PyObject *getFieldSplitedByType2(const char *mname=0) const throw(INTERP_KERNEL::Exception)
+ PyObject *getFieldSplitedByType2(const std::string& mname=std::string()) const throw(INTERP_KERNEL::Exception)
{
std::vector<INTERP_KERNEL::NormalizedCellType> types;
std::vector< std::vector<TypeOfField> > typesF;
{
public:
static MEDFileIntField1TS *New();
- static MEDFileIntField1TS *New(const char *fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception);
- static MEDFileIntField1TS *New(const char *fileName, const char *fieldName, bool loadAll=true) throw(INTERP_KERNEL::Exception);
- static MEDFileIntField1TS *New(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll=true) throw(INTERP_KERNEL::Exception);
+ static MEDFileIntField1TS *New(const std::string& fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception);
+ static MEDFileIntField1TS *New(const std::string& fileName, const std::string& fieldName, bool loadAll=true) throw(INTERP_KERNEL::Exception);
+ static MEDFileIntField1TS *New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll=true) throw(INTERP_KERNEL::Exception);
ParaMEDMEM::MEDFileField1TS *convertToDouble(bool isDeepCpyGlobs=true) const throw(INTERP_KERNEL::Exception);
//
void setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals) throw(INTERP_KERNEL::Exception);
return MEDFileIntField1TS::New();
}
- MEDFileIntField1TS(const char *fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception)
+ MEDFileIntField1TS(const std::string& fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception)
{
return MEDFileIntField1TS::New(fileName,loadAll);
}
- MEDFileIntField1TS(const char *fileName, const char *fieldName, bool loadAll=true) throw(INTERP_KERNEL::Exception)
+ MEDFileIntField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll=true) throw(INTERP_KERNEL::Exception)
{
return MEDFileIntField1TS::New(fileName,fieldName,loadAll);
}
- MEDFileIntField1TS(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll=true) throw(INTERP_KERNEL::Exception)
+ MEDFileIntField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll=true) throw(INTERP_KERNEL::Exception)
{
return MEDFileIntField1TS::New(fileName,fieldName,iteration,order,loadAll);
}
return ret;
}
- PyObject *getFieldAtLevelOld(TypeOfField type, const char *mname, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception)
+ PyObject *getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception)
{
DataArrayInt *ret1=0;
MEDCouplingFieldDouble *ret0=self->getFieldAtLevelOld(type,mname,meshDimRelToMax,ret1,renumPol);
class MEDFileAnyTypeFieldMultiTS : public RefCountObject, public MEDFileFieldGlobsReal, public MEDFileWritable
{
public:
- static MEDFileAnyTypeFieldMultiTS *New(const char *fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception);
- static MEDFileAnyTypeFieldMultiTS *New(const char *fileName, const char *fieldName, bool loadAll=true) throw(INTERP_KERNEL::Exception);
+ static MEDFileAnyTypeFieldMultiTS *New(const std::string& fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception);
+ static MEDFileAnyTypeFieldMultiTS *New(const std::string& fileName, const std::string& fieldName, bool loadAll=true) throw(INTERP_KERNEL::Exception);
MEDFileAnyTypeFieldMultiTS *deepCpy() const throw(INTERP_KERNEL::Exception);
virtual MEDFileAnyTypeFieldMultiTS *shallowCpy() const throw(INTERP_KERNEL::Exception);
std::string getName() const throw(INTERP_KERNEL::Exception);
- void setName(const char *name) throw(INTERP_KERNEL::Exception);
+ void setName(const std::string& name) throw(INTERP_KERNEL::Exception);
std::string getDtUnit() const throw(INTERP_KERNEL::Exception);
- void setDtUnit(const char *dtUnit) throw(INTERP_KERNEL::Exception);
+ void setDtUnit(const std::string& dtUnit) throw(INTERP_KERNEL::Exception);
std::string getMeshName() const throw(INTERP_KERNEL::Exception);
- void setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception);
+ void setMeshName(const std::string& newMeshName) throw(INTERP_KERNEL::Exception);
const std::vector<std::string>& getInfo() const throw(INTERP_KERNEL::Exception);
int getNumberOfComponents() const throw(INTERP_KERNEL::Exception);
int getNumberOfTS() const throw(INTERP_KERNEL::Exception);
void eraseEmptyTS() throw(INTERP_KERNEL::Exception);
int getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception);
int getPosGivenTime(double time, double eps=1e-8) const throw(INTERP_KERNEL::Exception);
- void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
+ void write(const std::string& fileName, int mode) const throw(INTERP_KERNEL::Exception);
void loadArrays() throw(INTERP_KERNEL::Exception);
void loadArraysIfNecessary() throw(INTERP_KERNEL::Exception);
void unloadArrays() throw(INTERP_KERNEL::Exception);
return ret2;
}
- PyObject *getNonEmptyLevels(int iteration, int order, const char *mname=0) const throw(INTERP_KERNEL::Exception)
+ PyObject *getNonEmptyLevels(int iteration, int order, const std::string& mname=std::string()) const throw(INTERP_KERNEL::Exception)
{
std::vector<int> ret1;
int ret0=self->getNonEmptyLevels(iteration,order,mname,ret1);
return elt;
}
- PyObject *getFieldSplitedByType(int iteration, int order, const char *mname=0) const throw(INTERP_KERNEL::Exception)
+ PyObject *getFieldSplitedByType(int iteration, int order, const std::string& mname=std::string()) const throw(INTERP_KERNEL::Exception)
{
std::vector<INTERP_KERNEL::NormalizedCellType> types;
std::vector< std::vector<TypeOfField> > typesF;
{
public:
static MEDFileFieldMultiTS *New() throw(INTERP_KERNEL::Exception);
- static MEDFileFieldMultiTS *New(const char *fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception);
- static MEDFileFieldMultiTS *New(const char *fileName, const char *fieldName, bool loadAll=true) throw(INTERP_KERNEL::Exception);
+ static MEDFileFieldMultiTS *New(const std::string& fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception);
+ static MEDFileFieldMultiTS *New(const std::string& fileName, const std::string& fieldName, bool loadAll=true) throw(INTERP_KERNEL::Exception);
//
MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol=0) const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *getFieldAtLevelOld(TypeOfField type, const char *mname, int iteration, int order, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *getFieldAtLevelOld(TypeOfField type, const std::string& mname, int iteration, int order, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
//
void appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception);
void appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception);
return MEDFileFieldMultiTS::New();
}
- MEDFileFieldMultiTS(const char *fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception)
+ MEDFileFieldMultiTS(const std::string& fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception)
{
return MEDFileFieldMultiTS::New(fileName,loadAll);
}
- MEDFileFieldMultiTS(const char *fileName, const char *fieldName, bool loadAll=true) throw(INTERP_KERNEL::Exception)
+ MEDFileFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll=true) throw(INTERP_KERNEL::Exception)
{
return MEDFileFieldMultiTS::New(fileName,fieldName,loadAll);
}
return ret;
}
- PyObject *getFieldSplitedByType2(int iteration, int order, const char *mname=0) const throw(INTERP_KERNEL::Exception)
+ PyObject *getFieldSplitedByType2(int iteration, int order, const std::string& mname=std::string()) const throw(INTERP_KERNEL::Exception)
{
std::vector<INTERP_KERNEL::NormalizedCellType> types;
std::vector< std::vector<TypeOfField> > typesF;
{
public:
static MEDFileIntFieldMultiTS *New();
- static MEDFileIntFieldMultiTS *New(const char *fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception);
- static MEDFileIntFieldMultiTS *New(const char *fileName, const char *fieldName, bool loadAll=true) throw(INTERP_KERNEL::Exception);
+ static MEDFileIntFieldMultiTS *New(const std::string& fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception);
+ static MEDFileIntFieldMultiTS *New(const std::string& fileName, const std::string& fieldName, bool loadAll=true) throw(INTERP_KERNEL::Exception);
//
void appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals) throw(INTERP_KERNEL::Exception);
void appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception);
return MEDFileIntFieldMultiTS::New();
}
- MEDFileIntFieldMultiTS(const char *fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception)
+ MEDFileIntFieldMultiTS(const std::string& fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception)
{
return MEDFileIntFieldMultiTS::New(fileName,loadAll);
}
- MEDFileIntFieldMultiTS(const char *fileName, const char *fieldName, bool loadAll=true) throw(INTERP_KERNEL::Exception)
+ MEDFileIntFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll=true) throw(INTERP_KERNEL::Exception)
{
return MEDFileIntFieldMultiTS::New(fileName,fieldName,loadAll);
}
return ret;
}
- PyObject *getFieldAtLevelOld(TypeOfField type, int iteration, int order, const char *mname, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception)
+ PyObject *getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception)
{
DataArrayInt *ret1=0;
MEDCouplingFieldDouble *ret0=self->getFieldAtLevelOld(type,iteration,order,mname,meshDimRelToMax,ret1,renumPol);
{
public:
static MEDFileFields *New() throw(INTERP_KERNEL::Exception);
- static MEDFileFields *New(const char *fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception);
+ static MEDFileFields *New(const std::string& fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception);
MEDFileFields *deepCpy() const throw(INTERP_KERNEL::Exception);
MEDFileFields *shallowCpy() const throw(INTERP_KERNEL::Exception);
void loadArrays() throw(INTERP_KERNEL::Exception);
void loadArraysIfNecessary() throw(INTERP_KERNEL::Exception);
void unloadArrays() throw(INTERP_KERNEL::Exception);
- void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
+ void write(const std::string& fileName, int mode) const throw(INTERP_KERNEL::Exception);
int getNumberOfFields() const;
std::vector<std::string> getFieldsNames() const throw(INTERP_KERNEL::Exception);
std::vector<std::string> getMeshesNames() const throw(INTERP_KERNEL::Exception);
void resize(int newSize) throw(INTERP_KERNEL::Exception);
void pushField(MEDFileAnyTypeFieldMultiTS *field) throw(INTERP_KERNEL::Exception);
void setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field) throw(INTERP_KERNEL::Exception);
- int getPosFromFieldName(const char *fieldName) const throw(INTERP_KERNEL::Exception);
+ int getPosFromFieldName(const std::string& fieldName) const throw(INTERP_KERNEL::Exception);
MEDFileAnyTypeFieldMultiTS *getFieldAtPos(int i) const throw(INTERP_KERNEL::Exception);
- MEDFileAnyTypeFieldMultiTS *getFieldWithName(const char *fieldName) const throw(INTERP_KERNEL::Exception);
- MEDFileFields *partOfThisLyingOnSpecifiedMeshName(const char *meshName) const throw(INTERP_KERNEL::Exception);
+ MEDFileAnyTypeFieldMultiTS *getFieldWithName(const std::string& fieldName) const throw(INTERP_KERNEL::Exception);
+ MEDFileFields *partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const throw(INTERP_KERNEL::Exception);
void destroyFieldAtPos(int i) throw(INTERP_KERNEL::Exception);
%extend
{
return MEDFileFields::New();
}
- MEDFileFields(const char *fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception)
+ MEDFileFields(const std::string& fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception)
{
return MEDFileFields::New(fileName,loadAll);
}
class MEDFileParameterTinyInfo : public MEDFileWritable
{
public:
- void setDescription(const char *name);
+ void setDescription(const std::string& name);
std::string getDescription() const;
- void setTimeUnit(const char *unit);
+ void setTimeUnit(const std::string& unit);
std::string getTimeUnit() const;
};
{
public:
static MEDFileParameterDouble1TS *New();
- static MEDFileParameterDouble1TS *New(const char *fileName) throw(INTERP_KERNEL::Exception);
- static MEDFileParameterDouble1TS *New(const char *fileName, const char *paramName) throw(INTERP_KERNEL::Exception);
- static MEDFileParameterDouble1TS *New(const char *fileName, const char *paramName, int dt, int it) throw(INTERP_KERNEL::Exception);
+ static MEDFileParameterDouble1TS *New(const std::string& fileName) throw(INTERP_KERNEL::Exception);
+ static MEDFileParameterDouble1TS *New(const std::string& fileName, const std::string& paramName) throw(INTERP_KERNEL::Exception);
+ static MEDFileParameterDouble1TS *New(const std::string& fileName, const std::string& paramName, int dt, int it) throw(INTERP_KERNEL::Exception);
virtual MEDFileParameter1TS *deepCpy() const throw(INTERP_KERNEL::Exception);
virtual std::string simpleRepr() const throw(INTERP_KERNEL::Exception);
- void setName(const char *name) throw(INTERP_KERNEL::Exception);
+ void setName(const std::string& name) throw(INTERP_KERNEL::Exception);
std::string getName() const throw(INTERP_KERNEL::Exception);
- void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
+ void write(const std::string& fileName, int mode) const throw(INTERP_KERNEL::Exception);
%extend
{
MEDFileParameterDouble1TS()
return MEDFileParameterDouble1TS::New();
}
- MEDFileParameterDouble1TS(const char *fileName) throw(INTERP_KERNEL::Exception)
+ MEDFileParameterDouble1TS(const std::string& fileName) throw(INTERP_KERNEL::Exception)
{
return MEDFileParameterDouble1TS::New(fileName);
}
- MEDFileParameterDouble1TS(const char *fileName, const char *paramName) throw(INTERP_KERNEL::Exception)
+ MEDFileParameterDouble1TS(const std::string& fileName, const std::string& paramName) throw(INTERP_KERNEL::Exception)
{
return MEDFileParameterDouble1TS::New(fileName,paramName);
}
- MEDFileParameterDouble1TS(const char *fileName, const char *paramName, int dt, int it) throw(INTERP_KERNEL::Exception)
+ MEDFileParameterDouble1TS(const std::string& fileName, const std::string& paramName, int dt, int it) throw(INTERP_KERNEL::Exception)
{
return MEDFileParameterDouble1TS::New(fileName,paramName,dt,it);
}
{
public:
static MEDFileParameterMultiTS *New();
- static MEDFileParameterMultiTS *New(const char *fileName) throw(INTERP_KERNEL::Exception);
- static MEDFileParameterMultiTS *New(const char *fileName, const char *paramName) throw(INTERP_KERNEL::Exception);
+ static MEDFileParameterMultiTS *New(const std::string& fileName) throw(INTERP_KERNEL::Exception);
+ static MEDFileParameterMultiTS *New(const std::string& fileName, const std::string& paramName) throw(INTERP_KERNEL::Exception);
std::string getName() const;
- void setName(const char *name);
+ void setName(const std::string& name);
MEDFileParameterMultiTS *deepCpy() const throw(INTERP_KERNEL::Exception);
- void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
+ void write(const std::string& fileName, int mode) const throw(INTERP_KERNEL::Exception);
std::string simpleRepr() const throw(INTERP_KERNEL::Exception);
void appendValue(int dt, int it, double time, double val) throw(INTERP_KERNEL::Exception);
double getDoubleValue(int iteration, int order) const throw(INTERP_KERNEL::Exception);
return MEDFileParameterMultiTS::New();
}
- MEDFileParameterMultiTS(const char *fileName)
+ MEDFileParameterMultiTS(const std::string& fileName)
{
return MEDFileParameterMultiTS::New(fileName);
}
- MEDFileParameterMultiTS(const char *fileName, const char *paramName)
+ MEDFileParameterMultiTS(const std::string& fileName, const std::string& paramName)
{
return MEDFileParameterMultiTS::New(fileName,paramName);
}
{
public:
static MEDFileParameters *New();
- static MEDFileParameters *New(const char *fileName) throw(INTERP_KERNEL::Exception);
+ static MEDFileParameters *New(const std::string& fileName) throw(INTERP_KERNEL::Exception);
MEDFileParameters *deepCpy() const throw(INTERP_KERNEL::Exception);
- void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
+ void write(const std::string& fileName, int mode) const throw(INTERP_KERNEL::Exception);
std::vector<std::string> getParamsNames() const throw(INTERP_KERNEL::Exception);
std::string simpleRepr() const throw(INTERP_KERNEL::Exception);
void resize(int newSize) throw(INTERP_KERNEL::Exception);
void pushParam(MEDFileParameterMultiTS *param) throw(INTERP_KERNEL::Exception);
void setParamAtPos(int i, MEDFileParameterMultiTS *param) throw(INTERP_KERNEL::Exception);
void destroyParamAtPos(int i) throw(INTERP_KERNEL::Exception);
- int getPosFromParamName(const char *paramName) const throw(INTERP_KERNEL::Exception);
+ int getPosFromParamName(const std::string& paramName) const throw(INTERP_KERNEL::Exception);
int getNumberOfParams() const throw(INTERP_KERNEL::Exception);
%extend
{
return MEDFileParameters::New();
}
- MEDFileParameters(const char *fileName)
+ MEDFileParameters(const std::string& fileName)
{
return MEDFileParameters::New(fileName);
}
return ret;
}
- MEDFileParameterMultiTS *getParamWithName(const char *paramName) const throw(INTERP_KERNEL::Exception)
+ MEDFileParameterMultiTS *getParamWithName(const std::string& paramName) const throw(INTERP_KERNEL::Exception)
{
MEDFileParameterMultiTS *ret=self->getParamWithName(paramName);
if(ret)
class MEDFileData : public RefCountObject, public MEDFileWritable
{
public:
- static MEDFileData *New(const char *fileName) throw(INTERP_KERNEL::Exception);
+ static MEDFileData *New(const std::string& fileName) throw(INTERP_KERNEL::Exception);
static MEDFileData *New();
MEDFileData *deepCpy() const throw(INTERP_KERNEL::Exception);
void setFields(MEDFileFields *fields) throw(INTERP_KERNEL::Exception);
int getNumberOfMeshes() const throw(INTERP_KERNEL::Exception);
int getNumberOfParams() const throw(INTERP_KERNEL::Exception);
//
- bool changeMeshName(const char *oldMeshName, const char *newMeshName) throw(INTERP_KERNEL::Exception);
+ bool changeMeshName(const std::string& oldMeshName, const std::string& newMeshName) throw(INTERP_KERNEL::Exception);
bool unPolyzeMeshes() throw(INTERP_KERNEL::Exception);
//
- void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
+ void write(const std::string& fileName, int mode) const throw(INTERP_KERNEL::Exception);
%extend
{
- MEDFileData(const char *fileName) throw(INTERP_KERNEL::Exception)
+ MEDFileData(const std::string& fileName) throw(INTERP_KERNEL::Exception)
{
return MEDFileData::New(fileName);
}
class SauvReader : public RefCountObject
{
public:
- static SauvReader* New(const char *fileName) throw(INTERP_KERNEL::Exception);
+ static SauvReader* New(const std::string& fileName) throw(INTERP_KERNEL::Exception);
MEDFileData * loadInMEDFileDS() throw(INTERP_KERNEL::Exception);
%extend
{
- SauvReader(const char *fileName) throw(INTERP_KERNEL::Exception)
+ SauvReader(const std::string& fileName) throw(INTERP_KERNEL::Exception)
{
return SauvReader::New(fileName);
}
public:
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 write(const std::string& fileName) throw(INTERP_KERNEL::Exception);
void setCpyGrpIfOnASingleFamilyStatus(bool status) throw(INTERP_KERNEL::Exception);
bool getCpyGrpIfOnASingleFamilyStatus() const throw(INTERP_KERNEL::Exception);
%extend
PyTuple_SetItem(ret,1,ret1Py);
return ret;
}
+
+ PyObject *getGeoTypes() const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector< INTERP_KERNEL::NormalizedCellType > result(self->getGeoTypes());
+ 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 *buildVTUArrays() const throw(INTERP_KERNEL::Exception)
{
- std::vector< DataArrayDouble * > objs(self->buildVTUArrays());
+ bool isInternal;
+ std::vector< DataArrayDouble * > objs(self->buildVTUArrays(isInternal));
std::size_t sz(objs.size());
- PyObject *ret=PyList_New(sz);
+ PyObject *ret(PyTuple_New(2));
+ PyObject *ret0=PyList_New(sz);
for(std::size_t i=0;i<sz;i++)
- PyList_SetItem(ret,i,SWIG_NewPointerObj(SWIG_as_voidptr(objs[i]),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, SWIG_POINTER_OWN | 0 ));
+ PyList_SetItem(ret0,i,SWIG_NewPointerObj(SWIG_as_voidptr(objs[i]),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,0,ret0);
+ PyObject *ret1Py(isInternal?Py_True:Py_False);
+ Py_XINCREF(ret1Py);
+ PyTuple_SetItem(ret,1,ret1Py);
return ret;
}
}
{
DataArrayDouble *ret0(0);
std::vector<int> ret1;
- self->buildVTUArrays(ret0,ret1);
+ bool ret2;
+ self->buildVTUArrays(ret0,ret1,ret2);
std::size_t sz(ret1.size());
- PyObject *ret=PyTuple_New(2);
+ PyObject *ret=PyTuple_New(3);
PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, SWIG_POINTER_OWN | 0 ));
PyObject *ret1Py=PyList_New(sz);
for(std::size_t i=0;i<sz;i++)
PyList_SetItem(ret1Py,i,SWIG_From_int(ret1[i]));
PyTuple_SetItem(ret,1,ret1Py);
+ PyObject *ret2Py(ret2?Py_True:Py_False);
+ Py_XINCREF(ret2Py);
+ PyTuple_SetItem(ret,2,ret2Py);
return ret;
}
}
static MEDFileFastCellSupportComparator *New(const MEDFileMeshStruct *m, const MEDFileAnyTypeFieldMultiTS *ref) throw(INTERP_KERNEL::Exception);
MEDMeshMultiLev *buildFromScratchDataSetSupport(int timeStepId, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception);
bool isDataSetSupportEqualToThePreviousOne(int timeStepId, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception);
+ int getNumberOfTS() const throw(INTERP_KERNEL::Exception);
protected:
~MEDFileFastCellSupportComparator();
+ public:
+ %extend
+ {
+ PyObject *getGeoTypesAt(int timeStepId, const MEDFileMesh *m) const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector< INTERP_KERNEL::NormalizedCellType > result(self->getGeoTypesAt(timeStepId,m));
+ 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;
+ }
+ }
};
}
d.alloc(1,1)
d.iota(1.)
# seting a long name
- d.setInfoOnComponent(0,"CONCENTRATION of I129")
+ d.setInfoOnComponent(0,"CONCENTRATION of I129")
f.setArray(d)
f.setName("field")
#
MEDLoader.MEDLoader.WriteField(fname,f,True)
pass
+ def testUsingAlreadyWrittenMesh2(self):
+ """ This test focuses on MEDLoader.WriteFieldUsingAlreadyWrittenMesh with mesh different from UMesh.
+ """
+ fname="Pyfile76.med"
+ mesh=MEDLoader.MEDCouplingCMesh("mesh")
+ arrX=MEDLoader.DataArrayDouble([0,1,2,3])
+ arrY=MEDLoader.DataArrayDouble([0,2,3,5,7])
+ arrZ=MEDLoader.DataArrayDouble([7])
+ mesh.setCoords(arrX,arrY,arrZ)
+ #
+ f1=MEDLoader.MEDCouplingFieldDouble(MEDLoader.ON_NODES) ; f1.setName("f1")
+ f1.setMesh(mesh)
+ arr=MEDLoader.DataArrayDouble(20) ; arr.iota()
+ f1.setArray(arr)
+ f1.checkCoherency()
+ #
+ f2=MEDLoader.MEDCouplingFieldDouble(MEDLoader.ON_NODES) ; f2.setName("f2")
+ f2.setMesh(mesh)
+ arr=MEDLoader.DataArrayDouble(20) ; arr.iota() ; arr*=3
+ f2.setArray(arr)
+ f2.checkCoherency()
+ #
+ f11=f1.deepCpy() ; (f11.getArray())[:]*=4 ; f11.setTime(1.1,5,6)
+ #
+ MEDLoader.MEDLoader.WriteMesh(fname,f1.getMesh(),True)
+ MEDLoader.MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fname,f1)
+ MEDLoader.MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fname,f2)
+ MEDLoader.MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fname,f11)
+ ##
+ f1r=MEDLoader.MEDLoader.ReadFieldNode(fname,"mesh",0,"f1",-1,-1);
+ self.assertTrue(f1.isEqual(f1r,1e-12,1e-12))
+ self.assertTrue(f1r.getArray().isEqual(MEDLoader.DataArrayDouble([0.,1.,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.,15.,16.,17.,18.,19.]),1e-12))
+ f2r=MEDLoader.MEDLoader.ReadFieldNode(fname,"mesh",0,"f2",-1,-1);
+ self.assertTrue(f2.isEqual(f2r,1e-12,1e-12))
+ self.assertTrue(f2r.getArray().isEqual(MEDLoader.DataArrayDouble([0.,3.,6.,9.,12.,15.,18.,21.,24.,27.,30.,33.,36.,39.,42.,45.,48.,51.,54.,57.]),1e-12))
+ f3r=MEDLoader.MEDLoader.ReadFieldNode(fname,"mesh",0,"f1",5,6);
+ self.assertTrue(f11.isEqual(f3r,1e-12,1e-12))
+ self.assertTrue(f3r.getArray().isEqual(MEDLoader.DataArrayDouble([0.,4.,8.,12.,16.,20.,24.,28.,32.,36.,40.,44.,48.,52.,56.,60.,64.,68.,72.,76.]),1e-12))
+ pass
pass
unittest.main()
self.assertTrue(m.getUnivNameWrStatus())
m.write(outFileName,2);
mm=MEDFileMesh.New(outFileName)
+ self.assertEqual([NORM_HEXA8],mm.getGeoTypesAtLevel(0))
self.assertTrue(isinstance(mm,MEDFileCMesh))
self.assertTrue(isinstance(mm.getUnivName(),str))
self.assertTrue(len(mm.getUnivName())!=0)
self.assertTrue(f_read.isEqual(f,1e-12,1e-12))
pass
+ def testLoadIfNecessaryOnFromScratchFields0(self):
+ """
+ This test checks that a call to loadArraysIfNecessary works (does nothing) on field data structure whatever its level 1TS, MTS, Fields.
+ """
+ fname="Pyfile77.med"
+ coords=DataArrayDouble([(0,0,0),(2,1,0),(1,0,0),(1,1,0),(2,0,0),(0,1,0)])
+ m=MEDCouplingUMesh("mesh",2) ; m.setCoords(coords)
+ m.allocateCells()
+ m.insertNextCell(NORM_QUAD4,[0,5,3,2])
+ m.insertNextCell(NORM_QUAD4,[4,2,3,1])
+ m.finishInsertingCells()
+ #
+ mm=MEDFileUMesh() ; mm.setMeshAtLevel(0,m)
+ ms=MEDFileMeshes() ; ms.pushMesh(mm)
+ fs=MEDFileFields()
+ arrs=4*[None]
+ #
+ ff0=MEDFileFieldMultiTS() ; fs.pushField(ff0)
+ f0=MEDCouplingFieldDouble(ON_GAUSS_NE) ; f0.setMesh(m) ; f0.setTimeUnit("ms")
+ f0.setTime(1.1,1,1)
+ f0.setName("myELNOField")
+ arrs[0]=DataArrayDouble([7,5,3,1,5,3,1,7]) ; arrs[0].setInfoOnComponent(0,"Comp0")
+ f0.setArray(arrs[0])
+ ff0.appendFieldNoProfileSBT(f0)
+ #
+ f0.setTime(2.2,2,1)
+ arrs[1]=DataArrayDouble([1,7,5,3,7,5,3,1]) ; arrs[1].setInfoOnComponent(0,"Comp0")
+ f0.setArray(arrs[1])
+ ff0.appendFieldNoProfileSBT(f0)
+ #
+ f0.setTime(3.3,3,1)
+ arrs[2]=DataArrayDouble([3,1,7,5,1,7,5,3]) ; arrs[2].setInfoOnComponent(0,"Comp0")
+ f0.setArray(arrs[2])
+ ff0.appendFieldNoProfileSBT(f0)
+ #
+ f0.setTime(4.4,4,1)
+ arrs[3]=DataArrayDouble([5,3,1,7,3,1,7,5]) ; arrs[3].setInfoOnComponent(0,"Comp0")
+ f0.setArray(arrs[3])
+ ff0.appendFieldNoProfileSBT(f0)
+ #
+ for i,arr in enumerate(arrs):
+ self.assertTrue(fs[0][i].getUndergroundDataArray().isEqual(arr,1e-12))
+ fs[0][i].loadArraysIfNecessary()
+ self.assertTrue(fs[0][i].getUndergroundDataArray().isEqual(arr,1e-12))
+ pass
+ fs.loadArraysIfNecessary()
+ for i,arr in enumerate(arrs):
+ self.assertTrue(fs[0][i].getUndergroundDataArray().isEqual(arr,1e-12))
+ pass
+ fs[0].loadArraysIfNecessary()
+ for i,arr in enumerate(arrs):
+ self.assertTrue(fs[0][i].getUndergroundDataArray().isEqual(arr,1e-12))
+ pass
+ pass
+
+ def testField1TSSetFieldNoProfileSBTPerGeoTypes(self):
+ """ This test is very important, because the same mechanism is used by the MEDReader to generate a field on all the mesh without any processing and memory.
+ """
+ fname="Pyfile78.med"
+ coords=DataArrayDouble([-0.3,-0.3,0., 0.2,-0.3,0., 0.7,-0.3,0., -0.3,0.2,0., 0.2,0.2,0., 0.7,0.2,0., -0.3,0.7,0., 0.2,0.7,0., 0.7,0.7,0. ],9,3)
+ targetConn=[0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4];
+ m0=MEDCouplingUMesh("mesh",3) ; m0.setCoords(coords)
+ m0.allocateCells()
+ for elt in [[0,1,2,3],[1,2,3,4],[2,3,4,5],[3,4,5,6],[4,5,6,7],[5,6,7,8]]:#6
+ m0.insertNextCell(NORM_TETRA4,elt)
+ pass
+ for elt in [[0,1,2,3,4],[1,2,3,4,5],[2,3,4,5,6],[3,4,5,6,7],[4,5,6,7,8]]:#5
+ m0.insertNextCell(NORM_PYRA5,elt)
+ pass
+ for elt in [[0,1,2,3,4,5],[1,2,3,4,5,6],[2,3,4,5,6,7],[3,4,5,6,7,8]]:#4
+ m0.insertNextCell(NORM_PENTA6,elt)
+ pass
+ m0.checkCoherency2()
+ m1=MEDCouplingUMesh(); m1.setName("mesh")
+ m1.setMeshDimension(2);
+ m1.allocateCells(5);
+ m1.insertNextCell(NORM_TRI3,3,targetConn[4:7]);
+ m1.insertNextCell(NORM_TRI3,3,targetConn[7:10]);
+ m1.insertNextCell(NORM_QUAD4,4,targetConn[0:4]);
+ m1.insertNextCell(NORM_QUAD4,4,targetConn[10:14]);
+ m1.insertNextCell(NORM_QUAD4,4,targetConn[14:18]);
+ m1.setCoords(coords);
+ m3=MEDCouplingUMesh("mesh",0) ; m3.setCoords(coords)
+ m3.allocateCells()
+ m3.insertNextCell(NORM_POINT1,[2])
+ m3.insertNextCell(NORM_POINT1,[3])
+ m3.insertNextCell(NORM_POINT1,[4])
+ m3.insertNextCell(NORM_POINT1,[5])
+ #
+ mm=MEDFileUMesh()
+ mm.setMeshAtLevel(0,m0)
+ mm.setMeshAtLevel(-1,m1)
+ mm.setMeshAtLevel(-3,m3)
+ mm.write(fname,2)
+ #### The file is written only with one mesh and no fields. Let's put a field on it geo types per geo types.
+ mm=MEDFileMesh.New(fname)
+ fs=MEDFileFields()
+ fmts=MEDFileFieldMultiTS()
+ f1ts=MEDFileField1TS()
+ for lev in mm.getNonEmptyLevels():
+ for gt in mm.getGeoTypesAtLevel(lev):
+ p0=mm.getDirectUndergroundSingleGeoTypeMesh(gt)
+ f=MEDCouplingFieldDouble(ON_CELLS) ; f.setMesh(p0)
+ arr=DataArrayDouble(f.getNumberOfTuplesExpected()) ; arr.iota()
+ f.setArray(arr) ; f.setName("f0")
+ f1ts.setFieldNoProfileSBT(f)
+ pass
+ pass
+ self.assertEqual(mm.getNonEmptyLevels(),(0,-1,-3))
+ for lev in [0,-1,-3]:
+ mm.getDirectUndergroundSingleGeoTypeMeshes(lev) # please let this line, it is for the test to emulate that
+ pass
+ fmts.pushBackTimeStep(f1ts)
+ fs.pushField(fmts)
+ fs.write(fname,0)
+ del fs,fmts,f1ts
+ #### The file contains now one mesh and one cell field with all cells wathever their level ang type fetched.
+ fs=MEDFileFields(fname)
+ self.assertEqual(len(fs),1)
+ self.assertEqual(len(fs[0]),1)
+ f1ts=fs[0][0]
+ self.assertEqual(f1ts.getFieldSplitedByType(),[(0,[(0,(0,4),'','')]),(3,[(0,(4,6),'','')]),(4,[(0,(6,9),'','')]),(14,[(0,(9,15),'','')]),(15,[(0,(15,20),'','')]),(16,[(0,(20,24),'','')])])
+ self.assertTrue(f1ts.getUndergroundDataArray().isEqual(DataArrayDouble([0,1,2,3,0,1,0,1,2,0,1,2,3,4,5,0,1,2,3,4,0,1,2,3]),1e-12))
+ pass
+
+ def testMEDFileUMeshSetName(self):
+ """ This test is a small but important one for MEDReader in sauv mode. When .sauv file is loaded the convertion is performed in memory and a preparation is done then.
+ This preparation makes access to internal MEDCouplingMesh pointers whose name must be updated.
+ """
+ fname="Pyfile79.med"
+ targetConn=[0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4];
+ mm=MEDFileUMesh()
+ m0=MEDCouplingUMesh() ; m0.setMeshDimension(2) # important no name here.
+ coords=DataArrayDouble([-0.3,-0.3,0., 0.2,-0.3,0., 0.7,-0.3,0., -0.3,0.2,0., 0.2,0.2,0., 0.7,0.2,0., -0.3,0.7,0., 0.2,0.7,0., 0.7,0.7,0. ],9,3)
+ m0.allocateCells(5);
+ m0.insertNextCell(NORM_TRI3,3,targetConn[4:7]);
+ m0.insertNextCell(NORM_TRI3,3,targetConn[7:10]);
+ m0.insertNextCell(NORM_QUAD4,4,targetConn[0:4]);
+ m0.insertNextCell(NORM_QUAD4,4,targetConn[10:14]);
+ m0.insertNextCell(NORM_QUAD4,4,targetConn[14:18]);
+ m0.setCoords(coords);
+ mm.setMeshAtLevel(0,m0)
+ m2=MEDCouplingUMesh() ; m2.setMeshDimension(0) ; m2.setCoords(coords) # important no name here.
+ m2.allocateCells()
+ m2.insertNextCell(NORM_POINT1,[2])
+ m2.insertNextCell(NORM_POINT1,[3])
+ m2.insertNextCell(NORM_POINT1,[4])
+ m2.insertNextCell(NORM_POINT1,[5])
+ mm.setMeshAtLevel(-2,m2)
+ self.assertEqual(mm.getName(),"")
+ self.assertEqual(mm.getMeshAtLevel(0).getName(),"")
+ mm.forceComputationOfParts()
+ self.assertEqual(mm.getDirectUndergroundSingleGeoTypeMesh(NORM_TRI3).getName(),"")
+ mm.setName("abc")
+ self.assertEqual(mm.getName(),"abc")
+ self.assertEqual(mm.getDirectUndergroundSingleGeoTypeMesh(NORM_TRI3).getName(),"abc")
+ self.assertEqual(mm.getDirectUndergroundSingleGeoTypeMesh(NORM_QUAD4).getName(),"abc")
+ self.assertEqual(mm.getDirectUndergroundSingleGeoTypeMesh(NORM_POINT1).getName(),"abc")
+ self.assertEqual(mm.getMeshAtLevel(0).getName(),"abc")
+ pass
+
pass
unittest.main()
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([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(a1.isEqual(DataArrayByte([5,5,5,5,9,9,9,9,9,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])))
+ self.assertTrue(a2.isEqual(DataArrayInt([0,4,8,12,16,21,26,31,36,41,44,47,50,53,56,59,62,65,68,71,74,77,80,83,86,89,92,95,98,101,104,107,110,113,116,119,122,125,128,131,134])))
+ 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,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])))
self.assertTrue(a4 is None)
self.assertTrue(a5 is None)
for i in xrange(2):
fcscp=allFMTSLeavesPerCommonSupport[0][1]
mml=fcscp.buildFromScratchDataSetSupport(0,fields)
mml2=mml.prepare()
- a,b=mml2.buildVTUArrays()
+ (a,b),c=mml2.buildVTUArrays()
+ self.assertTrue(c)# c is True here because the returned array is directly those coming from internal structure
self.assertTrue(a.isEqual(coordsX,1e-12))
self.assertTrue(b.isEqual(coordsY,1e-12))
self.assertTrue(isinstance(mml2,MEDCMeshMultiLev))
mml=fcscp.buildFromScratchDataSetSupport(0,fields)
mml2=mml.prepare()
self.assertTrue(isinstance(mml2,MEDCMeshMultiLev)) # here the 2nd support is a part of CMesh that is also a CMesh -> CMesh not a UMesh
- a,b=mml2.buildVTUArrays()
+ (a,b),c=mml2.buildVTUArrays()
+ self.assertTrue(not c)# c is False because this a sub support specialy built for buildVTUArrays
self.assertTrue(a.isEqual(coordsX[[2,3,4]],1e-12))
self.assertTrue(b.isEqual(coordsY,1e-12))
a6,a7=mml2.retrieveFamilyIdsOnCells()
mml=fcscp.buildFromScratchDataSetSupport(0,fields)
mml2=mml.prepare()
self.assertTrue(isinstance(mml2,MEDCurveLinearMeshMultiLev))
- a,b=mml2.buildVTUArrays()
+ a,b,c=mml2.buildVTUArrays()
+ self.assertTrue(c)#True here because a is directly coming from internal data without copy
self.assertTrue(a.isEqual(a0Exp,1e-12))
self.assertEqual(b,[5,3])
a6,a7=mml2.retrieveFamilyIdsOnCells()
mml=fcscp.buildFromScratchDataSetSupport(0,fields)
mml2=mml.prepare()
self.assertTrue(isinstance(mml2,MEDCurveLinearMeshMultiLev)) # here the 2nd support is a part of CMesh that is also a CMesh -> CMesh not a UMesh
- a,b=mml2.buildVTUArrays()
+ a,b,c=mml2.buildVTUArrays()
+ self.assertTrue(not c)#False here because a is the result of a computation not the internal strucutre
self.assertTrue(a.isEqual(a0Exp[pfl2],1e-12))
self.assertEqual(b,[3,3])
a6,a7=mml2.retrieveFamilyIdsOnCells()
fNode.setName(fieldName2) ; fNode.setMesh(m)
fNode.setGaussLocalizationOnCells([0,1,2,3],[0.,0.,1.,0.,0.,1.],[0.5,0.5,0.7,0.7],[0.8,0.2])
fNode.setGaussLocalizationOnCells([4,5],[0.,0.,1.,0.,0.,1.],[0.5,0.5,0.7,0.7,0.1,0.1,0.2,0.2,0.3,0.3],[0.8,0.05,0.1,0.04,0.01])
- fNode.setGaussLocalizationOnCells([6,7,8],[0.,0.,1.,0.,1.,1.,0.,1.],[0.5,0.5,0.7,0.7,0.1,0.1,0.2,0.2],[0.8,0.05,0.1,0.04])
- fNode.setGaussLocalizationOnCells([9,10],[0.,0.,1.,0.,1.,1.,0.,1.],[0.5,0.5,0.7,0.7,0.1,0.1,0.2,0.2,0.3,0.3,0.4,0.4,0.8,0.8],[0.8,0.05,0.1,0.01,0.02,0.005,0.005])
+ fNode.setGaussLocalizationOnCells([6,7,8],[-1.,-1.,1.,-1.,1.,1.,-1.,1.],[0.5,0.5,0.7,0.7,0.1,0.1,0.2,0.2],[0.8,0.05,0.1,0.04])
+ fNode.setGaussLocalizationOnCells([9,10],[-1.,-1.,1.,-1.,1.,1.,-1.,1.],[0.5,0.5,0.7,0.7,0.1,0.1,0.2,0.2,0.3,0.3,0.4,0.4,0.8,0.8],[0.8,0.05,0.1,0.01,0.02,0.005,0.005])
arr=DataArrayDouble(2*(4*2+2*5+3*4+2*7)) ; arr.iota(300+1000*i) ; arr.rearrange(2)
fNode.setArray(arr) ; arr.setInfoOnComponents(["Comp1_2 [m]","Com2_2 [s^2]"]) ; fNode.checkCoherency()
f.setFieldNoProfileSBT(fNode)
fNode.setName(fieldName2) ; fNode.setMesh(m[pfl1])
fNode.setGaussLocalizationOnCells([0],[0.,0.,1.,0.,0.,1.],[0.5,0.5,0.7,0.7],[0.8,0.2])
fNode.setGaussLocalizationOnCells([1],[0.,0.,1.,0.,0.,1.],[0.5,0.5,0.7,0.7,0.1,0.1,0.2,0.2,0.3,0.3],[0.8,0.05,0.1,0.04,0.01])
- fNode.setGaussLocalizationOnCells([2,3],[0.,0.,1.,0.,1.,1.,0.,1.],[0.5,0.5,0.7,0.7,0.1,0.1,0.2,0.2],[0.8,0.05,0.1,0.04])
- fNode.setGaussLocalizationOnCells([4],[0.,0.,1.,0.,1.,1.,0.,1.],[0.5,0.5,0.7,0.7,0.1,0.1,0.2,0.2,0.3,0.3,0.4,0.4,0.8,0.8],[0.8,0.05,0.1,0.01,0.02,0.005,0.005])
+ fNode.setGaussLocalizationOnCells([2,3],[-1.,-1.,1.,-1.,1.,1.,-1.,1.],[0.5,0.5,0.7,0.7,0.1,0.1,0.2,0.2],[0.8,0.05,0.1,0.04])
+ fNode.setGaussLocalizationOnCells([4],[-1.,-1.,1.,-1.,1.,1.,-1.,1.],[0.5,0.5,0.7,0.7,0.1,0.1,0.2,0.2,0.3,0.3,0.4,0.4,0.8,0.8],[0.8,0.05,0.1,0.01,0.02,0.005,0.005])
arr=DataArrayDouble(2*(2*1+5*1+4*2+7*1)) ; arr.iota(300+1000*i) ; arr.rearrange(2)
fNode.setArray(arr) ; arr.setInfoOnComponents(["Comp1_2 [m]","Com2_2 [s^2]"]) ; fNode.checkCoherency()
f.setFieldProfile(fNode,mm,0,pfl1)
f=MEDFileField1TS()
fNode=MEDCouplingFieldDouble(ON_GAUSS_PT) ; fNode.setTime(float(i),i,0)
fNode.setName(fieldName0) ; fNode.setMesh(m)
- fNode.setGaussLocalizationOnCells([0,2,3,4,7,15],[0.,0.,1.,0.,1.,1.,0.,1.],[0.5,0.5,0.7,0.7],[0.8,0.2])
- fNode.setGaussLocalizationOnCells([1,5,8,9],[0.,0.,1.,0.,1.,1.,0.,1.],[0.5,0.5,0.7,0.7,0.1,0.1,0.2,0.2,0.3,0.3],[0.8,0.05,0.1,0.04,0.01])
- fNode.setGaussLocalizationOnCells([6,10,13],[0.,0.,1.,0.,1.,1.,0.,1.],[0.5,0.5,0.7,0.7,0.1,0.1,0.2,0.2],[0.8,0.05,0.1,0.04])
- fNode.setGaussLocalizationOnCells([11,12,14],[0.,0.,1.,0.,1.,1.,0.,1.],[0.5,0.5,0.7,0.7,0.1,0.1,0.2,0.2,0.3,0.3,0.4,0.4,0.8,0.8],[0.8,0.05,0.1,0.01,0.02,0.005,0.005])
+ fNode.setGaussLocalizationOnCells([0,2,3,4,7,15],[-1.,-1.,1.,-1.,1.,1.,-1.,1.],[0.5,0.5,0.7,0.7],[0.8,0.2])
+ fNode.setGaussLocalizationOnCells([1,5,8,9],[-1.,-1.,1.,-1.,1.,1.,-1.,1.],[0.5,0.5,0.7,0.7,0.1,0.1,0.2,0.2,0.3,0.3],[0.8,0.05,0.1,0.04,0.01])
+ fNode.setGaussLocalizationOnCells([6,10,13],[-1.,-1.,1.,-1.,1.,1.,-1.,1.],[0.5,0.5,0.7,0.7,0.1,0.1,0.2,0.2],[0.8,0.05,0.1,0.04])
+ fNode.setGaussLocalizationOnCells([11,12,14],[-1.,-1.,1.,-1.,1.,1.,-1.,1.],[0.5,0.5,0.7,0.7,0.1,0.1,0.2,0.2,0.3,0.3,0.4,0.4,0.8,0.8],[0.8,0.05,0.1,0.01,0.02,0.005,0.005])
arr=DataArrayDouble(2*(2*6+5*4+4*3+7*3)) ; arr.iota(0+1000*i) ; arr.rearrange(2)
fNode.setArray(arr) ; arr.setInfoOnComponents(["Comp1_0 [m]","Com2_0 [s^2]"]) ; fNode.checkCoherency()
f.setFieldNoProfileSBT(fNode)
f=MEDFileField1TS()
fNode=MEDCouplingFieldDouble(ON_GAUSS_PT) ; fNode.setTime(float(i),i,0)
fNode.setName(fieldName0) ; fNode.setMesh(m)
- fNode.setGaussLocalizationOnCells([0,2,3,4,7,15],[0.,0.,1.,0.,1.,1.,0.,1.],[0.5,0.5,0.7,0.7],[0.8,0.2])
- fNode.setGaussLocalizationOnCells([1,5,8,9],[0.,0.,1.,0.,1.,1.,0.,1.],[0.5,0.5,0.7,0.7,0.1,0.1,0.2,0.2,0.3,0.3],[0.8,0.05,0.1,0.04,0.01])
- fNode.setGaussLocalizationOnCells([6,10,13],[0.,0.,1.,0.,1.,1.,0.,1.],[0.5,0.5,0.7,0.7,0.1,0.1,0.2,0.2],[0.8,0.05,0.1,0.04])
- fNode.setGaussLocalizationOnCells([11,12,14],[0.,0.,1.,0.,1.,1.,0.,1.],[0.5,0.5,0.7,0.7,0.1,0.1,0.2,0.2,0.3,0.3,0.4,0.4,0.8,0.8],[0.8,0.05,0.1,0.01,0.02,0.005,0.005])
+ fNode.setGaussLocalizationOnCells([0,2,3,4,7,15],[-1.,-1.,1.,-1.,1.,1.,-1.,1.],[0.5,0.5,0.7,0.7],[0.8,0.2])
+ fNode.setGaussLocalizationOnCells([1,5,8,9],[-1.,-1.,1.,-1.,1.,1.,-1.,1.],[0.5,0.5,0.7,0.7,0.1,0.1,0.2,0.2,0.3,0.3],[0.8,0.05,0.1,0.04,0.01])
+ fNode.setGaussLocalizationOnCells([6,10,13],[-1.,-1.,1.,-1.,1.,1.,-1.,1.],[0.5,0.5,0.7,0.7,0.1,0.1,0.2,0.2],[0.8,0.05,0.1,0.04])
+ fNode.setGaussLocalizationOnCells([11,12,14],[-1.,-1.,1.,-1.,1.,1.,-1.,1.],[0.5,0.5,0.7,0.7,0.1,0.1,0.2,0.2,0.3,0.3,0.4,0.4,0.8,0.8],[0.8,0.05,0.1,0.01,0.02,0.005,0.005])
arr=DataArrayDouble(2*(2*6+5*4+4*3+7*3)) ; arr.iota(0+1000*i) ; arr.rearrange(2)
fNode.setArray(arr) ; arr.setInfoOnComponents(["Comp1_0 [m]","Com2_0 [s^2]"]) ; fNode.checkCoherency()
f.setFieldNoProfileSBT(fNode)
mst=MEDFileMeshStruct.New(ms[0])
#
fcscp=allFMTSLeavesPerCommonSupport1[0][1]
+ self.assertEqual([NORM_QUAD4],fcscp.getGeoTypesAt(0,ms[0]))
mml=fcscp.buildFromScratchDataSetSupport(0,fields)
mml2=mml.prepare()
self.assertTrue(isinstance(mml2,MEDUMeshMultiLev))
self.assertTrue(v.isEqual(vExp,1e-12))
pass
pass
+
+ def test21(self):
+ """ Here the created MED file contains only a mesh. The aim here is to test capability of MEDReader to support no fields.
+ This test checks nothing but write a MED file to be used by MEDReader tests.
+ """
+ fname="ForMEDReader21.med"
+ mm=MEDFileUMesh()
+ #
+ m0=MEDCouplingCMesh("mesh") ; arr=DataArrayDouble(5) ; arr.iota() ; m0.setCoords(arr,arr) ; m0=m0.buildUnstructured()
+ mm.setMeshAtLevel(0,m0)
+ grp0=DataArrayInt([5,6,9,10]) ; grp0.setName("Inside2D")
+ grp1=DataArrayInt([0,1,2,3,4,7,8,11,12,13,14,15]) ; grp1.setName("Border2D")
+ grp2=DataArrayInt([2,3,6,7]) ; grp2.setName("LowerRight2D")
+ mm.setGroupsAtLevel(0,[grp0,grp1,grp2])
+ #
+ m1=MEDCouplingUMesh(m0.getName(),1) ; m1.setCoords(m0.getCoords()) ; m1.allocateCells()
+ for elt in [[0,1],[1,2],[2,3],[3,4],[4,9],[9,14],[14,19],[19,24],[24,23],[23,22],[22,21],[21,20],[20,15],[15,10],[10,5],[5,0],[2,7],[7,12],[12,17],[17,22],
+ [10,11],[11,12],[12,13],[13,14]]:
+ m1.insertNextCell(NORM_SEG2,elt)
+ pass
+ mm.setMeshAtLevel(-1,m1)
+ grp4=DataArrayInt([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]) ; grp4.setName("Border1D")
+ grp5=DataArrayInt([16,17,18,19,20,21,22,23]) ; grp5.setName("Inside1D")
+ grp6=DataArrayInt([18,19,22,23]) ; grp6.setName("UpperRight1D")
+ mm.setGroupsAtLevel(-1,[grp4,grp5,grp6])
+ #
+ grp7=DataArrayInt([1,2,3,6,7,8,11,12,13,16,17,18,21,22,23]) ; grp7.setName("InsideYNode")
+ grp8=DataArrayInt([5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]) ; grp8.setName("InsideXNode")
+ mm.setGroupsAtLevel(1,[grp7,grp8])
+ #
+ mm.write(fname,2)
+ pass
+
+ def test22(self):
+ """ Use case where a field on nodes (ANodeField) on a mesh defined both in meshdim 2 and meshdim 1.
+ The only possible geometrical support that suits the field is those with meshdim equal to 1 (-1 in relative).
+ """
+ fname="ForMEDReader22.med"
+ fieldName0="ANodeField"
+ mm=MEDFileUMesh()
+ coo=DataArrayDouble([(4.,3.),(7.,3.),(2.,5.),(6.,5.),(9.,5.),(4.,7.),(8.,7.),(3.,8.),(9.,8.)])
+ m0=MEDCouplingUMesh("mesh",2) ; m0.setCoords(coo) ; m0.allocateCells() ; m0.insertNextCell(NORM_TRI3,[2,3,0]) ; m0.insertNextCell(NORM_TRI3,[3,1,0]) ; m0.insertNextCell(NORM_TRI3,[3,4,1])
+ mm.setMeshAtLevel(0,m0)
+ m1=MEDCouplingUMesh("mesh",1) ; m1.setCoords(coo) ; m1.allocateCells() ; m1.insertNextCell(NORM_SEG2,[2,0]) ; m1.insertNextCell(NORM_SEG2,[0,1]) ; m1.insertNextCell(NORM_SEG2,[1,4])
+ m1.insertNextCell(NORM_SEG2,[3,5]) ; m1.insertNextCell(NORM_SEG2,[5,7]) ; m1.insertNextCell(NORM_SEG2,[3,6]) ; m1.insertNextCell(NORM_SEG2,[6,8])
+ mm.setMeshAtLevel(-1,m1)
+ fs=MEDFileFields()
+ fmts0=MEDFileFieldMultiTS() ; fs.pushField(fmts0)
+ fmts0.setDtUnit("s")
+ #
+ t=(1.1,0,-2)
+ f0=MEDCouplingFieldDouble(ON_NODES) ; f0.setMesh(m1)
+ f0.setName(fieldName0) ; f0.setTime(*t)
+ da=DataArrayDouble(9) ; da.iota() ; da.setInfoOnComponents(["zeInfo"])
+ f0.setArray(da)
+ f0.checkCoherency()
+ f1ts=MEDFileField1TS()
+ f1ts.setFieldNoProfileSBT(f0)
+ fmts0.pushBackTimeStep(f1ts)
+ #
+ t=(2.1,1,-3)
+ f0=MEDCouplingFieldDouble(ON_NODES) ; f0.setMesh(m1)
+ f0.setName(fieldName0) ; f0.setTime(*t)
+ da=DataArrayDouble(9) ; da.iota() ; da.reverse() ; da.setInfoOnComponents(["zeInfo"])
+ f0.setArray(da)
+ f0.checkCoherency()
+ f1ts=MEDFileField1TS()
+ f1ts.setFieldNoProfileSBT(f0)
+ fmts0.pushBackTimeStep(f1ts)
+ #
+ mm.write(fname,2)
+ 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]),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]
+ self.assertEqual([NORM_TRI3,NORM_SEG2],fcscp.getGeoTypesAt(0,ms[0]))#contains all cell types of underlying mesh because only nodes with no profiles
+ 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([(4.,3.,0.),(7.,3.,0.),(2.,5.,0.),(6.,5.,0.),(9.,5.,0.),(4.,7.,0.),(8.,7.,0.),(3.,8.,0.),(9.,8.,0.)]),1e-12))
+ self.assertTrue(a1.isEqual(DataArrayByte([5,5,5,3,3,3,3,3,3,3])))
+ self.assertTrue(a2.isEqual(DataArrayInt([0,4,8,12,15,18,21,24,27,30])))
+ self.assertTrue(a3.isEqual(DataArrayInt([3,2,3,0,3,3,1,0,3,3,4,1,2,2,0,2,0,1,2,1,4,2,3,5,2,5,7,2,3,6,2,6,8])))
+ 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])))
+ self.assertTrue(not a7) # copy here
+ a8,a9=mml2.retrieveNumberIdsOnCells()
+ self.assertTrue(not a8)
+ self.assertTrue(a9) # nocopy 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
+ #
+ f=allFMTSLeavesPerCommonSupport1[0][0][0][0]
+ 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(9) ; vExp.iota() ; vExp.setInfoOnComponents(["zeInfo"])
+ self.assertTrue(v.isEqual(vExp,1e-12))
+ #
+ f=allFMTSLeavesPerCommonSupport1[0][0][0][1]
+ 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(9) ; vExp.iota() ; vExp.setInfoOnComponents(["zeInfo"]) ; vExp.reverse()
+ self.assertTrue(v.isEqual(vExp,1e-12))
+ pass
+
+ def test23(self):
+ """ Non regression test 2219 of modes. Idem than test22 except that here the node field is on profile.
+ """
+ fname="ForMEDReader23.med"
+ fieldName0="ANodeField"
+ mm=MEDFileUMesh()
+ coo=DataArrayDouble([(4.,3.),(7.,3.),(2.,5.),(6.,5.),(9.,5.),(4.,7.),(8.,7.),(3.,8.),(9.,8.)])
+ m0=MEDCouplingUMesh("mesh",2) ; m0.setCoords(coo) ; m0.allocateCells() ; m0.insertNextCell(NORM_TRI3,[2,3,0]) ; m0.insertNextCell(NORM_TRI3,[3,1,0]) ; m0.insertNextCell(NORM_TRI3,[3,4,1])
+ mm.setMeshAtLevel(0,m0)
+ m1=MEDCouplingUMesh("mesh",1) ; m1.setCoords(coo) ; m1.allocateCells() ; m1.insertNextCell(NORM_SEG2,[2,0]) ; m1.insertNextCell(NORM_SEG2,[0,1]) ; m1.insertNextCell(NORM_SEG2,[1,4])
+ m1.insertNextCell(NORM_SEG2,[3,5]) ; m1.insertNextCell(NORM_SEG2,[5,7]) ; m1.insertNextCell(NORM_SEG2,[3,6]) ; m1.insertNextCell(NORM_SEG2,[6,8])
+ mm.setMeshAtLevel(-1,m1)
+ fmts0=MEDFileFieldMultiTS()
+ fmts0.setDtUnit("s")
+ #
+ pfl=DataArrayInt([0,1,2,4]) ; pfl.setName("pfl")
+ pflCell=DataArrayInt([0,1,2]) ; m1Part=m1[pflCell] ; m1Part.zipCoords()
+ #
+ t=(1.1,0,-2)
+ f0=MEDCouplingFieldDouble(ON_NODES) ; f0.setMesh(m1Part)
+ f0.setName(fieldName0) ; f0.setTime(*t)
+ da=DataArrayDouble(4) ; da.iota() ; da.setInfoOnComponents(["zeInfo"])
+ f0.setArray(da)
+ f0.checkCoherency()
+ f1ts=MEDFileField1TS()
+ f1ts.setFieldProfile(f0,mm,-1,pfl)
+ fmts0.pushBackTimeStep(f1ts)
+ #
+ t=(2.1,1,-3)
+ f0=MEDCouplingFieldDouble(ON_NODES) ; f0.setMesh(m1Part)
+ f0.setName(fieldName0) ; f0.setTime(*t)
+ da=DataArrayDouble(4) ; da.iota() ; da.reverse() ; da.setInfoOnComponents(["zeInfo"])
+ f0.setArray(da)
+ f0.checkCoherency()
+ f1ts=MEDFileField1TS()
+ f1ts.setFieldProfile(f0,mm,-1,pfl)
+ fmts0.pushBackTimeStep(f1ts)
+ mm.write(fname,2)
+ fmts0.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(not ncc)
+ self.assertTrue(a0.isEqual(DataArrayDouble([(4.,3.,0.),(7.,3.,0.),(2.,5.,0.),(9.,5.,0.)]),1e-12))
+ self.assertTrue(a1.isEqual(DataArrayByte([3,3,3])))
+ self.assertTrue(a2.isEqual(DataArrayInt([0,3,6])))
+ self.assertTrue(a3.isEqual(DataArrayInt([2,2,0,2,0,1,2,1,3])))
+ self.assertTrue(a4 is None)
+ self.assertTrue(a5 is None)
+ a6,a7=mml2.retrieveFamilyIdsOnCells()
+ self.assertTrue(a6.isEqual(DataArrayInt([0,0,0])))
+ self.assertTrue(not a7) # copy here
+ a8,a9=mml2.retrieveNumberIdsOnCells()
+ self.assertTrue(not a8)
+ self.assertTrue(a9) # nocopy 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
+ #
+ f=allFMTSLeavesPerCommonSupport1[0][0][0][0]
+ fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst)
+ f.loadArraysIfNecessary()
+ v=mml.buildDataArray(fsst,fields,f.getUndergroundDataArray())
+ self.assertEqual(f.getName(),fieldName0)
+ vExp=DataArrayDouble(4) ; vExp.iota() ; vExp.setInfoOnComponents(["zeInfo"])
+ self.assertTrue(v.isEqual(vExp,1e-12))
+ #
+ f=allFMTSLeavesPerCommonSupport1[0][0][0][1]
+ fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst)
+ f.loadArraysIfNecessary()
+ v=mml.buildDataArray(fsst,fields,f.getUndergroundDataArray())
+ self.assertEqual(f.getName(),fieldName0)
+ vExp=DataArrayDouble(4) ; vExp.iota() ; vExp.setInfoOnComponents(["zeInfo"]) ; vExp.reverse()
+ self.assertTrue(v.isEqual(vExp,1e-12))
+ pass
+
+ def test24(self):
+ """ Non regression test for cartesian mesh whose the 3rd direction has only one node. It a false 3D mesh.
+ """
+ fname="ForMEDReader24.med"
+ fieldName0="zeFieldNode"
+ cmesh=MEDCouplingCMesh("mesh")
+ arr0=DataArrayDouble([0.,1.1,2.2,3.3,4.4])
+ arr1=DataArrayDouble([0.,1.4,2.3])
+ arr2=DataArrayDouble([5.])
+ cmesh.setCoords(arr0,arr1,arr2)
+ fmts0=MEDFileFieldMultiTS()
+ fmts0.setDtUnit("s")
+ #
+ t=(1.1,2,3)
+ f=MEDCouplingFieldDouble(ON_NODES) ; f.setName(fieldName0)
+ f.setMesh(cmesh)
+ arr=DataArrayDouble(15) ; arr.setInfoOnComponents(["tutu"]) ; arr.iota()
+ f.setArray(arr)
+ f.setTime(*t)
+ f1ts=MEDFileField1TS()
+ f1ts.setFieldNoProfileSBT(f)
+ fmts0.pushBackTimeStep(f1ts)
+ #
+ t=(3.3,4,5)
+ arr=DataArrayDouble(15) ; arr.setInfoOnComponents(["tutu"]) ; arr.iota()
+ arr.reverse()
+ f.setArray(arr)
+ f.setTime(*t)
+ f1ts=MEDFileField1TS()
+ f1ts.setFieldNoProfileSBT(f)
+ fmts0.pushBackTimeStep(f1ts)
+ #
+ mm=MEDFileCMesh() ; mm.setMesh(cmesh)
+ mm.write(fname,2)
+ fmts0.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)
+ allFMTSLeavesPerCommonSupport=MEDFileAnyTypeFieldMultiTS.SplitPerCommonSupport(allFMTSLeavesToDisplay[0],ms[ms.getMeshesNames()[0]])
+ self.assertEqual(len(allFMTSLeavesPerCommonSupport),1)
+ self.assertEqual(len(allFMTSLeavesPerCommonSupport[0][0]),1)
+ #
+ mst=MEDFileMeshStruct.New(ms[0])
+ #
+ fcscp=allFMTSLeavesPerCommonSupport[0][1]
+ mml=fcscp.buildFromScratchDataSetSupport(0,fields)
+ mml2=mml.prepare()
+ self.assertTrue(isinstance(mml2,MEDCMeshMultiLev))
+ (a,b,c),d=mml2.buildVTUArrays()
+ self.assertTrue(d)#d is True because the a,b and c are directly those in the internal data structure
+ self.assertTrue(a.isEqual(arr0,1e-12))
+ self.assertTrue(b.isEqual(arr1,1e-12))
+ self.assertTrue(c.isEqual(arr2,1e-12))
+ for i in xrange(2):
+ f=allFMTSLeavesPerCommonSupport[0][0][0][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(15) ; vExp.iota(0) ; vExp.setInfoOnComponents(["tutu"])
+ if i==1:
+ vExp.reverse()
+ pass
+ self.assertTrue(v.isEqual(vExp,1e-12))
+ pass
+ pass
+
+ def test25(self):
+ """ A tricky test that reproduces an invalid behaviour
+ Here a same field is defined both on CELLS and GAUSS_PT, with a profile for each.
+ The problem appears on array computation when performing CELLS then GAUSS_PT and CELLS again.
+ """
+ fname="ForMEDReader25.med"
+ m=MEDFileUMesh()
+ coords=DataArrayDouble([0.,0.,1.,0.,2.,0.,0.,1.,1.,1.,2.,1.,0.,2.,1.,2.,2.,2.,0.,3.,1.,3.,2.,3.,1.,4.,1.,5.,1.,6.],15,2)
+ m0=MEDCouplingUMesh("mesh",2) ; m0.setCoords(coords)
+ m0.allocateCells()
+ m0.insertNextCell(NORM_QUAD4,[0,3,4,1])
+ m0.insertNextCell(NORM_QUAD4,[1,4,5,2])
+ m0.insertNextCell(NORM_QUAD4,[3,6,7,4])
+ m0.insertNextCell(NORM_QUAD4,[4,7,8,5])
+ m0.insertNextCell(NORM_QUAD4,[6,9,10,7])
+ m0.insertNextCell(NORM_QUAD4,[7,10,11,8])
+ m.setMeshAtLevel(0,m0)
+ m1=MEDCouplingUMesh("mesh",1) ; m1.setCoords(coords)
+ m1.allocateCells()
+ m1.insertNextCell(NORM_SEG2,[10,12])
+ m1.insertNextCell(NORM_SEG2,[12,13])
+ m1.insertNextCell(NORM_SEG2,[13,14])
+ m.setMeshAtLevel(-1,m1)
+ m.setFamilyFieldArr(0,DataArrayInt([-1,-2,-3,-4,-5,-6]))
+ m.setFamilyFieldArr(-1,DataArrayInt([-7,-8,-9]))
+ m.setFamilyFieldArr(1,DataArrayInt([3,4,5,6,7,8,9,10,11,12,13,14,15,16,17]))
+ m.setRenumFieldArr(0,DataArrayInt([101,102,103,104,105,106]))
+ m.setRenumFieldArr(-1,DataArrayInt([107,108,109]))
+ m.setRenumFieldArr(1,DataArrayInt([203,204,205,206,207,208,209,210,211,212,213,214,215,216,217]))
+ #
+ fmts=MEDFileFieldMultiTS()
+ info0=["aa","bbb"]
+ name0="zeField"
+ pflName0="pfl"
+ pflName1="pfl2"
+ #
+ f1ts=MEDFileField1TS()
+ f=MEDCouplingFieldDouble(ON_CELLS) ; f.setName(name0)
+ arr=DataArrayDouble([(-1,-11),(-2,-22)]) ; arr.setInfoOnComponents(info0)
+ f.setArray(arr)
+ pfl0=DataArrayInt([0,1]) ; pfl0.setName(pflName0)
+ f1ts.setFieldProfile(f,m,-1,pfl0)
+ del f
+ f2=MEDCouplingFieldDouble(ON_GAUSS_PT) ; f2.setName(name0)
+ arr=DataArrayDouble(15) ; arr.iota(1)
+ arr=DataArrayDouble.Meld(arr,arr+10) ; arr.setInfoOnComponents(info0)
+ f2.setArray(arr)
+ pfl1=DataArrayInt([1,3,5]) ; pfl1.setName(pflName1)
+ tmp=m0[pfl1] ; f2.setMesh(tmp)
+ f2.setGaussLocalizationOnType(NORM_QUAD4,[-1.,-1.,1.,-1.,1.,1.,-1.,1.],[-0.5,-0.5,0.5,-0.5,0.5,0.5,-0.5,0.5,0.,0.],[0.1,0.1,0.1,0.1,0.6])
+ f2.checkCoherency()
+ f1ts.setFieldProfile(f2,m,0,pfl1)
+ fmts.pushBackTimeStep(f1ts)
+ #
+ m.write(fname,2)
+ fmts.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) # false is absolutely necessary for the test
+ 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)
+ ### here the test is important !!! Pointers must be different !
+ self.assertTrue(allFMTSLeavesToDisplay[0][0][0].getUndergroundDataArray().getHiddenCppPointer()!=allFMTSLeavesToDisplay[0][1][0].getUndergroundDataArray().getHiddenCppPointer())
+ allFMTSLeavesPerTimeSeries=MEDFileAnyTypeFieldMultiTS.SplitIntoCommonTimeSeries(sum(allFMTSLeavesToDisplay,[]))
+ self.assertEqual(len(allFMTSLeavesPerTimeSeries),1)
+ self.assertEqual(len(allFMTSLeavesPerTimeSeries[0]),2)
+ ### here the test is important !!! Pointers must be different !
+ self.assertTrue(allFMTSLeavesToDisplay[0][0][0].getUndergroundDataArray().getHiddenCppPointer()!=allFMTSLeavesToDisplay[0][1][0].getUndergroundDataArray().getHiddenCppPointer())
+ allFMTSLeavesPerCommonSupport1=MEDFileAnyTypeFieldMultiTS.SplitPerCommonSupport(allFMTSLeavesToDisplay[0],ms[ms.getMeshesNames()[0]])
+ self.assertTrue(allFMTSLeavesToDisplay[0][0][0].getUndergroundDataArray().getHiddenCppPointer()!=allFMTSLeavesToDisplay[0][1][0].getUndergroundDataArray().getHiddenCppPointer())
+ self.assertEqual(len(allFMTSLeavesPerCommonSupport1),2)
+ self.assertEqual(len(allFMTSLeavesPerCommonSupport1[0][0]),1)
+ self.assertEqual(len(allFMTSLeavesPerCommonSupport1[1][0]),1)
+ #
+ mst=MEDFileMeshStruct.New(ms[0])
+ # emulate first click
+ fcscp=allFMTSLeavesPerCommonSupport1[0][1]
+ self.assertEqual([NORM_SEG2],fcscp.getGeoTypesAt(0,ms[0]))
+ 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) # copy here because 2D -> 3D
+ expCoords=coords.changeNbOfComponents(3,0.)
+ self.assertTrue(a0.isEqual(expCoords,1e-12))
+ self.assertTrue(a1.isEqual(DataArrayByte([3,3])))
+ self.assertTrue(a2.isEqual(DataArrayInt([0,3])))
+ self.assertTrue(a3.isEqual(DataArrayInt([2,10,12,2,12,13])))
+ self.assertTrue(a4 is None)
+ self.assertTrue(a5 is None)
+ a6,a7=mml2.retrieveFamilyIdsOnCells()
+ self.assertTrue(a6.isEqual(DataArrayInt([-7,-8])))
+ self.assertTrue(not a7) # copy here because profile on cells
+ a8,a9=mml2.retrieveNumberIdsOnCells()
+ self.assertTrue(a8.isEqual(DataArrayInt([107,108])))
+ self.assertTrue(not a9) # copy here because profile on cells
+ a10,a11=mml2.retrieveFamilyIdsOnNodes()
+ self.assertTrue(a10.isEqual(DataArrayInt([3,4,5,6,7,8,9,10,11,12,13,14,15,16,17])))
+ self.assertTrue(a11) # no copy here
+ a12,a13=mml2.retrieveNumberIdsOnNodes()
+ self.assertTrue(a12.isEqual(DataArrayInt([203,204,205,206,207,208,209,210,211,212,213,214,215,216,217])))
+ self.assertTrue(a13) # no copy here
+ fff0=allFMTSLeavesPerCommonSupport1[0][0][0][0]
+ fsst=MEDFileField1TSStructItem.BuildItemFrom(fff0,mst)
+ fff0.loadArraysIfNecessary()
+ self.assertEqual([ON_CELLS],fff0.getTypesOfFieldAvailable())
+ v=mml.buildDataArray(fsst,fields,fff0.getUndergroundDataArray())
+ self.assertEqual(fff0.getName(),name0)
+ self.assertEqual(v.getHiddenCppPointer(),fff0.getUndergroundDataArray().getHiddenCppPointer())
+ vExp=DataArrayDouble([(-1,-11),(-2,-22)]) ; vExp.setInfoOnComponents(info0)
+ self.assertTrue(v.isEqual(vExp,1e-12))
+ del fff0
+ # emulate second click
+ fcscp=allFMTSLeavesPerCommonSupport1[1][1]
+ self.assertEqual([NORM_QUAD4],fcscp.getGeoTypesAt(0,ms[0]))
+ 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) # copy here because 2D -> 3D
+ expCoords=coords.changeNbOfComponents(3,0.)
+ self.assertTrue(a0.isEqual(expCoords,1e-12))
+ self.assertTrue(a1.isEqual(DataArrayByte([9,9,9])))
+ self.assertTrue(a2.isEqual(DataArrayInt([0,5,10])))
+ self.assertTrue(a3.isEqual(DataArrayInt([4,1,4,5,2,4,4,7,8,5,4,7,10,11,8])))
+ self.assertTrue(a4 is None)
+ self.assertTrue(a5 is None)
+ a6,a7=mml2.retrieveFamilyIdsOnCells()
+ self.assertTrue(a6.isEqual(DataArrayInt([-2,-4,-6])))
+ self.assertTrue(not a7) # copy here because profile on cells
+ a8,a9=mml2.retrieveNumberIdsOnCells()
+ self.assertTrue(a8.isEqual(DataArrayInt([102,104,106])))
+ self.assertTrue(not a9) # copy here because profile on cells
+ a10,a11=mml2.retrieveFamilyIdsOnNodes()
+ self.assertTrue(a10.isEqual(DataArrayInt([3,4,5,6,7,8,9,10,11,12,13,14,15,16,17])))
+ self.assertTrue(a11) # no copy here
+ a12,a13=mml2.retrieveNumberIdsOnNodes()
+ self.assertTrue(a12.isEqual(DataArrayInt([203,204,205,206,207,208,209,210,211,212,213,214,215,216,217])))
+ self.assertTrue(a13) # no copy here
+ fff1=allFMTSLeavesPerCommonSupport1[1][0][0][0]
+ fsst=MEDFileField1TSStructItem.BuildItemFrom(fff1,mst)
+ fff1.loadArraysIfNecessary()
+ self.assertEqual([ON_GAUSS_PT],fff1.getTypesOfFieldAvailable())
+ v=mml.buildDataArray(fsst,fields,fff1.getUndergroundDataArray())
+ self.assertEqual(fff1.getName(),name0)
+ self.assertEqual(v.getHiddenCppPointer(),fff1.getUndergroundDataArray().getHiddenCppPointer())
+ vExp=DataArrayDouble([1.,11.,2.,12.,3.,13.,4.,14.,5.,15.,6.,16.,7.,17.,8.,18.,9.,19.,10.,20.,11.,21.,12.,22.,13.,23.,14.,24.,15.,25.],15,2) ; vExp.setInfoOnComponents(info0)
+ self.assertTrue(v.isEqual(vExp,1e-12))
+ # emulate third click
+ 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) # copy here because 2D -> 3D
+ expCoords=coords.changeNbOfComponents(3,0.)
+ self.assertTrue(a0.isEqual(expCoords,1e-12))
+ self.assertTrue(a1.isEqual(DataArrayByte([3,3])))
+ self.assertTrue(a2.isEqual(DataArrayInt([0,3])))
+ self.assertTrue(a3.isEqual(DataArrayInt([2,10,12,2,12,13])))
+ self.assertTrue(a4 is None)
+ self.assertTrue(a5 is None)
+ a6,a7=mml2.retrieveFamilyIdsOnCells()
+ self.assertTrue(a6.isEqual(DataArrayInt([-7,-8])))
+ self.assertTrue(not a7) # copy here because profile on cells
+ a8,a9=mml2.retrieveNumberIdsOnCells()
+ self.assertTrue(a8.isEqual(DataArrayInt([107,108])))
+ self.assertTrue(not a9) # copy here because profile on cells
+ a10,a11=mml2.retrieveFamilyIdsOnNodes()
+ self.assertTrue(a10.isEqual(DataArrayInt([3,4,5,6,7,8,9,10,11,12,13,14,15,16,17])))
+ self.assertTrue(a11) # no copy here
+ a12,a13=mml2.retrieveNumberIdsOnNodes()
+ self.assertTrue(a12.isEqual(DataArrayInt([203,204,205,206,207,208,209,210,211,212,213,214,215,216,217])))
+ self.assertTrue(a13) # no copy here
+ fff0=allFMTSLeavesPerCommonSupport1[0][0][0][0]
+ fsst=MEDFileField1TSStructItem.BuildItemFrom(fff0,mst)
+ fff0.loadArraysIfNecessary()
+ self.assertEqual([ON_CELLS],fff0.getTypesOfFieldAvailable())
+ v=mml.buildDataArray(fsst,fields,fff0.getUndergroundDataArray())
+ self.assertEqual(fff0.getName(),name0)
+ self.assertEqual(v.getHiddenCppPointer(),fff0.getUndergroundDataArray().getHiddenCppPointer())
+ vExp=DataArrayDouble([(-1,-11),(-2,-22)]) ; vExp.setInfoOnComponents(info0)
+ self.assertTrue(v.isEqual(vExp,1e-12)) # <- THE test is here !!!
+ del fff0
+ pass
+
+ def test26(self):
+ """ Test focused on field on nodes (here f0Node and f1Node) lying on a profile of nodes that do not match perfectly a sub set of cells of its underlying mesh. See bug EDF 2405 and 2177.
+ For this type of fields the support will contain only vertices.
+ """
+ fname="ForMEDReader26.med"
+ coords=DataArrayDouble([(0.,0.,0.),(1.,0.,0.),(2.,0.,0.),(3.,0.,0.),(0.,1.,0.),(1.,1.,0.),(2.,1.,0.),(3.,1.,0.),(0.,2.,0.),(1.,2.,0.),(2.,2.,0.),(3.,2.,0.),(0.,3.,0.),(1.,3.,0.),(2.,3.,0.),(3.,3.,0.)])
+ m0=MEDCouplingUMesh("mesh",2)
+ m0.allocateCells()
+ for elt in [[2,6,3],[6,7,3],[9,6,5],[9,10,6]]:
+ m0.insertNextCell(NORM_TRI3,elt)
+ pass
+ for elt in [[0,4,5,1],[1,5,6,2],[4,8,9,5],[6,10,11,7],[8,12,13,9],[9,13,14,10],[10,14,15,11]]:
+ m0.insertNextCell(NORM_QUAD4,elt)
+ pass
+ m0.setCoords(coords)
+ ##
+ mm=MEDFileUMesh()
+ mm.setMeshAtLevel(0,m0)
+ mm.setFamilyFieldArr(0,DataArrayInt([-1,-2,-3,-4,-5,-6,-7,-8,-9,-10,-11]))
+ mm.setFamilyFieldArr(1,DataArrayInt([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]))
+ #
+ f1ts0Node=MEDFileField1TS()
+ f1ts1Node=MEDFileField1TS()
+ f1ts2Cell=MEDFileField1TS()
+ f1ts3Cell=MEDFileField1TS()
+ f1ts4Cell=MEDFileField1TS()
+ f1ts5Node=MEDFileField1TS()
+ #
+ pfl0=DataArrayInt([4,5,6,8,9,12]) ; pfl0.setName("pfl0")
+ pfl1=DataArrayInt([0,1,4,5,7,10]) ; pfl1.setName("pfl1")
+ pfl2=DataArrayInt([0,1,2,3,4,5,6,7,10,11,14,15]) ; pfl2.setName("pfl2")
+ #
+ f0Node=MEDCouplingFieldDouble(ON_NODES) ; f0Node.setName("f0Node")
+ arr0=DataArrayDouble(6) ; arr0.iota()
+ f0Node.setArray(arr0)
+ f1ts0Node.setFieldProfile(f0Node,mm,0,pfl0)
+ #
+ f1Node=MEDCouplingFieldDouble(ON_NODES) ; f1Node.setName("f1Node")
+ arr1=DataArrayDouble(6) ; arr1.iota() ; arr1.reverse()
+ f1Node.setArray(arr1)
+ f1ts1Node.setFieldProfile(f1Node,mm,0,pfl0)
+ #
+ f2Cell=MEDCouplingFieldDouble(ON_CELLS) ; f2Cell.setName("f2Cell")
+ arr2=DataArrayDouble([2,3,0,1,4,5])
+ f2Cell.setArray(arr2)
+ f1ts2Cell.setFieldProfile(f2Cell,mm,0,pfl1)
+ #
+ f3Cell=MEDCouplingFieldDouble(ON_CELLS) ; f3Cell.setName("f3Cell")
+ arr3=DataArrayDouble([5,4,3,2,1,0])
+ f3Cell.setArray(arr3)
+ f1ts3Cell.setFieldProfile(f3Cell,mm,0,pfl1)
+ #
+ f4Cell=MEDCouplingFieldDouble(ON_CELLS) ; f4Cell.setName("f4Cell")
+ arr4=DataArrayDouble([2,2,0,1,1,0])
+ f4Cell.setArray(arr4)
+ f1ts4Cell.setFieldProfile(f4Cell,mm,0,pfl1)
+ #
+ f5Node=MEDCouplingFieldDouble(ON_NODES) ; f5Node.setName("f5Node")
+ arr5=DataArrayDouble([0,1,2,3,10,11,13,2,11,1,10,0])
+ f5Node.setArray(arr5)
+ f1ts5Node.setFieldProfile(f5Node,mm,0,pfl2)
+ #
+ fs=MEDFileFields()
+ for f in [f1ts0Node,f1ts1Node,f1ts2Cell,f1ts3Cell,f1ts4Cell,f1ts5Node]:
+ fmts=MEDFileFieldMultiTS()
+ fmts.pushBackTimeStep(f)
+ fs.pushField(fmts)
+ pass
+ mm.write(fname,2)
+ 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]),6)
+ allFMTSLeavesPerTimeSeries=MEDFileAnyTypeFieldMultiTS.SplitIntoCommonTimeSeries(sum(allFMTSLeavesToDisplay,[]))
+ self.assertEqual(len(allFMTSLeavesPerTimeSeries),1)
+ self.assertEqual(len(allFMTSLeavesPerTimeSeries[0]),6)
+ allFMTSLeavesPerCommonSupport1=MEDFileAnyTypeFieldMultiTS.SplitPerCommonSupport(allFMTSLeavesToDisplay[0],ms[ms.getMeshesNames()[0]])
+ self.assertEqual(len(allFMTSLeavesPerCommonSupport1),2)
+ self.assertEqual(len(allFMTSLeavesPerCommonSupport1[0][0]),4)
+ self.assertEqual(len(allFMTSLeavesPerCommonSupport1[1][0]),2)# <- the smart one is here
+ #
+ mst=MEDFileMeshStruct.New(ms[0])
+ #
+ fcscp=allFMTSLeavesPerCommonSupport1[1][1]
+ mml=fcscp.buildFromScratchDataSetSupport(0,fields)
+ mml2=mml.prepare()
+ self.assertTrue(isinstance(mml2,MEDUMeshMultiLev))
+ self.assertEqual([3,4,0],mml2.getGeoTypes())
+ ncc,a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays()
+ self.assertTrue(not ncc)
+ self.assertTrue(a0.isEqual(DataArrayDouble([0.,1.,0.,1.,1.,0.,2.,1.,0.,0.,2.,0.,1.,2.,0.,0.,3.,0.],6,3),1e-12))
+ self.assertTrue(a1.isEqual(DataArrayByte([5,9,1])))
+ self.assertTrue(a2.isEqual(DataArrayInt([0,4,9])))
+ self.assertTrue(a3.isEqual(DataArrayInt([3,4,2,1,4,0,3,4,1,1,5])))
+ self.assertTrue(a4 is None)
+ self.assertTrue(a5 is None)
+ a6,a7=mml2.retrieveFamilyIdsOnCells()
+ self.assertTrue(a6.isEqual(DataArrayInt([-3,-7,13])))
+ self.assertTrue(not a7) # copy here because profile on cells
+ a8,a9=mml2.retrieveNumberIdsOnCells()
+ self.assertTrue(a8 is None)
+ self.assertTrue(a9) # no copy here because no number field
+ a10,a11=mml2.retrieveFamilyIdsOnNodes()
+ self.assertTrue(a10.isEqual(DataArrayInt([5,6,7,9,10,13])))
+ self.assertTrue(not a11) # copy here
+ a12,a13=mml2.retrieveNumberIdsOnNodes()
+ self.assertTrue(a12 is None)
+ self.assertTrue(a13) # no copy here because no number field
+ #
+ fff0=allFMTSLeavesPerCommonSupport1[1][0][0][0]
+ fsst=MEDFileField1TSStructItem.BuildItemFrom(fff0,mst)
+ fff0.loadArraysIfNecessary()
+ v=mml2.buildDataArray(fsst,fields,fff0.getUndergroundDataArray())
+ self.assertEqual(fff0.getName(),"f0Node")
+ self.assertEqual(v.getHiddenCppPointer(),fff0.getUndergroundDataArray().getHiddenCppPointer())
+ vExp=DataArrayDouble([0.,1.,2.,3.,4.,5.])
+ self.assertTrue(v.isEqual(vExp,1e-12)) # <- THE test is here !!!
+ #
+ fff1=allFMTSLeavesPerCommonSupport1[1][0][1][0]
+ fsst=MEDFileField1TSStructItem.BuildItemFrom(fff1,mst)
+ fff1.loadArraysIfNecessary()
+ v=mml2.buildDataArray(fsst,fields,fff1.getUndergroundDataArray())
+ self.assertEqual(fff1.getName(),"f1Node")
+ self.assertEqual(v.getHiddenCppPointer(),fff1.getUndergroundDataArray().getHiddenCppPointer())
+ vExp=DataArrayDouble([5.,4.,3.,2.,1.,0.])
+ self.assertTrue(v.isEqual(vExp,1e-12)) # <- THE test is here !!!
+ pass
+
+ def test27(self):
+ """ This test defines 2 fields f0 and f1 on nodes lying on an unstructured mesh with no cells.
+ f0 is a field on all nodes. f1 is a partial field on nodes.
+ """
+ fname="ForMEDReader27.med"
+ coords=DataArrayDouble([(0.,0.,0.),(1.,0.,0.),(2.,0.,0.),(3.,0.,0.),(0.,1.,0.),(1.,1.,0.),(2.,1.,0.),(3.,1.,0.),(0.,2.,0.),(1.,2.,0.),(2.,2.,0.),(3.,2.,0.),(0.,3.,0.),(1.,3.,0.),(2.,3.,0.),(3.,3.,0.)])
+ m0=MEDCouplingUMesh("mesh",2)
+ m0.allocateCells()
+ m0.setCoords(coords)
+ ##
+ mm=MEDFileUMesh()
+ mm.setMeshAtLevel(0,m0)
+ mm.setFamilyFieldArr(1,DataArrayInt([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]))
+ #
+ f1ts0=MEDFileField1TS()
+ f1ts1=MEDFileField1TS()
+ #
+ f0=MEDCouplingFieldDouble(ON_NODES) ; f0.setMesh(m0) ; f0.setName("f0NoPfl")
+ arr0=DataArrayDouble([0.,1.,2.,3.,1.,1.5,2.2,3.1,2.,2.2,3.,3.1,3.,3.1,3.5,4.])
+ f0.setArray(arr0)
+ f0.checkCoherency()
+ f1ts0.setFieldNoProfileSBT(f0)
+ self.assertEqual(f1ts0.getMeshName(),"mesh")
+ #
+ pfl1=DataArrayInt([0,1,2,3,4,5,6,8,9,12]) ; pfl1.setName("pfl1")
+ f1=MEDCouplingFieldDouble(ON_NODES) ; f1.setName("f1Pfl")
+ arr1=DataArrayDouble([3.,2.,1.,0.,2.,1.5,0.,1.,0.,0.2])
+ f1.setArray(arr1)
+ f1ts1.setFieldProfile(f1,mm,0,pfl1)
+ self.assertEqual(f1ts1.getMeshName(),"mesh")
+ #
+ fs=MEDFileFields()
+ fmts0=MEDFileFieldMultiTS()
+ fmts0.pushBackTimeStep(f1ts0)
+ fmts1=MEDFileFieldMultiTS()
+ fmts1.pushBackTimeStep(f1ts1)
+ fs.pushField(fmts0) ; fs.pushField(fmts1)
+ self.assertEqual(fs[0].getMeshName(),"mesh")
+ self.assertEqual(fs[1].getMeshName(),"mesh")
+ mm.write(fname,2)
+ 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)
+ self.assertEqual(fields[0].getMeshName(),"mesh")
+ self.assertEqual(fields[1].getMeshName(),"mesh")
+ fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()]
+ self.assertEqual(fields_per_mesh[0][0].getMeshName(),"mesh")
+ self.assertEqual(fields_per_mesh[0][1].getMeshName(),"mesh")
+ 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)
+ self.assertEqual(len(allFMTSLeavesPerTimeSeries[0]),2)
+ allFMTSLeavesPerCommonSupport1=MEDFileAnyTypeFieldMultiTS.SplitPerCommonSupport(allFMTSLeavesToDisplay[0],ms[ms.getMeshesNames()[0]])
+ self.assertEqual(len(allFMTSLeavesPerCommonSupport1),2)
+ self.assertEqual(len(allFMTSLeavesPerCommonSupport1[0][0]),1)
+ self.assertEqual(len(allFMTSLeavesPerCommonSupport1[1][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.),(3.,0.,0.),(0.,1.,0.),(1.,1.,0.),(2.,1.,0.),(3.,1.,0.),(0.,2.,0.),(1.,2.,0.),(2.,2.,0.),(3.,2.,0.),(0.,3.,0.),(1.,3.,0.),(2.,3.,0.),(3.,3.,0.)]),1e-12))
+ self.assertTrue(a1.isEqual(DataArrayByte([])))
+ self.assertTrue(a2.isEqual(DataArrayInt([])))
+ self.assertTrue(a3.isEqual(DataArrayInt([])))
+ self.assertTrue(a4 is None)
+ self.assertTrue(a5 is None)
+ #
+ fff0=allFMTSLeavesPerCommonSupport1[0][0][0][0]
+ fsst=MEDFileField1TSStructItem.BuildItemFrom(fff0,mst)
+ fff0.loadArraysIfNecessary()
+ v=mml2.buildDataArray(fsst,fields,fff0.getUndergroundDataArray())
+ self.assertEqual(fff0.getName(),"f0NoPfl")
+ self.assertEqual(v.getHiddenCppPointer(),fff0.getUndergroundDataArray().getHiddenCppPointer())
+ vExp=DataArrayDouble([0.,1.,2.,3.,1.,1.5,2.2,3.1,2.,2.2,3.,3.1,3.,3.1,3.5,4])
+ self.assertTrue(v.isEqual(vExp,1e-12))
+ #
+ 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(a0.isEqual(DataArrayDouble([(0,0,0),(1,0,0),(2,0,0),(3,0,0),(0,1,0),(1,1,0),(2,1,0),(0,2,0),(1,2,0),(0,3,0)]),1e-12))
+ self.assertTrue(a1.isEqual(DataArrayByte([])))
+ self.assertTrue(a2.isEqual(DataArrayInt([])))
+ self.assertTrue(a3.isEqual(DataArrayInt([])))
+ self.assertTrue(a4 is None)
+ self.assertTrue(a5 is None)
+ fff1=allFMTSLeavesPerCommonSupport1[1][0][0][0]
+ fsst=MEDFileField1TSStructItem.BuildItemFrom(fff1,mst)
+ fff1.loadArraysIfNecessary()
+ v=mml2.buildDataArray(fsst,fields,fff1.getUndergroundDataArray())
+ self.assertEqual(fff1.getName(),"f1Pfl")
+ self.assertNotEqual(v.getHiddenCppPointer(),fff1.getUndergroundDataArray().getHiddenCppPointer()) # pointers are not equal because Profile
+ vExp=DataArrayDouble([3.,2.,1.,0.,2.,1.5,0.,1.,0.,0.2])
+ self.assertTrue(v.isEqual(vExp,1e-12))
+ pass
+
+ def test28(self):
+ """ This test defines 2 fields f0,f1,f2,f3 lying on an unstructured mesh whith cells including NORM_POINT1.
+ Both f0 and f1 are on NODES and f2 and f3 are on cells. f1 and f2 share the same support.
+ f0 is on a nodal support that is not matchable with any cells (including NORM_POINT1)
+ This test is a more aggressive version of test26.
+ """
+ fname="ForMEDReader28.med"
+ coords=DataArrayDouble([(0.,0.,0.),(1.,0.,0.),(2.,0.,0.),(3.,0.,0.),(0.,1.,0.),(1.,1.,0.),(2.,1.,0.),(3.,1.,0.),(0.,2.,0.),(1.,2.,0.),(2.,2.,0.),(3.,2.,0.),(0.,3.,0.),(1.,3.,0.),(2.,3.,0.),(3.,3.,0.)])
+ m0=MEDCouplingUMesh("mesh",2)
+ m0.allocateCells()
+ for elt in [[2,6,3],[6,7,3],[9,6,5],[9,10,6]]:
+ m0.insertNextCell(NORM_TRI3,elt)
+ pass
+ for elt in [[0,4,5,1],[1,5,6,2],[4,8,9,5],[6,10,11,7],[8,12,13,9],[9,13,14,10],[10,14,15,11]]:
+ m0.insertNextCell(NORM_QUAD4,elt)
+ pass
+ m0.setCoords(coords)
+ m2=MEDCouplingUMesh("mesh",0) ; m2.setCoords(coords)
+ m2.allocateCells()
+ for elt in [[8],[13]]:
+ m2.insertNextCell(NORM_POINT1,elt)
+ pass
+ ##
+ mm=MEDFileUMesh()
+ mm.setMeshAtLevel(0,m0)
+ mm.setMeshAtLevel(-2,m2)
+ mm.setFamilyFieldArr(0,DataArrayInt([-1,-2,-3,-4,-5,-6,-7,-8,-9,-10,-11]))
+ mm.setFamilyFieldArr(-2,DataArrayInt([-12,-13]))
+ mm.setFamilyFieldArr(1,DataArrayInt([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]))
+ #
+ f1ts0Node=MEDFileField1TS()
+ f1ts1Node=MEDFileField1TS()
+ f1ts2Cell=MEDFileField1TS()
+ f1ts3Cell=MEDFileField1TS()
+ #
+ pfl0=DataArrayInt([4,5,6,8,9,12]) ; pfl0.setName("pfl0")
+ pfl1=DataArrayInt([0,1,4,5,7,10]) ; pfl1.setName("pfl1")
+ pfl2=DataArrayInt([0,1,2,3,4,5,6,7,10,11,14,15]) ; pfl2.setName("pfl2")
+ #
+ f0Node=MEDCouplingFieldDouble(ON_NODES) ; f0Node.setName("f0Node")
+ arr0=DataArrayDouble(6) ; arr0.iota()
+ f0Node.setArray(arr0)
+ f1ts0Node.setFieldProfile(f0Node,mm,0,pfl0)
+ #
+ f1Node=MEDCouplingFieldDouble(ON_NODES) ; f1Node.setName("f1Node")
+ arr1=DataArrayDouble(12) ; arr1.iota() ; arr1.reverse()
+ f1Node.setArray(arr1)
+ f1ts1Node.setFieldProfile(f1Node,mm,0,pfl2)
+ #
+ f2Cell=MEDCouplingFieldDouble(ON_CELLS) ; f2Cell.setName("f2Cell")
+ arr2=DataArrayDouble([2,3,0,1,4,5])
+ f2Cell.setArray(arr2)
+ f1ts2Cell.setFieldProfile(f2Cell,mm,0,pfl1)
+ #
+ f3Cell=MEDCouplingFieldDouble(ON_CELLS) ; f3Cell.setName("f3Cell")
+ arr3=DataArrayDouble([5,4,3,2,1,0]) ; f3Cell.setArray(arr3)
+ f1ts3Cell.setFieldProfile(f3Cell,mm,0,pfl1)
+ f3Cell.setMesh(m2)
+ arr3=DataArrayDouble([-1.1,-3.1]) ; f3Cell.setArray(arr3)
+ f1ts3Cell.setFieldNoProfileSBT(f3Cell)
+ #
+ fs=MEDFileFields()
+ for f in [f1ts0Node,f1ts1Node,f1ts2Cell,f1ts3Cell]:
+ fmts=MEDFileFieldMultiTS()
+ fmts.pushBackTimeStep(f)
+ fs.pushField(fmts)
+ pass
+ mm.write(fname,2)
+ 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),3)
+ self.assertEqual(len(allFMTSLeavesPerCommonSupport1[0][0]),2)
+ self.assertEqual(len(allFMTSLeavesPerCommonSupport1[1][0]),1)
+ self.assertEqual(len(allFMTSLeavesPerCommonSupport1[2][0]),1)
+ #
+ mst=MEDFileMeshStruct.New(ms[0])
+ #
+ fcscp=allFMTSLeavesPerCommonSupport1[2][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.,1.,0.,1.,1.,0.,2.,1.,0.,0.,2.,0.,1.,2.,0.,0.,3.,0.],6,3),1e-12))
+ self.assertTrue(a1.isEqual(DataArrayByte([5,9,1,1])))
+ self.assertTrue(a2.isEqual(DataArrayInt([0,4,9,11])))
+ self.assertTrue(a3.isEqual(DataArrayInt([3,4,2,1,4,0,3,4,1,1,3,1,5])))
+ self.assertTrue(a4 is None)
+ self.assertTrue(a5 is None)
+ a6,a7=mml2.retrieveFamilyIdsOnCells()
+ self.assertTrue(a6.isEqual(DataArrayInt([-3,-7,-12,13])))
+ self.assertTrue(not a7) # copy here because profile on cells
+ a8,a9=mml2.retrieveNumberIdsOnCells()
+ self.assertTrue(a8 is None)
+ self.assertTrue(a9) # no copy here because no number field
+ a10,a11=mml2.retrieveFamilyIdsOnNodes()
+ self.assertTrue(a10.isEqual(DataArrayInt([5,6,7,9,10,13])))
+ self.assertTrue(not a11) # copy here
+ a12,a13=mml2.retrieveNumberIdsOnNodes()
+ self.assertTrue(a12 is None)
+ self.assertTrue(a13) # no copy here because no number field
+ #
+ fff0=allFMTSLeavesPerCommonSupport1[2][0][0][0]
+ fsst=MEDFileField1TSStructItem.BuildItemFrom(fff0,mst)
+ fff0.loadArraysIfNecessary()
+ v=mml2.buildDataArray(fsst,fields,fff0.getUndergroundDataArray())
+ self.assertEqual(fff0.getName(),"f0Node")
+ self.assertEqual(v.getHiddenCppPointer(),fff0.getUndergroundDataArray().getHiddenCppPointer())
+ vExp=DataArrayDouble([0.,1.,2.,3.,4.,5.])
+ self.assertTrue(v.isEqual(vExp,1e-12)) # <- THE test is here !!!
+ ###
+ 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),(0,1,0),(1,1,0),(2,1,0),(3,1,0),(2,2,0),(3,2,0),(2,3,0),(3,3,0)]),1e-12))
+ self.assertTrue(a1.isEqual(DataArrayByte([5,5,9,9,9,9])))
+ self.assertTrue(a2.isEqual(DataArrayInt([0,4,8,13,18,23])))
+ self.assertTrue(a3.isEqual(DataArrayInt([3,2,6,3,3,6,7,3,4,0,4,5,1,4,1,5,6,2,4,6,8,9,7,4,8,10,11,9])))
+ self.assertTrue(a4 is None)
+ self.assertTrue(a5 is None)
+ fff1=allFMTSLeavesPerCommonSupport1[0][0][0][0]
+ fsst=MEDFileField1TSStructItem.BuildItemFrom(fff1,mst)
+ fff1.loadArraysIfNecessary()
+ v=mml2.buildDataArray(fsst,fields,fff1.getUndergroundDataArray())
+ self.assertEqual(fff1.getName(),"f2Cell")
+ self.assertNotEqual(v.getHiddenCppPointer(),fff0.getUndergroundDataArray().getHiddenCppPointer())
+ vExp=DataArrayDouble([2,3,0,1,4,5])
+ self.assertTrue(v.isEqual(vExp,1e-12))
+ fff2=allFMTSLeavesPerCommonSupport1[0][0][1][0]
+ fsst=MEDFileField1TSStructItem.BuildItemFrom(fff2,mst)
+ fff2.loadArraysIfNecessary()
+ v=mml2.buildDataArray(fsst,fields,fff2.getUndergroundDataArray())
+ self.assertEqual(fff2.getName(),"f1Node")
+ self.assertNotEqual(v.getHiddenCppPointer(),fff0.getUndergroundDataArray().getHiddenCppPointer())
+ vExp=DataArrayDouble([11,10,9,8,7,6,5,4,3,2,1,0])
+ self.assertTrue(v.isEqual(vExp,1e-12))
+ ###
+ 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(ncc)# here all the 16 nodes are taken
+ self.assertTrue(a0.isEqual(DataArrayDouble([(0.,0.,0.),(1.,0.,0.),(2.,0.,0.),(3.,0.,0.),(0.,1.,0.),(1.,1.,0.),(2.,1.,0.),(3.,1.,0.),(0.,2.,0.),(1.,2.,0.),(2.,2.,0.),(3.,2.,0.),(0.,3.,0.),(1.,3.,0.),(2.,3.,0.),(3.,3.,0.)]),1e-12))
+ self.assertTrue(a1.isEqual(DataArrayByte([1,1,5,5,9,9,9,9])))
+ self.assertTrue(a2.isEqual(DataArrayInt([0,2,4,8,12,17,22,27])))
+ self.assertTrue(a3.isEqual(DataArrayInt([1,8,1,13,3,2,6,3,3,6,7,3,4,0,4,5,1,4,1,5,6,2,4,6,10,11,7,4,10,14,15,11])))
+ self.assertTrue(a4 is None)
+ self.assertTrue(a5 is None)
+ fff3=allFMTSLeavesPerCommonSupport1[1][0][0][0]
+ fsst=MEDFileField1TSStructItem.BuildItemFrom(fff3,mst)
+ fff3.loadArraysIfNecessary()
+ v=mml2.buildDataArray(fsst,fields,fff3.getUndergroundDataArray())
+ self.assertEqual(fff3.getName(),"f3Cell")
+ self.assertNotEqual(v.getHiddenCppPointer(),fff0.getUndergroundDataArray().getHiddenCppPointer())
+ vExp=DataArrayDouble([-1.1,-3.1,5,4,3,2,1,0])
+ self.assertTrue(v.isEqual(vExp,1e-12))
+ pass
pass
unittest.main()
LOG("Deleting MEDDataManager_i instance");
}
-const char * MEDDataManager_i::file_to_source(const char * filepath)
+std::string MEDDataManager_i::file_to_source(const char * filepath)
{
- string * source = new string("file://");
- source->append(filepath);
- return source->c_str();;
+ string source("file://");
+ source.append(filepath);
+ return source;
}
-const char * MEDDataManager_i::source_to_file(const char * source)
+
+std::string MEDDataManager_i::source_to_file(const char * source)
{
- string * filepath = new string(source);
- filepath->replace(0,7,"");
- return filepath->c_str();
+ string filepath(source);
+ filepath.replace(0,7,"");
+ return filepath;
}
/*!
MEDOP::DatasourceHandler * datasourceHandler = new MEDOP::DatasourceHandler();
datasourceHandler->id = _sourceLastId; _sourceLastId++;
datasourceHandler->name = (Kernel_Utils::GetBaseName(filepath)).c_str();
- datasourceHandler->uri = file_to_source(filepath);
+ std::string tmp(file_to_source(filepath));
+ datasourceHandler->uri = CORBA::string_dup(tmp.c_str());
_datasourceHandlerMap[datasourceHandler->id] = datasourceHandler;
// We start by read the list of meshes (spatial supports of fields)
}
long MEDDataManager_i::getDatasourceId(const char *filepath) {
- const char * uri = file_to_source(filepath);
+ std::string uri(file_to_source(filepath));
DatasourceHandlerMapIterator it = _datasourceHandlerMap.begin();
while ( it != _datasourceHandlerMap.end() ) {
- if ( strcmp(it->second->uri,uri) == 0 ) {
+ if ( strcmp(it->second->uri,uri.c_str()) == 0 ) {
return it->first;
}
++it;
}
long sourceid = _meshHandlerMap[meshHandlerId]->sourceid;
- const char * filepath = source_to_file((_datasourceHandlerMap[sourceid])->uri);
+ std::string filepath(source_to_file((_datasourceHandlerMap[sourceid])->uri));
const char * meshName = _meshHandlerMap[meshHandlerId]->name;
int meshDimRelToMax = 0;
myMesh = MEDLoader::ReadUMeshFromFile(filepath,meshName,meshDimRelToMax);
long sourceid = _meshHandlerMap[meshid]->sourceid;
- const char * filepath = source_to_file((_datasourceHandlerMap[sourceid])->uri);
- const char * meshName = myMesh->getName().c_str();
+ std::string filepath(source_to_file((_datasourceHandlerMap[sourceid])->uri));
+ std::string meshName(myMesh->getName());
LOG("getFieldDouble: field "<<fieldHandler->fieldname<<" loaded from file "<<filepath);
TypeOfField type = (TypeOfField)fieldHandler->type;
int meshDimRelToMax = 0;
filepath,
meshName,
meshDimRelToMax,
- fieldHandler->fieldname,
+ std::string(fieldHandler->fieldname),
fieldHandler->iteration,
fieldHandler->order);
myField->setMesh(myMesh);
MEDOP::FieldHandler * MEDDataManager_i::addField(MEDCouplingFieldDouble * fieldDouble,
long meshHandlerId)
{
- const char * fieldName = fieldDouble->getName().c_str();
- const char * meshName = fieldDouble->getMesh()->getName().c_str();
+ std::string fieldName(fieldDouble->getName());
+ std::string meshName(fieldDouble->getMesh()->getName());
TypeOfField type = fieldDouble->getTypeOfField();
int iteration, order;
// the fielddouble name, because this name describes the operation
// the field has been created with.
string * source = new string("mem://"); source->append(fieldName);
- MEDOP::FieldHandler * fieldHandler = newFieldHandler(fieldName,
- meshName,
- type,
- iteration,
- order,
- source->c_str());
+ MEDOP::FieldHandler * fieldHandler = newFieldHandler(fieldName.c_str(),
+ meshName.c_str(),
+ type,
+ iteration,
+ order,
+ source->c_str());
if ( meshHandlerId == LONG_UNDEFINED ) {
// We have to gess the id of the underlying mesh to preserve data
long order,
const char * source);
- const char * file_to_source(const char * filepath);
- const char * source_to_file(const char * source);
+ std::string file_to_source(const char * filepath);
+ std::string source_to_file(const char * source);
long getDatasourceId(const char *filepath);
MEDCouplingUMesh * getUMesh(long meshHandlerId);
if ( filenames.count() <= 0 ) return;
for ( QStringList::ConstIterator itFile = filenames.begin();
- itFile != filenames.end(); ++itFile ) {
+ itFile != filenames.end(); ++itFile ) {
QString filename = *itFile;
this->addDatasource(QCHARSTAR(filename));
_salomeModule->updateObjBrowser(true);
</mesh>\n \
</mapping>\n \
</root>\n";
- std::vector<std::string> meshNames=MEDLoader::GetMeshNames(myfile.c_str());
+ std::vector<std::string> meshNames=MEDLoader::GetMeshNames(myfile);
xml.replace(xml.find("$fileName"),9,myfile);
xml.replace(xml.find("$meshName"),9,meshNames[0]);
xml.replace(xml.find("$meshName"),9,meshNames[0]);
std::ostringstream oss;
oss<<name<<"_"<<i;
if (!isParallelMode() || _domain_selector->isMyDomain(i))
- _mesh[i]->setName(oss.str().c_str());
+ _mesh[i]->setName(oss.str());
}
}
ParaMEDMEM::DataArrayDouble *MEDPARTITIONER::MeshCollection::getField(std::string descriptionField, int iold)
//getField look for and read it if not done, and assume decrRef() in ~MeshCollection;
-//something like MEDCouplingFieldDouble *f2=MEDLoader::ReadFieldCell(name.c_str(),f1->getMesh()->getName(),0,f1->getName(),0,1);
+//something like MEDCouplingFieldDouble *f2=MEDLoader::ReadFieldCell(name,f1->getMesh()->getName(),0,f1->getName(),0,1);
{
int rank=MyGlobals::_Rank;
std::string tag="ioldFieldDouble="+IntToStr(iold);
meshName=MyGlobals::_Mesh_Names[iold];
ParaMEDMEM::MEDCouplingFieldDouble* f2=MEDLoader::ReadField((ParaMEDMEM::TypeOfField) typeField,
- fileName.c_str(), meshName.c_str(), 0, fieldName.c_str(), DT, IT);
+ fileName, meshName, 0, fieldName, DT, IT);
ParaMEDMEM::DataArrayDouble* res=f2->getArray();
//to know names of components
std::string meshname=MyGlobals::_Mesh_Names[idomain];
std::string file=MyGlobals::_File_Names[idomain];
- ParaMEDMEM::MEDFileUMesh* mfm=ParaMEDMEM::MEDFileUMesh::New(file.c_str(),meshname.c_str());
+ ParaMEDMEM::MEDFileUMesh* mfm=ParaMEDMEM::MEDFileUMesh::New(file,meshname);
std::vector<int> nonEmpty=mfm->getNonEmptyLevels();
try
std::string meshname=MyGlobals::_Mesh_Names[idomain];
std::string file=MyGlobals::_File_Names[idomain];
- ParaMEDMEM::MEDFileUMesh* mfm=ParaMEDMEM::MEDFileUMesh::New(file.c_str(),meshname.c_str());
+ ParaMEDMEM::MEDFileUMesh* mfm=ParaMEDMEM::MEDFileUMesh::New(file,meshname);
std::vector<int> nonEmpty=mfm->getNonEmptyLevels();
try
// faceMeshFilter=(ParaMEDMEM::MEDCouplingUMesh *) faceMesh->buildPartOfMySelf(index,index+filter->getNbOfElems(),true);
// faceMesh=faceMeshFilter;
// }
- cellMesh->setName(finalMeshName.c_str());
+ cellMesh->setName(finalMeshName);
meshes.push_back(cellMesh);
faceMesh->checkCoherency();
// boundaryMesh->setName("boundaryMesh");
// }
- MEDLoader::WriteUMeshes(distfilename.c_str(), meshes, true);
+ MEDLoader::WriteUMeshes(distfilename, meshes, true);
// if (faceMeshFilter!=0)
// faceMeshFilter->decrRef();
// if (boundaryMesh!=0)
// {
// //doing that testMesh becomes second mesh sorted by alphabetical order of name
- // MEDLoader::WriteUMesh(distfilename.c_str(), boundaryMesh, false);
+ // MEDLoader::WriteUMesh(distfilename, boundaryMesh, false);
// boundaryMesh->decrRef();
// }
- ParaMEDMEM::MEDFileUMesh* mfm=ParaMEDMEM::MEDFileUMesh::New(distfilename.c_str(), _collection->getMesh(idomain)->getName().c_str());
+ ParaMEDMEM::MEDFileUMesh* mfm=ParaMEDMEM::MEDFileUMesh::New(distfilename, _collection->getMesh(idomain)->getName());
mfm->setFamilyInfo(_collection->getFamilyInfo());
mfm->setGroupInfo(_collection->getGroupInfo());
if (_collection->getMapDataArrayInt().find(key)!=_collection->getMapDataArrayInt().end())
mfm->setFamilyFieldArr(0,_collection->getMapDataArrayInt().find(key)->second);
- mfm->write(distfilename.c_str(),0);
+ mfm->write(distfilename,0);
key="/inewFieldDouble="+IntToStr(idomain)+"/";
std::map<std::string,ParaMEDMEM::DataArrayDouble*>::iterator it;
continue;
}
nbfFieldFound++;
- field->setName(fieldName.c_str());
+ field->setName(fieldName);
field->setMesh(mfm->getLevel0Mesh(false));
ParaMEDMEM::DataArrayDouble *da=(*it).second;
r1=SelectTagsInVectorOfString(r1,"typeField="+IntToStr(typeField));
r1=SelectTagsInVectorOfString(r1,"DT="+IntToStr(DT));
r1=SelectTagsInVectorOfString(r1,"IT="+IntToStr(IT));
- //not saved in file? field->setDescription(ExtractFromDescription(r1[0], "fieldDescription=").c_str());
+ //not saved in file? field->setDescription(ExtractFromDescription(r1[0], "fieldDescription="));
int nbc=StrToInt(ExtractFromDescription(r1[0], "nbComponents="));
if (nbc==da->getNumberOfComponents())
{
for (int i=0; i<nbc; i++)
- da->setInfoOnComponent(i,ExtractFromDescription(r1[0], "componentInfo"+IntToStr(i)+"=").c_str());
+ da->setInfoOnComponent(i,ExtractFromDescription(r1[0], "componentInfo"+IntToStr(i)+"="));
}
else
{
field->checkCoherency();
try
{
- MEDLoader::WriteField(distfilename.c_str(),field,false);
+ MEDLoader::WriteField(distfilename,field,false);
}
catch(INTERP_KERNEL::Exception& e)
{
tmp+="_"+fieldName+"_"+IntToStr(nbfFieldFound)+".med";
newName.replace(newName.find(".med"),4,tmp);
std::cout << "WARNING : writeMedFile : create a new file name with only one field because MEDLoader::WriteField throw:" << newName << std::endl;
- MEDLoader::WriteField(newName.c_str(),field,true);
+ MEDLoader::WriteField(newName,field,true);
}
}
mfm->decrRef();
std::vector<std::string> MEDPARTITIONER::BrowseAllFields(const std::string& myfile)
{
std::vector<std::string> res;
- std::vector<std::string> meshNames=MEDLoader::GetMeshNames(myfile.c_str());
+ std::vector<std::string> meshNames=MEDLoader::GetMeshNames(myfile);
for (std::size_t i=0; i<meshNames.size(); i++)
{
std::vector<std::string> fieldNames=
- MEDLoader::GetAllFieldNamesOnMesh(myfile.c_str(),meshNames[i].c_str());
+ MEDLoader::GetAllFieldNamesOnMesh(myfile,meshNames[i]);
for (std::size_t j = 0; j < fieldNames.size(); j++)
{
std::vector< ParaMEDMEM::TypeOfField > typeFields=
- MEDLoader::GetTypesOfField(myfile.c_str(), meshNames[i].c_str(), fieldNames[j].c_str());
+ MEDLoader::GetTypesOfField(myfile, meshNames[i], fieldNames[j]);
for (std::size_t k = 0; k < typeFields.size(); k++)
{
std::vector< std::pair< int, int > > its=
- MEDLoader::GetFieldIterations(typeFields[k], myfile.c_str(), meshNames[i].c_str(), fieldNames[j].c_str());
+ MEDLoader::GetFieldIterations(typeFields[k], myfile, meshNames[i], fieldNames[j]);
if (MyGlobals::_Is0verbose>100)
std::cout<< "fieldName " << fieldNames[j] << " typeField " << typeFields[k] << " its.size() " << its.size() << std::endl;
for (std::size_t m = 0; m < its.size(); m++)
{
MEDCouplingNormalizedUnstructuredMesh<2,2> source_mesh_wrapper(source_supportC);
INTERP_KERNEL::Interpolation2D interpolation(*this);
- interpolation.fromIntegralUniform(source_mesh_wrapper,surfaces,srcMeth.c_str());
+ interpolation.fromIntegralUniform(source_mesh_wrapper,surfaces,srcMeth);
}
else if(source_supportC->getMeshDimension()==3 && source_supportC->getSpaceDimension()==3)
{
MEDCouplingNormalizedUnstructuredMesh<3,3> source_mesh_wrapper(source_supportC);
INTERP_KERNEL::Interpolation3D interpolation(*this);
- interpolation.fromIntegralUniform(source_mesh_wrapper,surfaces,srcMeth.c_str());
+ interpolation.fromIntegralUniform(source_mesh_wrapper,surfaces,srcMeth);
}
else if(source_supportC->getMeshDimension()==2 && source_supportC->getSpaceDimension()==3)
{
MEDCouplingNormalizedUnstructuredMesh<3,2> source_mesh_wrapper(source_supportC);
INTERP_KERNEL::Interpolation3DSurf interpolation(*this);
- interpolation.fromIntegralUniform(source_mesh_wrapper,surfaces,srcMeth.c_str());
+ interpolation.fromIntegralUniform(source_mesh_wrapper,surfaces,srcMeth);
}
else
throw INTERP_KERNEL::Exception("No para interpolation available for the given mesh and space dimension of source mesh to -1D targetMesh");
{
MEDCouplingNormalizedUnstructuredMesh<2,2> distant_mesh_wrapper(distant_supportC);
INTERP_KERNEL::Interpolation2D interpolation(*this);
- interpolation.toIntegralUniform(distant_mesh_wrapper,surfaces,srcMeth.c_str());
+ interpolation.toIntegralUniform(distant_mesh_wrapper,surfaces,srcMeth);
}
else if(distant_supportC->getMeshDimension()==3 && distant_supportC->getSpaceDimension()==3)
{
MEDCouplingNormalizedUnstructuredMesh<3,3> distant_mesh_wrapper(distant_supportC);
INTERP_KERNEL::Interpolation3D interpolation(*this);
- interpolation.toIntegralUniform(distant_mesh_wrapper,surfaces,srcMeth.c_str());
+ interpolation.toIntegralUniform(distant_mesh_wrapper,surfaces,srcMeth);
}
else if(distant_supportC->getMeshDimension()==2 && distant_supportC->getSpaceDimension()==3)
{
MEDCouplingNormalizedUnstructuredMesh<3,2> distant_mesh_wrapper(distant_supportC);
INTERP_KERNEL::Interpolation3DSurf interpolation(*this);
- interpolation.toIntegralUniform(distant_mesh_wrapper,surfaces,srcMeth.c_str());
+ interpolation.toIntegralUniform(distant_mesh_wrapper,surfaces,srcMeth);
}
else
throw INTERP_KERNEL::Exception("No para interpolation available for the given mesh and space dimension of distant mesh to -1D sourceMesh");
MEDCouplingNormalizedUnstructuredMesh<3,3> target_wrapper(distant_supportC);
MEDCouplingNormalizedUnstructuredMesh<3,3> source_wrapper(source_supportC);
INTERP_KERNEL::Interpolation3D2D interpolator (*this);
- interpolator.interpolateMeshes(target_wrapper,source_wrapper,surfaces,interpMethod.c_str());
+ interpolator.interpolateMeshes(target_wrapper,source_wrapper,surfaces,interpMethod);
target_wrapper.releaseTempArrays();
source_wrapper.releaseTempArrays();
}
MEDCouplingNormalizedUnstructuredMesh<2,2> target_wrapper(distant_supportC);
MEDCouplingNormalizedUnstructuredMesh<2,2> source_wrapper(source_supportC);
INTERP_KERNEL::Interpolation2D1D interpolator (*this);
- interpolator.interpolateMeshes(target_wrapper,source_wrapper,surfaces,interpMethod.c_str());
+ interpolator.interpolateMeshes(target_wrapper,source_wrapper,surfaces,interpMethod);
target_wrapper.releaseTempArrays();
source_wrapper.releaseTempArrays();
}
MEDCouplingNormalizedUnstructuredMesh<1,1> source_wrapper(source_supportC);
INTERP_KERNEL::Interpolation1D interpolation(*this);
- interpolation.interpolateMeshes(target_wrapper,source_wrapper,surfaces,interpMethod.c_str());
+ interpolation.interpolateMeshes(target_wrapper,source_wrapper,surfaces,interpMethod);
target_wrapper.releaseTempArrays();
source_wrapper.releaseTempArrays();
}
MEDCouplingNormalizedUnstructuredMesh<2,1> source_wrapper(source_supportC);
INTERP_KERNEL::Interpolation2DCurve interpolation(*this);
- interpolation.interpolateMeshes(target_wrapper,source_wrapper,surfaces,interpMethod.c_str());
+ interpolation.interpolateMeshes(target_wrapper,source_wrapper,surfaces,interpMethod);
target_wrapper.releaseTempArrays();
source_wrapper.releaseTempArrays();
}
MEDCouplingNormalizedUnstructuredMesh<3,2> source_wrapper(source_supportC);
INTERP_KERNEL::Interpolation3DSurf interpolator (*this);
- interpolator.interpolateMeshes(target_wrapper,source_wrapper,surfaces,interpMethod.c_str());
+ interpolator.interpolateMeshes(target_wrapper,source_wrapper,surfaces,interpMethod);
target_wrapper.releaseTempArrays();
source_wrapper.releaseTempArrays();
}
MEDCouplingNormalizedUnstructuredMesh<2,2> source_wrapper(source_supportC);
INTERP_KERNEL::Interpolation2D interpolator (*this);
- interpolator.interpolateMeshes(target_wrapper,source_wrapper,surfaces,interpMethod.c_str());
+ interpolator.interpolateMeshes(target_wrapper,source_wrapper,surfaces,interpMethod);
target_wrapper.releaseTempArrays();
source_wrapper.releaseTempArrays();
}
MEDCouplingNormalizedUnstructuredMesh<3,3> source_wrapper(source_supportC);
INTERP_KERNEL::Interpolation3D interpolator (*this);
- interpolator.interpolateMeshes(target_wrapper,source_wrapper,surfaces,interpMethod.c_str());
+ interpolator.interpolateMeshes(target_wrapper,source_wrapper,surfaces,interpMethod);
target_wrapper.releaseTempArrays();
source_wrapper.releaseTempArrays();
}
fvm_nodal_t* medmemMeshToFVMMesh(const MEDMEM::MESH* mesh)
{
// create an FVM structure from the paramesh structure
- fvm_nodal_t * fvm_nodal = fvm_nodal_create(mesh->getName().c_str(),mesh->getMeshDimension());
+ std::string meshName(mesh->getName());//this line avoid that mesh->getName() object killed before fvm_nodal_create read the const char *.
+ fvm_nodal_t * fvm_nodal = fvm_nodal_create(meshName.c_str(),mesh->getMeshDimension());
//loop on cell types
int nbtypes = mesh->getNumberOfTypes(MED_EN::MED_CELL);
{
// create an FVM structure from the paramesh structure
- fvm_nodal_t * fvm_nodal = fvm_nodal_create(support->getName().c_str(),1);
+ std::string supportName(support->getName());//this line avoid that support->getName() object killed before fvm_nodal_create read the const char *.
+ fvm_nodal_t * fvm_nodal = fvm_nodal_create(supportName.c_str(),1);
const MEDMEM::MESH* mesh= support->getMesh();
{
MEDCouplingNormalizedUnstructuredMesh<2,2> target_mesh_wrapper(trgC);
INTERP_KERNEL::Interpolation2D interpolation(*this);
- colSize=interpolation.fromIntegralUniform(target_mesh_wrapper,surfaces,trgMeth.c_str());
+ colSize=interpolation.fromIntegralUniform(target_mesh_wrapper,surfaces,trgMeth);
}
else if(trgC->getMeshDimension()==3 && trgC->getSpaceDimension()==3)
{
MEDCouplingNormalizedUnstructuredMesh<3,3> target_mesh_wrapper(trgC);
INTERP_KERNEL::Interpolation3D interpolation(*this);
- colSize=interpolation.fromIntegralUniform(target_mesh_wrapper,surfaces,trgMeth.c_str());
+ colSize=interpolation.fromIntegralUniform(target_mesh_wrapper,surfaces,trgMeth);
}
else if(trgC->getMeshDimension()==2 && trgC->getSpaceDimension()==3)
{
MEDCouplingNormalizedUnstructuredMesh<3,2> target_mesh_wrapper(trgC);
INTERP_KERNEL::Interpolation3DSurf interpolation(*this);
- colSize=interpolation.fromIntegralUniform(target_mesh_wrapper,surfaces,trgMeth.c_str());
+ colSize=interpolation.fromIntegralUniform(target_mesh_wrapper,surfaces,trgMeth);
}
else
throw INTERP_KERNEL::Exception("No para interpolation available for the given mesh and space dimension of source mesh to -1D targetMesh");
{
MEDCouplingNormalizedUnstructuredMesh<2,2> local_mesh_wrapper(srcC);
INTERP_KERNEL::Interpolation2D interpolation(*this);
- colSize=interpolation.toIntegralUniform(local_mesh_wrapper,surfaces,srcMeth.c_str());
+ colSize=interpolation.toIntegralUniform(local_mesh_wrapper,surfaces,srcMeth);
}
else if(srcC->getMeshDimension()==3 && srcC->getSpaceDimension()==3)
{
MEDCouplingNormalizedUnstructuredMesh<3,3> local_mesh_wrapper(srcC);
INTERP_KERNEL::Interpolation3D interpolation(*this);
- colSize=interpolation.toIntegralUniform(local_mesh_wrapper,surfaces,srcMeth.c_str());
+ colSize=interpolation.toIntegralUniform(local_mesh_wrapper,surfaces,srcMeth);
}
else if(srcC->getMeshDimension()==2 && srcC->getSpaceDimension()==3)
{
MEDCouplingNormalizedUnstructuredMesh<3,2> local_mesh_wrapper(srcC);
INTERP_KERNEL::Interpolation3DSurf interpolation(*this);
- colSize=interpolation.toIntegralUniform(local_mesh_wrapper,surfaces,srcMeth.c_str());
+ colSize=interpolation.toIntegralUniform(local_mesh_wrapper,surfaces,srcMeth);
}
else
throw INTERP_KERNEL::Exception("No para interpolation available for the given mesh and space dimension of distant mesh to -1D sourceMesh");
MEDCouplingNormalizedUnstructuredMesh<3,3> source_wrapper(srcC);
INTERP_KERNEL::Interpolation3D2D interpolator (*this);
- colSize=interpolator.interpolateMeshes(source_wrapper,target_wrapper,surfaces,interpMethod.c_str());
+ colSize=interpolator.interpolateMeshes(source_wrapper,target_wrapper,surfaces,interpMethod);
target_wrapper.releaseTempArrays();
source_wrapper.releaseTempArrays();
}
INTERP_KERNEL::Interpolation3D2D interpolator (*this);
vector<map<int,double> > surfacesTranspose;
- colSize=interpolator.interpolateMeshes(target_wrapper,source_wrapper,surfaces,interpMethod.c_str());//not a bug target in source.
+ colSize=interpolator.interpolateMeshes(target_wrapper,source_wrapper,surfaces,interpMethod);//not a bug target in source.
TransposeMatrix(surfacesTranspose,colSize,surfaces);
colSize=surfacesTranspose.size();
target_wrapper.releaseTempArrays();
MEDCouplingNormalizedUnstructuredMesh<2,2> source_wrapper(srcC);
INTERP_KERNEL::Interpolation2D1D interpolator (*this);
- colSize=interpolator.interpolateMeshes(source_wrapper,target_wrapper,surfaces,interpMethod.c_str());
+ colSize=interpolator.interpolateMeshes(source_wrapper,target_wrapper,surfaces,interpMethod);
target_wrapper.releaseTempArrays();
source_wrapper.releaseTempArrays();
}
INTERP_KERNEL::Interpolation2D1D interpolator (*this);
vector<map<int,double> > surfacesTranspose;
- colSize=interpolator.interpolateMeshes(target_wrapper,source_wrapper,surfacesTranspose,interpMethod.c_str());//not a bug target in source.
+ colSize=interpolator.interpolateMeshes(target_wrapper,source_wrapper,surfacesTranspose,interpMethod);//not a bug target in source.
TransposeMatrix(surfacesTranspose,colSize,surfaces);
colSize=surfacesTranspose.size();
target_wrapper.releaseTempArrays();
MEDCouplingNormalizedUnstructuredMesh<1,1> source_wrapper(srcC);
INTERP_KERNEL::Interpolation1D interpolation(*this);
- colSize=interpolation.interpolateMeshes(source_wrapper,target_wrapper,surfaces,interpMethod.c_str());
+ colSize=interpolation.interpolateMeshes(source_wrapper,target_wrapper,surfaces,interpMethod);
target_wrapper.releaseTempArrays();
source_wrapper.releaseTempArrays();
}
MEDCouplingNormalizedUnstructuredMesh<2,1> source_wrapper(srcC);
INTERP_KERNEL::Interpolation2DCurve interpolation(*this);
- colSize=interpolation.interpolateMeshes(source_wrapper,target_wrapper,surfaces,interpMethod.c_str());
+ colSize=interpolation.interpolateMeshes(source_wrapper,target_wrapper,surfaces,interpMethod);
target_wrapper.releaseTempArrays();
source_wrapper.releaseTempArrays();
}
MEDCouplingNormalizedUnstructuredMesh<3,2> source_wrapper(srcC);
INTERP_KERNEL::Interpolation3DSurf interpolator (*this);
- colSize=interpolator.interpolateMeshes(source_wrapper,target_wrapper,surfaces,interpMethod.c_str());
+ colSize=interpolator.interpolateMeshes(source_wrapper,target_wrapper,surfaces,interpMethod);
target_wrapper.releaseTempArrays();
source_wrapper.releaseTempArrays();
}
MEDCouplingNormalizedUnstructuredMesh<2,2> source_wrapper(srcC);
INTERP_KERNEL::Interpolation2D interpolator (*this);
- colSize=interpolator.interpolateMeshes(source_wrapper,target_wrapper,surfaces,interpMethod.c_str());
+ colSize=interpolator.interpolateMeshes(source_wrapper,target_wrapper,surfaces,interpMethod);
target_wrapper.releaseTempArrays();
source_wrapper.releaseTempArrays();
}
MEDCouplingNormalizedUnstructuredMesh<3,3> source_wrapper(srcC);
INTERP_KERNEL::Interpolation3D interpolator (*this);
- colSize=interpolator.interpolateMeshes(source_wrapper,target_wrapper,surfaces,interpMethod.c_str());
+ colSize=interpolator.interpolateMeshes(source_wrapper,target_wrapper,surfaces,interpMethod);
target_wrapper.releaseTempArrays();
source_wrapper.releaseTempArrays();
}
st->compo = compo._retn();
st->coupling = coupling;
st->ior = lcompo;
-
+
pthread_create(&(th[0]),NULL,th_initializecouplingdist,(void*)st);
-
+
//initializing the coupling on the local object
initializeCoupling (coupling.c_str(), rcompo.c_str());
pthread_join (th[0], &ret_th);
}
// Reading file structure
cout << "Reading : " << flush;
- MEDCouplingAutoRefCountObjectPtr<MEDFileData> fd=MEDFileData::New(filename_in.c_str());
- MEDFileMesh *m=fd->getMeshes()->getMeshWithName(meshname.c_str());
+ MEDCouplingAutoRefCountObjectPtr<MEDFileData> fd(MEDFileData::New(filename_in));
+ MEDFileMesh *m=fd->getMeshes()->getMeshWithName(meshname);
MEDFileUMesh *mc=dynamic_cast<MEDFileUMesh *>(m);
if(!mc)
{
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> famField2=famField->renumber(perm->begin());
mc->setFamilyFieldArr(0,famField2);
}
- mc->write(filename_out.c_str(),2);
+ mc->write(filename_out,2);
t_family=clock();
cout << " : " << (t_family-t_compute_graph)/(double) CLOCKS_PER_SEC << "s" << endl << flush;
// Fields
for(int i=0;i<fs->getNumberOfFields();i++)
{
MEDFileFieldMultiTS *fmts=dynamic_cast<MEDFileFieldMultiTS *>(fs->getFieldAtPos(i));
- if(!fmts) continue;
+ if(!fmts) continue;
if(fmts->getMeshName()==meshname)
{
for(int j=0;j<fmts->getNumberOfTS();j++)
{
MEDFileField1TS *f1ts=dynamic_cast<MEDFileField1TS*>(fmts->getTimeStepAtPos(j));
- if(!f1ts) continue;
+ if(!f1ts) continue;
DataArrayDouble *arr=f1ts->getUndergroundDataArray();
arr->renumberInPlace(perm->begin());
}
}
}
- fs->write(filename_out.c_str(),0);
- //fs->renumberEntitiesLyingOnMesh(meshname.c_str(),code,code,o2n); bugged
+ fs->write(filename_out,0);
+ //fs->renumberEntitiesLyingOnMesh(meshname,code,code,o2n); bugged
}
t_field=clock();
cout << " : " << (t_field-t_family)/(double) CLOCKS_PER_SEC << "s" << endl << flush;