std::string meshName(MEDLoaderBase::buildStringFromFortran(maa,MED_NAME_SIZE));
MEDFileUMeshL2::WriteCoords(fid,meshName,_iteration,_order,_time,_coords,_fam_coords,_num_coords,_name_coords,_global_num_coords);
for(std::vector< MCAuto<MEDFileUMeshSplitL1> >::const_iterator it=_ms.begin();it!=_ms.end();it++)
- if((const MEDFileUMeshSplitL1 *)(*it)!=0)
+ if(it->isNotNull())
+ {
+ (*it)->checkCoordsConsistency(coo);
(*it)->write(fid,meshName,mdim);
+ }
MEDFileUMeshL2::WriteFamiliesAndGrps(fid,meshName,_families,_groups,_too_long_str);
}
*w=famIdTrad[*w];
}
+void MEDFileUMeshSplitL1::checkCoordsConsistency(const DataArrayDouble *coords) const
+{
+ std::vector<MEDCoupling1GTUMesh *> ms(_m_by_types.getParts());
+ for(auto mesh : ms)
+ {
+ if(mesh)
+ if(mesh->getCoords() != coords)
+ mesh->getCoords()->checkNbOfTuplesAndComp(*coords,"MEDFileUMeshSplitL1::checkCoordsConsistency : mismatch between coordinates instance in MEDFileUMesh and instance in subparts");
+ }
+}
+
void MEDFileUMeshSplitL1::write(med_idt fid, const std::string& mName, int mdim) const
{
std::vector<MEDCoupling1GTUMesh *> ms(_m_by_types.getParts());
void eraseFamilyField();
void setGroupsFromScratch(const std::vector<const MEDCouplingUMesh *>& ms, std::map<std::string,mcIdType>& familyIds,
std::map<std::string, std::vector<std::string> >& groups);
+ void checkCoordsConsistency(const DataArrayDouble *coords) const;
void write(med_idt fid, const std::string& mName, int mdim) const;
//
void setFamilyArr(DataArrayIdType *famArr);
self.assertTrue( cas1.getGroupArr(0,"GCELL2").isEqual(gcell2) )
self.assertTrue( cas1.getGroupArr(0,"GCELL3").isEqual(gcell3) )
+ @WriteInTmpDir
+ def test46(self):
+ """
+ EDF26362 : unconsistency between DataArrayDouble instance in MEDFileUMesh and those of MEDCouplingUMesh or MEDCoupling1GTUMesh used at write time
+ """
+ fname = "test46.med"
+ arr=DataArrayDouble([0,1,1,2,3])
+ m = MEDCouplingUMesh.Build1DMeshFromCoords(arr)
+ mm = MEDFileUMesh()
+ mm[0] = m
+ m.mergeNodes(1e-5) # coords into m has been modified so coords of mm and m mismatches
+ self.assertRaises(InterpKernelException,mm.write,fname,2) # write fails due to mismatch of number of tuples of coords of mm and those of m
+
pass
if __name__ == "__main__":