From fa50a93f4d638f7d4d5942c6b67f72cd34654b6d Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Mon, 21 Jun 2021 22:54:32 +0200 Subject: [PATCH 1/1] [EDF23738] : multi geometric type in a single mesh having structure elements on each geometric type --- src/MEDLoader/MEDFileMeshSupport.cxx | 12 ++++++------ src/MEDLoader/MEDFileMeshSupport.hxx | 2 +- src/MEDLoader/MEDFileStructureElement.cxx | 2 +- src/MEDLoader/MEDFileStructureElement.hxx | 1 + 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/MEDLoader/MEDFileMeshSupport.cxx b/src/MEDLoader/MEDFileMeshSupport.cxx index 36258715b..a1b054593 100644 --- a/src/MEDLoader/MEDFileMeshSupport.cxx +++ b/src/MEDLoader/MEDFileMeshSupport.cxx @@ -120,7 +120,7 @@ const MEDFileUMesh *MEDFileMeshSupports::getSupMeshWithName(const std::string& n throw INTERP_KERNEL::Exception(oss.str()); } -mcIdType MEDFileMeshSupports::getNumberOfNodesInConnOf(TypeOfField entity, const std::string& name) const +mcIdType MEDFileMeshSupports::getNumberOfNodesInConnOf(TypeOfField entity, INTERP_KERNEL::NormalizedCellType gt, const std::string& name) const { const MEDFileUMesh *sup(getSupMeshWithName(name)); switch(entity) @@ -129,11 +129,11 @@ mcIdType MEDFileMeshSupports::getNumberOfNodesInConnOf(TypeOfField entity, const return sup->getNumberOfNodes(); case ON_CELLS: { - std::vector gt(sup->getAllGeoTypes()); - if(gt.size()!=1) - throw INTERP_KERNEL::Exception("MEDFileMeshSupports::getNumberOfNodesInConnOf : on cells only one geometric type allowed !"); - const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(gt[0])); - return sup->getNumberOfCellsAtLevel(0)*cm.getNumberOfNodes(); + std::vector gts(sup->getAllGeoTypes()); + if(std::find(gts.begin(),gts.end(),gt) == gts.end()) + throw INTERP_KERNEL::Exception("MEDFileMeshSupports::getNumberOfNodesInConnOf : specified geometric type not found !"); + const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(gt)); + return sup->getNumberOfCellsWithType(gt)*cm.getNumberOfNodes(); } default: throw INTERP_KERNEL::Exception("MEDFileMeshSupports::getNumberOfNodesInConnOf : not recognized entity type !"); diff --git a/src/MEDLoader/MEDFileMeshSupport.hxx b/src/MEDLoader/MEDFileMeshSupport.hxx index 8d81c4e78..584f906c4 100644 --- a/src/MEDLoader/MEDFileMeshSupport.hxx +++ b/src/MEDLoader/MEDFileMeshSupport.hxx @@ -42,7 +42,7 @@ namespace MEDCoupling MEDLOADER_EXPORT void writeLL(med_idt fid) const; MEDLOADER_EXPORT std::vector getSupMeshNames() const; MEDLOADER_EXPORT const MEDFileUMesh *getSupMeshWithName(const std::string& name) const; - MEDLOADER_EXPORT mcIdType getNumberOfNodesInConnOf(TypeOfField entity, const std::string& name) const; + MEDLOADER_EXPORT mcIdType getNumberOfNodesInConnOf(TypeOfField entity, INTERP_KERNEL::NormalizedCellType gt, const std::string& name) const; private: MEDFileMeshSupports(med_idt fid); MEDFileMeshSupports(); diff --git a/src/MEDLoader/MEDFileStructureElement.cxx b/src/MEDLoader/MEDFileStructureElement.cxx index 107b5ffbd..3a5b92b83 100644 --- a/src/MEDLoader/MEDFileStructureElement.cxx +++ b/src/MEDLoader/MEDFileStructureElement.cxx @@ -383,7 +383,7 @@ mcIdType MEDFileStructureElements::getNumberOfNodesPerSE(const std::string& seNa return 1; const MEDFileStructureElement *se(getSEWithName(seName)); std::string meshName(se->getMeshName()); - return _sup->getNumberOfNodesInConnOf(se->getEntity(),meshName); + return _sup->getNumberOfNodesInConnOf(se->getEntity(),se->getGeoType(),meshName); } const MEDFileStructureElement *MEDFileStructureElements::getSEWithName(const std::string& seName) const diff --git a/src/MEDLoader/MEDFileStructureElement.hxx b/src/MEDLoader/MEDFileStructureElement.hxx index 384f056c1..8cd799e20 100644 --- a/src/MEDLoader/MEDFileStructureElement.hxx +++ b/src/MEDLoader/MEDFileStructureElement.hxx @@ -95,6 +95,7 @@ class MEDFileSEConstAtt : public RefCountObject, public MEDFileWritableStandAlon MEDLOADER_EXPORT std::vector getVarAtts() const; MEDLOADER_EXPORT const MEDFileSEVarAtt *getVarAtt(const std::string& varName) const; MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileStructureElement"); } + MEDLOADER_EXPORT INTERP_KERNEL::NormalizedCellType getGeoType() const { return _geo_type; } public: std::vector getDirectChildrenWithNull() const; std::size_t getHeapMemorySizeWithoutChildren() const; -- 2.39.2