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;
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
}
MEDFILESAFECALLERWR0(MEDmeshCr,(fid,maa,spaceDim,mdim,MED_UNSTRUCTURED_MESH,desc,"",MED_SORT_DTIT,MED_CARTESIAN,comp,unit));
- MEDFILESAFECALLERWR0(MEDmeshUniversalNameWr,(fid,maa));
+ if(_univ_wr_status)
+ MEDFILESAFECALLERWR0(MEDmeshUniversalNameWr,(fid,maa));
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,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.
_groups.erase(*it);
}
-void MEDFileUMesh::duplicateNodesOnM1Group(const std::string& grpNameM1, DataArrayInt *&nodesDuplicated,
+/**
+ * \b this must be filled at level 0 and -1, typically the -1 level being (part of) the descending connectivity
+ * of the top level. This method build a "crack", or an inner boundary, in \b this along the group of level -1 named grpNameM1.
+ * The boundary is built according to the following method:
+ * - all nodes along the boundary which are not lying on an internal extremity of the (-1)-level group are duplicated (so the
+ * coordinates array is extended).
+ * - new (-1)-level cells are built lying on those new nodes. So the edges/faces along the group are duplicated.
+ * After this operation a top-level cell bordering the group will loose some neighbors (typically the cell which is on the
+ * other side of the group is no more a neighbor)
+ * - finally, the connectivity of (part of) the top level-cells bordering the group is also modified so that some cells
+ * bordering the newly created boundary use the newly computed nodes.
+ *
+ * \param[in] grpNameM1 name of the (-1)-level group defining the boundary
+ * \param[out] nodesDuplicated ids of the initial nodes which have been duplicated (and whose copy is put at the end of
+ * the coord array)
+ * \param[out] cellsModified ids of the cells whose connectivity has been modified (to use the newly created nodes)
+ * \param[out] cellsNotModified ids of the rest of cells bordering the new boundary whose connectivity remains unchanged.
+ */
+void MEDFileUMesh::buildInnerBoundaryAlongM1Group(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())
- throw INTERP_KERNEL::Exception("MEDFileUMesh::duplicateNodesOnM1Group : This method works only for mesh definied on level 0 and -1 !");
+ throw INTERP_KERNEL::Exception("MEDFileUMesh::buildInnerBoundaryAlongM1Group : This method works only for mesh definied on level 0 and -1 !");
MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> m0=getMeshAtLevel(0);
MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> m1=getMeshAtLevel(-1);
int nbNodes=m0->getNumberOfNodes();
newm1->setName(getName());
const DataArrayInt *fam=getFamilyFieldAtLevel(-1);
if(!fam)
- throw INTERP_KERNEL::Exception("MEDFileUMesh::duplicateNodesOnM1Group : internal problem !");
+ throw INTERP_KERNEL::Exception("MEDFileUMesh::buildInnerBoundaryAlongM1Group : internal problem !");
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newFam=DataArrayInt::New();
newFam->alloc(newm1->getNumberOfCells(),1);
- int idd=getMaxFamilyId()+1;
+ // Get a new family ID: care must be taken if we need a positive ID or a negative one:
+ // Positive ID for family of nodes, negative for all the rest.
+ int idd;
+ if (m1->getMeshDimension() == 0)
+ idd=getMaxFamilyId()+1;
+ else
+ idd=getMinFamilyId()-1;
int globStart=0,start=0,end,globEnd;
int nbOfChunks=szOfCellGrpOfSameType->getNumberOfTuples();
for(int i=0;i<nbOfChunks;i++)
return ret;
}
+/*! \cond HIDDEN_ITEMS */
struct MEDLoaderAccVisit1
{
MEDLoaderAccVisit1():_new_nb_of_nodes(0) { }
int operator()(bool val) { return val?_new_nb_of_nodes++:-1; }
int _new_nb_of_nodes;
};
+/*! \endcond */
/*!
* Array returned is the correspondance in \b old \b to \b new format. The returned array is newly created and should be dealt by the caller.
continue;
MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> m1Tmp(getMeshAtLevel(*lev));
MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> m1(dynamic_cast<MEDCouplingUMesh *>(m1Tmp->deepCpy()));
- {
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> notUsed(m1->convertLinearCellsToQuadratic(conversionType));
- }
- MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> m1Coords(m1->getCoords()->selectByTupleId2(initialNbNodes,m1->getNumberOfNodes(),1));
- DataArrayInt *b(0);
- bool a(partZeCoords->areIncludedInMe(m1Coords,eps,b));
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> bSafe(b);
- if(!a)
+ if(m1->getMeshDimension()!=0)
{
- std::ostringstream oss; oss << "MEDFileUMesh::linearCellsToQuadratic : for level " << *lev << " problem to identify nodes generated !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> notUsed(m1->convertLinearCellsToQuadratic(conversionType));
+ }//kill unused notUsed var
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> m1Coords(m1->getCoords()->selectByTupleId2(initialNbNodes,m1->getNumberOfNodes(),1));
+ DataArrayInt *b(0);
+ bool a(partZeCoords->areIncludedInMe(m1Coords,eps,b));
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> bSafe(b);
+ if(!a)
+ {
+ std::ostringstream oss; oss << "MEDFileUMesh::linearCellsToQuadratic : for level " << *lev << " problem to identify nodes generated !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ b->applyLin(1,initialNbNodes);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> l0(DataArrayInt::New()); l0->alloc(initialNbNodes,1); l0->iota();
+ std::vector<const DataArrayInt *> v(2); v[0]=l0; v[1]=b;
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renum(DataArrayInt::Aggregate(v));
+ m1->renumberNodesInConn(renum->begin());
}
- b->applyLin(1,initialNbNodes);
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> l0(DataArrayInt::New()); l0->alloc(initialNbNodes,1); l0->iota();
- std::vector<const DataArrayInt *> v(2); v[0]=l0; v[1]=b;
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renum(DataArrayInt::Aggregate(v));
- m1->renumberNodesInConn(renum->begin());
m1->setCoords(zeCoords);
ret->setMeshAtLevel(*lev,m1);
famField=getFamilyFieldAtLevel(*lev);
}
}
+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;
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
}
MEDFILESAFECALLERWR0(MEDmeshCr,(fid,maa,spaceDim,spaceDim,MED_STRUCTURED_MESH,desc,dtunit,MED_SORT_DTIT,MED_CARTESIAN,comp,unit));
- MEDFILESAFECALLERWR0(MEDmeshUniversalNameWr,(fid,maa));
+ if(_univ_wr_status)
+ MEDFILESAFECALLERWR0(MEDmeshUniversalNameWr,(fid,maa));
MEDFILESAFECALLERWR0(MEDmeshGridTypeWr,(fid,maa,MED_CARTESIAN_GRID));
for(int i=0;i<spaceDim;i++)
{
//
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)
{
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
}
MEDFILESAFECALLERWR0(MEDmeshCr,(fid,maa,spaceDim,meshDim,MED_STRUCTURED_MESH,desc,dtunit,MED_SORT_DTIT,MED_CARTESIAN,comp,unit));
- MEDFILESAFECALLERWR0(MEDmeshUniversalNameWr,(fid,maa));
+ if(_univ_wr_status)
+ MEDFILESAFECALLERWR0(MEDmeshUniversalNameWr,(fid,maa));
MEDFILESAFECALLERWR0(MEDmeshGridTypeWr,(fid,maa,MED_CURVILINEAR_GRID));
std::vector<int> nodeGridSt=_clmesh->getNodeGridStructure();
MEDFILESAFECALLERWR0(MEDmeshGridStructWr,(fid,maa,_iteration,_order,_time,&nodeGridSt[0]));
//
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;