-// Copyright (C) 2007-2020 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2021 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 <limits>
#include <cmath>
+// From MEDLOader.cxx TU
extern med_geometry_type typmai[MED_N_CELL_FIXED_GEO];
extern INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO];
extern med_geometry_type typmai3[INTERP_KERNEL::NORM_MAXTYPE];
if(idsToKill->empty())
return ;
std::vector<std::string> newFamsOnGrp;
- for(std::vector<std::string>::const_iterator it=famsOnGrp.begin();it!=famsOnGrp.end();it++)
+ for(std::vector<std::string>::const_iterator itt=famsOnGrp.begin();itt!=famsOnGrp.end();itt++)
{
- if(!idsToKill->presenceOfValue(getFamilyId(*it)))
- newFamsOnGrp.push_back(*it);
+ if(!idsToKill->presenceOfValue(getFamilyId(*itt)))
+ newFamsOnGrp.push_back(*itt);
}
(*it).second=newFamsOnGrp;
}
{
fams=getFamilyFieldAtLevel(*it);
}
- catch(INTERP_KERNEL::Exception& e) { }
+ catch(INTERP_KERNEL::Exception& ) { }
if(!fams)
continue;
std::vector<bool> v(fams->getNumberOfTuples(),false);
{
fams=getFamilyFieldAtLevel(*it);
}
- catch(INTERP_KERNEL::Exception& e) { }
+ catch(INTERP_KERNEL::Exception& ) { }
if(!fams)
continue;
MCAuto<DataArrayIdType> idsToModif(fams->findIdsEqualList(famIdsSubstSession.second.data(),famIdsSubstSession.second.data()+famIdsSubstSession.second.size()));
}
/*!
- * Returns ids of nodes contained in a given group.
- * \param [in] grp - the name of the group of interest.
+ * Returns ids of nodes contained in a given family.
+ * \param [in] fam - the name of the family of interest.
* \param [in] renum - if \c true, the optional numbers of nodes, if available, are
* returned instead of ids.
* \return DataArrayIdType * - a new instance of DataArrayIdType holding either ids or
- * numbers, if available and required, of nodes of the group. The caller
+ * numbers, if available and required, of nodes of the family. The caller
* is to delete this array using decrRef() as it is no more needed.
- * \throw If the name of a nonexistent group is specified.
+ * \throw If the name of a nonexistent family is specified.
* \throw If the family field is missing for nodes.
*/
DataArrayIdType *MEDFileMesh::getNodeFamilyArr(const std::string& fam, bool renum) const
{
if(offset<0)
std::transform((*it1).begin(),(*it1).end(),(*it1).begin(),std::negate<mcIdType>());
- std::transform((*it1).begin(),(*it1).end(),(*it1).begin(),std::bind2nd(std::plus<mcIdType>(),offset));
+ std::transform((*it1).begin(),(*it1).end(),(*it1).begin(),std::bind(std::plus<mcIdType>(),std::placeholders::_1,offset));
}
}
* \param [in] fileName - the name of the file.
* \param [in] mName - the name of the mesh to be read.
* \param [in] types - the list of the geo types of which some part will be taken. A geometric type in \a types must appear only once at most.
- * \param [in] slicPerType - an array of size 3 times larger than \a types that specifies for each type in \a types (in the same order) resp the start, the stop and the step.
+ * \param [in] slicPerTyp - an array of size 3 times larger than \a types that specifies for each type in \a types (in the same order) resp the start, the stop and the step.
* \param [in] dt - the iteration, that is to say the first element of the pair that locates the asked time step.
* \param [in] it - the order, that is to say the second element of the pair that locates the asked time step.
* \param [in] mrs - the request for what to be loaded.
return ret.retn();
}
+/*!
+ * This method is an helper to load only consecutive nodes chunk of data of MED file pointed by \a fileName.
+ * Consecutive chunk is specified classicaly by start (included) stop (excluded) format with \a startNodeId and \a stopNodeId respectively.
+ * This method returns 5 elements.
+ *
+ * \param [in] fileName - Name of file nodes to be read of.
+ * \param [in] mName - Name of the mesh inside file pointed be \a fileName nodes to be read of.
+ * \param [in] dt - Time iteration inside file pointed be \a fileName nodes to be read of.
+ * \param [in] it - Time order inside file pointed be \a fileName nodes to be read of.
+ * \param [in] infosOnComp - Components info of nodes to be read of. The size of string vector should be equal to space dimension of mesh to be read.
+ * \param [in] startNodeId - Start Node Id (included) of chunk of data to be read
+ * \param [in] stopNodeId - Start Node Id (included) of chunk of data to be read
+ * \param [out] coords - output coordinates of requested chunk (DataArrayDouble)
+ * \param [out] partCoords - output PartDefinition object of chunk
+ * \param [out] famCoords - output family id field of requested chunk (DataArrayIdType)
+ * \param [out] numCoords - output num id field of requested chunk (DataArrayIdType)
+ * \param [out] nameCoords - output names on nodes of requested chunk (DataArrayAsciiChar)
+ *
+ * \sa MEDLoaderUMesh::LoadPartOf
+ */
+void MEDFileUMesh::LoadPartCoords(const std::string& fileName, const std::string& mName, int dt, int it, const std::vector<std::string>& infosOnComp, mcIdType startNodeId, mcIdType stopNodeId,
+MCAuto<DataArrayDouble>& coords, MCAuto<PartDefinition>& partCoords, MCAuto<DataArrayIdType>& famCoords, MCAuto<DataArrayIdType>& numCoords, MCAuto<DataArrayAsciiChar>& nameCoords)
+{
+ MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
+ MEDFileUMeshL2::LoadPartCoords(fid,infosOnComp,mName,dt,it,startNodeId,stopNodeId,coords,partCoords,famCoords,numCoords,nameCoords);
+}
+
std::size_t MEDFileUMesh::getHeapMemorySizeWithoutChildren() const
{
std::size_t ret(MEDFileMesh::getHeapMemorySizeWithoutChildren());
if(!mrs || mrs->isGlobalNodeNumFieldReading())
_global_num_coords=loaderl2.getCoordsGlobalNum();
_part_coords=loaderl2.getPartDefOfCoo();
- computeRevNum();
}
MEDFileUMesh::~MEDFileUMesh()
* valid**. This is a feature, because MEDLoader does not create cells that do not exist!
* To build a valid MEDCouplingUMesh from the returned one in this case,
* call MEDCouplingUMesh::Build0DMeshFromCoords().
- * \param [in] meshDimRelToMax - the relative dimension of interest.
+ * \param [in] meshDimRelToMaxExt - the relative dimension of interest.
* \param [in] renum - if \c true, the returned mesh is permuted according to the
* optional numbers of mesh entities.
* \return MEDCouplingUMesh * - a pointer to MEDCouplingUMesh that the caller is to
throw INTERP_KERNEL::Exception("MEDFileUMesh::setRenumFieldArr : the coordinates have not been set !");
renumArr->checkNbOfTuplesAndComp(_coords->getNumberOfTuples(),1,"MEDFileUMesh::setRenumArr : Problem in size of node numbering arr ! ");
_num_coords.takeRef(renumArr);
- computeRevNum();
return ;
}
if(meshDimRelToMaxExt>1)
mcIdType nbCells=mesh->getNumberOfCellsOfSubLevelMesh();
nameArr->checkNbOfTuplesAndComp(nbCells,MED_SNAME_SIZE,"MEDFileStructuredMesh::setNameFieldAtLevel : Problem in size of names arr ! Mismatch with number of faces of mesh !");
_names_faces=nameArr;
+ break;
}
default:
throw INTERP_KERNEL::Exception("MEDFileStructuredMesh::setNameFieldAtLevel : Only available for levels 0 or 1 or -1 !");
}
}
+/*!
+ * Returns all relative mesh levels (**excluding nodes**) where given families are defined.
+ * To include nodes, call getFamsNonEmptyLevelsExt() method.
+ * \param [in] fams - the name of the family of interest.
+ * \return std::vector<int> - a sequence of the relative dimensions.
+ */
std::vector<mcIdType> MEDFileStructuredMesh::getFamsNonEmptyLevels(const std::vector<std::string>& fams) const
{
- std::vector<mcIdType> ret;
+ std::vector<mcIdType> lvls;
+ std::vector<mcIdType> famIds(getFamiliesIds(fams));
const DataArrayIdType *famCells(_fam_cells),*famFaces(_fam_faces);
- if(famCells && famCells->presenceOfValue(ret))
- ret.push_back(0);
- if(famFaces && famFaces->presenceOfValue(ret))
- ret.push_back(-1);
- return ret;
+ if(famCells && famCells->presenceOfValue(famIds))
+ lvls.push_back(0);
+ if(famFaces && famFaces->presenceOfValue(famIds))
+ lvls.push_back(-1);
+ return lvls;
}
+/*!
+ * Returns all relative mesh levels (including nodes) where given families are defined.
+ * \param [in] fams - the names of the families of interest.
+ * \return std::vector<int> - a sequence of the relative dimensions.
+ */
std::vector<mcIdType> MEDFileStructuredMesh::getFamsNonEmptyLevelsExt(const std::vector<std::string>& fams) const
{
- std::vector<mcIdType> ret(getFamsNonEmptyLevels(fams));
+ std::vector<mcIdType> lvls(getFamsNonEmptyLevels(fams));
+ std::vector<mcIdType> famIds(getFamiliesIds(fams));
const DataArrayIdType *famNodes(_fam_nodes);
- if(famNodes && famNodes->presenceOfValue(ret))
- ret.push_back(1);
- return ret;
+ if(famNodes && famNodes->presenceOfValue(famIds))
+ lvls.push_back(1);
+ return lvls;
}
/*!
int MEDFileCurveLinearMesh::getMeshDimension() const
{
if(!((const MEDCouplingCurveLinearMesh*)_clmesh))
- throw INTERP_KERNEL::Exception("MEDFileCurveLinearMesh::getMeshDimension : unable to get meshdimension because no mesh set !");
+ throw INTERP_KERNEL::Exception("MEDFileCurveLinearMesh::getMeshDimension : unable to get mesh dimension because no mesh set !");
return _clmesh->getMeshDimension();
}
+int MEDFileCurveLinearMesh::getSpaceDimension() const
+{
+ if(!((const MEDCouplingCurveLinearMesh*)_clmesh))
+ throw INTERP_KERNEL::Exception("MEDFileCurveLinearMesh::getMeshDimension : unable to get space dimension because no mesh set !");
+ return _clmesh->getSpaceDimension();
+}
+
std::string MEDFileCurveLinearMesh::simpleRepr() const
{
return MEDFileStructuredMesh::simpleRepr();