-// Copyright (C) 2007-2014 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
#include "MEDCoupling1GTUMesh.hxx"
#include "MEDCouplingPartDefinition.hxx"
#include "MEDCouplingCurveLinearMesh.hxx"
-#include "MEDCouplingAutoRefCountObjectPtr.hxx"
+#include "MCAuto.hxx"
#include "med.h"
#include <map>
-namespace ParaMEDMEM
+namespace MEDCoupling
{
class MEDFileMeshReadSelector;
int getIteration() const { return _iteration; }
int getOrder() const { return _order; }
double getTime() const { return _time; }
- MEDCouplingAutoRefCountObjectPtr<PartDefinition> getPartDefOfCoo() const { return _part_coords; }
- 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);
+ MCAuto<PartDefinition> getPartDefOfCoo() const { return _part_coords; }
+ std::vector<std::string> getAxisInfoOnMesh(med_idt fid, int mId, const std::string& mName, MEDCoupling::MEDCouplingMeshType& meshType, MEDCoupling::MEDCouplingAxisType& axType, int& nstep, int& Mdim);
+ static int GetMeshIdFromName(med_idt fid, const std::string& mName, MEDCoupling::MEDCouplingMeshType& meshType, MEDCoupling::MEDCouplingAxisType& axType, 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);
+ static bool RenameFamiliesFromFileToMem(std::vector< std::string >& famNames);
+ static bool RenameFamiliesFromMemToFile(std::vector< std::string >& famNames);
+ static MEDCoupling::MEDCouplingAxisType TraduceAxisType(med_axis_type at);
+ static MEDCoupling::MEDCouplingAxisType TraduceAxisTypeStruct(med_grid_type gt);
+ static med_axis_type TraduceAxisTypeRev(MEDCoupling::MEDCouplingAxisType at);
+ static med_grid_type TraduceAxisTypeRevStruct(MEDCoupling::MEDCouplingAxisType at);
+ private:
+ typedef bool (*RenameFamiliesPatternFunc)(std::vector< std::string >&);
+ static void RenameFamiliesPatternInternal(std::vector< std::pair<std::string,std::pair<int,std::vector<std::string> > > >& crudeFams, RenameFamiliesPatternFunc func);
+ static void RenameFamiliesFromFileToMemInternal(std::vector< std::pair<std::string,std::pair<int,std::vector<std::string> > > >& crudeFams);
+ static void RenameFamiliesFromMemToFileInternal(std::vector< std::pair<std::string,std::pair<int,std::vector<std::string> > > >& crudeFams);
+ public:
+ static const char ZE_SEP_FOR_FAMILY_KILLERS[];
+ static int ZE_SEP2_FOR_FAMILY_KILLERS;
protected:
MEDFileString _name;
MEDFileString _description;
int _iteration;
int _order;
double _time;
- MEDCouplingAutoRefCountObjectPtr<PartDefinition> _part_coords;
+ MCAuto<PartDefinition> _part_coords;
};
class MEDFileUMeshL2 : public MEDFileMeshL2
void loadPartCoords(med_idt fid, int mId, const std::vector<std::string>& infosOnComp, const std::string& mName, int dt, int it, int nMin, int nMax);
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]; }
+ const std::vector< MCAuto<MEDFileUMeshPerType> >& getLev(int levId) const { return _per_type_mesh[levId]; }
bool isFamDefinedOnLev(int levId) const;
bool isNumDefinedOnLev(int levId) const;
bool isNamesDefinedOnLev(int levId) const;
- MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> getCoords() const { return _coords; }
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> getCoordsFamily() const { return _fam_coords; }
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> getCoordsNum() const { return _num_coords; }
- MEDCouplingAutoRefCountObjectPtr<DataArrayAsciiChar> getCoordsName() const { return _name_coords; }
+ MCAuto<DataArrayDouble> getCoords() const { return _coords; }
+ MCAuto<DataArrayInt> getCoordsFamily() const { return _fam_coords; }
+ MCAuto<DataArrayInt> getCoordsNum() const { return _num_coords; }
+ MCAuto<DataArrayAsciiChar> getCoordsName() const { return _name_coords; }
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:
- std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> > > _per_type_mesh;
- MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> _coords;
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _fam_coords;
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _num_coords;
- MEDCouplingAutoRefCountObjectPtr<DataArrayAsciiChar> _name_coords;
+ std::vector< std::vector< MCAuto<MEDFileUMeshPerType> > > _per_type_mesh;
+ MCAuto<DataArrayDouble> _coords;
+ MCAuto<DataArrayInt> _fam_coords;
+ MCAuto<DataArrayInt> _num_coords;
+ MCAuto<DataArrayAsciiChar> _name_coords;
};
class MEDFileStrMeshL2 : public MEDFileMeshL2
MEDFileCMeshL2();
void loadAll(med_idt fid, int mId, const std::string& mName, int dt, int it);
MEDCouplingCMesh *getMesh() { return _cmesh; }
+ MEDCoupling::MEDCouplingAxisType getAxisType() const { return _ax_type; }
private:
static med_data_type GetDataTypeCorrespondingToSpaceId(int id);
private:
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingCMesh> _cmesh;
+ MCAuto<MEDCouplingCMesh> _cmesh;
+ MEDCoupling::MEDCouplingAxisType _ax_type;
};
class MEDFileCLMeshL2 : public MEDFileStrMeshL2
void loadAll(med_idt fid, int mId, const std::string& mName, int dt, int it);
MEDCouplingCurveLinearMesh *getMesh() { return _clmesh; }
private:
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingCurveLinearMesh> _clmesh;
+ MCAuto<MEDCouplingCurveLinearMesh> _clmesh;
};
class MEDFileMesh;
const MEDFileUMeshSplitL1 *_st;
mutable std::size_t _mpt_time;
mutable std::size_t _num_time;
- mutable MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> _m;
+ mutable MCAuto<MEDCouplingUMesh> _m;
};
class MEDFileUMeshAggregateCompute : public BigMemoryObject
void assignDefParts(const std::vector<const PartDefinition *>& partDefs);
void assignUMesh(MEDCouplingUMesh *m);
MEDCouplingUMesh *getUmesh() const;
+ int getNumberOfCells() const;
std::vector<MEDCoupling1GTUMesh *> getParts() const;
std::vector<INTERP_KERNEL::NormalizedCellType> getGeoTypes() const;
+ int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType ct) const;
std::vector<MEDCoupling1GTUMesh *> retrievePartsWithoutComputation() const;
MEDCoupling1GTUMesh *retrievePartWithoutComputation(INTERP_KERNEL::NormalizedCellType gt) const;
void getStartStopOfGeoTypeWithoutComputation(INTERP_KERNEL::NormalizedCellType gt, int& start, int& stop) const;
std::size_t getTimeOfThis() const;
std::size_t getHeapMemorySizeWithoutChildren() const;
std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
- MEDFileUMeshAggregateCompute deepCpy(DataArrayDouble *coords) const;
+ MEDFileUMeshAggregateCompute deepCopy(DataArrayDouble *coords) const;
+ void shallowCpyMeshes();
bool isEqual(const MEDFileUMeshAggregateCompute& other, double eps, std::string& what) const;
+ void checkConsistency() const;
void clearNonDiscrAttributes() const;
void synchronizeTinyInfo(const MEDFileMesh& master) const;
bool empty() const;
void setCoords(DataArrayDouble *coords);
void forceComputationOfPartsFromUMesh() const;
const PartDefinition *getPartDefOfWithoutComputation(INTERP_KERNEL::NormalizedCellType gt) const;
+ void serialize(std::vector<int>& tinyInt, std::vector< MCAuto<DataArrayInt> >& bigArraysI) const;
+ void unserialize(const std::string& name, DataArrayDouble *coo, std::vector<int>& tinyInt, std::vector< MCAuto<DataArrayInt> >& bigArraysI);
private:
std::size_t getTimeOfParts() const;
std::size_t getTimeOfUMesh() const;
private:
- mutable std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> > _m_parts;
+ mutable std::vector< MCAuto<MEDCoupling1GTUMesh> > _m_parts;
mutable std::size_t _mp_time;
mutable std::size_t _m_time;
- mutable MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> _m;
- mutable std::vector< MEDCouplingAutoRefCountObjectPtr<PartDefinition> > _part_def;
+ mutable MCAuto<MEDCouplingUMesh> _m;
+ mutable std::vector< MCAuto<PartDefinition> > _part_def;
};
class MEDFileUMeshSplitL1 : public RefCountObject
{
friend class MEDFileUMeshPermCompute;
+ friend class MEDFileUMesh;
public:
MEDFileUMeshSplitL1(const MEDFileUMeshSplitL1& other);
MEDFileUMeshSplitL1(const MEDFileUMeshL2& l2, const std::string& mName, int id);
void setName(const std::string& name);
std::size_t getHeapMemorySizeWithoutChildren() const;
std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
- MEDFileUMeshSplitL1 *deepCpy(DataArrayDouble *coords) const;
+ MEDFileUMeshSplitL1 *shallowCpyUsingCoords(DataArrayDouble *coords) const;
+ MEDFileUMeshSplitL1 *deepCopy(DataArrayDouble *coords) const;
+ void checkConsistency() const;
void setCoords(DataArrayDouble *coords);
bool isEqual(const MEDFileUMeshSplitL1 *other, double eps, std::string& what) const;
void clearNonDiscrAttributes() const;
MEDCouplingUMesh *getFamilyPart(const int *idsBg, const int *idsEnd, bool renum) const;
DataArrayInt *getFamilyPartArr(const int *idsBg, const int *idsEnd, bool renum) const;
MEDCouplingUMesh *getWholeMesh(bool renum) const;
+ int getNumberOfCells() const;
bool isMeshStoredSplitByType() const { return _m_by_types.isStoredSplitByType(); }
std::vector<INTERP_KERNEL::NormalizedCellType> getGeoTypes() const;
+ int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType ct) const;
std::vector<MEDCoupling1GTUMesh *> getDirectUndergroundSingleGeoTypeMeshes() const { return _m_by_types.retrievePartsWithoutComputation(); }
MEDCoupling1GTUMesh *getDirectUndergroundSingleGeoTypeMesh(INTERP_KERNEL::NormalizedCellType gt) const { return _m_by_types.retrievePartWithoutComputation(gt); }
DataArrayInt *extractFamilyFieldOnGeoType(INTERP_KERNEL::NormalizedCellType gt) const;
void write(med_idt fid, const std::string& mName, int mdim) const;
//
void setFamilyArr(DataArrayInt *famArr);
+ DataArrayInt *getFamilyField();
void setRenumArr(DataArrayInt *renumArr);
void setNameArr(DataArrayAsciiChar *nameArr);
void changeFamilyIdArr(int oldId, int newId);
//
void renumberNodesInConn(const int *newNodeNumbersO2N);
//
+ void serialize(std::vector<int>& tinyInt, std::vector< MCAuto<DataArrayInt> >& bigArraysI) const;
+ void unserialize(const std::string& name, DataArrayDouble *coo, std::vector<int>& tinyInt, std::vector< MCAuto<DataArrayInt> >& bigArraysI);
+ //
static void ClearNonDiscrAttributes(const MEDCouplingMesh *tmp);
static std::vector<int> GetNewFamiliesNumber(int nb, const std::map<std::string,int>& families);
static void TraduceFamilyNumber(const std::vector< std::vector<int> >& fidsGrps, std::map<std::string,int>& familyIds,
std::map<int,int>& famIdTrad, std::map<int,std::string>& newfams);
static DataArrayInt *Renumber(const DataArrayInt *renum, const DataArrayInt *da);
static MEDCouplingUMesh *Renumber2(const DataArrayInt *renum, MEDCouplingUMesh *m, const int *cellIds);
+ static MEDFileUMeshSplitL1 *Unserialize(const std::string& name, DataArrayDouble *coo, std::vector<int>& tinyInt, std::vector< MCAuto<DataArrayInt> >& bigArraysI);
private:
+ MEDFileUMeshSplitL1();
void assignCommonPart();
MEDCouplingUMesh *renumIfNeeded(MEDCouplingUMesh *m, const int *cellIds) const;
DataArrayInt *renumIfNeededArr(const DataArrayInt *da) const;
void computeRevNum() const;
private:
MEDFileUMeshAggregateCompute _m_by_types;
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _fam;
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _num;
- MEDCouplingAutoRefCountObjectPtr<DataArrayAsciiChar> _names;
- mutable MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _rev_num;
+ MCAuto<DataArrayInt> _fam;
+ MCAuto<DataArrayInt> _num;
+ MCAuto<DataArrayAsciiChar> _names;
+ mutable MCAuto<DataArrayInt> _rev_num;
MEDFileUMeshPermCompute _m;
};
}