MEDFileMeshLL.cxx
MEDFileField.cxx
MEDFileJoint.cxx
+ MEDFileEquivalence.cxx
MEDFileParameter.cxx
MEDFileData.cxx
MEDFileFieldOverView.cxx
MEDCouplingAutoRefCountObjectPtr<MEDFileParameters> params;
if((const MEDFileParameters *)_params)
params=_params->deepCpy();
- MEDCouplingAutoRefCountObjectPtr<MEDFileJoints> joints;
- MEDCouplingAutoRefCountObjectPtr<MEDFileData> ret=MEDFileData::New();
+ MEDCouplingAutoRefCountObjectPtr<MEDFileData> ret(MEDFileData::New());
ret->_fields=fields; ret->_meshes=meshes; ret->_params=params;
return ret.retn();
}
std::vector<const BigMemoryObject *> MEDFileMesh::getDirectChildrenWithNull() const
{
- return std::vector<const BigMemoryObject *>();
+ std::vector<const BigMemoryObject *> ret(1);
+ ret[0]=(const MEDFileEquivalences *)_equiv;
+ return ret;
}
/*!
int dt,it;
std::string dummy2;
MEDFileMeshL2::GetMeshIdFromName(fid,ms.front(),meshType,dt,it,dummy2);
+ MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> ret;
switch(meshType)
{
case UNSTRUCTURED:
{
- MEDCouplingAutoRefCountObjectPtr<MEDFileUMesh> ret=MEDFileUMesh::New();
- ret->loadUMeshFromFile(fid,ms.front(),dt,it,mrs);
- ret->loadJointsFromFile(fid);
- return (MEDFileUMesh *)ret.retn();
+ ret=MEDFileUMesh::New();
+ break;
}
case CARTESIAN:
{
- MEDCouplingAutoRefCountObjectPtr<MEDFileCMesh> ret=MEDFileCMesh::New();
- ret->loadCMeshFromFile(fid,ms.front(),dt,it,mrs);
- ret->loadJointsFromFile(fid);
- return (MEDFileCMesh *)ret.retn();
+ ret=MEDFileCMesh::New();
+ break;
}
case CURVE_LINEAR:
{
- MEDCouplingAutoRefCountObjectPtr<MEDFileCurveLinearMesh> ret=MEDFileCurveLinearMesh::New();
- ret->loadCLMeshFromFile(fid,ms.front(),dt,it,mrs);
- ret->loadJointsFromFile(fid);
- return (MEDFileCurveLinearMesh *)ret.retn();
+ ret=MEDFileCurveLinearMesh::New();
+ break;
}
default:
{
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
}
+ ret->loadLLWithAdditionalItems(fid,ms.front(),dt,it,mrs);
+ return ret.retn();
}
/*!
int dummy0,dummy1;
std::string dummy2;
MEDFileMeshL2::GetMeshIdFromName(fid,mName,meshType,dummy0,dummy1,dummy2);
+ MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> ret;
switch(meshType)
{
case UNSTRUCTURED:
{
- MEDCouplingAutoRefCountObjectPtr<MEDFileUMesh> ret=MEDFileUMesh::New();
- ret->loadUMeshFromFile(fid,mName,dt,it,mrs);
- ret->loadJointsFromFile(fid,joints);
- return (MEDFileUMesh *)ret.retn();
+ ret=MEDFileUMesh::New();
+ break;
}
case CARTESIAN:
{
- MEDCouplingAutoRefCountObjectPtr<MEDFileCMesh> ret=MEDFileCMesh::New();
- ret->loadCMeshFromFile(fid,mName,dt,it,mrs);
- ret->loadJointsFromFile(fid,joints);
- return (MEDFileCMesh *)ret.retn();
+ ret=MEDFileCMesh::New();
+ break;
}
case CURVE_LINEAR:
{
- MEDCouplingAutoRefCountObjectPtr<MEDFileCurveLinearMesh> ret=MEDFileCurveLinearMesh::New();
- ret->loadCLMeshFromFile(fid,mName,dt,it,mrs);
- ret->loadJointsFromFile(fid,joints);
- return (MEDFileCurveLinearMesh *)ret.retn();
+ ret=MEDFileCurveLinearMesh::New();
+ break;
}
default:
{
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
}
+ ret->loadLLWithAdditionalItems(fid,mName,dt,it,mrs);
+ return ret.retn();
}
/*!
if(_name.empty())
throw INTERP_KERNEL::Exception("MEDFileMesh : name is empty. MED file ask for a NON EMPTY name !");
writeLL(fid);
+ writeJoints(fid);
+ const MEDFileEquivalences *eqs(_equiv);
+ if(eqs)
+ eqs->write(fid);
}
/*!
return false;
if(!areFamsEqual(other,what))
return false;
+ if(!areEquivalencesEqual(other,what))
+ return false;
return true;
}
return mLev->getDistributionOfTypes();
}
+void MEDFileMesh::loadLLWithAdditionalItems(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs)
+{
+ loadLL(fid,mName,dt,it,mrs);
+ loadJointsFromFile(fid);
+ loadEquivalences(fid);
+}
+
void MEDFileMesh::TranslateFamilyIds(int offset, DataArrayInt *famArr, std::vector< std::vector<int> >& famIdsPerGrp)
{
famArr->applyLin(offset>0?1:-1,offset,0);
MEDFileMesh *MEDFileUMesh::deepCpy() const
{
MEDCouplingAutoRefCountObjectPtr<MEDFileUMesh> ret=new MEDFileUMesh(*this);
+ ret->deepCpyEquivalences(*this);
if((const DataArrayDouble*)_coords)
ret->_coords=_coords->deepCpy();
if((const DataArrayInt*)_fam_coords)
MEDFileUMesh::MEDFileUMesh(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs)
try
{
- loadUMeshFromFile(fid,mName,dt,it,mrs);
- loadJointsFromFile(fid);
- }
+ loadLLWithAdditionalItems(fid,mName,dt,it,mrs);
+}
catch(INTERP_KERNEL::Exception& e)
{
throw e;
* This method loads only a part of specified cells (given by range of cell ID per geometric type)
* See MEDFileUMesh::LoadPartOf for detailed description.
*
- * \sa loadUMeshFromFile
+ * \sa loadLL
*/
void MEDFileUMesh::loadPartUMeshFromFile(med_idt fid, const std::string& mName, const std::vector<INTERP_KERNEL::NormalizedCellType>& types, const std::vector<int>& slicPerTyp, int dt, int it, MEDFileMeshReadSelector *mrs)
{
_joints = MEDFileJoints::New( fid, _name );
}
+void MEDFileMesh::loadEquivalences(med_idt fid)
+{
+ int nbOfEq(MEDFileEquivalences::PresenceOfEquivalences(fid,_name));
+ if(nbOfEq>0)
+ _equiv=MEDFileEquivalences::Load(fid,nbOfEq,this);
+}
+
+void MEDFileMesh::deepCpyEquivalences(const MEDFileMesh& other)
+{
+ const MEDFileEquivalences *equiv(other._equiv);
+ if(equiv)
+ _equiv=equiv->deepCpy(this);
+}
+
+bool MEDFileMesh::areEquivalencesEqual(const MEDFileMesh *other, std::string& what) const
+{
+ const MEDFileEquivalences *thisEq(_equiv),*otherEq(other->_equiv);
+ if(!thisEq && !otherEq)
+ return true;
+ if(thisEq && otherEq)
+ return thisEq->isEqual(otherEq,what);
+ else
+ {
+ what+="Equivalence differs : defined in this and not in other (or reversely) !";
+ return false;
+ }
+}
+
+void MEDFileMesh::getEquivalencesRepr(std::ostream& oss) const
+{
+ const MEDFileEquivalences *equiv(_equiv);
+ if(!equiv)
+ return ;
+ oss << "(******************************)\n(* EQUIVALENCES OF THE MESH : *)\n(******************************)\n";
+ _equiv->getRepr(oss);
+}
+
/*!
* \brief Return number of joints, which is equal to number of adjacent mesh domains
*/
-int MEDFileMesh::getNumberOfJoints()
+int MEDFileMesh::getNumberOfJoints() const
{
- return ( (MEDFileJoints*) _joints ) ? _joints->getNumberOfJoints() : 0;
+ return ( (const MEDFileJoints *) _joints ) ? _joints->getNumberOfJoints() : 0;
}
/*!
*
* \sa loadPartUMeshFromFile
*/
-void MEDFileUMesh::loadUMeshFromFile(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs)
+void MEDFileUMesh::loadLL(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs)
{
MEDFileUMeshL2 loaderl2;
ParaMEDMEM::MEDCouplingMeshType meshType;
if((const MEDFileUMeshSplitL1 *)(*it)!=0)
(*it)->write(fid,meshName,mdim);
MEDFileUMeshL2::WriteFamiliesAndGrps(fid,meshName,_families,_groups,_too_long_str);
-
- writeJoints(fid);
}
/*!
}
oss << std::endl << std::endl;
getFamilyRepr(oss);
+ getEquivalencesRepr(oss);
return oss.str();
}
return sp->getGeoTypes();
}
+int MEDFileUMesh::getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType ct) const
+{
+ const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(ct);
+ const MEDFileUMeshSplitL1 *sp(getMeshAtLevSafe( ((int)cm.getDimension())-getMeshDimension() ));
+ return sp->getNumberOfCellsWithType(ct);
+}
+
/*!
* This method extracts from whole family field ids the part relative to the input parameter \a gt.
* \param [in] gt - the geometric type for which the family field is asked.
}
}
+int MEDFileStructuredMesh::getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType ct) const
+{
+ if(ct!=MEDCouplingStructuredMesh::GetGeoTypeGivenMeshDimension(getMeshDimension()))
+ return 0;
+ else
+ return getNumberOfCellsAtLevel(0);
+}
+
void MEDFileStructuredMesh::whichAreNodesFetched(const MEDFileField1TSStructItem& st, const MEDFileFieldGlobsReal *globs, std::vector<bool>& nodesFetched) const
{
if(st.getNumberOfItems()!=1)
MEDFileMesh *MEDFileCMesh::deepCpy() const
{
MEDCouplingAutoRefCountObjectPtr<MEDFileCMesh> ret=new MEDFileCMesh(*this);
+ ret->deepCpyEquivalences(*this);
if((const MEDCouplingCMesh*)_cmesh)
ret->_cmesh=static_cast<MEDCouplingCMesh*>(_cmesh->deepCpy());
ret->deepCpyAttributes();
MEDFileCMesh::MEDFileCMesh(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs)
try
{
- loadCMeshFromFile(fid,mName,dt,it,mrs);
- loadJointsFromFile(fid);
+ loadLLWithAdditionalItems(fid,mName,dt,it,mrs);
}
catch(INTERP_KERNEL::Exception& e)
{
throw e;
}
-void MEDFileCMesh::loadCMeshFromFile(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs)
+void MEDFileCMesh::loadLL(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs)
{
ParaMEDMEM::MEDCouplingMeshType meshType;
int dummy0,dummy1;
//
std::string meshName(MEDLoaderBase::buildStringFromFortran(maa,MED_NAME_SIZE));
MEDFileStructuredMesh::writeStructuredLL(fid,meshName);
-
- writeJoints(fid);
}
void MEDFileCMesh::synchronizeTinyInfoOnLeaves() const
MEDFileMesh *MEDFileCurveLinearMesh::deepCpy() const
{
MEDCouplingAutoRefCountObjectPtr<MEDFileCurveLinearMesh> ret=new MEDFileCurveLinearMesh(*this);
+ ret->deepCpyEquivalences(*this);
if((const MEDCouplingCurveLinearMesh*)_clmesh)
ret->_clmesh=static_cast<MEDCouplingCurveLinearMesh*>(_clmesh->deepCpy());
ret->deepCpyAttributes();
MEDFileCurveLinearMesh::MEDFileCurveLinearMesh(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs)
try
{
- loadCLMeshFromFile(fid,mName,dt,it,mrs);
- loadJointsFromFile(fid);
+ loadLLWithAdditionalItems(fid,mName,dt,it,mrs);
}
catch(INTERP_KERNEL::Exception& e)
{
//
std::string meshName(MEDLoaderBase::buildStringFromFortran(maa,MED_NAME_SIZE));
MEDFileStructuredMesh::writeStructuredLL(fid,meshName);
-
- writeJoints(fid);
}
-void MEDFileCurveLinearMesh::loadCLMeshFromFile(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs)
+void MEDFileCurveLinearMesh::loadLL(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs)
{
ParaMEDMEM::MEDCouplingMeshType meshType;
int dummy0,dummy1;
#include "MEDCouplingPartDefinition.hxx"
#include "MEDFileMeshReadSelector.hxx"
#include "MEDFileJoint.hxx"
+#include "MEDFileEquivalence.hxx"
#include <map>
#include <list>
MEDLOADER_EXPORT int getIteration() const { return _iteration; }
MEDLOADER_EXPORT void setTimeValue(double time) { _time=time; }
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 getTime(int& dt, int& it) const { dt=_iteration; it=_order; return _time; }
MEDLOADER_EXPORT double getTimeValue() const { return _time; }
MEDLOADER_EXPORT void setTimeUnit(const std::string& unit) { _dt_unit=unit; }
MEDLOADER_EXPORT std::string getTimeUnit() const { return _dt_unit; }
MEDLOADER_EXPORT virtual int buildImplicitPartIfAny(INTERP_KERNEL::NormalizedCellType gt) const = 0;
MEDLOADER_EXPORT virtual void releaseImplicitPartIfAny() const = 0;
MEDLOADER_EXPORT virtual std::vector<INTERP_KERNEL::NormalizedCellType> getGeoTypesAtLevel(int meshDimRelToMax) const = 0;
+ MEDLOADER_EXPORT virtual int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType ct) 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 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;
- MEDLOADER_EXPORT int getNumberOfJoints();
+ MEDLOADER_EXPORT int getNumberOfJoints() const;
MEDLOADER_EXPORT MEDFileJoints *getJoints() const;
- MEDLOADER_EXPORT void setJoints( MEDFileJoints* joints );
+ MEDLOADER_EXPORT void setJoints( MEDFileJoints* joints );
+ MEDFileEquivalences *getEquivalences() { return _equiv; }
+ const MEDFileEquivalences *getEquivalences() const { return _equiv; }
+ void killEquivalences() { _equiv=(MEDFileEquivalences *)0; }
+ void initializeEquivalences() { _equiv=MEDFileEquivalences::New(this); }
protected:
MEDFileMesh();
//! protected because no way in MED file API to specify this name
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;
virtual std::list< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > getAllNonNullFamilyIds() const = 0;
+ virtual void loadLL(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs) = 0;
+ void loadLLWithAdditionalItems(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs);
void addGroupUnderground(bool isNodeGroup, const DataArrayInt *ids, DataArrayInt *famArr);
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 std::string& familyNameToChange, const std::vector<std::string>& newFamiliesNames);
static std::string CreateNameNotIn(const std::string& nameTry, const std::vector<std::string>& namesToAvoid);
static int PutInThirdComponentOfCodeOffset(std::vector<int>& code, int strt);
void writeJoints(med_idt fid) const;
- void loadJointsFromFile(med_idt fid, MEDFileJoints* toUseInstedOfReading=0);
+ void loadJointsFromFile(med_idt fid, MEDFileJoints *toUseInstedOfReading=0);
+ void loadEquivalences(med_idt fid);
+ void deepCpyEquivalences(const MEDFileMesh& other);
+ bool areEquivalencesEqual(const MEDFileMesh *other, std::string& what) const;
+ void getEquivalencesRepr(std::ostream& oss) const;
protected:
int _order;
int _iteration;
bool _univ_wr_status;
std::string _desc_name;
MEDCouplingAutoRefCountObjectPtr<MEDFileJoints> _joints;
+ MEDCouplingAutoRefCountObjectPtr<MEDFileEquivalences> _equiv;
protected:
std::map<std::string, std::vector<std::string> > _groups;
std::map<std::string,int> _families;
MEDLOADER_EXPORT int buildImplicitPartIfAny(INTERP_KERNEL::NormalizedCellType gt) const;
MEDLOADER_EXPORT void releaseImplicitPartIfAny() const;
MEDLOADER_EXPORT std::vector<INTERP_KERNEL::NormalizedCellType> getGeoTypesAtLevel(int meshDimRelToMax) const;
+ MEDLOADER_EXPORT int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType ct) const;
MEDLOADER_EXPORT void whichAreNodesFetched(const MEDFileField1TSStructItem& st, const MEDFileFieldGlobsReal *globs, std::vector<bool>& nodesFetched) const;
MEDLOADER_EXPORT std::vector<int> getNonEmptyLevels() const;
MEDLOADER_EXPORT std::vector<int> getNonEmptyLevelsExt() const;
MEDFileUMesh();
MEDFileUMesh(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs);
void loadPartUMeshFromFile(med_idt fid, const std::string& mName, const std::vector<INTERP_KERNEL::NormalizedCellType>& types, const std::vector<int>& slicPerTyp, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0);
- void loadUMeshFromFile(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs);
+ void loadLL(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs);
void dispatchLoadedPart(med_idt fid, const MEDFileUMeshL2& loaderl2, const std::string& mName, MEDFileMeshReadSelector *mrs);
const MEDFileUMeshSplitL1 *getMeshAtLevSafe(int meshDimRelToMaxExt) const;
MEDFileUMeshSplitL1 *getMeshAtLevSafe(int meshDimRelToMaxExt);
MEDLOADER_EXPORT void releaseImplicitPartIfAny() const;
MEDLOADER_EXPORT MEDCoupling1SGTUMesh *getImplicitFaceMesh() const;
MEDLOADER_EXPORT std::vector<INTERP_KERNEL::NormalizedCellType> getGeoTypesAtLevel(int meshDimRelToMax) const;
+ MEDLOADER_EXPORT int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType ct) const;
MEDLOADER_EXPORT void whichAreNodesFetched(const MEDFileField1TSStructItem& st, const MEDFileFieldGlobsReal *globs, std::vector<bool>& nodesFetched) const;
MEDLOADER_EXPORT virtual const MEDCouplingStructuredMesh *getStructuredMesh() const = 0;
// tools
MEDFileCMesh();
void synchronizeTinyInfoOnLeaves() const;
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);
+ void loadLL(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs);
private:
MEDCouplingAutoRefCountObjectPtr<MEDCouplingCMesh> _cmesh;
};
const MEDCouplingStructuredMesh *getStructuredMesh() const;
void synchronizeTinyInfoOnLeaves() const;
void writeLL(med_idt fid) const;
- void loadCLMeshFromFile(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs);//to imp
+ void loadLL(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs);//to imp
private:
MEDCouplingAutoRefCountObjectPtr<MEDCouplingCurveLinearMesh> _clmesh;
};
return _m_by_types.getGeoTypes();
}
+int MEDFileUMeshSplitL1::getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType ct) const
+{
+ return _m_by_types.getNumberOfCellsWithType(ct);
+}
+
MEDCouplingUMesh *MEDFileUMeshSplitL1::getWholeMesh(bool renum) const
{
MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> tmp;
return _m->getAllGeoTypesSorted();
}
+int MEDFileUMeshAggregateCompute::getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType ct) const
+{
+ if(_mp_time>=_m_time)
+ {
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> >::const_iterator it=_m_parts.begin();it!=_m_parts.end();it++)
+ {
+ const MEDCoupling1GTUMesh *elt(*it);
+ if(elt && elt->getCellModelEnum()==ct)
+ return elt->getNumberOfCells();
+ }
+ return 0;
+ }
+ else
+ return _m->getNumberOfCellsWithType(ct);
+}
+
std::vector<MEDCoupling1GTUMesh *> MEDFileUMeshAggregateCompute::retrievePartsWithoutComputation() const
{
if(_mp_time<_m_time)
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;
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;
#include "MEDFileField.hxx"
#include "MEDFileParameter.hxx"
#include "MEDFileData.hxx"
+#include "MEDFileEquivalence.hxx"
#include "MEDFileMeshReadSelector.hxx"
#include "MEDFileFieldOverView.hxx"
#include "MEDLoaderTypemaps.i"
%newobject ParaMEDMEM::MEDFileMesh::getNodeFamiliesArr;
%newobject ParaMEDMEM::MEDFileMesh::getAllFamiliesIdsReferenced;
%newobject ParaMEDMEM::MEDFileMesh::computeAllFamilyIdsInUse;
+%newobject ParaMEDMEM::MEDFileMesh::getEquivalences;
%newobject ParaMEDMEM::MEDFileData::getJoints;
%newobject ParaMEDMEM::MEDFileStructuredMesh::getImplicitFaceMesh;
%newobject ParaMEDMEM::MEDFileUMesh::New;
%newobject ParaMEDMEM::MEDFileJoints::getJointAtPos;
%newobject ParaMEDMEM::MEDFileJoints::getJointWithName;
%newobject ParaMEDMEM::MEDFileJoints::__getitem__;
+%newobject ParaMEDMEM::MEDFileEquivalences::getEquivalence;
+%newobject ParaMEDMEM::MEDFileEquivalences::getEquivalenceWithName;
+%newobject ParaMEDMEM::MEDFileEquivalences::appendEmptyEquivalenceWithName;
+%newobject ParaMEDMEM::MEDFileEquivalencePair::initCell;
+%newobject ParaMEDMEM::MEDFileEquivalencePair::initNode;
+%newobject ParaMEDMEM::MEDFileEquivalencePair::getCell;
+%newobject ParaMEDMEM::MEDFileEquivalencePair::getNode;
+%newobject ParaMEDMEM::MEDFileEquivalenceData::getArray;
+%newobject ParaMEDMEM::MEDFileEquivalenceCell::getArray;
%newobject ParaMEDMEM::SauvWriter::New;
%newobject ParaMEDMEM::SauvReader::New;
%feature("unref") MEDFileJointOneStep "$this->decrRef();"
%feature("unref") MEDFileJoint "$this->decrRef();"
%feature("unref") MEDFileJoints "$this->decrRef();"
+%feature("unref") MEDFileEquivalences "$this->decrRef();"
+%feature("unref") MEDFileEquivalencePair "$this->decrRef();"
+%feature("unref") MEDFileEquivalenceBase "$this->decrRef();"
+%feature("unref") MEDFileEquivalenceData "$this->decrRef();"
+%feature("unref") MEDFileEquivalenceCell "$this->decrRef();"
+%feature("unref") MEDFileEquivalenceNode "$this->decrRef();"
%feature("unref") MEDFileData "$this->decrRef();"
%feature("unref") SauvReader "$this->decrRef();"
%feature("unref") SauvWriter "$this->decrRef();"
}
}
};
+
class MEDFileJointCorrespondence : public RefCountObject, public MEDFileWritable
{
public:
}
}
};
+
class MEDFileJoint : public RefCountObject, public MEDFileWritable
{
public:
}
}
};
+
+ class MEDFileEquivalenceBase : public RefCountObject
+ {
+ private:
+ MEDFileEquivalenceBase();
+ };
+
+ class MEDFileEquivalenceData : public MEDFileEquivalenceBase
+ {
+ private:
+ MEDFileEquivalenceData();
+ public:
+ void setArray(DataArrayInt *data);
+ %extend
+ {
+ DataArrayInt *getArray()
+ {
+ DataArrayInt *ret(self->getArray());
+ if(ret) ret->incrRef();
+ return ret;
+ }
+ }
+ };
+
+ class MEDFileEquivalenceNode : public MEDFileEquivalenceData
+ {
+ private:
+ MEDFileEquivalenceNode();
+ };
+
+ class MEDFileEquivalenceCell : public MEDFileEquivalenceBase
+ {
+ private:
+ MEDFileEquivalenceCell();
+ public:
+ void clear();
+ std::size_t size() const;
+ void setArray(int meshDimRelToMax, DataArrayInt *da) throw(INTERP_KERNEL::Exception);
+ void setArrayForType(INTERP_KERNEL::NormalizedCellType type, DataArrayInt *da) throw(INTERP_KERNEL::Exception);
+ %extend
+ {
+ DataArrayInt *getArray(INTERP_KERNEL::NormalizedCellType type) throw(INTERP_KERNEL::Exception)
+ {
+ DataArrayInt *ret(self->getArray(type));
+ if(ret) ret->incrRef();
+ return ret;
+ }
+
+ PyObject *getTypes() const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<INTERP_KERNEL::NormalizedCellType> result(self->getTypes());
+ 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;
+ }
+ }
+ };
+
+ class MEDFileEquivalencePair : public RefCountObject
+ {
+ private:
+ MEDFileEquivalencePair();
+ public:
+ std::string getName() const;
+ void setName(const std::string& name);
+ std::string getDescription() const;
+ void setDescription(const std::string& descr);
+ void setArray(int meshDimRelToMaxExt, DataArrayInt *da);;
+ %extend
+ {
+ MEDFileEquivalenceCell *initCell()
+ {
+ MEDFileEquivalenceCell *ret(self->initCell());
+ if(ret) ret->incrRef();
+ return ret;
+ }
+
+ MEDFileEquivalenceNode *initNode()
+ {
+ MEDFileEquivalenceNode *ret(self->initNode());
+ if(ret) ret->incrRef();
+ return ret;
+ }
+
+ MEDFileEquivalenceCell *getCell()
+ {
+ MEDFileEquivalenceCell *ret(self->getCell());
+ if(ret) ret->incrRef();
+ return ret;
+ }
+
+ MEDFileEquivalenceNode *getNode()
+ {
+ MEDFileEquivalenceNode *ret(self->getNode());
+ if(ret) ret->incrRef();
+ return ret;
+ }
+ }
+ };
+
+ class MEDFileEquivalences : public RefCountObject
+ {
+ private:
+ MEDFileEquivalences();
+ public:
+ int size() const;
+ std::vector<std::string> getEquivalenceNames() const throw(INTERP_KERNEL::Exception);
+ void killEquivalenceWithName(const std::string& name) throw(INTERP_KERNEL::Exception);
+ void killEquivalenceAt(int i) throw(INTERP_KERNEL::Exception);
+ void clear();
+ %extend
+ {
+ MEDFileEquivalencePair *getEquivalence(int i) throw(INTERP_KERNEL::Exception)
+ {
+ MEDFileEquivalencePair *ret(self->getEquivalence(i));
+ if(ret) ret->incrRef();
+ return ret;
+ }
+ MEDFileEquivalencePair *getEquivalenceWithName(const std::string& name) throw(INTERP_KERNEL::Exception)
+ {
+ MEDFileEquivalencePair *ret(self->getEquivalenceWithName(name));
+ if(ret) ret->incrRef();
+ return ret;
+ }
+
+ MEDFileEquivalencePair *appendEmptyEquivalenceWithName(const std::string& name) throw(INTERP_KERNEL::Exception)
+ {
+ MEDFileEquivalencePair *ret(self->appendEmptyEquivalenceWithName(name));
+ if(ret) ret->incrRef();
+ return ret;
+ }
+ }
+ };
class MEDFileMesh : public RefCountObject, public MEDFileWritable
{
virtual bool hasImplicitPart() const throw(INTERP_KERNEL::Exception);
virtual int buildImplicitPartIfAny(INTERP_KERNEL::NormalizedCellType gt) const throw(INTERP_KERNEL::Exception);
virtual void releaseImplicitPartIfAny() const throw(INTERP_KERNEL::Exception);
+ virtual int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType ct) 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> getNameArrNonEmptyLevelsExt() const throw(INTERP_KERNEL::Exception);
virtual DataArrayInt *getNodeFamiliesArr(const std::vector<std::string>& fams, bool renum=false) const throw(INTERP_KERNEL::Exception);
int getNumberOfJoints();
MEDFileJoints *getJoints();
- void setJoints( MEDFileJoints* joints );
+ void setJoints( MEDFileJoints* joints );
+ void initializeEquivalences();
+ void killEquivalences();
%extend
{
std::string __str__() const throw(INTERP_KERNEL::Exception)
PyTuple_SetItem(ret,3,SWIG_NewPointerObj(SWIG_as_voidptr(ret3),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
return ret;
}
+
+ MEDFileEquivalences *getEquivalences() throw(INTERP_KERNEL::Exception)
+ {
+ MEDFileEquivalences *ret(self->getEquivalences());
+ if(ret) ret->incrRef();
+ return ret;
+ }
}
};
self.assertTrue(mesh.isEqual(mm2,1e-12)[0])
pass
+ def testMEDFileEquivalence1(self):
+ """ First check of equivalence implementation in MEDFileMesh"""
+ fileName="Pyfile97.med"
+ meshName="M_01"
+ mm=MEDFileUMesh()
+ coo=DataArrayDouble([(0,0,0),(6,0,0),(19,0,0),(36,0,0),(0,4,0),(6,4,0),(19,4,0),(36,4,0),(0,13,0),(6,13,0),(19,13,0),(36,13,0),(0,24,0),(6,24,0),(19,24,0),(36,24,0),(0,0,6),(6,0,6),(19,0,6),(36,0,6),(0,4,6),(6,4,6),(19,4,6),(36,4,6),(0,13,6),(6,13,6),(19,13,6),(36,13,6),(0,24,6),(6,24,6),(19,24,6),(36,24,6),(6,0,3),(6,2,0),(12.5,0,0),(19,0,3),(19,2,0),(6,4,3),(12.5,4,0),(19,4,3),(6,2,6),(12.5,0,6),(19,2,6),(12.5,4,6),(6,2,3),(12.5,0,3),(12.5,2,0),(19,2,3),(12.5,4,3),(12.5,2,6),(12.5,2,3)])
+ coo.setInfoOnComponents(["X [Sans_unite]","Y [Sans_unite]","Z [Sans_unite]"])
+ connQ4=DataArrayInt([1,17,21,5,2,18,22,6,21,5,6,22,1,32,44,33,17,40,44,32,21,37,44,40,5,33,44,37,2,35,47,36,18,42,47,35,22,39,47,42,6,36,47,39,21,37,48,43,5,38,48,37,6,39,48,38,22,43,48,39])
+ m1=MEDCoupling1SGTUMesh(meshName,NORM_QUAD4) ; m1.setCoords(coo) ; m1.setNodalConnectivity(connQ4) ; mm[-1]=m1
+ connH8=DataArrayInt([20,16,17,21,4,0,1,5,22,18,19,23,6,2,3,7,24,20,21,25,8,4,5,9,25,21,22,26,9,5,6,10,26,22,23,27,10,6,7,11,28,24,25,29,12,8,9,13,29,25,26,30,13,9,10,14,30,26,27,31,14,10,11,15,21,40,49,43,37,44,50,48,40,17,41,49,44,32,45,50,49,41,18,42,50,45,35,47,43,49,42,22,48,50,47,39,44,32,45,50,33,1,34,46,37,44,50,48,5,33,46,38,48,50,47,39,38,46,36,6,50,45,35,47,46,34,2,36])
+ m0=MEDCoupling1SGTUMesh(meshName,NORM_HEXA8) ; m0.setCoords(coo) ; m0.setNodalConnectivity(connH8) ; mm[0]=m0
+ mm.getFamilyFieldAtLevel(-1)[:]=-2
+ mm.getFamilyFieldAtLevel(0)[:]=0
+ mm.addFamily("HOMARD________-1",-1)
+ mm.addFamily("HOMARD________-2",-2)
+ mm.addFamily("HOMARD________-3",-3)
+ mm.setFamiliesIdsOnGroup("HOMARD",[-1,-2,-3])
+
+ eqName="MAILLES_A_RECOLLER_APRES_HOMARD"
+ descEq="Cette equivalence decrit les mailles a recoller. Dans chaque correspondance, le premier numero est celui de la maille coupee ; le second numero est celui d'une des petites mailles en regard."
+ mm.initializeEquivalences()
+ eqs=mm.getEquivalences()
+ eq0=eqs.appendEmptyEquivalenceWithName(eqName)
+ eq0.setDescription(descEq)
+ corr=DataArrayInt([(0,3),(0,4),(0,5),(0,6),(1,7),(1,8),(1,9),(1,10),(2,11),(2,12),(2,13),(2,14)])
+ eq0.setArray(-1,corr)
+ self.assertEqual(eq0.getCell().size(),1)
+ self.assertTrue(eq0.getCell().getArray(NORM_QUAD4).isEqual(corr))
+ eq0.getCell().clear()
+ self.assertEqual(eq0.getCell().size(),0)
+ eq0.getCell().setArrayForType(NORM_QUAD4,corr)
+ self.assertEqual(eq0.getCell().size(),1)
+ self.assertTrue(eq0.getCell().getArray(NORM_QUAD4).isEqual(corr))
+ mm.killEquivalences()
+ mm.initializeEquivalences()
+ eqs=mm.getEquivalences()
+ eq0=eqs.appendEmptyEquivalenceWithName(eqName)
+ eq0.setDescription(descEq)
+ c=eq0.initCell()
+ c.setArrayForType(NORM_QUAD4,corr)
+ self.assertEqual(eq0.getCell().size(),1)
+ self.assertTrue(eq0.getCell().getArray(NORM_QUAD4).isEqual(corr))
+ mm2=mm.deepCpy()
+ self.assertTrue(mm.isEqual(mm2,1e-12)[0])
+ self.assertEqual(mm2.getEquivalences().size(),1)
+ self.assertTrue(mm2.getEquivalences().getEquivalence(0).getCell().getArray(NORM_QUAD4).isEqual(corr))
+ mm2.getEquivalences().getEquivalence(0).getCell().getArray(NORM_QUAD4)[0,0]=2
+ self.assertTrue(not mm.isEqual(mm2,1e-12)[0])
+ mm2.getEquivalences().getEquivalence(0).getCell().getArray(NORM_QUAD4)[0,0]=0
+ self.assertTrue(mm.isEqual(mm2,1e-12)[0])
+ mm.write(fileName,2)
+ #
+ mm3=MEDFileMesh.New(fileName)
+ self.assertTrue(mm.isEqual(mm3,1e-12)[0])
+ pass
+
pass
if __name__ == "__main__":